tileserver-gl-light 4.1.2 → 4.2.1

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,14 +5,14 @@ import fs from 'node:fs';
5
5
 
6
6
  import clone from 'clone';
7
7
  import express from 'express';
8
- import {validate} from '@maplibre/maplibre-gl-style-spec';
8
+ import { validate } from '@maplibre/maplibre-gl-style-spec';
9
9
 
10
- import {getPublicUrl} from './utils.js';
10
+ import { getPublicUrl } from './utils.js';
11
11
 
12
12
  const httpTester = /^(http(s)?:)?\/\//;
13
13
 
14
14
  const fixUrl = (req, url, publicUrl, opt_nokey) => {
15
- if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
15
+ if (!url || typeof url !== 'string' || url.indexOf('local://') !== 0) {
16
16
  return url;
17
17
  }
18
18
  const queryParams = [];
@@ -23,8 +23,7 @@ const fixUrl = (req, url, publicUrl, opt_nokey) => {
23
23
  if (queryParams.length) {
24
24
  query = `?${queryParams.join('&')}`;
25
25
  }
26
- return url.replace(
27
- 'local://', getPublicUrl(publicUrl, req)) + query;
26
+ return url.replace('local://', getPublicUrl(publicUrl, req)) + query;
28
27
  };
29
28
 
30
29
  export const serve_style = {
@@ -43,10 +42,20 @@ export const serve_style = {
43
42
  }
44
43
  // mapbox-gl-js viewer cannot handle sprite urls with query
45
44
  if (styleJSON_.sprite) {
46
- styleJSON_.sprite = fixUrl(req, styleJSON_.sprite, item.publicUrl, false);
45
+ styleJSON_.sprite = fixUrl(
46
+ req,
47
+ styleJSON_.sprite,
48
+ item.publicUrl,
49
+ false,
50
+ );
47
51
  }
48
52
  if (styleJSON_.glyphs) {
49
- styleJSON_.glyphs = fixUrl(req, styleJSON_.glyphs, item.publicUrl, false);
53
+ styleJSON_.glyphs = fixUrl(
54
+ req,
55
+ styleJSON_.glyphs,
56
+ item.publicUrl,
57
+ false,
58
+ );
50
59
  }
51
60
  return res.send(styleJSON_);
52
61
  });
@@ -89,7 +98,9 @@ export const serve_style = {
89
98
 
90
99
  const validationErrors = validate(styleFileData);
91
100
  if (validationErrors.length > 0) {
92
- console.log(`The file "${params.style}" is not valid a valid style file:`);
101
+ console.log(
102
+ `The file "${params.style}" is not valid a valid style file:`,
103
+ );
93
104
  for (const err of validationErrors) {
94
105
  console.log(`${err.line}: ${err.message}`);
95
106
  }
@@ -102,8 +113,8 @@ export const serve_style = {
102
113
  const url = source.url;
103
114
  if (url && url.lastIndexOf('mbtiles:', 0) === 0) {
104
115
  let mbtilesFile = url.substring('mbtiles://'.length);
105
- const fromData = mbtilesFile[0] === '{' &&
106
- mbtilesFile[mbtilesFile.length - 1] === '}';
116
+ const fromData =
117
+ mbtilesFile[0] === '{' && mbtilesFile[mbtilesFile.length - 1] === '}';
107
118
 
108
119
  if (fromData) {
109
120
  mbtilesFile = mbtilesFile.substr(1, mbtilesFile.length - 2);
@@ -135,10 +146,14 @@ export const serve_style = {
135
146
  let spritePath;
136
147
 
137
148
  if (styleJSON.sprite && !httpTester.test(styleJSON.sprite)) {
138
- spritePath = path.join(options.paths.sprites,
139
- styleJSON.sprite
140
- .replace('{style}', path.basename(styleFile, '.json'))
141
- .replace('{styleJsonFolder}', path.relative(options.paths.sprites, path.dirname(styleFile)))
149
+ spritePath = path.join(
150
+ options.paths.sprites,
151
+ styleJSON.sprite
152
+ .replace('{style}', path.basename(styleFile, '.json'))
153
+ .replace(
154
+ '{styleJsonFolder}',
155
+ path.relative(options.paths.sprites, path.dirname(styleFile)),
156
+ ),
142
157
  );
143
158
  styleJSON.sprite = `local://styles/${id}/sprite`;
144
159
  }
@@ -150,9 +165,9 @@ export const serve_style = {
150
165
  styleJSON,
151
166
  spritePath,
152
167
  publicUrl,
153
- name: styleJSON.name
168
+ name: styleJSON.name,
154
169
  };
155
170
 
156
171
  return true;
157
- }
172
+ },
158
173
  };