@elastic/ems-client 8.7.0 → 8.8.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.
@@ -5,78 +5,292 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TMSService = void 0;
7
7
  var _lodash = _interopRequireDefault(require("lodash"));
8
+ var _maplibreGl = require("maplibre-gl");
9
+ var _ems_client = require("./ems_client");
8
10
  var _ems_service = require("./ems_service");
9
11
  var _utils = require("./utils");
10
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
13
+ /*
14
14
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
15
15
  * or more contributor license agreements. Licensed under the Elastic License
16
16
  * 2.0; you may not use this file except in compliance with the Elastic License
17
17
  * 2.0.
18
18
  */
19
+
19
20
  class TMSService extends _ems_service.AbstractEmsService {
20
- constructor(config, emsClient, proxyPath) {
21
- super(config, emsClient, proxyPath);
22
- _defineProperty(this, "_config", void 0);
23
- _defineProperty(this, "_getRasterStyleJson", _lodash.default.once(async () => {
24
- const rasterUrl = this._getStyleUrlForLocale('raster');
25
- if (rasterUrl) {
26
- const url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
27
- return this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
28
- } else {
29
- return;
30
- }
31
- }));
32
- _defineProperty(this, "_getVectorStyleJsonRaw", _lodash.default.once(async () => {
33
- const vectorUrl = this._getStyleUrlForLocale('vector');
34
- if (vectorUrl) {
35
- const url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
36
- const vectorJson = await this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
37
- return {
38
- ...vectorJson
39
- };
40
- } else {
41
- return;
42
- }
43
- }));
44
- _defineProperty(this, "_getVectorStyleJsonInlined", _lodash.default.once(async () => {
45
- const vectorJson = await this._getVectorStyleJsonRaw();
46
- if (vectorJson) {
47
- const inlinedSources = {};
21
+ /*
22
+ List of supported languages with labels and OMT codes extracted
23
+ from https://openmaptiles.org/languages
24
+ Keys are values for i18.locale from Kibana settings
25
+ and OMT codes for the rest.
26
+ */
27
+ static SupportedLanguages = [{
28
+ key: 'ar',
29
+ omt: 'ar'
30
+ }, {
31
+ key: 'az',
32
+ omt: 'az'
33
+ }, {
34
+ key: 'be',
35
+ omt: 'be'
36
+ }, {
37
+ key: 'bg',
38
+ omt: 'bg'
39
+ }, {
40
+ key: 'br',
41
+ omt: 'br'
42
+ }, {
43
+ key: 'bs',
44
+ omt: 'bs'
45
+ }, {
46
+ key: 'ca',
47
+ omt: 'ca'
48
+ }, {
49
+ key: 'cs',
50
+ omt: 'cs'
51
+ }, {
52
+ key: 'cy',
53
+ omt: 'cy'
54
+ }, {
55
+ key: 'da',
56
+ omt: 'da'
57
+ }, {
58
+ key: 'de',
59
+ omt: 'de'
60
+ }, {
61
+ key: 'el',
62
+ omt: 'el'
63
+ }, {
64
+ key: 'en',
65
+ omt: 'en'
66
+ }, {
67
+ key: 'eo',
68
+ omt: 'eo'
69
+ }, {
70
+ key: 'es',
71
+ omt: 'es'
72
+ }, {
73
+ key: 'et',
74
+ omt: 'et'
75
+ }, {
76
+ key: 'fi',
77
+ omt: 'fi'
78
+ }, {
79
+ key: 'fr-fr',
80
+ omt: 'fr'
81
+ }, {
82
+ key: 'fy',
83
+ omt: 'fy'
84
+ }, {
85
+ key: 'ga',
86
+ omt: 'ga'
87
+ }, {
88
+ key: 'gd',
89
+ omt: 'gd'
90
+ }, {
91
+ key: 'he',
92
+ omt: 'he'
93
+ }, {
94
+ key: 'hi-in',
95
+ omt: 'hi'
96
+ }, {
97
+ key: 'hr',
98
+ omt: 'hr'
99
+ }, {
100
+ key: 'hu',
101
+ omt: 'hu'
102
+ }, {
103
+ key: 'hy',
104
+ omt: 'hy'
105
+ }, {
106
+ key: 'is',
107
+ omt: 'is'
108
+ }, {
109
+ key: 'it',
110
+ omt: 'it'
111
+ }, {
112
+ key: 'ja_kana',
113
+ omt: 'ja_kana'
114
+ }, {
115
+ key: 'ja_rm',
116
+ omt: 'ja_rm'
117
+ }, {
118
+ key: 'ja-jp',
119
+ omt: 'ja'
120
+ }, {
121
+ key: 'ka',
122
+ omt: 'ka'
123
+ }, {
124
+ key: 'kk',
125
+ omt: 'kk'
126
+ }, {
127
+ key: 'kn',
128
+ omt: 'kn'
129
+ }, {
130
+ key: 'ko_rm',
131
+ omt: 'ko_rm'
132
+ }, {
133
+ key: 'ko',
134
+ omt: 'ko'
135
+ }, {
136
+ key: 'la',
137
+ omt: 'la'
138
+ }, {
139
+ key: 'lb',
140
+ omt: 'lb'
141
+ }, {
142
+ key: 'lt',
143
+ omt: 'lt'
144
+ }, {
145
+ key: 'lv',
146
+ omt: 'lv'
147
+ }, {
148
+ key: 'mk',
149
+ omt: 'mk'
150
+ }, {
151
+ key: 'mt',
152
+ omt: 'mt'
153
+ }, {
154
+ key: 'nl',
155
+ omt: 'nl'
156
+ }, {
157
+ key: 'no',
158
+ omt: 'no'
159
+ }, {
160
+ key: 'pl',
161
+ omt: 'pl'
162
+ }, {
163
+ key: 'pt-pt',
164
+ omt: 'pt'
165
+ }, {
166
+ key: 'rm',
167
+ omt: 'rm'
168
+ }, {
169
+ key: 'ro',
170
+ omt: 'ro'
171
+ }, {
172
+ key: 'ru-ru',
173
+ omt: 'ru'
174
+ }, {
175
+ key: 'sk',
176
+ omt: 'sk'
177
+ }, {
178
+ key: 'sl',
179
+ omt: 'sl'
180
+ }, {
181
+ key: 'sq',
182
+ omt: 'sq'
183
+ }, {
184
+ key: 'sr-Ltn',
185
+ omt: 'sr-Ltn'
186
+ }, {
187
+ key: 'sr',
188
+ omt: 'sr'
189
+ }, {
190
+ key: 'sv',
191
+ omt: 'sv'
192
+ }, {
193
+ key: 'th',
194
+ omt: 'th'
195
+ }, {
196
+ key: 'tr',
197
+ omt: 'tr'
198
+ }, {
199
+ key: 'uk',
200
+ omt: 'uk'
201
+ }, {
202
+ key: 'zh-cn',
203
+ omt: 'zh'
204
+ }];
205
+
206
+ /*
207
+ Suggested default operations for the different EMS styles
208
+ */
209
+ static colorOperationDefaults = [{
210
+ style: 'road_map',
211
+ operation: 'mix',
212
+ percentage: 0.25
213
+ }, {
214
+ style: 'road_map_desaturated',
215
+ operation: 'screen',
216
+ percentage: 0.25
217
+ }, {
218
+ style: 'dark_map',
219
+ operation: 'dodge',
220
+ percentage: 0.25
221
+ }, {
222
+ style: 'high_contrast',
223
+ operation: 'screen',
224
+ percentage: 0.25
225
+ }, {
226
+ style: 'road_map_desaturated_v9',
227
+ operation: 'screen',
228
+ percentage: 0.25
229
+ }, {
230
+ style: 'dark_map_v9',
231
+ operation: 'dodge',
232
+ percentage: 0.25
233
+ }];
234
+ _config;
235
+ _getRasterStyleJson = _lodash.default.once(async () => {
236
+ const rasterUrl = this._getStyleUrlForLocale('raster');
237
+ if (rasterUrl) {
238
+ const url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
239
+ return this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
240
+ } else {
241
+ return;
242
+ }
243
+ });
244
+ _getVectorStyleJsonRaw = _lodash.default.once(async () => {
245
+ const vectorUrl = this._getStyleUrlForLocale('vector');
246
+ if (vectorUrl) {
247
+ const url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
248
+ const vectorJson = await this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
249
+ return {
250
+ ...vectorJson
251
+ };
252
+ } else {
253
+ return;
254
+ }
255
+ });
256
+ _getVectorStyleJsonInlined = _lodash.default.once(async () => {
257
+ const vectorJson = await this._getVectorStyleJsonRaw();
258
+ if (vectorJson) {
259
+ const inlinedSources = {};
260
+ const {
261
+ sources
262
+ } = vectorJson;
263
+ for (const sourceName of Object.getOwnPropertyNames(sources)) {
48
264
  const {
49
- sources
50
- } = vectorJson;
51
- for (const sourceName of Object.getOwnPropertyNames(sources)) {
52
- const {
53
- url
54
- } = sources[sourceName];
55
- if (url) {
56
- const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
57
- const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
58
- const sourceJson = await this._emsClient.getManifest(extendedUrl);
59
- const tiles = sourceJson?.tiles?.map(tileUrl => {
60
- const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
61
- return this._emsClient.extendUrlWithParams(directUrl);
62
- });
63
- inlinedSources[sourceName] = {
64
- ...sourceJson,
65
- type: 'vector',
66
- tiles
67
- };
68
- }
265
+ url
266
+ } = sources[sourceName];
267
+ if (url) {
268
+ const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
269
+ const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
270
+ const sourceJson = await this._emsClient.getManifest(extendedUrl);
271
+ const tiles = sourceJson?.tiles?.map(tileUrl => {
272
+ const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
273
+ return this._emsClient.extendUrlWithParams(directUrl);
274
+ });
275
+ inlinedSources[sourceName] = {
276
+ ...sourceJson,
277
+ type: 'vector',
278
+ tiles
279
+ };
69
280
  }
70
- return {
71
- ...vectorJson,
72
- sources: inlinedSources,
73
- sprite: await this._getSpriteSheetRootPath(),
74
- glyphs: await this._getUrlTemplateForGlyphs()
75
- };
76
- } else {
77
- return;
78
281
  }
79
- }));
282
+ return {
283
+ ...vectorJson,
284
+ sources: inlinedSources,
285
+ sprite: await this._getSpriteSheetRootPath(),
286
+ glyphs: await this._getUrlTemplateForGlyphs()
287
+ };
288
+ } else {
289
+ return;
290
+ }
291
+ });
292
+ constructor(config, emsClient, proxyPath) {
293
+ super(config, emsClient, proxyPath);
80
294
  this._config = config;
81
295
  }
82
296
 
@@ -299,216 +513,4 @@ class TMSService extends _ems_service.AbstractEmsService {
299
513
  }
300
514
  }
301
515
  }
302
- exports.TMSService = TMSService;
303
- /*
304
- List of supported languages with labels and OMT codes extracted
305
- from https://openmaptiles.org/languages
306
- Keys are values for i18.locale from Kibana settings
307
- and OMT codes for the rest.
308
- */
309
- _defineProperty(TMSService, "SupportedLanguages", [{
310
- key: 'ar',
311
- omt: 'ar'
312
- }, {
313
- key: 'az',
314
- omt: 'az'
315
- }, {
316
- key: 'be',
317
- omt: 'be'
318
- }, {
319
- key: 'bg',
320
- omt: 'bg'
321
- }, {
322
- key: 'br',
323
- omt: 'br'
324
- }, {
325
- key: 'bs',
326
- omt: 'bs'
327
- }, {
328
- key: 'ca',
329
- omt: 'ca'
330
- }, {
331
- key: 'cs',
332
- omt: 'cs'
333
- }, {
334
- key: 'cy',
335
- omt: 'cy'
336
- }, {
337
- key: 'da',
338
- omt: 'da'
339
- }, {
340
- key: 'de',
341
- omt: 'de'
342
- }, {
343
- key: 'el',
344
- omt: 'el'
345
- }, {
346
- key: 'en',
347
- omt: 'en'
348
- }, {
349
- key: 'eo',
350
- omt: 'eo'
351
- }, {
352
- key: 'es',
353
- omt: 'es'
354
- }, {
355
- key: 'et',
356
- omt: 'et'
357
- }, {
358
- key: 'fi',
359
- omt: 'fi'
360
- }, {
361
- key: 'fr-fr',
362
- omt: 'fr'
363
- }, {
364
- key: 'fy',
365
- omt: 'fy'
366
- }, {
367
- key: 'ga',
368
- omt: 'ga'
369
- }, {
370
- key: 'gd',
371
- omt: 'gd'
372
- }, {
373
- key: 'he',
374
- omt: 'he'
375
- }, {
376
- key: 'hi-in',
377
- omt: 'hi'
378
- }, {
379
- key: 'hr',
380
- omt: 'hr'
381
- }, {
382
- key: 'hu',
383
- omt: 'hu'
384
- }, {
385
- key: 'hy',
386
- omt: 'hy'
387
- }, {
388
- key: 'is',
389
- omt: 'is'
390
- }, {
391
- key: 'it',
392
- omt: 'it'
393
- }, {
394
- key: 'ja_kana',
395
- omt: 'ja_kana'
396
- }, {
397
- key: 'ja_rm',
398
- omt: 'ja_rm'
399
- }, {
400
- key: 'ja-jp',
401
- omt: 'ja'
402
- }, {
403
- key: 'ka',
404
- omt: 'ka'
405
- }, {
406
- key: 'kk',
407
- omt: 'kk'
408
- }, {
409
- key: 'kn',
410
- omt: 'kn'
411
- }, {
412
- key: 'ko_rm',
413
- omt: 'ko_rm'
414
- }, {
415
- key: 'ko',
416
- omt: 'ko'
417
- }, {
418
- key: 'la',
419
- omt: 'la'
420
- }, {
421
- key: 'lb',
422
- omt: 'lb'
423
- }, {
424
- key: 'lt',
425
- omt: 'lt'
426
- }, {
427
- key: 'lv',
428
- omt: 'lv'
429
- }, {
430
- key: 'mk',
431
- omt: 'mk'
432
- }, {
433
- key: 'mt',
434
- omt: 'mt'
435
- }, {
436
- key: 'nl',
437
- omt: 'nl'
438
- }, {
439
- key: 'no',
440
- omt: 'no'
441
- }, {
442
- key: 'pl',
443
- omt: 'pl'
444
- }, {
445
- key: 'pt-pt',
446
- omt: 'pt'
447
- }, {
448
- key: 'rm',
449
- omt: 'rm'
450
- }, {
451
- key: 'ro',
452
- omt: 'ro'
453
- }, {
454
- key: 'ru-ru',
455
- omt: 'ru'
456
- }, {
457
- key: 'sk',
458
- omt: 'sk'
459
- }, {
460
- key: 'sl',
461
- omt: 'sl'
462
- }, {
463
- key: 'sq',
464
- omt: 'sq'
465
- }, {
466
- key: 'sr-Ltn',
467
- omt: 'sr-Ltn'
468
- }, {
469
- key: 'sr',
470
- omt: 'sr'
471
- }, {
472
- key: 'sv',
473
- omt: 'sv'
474
- }, {
475
- key: 'th',
476
- omt: 'th'
477
- }, {
478
- key: 'tr',
479
- omt: 'tr'
480
- }, {
481
- key: 'uk',
482
- omt: 'uk'
483
- }, {
484
- key: 'zh-cn',
485
- omt: 'zh'
486
- }]);
487
- /*
488
- Suggested default operations for the different EMS styles
489
- */
490
- _defineProperty(TMSService, "colorOperationDefaults", [{
491
- style: 'road_map',
492
- operation: 'mix',
493
- percentage: 0.25
494
- }, {
495
- style: 'road_map_desaturated',
496
- operation: 'screen',
497
- percentage: 0.25
498
- }, {
499
- style: 'dark_map',
500
- operation: 'dodge',
501
- percentage: 0.25
502
- }, {
503
- style: 'high_contrast',
504
- operation: 'screen',
505
- percentage: 0.25
506
- }, {
507
- style: 'road_map_desaturated_v9',
508
- operation: 'screen',
509
- percentage: 0.25
510
- }, {
511
- style: 'dark_map_v9',
512
- operation: 'dodge',
513
- percentage: 0.25
514
- }]);
516
+ exports.TMSService = TMSService;
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.colorizeColor = colorizeColor;
7
7
  exports.desaturateColor = desaturateColor;
8
8
  exports.toAbsoluteUrl = toAbsoluteUrl;
9
- var _chromaJs = _interopRequireDefault(require("chroma-js"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _chromaJs = _interopRequireWildcard(require("chroma-js"));
10
+ var _maplibreGl = require("maplibre-gl");
11
+ var cache;
12
+ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
11
13
  /*
12
14
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
13
15
  * or more contributor license agreements. Licensed under the Elastic License