client.js 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848
  1. var SubscriptionsTransportWs =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter
  44. /******/ });
  45. /******/ }
  46. /******/ };
  47. /******/
  48. /******/ // getDefaultExport function for compatibility with non-harmony modules
  49. /******/ __webpack_require__.n = function(module) {
  50. /******/ var getter = module && module.__esModule ?
  51. /******/ function getDefault() { return module['default']; } :
  52. /******/ function getModuleExports() { return module; };
  53. /******/ __webpack_require__.d(getter, 'a', getter);
  54. /******/ return getter;
  55. /******/ };
  56. /******/
  57. /******/ // Object.prototype.hasOwnProperty.call
  58. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  59. /******/
  60. /******/ // __webpack_public_path__
  61. /******/ __webpack_require__.p = "";
  62. /******/
  63. /******/ // Load entry module and return exports
  64. /******/ return __webpack_require__(__webpack_require__.s = 2);
  65. /******/ })
  66. /************************************************************************/
  67. /******/ ([
  68. /* 0 */
  69. /***/ (function(module, exports) {
  70. var g;
  71. // This works in non-strict mode
  72. g = (function() {
  73. return this;
  74. })();
  75. try {
  76. // This works if eval is allowed (see CSP)
  77. g = g || Function("return this")() || (1,eval)("this");
  78. } catch(e) {
  79. // This works if the window reference is available
  80. if(typeof window === "object")
  81. g = window;
  82. }
  83. // g can still be undefined, but nothing to do about it...
  84. // We return undefined, instead of nothing here, so it's
  85. // easier to handle this case. if(!global) { ...}
  86. module.exports = g;
  87. /***/ }),
  88. /* 1 */
  89. /***/ (function(module, exports, __webpack_require__) {
  90. "use strict";
  91. Object.defineProperty(exports, '__esModule', {
  92. value: true,
  93. });
  94. exports.Kind = void 0;
  95. /**
  96. * The set of allowed kind values for AST nodes.
  97. */
  98. let Kind;
  99. /**
  100. * The enum type representing the possible kind values of AST nodes.
  101. *
  102. * @deprecated Please use `Kind`. Will be remove in v17.
  103. */
  104. exports.Kind = Kind;
  105. (function (Kind) {
  106. Kind['NAME'] = 'Name';
  107. Kind['DOCUMENT'] = 'Document';
  108. Kind['OPERATION_DEFINITION'] = 'OperationDefinition';
  109. Kind['VARIABLE_DEFINITION'] = 'VariableDefinition';
  110. Kind['SELECTION_SET'] = 'SelectionSet';
  111. Kind['FIELD'] = 'Field';
  112. Kind['ARGUMENT'] = 'Argument';
  113. Kind['FRAGMENT_SPREAD'] = 'FragmentSpread';
  114. Kind['INLINE_FRAGMENT'] = 'InlineFragment';
  115. Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition';
  116. Kind['VARIABLE'] = 'Variable';
  117. Kind['INT'] = 'IntValue';
  118. Kind['FLOAT'] = 'FloatValue';
  119. Kind['STRING'] = 'StringValue';
  120. Kind['BOOLEAN'] = 'BooleanValue';
  121. Kind['NULL'] = 'NullValue';
  122. Kind['ENUM'] = 'EnumValue';
  123. Kind['LIST'] = 'ListValue';
  124. Kind['OBJECT'] = 'ObjectValue';
  125. Kind['OBJECT_FIELD'] = 'ObjectField';
  126. Kind['DIRECTIVE'] = 'Directive';
  127. Kind['NAMED_TYPE'] = 'NamedType';
  128. Kind['LIST_TYPE'] = 'ListType';
  129. Kind['NON_NULL_TYPE'] = 'NonNullType';
  130. Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition';
  131. Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition';
  132. Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition';
  133. Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition';
  134. Kind['FIELD_DEFINITION'] = 'FieldDefinition';
  135. Kind['INPUT_VALUE_DEFINITION'] = 'InputValueDefinition';
  136. Kind['INTERFACE_TYPE_DEFINITION'] = 'InterfaceTypeDefinition';
  137. Kind['UNION_TYPE_DEFINITION'] = 'UnionTypeDefinition';
  138. Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition';
  139. Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition';
  140. Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
  141. Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
  142. Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
  143. Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
  144. Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
  145. Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
  146. Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension';
  147. Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
  148. Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
  149. })(Kind || (exports.Kind = Kind = {}));
  150. /***/ }),
  151. /* 2 */
  152. /***/ (function(module, exports, __webpack_require__) {
  153. "use strict";
  154. /* WEBPACK VAR INJECTION */(function(global) {
  155. var __assign = (this && this.__assign) || function () {
  156. __assign = Object.assign || function(t) {
  157. for (var s, i = 1, n = arguments.length; i < n; i++) {
  158. s = arguments[i];
  159. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  160. t[p] = s[p];
  161. }
  162. return t;
  163. };
  164. return __assign.apply(this, arguments);
  165. };
  166. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  167. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  168. return new (P || (P = Promise))(function (resolve, reject) {
  169. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  170. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  171. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  172. step((generator = generator.apply(thisArg, _arguments || [])).next());
  173. });
  174. };
  175. var __generator = (this && this.__generator) || function (thisArg, body) {
  176. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  177. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  178. function verb(n) { return function (v) { return step([n, v]); }; }
  179. function step(op) {
  180. if (f) throw new TypeError("Generator is already executing.");
  181. while (_) try {
  182. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  183. if (y = 0, t) op = [op[0] & 2, t.value];
  184. switch (op[0]) {
  185. case 0: case 1: t = op; break;
  186. case 4: _.label++; return { value: op[1], done: false };
  187. case 5: _.label++; y = op[1]; op = [0]; continue;
  188. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  189. default:
  190. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  191. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  192. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  193. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  194. if (t[2]) _.ops.pop();
  195. _.trys.pop(); continue;
  196. }
  197. op = body.call(thisArg, _);
  198. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  199. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  200. }
  201. };
  202. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  203. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  204. if (ar || !(i in from)) {
  205. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  206. ar[i] = from[i];
  207. }
  208. }
  209. return to.concat(ar || Array.prototype.slice.call(from));
  210. };
  211. Object.defineProperty(exports, "__esModule", { value: true });
  212. exports.SubscriptionClient = void 0;
  213. var _global = typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : {});
  214. var NativeWebSocket = _global.WebSocket || _global.MozWebSocket;
  215. var Backoff = __webpack_require__(3);
  216. var eventemitter3_1 = __webpack_require__(4);
  217. var is_string_1 = __webpack_require__(5);
  218. var is_object_1 = __webpack_require__(6);
  219. var printer_1 = __webpack_require__(7);
  220. var getOperationAST_1 = __webpack_require__(14);
  221. var symbol_observable_1 = __webpack_require__(15);
  222. var protocol_1 = __webpack_require__(18);
  223. var defaults_1 = __webpack_require__(19);
  224. var message_types_1 = __webpack_require__(20);
  225. var SubscriptionClient = (function () {
  226. function SubscriptionClient(url, options, webSocketImpl, webSocketProtocols) {
  227. var _a = (options || {}), _b = _a.connectionCallback, connectionCallback = _b === void 0 ? undefined : _b, _c = _a.connectionParams, connectionParams = _c === void 0 ? {} : _c, _d = _a.minTimeout, minTimeout = _d === void 0 ? defaults_1.MIN_WS_TIMEOUT : _d, _e = _a.timeout, timeout = _e === void 0 ? defaults_1.WS_TIMEOUT : _e, _f = _a.reconnect, reconnect = _f === void 0 ? false : _f, _g = _a.reconnectionAttempts, reconnectionAttempts = _g === void 0 ? Infinity : _g, _h = _a.lazy, lazy = _h === void 0 ? false : _h, _j = _a.inactivityTimeout, inactivityTimeout = _j === void 0 ? 0 : _j, _k = _a.wsOptionArguments, wsOptionArguments = _k === void 0 ? [] : _k;
  228. this.wsImpl = webSocketImpl || NativeWebSocket;
  229. if (!this.wsImpl) {
  230. throw new Error('Unable to find native implementation, or alternative implementation for WebSocket!');
  231. }
  232. this.wsProtocols = webSocketProtocols || protocol_1.GRAPHQL_WS;
  233. this.connectionCallback = connectionCallback;
  234. this.url = url;
  235. this.operations = {};
  236. this.nextOperationId = 0;
  237. this.minWsTimeout = minTimeout;
  238. this.wsTimeout = timeout;
  239. this.unsentMessagesQueue = [];
  240. this.reconnect = reconnect;
  241. this.reconnecting = false;
  242. this.reconnectionAttempts = reconnectionAttempts;
  243. this.lazy = !!lazy;
  244. this.inactivityTimeout = inactivityTimeout;
  245. this.closedByUser = false;
  246. this.backoff = new Backoff({ jitter: 0.5 });
  247. this.eventEmitter = new eventemitter3_1.EventEmitter();
  248. this.middlewares = [];
  249. this.client = null;
  250. this.maxConnectTimeGenerator = this.createMaxConnectTimeGenerator();
  251. this.connectionParams = this.getConnectionParams(connectionParams);
  252. this.wsOptionArguments = wsOptionArguments;
  253. if (!this.lazy) {
  254. this.connect();
  255. }
  256. }
  257. Object.defineProperty(SubscriptionClient.prototype, "status", {
  258. get: function () {
  259. if (this.client === null) {
  260. return this.wsImpl.CLOSED;
  261. }
  262. return this.client.readyState;
  263. },
  264. enumerable: false,
  265. configurable: true
  266. });
  267. SubscriptionClient.prototype.close = function (isForced, closedByUser) {
  268. if (isForced === void 0) { isForced = true; }
  269. if (closedByUser === void 0) { closedByUser = true; }
  270. this.clearInactivityTimeout();
  271. if (this.client !== null) {
  272. this.closedByUser = closedByUser;
  273. if (isForced) {
  274. this.clearCheckConnectionInterval();
  275. this.clearMaxConnectTimeout();
  276. this.clearTryReconnectTimeout();
  277. this.unsubscribeAll();
  278. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_TERMINATE, null);
  279. }
  280. this.client.close();
  281. this.client.onopen = null;
  282. this.client.onclose = null;
  283. this.client.onerror = null;
  284. this.client.onmessage = null;
  285. this.client = null;
  286. this.eventEmitter.emit('disconnected');
  287. if (!isForced) {
  288. this.tryReconnect();
  289. }
  290. }
  291. };
  292. SubscriptionClient.prototype.request = function (request) {
  293. var _a;
  294. var getObserver = this.getObserver.bind(this);
  295. var executeOperation = this.executeOperation.bind(this);
  296. var unsubscribe = this.unsubscribe.bind(this);
  297. var opId;
  298. this.clearInactivityTimeout();
  299. return _a = {},
  300. _a[symbol_observable_1.default] = function () {
  301. return this;
  302. },
  303. _a.subscribe = function (observerOrNext, onError, onComplete) {
  304. var observer = getObserver(observerOrNext, onError, onComplete);
  305. opId = executeOperation(request, function (error, result) {
  306. if (error === null && result === null) {
  307. if (observer.complete) {
  308. observer.complete();
  309. }
  310. }
  311. else if (error) {
  312. if (observer.error) {
  313. observer.error(error[0]);
  314. }
  315. }
  316. else {
  317. if (observer.next) {
  318. observer.next(result);
  319. }
  320. }
  321. });
  322. return {
  323. unsubscribe: function () {
  324. if (opId) {
  325. unsubscribe(opId);
  326. opId = null;
  327. }
  328. },
  329. };
  330. },
  331. _a;
  332. };
  333. SubscriptionClient.prototype.on = function (eventName, callback, context) {
  334. var handler = this.eventEmitter.on(eventName, callback, context);
  335. return function () {
  336. handler.off(eventName, callback, context);
  337. };
  338. };
  339. SubscriptionClient.prototype.onConnected = function (callback, context) {
  340. return this.on('connected', callback, context);
  341. };
  342. SubscriptionClient.prototype.onConnecting = function (callback, context) {
  343. return this.on('connecting', callback, context);
  344. };
  345. SubscriptionClient.prototype.onDisconnected = function (callback, context) {
  346. return this.on('disconnected', callback, context);
  347. };
  348. SubscriptionClient.prototype.onReconnected = function (callback, context) {
  349. return this.on('reconnected', callback, context);
  350. };
  351. SubscriptionClient.prototype.onReconnecting = function (callback, context) {
  352. return this.on('reconnecting', callback, context);
  353. };
  354. SubscriptionClient.prototype.onError = function (callback, context) {
  355. return this.on('error', callback, context);
  356. };
  357. SubscriptionClient.prototype.unsubscribeAll = function () {
  358. var _this = this;
  359. Object.keys(this.operations).forEach(function (subId) {
  360. _this.unsubscribe(subId);
  361. });
  362. };
  363. SubscriptionClient.prototype.applyMiddlewares = function (options) {
  364. var _this = this;
  365. return new Promise(function (resolve, reject) {
  366. var queue = function (funcs, scope) {
  367. var next = function (error) {
  368. if (error) {
  369. reject(error);
  370. }
  371. else {
  372. if (funcs.length > 0) {
  373. var f = funcs.shift();
  374. if (f) {
  375. f.applyMiddleware.apply(scope, [options, next]);
  376. }
  377. }
  378. else {
  379. resolve(options);
  380. }
  381. }
  382. };
  383. next();
  384. };
  385. queue(__spreadArray([], _this.middlewares, true), _this);
  386. });
  387. };
  388. SubscriptionClient.prototype.use = function (middlewares) {
  389. var _this = this;
  390. middlewares.map(function (middleware) {
  391. if (typeof middleware.applyMiddleware === 'function') {
  392. _this.middlewares.push(middleware);
  393. }
  394. else {
  395. throw new Error('Middleware must implement the applyMiddleware function.');
  396. }
  397. });
  398. return this;
  399. };
  400. SubscriptionClient.prototype.getConnectionParams = function (connectionParams) {
  401. return function () { return new Promise(function (resolve, reject) {
  402. if (typeof connectionParams === 'function') {
  403. try {
  404. return resolve(connectionParams.call(null));
  405. }
  406. catch (error) {
  407. return reject(error);
  408. }
  409. }
  410. resolve(connectionParams);
  411. }); };
  412. };
  413. SubscriptionClient.prototype.executeOperation = function (options, handler) {
  414. var _this = this;
  415. if (this.client === null) {
  416. this.connect();
  417. }
  418. var opId = this.generateOperationId();
  419. this.operations[opId] = { options: options, handler: handler };
  420. this.applyMiddlewares(options)
  421. .then(function (processedOptions) {
  422. _this.checkOperationOptions(processedOptions, handler);
  423. if (_this.operations[opId]) {
  424. _this.operations[opId] = { options: processedOptions, handler: handler };
  425. _this.sendMessage(opId, message_types_1.default.GQL_START, processedOptions);
  426. }
  427. })
  428. .catch(function (error) {
  429. _this.unsubscribe(opId);
  430. handler(_this.formatErrors(error));
  431. });
  432. return opId;
  433. };
  434. SubscriptionClient.prototype.getObserver = function (observerOrNext, error, complete) {
  435. if (typeof observerOrNext === 'function') {
  436. return {
  437. next: function (v) { return observerOrNext(v); },
  438. error: function (e) { return error && error(e); },
  439. complete: function () { return complete && complete(); },
  440. };
  441. }
  442. return observerOrNext;
  443. };
  444. SubscriptionClient.prototype.createMaxConnectTimeGenerator = function () {
  445. var minValue = this.minWsTimeout;
  446. var maxValue = this.wsTimeout;
  447. return new Backoff({
  448. min: minValue,
  449. max: maxValue,
  450. factor: 1.2,
  451. });
  452. };
  453. SubscriptionClient.prototype.clearCheckConnectionInterval = function () {
  454. if (this.checkConnectionIntervalId) {
  455. clearInterval(this.checkConnectionIntervalId);
  456. this.checkConnectionIntervalId = null;
  457. }
  458. };
  459. SubscriptionClient.prototype.clearMaxConnectTimeout = function () {
  460. if (this.maxConnectTimeoutId) {
  461. clearTimeout(this.maxConnectTimeoutId);
  462. this.maxConnectTimeoutId = null;
  463. }
  464. };
  465. SubscriptionClient.prototype.clearTryReconnectTimeout = function () {
  466. if (this.tryReconnectTimeoutId) {
  467. clearTimeout(this.tryReconnectTimeoutId);
  468. this.tryReconnectTimeoutId = null;
  469. }
  470. };
  471. SubscriptionClient.prototype.clearInactivityTimeout = function () {
  472. if (this.inactivityTimeoutId) {
  473. clearTimeout(this.inactivityTimeoutId);
  474. this.inactivityTimeoutId = null;
  475. }
  476. };
  477. SubscriptionClient.prototype.setInactivityTimeout = function () {
  478. var _this = this;
  479. if (this.inactivityTimeout > 0 && Object.keys(this.operations).length === 0) {
  480. this.inactivityTimeoutId = setTimeout(function () {
  481. if (Object.keys(_this.operations).length === 0) {
  482. _this.close();
  483. }
  484. }, this.inactivityTimeout);
  485. }
  486. };
  487. SubscriptionClient.prototype.checkOperationOptions = function (options, handler) {
  488. var query = options.query, variables = options.variables, operationName = options.operationName;
  489. if (!query) {
  490. throw new Error('Must provide a query.');
  491. }
  492. if (!handler) {
  493. throw new Error('Must provide an handler.');
  494. }
  495. if ((!(0, is_string_1.default)(query) && !(0, getOperationAST_1.getOperationAST)(query, operationName)) ||
  496. (operationName && !(0, is_string_1.default)(operationName)) ||
  497. (variables && !(0, is_object_1.default)(variables))) {
  498. throw new Error('Incorrect option types. query must be a string or a document,' +
  499. '`operationName` must be a string, and `variables` must be an object.');
  500. }
  501. };
  502. SubscriptionClient.prototype.buildMessage = function (id, type, payload) {
  503. var payloadToReturn = payload && payload.query ? __assign(__assign({}, payload), { query: typeof payload.query === 'string' ? payload.query : (0, printer_1.print)(payload.query) }) :
  504. payload;
  505. return {
  506. id: id,
  507. type: type,
  508. payload: payloadToReturn,
  509. };
  510. };
  511. SubscriptionClient.prototype.formatErrors = function (errors) {
  512. if (Array.isArray(errors)) {
  513. return errors;
  514. }
  515. if (errors && errors.errors) {
  516. return this.formatErrors(errors.errors);
  517. }
  518. if (errors && errors.message) {
  519. return [errors];
  520. }
  521. return [{
  522. name: 'FormatedError',
  523. message: 'Unknown error',
  524. originalError: errors,
  525. }];
  526. };
  527. SubscriptionClient.prototype.sendMessage = function (id, type, payload) {
  528. this.sendMessageRaw(this.buildMessage(id, type, payload));
  529. };
  530. SubscriptionClient.prototype.sendMessageRaw = function (message) {
  531. switch (this.status) {
  532. case this.wsImpl.OPEN:
  533. var serializedMessage = JSON.stringify(message);
  534. try {
  535. JSON.parse(serializedMessage);
  536. }
  537. catch (e) {
  538. this.eventEmitter.emit('error', new Error("Message must be JSON-serializable. Got: " + message));
  539. }
  540. this.client.send(serializedMessage);
  541. break;
  542. case this.wsImpl.CONNECTING:
  543. this.unsentMessagesQueue.push(message);
  544. break;
  545. default:
  546. if (!this.reconnecting) {
  547. this.eventEmitter.emit('error', new Error('A message was not sent because socket is not connected, is closing or ' +
  548. 'is already closed. Message was: ' + JSON.stringify(message)));
  549. }
  550. }
  551. };
  552. SubscriptionClient.prototype.generateOperationId = function () {
  553. return String(++this.nextOperationId);
  554. };
  555. SubscriptionClient.prototype.tryReconnect = function () {
  556. var _this = this;
  557. if (!this.reconnect || this.backoff.attempts >= this.reconnectionAttempts) {
  558. return;
  559. }
  560. if (!this.reconnecting) {
  561. Object.keys(this.operations).forEach(function (key) {
  562. _this.unsentMessagesQueue.push(_this.buildMessage(key, message_types_1.default.GQL_START, _this.operations[key].options));
  563. });
  564. this.reconnecting = true;
  565. }
  566. this.clearTryReconnectTimeout();
  567. var delay = this.backoff.duration();
  568. this.tryReconnectTimeoutId = setTimeout(function () {
  569. _this.connect();
  570. }, delay);
  571. };
  572. SubscriptionClient.prototype.flushUnsentMessagesQueue = function () {
  573. var _this = this;
  574. this.unsentMessagesQueue.forEach(function (message) {
  575. _this.sendMessageRaw(message);
  576. });
  577. this.unsentMessagesQueue = [];
  578. };
  579. SubscriptionClient.prototype.checkConnection = function () {
  580. if (this.wasKeepAliveReceived) {
  581. this.wasKeepAliveReceived = false;
  582. return;
  583. }
  584. if (!this.reconnecting) {
  585. this.close(false, true);
  586. }
  587. };
  588. SubscriptionClient.prototype.checkMaxConnectTimeout = function () {
  589. var _this = this;
  590. this.clearMaxConnectTimeout();
  591. this.maxConnectTimeoutId = setTimeout(function () {
  592. if (_this.status !== _this.wsImpl.OPEN) {
  593. _this.reconnecting = true;
  594. _this.close(false, true);
  595. }
  596. }, this.maxConnectTimeGenerator.duration());
  597. };
  598. SubscriptionClient.prototype.connect = function () {
  599. var _a;
  600. var _this = this;
  601. this.client = new ((_a = this.wsImpl).bind.apply(_a, __spreadArray([void 0, this.url, this.wsProtocols], this.wsOptionArguments, false)))();
  602. this.checkMaxConnectTimeout();
  603. this.client.onopen = function () { return __awaiter(_this, void 0, void 0, function () {
  604. var connectionParams, error_1;
  605. return __generator(this, function (_a) {
  606. switch (_a.label) {
  607. case 0:
  608. if (!(this.status === this.wsImpl.OPEN)) return [3, 4];
  609. this.clearMaxConnectTimeout();
  610. this.closedByUser = false;
  611. this.eventEmitter.emit(this.reconnecting ? 'reconnecting' : 'connecting');
  612. _a.label = 1;
  613. case 1:
  614. _a.trys.push([1, 3, , 4]);
  615. return [4, this.connectionParams()];
  616. case 2:
  617. connectionParams = _a.sent();
  618. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_INIT, connectionParams);
  619. this.flushUnsentMessagesQueue();
  620. return [3, 4];
  621. case 3:
  622. error_1 = _a.sent();
  623. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_ERROR, error_1);
  624. this.flushUnsentMessagesQueue();
  625. return [3, 4];
  626. case 4: return [2];
  627. }
  628. });
  629. }); };
  630. this.client.onclose = function () {
  631. if (!_this.closedByUser) {
  632. _this.close(false, false);
  633. }
  634. };
  635. this.client.onerror = function (err) {
  636. _this.eventEmitter.emit('error', err);
  637. };
  638. this.client.onmessage = function (_a) {
  639. var data = _a.data;
  640. _this.processReceivedData(data);
  641. };
  642. };
  643. SubscriptionClient.prototype.processReceivedData = function (receivedData) {
  644. var parsedMessage;
  645. var opId;
  646. try {
  647. parsedMessage = JSON.parse(receivedData);
  648. opId = parsedMessage.id;
  649. }
  650. catch (e) {
  651. throw new Error("Message must be JSON-parseable. Got: " + receivedData);
  652. }
  653. if ([message_types_1.default.GQL_DATA,
  654. message_types_1.default.GQL_COMPLETE,
  655. message_types_1.default.GQL_ERROR,
  656. ].indexOf(parsedMessage.type) !== -1 && !this.operations[opId]) {
  657. this.unsubscribe(opId);
  658. return;
  659. }
  660. switch (parsedMessage.type) {
  661. case message_types_1.default.GQL_CONNECTION_ERROR:
  662. if (this.connectionCallback) {
  663. this.connectionCallback(parsedMessage.payload);
  664. }
  665. break;
  666. case message_types_1.default.GQL_CONNECTION_ACK:
  667. this.eventEmitter.emit(this.reconnecting ? 'reconnected' : 'connected', parsedMessage.payload);
  668. this.reconnecting = false;
  669. this.backoff.reset();
  670. this.maxConnectTimeGenerator.reset();
  671. if (this.connectionCallback) {
  672. this.connectionCallback();
  673. }
  674. break;
  675. case message_types_1.default.GQL_COMPLETE:
  676. var handler = this.operations[opId].handler;
  677. delete this.operations[opId];
  678. handler.call(this, null, null);
  679. break;
  680. case message_types_1.default.GQL_ERROR:
  681. this.operations[opId].handler(this.formatErrors(parsedMessage.payload), null);
  682. delete this.operations[opId];
  683. break;
  684. case message_types_1.default.GQL_DATA:
  685. var parsedPayload = !parsedMessage.payload.errors ?
  686. parsedMessage.payload : __assign(__assign({}, parsedMessage.payload), { errors: this.formatErrors(parsedMessage.payload.errors) });
  687. this.operations[opId].handler(null, parsedPayload);
  688. break;
  689. case message_types_1.default.GQL_CONNECTION_KEEP_ALIVE:
  690. var firstKA = typeof this.wasKeepAliveReceived === 'undefined';
  691. this.wasKeepAliveReceived = true;
  692. if (firstKA) {
  693. this.checkConnection();
  694. }
  695. if (this.checkConnectionIntervalId) {
  696. clearInterval(this.checkConnectionIntervalId);
  697. this.checkConnection();
  698. }
  699. this.checkConnectionIntervalId = setInterval(this.checkConnection.bind(this), this.wsTimeout);
  700. break;
  701. default:
  702. throw new Error('Invalid message type!');
  703. }
  704. };
  705. SubscriptionClient.prototype.unsubscribe = function (opId) {
  706. if (this.operations[opId]) {
  707. delete this.operations[opId];
  708. this.setInactivityTimeout();
  709. this.sendMessage(opId, message_types_1.default.GQL_STOP, undefined);
  710. }
  711. };
  712. return SubscriptionClient;
  713. }());
  714. exports.SubscriptionClient = SubscriptionClient;
  715. //# sourceMappingURL=client.js.map
  716. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  717. /***/ }),
  718. /* 3 */
  719. /***/ (function(module, exports) {
  720. /**
  721. * Expose `Backoff`.
  722. */
  723. module.exports = Backoff;
  724. /**
  725. * Initialize backoff timer with `opts`.
  726. *
  727. * - `min` initial timeout in milliseconds [100]
  728. * - `max` max timeout [10000]
  729. * - `jitter` [0]
  730. * - `factor` [2]
  731. *
  732. * @param {Object} opts
  733. * @api public
  734. */
  735. function Backoff(opts) {
  736. opts = opts || {};
  737. this.ms = opts.min || 100;
  738. this.max = opts.max || 10000;
  739. this.factor = opts.factor || 2;
  740. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  741. this.attempts = 0;
  742. }
  743. /**
  744. * Return the backoff duration.
  745. *
  746. * @return {Number}
  747. * @api public
  748. */
  749. Backoff.prototype.duration = function(){
  750. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  751. if (this.jitter) {
  752. var rand = Math.random();
  753. var deviation = Math.floor(rand * this.jitter * ms);
  754. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  755. }
  756. return Math.min(ms, this.max) | 0;
  757. };
  758. /**
  759. * Reset the number of attempts.
  760. *
  761. * @api public
  762. */
  763. Backoff.prototype.reset = function(){
  764. this.attempts = 0;
  765. };
  766. /**
  767. * Set the minimum duration
  768. *
  769. * @api public
  770. */
  771. Backoff.prototype.setMin = function(min){
  772. this.ms = min;
  773. };
  774. /**
  775. * Set the maximum duration
  776. *
  777. * @api public
  778. */
  779. Backoff.prototype.setMax = function(max){
  780. this.max = max;
  781. };
  782. /**
  783. * Set the jitter
  784. *
  785. * @api public
  786. */
  787. Backoff.prototype.setJitter = function(jitter){
  788. this.jitter = jitter;
  789. };
  790. /***/ }),
  791. /* 4 */
  792. /***/ (function(module, exports, __webpack_require__) {
  793. "use strict";
  794. var has = Object.prototype.hasOwnProperty
  795. , prefix = '~';
  796. /**
  797. * Constructor to create a storage for our `EE` objects.
  798. * An `Events` instance is a plain object whose properties are event names.
  799. *
  800. * @constructor
  801. * @private
  802. */
  803. function Events() {}
  804. //
  805. // We try to not inherit from `Object.prototype`. In some engines creating an
  806. // instance in this way is faster than calling `Object.create(null)` directly.
  807. // If `Object.create(null)` is not supported we prefix the event names with a
  808. // character to make sure that the built-in object properties are not
  809. // overridden or used as an attack vector.
  810. //
  811. if (Object.create) {
  812. Events.prototype = Object.create(null);
  813. //
  814. // This hack is needed because the `__proto__` property is still inherited in
  815. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  816. //
  817. if (!new Events().__proto__) prefix = false;
  818. }
  819. /**
  820. * Representation of a single event listener.
  821. *
  822. * @param {Function} fn The listener function.
  823. * @param {*} context The context to invoke the listener with.
  824. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  825. * @constructor
  826. * @private
  827. */
  828. function EE(fn, context, once) {
  829. this.fn = fn;
  830. this.context = context;
  831. this.once = once || false;
  832. }
  833. /**
  834. * Add a listener for a given event.
  835. *
  836. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  837. * @param {(String|Symbol)} event The event name.
  838. * @param {Function} fn The listener function.
  839. * @param {*} context The context to invoke the listener with.
  840. * @param {Boolean} once Specify if the listener is a one-time listener.
  841. * @returns {EventEmitter}
  842. * @private
  843. */
  844. function addListener(emitter, event, fn, context, once) {
  845. if (typeof fn !== 'function') {
  846. throw new TypeError('The listener must be a function');
  847. }
  848. var listener = new EE(fn, context || emitter, once)
  849. , evt = prefix ? prefix + event : event;
  850. if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  851. else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  852. else emitter._events[evt] = [emitter._events[evt], listener];
  853. return emitter;
  854. }
  855. /**
  856. * Clear event by name.
  857. *
  858. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  859. * @param {(String|Symbol)} evt The Event name.
  860. * @private
  861. */
  862. function clearEvent(emitter, evt) {
  863. if (--emitter._eventsCount === 0) emitter._events = new Events();
  864. else delete emitter._events[evt];
  865. }
  866. /**
  867. * Minimal `EventEmitter` interface that is molded against the Node.js
  868. * `EventEmitter` interface.
  869. *
  870. * @constructor
  871. * @public
  872. */
  873. function EventEmitter() {
  874. this._events = new Events();
  875. this._eventsCount = 0;
  876. }
  877. /**
  878. * Return an array listing the events for which the emitter has registered
  879. * listeners.
  880. *
  881. * @returns {Array}
  882. * @public
  883. */
  884. EventEmitter.prototype.eventNames = function eventNames() {
  885. var names = []
  886. , events
  887. , name;
  888. if (this._eventsCount === 0) return names;
  889. for (name in (events = this._events)) {
  890. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  891. }
  892. if (Object.getOwnPropertySymbols) {
  893. return names.concat(Object.getOwnPropertySymbols(events));
  894. }
  895. return names;
  896. };
  897. /**
  898. * Return the listeners registered for a given event.
  899. *
  900. * @param {(String|Symbol)} event The event name.
  901. * @returns {Array} The registered listeners.
  902. * @public
  903. */
  904. EventEmitter.prototype.listeners = function listeners(event) {
  905. var evt = prefix ? prefix + event : event
  906. , handlers = this._events[evt];
  907. if (!handlers) return [];
  908. if (handlers.fn) return [handlers.fn];
  909. for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
  910. ee[i] = handlers[i].fn;
  911. }
  912. return ee;
  913. };
  914. /**
  915. * Return the number of listeners listening to a given event.
  916. *
  917. * @param {(String|Symbol)} event The event name.
  918. * @returns {Number} The number of listeners.
  919. * @public
  920. */
  921. EventEmitter.prototype.listenerCount = function listenerCount(event) {
  922. var evt = prefix ? prefix + event : event
  923. , listeners = this._events[evt];
  924. if (!listeners) return 0;
  925. if (listeners.fn) return 1;
  926. return listeners.length;
  927. };
  928. /**
  929. * Calls each of the listeners registered for a given event.
  930. *
  931. * @param {(String|Symbol)} event The event name.
  932. * @returns {Boolean} `true` if the event had listeners, else `false`.
  933. * @public
  934. */
  935. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  936. var evt = prefix ? prefix + event : event;
  937. if (!this._events[evt]) return false;
  938. var listeners = this._events[evt]
  939. , len = arguments.length
  940. , args
  941. , i;
  942. if (listeners.fn) {
  943. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  944. switch (len) {
  945. case 1: return listeners.fn.call(listeners.context), true;
  946. case 2: return listeners.fn.call(listeners.context, a1), true;
  947. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  948. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  949. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  950. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  951. }
  952. for (i = 1, args = new Array(len -1); i < len; i++) {
  953. args[i - 1] = arguments[i];
  954. }
  955. listeners.fn.apply(listeners.context, args);
  956. } else {
  957. var length = listeners.length
  958. , j;
  959. for (i = 0; i < length; i++) {
  960. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  961. switch (len) {
  962. case 1: listeners[i].fn.call(listeners[i].context); break;
  963. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  964. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  965. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  966. default:
  967. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  968. args[j - 1] = arguments[j];
  969. }
  970. listeners[i].fn.apply(listeners[i].context, args);
  971. }
  972. }
  973. }
  974. return true;
  975. };
  976. /**
  977. * Add a listener for a given event.
  978. *
  979. * @param {(String|Symbol)} event The event name.
  980. * @param {Function} fn The listener function.
  981. * @param {*} [context=this] The context to invoke the listener with.
  982. * @returns {EventEmitter} `this`.
  983. * @public
  984. */
  985. EventEmitter.prototype.on = function on(event, fn, context) {
  986. return addListener(this, event, fn, context, false);
  987. };
  988. /**
  989. * Add a one-time listener for a given event.
  990. *
  991. * @param {(String|Symbol)} event The event name.
  992. * @param {Function} fn The listener function.
  993. * @param {*} [context=this] The context to invoke the listener with.
  994. * @returns {EventEmitter} `this`.
  995. * @public
  996. */
  997. EventEmitter.prototype.once = function once(event, fn, context) {
  998. return addListener(this, event, fn, context, true);
  999. };
  1000. /**
  1001. * Remove the listeners of a given event.
  1002. *
  1003. * @param {(String|Symbol)} event The event name.
  1004. * @param {Function} fn Only remove the listeners that match this function.
  1005. * @param {*} context Only remove the listeners that have this context.
  1006. * @param {Boolean} once Only remove one-time listeners.
  1007. * @returns {EventEmitter} `this`.
  1008. * @public
  1009. */
  1010. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  1011. var evt = prefix ? prefix + event : event;
  1012. if (!this._events[evt]) return this;
  1013. if (!fn) {
  1014. clearEvent(this, evt);
  1015. return this;
  1016. }
  1017. var listeners = this._events[evt];
  1018. if (listeners.fn) {
  1019. if (
  1020. listeners.fn === fn &&
  1021. (!once || listeners.once) &&
  1022. (!context || listeners.context === context)
  1023. ) {
  1024. clearEvent(this, evt);
  1025. }
  1026. } else {
  1027. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  1028. if (
  1029. listeners[i].fn !== fn ||
  1030. (once && !listeners[i].once) ||
  1031. (context && listeners[i].context !== context)
  1032. ) {
  1033. events.push(listeners[i]);
  1034. }
  1035. }
  1036. //
  1037. // Reset the array, or remove it completely if we have no more listeners.
  1038. //
  1039. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  1040. else clearEvent(this, evt);
  1041. }
  1042. return this;
  1043. };
  1044. /**
  1045. * Remove all listeners, or those of the specified event.
  1046. *
  1047. * @param {(String|Symbol)} [event] The event name.
  1048. * @returns {EventEmitter} `this`.
  1049. * @public
  1050. */
  1051. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  1052. var evt;
  1053. if (event) {
  1054. evt = prefix ? prefix + event : event;
  1055. if (this._events[evt]) clearEvent(this, evt);
  1056. } else {
  1057. this._events = new Events();
  1058. this._eventsCount = 0;
  1059. }
  1060. return this;
  1061. };
  1062. //
  1063. // Alias methods names because people roll like that.
  1064. //
  1065. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  1066. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  1067. //
  1068. // Expose the prefix.
  1069. //
  1070. EventEmitter.prefixed = prefix;
  1071. //
  1072. // Allow `EventEmitter` to be imported as module namespace.
  1073. //
  1074. EventEmitter.EventEmitter = EventEmitter;
  1075. //
  1076. // Expose the module.
  1077. //
  1078. if (true) {
  1079. module.exports = EventEmitter;
  1080. }
  1081. /***/ }),
  1082. /* 5 */
  1083. /***/ (function(module, exports, __webpack_require__) {
  1084. "use strict";
  1085. Object.defineProperty(exports, "__esModule", { value: true });
  1086. function isString(value) {
  1087. return typeof value === 'string';
  1088. }
  1089. exports.default = isString;
  1090. //# sourceMappingURL=is-string.js.map
  1091. /***/ }),
  1092. /* 6 */
  1093. /***/ (function(module, exports, __webpack_require__) {
  1094. "use strict";
  1095. Object.defineProperty(exports, "__esModule", { value: true });
  1096. function isObject(value) {
  1097. return ((value !== null) && (typeof value === 'object'));
  1098. }
  1099. exports.default = isObject;
  1100. //# sourceMappingURL=is-object.js.map
  1101. /***/ }),
  1102. /* 7 */
  1103. /***/ (function(module, exports, __webpack_require__) {
  1104. "use strict";
  1105. Object.defineProperty(exports, '__esModule', {
  1106. value: true,
  1107. });
  1108. exports.print = print;
  1109. var _visitor = __webpack_require__(8);
  1110. var _blockString = __webpack_require__(12);
  1111. var _printString = __webpack_require__(13);
  1112. /**
  1113. * Converts an AST into a string, using one set of reasonable
  1114. * formatting rules.
  1115. */
  1116. function print(ast) {
  1117. return (0, _visitor.visit)(ast, printDocASTReducer);
  1118. }
  1119. const MAX_LINE_LENGTH = 80;
  1120. const printDocASTReducer = {
  1121. Name: {
  1122. leave: (node) => node.value,
  1123. },
  1124. Variable: {
  1125. leave: (node) => '$' + node.name,
  1126. },
  1127. // Document
  1128. Document: {
  1129. leave: (node) => join(node.definitions, '\n\n'),
  1130. },
  1131. OperationDefinition: {
  1132. leave(node) {
  1133. const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
  1134. const prefix = join(
  1135. [
  1136. node.operation,
  1137. join([node.name, varDefs]),
  1138. join(node.directives, ' '),
  1139. ],
  1140. ' ',
  1141. ); // Anonymous queries with no directives or variable definitions can use
  1142. // the query short form.
  1143. return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet;
  1144. },
  1145. },
  1146. VariableDefinition: {
  1147. leave: ({ variable, type, defaultValue, directives }) =>
  1148. variable +
  1149. ': ' +
  1150. type +
  1151. wrap(' = ', defaultValue) +
  1152. wrap(' ', join(directives, ' ')),
  1153. },
  1154. SelectionSet: {
  1155. leave: ({ selections }) => block(selections),
  1156. },
  1157. Field: {
  1158. leave({ alias, name, arguments: args, directives, selectionSet }) {
  1159. const prefix = wrap('', alias, ': ') + name;
  1160. let argsLine = prefix + wrap('(', join(args, ', '), ')');
  1161. if (argsLine.length > MAX_LINE_LENGTH) {
  1162. argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
  1163. }
  1164. return join([argsLine, join(directives, ' '), selectionSet], ' ');
  1165. },
  1166. },
  1167. Argument: {
  1168. leave: ({ name, value }) => name + ': ' + value,
  1169. },
  1170. // Fragments
  1171. FragmentSpread: {
  1172. leave: ({ name, directives }) =>
  1173. '...' + name + wrap(' ', join(directives, ' ')),
  1174. },
  1175. InlineFragment: {
  1176. leave: ({ typeCondition, directives, selectionSet }) =>
  1177. join(
  1178. [
  1179. '...',
  1180. wrap('on ', typeCondition),
  1181. join(directives, ' '),
  1182. selectionSet,
  1183. ],
  1184. ' ',
  1185. ),
  1186. },
  1187. FragmentDefinition: {
  1188. leave: (
  1189. { name, typeCondition, variableDefinitions, directives, selectionSet }, // Note: fragment variable definitions are experimental and may be changed
  1190. ) =>
  1191. // or removed in the future.
  1192. `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` +
  1193. `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` +
  1194. selectionSet,
  1195. },
  1196. // Value
  1197. IntValue: {
  1198. leave: ({ value }) => value,
  1199. },
  1200. FloatValue: {
  1201. leave: ({ value }) => value,
  1202. },
  1203. StringValue: {
  1204. leave: ({ value, block: isBlockString }) =>
  1205. isBlockString
  1206. ? (0, _blockString.printBlockString)(value)
  1207. : (0, _printString.printString)(value),
  1208. },
  1209. BooleanValue: {
  1210. leave: ({ value }) => (value ? 'true' : 'false'),
  1211. },
  1212. NullValue: {
  1213. leave: () => 'null',
  1214. },
  1215. EnumValue: {
  1216. leave: ({ value }) => value,
  1217. },
  1218. ListValue: {
  1219. leave: ({ values }) => '[' + join(values, ', ') + ']',
  1220. },
  1221. ObjectValue: {
  1222. leave: ({ fields }) => '{' + join(fields, ', ') + '}',
  1223. },
  1224. ObjectField: {
  1225. leave: ({ name, value }) => name + ': ' + value,
  1226. },
  1227. // Directive
  1228. Directive: {
  1229. leave: ({ name, arguments: args }) =>
  1230. '@' + name + wrap('(', join(args, ', '), ')'),
  1231. },
  1232. // Type
  1233. NamedType: {
  1234. leave: ({ name }) => name,
  1235. },
  1236. ListType: {
  1237. leave: ({ type }) => '[' + type + ']',
  1238. },
  1239. NonNullType: {
  1240. leave: ({ type }) => type + '!',
  1241. },
  1242. // Type System Definitions
  1243. SchemaDefinition: {
  1244. leave: ({ description, directives, operationTypes }) =>
  1245. wrap('', description, '\n') +
  1246. join(['schema', join(directives, ' '), block(operationTypes)], ' '),
  1247. },
  1248. OperationTypeDefinition: {
  1249. leave: ({ operation, type }) => operation + ': ' + type,
  1250. },
  1251. ScalarTypeDefinition: {
  1252. leave: ({ description, name, directives }) =>
  1253. wrap('', description, '\n') +
  1254. join(['scalar', name, join(directives, ' ')], ' '),
  1255. },
  1256. ObjectTypeDefinition: {
  1257. leave: ({ description, name, interfaces, directives, fields }) =>
  1258. wrap('', description, '\n') +
  1259. join(
  1260. [
  1261. 'type',
  1262. name,
  1263. wrap('implements ', join(interfaces, ' & ')),
  1264. join(directives, ' '),
  1265. block(fields),
  1266. ],
  1267. ' ',
  1268. ),
  1269. },
  1270. FieldDefinition: {
  1271. leave: ({ description, name, arguments: args, type, directives }) =>
  1272. wrap('', description, '\n') +
  1273. name +
  1274. (hasMultilineItems(args)
  1275. ? wrap('(\n', indent(join(args, '\n')), '\n)')
  1276. : wrap('(', join(args, ', '), ')')) +
  1277. ': ' +
  1278. type +
  1279. wrap(' ', join(directives, ' ')),
  1280. },
  1281. InputValueDefinition: {
  1282. leave: ({ description, name, type, defaultValue, directives }) =>
  1283. wrap('', description, '\n') +
  1284. join(
  1285. [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')],
  1286. ' ',
  1287. ),
  1288. },
  1289. InterfaceTypeDefinition: {
  1290. leave: ({ description, name, interfaces, directives, fields }) =>
  1291. wrap('', description, '\n') +
  1292. join(
  1293. [
  1294. 'interface',
  1295. name,
  1296. wrap('implements ', join(interfaces, ' & ')),
  1297. join(directives, ' '),
  1298. block(fields),
  1299. ],
  1300. ' ',
  1301. ),
  1302. },
  1303. UnionTypeDefinition: {
  1304. leave: ({ description, name, directives, types }) =>
  1305. wrap('', description, '\n') +
  1306. join(
  1307. ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))],
  1308. ' ',
  1309. ),
  1310. },
  1311. EnumTypeDefinition: {
  1312. leave: ({ description, name, directives, values }) =>
  1313. wrap('', description, '\n') +
  1314. join(['enum', name, join(directives, ' '), block(values)], ' '),
  1315. },
  1316. EnumValueDefinition: {
  1317. leave: ({ description, name, directives }) =>
  1318. wrap('', description, '\n') + join([name, join(directives, ' ')], ' '),
  1319. },
  1320. InputObjectTypeDefinition: {
  1321. leave: ({ description, name, directives, fields }) =>
  1322. wrap('', description, '\n') +
  1323. join(['input', name, join(directives, ' '), block(fields)], ' '),
  1324. },
  1325. DirectiveDefinition: {
  1326. leave: ({ description, name, arguments: args, repeatable, locations }) =>
  1327. wrap('', description, '\n') +
  1328. 'directive @' +
  1329. name +
  1330. (hasMultilineItems(args)
  1331. ? wrap('(\n', indent(join(args, '\n')), '\n)')
  1332. : wrap('(', join(args, ', '), ')')) +
  1333. (repeatable ? ' repeatable' : '') +
  1334. ' on ' +
  1335. join(locations, ' | '),
  1336. },
  1337. SchemaExtension: {
  1338. leave: ({ directives, operationTypes }) =>
  1339. join(
  1340. ['extend schema', join(directives, ' '), block(operationTypes)],
  1341. ' ',
  1342. ),
  1343. },
  1344. ScalarTypeExtension: {
  1345. leave: ({ name, directives }) =>
  1346. join(['extend scalar', name, join(directives, ' ')], ' '),
  1347. },
  1348. ObjectTypeExtension: {
  1349. leave: ({ name, interfaces, directives, fields }) =>
  1350. join(
  1351. [
  1352. 'extend type',
  1353. name,
  1354. wrap('implements ', join(interfaces, ' & ')),
  1355. join(directives, ' '),
  1356. block(fields),
  1357. ],
  1358. ' ',
  1359. ),
  1360. },
  1361. InterfaceTypeExtension: {
  1362. leave: ({ name, interfaces, directives, fields }) =>
  1363. join(
  1364. [
  1365. 'extend interface',
  1366. name,
  1367. wrap('implements ', join(interfaces, ' & ')),
  1368. join(directives, ' '),
  1369. block(fields),
  1370. ],
  1371. ' ',
  1372. ),
  1373. },
  1374. UnionTypeExtension: {
  1375. leave: ({ name, directives, types }) =>
  1376. join(
  1377. [
  1378. 'extend union',
  1379. name,
  1380. join(directives, ' '),
  1381. wrap('= ', join(types, ' | ')),
  1382. ],
  1383. ' ',
  1384. ),
  1385. },
  1386. EnumTypeExtension: {
  1387. leave: ({ name, directives, values }) =>
  1388. join(['extend enum', name, join(directives, ' '), block(values)], ' '),
  1389. },
  1390. InputObjectTypeExtension: {
  1391. leave: ({ name, directives, fields }) =>
  1392. join(['extend input', name, join(directives, ' '), block(fields)], ' '),
  1393. },
  1394. };
  1395. /**
  1396. * Given maybeArray, print an empty string if it is null or empty, otherwise
  1397. * print all items together separated by separator if provided
  1398. */
  1399. function join(maybeArray, separator = '') {
  1400. var _maybeArray$filter$jo;
  1401. return (_maybeArray$filter$jo =
  1402. maybeArray === null || maybeArray === void 0
  1403. ? void 0
  1404. : maybeArray.filter((x) => x).join(separator)) !== null &&
  1405. _maybeArray$filter$jo !== void 0
  1406. ? _maybeArray$filter$jo
  1407. : '';
  1408. }
  1409. /**
  1410. * Given array, print each item on its own line, wrapped in an indented `{ }` block.
  1411. */
  1412. function block(array) {
  1413. return wrap('{\n', indent(join(array, '\n')), '\n}');
  1414. }
  1415. /**
  1416. * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
  1417. */
  1418. function wrap(start, maybeString, end = '') {
  1419. return maybeString != null && maybeString !== ''
  1420. ? start + maybeString + end
  1421. : '';
  1422. }
  1423. function indent(str) {
  1424. return wrap(' ', str.replace(/\n/g, '\n '));
  1425. }
  1426. function hasMultilineItems(maybeArray) {
  1427. var _maybeArray$some;
  1428. // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
  1429. return (_maybeArray$some =
  1430. maybeArray === null || maybeArray === void 0
  1431. ? void 0
  1432. : maybeArray.some((str) => str.includes('\n'))) !== null &&
  1433. _maybeArray$some !== void 0
  1434. ? _maybeArray$some
  1435. : false;
  1436. }
  1437. /***/ }),
  1438. /* 8 */
  1439. /***/ (function(module, exports, __webpack_require__) {
  1440. "use strict";
  1441. Object.defineProperty(exports, '__esModule', {
  1442. value: true,
  1443. });
  1444. exports.BREAK = void 0;
  1445. exports.getEnterLeaveForKind = getEnterLeaveForKind;
  1446. exports.getVisitFn = getVisitFn;
  1447. exports.visit = visit;
  1448. exports.visitInParallel = visitInParallel;
  1449. var _inspect = __webpack_require__(9);
  1450. var _devAssert = __webpack_require__(10);
  1451. var _ast = __webpack_require__(11);
  1452. var _kinds = __webpack_require__(1);
  1453. const BREAK = Object.freeze({});
  1454. /**
  1455. * visit() will walk through an AST using a depth-first traversal, calling
  1456. * the visitor's enter function at each node in the traversal, and calling the
  1457. * leave function after visiting that node and all of its child nodes.
  1458. *
  1459. * By returning different values from the enter and leave functions, the
  1460. * behavior of the visitor can be altered, including skipping over a sub-tree of
  1461. * the AST (by returning false), editing the AST by returning a value or null
  1462. * to remove the value, or to stop the whole traversal by returning BREAK.
  1463. *
  1464. * When using visit() to edit an AST, the original AST will not be modified, and
  1465. * a new version of the AST with the changes applied will be returned from the
  1466. * visit function.
  1467. *
  1468. * ```ts
  1469. * const editedAST = visit(ast, {
  1470. * enter(node, key, parent, path, ancestors) {
  1471. * // @return
  1472. * // undefined: no action
  1473. * // false: skip visiting this node
  1474. * // visitor.BREAK: stop visiting altogether
  1475. * // null: delete this node
  1476. * // any value: replace this node with the returned value
  1477. * },
  1478. * leave(node, key, parent, path, ancestors) {
  1479. * // @return
  1480. * // undefined: no action
  1481. * // false: no action
  1482. * // visitor.BREAK: stop visiting altogether
  1483. * // null: delete this node
  1484. * // any value: replace this node with the returned value
  1485. * }
  1486. * });
  1487. * ```
  1488. *
  1489. * Alternatively to providing enter() and leave() functions, a visitor can
  1490. * instead provide functions named the same as the kinds of AST nodes, or
  1491. * enter/leave visitors at a named key, leading to three permutations of the
  1492. * visitor API:
  1493. *
  1494. * 1) Named visitors triggered when entering a node of a specific kind.
  1495. *
  1496. * ```ts
  1497. * visit(ast, {
  1498. * Kind(node) {
  1499. * // enter the "Kind" node
  1500. * }
  1501. * })
  1502. * ```
  1503. *
  1504. * 2) Named visitors that trigger upon entering and leaving a node of a specific kind.
  1505. *
  1506. * ```ts
  1507. * visit(ast, {
  1508. * Kind: {
  1509. * enter(node) {
  1510. * // enter the "Kind" node
  1511. * }
  1512. * leave(node) {
  1513. * // leave the "Kind" node
  1514. * }
  1515. * }
  1516. * })
  1517. * ```
  1518. *
  1519. * 3) Generic visitors that trigger upon entering and leaving any node.
  1520. *
  1521. * ```ts
  1522. * visit(ast, {
  1523. * enter(node) {
  1524. * // enter any node
  1525. * },
  1526. * leave(node) {
  1527. * // leave any node
  1528. * }
  1529. * })
  1530. * ```
  1531. */
  1532. exports.BREAK = BREAK;
  1533. function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) {
  1534. const enterLeaveMap = new Map();
  1535. for (const kind of Object.values(_kinds.Kind)) {
  1536. enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
  1537. }
  1538. /* eslint-disable no-undef-init */
  1539. let stack = undefined;
  1540. let inArray = Array.isArray(root);
  1541. let keys = [root];
  1542. let index = -1;
  1543. let edits = [];
  1544. let node = undefined;
  1545. let key = undefined;
  1546. let parent = undefined;
  1547. const path = [];
  1548. const ancestors = [];
  1549. let newRoot = root;
  1550. /* eslint-enable no-undef-init */
  1551. do {
  1552. index++;
  1553. const isLeaving = index === keys.length;
  1554. const isEdited = isLeaving && edits.length !== 0;
  1555. if (isLeaving) {
  1556. key = ancestors.length === 0 ? undefined : path[path.length - 1];
  1557. node = parent;
  1558. parent = ancestors.pop();
  1559. if (isEdited) {
  1560. if (inArray) {
  1561. node = node.slice();
  1562. let editOffset = 0;
  1563. for (const [editKey, editValue] of edits) {
  1564. const arrayKey = editKey - editOffset;
  1565. if (editValue === null) {
  1566. node.splice(arrayKey, 1);
  1567. editOffset++;
  1568. } else {
  1569. node[arrayKey] = editValue;
  1570. }
  1571. }
  1572. } else {
  1573. node = Object.defineProperties(
  1574. {},
  1575. Object.getOwnPropertyDescriptors(node),
  1576. );
  1577. for (const [editKey, editValue] of edits) {
  1578. node[editKey] = editValue;
  1579. }
  1580. }
  1581. }
  1582. index = stack.index;
  1583. keys = stack.keys;
  1584. edits = stack.edits;
  1585. inArray = stack.inArray;
  1586. stack = stack.prev;
  1587. } else {
  1588. key = parent ? (inArray ? index : keys[index]) : undefined;
  1589. node = parent ? parent[key] : newRoot;
  1590. if (node === null || node === undefined) {
  1591. continue;
  1592. }
  1593. if (parent) {
  1594. path.push(key);
  1595. }
  1596. }
  1597. let result;
  1598. if (!Array.isArray(node)) {
  1599. var _enterLeaveMap$get, _enterLeaveMap$get2;
  1600. (0, _ast.isNode)(node) ||
  1601. (0, _devAssert.devAssert)(
  1602. false,
  1603. `Invalid AST Node: ${(0, _inspect.inspect)(node)}.`,
  1604. );
  1605. const visitFn = isLeaving
  1606. ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null ||
  1607. _enterLeaveMap$get === void 0
  1608. ? void 0
  1609. : _enterLeaveMap$get.leave
  1610. : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null ||
  1611. _enterLeaveMap$get2 === void 0
  1612. ? void 0
  1613. : _enterLeaveMap$get2.enter;
  1614. result =
  1615. visitFn === null || visitFn === void 0
  1616. ? void 0
  1617. : visitFn.call(visitor, node, key, parent, path, ancestors);
  1618. if (result === BREAK) {
  1619. break;
  1620. }
  1621. if (result === false) {
  1622. if (!isLeaving) {
  1623. path.pop();
  1624. continue;
  1625. }
  1626. } else if (result !== undefined) {
  1627. edits.push([key, result]);
  1628. if (!isLeaving) {
  1629. if ((0, _ast.isNode)(result)) {
  1630. node = result;
  1631. } else {
  1632. path.pop();
  1633. continue;
  1634. }
  1635. }
  1636. }
  1637. }
  1638. if (result === undefined && isEdited) {
  1639. edits.push([key, node]);
  1640. }
  1641. if (isLeaving) {
  1642. path.pop();
  1643. } else {
  1644. var _node$kind;
  1645. stack = {
  1646. inArray,
  1647. index,
  1648. keys,
  1649. edits,
  1650. prev: stack,
  1651. };
  1652. inArray = Array.isArray(node);
  1653. keys = inArray
  1654. ? node
  1655. : (_node$kind = visitorKeys[node.kind]) !== null &&
  1656. _node$kind !== void 0
  1657. ? _node$kind
  1658. : [];
  1659. index = -1;
  1660. edits = [];
  1661. if (parent) {
  1662. ancestors.push(parent);
  1663. }
  1664. parent = node;
  1665. }
  1666. } while (stack !== undefined);
  1667. if (edits.length !== 0) {
  1668. newRoot = edits[edits.length - 1][1];
  1669. }
  1670. return newRoot;
  1671. }
  1672. /**
  1673. * Creates a new visitor instance which delegates to many visitors to run in
  1674. * parallel. Each visitor will be visited for each node before moving on.
  1675. *
  1676. * If a prior visitor edits a node, no following visitors will see that node.
  1677. */
  1678. function visitInParallel(visitors) {
  1679. const skipping = new Array(visitors.length).fill(null);
  1680. const mergedVisitor = Object.create(null);
  1681. for (const kind of Object.values(_kinds.Kind)) {
  1682. let hasVisitor = false;
  1683. const enterList = new Array(visitors.length).fill(undefined);
  1684. const leaveList = new Array(visitors.length).fill(undefined);
  1685. for (let i = 0; i < visitors.length; ++i) {
  1686. const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);
  1687. hasVisitor || (hasVisitor = enter != null || leave != null);
  1688. enterList[i] = enter;
  1689. leaveList[i] = leave;
  1690. }
  1691. if (!hasVisitor) {
  1692. continue;
  1693. }
  1694. const mergedEnterLeave = {
  1695. enter(...args) {
  1696. const node = args[0];
  1697. for (let i = 0; i < visitors.length; i++) {
  1698. if (skipping[i] === null) {
  1699. var _enterList$i;
  1700. const result =
  1701. (_enterList$i = enterList[i]) === null || _enterList$i === void 0
  1702. ? void 0
  1703. : _enterList$i.apply(visitors[i], args);
  1704. if (result === false) {
  1705. skipping[i] = node;
  1706. } else if (result === BREAK) {
  1707. skipping[i] = BREAK;
  1708. } else if (result !== undefined) {
  1709. return result;
  1710. }
  1711. }
  1712. }
  1713. },
  1714. leave(...args) {
  1715. const node = args[0];
  1716. for (let i = 0; i < visitors.length; i++) {
  1717. if (skipping[i] === null) {
  1718. var _leaveList$i;
  1719. const result =
  1720. (_leaveList$i = leaveList[i]) === null || _leaveList$i === void 0
  1721. ? void 0
  1722. : _leaveList$i.apply(visitors[i], args);
  1723. if (result === BREAK) {
  1724. skipping[i] = BREAK;
  1725. } else if (result !== undefined && result !== false) {
  1726. return result;
  1727. }
  1728. } else if (skipping[i] === node) {
  1729. skipping[i] = null;
  1730. }
  1731. }
  1732. },
  1733. };
  1734. mergedVisitor[kind] = mergedEnterLeave;
  1735. }
  1736. return mergedVisitor;
  1737. }
  1738. /**
  1739. * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
  1740. */
  1741. function getEnterLeaveForKind(visitor, kind) {
  1742. const kindVisitor = visitor[kind];
  1743. if (typeof kindVisitor === 'object') {
  1744. // { Kind: { enter() {}, leave() {} } }
  1745. return kindVisitor;
  1746. } else if (typeof kindVisitor === 'function') {
  1747. // { Kind() {} }
  1748. return {
  1749. enter: kindVisitor,
  1750. leave: undefined,
  1751. };
  1752. } // { enter() {}, leave() {} }
  1753. return {
  1754. enter: visitor.enter,
  1755. leave: visitor.leave,
  1756. };
  1757. }
  1758. /**
  1759. * Given a visitor instance, if it is leaving or not, and a node kind, return
  1760. * the function the visitor runtime should call.
  1761. *
  1762. * @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17
  1763. */
  1764. // istanbul ignore next (Deprecated code)
  1765. function getVisitFn(visitor, kind, isLeaving) {
  1766. const { enter, leave } = getEnterLeaveForKind(visitor, kind);
  1767. return isLeaving ? leave : enter;
  1768. }
  1769. /***/ }),
  1770. /* 9 */
  1771. /***/ (function(module, exports, __webpack_require__) {
  1772. "use strict";
  1773. Object.defineProperty(exports, '__esModule', {
  1774. value: true,
  1775. });
  1776. exports.inspect = inspect;
  1777. const MAX_ARRAY_LENGTH = 10;
  1778. const MAX_RECURSIVE_DEPTH = 2;
  1779. /**
  1780. * Used to print values in error messages.
  1781. */
  1782. function inspect(value) {
  1783. return formatValue(value, []);
  1784. }
  1785. function formatValue(value, seenValues) {
  1786. switch (typeof value) {
  1787. case 'string':
  1788. return JSON.stringify(value);
  1789. case 'function':
  1790. return value.name ? `[function ${value.name}]` : '[function]';
  1791. case 'object':
  1792. return formatObjectValue(value, seenValues);
  1793. default:
  1794. return String(value);
  1795. }
  1796. }
  1797. function formatObjectValue(value, previouslySeenValues) {
  1798. if (value === null) {
  1799. return 'null';
  1800. }
  1801. if (previouslySeenValues.includes(value)) {
  1802. return '[Circular]';
  1803. }
  1804. const seenValues = [...previouslySeenValues, value];
  1805. if (isJSONable(value)) {
  1806. const jsonValue = value.toJSON(); // check for infinite recursion
  1807. if (jsonValue !== value) {
  1808. return typeof jsonValue === 'string'
  1809. ? jsonValue
  1810. : formatValue(jsonValue, seenValues);
  1811. }
  1812. } else if (Array.isArray(value)) {
  1813. return formatArray(value, seenValues);
  1814. }
  1815. return formatObject(value, seenValues);
  1816. }
  1817. function isJSONable(value) {
  1818. return typeof value.toJSON === 'function';
  1819. }
  1820. function formatObject(object, seenValues) {
  1821. const entries = Object.entries(object);
  1822. if (entries.length === 0) {
  1823. return '{}';
  1824. }
  1825. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  1826. return '[' + getObjectTag(object) + ']';
  1827. }
  1828. const properties = entries.map(
  1829. ([key, value]) => key + ': ' + formatValue(value, seenValues),
  1830. );
  1831. return '{ ' + properties.join(', ') + ' }';
  1832. }
  1833. function formatArray(array, seenValues) {
  1834. if (array.length === 0) {
  1835. return '[]';
  1836. }
  1837. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  1838. return '[Array]';
  1839. }
  1840. const len = Math.min(MAX_ARRAY_LENGTH, array.length);
  1841. const remaining = array.length - len;
  1842. const items = [];
  1843. for (let i = 0; i < len; ++i) {
  1844. items.push(formatValue(array[i], seenValues));
  1845. }
  1846. if (remaining === 1) {
  1847. items.push('... 1 more item');
  1848. } else if (remaining > 1) {
  1849. items.push(`... ${remaining} more items`);
  1850. }
  1851. return '[' + items.join(', ') + ']';
  1852. }
  1853. function getObjectTag(object) {
  1854. const tag = Object.prototype.toString
  1855. .call(object)
  1856. .replace(/^\[object /, '')
  1857. .replace(/]$/, '');
  1858. if (tag === 'Object' && typeof object.constructor === 'function') {
  1859. const name = object.constructor.name;
  1860. if (typeof name === 'string' && name !== '') {
  1861. return name;
  1862. }
  1863. }
  1864. return tag;
  1865. }
  1866. /***/ }),
  1867. /* 10 */
  1868. /***/ (function(module, exports, __webpack_require__) {
  1869. "use strict";
  1870. Object.defineProperty(exports, '__esModule', {
  1871. value: true,
  1872. });
  1873. exports.devAssert = devAssert;
  1874. function devAssert(condition, message) {
  1875. const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
  1876. if (!booleanCondition) {
  1877. throw new Error(message);
  1878. }
  1879. }
  1880. /***/ }),
  1881. /* 11 */
  1882. /***/ (function(module, exports, __webpack_require__) {
  1883. "use strict";
  1884. Object.defineProperty(exports, '__esModule', {
  1885. value: true,
  1886. });
  1887. exports.Token =
  1888. exports.QueryDocumentKeys =
  1889. exports.OperationTypeNode =
  1890. exports.Location =
  1891. void 0;
  1892. exports.isNode = isNode;
  1893. /**
  1894. * Contains a range of UTF-8 character offsets and token references that
  1895. * identify the region of the source from which the AST derived.
  1896. */
  1897. class Location {
  1898. /**
  1899. * The character offset at which this Node begins.
  1900. */
  1901. /**
  1902. * The character offset at which this Node ends.
  1903. */
  1904. /**
  1905. * The Token at which this Node begins.
  1906. */
  1907. /**
  1908. * The Token at which this Node ends.
  1909. */
  1910. /**
  1911. * The Source document the AST represents.
  1912. */
  1913. constructor(startToken, endToken, source) {
  1914. this.start = startToken.start;
  1915. this.end = endToken.end;
  1916. this.startToken = startToken;
  1917. this.endToken = endToken;
  1918. this.source = source;
  1919. }
  1920. get [Symbol.toStringTag]() {
  1921. return 'Location';
  1922. }
  1923. toJSON() {
  1924. return {
  1925. start: this.start,
  1926. end: this.end,
  1927. };
  1928. }
  1929. }
  1930. /**
  1931. * Represents a range of characters represented by a lexical token
  1932. * within a Source.
  1933. */
  1934. exports.Location = Location;
  1935. class Token {
  1936. /**
  1937. * The kind of Token.
  1938. */
  1939. /**
  1940. * The character offset at which this Node begins.
  1941. */
  1942. /**
  1943. * The character offset at which this Node ends.
  1944. */
  1945. /**
  1946. * The 1-indexed line number on which this Token appears.
  1947. */
  1948. /**
  1949. * The 1-indexed column number at which this Token begins.
  1950. */
  1951. /**
  1952. * For non-punctuation tokens, represents the interpreted value of the token.
  1953. *
  1954. * Note: is undefined for punctuation tokens, but typed as string for
  1955. * convenience in the parser.
  1956. */
  1957. /**
  1958. * Tokens exist as nodes in a double-linked-list amongst all tokens
  1959. * including ignored tokens. <SOF> is always the first node and <EOF>
  1960. * the last.
  1961. */
  1962. constructor(kind, start, end, line, column, value) {
  1963. this.kind = kind;
  1964. this.start = start;
  1965. this.end = end;
  1966. this.line = line;
  1967. this.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  1968. this.value = value;
  1969. this.prev = null;
  1970. this.next = null;
  1971. }
  1972. get [Symbol.toStringTag]() {
  1973. return 'Token';
  1974. }
  1975. toJSON() {
  1976. return {
  1977. kind: this.kind,
  1978. value: this.value,
  1979. line: this.line,
  1980. column: this.column,
  1981. };
  1982. }
  1983. }
  1984. /**
  1985. * The list of all possible AST node types.
  1986. */
  1987. exports.Token = Token;
  1988. /**
  1989. * @internal
  1990. */
  1991. const QueryDocumentKeys = {
  1992. Name: [],
  1993. Document: ['definitions'],
  1994. OperationDefinition: [
  1995. 'name',
  1996. 'variableDefinitions',
  1997. 'directives',
  1998. 'selectionSet',
  1999. ],
  2000. VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
  2001. Variable: ['name'],
  2002. SelectionSet: ['selections'],
  2003. Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
  2004. Argument: ['name', 'value'],
  2005. FragmentSpread: ['name', 'directives'],
  2006. InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
  2007. FragmentDefinition: [
  2008. 'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0
  2009. 'variableDefinitions',
  2010. 'typeCondition',
  2011. 'directives',
  2012. 'selectionSet',
  2013. ],
  2014. IntValue: [],
  2015. FloatValue: [],
  2016. StringValue: [],
  2017. BooleanValue: [],
  2018. NullValue: [],
  2019. EnumValue: [],
  2020. ListValue: ['values'],
  2021. ObjectValue: ['fields'],
  2022. ObjectField: ['name', 'value'],
  2023. Directive: ['name', 'arguments'],
  2024. NamedType: ['name'],
  2025. ListType: ['type'],
  2026. NonNullType: ['type'],
  2027. SchemaDefinition: ['description', 'directives', 'operationTypes'],
  2028. OperationTypeDefinition: ['type'],
  2029. ScalarTypeDefinition: ['description', 'name', 'directives'],
  2030. ObjectTypeDefinition: [
  2031. 'description',
  2032. 'name',
  2033. 'interfaces',
  2034. 'directives',
  2035. 'fields',
  2036. ],
  2037. FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
  2038. InputValueDefinition: [
  2039. 'description',
  2040. 'name',
  2041. 'type',
  2042. 'defaultValue',
  2043. 'directives',
  2044. ],
  2045. InterfaceTypeDefinition: [
  2046. 'description',
  2047. 'name',
  2048. 'interfaces',
  2049. 'directives',
  2050. 'fields',
  2051. ],
  2052. UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
  2053. EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
  2054. EnumValueDefinition: ['description', 'name', 'directives'],
  2055. InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
  2056. DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
  2057. SchemaExtension: ['directives', 'operationTypes'],
  2058. ScalarTypeExtension: ['name', 'directives'],
  2059. ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  2060. InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  2061. UnionTypeExtension: ['name', 'directives', 'types'],
  2062. EnumTypeExtension: ['name', 'directives', 'values'],
  2063. InputObjectTypeExtension: ['name', 'directives', 'fields'],
  2064. };
  2065. exports.QueryDocumentKeys = QueryDocumentKeys;
  2066. const kindValues = new Set(Object.keys(QueryDocumentKeys));
  2067. /**
  2068. * @internal
  2069. */
  2070. function isNode(maybeNode) {
  2071. const maybeKind =
  2072. maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind;
  2073. return typeof maybeKind === 'string' && kindValues.has(maybeKind);
  2074. }
  2075. /** Name */
  2076. let OperationTypeNode;
  2077. exports.OperationTypeNode = OperationTypeNode;
  2078. (function (OperationTypeNode) {
  2079. OperationTypeNode['QUERY'] = 'query';
  2080. OperationTypeNode['MUTATION'] = 'mutation';
  2081. OperationTypeNode['SUBSCRIPTION'] = 'subscription';
  2082. })(OperationTypeNode || (exports.OperationTypeNode = OperationTypeNode = {}));
  2083. /***/ }),
  2084. /* 12 */
  2085. /***/ (function(module, exports, __webpack_require__) {
  2086. "use strict";
  2087. Object.defineProperty(exports, '__esModule', {
  2088. value: true,
  2089. });
  2090. exports.dedentBlockStringValue = dedentBlockStringValue;
  2091. exports.getBlockStringIndentation = getBlockStringIndentation;
  2092. exports.printBlockString = printBlockString;
  2093. /**
  2094. * Produces the value of a block string from its parsed raw value, similar to
  2095. * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
  2096. *
  2097. * This implements the GraphQL spec's BlockStringValue() static algorithm.
  2098. *
  2099. * @internal
  2100. */
  2101. function dedentBlockStringValue(rawString) {
  2102. // Expand a block string's raw value into independent lines.
  2103. const lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
  2104. const commonIndent = getBlockStringIndentation(rawString);
  2105. if (commonIndent !== 0) {
  2106. for (let i = 1; i < lines.length; i++) {
  2107. lines[i] = lines[i].slice(commonIndent);
  2108. }
  2109. } // Remove leading and trailing blank lines.
  2110. let startLine = 0;
  2111. while (startLine < lines.length && isBlank(lines[startLine])) {
  2112. ++startLine;
  2113. }
  2114. let endLine = lines.length;
  2115. while (endLine > startLine && isBlank(lines[endLine - 1])) {
  2116. --endLine;
  2117. } // Return a string of the lines joined with U+000A.
  2118. return lines.slice(startLine, endLine).join('\n');
  2119. }
  2120. function isBlank(str) {
  2121. for (const char of str) {
  2122. if (char !== ' ' && char !== '\t') {
  2123. return false;
  2124. }
  2125. }
  2126. return true;
  2127. }
  2128. /**
  2129. * @internal
  2130. */
  2131. function getBlockStringIndentation(value) {
  2132. var _commonIndent;
  2133. let isFirstLine = true;
  2134. let isEmptyLine = true;
  2135. let indent = 0;
  2136. let commonIndent = null;
  2137. for (let i = 0; i < value.length; ++i) {
  2138. switch (value.charCodeAt(i)) {
  2139. case 13:
  2140. // \r
  2141. if (value.charCodeAt(i + 1) === 10) {
  2142. ++i; // skip \r\n as one symbol
  2143. }
  2144. // falls through
  2145. case 10:
  2146. // \n
  2147. isFirstLine = false;
  2148. isEmptyLine = true;
  2149. indent = 0;
  2150. break;
  2151. case 9: // \t
  2152. case 32:
  2153. // <space>
  2154. ++indent;
  2155. break;
  2156. default:
  2157. if (
  2158. isEmptyLine &&
  2159. !isFirstLine &&
  2160. (commonIndent === null || indent < commonIndent)
  2161. ) {
  2162. commonIndent = indent;
  2163. }
  2164. isEmptyLine = false;
  2165. }
  2166. }
  2167. return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0
  2168. ? _commonIndent
  2169. : 0;
  2170. }
  2171. /**
  2172. * Print a block string in the indented block form by adding a leading and
  2173. * trailing blank line. However, if a block string starts with whitespace and is
  2174. * a single-line, adding a leading blank line would strip that whitespace.
  2175. *
  2176. * @internal
  2177. */
  2178. function printBlockString(value, preferMultipleLines = false) {
  2179. const isSingleLine = !value.includes('\n');
  2180. const hasLeadingSpace = value.startsWith(' ') || value.startsWith('\t');
  2181. const hasTrailingQuote = value.endsWith('"');
  2182. const hasTrailingSlash = value.endsWith('\\');
  2183. const printAsMultipleLines =
  2184. !isSingleLine ||
  2185. hasTrailingQuote ||
  2186. hasTrailingSlash ||
  2187. preferMultipleLines;
  2188. let result = ''; // Format a multi-line block quote to account for leading space.
  2189. if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
  2190. result += '\n';
  2191. }
  2192. result += value;
  2193. if (printAsMultipleLines) {
  2194. result += '\n';
  2195. }
  2196. return '"""' + result.replace(/"""/g, '\\"""') + '"""';
  2197. }
  2198. /***/ }),
  2199. /* 13 */
  2200. /***/ (function(module, exports, __webpack_require__) {
  2201. "use strict";
  2202. Object.defineProperty(exports, '__esModule', {
  2203. value: true,
  2204. });
  2205. exports.printString = printString;
  2206. /**
  2207. * Prints a string as a GraphQL StringValue literal. Replaces control characters
  2208. * and excluded characters (" U+0022 and \\ U+005C) with escape sequences.
  2209. */
  2210. function printString(str) {
  2211. return `"${str.replace(escapedRegExp, escapedReplacer)}"`;
  2212. } // eslint-disable-next-line no-control-regex
  2213. const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
  2214. function escapedReplacer(str) {
  2215. return escapeSequences[str.charCodeAt(0)];
  2216. } // prettier-ignore
  2217. const escapeSequences = [
  2218. '\\u0000',
  2219. '\\u0001',
  2220. '\\u0002',
  2221. '\\u0003',
  2222. '\\u0004',
  2223. '\\u0005',
  2224. '\\u0006',
  2225. '\\u0007',
  2226. '\\b',
  2227. '\\t',
  2228. '\\n',
  2229. '\\u000B',
  2230. '\\f',
  2231. '\\r',
  2232. '\\u000E',
  2233. '\\u000F',
  2234. '\\u0010',
  2235. '\\u0011',
  2236. '\\u0012',
  2237. '\\u0013',
  2238. '\\u0014',
  2239. '\\u0015',
  2240. '\\u0016',
  2241. '\\u0017',
  2242. '\\u0018',
  2243. '\\u0019',
  2244. '\\u001A',
  2245. '\\u001B',
  2246. '\\u001C',
  2247. '\\u001D',
  2248. '\\u001E',
  2249. '\\u001F',
  2250. '',
  2251. '',
  2252. '\\"',
  2253. '',
  2254. '',
  2255. '',
  2256. '',
  2257. '',
  2258. '',
  2259. '',
  2260. '',
  2261. '',
  2262. '',
  2263. '',
  2264. '',
  2265. '', // 2F
  2266. '',
  2267. '',
  2268. '',
  2269. '',
  2270. '',
  2271. '',
  2272. '',
  2273. '',
  2274. '',
  2275. '',
  2276. '',
  2277. '',
  2278. '',
  2279. '',
  2280. '',
  2281. '', // 3F
  2282. '',
  2283. '',
  2284. '',
  2285. '',
  2286. '',
  2287. '',
  2288. '',
  2289. '',
  2290. '',
  2291. '',
  2292. '',
  2293. '',
  2294. '',
  2295. '',
  2296. '',
  2297. '', // 4F
  2298. '',
  2299. '',
  2300. '',
  2301. '',
  2302. '',
  2303. '',
  2304. '',
  2305. '',
  2306. '',
  2307. '',
  2308. '',
  2309. '',
  2310. '\\\\',
  2311. '',
  2312. '',
  2313. '', // 5F
  2314. '',
  2315. '',
  2316. '',
  2317. '',
  2318. '',
  2319. '',
  2320. '',
  2321. '',
  2322. '',
  2323. '',
  2324. '',
  2325. '',
  2326. '',
  2327. '',
  2328. '',
  2329. '', // 6F
  2330. '',
  2331. '',
  2332. '',
  2333. '',
  2334. '',
  2335. '',
  2336. '',
  2337. '',
  2338. '',
  2339. '',
  2340. '',
  2341. '',
  2342. '',
  2343. '',
  2344. '',
  2345. '\\u007F',
  2346. '\\u0080',
  2347. '\\u0081',
  2348. '\\u0082',
  2349. '\\u0083',
  2350. '\\u0084',
  2351. '\\u0085',
  2352. '\\u0086',
  2353. '\\u0087',
  2354. '\\u0088',
  2355. '\\u0089',
  2356. '\\u008A',
  2357. '\\u008B',
  2358. '\\u008C',
  2359. '\\u008D',
  2360. '\\u008E',
  2361. '\\u008F',
  2362. '\\u0090',
  2363. '\\u0091',
  2364. '\\u0092',
  2365. '\\u0093',
  2366. '\\u0094',
  2367. '\\u0095',
  2368. '\\u0096',
  2369. '\\u0097',
  2370. '\\u0098',
  2371. '\\u0099',
  2372. '\\u009A',
  2373. '\\u009B',
  2374. '\\u009C',
  2375. '\\u009D',
  2376. '\\u009E',
  2377. '\\u009F',
  2378. ];
  2379. /***/ }),
  2380. /* 14 */
  2381. /***/ (function(module, exports, __webpack_require__) {
  2382. "use strict";
  2383. Object.defineProperty(exports, '__esModule', {
  2384. value: true,
  2385. });
  2386. exports.getOperationAST = getOperationAST;
  2387. var _kinds = __webpack_require__(1);
  2388. /**
  2389. * Returns an operation AST given a document AST and optionally an operation
  2390. * name. If a name is not provided, an operation is only returned if only one is
  2391. * provided in the document.
  2392. */
  2393. function getOperationAST(documentAST, operationName) {
  2394. let operation = null;
  2395. for (const definition of documentAST.definitions) {
  2396. if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
  2397. var _definition$name;
  2398. if (operationName == null) {
  2399. // If no operation name was provided, only return an Operation if there
  2400. // is one defined in the document. Upon encountering the second, return
  2401. // null.
  2402. if (operation) {
  2403. return null;
  2404. }
  2405. operation = definition;
  2406. } else if (
  2407. ((_definition$name = definition.name) === null ||
  2408. _definition$name === void 0
  2409. ? void 0
  2410. : _definition$name.value) === operationName
  2411. ) {
  2412. return definition;
  2413. }
  2414. }
  2415. }
  2416. return operation;
  2417. }
  2418. /***/ }),
  2419. /* 15 */
  2420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2421. "use strict";
  2422. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  2423. /* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ponyfill_js__ = __webpack_require__(17);
  2424. /* global window */
  2425. var root;
  2426. if (typeof self !== 'undefined') {
  2427. root = self;
  2428. } else if (typeof window !== 'undefined') {
  2429. root = window;
  2430. } else if (typeof global !== 'undefined') {
  2431. root = global;
  2432. } else if (true) {
  2433. root = module;
  2434. } else {
  2435. root = Function('return this')();
  2436. }
  2437. var result = Object(__WEBPACK_IMPORTED_MODULE_0__ponyfill_js__["a" /* default */])(root);
  2438. /* harmony default export */ __webpack_exports__["default"] = (result);
  2439. /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(0), __webpack_require__(16)(module)))
  2440. /***/ }),
  2441. /* 16 */
  2442. /***/ (function(module, exports) {
  2443. module.exports = function(originalModule) {
  2444. if(!originalModule.webpackPolyfill) {
  2445. var module = Object.create(originalModule);
  2446. // module.parent = undefined by default
  2447. if(!module.children) module.children = [];
  2448. Object.defineProperty(module, "loaded", {
  2449. enumerable: true,
  2450. get: function() {
  2451. return module.l;
  2452. }
  2453. });
  2454. Object.defineProperty(module, "id", {
  2455. enumerable: true,
  2456. get: function() {
  2457. return module.i;
  2458. }
  2459. });
  2460. Object.defineProperty(module, "exports", {
  2461. enumerable: true,
  2462. });
  2463. module.webpackPolyfill = 1;
  2464. }
  2465. return module;
  2466. };
  2467. /***/ }),
  2468. /* 17 */
  2469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2470. "use strict";
  2471. /* harmony export (immutable) */ __webpack_exports__["a"] = symbolObservablePonyfill;
  2472. function symbolObservablePonyfill(root) {
  2473. var result;
  2474. var Symbol = root.Symbol;
  2475. if (typeof Symbol === 'function') {
  2476. if (Symbol.observable) {
  2477. result = Symbol.observable;
  2478. } else {
  2479. result = Symbol('observable');
  2480. Symbol.observable = result;
  2481. }
  2482. } else {
  2483. result = '@@observable';
  2484. }
  2485. return result;
  2486. };
  2487. /***/ }),
  2488. /* 18 */
  2489. /***/ (function(module, exports, __webpack_require__) {
  2490. "use strict";
  2491. Object.defineProperty(exports, "__esModule", { value: true });
  2492. exports.GRAPHQL_SUBSCRIPTIONS = exports.GRAPHQL_WS = void 0;
  2493. var GRAPHQL_WS = 'graphql-ws';
  2494. exports.GRAPHQL_WS = GRAPHQL_WS;
  2495. var GRAPHQL_SUBSCRIPTIONS = 'graphql-subscriptions';
  2496. exports.GRAPHQL_SUBSCRIPTIONS = GRAPHQL_SUBSCRIPTIONS;
  2497. //# sourceMappingURL=protocol.js.map
  2498. /***/ }),
  2499. /* 19 */
  2500. /***/ (function(module, exports, __webpack_require__) {
  2501. "use strict";
  2502. Object.defineProperty(exports, "__esModule", { value: true });
  2503. exports.WS_TIMEOUT = exports.MIN_WS_TIMEOUT = void 0;
  2504. var MIN_WS_TIMEOUT = 1000;
  2505. exports.MIN_WS_TIMEOUT = MIN_WS_TIMEOUT;
  2506. var WS_TIMEOUT = 30000;
  2507. exports.WS_TIMEOUT = WS_TIMEOUT;
  2508. //# sourceMappingURL=defaults.js.map
  2509. /***/ }),
  2510. /* 20 */
  2511. /***/ (function(module, exports, __webpack_require__) {
  2512. "use strict";
  2513. Object.defineProperty(exports, "__esModule", { value: true });
  2514. var MessageTypes = (function () {
  2515. function MessageTypes() {
  2516. throw new Error('Static Class');
  2517. }
  2518. MessageTypes.GQL_CONNECTION_INIT = 'connection_init';
  2519. MessageTypes.GQL_CONNECTION_ACK = 'connection_ack';
  2520. MessageTypes.GQL_CONNECTION_ERROR = 'connection_error';
  2521. MessageTypes.GQL_CONNECTION_KEEP_ALIVE = 'ka';
  2522. MessageTypes.GQL_CONNECTION_TERMINATE = 'connection_terminate';
  2523. MessageTypes.GQL_START = 'start';
  2524. MessageTypes.GQL_DATA = 'data';
  2525. MessageTypes.GQL_ERROR = 'error';
  2526. MessageTypes.GQL_COMPLETE = 'complete';
  2527. MessageTypes.GQL_STOP = 'stop';
  2528. MessageTypes.SUBSCRIPTION_START = 'subscription_start';
  2529. MessageTypes.SUBSCRIPTION_DATA = 'subscription_data';
  2530. MessageTypes.SUBSCRIPTION_SUCCESS = 'subscription_success';
  2531. MessageTypes.SUBSCRIPTION_FAIL = 'subscription_fail';
  2532. MessageTypes.SUBSCRIPTION_END = 'subscription_end';
  2533. MessageTypes.INIT = 'init';
  2534. MessageTypes.INIT_SUCCESS = 'init_success';
  2535. MessageTypes.INIT_FAIL = 'init_fail';
  2536. MessageTypes.KEEP_ALIVE = 'keepalive';
  2537. return MessageTypes;
  2538. }());
  2539. exports.default = MessageTypes;
  2540. //# sourceMappingURL=message-types.js.map
  2541. /***/ })
  2542. /******/ ]);