@elastic/ems-client 7.14.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,780 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/regenerator", "@babel/runtime/helpers/asyncToGenerator", "@babel/runtime/helpers/classCallCheck", "@babel/runtime/helpers/createClass", "@babel/runtime/helpers/defineProperty", "lodash", "./tms_service", "./file_layer", "semver", "url", "./utils"], factory);
4
- } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/regenerator"), require("@babel/runtime/helpers/asyncToGenerator"), require("@babel/runtime/helpers/classCallCheck"), require("@babel/runtime/helpers/createClass"), require("@babel/runtime/helpers/defineProperty"), require("lodash"), require("./tms_service"), require("./file_layer"), require("semver"), require("url"), require("./utils"));
6
- } else {
7
- var mod = {
8
- exports: {}
9
- };
10
- factory(mod.exports, global.regenerator, global.asyncToGenerator, global.classCallCheck, global.createClass, global.defineProperty, global.lodash, global.tms_service, global.file_layer, global.semver, global.url, global.utils);
11
- global.ems_client = mod.exports;
12
- }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _regenerator, _asyncToGenerator2, _classCallCheck2, _createClass2, _defineProperty2, _lodash, _tms_service, _file_layer, _semver, _url, _utils) {
14
- "use strict";
15
-
16
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
-
18
- Object.defineProperty(_exports, "__esModule", {
19
- value: true
20
- });
21
- _exports.EMSClient = void 0;
22
- _regenerator = _interopRequireDefault(_regenerator);
23
- _asyncToGenerator2 = _interopRequireDefault(_asyncToGenerator2);
24
- _classCallCheck2 = _interopRequireDefault(_classCallCheck2);
25
- _createClass2 = _interopRequireDefault(_createClass2);
26
- _defineProperty2 = _interopRequireDefault(_defineProperty2);
27
- _lodash = _interopRequireDefault(_lodash);
28
- _semver = _interopRequireDefault(_semver);
29
-
30
- /*
31
- * Licensed to Elasticsearch B.V. under one or more contributor
32
- * license agreements. See the NOTICE file distributed with
33
- * this work for additional information regarding copyright
34
- * ownership. Elasticsearch B.V. licenses this file to you under
35
- * the Apache License, Version 2.0 (the "License"); you may
36
- * not use this file except in compliance with the License.
37
- * You may obtain a copy of the License at
38
- *
39
- * http://www.apache.org/licenses/LICENSE-2.0
40
- *
41
- * Unless required by applicable law or agreed to in writing,
42
- * software distributed under the License is distributed on an
43
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
44
- * KIND, either express or implied. See the License for the
45
- * specific language governing permissions and limitations
46
- * under the License.
47
- */
48
- var DEFAULT_EMS_VERSION = '7.9';
49
-
50
- /**
51
- * plugins cannot have upstream dependencies on core/*-kibana.
52
- * Work-around by copy-pasting modifyUrl routine here.
53
- * @param url
54
- * @param block
55
- */
56
- function modifyUrlLocal(url, block) {
57
- var parsed = (0, _url.parse)(url, true); // copy over the most specific version of each
58
- // property. By default, the parsed url includes
59
- // several conflicting properties (like path and
60
- // pathname + search, or search and query) and keeping
61
- // track of which property is actually used when they
62
- // are formatted is harder than necessary
63
-
64
- var meaningfulParts = {
65
- protocol: parsed.protocol,
66
- slashes: parsed.slashes,
67
- auth: parsed.auth,
68
- hostname: parsed.hostname,
69
- port: parsed.port,
70
- pathname: parsed.pathname,
71
- query: parsed.query || {},
72
- hash: parsed.hash
73
- }; // the block modifies the meaningfulParts object, or returns a new one
74
-
75
- var modifiedParts = block(meaningfulParts) || meaningfulParts; // format the modified/replaced meaningfulParts back into a url
76
-
77
- return (0, _url.format)({
78
- protocol: modifiedParts.protocol,
79
- slashes: modifiedParts.slashes,
80
- auth: modifiedParts.auth,
81
- hostname: modifiedParts.hostname,
82
- port: modifiedParts.port,
83
- pathname: modifiedParts.pathname,
84
- query: modifiedParts.query,
85
- hash: modifiedParts.hash
86
- });
87
- }
88
-
89
- var extendUrl = function extendUrl(url, props) {
90
- return modifyUrlLocal(url, function (parsed) {
91
- return _lodash["default"].merge(parsed, props);
92
- });
93
- };
94
- /**
95
- * Unescape a url template that was escaped by encodeURI() so leaflet
96
- * will be able to correctly locate the variables in the template
97
- * @param {String} url
98
- * @return {String}
99
- */
100
-
101
-
102
- var unescapeTemplateVars = function unescapeTemplateVars(url) {
103
- var ENCODED_TEMPLATE_VARS_RE = /%7B(\w+?)%7D/g;
104
- return url.replace(ENCODED_TEMPLATE_VARS_RE, function (total, varName) {
105
- return "{".concat(varName, "}");
106
- });
107
- };
108
-
109
- //this is not the default locale from Kibana, but the default locale supported by the Elastic Maps Service
110
- var DEFAULT_LANGUAGE = 'en';
111
-
112
- var EMSClient = /*#__PURE__*/function () {
113
- /**
114
- * these methods are assigned outside the constructor
115
- */
116
- function EMSClient(config) {
117
- (0, _classCallCheck2["default"])(this, EMSClient);
118
- (0, _defineProperty2["default"])(this, "EMS_LOAD_TIMEOUT", 32000);
119
- (0, _defineProperty2["default"])(this, "_queryParams", void 0);
120
- (0, _defineProperty2["default"])(this, "_appVersion", void 0);
121
- (0, _defineProperty2["default"])(this, "_fetchFunction", void 0);
122
- (0, _defineProperty2["default"])(this, "_sanitizer", void 0);
123
- (0, _defineProperty2["default"])(this, "_manifestServiceUrl", void 0);
124
- (0, _defineProperty2["default"])(this, "_fileApiUrl", void 0);
125
- (0, _defineProperty2["default"])(this, "_tileApiUrl", void 0);
126
- (0, _defineProperty2["default"])(this, "_emsVersion", void 0);
127
- (0, _defineProperty2["default"])(this, "_emsLandingPageUrl", void 0);
128
- (0, _defineProperty2["default"])(this, "_language", void 0);
129
- (0, _defineProperty2["default"])(this, "_proxyPath", void 0);
130
- (0, _defineProperty2["default"])(this, "_getMainCatalog", void 0);
131
- (0, _defineProperty2["default"])(this, "_getDefaultTMSCatalog", void 0);
132
- (0, _defineProperty2["default"])(this, "_getDefaultFileCatalog", void 0);
133
- (0, _defineProperty2["default"])(this, "_loadTMSServices", void 0);
134
- (0, _defineProperty2["default"])(this, "_loadFileLayers", void 0);
135
-
136
- // Remove kbnVersion in 8.0
137
- if ('kbnVersion' in config) {
138
- console.warn('The "kbnVersion" parameter for ems-client is deprecated. Please use "appVersion" instead.');
139
- this._appVersion = config.kbnVersion;
140
- } else {
141
- this._appVersion = config.appVersion;
142
- }
143
-
144
- this._queryParams = {
145
- elastic_tile_service_tos: 'agree',
146
- my_app_name: config.appName || 'kibana',
147
- my_app_version: this._appVersion
148
- };
149
- this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : function (x) {
150
- return x;
151
- };
152
- this._manifestServiceUrl = config.manifestServiceUrl;
153
- this._tileApiUrl = config.tileApiUrl;
154
- this._fileApiUrl = config.fileApiUrl;
155
- this._emsVersion = this._getEmsVersion(config.emsVersion);
156
- this._emsLandingPageUrl = config.landingPageUrl || '';
157
- this._language = config.language || DEFAULT_LANGUAGE;
158
- this._fetchFunction = config.fetchFunction;
159
- this._proxyPath = config.proxyPath || '';
160
-
161
- this._invalidateSettings();
162
- }
163
-
164
- (0, _createClass2["default"])(EMSClient, [{
165
- key: "getDefaultLocale",
166
- value: function getDefaultLocale() {
167
- return DEFAULT_LANGUAGE;
168
- }
169
- }, {
170
- key: "getLocale",
171
- value: function getLocale() {
172
- return this._language;
173
- }
174
- }, {
175
- key: "getValueInLanguage",
176
- value: function getValueInLanguage(i18nObject) {
177
- if (!i18nObject) {
178
- return '';
179
- }
180
-
181
- return i18nObject[this._language] ? i18nObject[this._language] : i18nObject[DEFAULT_LANGUAGE];
182
- }
183
- /**
184
- * this internal method is overridden by the tests to simulate custom manifest.
185
- */
186
-
187
- }, {
188
- key: "getManifest",
189
- value: function () {
190
- var _getManifest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(manifestUrl) {
191
- var url, result;
192
- return _regenerator["default"].wrap(function _callee$(_context) {
193
- while (1) {
194
- switch (_context.prev = _context.next) {
195
- case 0:
196
- _context.prev = 0;
197
- url = extendUrl(manifestUrl, {
198
- query: this._queryParams
199
- });
200
- _context.next = 4;
201
- return this._fetchWithTimeout(url);
202
-
203
- case 4:
204
- result = _context.sent;
205
-
206
- if (!result) {
207
- _context.next = 11;
208
- break;
209
- }
210
-
211
- _context.next = 8;
212
- return result.json();
213
-
214
- case 8:
215
- _context.t0 = _context.sent;
216
- _context.next = 12;
217
- break;
218
-
219
- case 11:
220
- _context.t0 = null;
221
-
222
- case 12:
223
- return _context.abrupt("return", _context.t0);
224
-
225
- case 15:
226
- _context.prev = 15;
227
- _context.t1 = _context["catch"](0);
228
-
229
- if (!_context.t1) {
230
- _context.t1 = new Error('Unknown error');
231
- }
232
-
233
- if (!(_context.t1 instanceof Error)) {
234
- _context.t1 = new Error(_context.t1.data || "status ".concat(_context.t1.statusText || _context.t1.status));
235
- }
236
-
237
- throw new Error("Unable to retrieve manifest from ".concat(manifestUrl, ": ").concat(_context.t1.message));
238
-
239
- case 20:
240
- case "end":
241
- return _context.stop();
242
- }
243
- }
244
- }, _callee, this, [[0, 15]]);
245
- }));
246
-
247
- function getManifest(_x) {
248
- return _getManifest.apply(this, arguments);
249
- }
250
-
251
- return getManifest;
252
- }()
253
- /**
254
- * Add optional query-parameters to all requests
255
- *
256
- * @param additionalQueryParams
257
- */
258
-
259
- }, {
260
- key: "addQueryParams",
261
- value: function addQueryParams(additionalQueryParams) {
262
- for (var _key in additionalQueryParams) {
263
- if (additionalQueryParams.hasOwnProperty(_key)) {
264
- if (additionalQueryParams[_key] !== this._queryParams[_key]) {
265
- //changes detected.
266
- this._queryParams = _lodash["default"].assign({}, this._queryParams, additionalQueryParams);
267
-
268
- this._invalidateSettings();
269
-
270
- break;
271
- }
272
- }
273
- }
274
- }
275
- }, {
276
- key: "getMainManifest",
277
- value: function () {
278
- var _getMainManifest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
279
- return _regenerator["default"].wrap(function _callee2$(_context2) {
280
- while (1) {
281
- switch (_context2.prev = _context2.next) {
282
- case 0:
283
- _context2.next = 2;
284
- return this._getMainCatalog();
285
-
286
- case 2:
287
- return _context2.abrupt("return", _context2.sent);
288
-
289
- case 3:
290
- case "end":
291
- return _context2.stop();
292
- }
293
- }
294
- }, _callee2, this);
295
- }));
296
-
297
- function getMainManifest() {
298
- return _getMainManifest.apply(this, arguments);
299
- }
300
-
301
- return getMainManifest;
302
- }()
303
- }, {
304
- key: "getDefaultFileManifest",
305
- value: function () {
306
- var _getDefaultFileManifest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
307
- return _regenerator["default"].wrap(function _callee3$(_context3) {
308
- while (1) {
309
- switch (_context3.prev = _context3.next) {
310
- case 0:
311
- _context3.next = 2;
312
- return this._getDefaultFileCatalog();
313
-
314
- case 2:
315
- return _context3.abrupt("return", _context3.sent);
316
-
317
- case 3:
318
- case "end":
319
- return _context3.stop();
320
- }
321
- }
322
- }, _callee3, this);
323
- }));
324
-
325
- function getDefaultFileManifest() {
326
- return _getDefaultFileManifest.apply(this, arguments);
327
- }
328
-
329
- return getDefaultFileManifest;
330
- }()
331
- }, {
332
- key: "getDefaultTMSManifest",
333
- value: function () {
334
- var _getDefaultTMSManifest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
335
- return _regenerator["default"].wrap(function _callee4$(_context4) {
336
- while (1) {
337
- switch (_context4.prev = _context4.next) {
338
- case 0:
339
- _context4.next = 2;
340
- return this._getDefaultTMSCatalog();
341
-
342
- case 2:
343
- return _context4.abrupt("return", _context4.sent);
344
-
345
- case 3:
346
- case "end":
347
- return _context4.stop();
348
- }
349
- }
350
- }, _callee4, this);
351
- }));
352
-
353
- function getDefaultTMSManifest() {
354
- return _getDefaultTMSManifest.apply(this, arguments);
355
- }
356
-
357
- return getDefaultTMSManifest;
358
- }()
359
- }, {
360
- key: "getFileLayers",
361
- value: function () {
362
- var _getFileLayers = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
363
- return _regenerator["default"].wrap(function _callee5$(_context5) {
364
- while (1) {
365
- switch (_context5.prev = _context5.next) {
366
- case 0:
367
- _context5.next = 2;
368
- return this._loadFileLayers();
369
-
370
- case 2:
371
- return _context5.abrupt("return", _context5.sent);
372
-
373
- case 3:
374
- case "end":
375
- return _context5.stop();
376
- }
377
- }
378
- }, _callee5, this);
379
- }));
380
-
381
- function getFileLayers() {
382
- return _getFileLayers.apply(this, arguments);
383
- }
384
-
385
- return getFileLayers;
386
- }()
387
- }, {
388
- key: "getTMSServices",
389
- value: function () {
390
- var _getTMSServices = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
391
- return _regenerator["default"].wrap(function _callee6$(_context6) {
392
- while (1) {
393
- switch (_context6.prev = _context6.next) {
394
- case 0:
395
- _context6.next = 2;
396
- return this._loadTMSServices();
397
-
398
- case 2:
399
- return _context6.abrupt("return", _context6.sent);
400
-
401
- case 3:
402
- case "end":
403
- return _context6.stop();
404
- }
405
- }
406
- }, _callee6, this);
407
- }));
408
-
409
- function getTMSServices() {
410
- return _getTMSServices.apply(this, arguments);
411
- }
412
-
413
- return getTMSServices;
414
- }()
415
- }, {
416
- key: "getTileApiUrl",
417
- value: function getTileApiUrl() {
418
- return this._tileApiUrl;
419
- }
420
- }, {
421
- key: "getFileApiUrl",
422
- value: function getFileApiUrl() {
423
- return this._fileApiUrl;
424
- }
425
- }, {
426
- key: "getLandingPageUrl",
427
- value: function getLandingPageUrl() {
428
- return this._emsLandingPageUrl;
429
- }
430
- }, {
431
- key: "sanitizeHtml",
432
- value: function sanitizeHtml(html) {
433
- return this._sanitizer(html);
434
- }
435
- }, {
436
- key: "extendUrlWithParams",
437
- value: function extendUrlWithParams(url) {
438
- return unescapeTemplateVars(extendUrl(url, {
439
- query: this._queryParams
440
- }));
441
- }
442
- }, {
443
- key: "findFileLayerById",
444
- value: function () {
445
- var _findFileLayerById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(id) {
446
- var fileLayers, i;
447
- return _regenerator["default"].wrap(function _callee7$(_context7) {
448
- while (1) {
449
- switch (_context7.prev = _context7.next) {
450
- case 0:
451
- _context7.next = 2;
452
- return this.getFileLayers();
453
-
454
- case 2:
455
- fileLayers = _context7.sent;
456
- i = 0;
457
-
458
- case 4:
459
- if (!(i < fileLayers.length)) {
460
- _context7.next = 10;
461
- break;
462
- }
463
-
464
- if (!fileLayers[i].hasId(id)) {
465
- _context7.next = 7;
466
- break;
467
- }
468
-
469
- return _context7.abrupt("return", fileLayers[i]);
470
-
471
- case 7:
472
- i++;
473
- _context7.next = 4;
474
- break;
475
-
476
- case 10:
477
- case "end":
478
- return _context7.stop();
479
- }
480
- }
481
- }, _callee7, this);
482
- }));
483
-
484
- function findFileLayerById(_x2) {
485
- return _findFileLayerById.apply(this, arguments);
486
- }
487
-
488
- return findFileLayerById;
489
- }()
490
- }, {
491
- key: "findTMSServiceById",
492
- value: function () {
493
- var _findTMSServiceById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(id) {
494
- var tmsServices, i;
495
- return _regenerator["default"].wrap(function _callee8$(_context8) {
496
- while (1) {
497
- switch (_context8.prev = _context8.next) {
498
- case 0:
499
- _context8.next = 2;
500
- return this.getTMSServices();
501
-
502
- case 2:
503
- tmsServices = _context8.sent;
504
- i = 0;
505
-
506
- case 4:
507
- if (!(i < tmsServices.length)) {
508
- _context8.next = 10;
509
- break;
510
- }
511
-
512
- if (!tmsServices[i].hasId(id)) {
513
- _context8.next = 7;
514
- break;
515
- }
516
-
517
- return _context8.abrupt("return", tmsServices[i]);
518
-
519
- case 7:
520
- i++;
521
- _context8.next = 4;
522
- break;
523
-
524
- case 10:
525
- case "end":
526
- return _context8.stop();
527
- }
528
- }
529
- }, _callee8, this);
530
- }));
531
-
532
- function findTMSServiceById(_x3) {
533
- return _findTMSServiceById.apply(this, arguments);
534
- }
535
-
536
- return findTMSServiceById;
537
- }()
538
- }, {
539
- key: "_getEmsVersion",
540
- value: function _getEmsVersion(version) {
541
- var userVersion = _semver["default"].valid(_semver["default"].coerce(version));
542
-
543
- var semverVersion = userVersion ? userVersion : _semver["default"].coerce(DEFAULT_EMS_VERSION);
544
-
545
- if (semverVersion) {
546
- return "v".concat(_semver["default"].major(semverVersion), ".").concat(_semver["default"].minor(semverVersion));
547
- } else {
548
- throw new Error("Invalid version: ".concat(version));
549
- }
550
- }
551
- }, {
552
- key: "_fetchWithTimeout",
553
- value: function _fetchWithTimeout(url) {
554
- var _this = this;
555
-
556
- return new Promise(function (resolve, reject) {
557
- var timer = setTimeout(function () {
558
- return reject(new Error("Request to ".concat(url, " timed out")));
559
- }, _this.EMS_LOAD_TIMEOUT);
560
-
561
- _this._fetchFunction(url).then(function (response) {
562
- clearTimeout(timer);
563
- resolve(response);
564
- }, function (err) {
565
- clearTimeout(timer);
566
- reject(err);
567
- });
568
- });
569
- }
570
- }, {
571
- key: "_getManifestWithParams",
572
- value: function () {
573
- var _getManifestWithParams2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(url) {
574
- var extendedUrl;
575
- return _regenerator["default"].wrap(function _callee9$(_context9) {
576
- while (1) {
577
- switch (_context9.prev = _context9.next) {
578
- case 0:
579
- extendedUrl = this.extendUrlWithParams(url);
580
- _context9.next = 3;
581
- return this.getManifest(extendedUrl);
582
-
583
- case 3:
584
- return _context9.abrupt("return", _context9.sent);
585
-
586
- case 4:
587
- case "end":
588
- return _context9.stop();
589
- }
590
- }
591
- }, _callee9, this);
592
- }));
593
-
594
- function _getManifestWithParams(_x4) {
595
- return _getManifestWithParams2.apply(this, arguments);
596
- }
597
-
598
- return _getManifestWithParams;
599
- }()
600
- }, {
601
- key: "_invalidateSettings",
602
- value: function _invalidateSettings() {
603
- var _this2 = this;
604
-
605
- this._getMainCatalog = _lodash["default"].once( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
606
- var services;
607
- return _regenerator["default"].wrap(function _callee10$(_context10) {
608
- while (1) {
609
- switch (_context10.prev = _context10.next) {
610
- case 0:
611
- if (!_this2._manifestServiceUrl) {
612
- _context10.next = 7;
613
- break;
614
- }
615
-
616
- console.warn("The \"manifestServiceUrl\" parameter is deprecated in v7.6.0.\n Consider using \"tileApiUrl\" and \"fileApiUrl\" instead.");
617
- _context10.next = 4;
618
- return _this2._getManifestWithParams(_this2._manifestServiceUrl);
619
-
620
- case 4:
621
- return _context10.abrupt("return", _context10.sent);
622
-
623
- case 7:
624
- services = [];
625
-
626
- if (_this2._tileApiUrl) {
627
- services.push({
628
- type: 'tms',
629
- manifest: (0, _utils.toAbsoluteUrl)(_this2._tileApiUrl, "".concat(_this2._emsVersion, "/manifest"))
630
- });
631
- }
632
-
633
- if (_this2._fileApiUrl) {
634
- services.push({
635
- type: 'file',
636
- manifest: (0, _utils.toAbsoluteUrl)(_this2._fileApiUrl, "".concat(_this2._emsVersion, "/manifest"))
637
- });
638
- }
639
-
640
- return _context10.abrupt("return", {
641
- services: services
642
- });
643
-
644
- case 11:
645
- case "end":
646
- return _context10.stop();
647
- }
648
- }
649
- }, _callee10);
650
- })));
651
- this._getDefaultTMSCatalog = _lodash["default"].once( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
652
- var catalogue, firstService, url;
653
- return _regenerator["default"].wrap(function _callee11$(_context11) {
654
- while (1) {
655
- switch (_context11.prev = _context11.next) {
656
- case 0:
657
- _context11.next = 2;
658
- return _this2._getMainCatalog();
659
-
660
- case 2:
661
- catalogue = _context11.sent;
662
- firstService = catalogue.services.find(function (service) {
663
- return service.type === 'tms';
664
- });
665
-
666
- if (firstService) {
667
- _context11.next = 6;
668
- break;
669
- }
670
-
671
- return _context11.abrupt("return", {
672
- services: []
673
- });
674
-
675
- case 6:
676
- url = _this2._proxyPath + firstService.manifest;
677
- _context11.next = 9;
678
- return _this2.getManifest(url);
679
-
680
- case 9:
681
- return _context11.abrupt("return", _context11.sent);
682
-
683
- case 10:
684
- case "end":
685
- return _context11.stop();
686
- }
687
- }
688
- }, _callee11);
689
- })));
690
- this._getDefaultFileCatalog = _lodash["default"].once( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
691
- var catalogue, firstService, url;
692
- return _regenerator["default"].wrap(function _callee12$(_context12) {
693
- while (1) {
694
- switch (_context12.prev = _context12.next) {
695
- case 0:
696
- _context12.next = 2;
697
- return _this2._getMainCatalog();
698
-
699
- case 2:
700
- catalogue = _context12.sent;
701
- firstService = catalogue.services.find(function (service) {
702
- return service.type === 'file';
703
- });
704
-
705
- if (firstService) {
706
- _context12.next = 6;
707
- break;
708
- }
709
-
710
- return _context12.abrupt("return", {
711
- layers: []
712
- });
713
-
714
- case 6:
715
- url = _this2._proxyPath + firstService.manifest;
716
- _context12.next = 9;
717
- return _this2.getManifest(url);
718
-
719
- case 9:
720
- return _context12.abrupt("return", _context12.sent);
721
-
722
- case 10:
723
- case "end":
724
- return _context12.stop();
725
- }
726
- }
727
- }, _callee12);
728
- }))); //Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
729
-
730
- this._loadTMSServices = _lodash["default"].once( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
731
- var tmsManifest;
732
- return _regenerator["default"].wrap(function _callee13$(_context13) {
733
- while (1) {
734
- switch (_context13.prev = _context13.next) {
735
- case 0:
736
- _context13.next = 2;
737
- return _this2._getDefaultTMSCatalog();
738
-
739
- case 2:
740
- tmsManifest = _context13.sent;
741
- return _context13.abrupt("return", tmsManifest.services.map(function (serviceConfig) {
742
- return new _tms_service.TMSService(serviceConfig, _this2, _this2._proxyPath);
743
- }));
744
-
745
- case 4:
746
- case "end":
747
- return _context13.stop();
748
- }
749
- }
750
- }, _callee13);
751
- })));
752
- this._loadFileLayers = _lodash["default"].once( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
753
- var fileManifest;
754
- return _regenerator["default"].wrap(function _callee14$(_context14) {
755
- while (1) {
756
- switch (_context14.prev = _context14.next) {
757
- case 0:
758
- _context14.next = 2;
759
- return _this2._getDefaultFileCatalog();
760
-
761
- case 2:
762
- fileManifest = _context14.sent;
763
- return _context14.abrupt("return", fileManifest.layers.map(function (layerConfig) {
764
- return new _file_layer.FileLayer(layerConfig, _this2, _this2._proxyPath);
765
- }));
766
-
767
- case 4:
768
- case "end":
769
- return _context14.stop();
770
- }
771
- }
772
- }, _callee14);
773
- })));
774
- }
775
- }]);
776
- return EMSClient;
777
- }();
778
-
779
- _exports.EMSClient = EMSClient;
780
- });