@elastic/ems-client 8.0.0 → 8.3.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.
- package/.backportrc.json +25 -3
- package/.ci/jobs/elastic+ems-client+pull-request.yml +1 -0
- package/CHANGELOG.md +19 -0
- package/package.json +3 -2
- package/src/ems_client.ts +1 -1
- package/src/ems_service.ts +0 -6
- package/src/index.ts +1 -2
- package/src/tms_service.ts +33 -53
- package/target/ems_service.d.ts +0 -2
- package/target/index.d.ts +1 -2
- package/target/node/ems_client.js +1 -1
- package/target/node/ems_service.js +0 -6
- package/target/node/index.js +12 -8
- package/target/node/tms_service.js +22 -19
- package/target/tms_service.d.ts +10 -30
- package/target/web/ems_client.js +1 -1
- package/target/web/ems_service.js +0 -6
- package/target/web/index.js +1 -2
- package/target/web/tms_service.js +42 -41
- package/test/ems_client.test.ts +2 -2
- package/src/origin.ts +0 -11
- package/target/node/origin.js +0 -18
- package/target/web/origin.js +0 -10
package/.backportrc.json
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"upstream": "elastic/ems-client",
|
|
3
|
-
"branches": [
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"branches": [
|
|
4
|
+
{
|
|
5
|
+
"name": "8.2",
|
|
6
|
+
"checked": true
|
|
7
|
+
},
|
|
8
|
+
"8.1",
|
|
9
|
+
"8.0",
|
|
10
|
+
"7.17",
|
|
11
|
+
"7.16",
|
|
12
|
+
"7.16",
|
|
13
|
+
"7.15",
|
|
14
|
+
"7.14",
|
|
15
|
+
"7.12",
|
|
16
|
+
"7.11",
|
|
17
|
+
"7.10",
|
|
18
|
+
"7.9",
|
|
19
|
+
"7.8",
|
|
20
|
+
"7.7",
|
|
21
|
+
"7.6",
|
|
22
|
+
"7.2"
|
|
23
|
+
],
|
|
24
|
+
"labels": [
|
|
25
|
+
"backport"
|
|
26
|
+
]
|
|
27
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
5
|
|
|
6
|
+
## [8.3.0] - 2022-04-18
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Default EMS version is 8.3
|
|
10
|
+
- bump maplibre-gl to 2.1.9
|
|
11
|
+
|
|
12
|
+
## [8.2.0] - 2022-03-24
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Default EMS version is 8.2
|
|
16
|
+
- Removed getOrigin method #91
|
|
17
|
+
|
|
18
|
+
## [8.1.0] - 2021-11-09
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Default EMS version is 8.1
|
|
22
|
+
- Export EmsSprite and EmsSpritesheet types
|
|
23
|
+
- Inherit types from maplibre-gl
|
|
24
|
+
|
|
6
25
|
## [8.0.0] - 2021-10-20
|
|
7
26
|
|
|
8
27
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/ems-client",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "JavaScript client library for the Elastic Maps Service",
|
|
5
5
|
"main": "target/node/index.js",
|
|
6
6
|
"browser": "target/web/index.js",
|
|
@@ -63,9 +63,10 @@
|
|
|
63
63
|
"eslint-plugin-prettier": "^3.1.3",
|
|
64
64
|
"husky": "^4.2.5",
|
|
65
65
|
"jest": "^26.4.0",
|
|
66
|
+
"maplibre-gl": "2.1.9",
|
|
66
67
|
"node-fetch": "^2.6.1",
|
|
67
68
|
"prettier": "^2.0.5",
|
|
68
69
|
"ts-jest": "^26.2.0",
|
|
69
|
-
"typescript": "
|
|
70
|
+
"typescript": "4.6.3"
|
|
70
71
|
}
|
|
71
72
|
}
|
package/src/ems_client.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { toAbsoluteUrl } from './utils';
|
|
|
16
16
|
import { ParsedUrlQueryInput } from 'querystring';
|
|
17
17
|
import LRUCache from 'lru-cache';
|
|
18
18
|
|
|
19
|
-
const DEFAULT_EMS_VERSION = '8.
|
|
19
|
+
const DEFAULT_EMS_VERSION = '8.3';
|
|
20
20
|
|
|
21
21
|
type URLMeaningfulParts = {
|
|
22
22
|
auth?: string | null;
|
package/src/ems_service.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { EMSClient, BaseEmsServiceConfig } from './ems_client';
|
|
9
|
-
import { ORIGIN } from './origin';
|
|
10
9
|
import { toAbsoluteUrl } from './utils';
|
|
11
10
|
|
|
12
11
|
export interface IEmsService {
|
|
@@ -15,7 +14,6 @@ export interface IEmsService {
|
|
|
15
14
|
getDisplayName(): string;
|
|
16
15
|
getId(): string;
|
|
17
16
|
hasId(id: string): boolean;
|
|
18
|
-
getOrigin(): string;
|
|
19
17
|
getApiUrl(): string;
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -50,10 +48,6 @@ export abstract class AbstractEmsService implements IEmsService {
|
|
|
50
48
|
return attributions.join('|');
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
getOrigin(): string {
|
|
54
|
-
return ORIGIN.EMS;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
51
|
/**
|
|
58
52
|
* Checks if url is absolute. If not, prepend the basePath.
|
|
59
53
|
*/
|
package/src/index.ts
CHANGED
package/src/tms_service.ts
CHANGED
|
@@ -6,52 +6,31 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
+
import { StyleSpecification, VectorSourceSpecification } from 'maplibre-gl';
|
|
9
10
|
import { EMSClient, EmsTmsFormat, TMSServiceConfig } from './ems_client';
|
|
10
11
|
import { AbstractEmsService } from './ems_service';
|
|
11
12
|
|
|
12
|
-
type
|
|
13
|
-
type: 'vector';
|
|
14
|
-
url: string;
|
|
15
|
-
tiles: string[];
|
|
16
|
-
bounds?: number[];
|
|
17
|
-
scheme?: 'xyz' | 'tms';
|
|
18
|
-
minzoom?: number;
|
|
19
|
-
maxzoom?: number;
|
|
20
|
-
attribution?: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type EmsVectorSources = {
|
|
24
|
-
[sourceName: string]: EmsVectorSource;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type EmsVectorStyle = {
|
|
28
|
-
sources: EmsVectorSources;
|
|
29
|
-
sprite: string;
|
|
30
|
-
glyphs: string;
|
|
31
|
-
bearing?: number;
|
|
32
|
-
center?: number[];
|
|
33
|
-
layers?: unknown[];
|
|
34
|
-
metadata?: unknown;
|
|
35
|
-
name?: string;
|
|
36
|
-
pitch?: number;
|
|
37
|
-
light?: unknown;
|
|
38
|
-
transition?: unknown;
|
|
39
|
-
version: number;
|
|
40
|
-
zoom?: number;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type EmsSprite = {
|
|
13
|
+
export type EmsSprite = {
|
|
44
14
|
height: number;
|
|
45
15
|
pixelRatio: number;
|
|
46
16
|
width: number;
|
|
47
17
|
x: number;
|
|
48
18
|
y: number;
|
|
19
|
+
sdf?: boolean;
|
|
49
20
|
};
|
|
50
21
|
|
|
51
|
-
type EmsSpriteSheet = {
|
|
22
|
+
export type EmsSpriteSheet = {
|
|
52
23
|
[spriteName: string]: EmsSprite;
|
|
53
24
|
};
|
|
54
25
|
|
|
26
|
+
type EmsVectorSources = {
|
|
27
|
+
[sourceName: string]: VectorSourceSpecification;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type EmsVectorStyle = StyleSpecification & {
|
|
31
|
+
sources: EmsVectorSources;
|
|
32
|
+
};
|
|
33
|
+
|
|
55
34
|
type EmsRasterStyle = {
|
|
56
35
|
tilejson: string;
|
|
57
36
|
name: string;
|
|
@@ -98,19 +77,22 @@ export class TMSService extends AbstractEmsService {
|
|
|
98
77
|
const { sources } = vectorJson;
|
|
99
78
|
for (const sourceName of Object.getOwnPropertyNames(sources)) {
|
|
100
79
|
const { url } = sources[sourceName];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
80
|
+
if (url) {
|
|
81
|
+
const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
82
|
+
const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
83
|
+
const sourceJson = await this._emsClient.getManifest<VectorSourceSpecification>(
|
|
84
|
+
extendedUrl
|
|
85
|
+
);
|
|
86
|
+
const tiles = sourceJson?.tiles?.map((tileUrl) => {
|
|
87
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
88
|
+
return this._emsClient.extendUrlWithParams(directUrl);
|
|
89
|
+
});
|
|
90
|
+
inlinedSources[sourceName] = {
|
|
91
|
+
...sourceJson,
|
|
92
|
+
type: 'vector',
|
|
93
|
+
tiles,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
114
96
|
}
|
|
115
97
|
return {
|
|
116
98
|
...vectorJson,
|
|
@@ -155,11 +137,9 @@ export class TMSService extends AbstractEmsService {
|
|
|
155
137
|
|
|
156
138
|
async getUrlTemplateForVector(sourceId: string): Promise<string> {
|
|
157
139
|
const tileJson = await this._getVectorStyleJsonInlined();
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles) {
|
|
162
|
-
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
140
|
+
const url = tileJson?.sources[sourceId]?.tiles?.pop();
|
|
141
|
+
if (url) {
|
|
142
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
163
143
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
164
144
|
} else {
|
|
165
145
|
return '';
|
|
@@ -271,7 +251,7 @@ export class TMSService extends AbstractEmsService {
|
|
|
271
251
|
|
|
272
252
|
private async _getSpriteSheetRootPath(): Promise<string> {
|
|
273
253
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
274
|
-
if (vectorStyleJson) {
|
|
254
|
+
if (vectorStyleJson?.sprite) {
|
|
275
255
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite);
|
|
276
256
|
} else {
|
|
277
257
|
return '';
|
|
@@ -280,7 +260,7 @@ export class TMSService extends AbstractEmsService {
|
|
|
280
260
|
|
|
281
261
|
private async _getUrlTemplateForGlyphs(): Promise<string> {
|
|
282
262
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
283
|
-
if (vectorStyleJson) {
|
|
263
|
+
if (vectorStyleJson?.glyphs) {
|
|
284
264
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs);
|
|
285
265
|
} else {
|
|
286
266
|
return '';
|
package/target/ems_service.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export interface IEmsService {
|
|
|
8
8
|
getDisplayName(): string;
|
|
9
9
|
getId(): string;
|
|
10
10
|
hasId(id: string): boolean;
|
|
11
|
-
getOrigin(): string;
|
|
12
11
|
getApiUrl(): string;
|
|
13
12
|
}
|
|
14
13
|
export declare abstract class AbstractEmsService implements IEmsService {
|
|
@@ -21,7 +20,6 @@ export declare abstract class AbstractEmsService implements IEmsService {
|
|
|
21
20
|
label: string;
|
|
22
21
|
}[];
|
|
23
22
|
getMarkdownAttribution(): string;
|
|
24
|
-
getOrigin(): string;
|
|
25
23
|
/**
|
|
26
24
|
* Checks if url is absolute. If not, prepend the basePath.
|
|
27
25
|
*/
|
package/target/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
23
|
|
|
24
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
25
|
|
|
26
|
-
const DEFAULT_EMS_VERSION = '8.
|
|
26
|
+
const DEFAULT_EMS_VERSION = '8.3';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.AbstractEmsService = void 0;
|
|
7
7
|
|
|
8
|
-
var _origin = require("./origin");
|
|
9
|
-
|
|
10
8
|
var _utils = require("./utils");
|
|
11
9
|
|
|
12
10
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -56,10 +54,6 @@ class AbstractEmsService {
|
|
|
56
54
|
|
|
57
55
|
return attributions.join('|');
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
getOrigin() {
|
|
61
|
-
return _origin.ORIGIN.EMS;
|
|
62
|
-
}
|
|
63
57
|
/**
|
|
64
58
|
* Checks if url is absolute. If not, prepend the basePath.
|
|
65
59
|
*/
|
package/target/node/index.js
CHANGED
|
@@ -9,22 +9,28 @@ Object.defineProperty(exports, "EMSClient", {
|
|
|
9
9
|
return _ems_client.EMSClient;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "EmsSprite", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _tms_service.EmsSprite;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "EmsSpriteSheet", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _tms_service.EmsSpriteSheet;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "FileLayer", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _file_layer.FileLayer;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "FileLayerField", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _ems_client.FileLayerField;
|
|
28
34
|
}
|
|
29
35
|
});
|
|
30
36
|
Object.defineProperty(exports, "TMSService", {
|
|
@@ -36,8 +42,6 @@ Object.defineProperty(exports, "TMSService", {
|
|
|
36
42
|
|
|
37
43
|
var _ems_client = require("./ems_client");
|
|
38
44
|
|
|
39
|
-
var _origin = require("./origin");
|
|
40
|
-
|
|
41
45
|
var _file_layer = require("./file_layer");
|
|
42
46
|
|
|
43
47
|
var _tms_service = require("./tms_service");
|
|
@@ -59,20 +59,24 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
59
59
|
url
|
|
60
60
|
} = sources[sourceName];
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
if (url) {
|
|
63
|
+
var _sourceJson$tiles;
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
const extendedTileUrls = sourceJson.tiles.map(tileUrl => {
|
|
68
|
-
const url = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
67
|
+
const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const sourceJson = await this._emsClient.getManifest(extendedUrl);
|
|
70
|
+
const tiles = sourceJson === null || sourceJson === void 0 ? void 0 : (_sourceJson$tiles = sourceJson.tiles) === null || _sourceJson$tiles === void 0 ? void 0 : _sourceJson$tiles.map(tileUrl => {
|
|
71
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
72
|
+
|
|
73
|
+
return this._emsClient.extendUrlWithParams(directUrl);
|
|
74
|
+
});
|
|
75
|
+
inlinedSources[sourceName] = { ...sourceJson,
|
|
76
|
+
type: 'vector',
|
|
77
|
+
tiles
|
|
78
|
+
};
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
return { ...vectorJson,
|
|
@@ -116,14 +120,13 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
async getUrlTemplateForVector(sourceId) {
|
|
119
|
-
|
|
123
|
+
var _tileJson$sources$sou, _tileJson$sources$sou2;
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
125
|
+
const tileJson = await this._getVectorStyleJsonInlined();
|
|
126
|
+
const url = tileJson === null || tileJson === void 0 ? void 0 : (_tileJson$sources$sou = tileJson.sources[sourceId]) === null || _tileJson$sources$sou === void 0 ? void 0 : (_tileJson$sources$sou2 = _tileJson$sources$sou.tiles) === null || _tileJson$sources$sou2 === void 0 ? void 0 : _tileJson$sources$sou2.pop();
|
|
124
127
|
|
|
125
|
-
if (
|
|
126
|
-
const directUrl = this._proxyPath + this._getAbsoluteUrl(
|
|
128
|
+
if (url) {
|
|
129
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
127
130
|
|
|
128
131
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
129
132
|
} else {
|
|
@@ -241,7 +244,7 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
241
244
|
async _getSpriteSheetRootPath() {
|
|
242
245
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
243
246
|
|
|
244
|
-
if (vectorStyleJson) {
|
|
247
|
+
if (vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.sprite) {
|
|
245
248
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite);
|
|
246
249
|
} else {
|
|
247
250
|
return '';
|
|
@@ -251,7 +254,7 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
251
254
|
async _getUrlTemplateForGlyphs() {
|
|
252
255
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
253
256
|
|
|
254
|
-
if (vectorStyleJson) {
|
|
257
|
+
if (vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.glyphs) {
|
|
255
258
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs);
|
|
256
259
|
} else {
|
|
257
260
|
return '';
|
package/target/tms_service.d.ts
CHANGED
|
@@ -1,43 +1,23 @@
|
|
|
1
|
+
import { StyleSpecification, VectorSourceSpecification } from 'maplibre-gl';
|
|
1
2
|
import { EMSClient, TMSServiceConfig } from './ems_client';
|
|
2
3
|
import { AbstractEmsService } from './ems_service';
|
|
3
|
-
declare type
|
|
4
|
-
type: 'vector';
|
|
5
|
-
url: string;
|
|
6
|
-
tiles: string[];
|
|
7
|
-
bounds?: number[];
|
|
8
|
-
scheme?: 'xyz' | 'tms';
|
|
9
|
-
minzoom?: number;
|
|
10
|
-
maxzoom?: number;
|
|
11
|
-
attribution?: string;
|
|
12
|
-
};
|
|
13
|
-
declare type EmsVectorSources = {
|
|
14
|
-
[sourceName: string]: EmsVectorSource;
|
|
15
|
-
};
|
|
16
|
-
declare type EmsVectorStyle = {
|
|
17
|
-
sources: EmsVectorSources;
|
|
18
|
-
sprite: string;
|
|
19
|
-
glyphs: string;
|
|
20
|
-
bearing?: number;
|
|
21
|
-
center?: number[];
|
|
22
|
-
layers?: unknown[];
|
|
23
|
-
metadata?: unknown;
|
|
24
|
-
name?: string;
|
|
25
|
-
pitch?: number;
|
|
26
|
-
light?: unknown;
|
|
27
|
-
transition?: unknown;
|
|
28
|
-
version: number;
|
|
29
|
-
zoom?: number;
|
|
30
|
-
};
|
|
31
|
-
declare type EmsSprite = {
|
|
4
|
+
export declare type EmsSprite = {
|
|
32
5
|
height: number;
|
|
33
6
|
pixelRatio: number;
|
|
34
7
|
width: number;
|
|
35
8
|
x: number;
|
|
36
9
|
y: number;
|
|
10
|
+
sdf?: boolean;
|
|
37
11
|
};
|
|
38
|
-
declare type EmsSpriteSheet = {
|
|
12
|
+
export declare type EmsSpriteSheet = {
|
|
39
13
|
[spriteName: string]: EmsSprite;
|
|
40
14
|
};
|
|
15
|
+
declare type EmsVectorSources = {
|
|
16
|
+
[sourceName: string]: VectorSourceSpecification;
|
|
17
|
+
};
|
|
18
|
+
declare type EmsVectorStyle = StyleSpecification & {
|
|
19
|
+
sources: EmsVectorSources;
|
|
20
|
+
};
|
|
41
21
|
declare type EmsRasterStyle = {
|
|
42
22
|
tilejson: string;
|
|
43
23
|
name: string;
|
package/target/web/ems_client.js
CHANGED
|
@@ -23,7 +23,7 @@ import semver from 'semver';
|
|
|
23
23
|
import { format as formatUrl, parse as parseUrl } from 'url';
|
|
24
24
|
import { toAbsoluteUrl } from './utils';
|
|
25
25
|
import LRUCache from 'lru-cache';
|
|
26
|
-
var DEFAULT_EMS_VERSION = '8.
|
|
26
|
+
var DEFAULT_EMS_VERSION = '8.3';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
|
@@ -12,7 +12,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
12
12
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
13
13
|
* 2.0.
|
|
14
14
|
*/
|
|
15
|
-
import { ORIGIN } from './origin';
|
|
16
15
|
import { toAbsoluteUrl } from './utils';
|
|
17
16
|
export var AbstractEmsService = /*#__PURE__*/function () {
|
|
18
17
|
function AbstractEmsService(config, emsClient, proxyPath) {
|
|
@@ -70,11 +69,6 @@ export var AbstractEmsService = /*#__PURE__*/function () {
|
|
|
70
69
|
|
|
71
70
|
return attributions.join('|');
|
|
72
71
|
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "getOrigin",
|
|
75
|
-
value: function getOrigin() {
|
|
76
|
-
return ORIGIN.EMS;
|
|
77
|
-
}
|
|
78
72
|
/**
|
|
79
73
|
* Checks if url is absolute. If not, prepend the basePath.
|
|
80
74
|
*/
|
package/target/web/index.js
CHANGED
|
@@ -5,6 +5,5 @@
|
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
7
|
export { EMSClient, FileLayerField } from './ems_client';
|
|
8
|
-
export { ORIGIN } from './origin';
|
|
9
8
|
export { FileLayer } from './file_layer';
|
|
10
|
-
export { TMSService } from './tms_service';
|
|
9
|
+
export { TMSService, EmsSprite, EmsSpriteSheet } from './tms_service';
|
|
@@ -118,7 +118,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
118
118
|
}))));
|
|
119
119
|
|
|
120
120
|
_defineProperty(_assertThisInitialized(_this), "_getVectorStyleJsonInlined", _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
121
|
-
var vectorJson, inlinedSources, sources, _iterator, _step, _sourceName, url, sourceUrl, extendedUrl, sourceJson,
|
|
121
|
+
var vectorJson, inlinedSources, sources, _iterator, _step, _sourceName, url, _sourceJson$tiles, sourceUrl, extendedUrl, sourceJson, tiles;
|
|
122
122
|
|
|
123
123
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
124
124
|
while (1) {
|
|
@@ -131,7 +131,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
131
131
|
vectorJson = _context3.sent;
|
|
132
132
|
|
|
133
133
|
if (!vectorJson) {
|
|
134
|
-
_context3.next =
|
|
134
|
+
_context3.next = 44;
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -144,64 +144,70 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
144
144
|
|
|
145
145
|
case 9:
|
|
146
146
|
if ((_step = _iterator.n()).done) {
|
|
147
|
-
_context3.next =
|
|
147
|
+
_context3.next = 22;
|
|
148
148
|
break;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
_sourceName = _step.value;
|
|
152
152
|
url = sources[_sourceName].url;
|
|
153
|
+
|
|
154
|
+
if (!url) {
|
|
155
|
+
_context3.next = 20;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
153
159
|
sourceUrl = _this._proxyPath + _this._getAbsoluteUrl(url);
|
|
154
160
|
extendedUrl = _this._emsClient.extendUrlWithParams(sourceUrl);
|
|
155
|
-
_context3.next =
|
|
161
|
+
_context3.next = 17;
|
|
156
162
|
return _this._emsClient.getManifest(extendedUrl);
|
|
157
163
|
|
|
158
|
-
case
|
|
164
|
+
case 17:
|
|
159
165
|
sourceJson = _context3.sent;
|
|
160
|
-
|
|
161
|
-
var
|
|
166
|
+
tiles = sourceJson === null || sourceJson === void 0 ? void 0 : (_sourceJson$tiles = sourceJson.tiles) === null || _sourceJson$tiles === void 0 ? void 0 : _sourceJson$tiles.map(function (tileUrl) {
|
|
167
|
+
var directUrl = _this._proxyPath + _this._getAbsoluteUrl(tileUrl);
|
|
162
168
|
|
|
163
|
-
return _this._emsClient.extendUrlWithParams(
|
|
169
|
+
return _this._emsClient.extendUrlWithParams(directUrl);
|
|
164
170
|
});
|
|
165
171
|
inlinedSources[_sourceName] = _objectSpread(_objectSpread({}, sourceJson), {}, {
|
|
166
172
|
type: 'vector',
|
|
167
|
-
tiles:
|
|
173
|
+
tiles: tiles
|
|
168
174
|
});
|
|
169
175
|
|
|
170
|
-
case
|
|
176
|
+
case 20:
|
|
171
177
|
_context3.next = 9;
|
|
172
178
|
break;
|
|
173
179
|
|
|
174
|
-
case
|
|
175
|
-
_context3.next =
|
|
180
|
+
case 22:
|
|
181
|
+
_context3.next = 27;
|
|
176
182
|
break;
|
|
177
183
|
|
|
178
|
-
case
|
|
179
|
-
_context3.prev =
|
|
184
|
+
case 24:
|
|
185
|
+
_context3.prev = 24;
|
|
180
186
|
_context3.t0 = _context3["catch"](7);
|
|
181
187
|
|
|
182
188
|
_iterator.e(_context3.t0);
|
|
183
189
|
|
|
184
|
-
case
|
|
185
|
-
_context3.prev =
|
|
190
|
+
case 27:
|
|
191
|
+
_context3.prev = 27;
|
|
186
192
|
|
|
187
193
|
_iterator.f();
|
|
188
194
|
|
|
189
|
-
return _context3.finish(
|
|
195
|
+
return _context3.finish(27);
|
|
190
196
|
|
|
191
|
-
case
|
|
197
|
+
case 30:
|
|
192
198
|
_context3.t1 = _objectSpread;
|
|
193
199
|
_context3.t2 = _objectSpread({}, vectorJson);
|
|
194
200
|
_context3.t3 = {};
|
|
195
201
|
_context3.t4 = inlinedSources;
|
|
196
|
-
_context3.next =
|
|
202
|
+
_context3.next = 36;
|
|
197
203
|
return _this._getSpriteSheetRootPath();
|
|
198
204
|
|
|
199
|
-
case
|
|
205
|
+
case 36:
|
|
200
206
|
_context3.t5 = _context3.sent;
|
|
201
|
-
_context3.next =
|
|
207
|
+
_context3.next = 39;
|
|
202
208
|
return _this._getUrlTemplateForGlyphs();
|
|
203
209
|
|
|
204
|
-
case
|
|
210
|
+
case 39:
|
|
205
211
|
_context3.t6 = _context3.sent;
|
|
206
212
|
_context3.t7 = {
|
|
207
213
|
sources: _context3.t4,
|
|
@@ -210,15 +216,15 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
210
216
|
};
|
|
211
217
|
return _context3.abrupt("return", (0, _context3.t1)(_context3.t2, _context3.t3, _context3.t7));
|
|
212
218
|
|
|
213
|
-
case
|
|
219
|
+
case 44:
|
|
214
220
|
return _context3.abrupt("return");
|
|
215
221
|
|
|
216
|
-
case
|
|
222
|
+
case 45:
|
|
217
223
|
case "end":
|
|
218
224
|
return _context3.stop();
|
|
219
225
|
}
|
|
220
226
|
}
|
|
221
|
-
}, _callee3, null, [[7,
|
|
227
|
+
}, _callee3, null, [[7, 24, 27, 30]]);
|
|
222
228
|
}))));
|
|
223
229
|
|
|
224
230
|
_this._config = config;
|
|
@@ -315,7 +321,9 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
315
321
|
key: "getUrlTemplateForVector",
|
|
316
322
|
value: function () {
|
|
317
323
|
var _getUrlTemplateForVector = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(sourceId) {
|
|
318
|
-
var
|
|
324
|
+
var _tileJson$sources$sou, _tileJson$sources$sou2;
|
|
325
|
+
|
|
326
|
+
var tileJson, url, directUrl;
|
|
319
327
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
320
328
|
while (1) {
|
|
321
329
|
switch (_context6.prev = _context6.next) {
|
|
@@ -325,27 +333,20 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
325
333
|
|
|
326
334
|
case 2:
|
|
327
335
|
tileJson = _context6.sent;
|
|
336
|
+
url = tileJson === null || tileJson === void 0 ? void 0 : (_tileJson$sources$sou = tileJson.sources[sourceId]) === null || _tileJson$sources$sou === void 0 ? void 0 : (_tileJson$sources$sou2 = _tileJson$sources$sou.tiles) === null || _tileJson$sources$sou2 === void 0 ? void 0 : _tileJson$sources$sou2.pop();
|
|
328
337
|
|
|
329
|
-
if (
|
|
330
|
-
_context6.next =
|
|
338
|
+
if (!url) {
|
|
339
|
+
_context6.next = 9;
|
|
331
340
|
break;
|
|
332
341
|
}
|
|
333
342
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
case 5:
|
|
337
|
-
if (!(tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles)) {
|
|
338
|
-
_context6.next = 10;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
343
|
+
directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
343
344
|
return _context6.abrupt("return", this._emsClient.extendUrlWithParams(directUrl));
|
|
344
345
|
|
|
345
|
-
case
|
|
346
|
+
case 9:
|
|
346
347
|
return _context6.abrupt("return", '');
|
|
347
348
|
|
|
348
|
-
case
|
|
349
|
+
case 10:
|
|
349
350
|
case "end":
|
|
350
351
|
return _context6.stop();
|
|
351
352
|
}
|
|
@@ -703,7 +704,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
703
704
|
case 2:
|
|
704
705
|
vectorStyleJson = _context14.sent;
|
|
705
706
|
|
|
706
|
-
if (!vectorStyleJson) {
|
|
707
|
+
if (!(vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.sprite)) {
|
|
707
708
|
_context14.next = 7;
|
|
708
709
|
break;
|
|
709
710
|
}
|
|
@@ -742,7 +743,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
742
743
|
case 2:
|
|
743
744
|
vectorStyleJson = _context15.sent;
|
|
744
745
|
|
|
745
|
-
if (!vectorStyleJson) {
|
|
746
|
+
if (!(vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.glyphs)) {
|
|
746
747
|
_context15.next = 7;
|
|
747
748
|
break;
|
|
748
749
|
}
|
package/test/ems_client.test.ts
CHANGED
|
@@ -431,8 +431,8 @@ it('should retrieve vectorstylesheet with all sources inlined)', async () => {
|
|
|
431
431
|
|
|
432
432
|
expect(styleSheet!.layers!.length).toBe(111);
|
|
433
433
|
expect(styleSheet!.sprite).toBe('https://tiles.foobar/styles/osm-bright/sprite');
|
|
434
|
-
expect(styleSheet!.sources!.openmaptiles!.tiles
|
|
435
|
-
expect(styleSheet!.sources!.openmaptiles!.tiles[0]).toBe(
|
|
434
|
+
expect(styleSheet!.sources!.openmaptiles!.tiles!.length).toBe(1);
|
|
435
|
+
expect(styleSheet!.sources!.openmaptiles!.tiles![0]).toBe(
|
|
436
436
|
'https://tiles.foobar/data/v3/{z}/{x}/{y}.pbf?elastic_tile_service_tos=agree&my_app_name=tester&my_app_version=7.x.x'
|
|
437
437
|
);
|
|
438
438
|
expect(styleSheet!.sources!.openmaptiles!.type).toBe('vector');
|
package/src/origin.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
-
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
-
* 2.0.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const ORIGIN = {
|
|
9
|
-
EMS: 'elastic_maps_service',
|
|
10
|
-
KIBANA_YML: 'self_hosted',
|
|
11
|
-
};
|
package/target/node/origin.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ORIGIN = void 0;
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
10
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
11
|
-
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
12
|
-
* 2.0.
|
|
13
|
-
*/
|
|
14
|
-
const ORIGIN = {
|
|
15
|
-
EMS: 'elastic_maps_service',
|
|
16
|
-
KIBANA_YML: 'self_hosted'
|
|
17
|
-
};
|
|
18
|
-
exports.ORIGIN = ORIGIN;
|
package/target/web/origin.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
-
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
-
* 2.0.
|
|
6
|
-
*/
|
|
7
|
-
export var ORIGIN = {
|
|
8
|
-
EMS: 'elastic_maps_service',
|
|
9
|
-
KIBANA_YML: 'self_hosted'
|
|
10
|
-
};
|