tileserver-gl 5.7.0-pre.0 → 5.7.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/docs/config.rst +43 -2
  3. package/docs/usage.rst +2 -1
  4. package/package.json +33 -28
  5. package/public/resources/elevation-control.js +8 -4
  6. package/public/resources/maplibre-gl-inspect.mjs +2286 -0
  7. package/public/resources/maplibre-gl-inspect.mjs.map +1 -0
  8. package/public/resources/maplibre-gl-shared.mjs +6 -0
  9. package/public/resources/maplibre-gl-shared.mjs.map +1 -0
  10. package/public/resources/maplibre-gl-worker.mjs +10 -0
  11. package/public/resources/maplibre-gl-worker.mjs.map +1 -0
  12. package/public/resources/maplibre-gl.css +1 -1
  13. package/public/resources/maplibre-gl.mjs +819 -0
  14. package/public/resources/maplibre-gl.mjs.map +1 -0
  15. package/public/templates/data.tmpl +12 -6
  16. package/public/templates/viewer.tmpl +12 -8
  17. package/src/main.js +53 -7
  18. package/src/render_mode.js +38 -0
  19. package/src/serve_data.js +29 -11
  20. package/src/serve_rendered.js +317 -249
  21. package/src/server.js +10 -10
  22. package/src/utils.js +51 -0
  23. package/test/data_decorator.js +156 -0
  24. package/test/fixtures/data-decorator-async.js +17 -0
  25. package/test/fixtures/data-decorator.js +29 -0
  26. package/test/fixtures/visual/static-512px-path-alignment-2x.png +0 -0
  27. package/test/fixtures/visual/static-marker-low-zoom-large-viewport.png +0 -0
  28. package/test/render_mode.js +48 -0
  29. package/test/sparse.js +411 -0
  30. package/test/static.js +20 -0
  31. package/test/static_images.js +10 -0
  32. package/test/tiles_data_compression.js +145 -0
  33. package/public/resources/maplibre-gl-inspect.js +0 -2934
  34. package/public/resources/maplibre-gl-inspect.js.map +0 -1
  35. package/public/resources/maplibre-gl.js +0 -59
  36. package/public/resources/maplibre-gl.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,14 +7,25 @@
7
7
  ### 🐞 Bug fixes
8
8
  - _...Add new stuff here..._
9
9
 
10
- ## 5.7.0-pre.0
10
+ ## 5.7.0
11
11
  ### ✨ Features and improvements
12
12
  - feat: add opt-in Prometheus metrics endpoint ([#2211](https://github.com/maptiler/tileserver-gl/pull/2211)) (by [navidnabavi](https://github.com/navidnabavi))
13
+ - feat: allow the data decorator to be asynchronous ([#2352](https://github.com/maptiler/tileserver-gl/pull/2352)) (by [acalcutt](https://github.com/acalcutt))
14
+ - Updates Maplibre-gl-js to v6 and maplibre-gl-inspect to v1.9.0. maplibre-gl-js v6 is ESM-only, so the viewer and data templates now load it as an ES module via an import map, and the elevation control is now an ES module. maplibre-gl-js v6 requires WebGL2; the viewer falls back to the raster (Leaflet) view without it ([#2360](https://github.com/maptiler/tileserver-gl/pull/2360)) (by [acalcutt](https://github.com/acalcutt))
13
15
 
14
16
  ### 🐞 Bug fixes
15
17
  - fix: TypeError when style source value is a string (e.g. sprite path) ([#2179](https://github.com/maptiler/tileserver-gl/pull/2179)) (by [app/copilot-swe-agent](https://github.com/app/copilot-swe-agent))
16
18
  - fix: clean stale tile-source state on SIGHUP reload ([#2158](https://github.com/maptiler/tileserver-gl/pull/2158)) (by [bvitlas](https://github.com/bvitlas))
17
19
  - fix: correctly handle public_url in wmts endpoint ([#2205](https://github.com/maptiler/tileserver-gl/pull/2205)) (by [andrewlaguna824](https://github.com/andrewlaguna824))
20
+ - fix: never leave a renderer request or pool slot unsettled ([#2347](https://github.com/maptiler/tileserver-gl/pull/2347)) (by [acalcutt](https://github.com/acalcutt))
21
+ - fix: honour sparse set in archive metadata ([#2350](https://github.com/maptiler/tileserver-gl/pull/2350)) (by [acalcutt](https://github.com/acalcutt))
22
+ - fix: data decorator never ran on Windows, or on PMTiles style sources ([#2351](https://github.com/maptiler/tileserver-gl/pull/2351)) (by [acalcutt](https://github.com/acalcutt))
23
+ - chore: drop unused host-validation imports from server.js ([#2349](https://github.com/maptiler/tileserver-gl/pull/2349)) (by [acalcutt](https://github.com/acalcutt))
24
+ - fix: restore the format-based sparse default ([#2348](https://github.com/maptiler/tileserver-gl/pull/2348)) (by [acalcutt](https://github.com/acalcutt))
25
+ - fix: align 512px static map overlays ([#2344](https://github.com/maptiler/tileserver-gl/pull/2344)) (by [miakh](https://github.com/miakh))
26
+ - fix: allow native install scripts under npm 12 so canvas builds ([#2343](https://github.com/maptiler/tileserver-gl/pull/2343)) (by [mikey923](https://github.com/mikey923))
27
+ - fix: align low-zoom static map overlays ([#2355](https://github.com/maptiler/tileserver-gl/pull/2355)) (by [miakh](https://github.com/miakh))
28
+ - perf: avoid recompressing gzipped mvt tiles ([#2369](https://github.com/maptiler/tileserver-gl/pull/2369)) (by [bvitlas](https://github.com/bvitlas))
18
29
 
19
30
  ## 5.6.0
20
31
  ### ✨ Features and improvements
package/docs/config.rst CHANGED
@@ -214,6 +214,41 @@ Allows the rendering of inline marker icons or base64 urls.
214
214
  For security reasons only allow this if you can control the origins from where the markers are fetched!
215
215
  Not used by default.
216
216
 
217
+ ``dataDecorator``
218
+ -----------------
219
+
220
+ Path (relative to ``root``) to a JavaScript module whose default export is called to modify tile data and TileJSON on the fly. Not used by default.
221
+
222
+ The module must be an ES module with a default export. The function is called as ``decorate(id, type, data, z, x, y)`` and **must return the value**, modified or not - returning nothing discards the data.
223
+
224
+ The function may be ``async``, or return a promise. The return value is awaited, so the decorator can do asynchronous work such as a lookup or a fetch. It is awaited on every call, including once per tile for ``'data'``, so keep it fast or cache inside the module.
225
+
226
+ ``id``
227
+ The data source id from the config, or the source name from the style.
228
+
229
+ ``type``
230
+ Either ``'tilejson'`` or ``'data'``.
231
+
232
+ ``data``
233
+ For ``'tilejson'``, the TileJSON object served at ``/data/{id}.json``, or a style's local source object. For ``'data'``, a ``Buffer`` of vector tile bytes, already un-gzipped.
234
+
235
+ ``z``, ``x``, ``y``
236
+ Tile coordinates. Only passed for ``'data'``.
237
+
238
+ ``'data'`` is called for vector (pbf) sources only, both for ``/data/{id}/{z}/{x}/{y}.pbf`` and for the tiles fed to the raster renderer. Raster tiles are never passed through it.
239
+
240
+ .. code-block:: js
241
+
242
+ // decorator.js
243
+ export default function (id, type, data, z, x, y) {
244
+ if (type === 'tilejson') {
245
+ data.attribution = 'Example attribution';
246
+ }
247
+ return data;
248
+ }
249
+
250
+ Errors loading the module are logged and the server starts without a decorator, so check the startup output if it does not appear to run.
251
+
217
252
 
218
253
  ``styles``
219
254
  ==========
@@ -294,8 +329,14 @@ Here are the available options for each data source:
294
329
  * ``true`` - Returns HTTP 404, allowing clients like MapLibre to overzoom and use parent tiles. Use this for terrain or datasets with uneven zoom coverage.
295
330
  * ``false`` - Returns HTTP 204 (No Content), signaling an intentionally empty tile and preventing overzoom.
296
331
 
297
- This can be set globally in the top-level options or per-data-source (per-source overrides global).
298
- Default: Depends on tile format - ``false`` for vector tiles (pbf), ``true`` for raster tiles (png, webp, jpg, etc.).
332
+ Resolved from the first of these that is set, highest priority first:
333
+
334
+ 1. ``sparse`` on the data source in this config file
335
+ 2. ``sparse`` in the top-level ``options``
336
+ 3. ``sparse`` in the archive's own metadata (the MBTiles ``metadata`` table, or the PMTiles metadata JSON)
337
+ 4. The tile format - ``false`` for vector tiles (pbf), ``true`` for raster tiles (png, webp, jpg, etc.)
338
+
339
+ Config outranks archive metadata, so a source that declares the wrong value for your deployment can be corrected without rewriting the file. MBTiles metadata values are text; ``"true"``/``"false"`` and ``"1"``/``"0"`` are both understood, and anything else is ignored rather than guessed at.
299
340
 
300
341
  ``s3Profile`` (string)
301
342
  Specifies the AWS credential profile to use for S3 PMTiles sources. The profile must be defined in your ``~/.aws/credentials`` file.
package/docs/usage.rst CHANGED
@@ -119,7 +119,8 @@ TileServer GL can fetch tiles from remote HTTP/HTTPS sources referenced in your
119
119
 
120
120
  **Default behavior:**
121
121
  - Default timeout is 15 seconds (15000 milliseconds)
122
- - If a remote tile request exceeds this timeout, an error is logged and an empty tile is returned to the renderer
122
+ - If a remote tile request exceeds this timeout, an error is logged and the tile is treated as missing
123
+ - What "missing" means follows the source's ``sparse`` setting: raster sources are sparse by default, so MapLibre overzooms from a parent tile, while vector sources are not, so an empty tile is returned to the renderer. See ``sparse`` in :doc:`/config`.
123
124
 
124
125
  **Tuning the timeout:**
125
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tileserver-gl",
3
- "version": "5.7.0-pre.0",
3
+ "version": "5.7.0",
4
4
  "description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "prepare": "npm run copy:maplibre && npm run copy:maplibre-inspect && npm run copy:mapbox-rtl-text && npm run copy:leaflet && npm run copy:leaflet-hash",
22
- "copy:maplibre": "copyfiles -EVf node_modules/maplibre-gl/dist/maplibre-gl.js node_modules/maplibre-gl/dist/maplibre-gl.js.map node_modules/maplibre-gl/dist/maplibre-gl.css public/resources/",
23
- "copy:maplibre-inspect": "copyfiles -EVf node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.js node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.js.map node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.css public/resources/",
22
+ "copy:maplibre": "copyfiles -EVf node_modules/maplibre-gl/dist/maplibre-gl.mjs node_modules/maplibre-gl/dist/maplibre-gl.mjs.map node_modules/maplibre-gl/dist/maplibre-gl-shared.mjs node_modules/maplibre-gl/dist/maplibre-gl-shared.mjs.map node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs.map node_modules/maplibre-gl/dist/maplibre-gl.css public/resources/",
23
+ "copy:maplibre-inspect": "copyfiles -EVf node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.mjs node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.mjs.map node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.css public/resources/",
24
24
  "copy:mapbox-rtl-text": "copyfiles -EVf node_modules/@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js public/resources/",
25
25
  "copy:leaflet": "copyfiles -EVf node_modules/leaflet/dist/leaflet.js node_modules/leaflet/dist/leaflet.js.map node_modules/leaflet/dist/leaflet.css node_modules/leaflet/dist/leaflet-hash.js public/resources/",
26
26
  "copy:leaflet-hash": "copyfiles -EVf node_modules/leaflet-hash/leaflet-hash.js public/resources/",
@@ -37,61 +37,61 @@
37
37
  "docker": "docker build . && docker run --rm -i -p 8080:8080 $(docker build -q .)"
38
38
  },
39
39
  "dependencies": {
40
- "@aws-sdk/client-s3": "^3.1055.0",
41
- "@jsse/pbfont": "^0.3.3",
40
+ "@aws-sdk/client-s3": "^3.1081.0",
41
+ "@jsse/pbfont": "^0.3.4",
42
42
  "@mapbox/mapbox-gl-rtl-text": "0.4.0",
43
43
  "@mapbox/mbtiles": "0.12.1",
44
44
  "@mapbox/polyline": "^1.2.1",
45
45
  "@mapbox/sphericalmercator": "2.0.2",
46
46
  "@mapbox/vector-tile": "3.0.0",
47
- "@maplibre/maplibre-gl-inspect": "1.8.2",
47
+ "@maplibre/maplibre-gl-inspect": "1.9.0",
48
48
  "@maplibre/maplibre-gl-native": "6.4.1",
49
- "@maplibre/maplibre-gl-style-spec": "24.8.5",
49
+ "@maplibre/maplibre-gl-style-spec": "24.10.0",
50
50
  "@sindresorhus/fnv1a": "3.1.0",
51
51
  "advanced-pool": "0.3.3",
52
52
  "canvas": "3.2.3",
53
53
  "chokidar": "5.0.0",
54
54
  "clone": "2.1.2",
55
55
  "color": "5.0.3",
56
- "commander": "14.0.3",
56
+ "commander": "15.0.0",
57
57
  "copyfiles": "2.4.1",
58
58
  "cors": "2.8.6",
59
59
  "express": "5.2.1",
60
- "handlebars": "4.7.9",
60
+ "handlebars": "4.7.10",
61
61
  "http-shutdown": "1.2.2",
62
62
  "leaflet": "1.9.4",
63
63
  "leaflet-hash": "0.2.1",
64
- "maplibre-gl": "5.24.0",
65
- "morgan": "1.10.1",
66
- "pbf": "5.0.0",
64
+ "maplibre-gl": "6.11.2",
65
+ "morgan": "1.12.1",
66
+ "pbf": "5.1.0",
67
67
  "pmtiles": "4.4.1",
68
- "proj4": "2.20.8",
68
+ "proj4": "2.20.9",
69
69
  "prom-client": "^15.1.3",
70
70
  "sanitize-filename": "1.6.4",
71
71
  "secure-json-parse": "^4.1.0",
72
- "semver": "^7.8.1",
73
- "sharp": "0.34.5",
72
+ "semver": "^7.8.5",
73
+ "sharp": "0.35.5",
74
74
  "tileserver-gl-styles": "2.0.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@commitlint/cli": "^21.0.1",
78
- "@commitlint/config-conventional": "^21.0.1",
77
+ "@commitlint/cli": "^21.2.0",
78
+ "@commitlint/config-conventional": "^21.2.0",
79
79
  "@eslint/js": "^10.0.1",
80
- "@typescript-eslint/eslint-plugin": "^8.60.0",
81
- "@typescript-eslint/parser": "^8.60.0",
80
+ "@typescript-eslint/eslint-plugin": "^8.63.0",
81
+ "@typescript-eslint/parser": "^8.61.1",
82
82
  "chai": "6.2.2",
83
83
  "cross-env": "^10.1.0",
84
- "eslint": "^10.4.0",
84
+ "eslint": "^10.6.0",
85
85
  "eslint-config-prettier": "^10.1.8",
86
- "eslint-plugin-jsdoc": "^63.0.0",
87
- "eslint-plugin-prettier": "^5.5.5",
88
- "eslint-plugin-security": "^4.0.0",
89
- "globals": "^17.6.0",
90
- "lint-staged": "^17.0.5",
91
- "mocha": "^11.7.6",
86
+ "eslint-plugin-jsdoc": "^63.0.12",
87
+ "eslint-plugin-prettier": "^5.5.6",
88
+ "eslint-plugin-security": "^4.0.1",
89
+ "globals": "^17.7.0",
90
+ "lint-staged": "^17.0.8",
91
+ "mocha": "^12.0.0",
92
92
  "node-addon-api": "^8",
93
93
  "pixelmatch": "^7.2.0",
94
- "prettier": "^3.8.3",
94
+ "prettier": "^3.9.4",
95
95
  "should": "^13.2.3",
96
96
  "supertest": "^7.2.2",
97
97
  "yaml-lint": "^1.7.0"
@@ -113,5 +113,10 @@
113
113
  "bugs": {
114
114
  "url": "https://github.com/maptiler/tileserver-gl/issues"
115
115
  },
116
- "homepage": "https://github.com/maptiler/tileserver-gl#readme"
116
+ "homepage": "https://github.com/maptiler/tileserver-gl#readme",
117
+ "allowScripts": {
118
+ "canvas": true,
119
+ "sqlite3": true,
120
+ "@maplibre/maplibre-gl-native": true
121
+ }
117
122
  }
@@ -1,4 +1,6 @@
1
- class ElevationInfoControl {
1
+ import { Marker } from 'maplibre-gl';
2
+
3
+ export default class ElevationInfoControl {
2
4
  constructor(options) {
3
5
  this.url = options["url"];
4
6
  this.originalTerrain = null;
@@ -49,10 +51,12 @@ class ElevationInfoControl {
49
51
  this.controlContainer.classList.add("maplibre-ctrl-elevation");
50
52
  this.controlContainer.textContent = "Elevation: Click on Map";
51
53
 
52
- this.marker = new maplibregl.Marker();
54
+ this.marker = new Marker();
53
55
 
54
56
  map.on('click', (e) => {
55
- if (!map.transform.isPointOnMapSurface(e.point)) {
57
+ // map.transform was removed in maplibre-gl v6; a click off the globe unprojects
58
+ // to the horizon, so it does not round-trip back to the clicked pixel
59
+ if (map.project(map.unproject(e.point)).dist(e.point) > 1) {
56
60
  this.controlContainer.textContent = "Elevation: Click on Globe";
57
61
  return;
58
62
  }
@@ -77,7 +81,7 @@ class ElevationInfoControl {
77
81
  this.marker.remove();
78
82
  }
79
83
 
80
- this.marker = new maplibregl.Marker();
84
+ this.marker = new Marker();
81
85
  this.marker.setLngLat({lng: lngLat.lng, lat: lngLat.lat});
82
86
  this.marker.addTo(this.map);
83
87
  } catch (_err) {