@mapbox/mapbox-gl-style-spec 14.15.0-beta.2 → 14.15.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 (74) hide show
  1. package/deref.ts +3 -0
  2. package/diff.ts +63 -0
  3. package/dist/index.cjs +722 -47
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +85 -6
  6. package/dist/index.es.js +722 -47
  7. package/dist/index.es.js.map +1 -1
  8. package/expression/compound_expression.ts +4 -0
  9. package/expression/definitions/assertion.ts +7 -0
  10. package/expression/definitions/case.ts +2 -1
  11. package/expression/definitions/coalesce.ts +4 -0
  12. package/expression/definitions/coercion.ts +12 -0
  13. package/expression/definitions/collator.ts +8 -5
  14. package/expression/definitions/comparison.ts +12 -5
  15. package/expression/definitions/config.ts +12 -0
  16. package/expression/definitions/distance.ts +13 -2
  17. package/expression/definitions/format.ts +10 -0
  18. package/expression/definitions/image.ts +3 -0
  19. package/expression/definitions/in.ts +5 -0
  20. package/expression/definitions/index.ts +62 -10
  21. package/expression/definitions/index_of.ts +6 -0
  22. package/expression/definitions/interpolate.ts +5 -1
  23. package/expression/definitions/length.ts +2 -0
  24. package/expression/definitions/let.ts +1 -0
  25. package/expression/definitions/match.ts +5 -0
  26. package/expression/definitions/number_format.ts +7 -0
  27. package/expression/definitions/slice.ts +4 -0
  28. package/expression/definitions/within.ts +1 -0
  29. package/expression/index.ts +28 -19
  30. package/expression/parsing_context.ts +2 -0
  31. package/expression/types/image_variant.ts +3 -0
  32. package/expression/types.ts +1 -2
  33. package/expression/values.ts +1 -0
  34. package/feature_filter/convert.ts +9 -1
  35. package/feature_filter/index.ts +41 -1
  36. package/format.ts +5 -0
  37. package/function/convert.ts +5 -0
  38. package/function/index.ts +79 -25
  39. package/group_by_layout.ts +4 -5
  40. package/migrate/v8.ts +42 -3
  41. package/migrate/v9.ts +5 -0
  42. package/migrate.ts +1 -0
  43. package/package.json +1 -1
  44. package/read_style.ts +2 -0
  45. package/reference/v8.json +457 -12
  46. package/rollup.config.js +1 -0
  47. package/test.js +4 -0
  48. package/types.ts +74 -5
  49. package/util/geometry_util.ts +4 -0
  50. package/validate/validate.ts +1 -0
  51. package/validate/validate_appearance.ts +101 -0
  52. package/validate/validate_array.ts +1 -0
  53. package/validate/validate_expression.ts +48 -3
  54. package/validate/validate_filter.ts +5 -3
  55. package/validate/validate_fog.ts +6 -0
  56. package/validate/validate_function.ts +2 -0
  57. package/validate/validate_iconset.ts +1 -0
  58. package/validate/validate_import.ts +2 -2
  59. package/validate/validate_layer.ts +37 -4
  60. package/validate/validate_light.ts +6 -0
  61. package/validate/validate_lights.ts +9 -0
  62. package/validate/validate_model.ts +1 -2
  63. package/validate/validate_number.ts +2 -0
  64. package/validate/validate_object.ts +7 -0
  65. package/validate/validate_projection.ts +2 -0
  66. package/validate/validate_property.ts +15 -4
  67. package/validate/validate_rain.ts +5 -0
  68. package/validate/validate_snow.ts +5 -0
  69. package/validate/validate_source.ts +12 -0
  70. package/validate/validate_style.ts +1 -0
  71. package/validate/validate_terrain.ts +6 -0
  72. package/validate_mapbox_api_supported.ts +1 -0
  73. package/visit.ts +2 -0
  74. package/util/extend.ts +0 -9
package/function/index.ts CHANGED
@@ -3,7 +3,6 @@
3
3
 
4
4
  import * as colorSpaces from '../util/color_spaces';
5
5
  import Color from '../util/color';
6
- import extend from '../util/extend';
7
6
  import {getType, isNumber} from '../util/get_type';
8
7
  import * as interpolate from '../util/interpolate';
9
8
  import Interpolate from '../expression/definitions/interpolate';
@@ -22,30 +21,42 @@ function identityFunction(x) {
22
21
  }
23
22
 
24
23
  export function createFunction(parameters, propertySpec) {
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
25
25
  const isColor = propertySpec.type === 'color';
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
26
27
  const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';
28
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
27
29
  const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
28
30
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
29
32
  const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');
30
33
 
31
34
  if (isColor) {
32
- parameters = extend({}, parameters);
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
36
+ parameters = Object.assign({}, parameters);
33
37
 
38
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
34
39
  if (parameters.stops) {
40
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
35
41
  parameters.stops = parameters.stops.map((stop) => {
36
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
42
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
37
43
  return [stop[0], Color.parse(stop[1])];
38
44
  });
39
45
  }
40
46
 
47
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
41
48
  if (parameters.default) {
49
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
42
50
  parameters.default = Color.parse(parameters.default);
43
51
  } else {
52
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
44
53
  parameters.default = Color.parse(propertySpec.default);
45
54
  }
46
55
  }
47
56
 
57
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
48
58
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
59
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
49
60
  throw new Error(`Unknown color space: ${parameters.colorSpace}`);
50
61
  }
51
62
 
@@ -60,12 +71,16 @@ export function createFunction(parameters, propertySpec) {
60
71
  innerFun = evaluateCategoricalFunction;
61
72
 
62
73
  // For categorical functions, generate an Object as a hashmap of the stops for fast searching
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
63
75
  hashedStops = Object.create(null);
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
64
77
  for (const stop of parameters.stops) {
78
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
65
79
  hashedStops[stop[0]] = stop[1];
66
80
  }
67
81
 
68
82
  // Infer key type based on first stop key-- used to encforce strict type checking later
83
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
69
84
  categoricalKeyType = typeof parameters.stops[0][0];
70
85
 
71
86
  } else if (type === 'identity') {
@@ -78,24 +93,35 @@ export function createFunction(parameters, propertySpec) {
78
93
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
94
  const featureFunctions: Record<string, any> = {};
80
95
  const zoomStops = [];
96
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
81
97
  for (let s = 0; s < parameters.stops.length; s++) {
98
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
82
99
  const stop = parameters.stops[s];
100
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
83
101
  const zoom = stop[0].zoom;
102
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
84
103
  if (featureFunctions[zoom] === undefined) {
104
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
85
105
  featureFunctions[zoom] = {
106
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
86
107
  zoom,
108
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
87
109
  type: parameters.type,
110
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
88
111
  property: parameters.property,
112
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
89
113
  default: parameters.default,
90
114
  stops: []
91
115
  };
92
116
  zoomStops.push(zoom);
93
117
  }
118
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
94
119
  featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);
95
120
  }
96
121
 
97
122
  const featureFunctionStops = [];
98
123
  for (const z of zoomStops) {
124
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
99
125
  featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);
100
126
  }
101
127
 
@@ -103,39 +129,45 @@ export function createFunction(parameters, propertySpec) {
103
129
  return {
104
130
  kind: 'composite',
105
131
  interpolationType,
132
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
106
133
  interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
107
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
134
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
108
135
  zoomStops: featureFunctionStops.map(s => s[0]),
109
136
  evaluate({zoom}, properties) {
110
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
137
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
111
138
  return evaluateExponentialFunction({
112
139
  stops: featureFunctionStops,
140
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
113
141
  base: parameters.base
142
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
114
143
  }, propertySpec, zoom).evaluate(zoom, properties);
115
144
  }
116
145
  };
117
146
  } else if (zoomDependent) {
118
147
  const interpolationType = type === 'exponential' ?
148
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
119
149
  {name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1} : null;
120
150
  return {
121
151
  kind: 'camera',
122
152
  interpolationType,
153
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
123
154
  interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
124
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
155
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
125
156
  zoomStops: parameters.stops.map(s => s[0]),
126
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
127
158
  evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
128
159
  };
129
160
  } else {
130
161
  return {
131
162
  kind: 'source',
132
163
  evaluate(_, feature) {
164
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
133
165
  const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;
134
166
  if (value === undefined) {
135
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
167
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
136
168
  return coalesce(parameters.default, propertySpec.default);
137
169
  }
138
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
170
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
139
171
  return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);
140
172
  }
141
173
  };
@@ -152,91 +184,112 @@ function coalesce(a, b, c) {
152
184
  }
153
185
 
154
186
  function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {
187
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
155
188
  const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input
156
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
189
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
157
190
  return coalesce(evaluated, parameters.default, propertySpec.default);
158
191
  }
159
192
 
160
193
  function evaluateIntervalFunction(parameters, propertySpec, input) {
161
194
  // Edge cases
162
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
195
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
163
196
  if (!isNumber(input)) return coalesce(parameters.default, propertySpec.default);
197
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
164
198
  const n = parameters.stops.length;
165
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
199
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
166
200
  if (n === 1) return parameters.stops[0][1];
167
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
201
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
168
202
  if (input <= parameters.stops[0][0]) return parameters.stops[0][1];
169
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
203
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
170
204
  if (input >= parameters.stops[n - 1][0]) return parameters.stops[n - 1][1];
171
205
 
172
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
206
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
173
207
  const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);
174
208
 
175
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
209
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
176
210
  return parameters.stops[index][1];
177
211
  }
178
212
 
179
213
  function evaluateExponentialFunction(parameters, propertySpec, input) {
214
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
180
215
  const base = parameters.base !== undefined ? parameters.base : 1;
181
216
 
182
217
  // Edge cases
183
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
218
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
184
219
  if (!isNumber(input)) return coalesce(parameters.default, propertySpec.default);
220
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
185
221
  const n = parameters.stops.length;
186
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
222
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
187
223
  if (n === 1) return parameters.stops[0][1];
188
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
224
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
189
225
  if (input <= parameters.stops[0][0]) return parameters.stops[0][1];
190
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
226
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
191
227
  if (input >= parameters.stops[n - 1][0]) return parameters.stops[n - 1][1];
192
228
 
193
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
229
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
194
230
  const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);
195
231
  const t = interpolationFactor(
196
232
  input, base,
233
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
197
234
  parameters.stops[index][0],
235
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
198
236
  parameters.stops[index + 1][0]);
199
237
 
238
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
200
239
  const outputLower = parameters.stops[index][1];
240
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
201
241
  const outputUpper = parameters.stops[index + 1][1];
242
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
202
243
  let interp = interpolate[propertySpec.type] || identityFunction;
203
244
 
245
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
204
246
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
247
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
205
248
  const colorspace = colorSpaces[parameters.colorSpace];
206
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
249
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
207
250
  interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
208
251
  }
209
252
 
253
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
210
254
  if (typeof outputLower.evaluate === 'function') {
211
255
  return {
212
256
  evaluate(...args) {
257
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
213
258
  const evaluatedLower = outputLower.evaluate.apply(undefined, args);
259
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
214
260
  const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);
215
261
  // Special case for fill-outline-color, which has no spec default.
216
262
  if (evaluatedLower === undefined || evaluatedUpper === undefined) {
217
263
  return undefined;
218
264
  }
219
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
265
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
220
266
  return interp(evaluatedLower, evaluatedUpper, t);
221
267
  }
222
268
  };
223
269
  }
224
270
 
225
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
271
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
226
272
  return interp(outputLower, outputUpper, t);
227
273
  }
228
274
 
229
275
  function evaluateIdentityFunction(parameters, propertySpec, input) {
276
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
230
277
  if (propertySpec.type === 'color') {
278
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
231
279
  input = Color.parse(input);
280
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
232
281
  } else if (propertySpec.type === 'formatted') {
282
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
233
283
  input = Formatted.fromString(input.toString());
284
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
234
285
  } else if (propertySpec.type === 'resolvedImage') {
286
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
235
287
  input = ResolvedImage.build(input.toString());
288
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
236
289
  } else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {
237
290
  input = undefined;
238
291
  }
239
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
292
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
240
293
  return coalesce(input, parameters.default, propertySpec.default);
241
294
  }
242
295
 
@@ -287,6 +340,7 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
287
340
  } else if (base === 1) {
288
341
  return progress / difference;
289
342
  } else {
343
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
290
344
  return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
291
345
  }
292
346
  }
@@ -15,8 +15,8 @@ function stringify(obj: unknown) {
15
15
  }
16
16
 
17
17
  let str = '{';
18
- for (const key of Object.keys(obj).sort()) {
19
- str += `${key}:${stringify((obj)[key])},`;
18
+ for (const key of Object.keys(obj as Record<string, unknown>).sort()) {
19
+ str += `${key}:${stringify((obj as Record<string, unknown>)[key])},`;
20
20
  }
21
21
  return `${str}}`;
22
22
  }
@@ -30,7 +30,7 @@ function getKey(layer: LayerSpecification) {
30
30
  }
31
31
 
32
32
  function containsKey(obj: unknown, key: string) {
33
- function recursiveSearch(item) {
33
+ function recursiveSearch(item: unknown): boolean {
34
34
  if (typeof item === 'string' && item === key) {
35
35
  return true;
36
36
  }
@@ -69,8 +69,7 @@ export default function groupByLayout(
69
69
  [id: string]: string;
70
70
  },
71
71
  ): Array<Array<LayerSpecification>> {
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
- const groups: Record<string, any> = {};
72
+ const groups: Record<string, LayerSpecification[]> = {};
74
73
 
75
74
  for (let i = 0; i < layers.length; i++) {
76
75
  const layer = layers[i];
package/migrate/v8.ts CHANGED
@@ -5,6 +5,7 @@ import {eachSource, eachLayer, eachProperty} from '../visit';
5
5
  function eachLayout(layer, callback) {
6
6
  for (const k in layer) {
7
7
  if (k.indexOf('layout') === 0) {
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
8
9
  callback(layer[k], k);
9
10
  }
10
11
  }
@@ -13,6 +14,7 @@ function eachLayout(layer, callback) {
13
14
  function eachPaint(layer, callback) {
14
15
  for (const k in layer) {
15
16
  if (k.indexOf('paint') === 0) {
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
16
18
  callback(layer[k], k);
17
19
  }
18
20
  }
@@ -20,7 +22,7 @@ function eachPaint(layer, callback) {
20
22
 
21
23
  function resolveConstant(style, value) {
22
24
  if (typeof value === 'string' && value[0] === '@') {
23
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
25
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
24
26
  return resolveConstant(style, style.constants[value]);
25
27
  } else {
26
28
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -29,17 +31,21 @@ function resolveConstant(style, value) {
29
31
  }
30
32
 
31
33
  function isFunction(value) {
34
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
32
35
  return Array.isArray(value.stops);
33
36
  }
34
37
 
35
38
  function renameProperty(obj, from, to) {
39
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
36
40
  obj[to] = obj[from]; delete obj[from];
37
41
  }
38
42
 
39
43
  export default function (style) {
44
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
40
45
  style.version = 8;
41
46
 
42
47
  // Rename properties, reverse coordinates in source and layers
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
43
49
  eachSource(style, (source) => {
44
50
  if (source.type === 'video' && source.url !== undefined) {
45
51
  renameProperty(source, 'url', 'urls');
@@ -51,20 +57,25 @@ export default function (style) {
51
57
  }
52
58
  });
53
59
 
60
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
54
61
  eachLayer(style, (layer) => {
55
62
  eachLayout(layer, (layout) => {
63
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
56
64
  if (layout['symbol-min-distance'] !== undefined) {
57
65
  renameProperty(layout, 'symbol-min-distance', 'symbol-spacing');
58
66
  }
59
67
  });
60
68
 
61
69
  eachPaint(layer, (paint) => {
70
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
62
71
  if (paint['background-image'] !== undefined) {
63
72
  renameProperty(paint, 'background-image', 'background-pattern');
64
73
  }
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
65
75
  if (paint['line-image'] !== undefined) {
66
76
  renameProperty(paint, 'line-image', 'line-pattern');
67
77
  }
78
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
68
79
  if (paint['fill-image'] !== undefined) {
69
80
  renameProperty(paint, 'fill-image', 'fill-pattern');
70
81
  }
@@ -72,45 +83,60 @@ export default function (style) {
72
83
  });
73
84
 
74
85
  // Inline Constants
86
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75
87
  eachProperty(style, {paint: true, layout: true}, (property) => {
88
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76
89
  const value = resolveConstant(style, property.value);
77
90
 
78
91
  if (isFunction(value)) {
92
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
79
93
  value.stops.forEach((stop) => {
94
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
80
95
  stop[1] = resolveConstant(style, stop[1]);
81
96
  });
82
97
  }
83
98
 
84
99
  property.set(value);
85
100
  });
101
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
86
102
  delete style.constants;
87
103
 
104
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
88
105
  eachLayer(style, (layer) => {
89
106
  // get rid of text-max-size, icon-max-size
90
107
  // turn text-size, icon-size into layout properties
91
108
  // https://github.com/mapbox/mapbox-gl-style-spec/issues/255
92
109
 
93
110
  eachLayout(layer, (layout) => {
111
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
94
112
  delete layout['text-max-size'];
113
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
95
114
  delete layout['icon-max-size'];
96
115
  });
97
116
 
98
117
  eachPaint(layer, (paint) => {
118
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
99
119
  if (paint['text-size']) {
100
120
  if (!layer.layout) layer.layout = {};
121
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
101
122
  layer.layout['text-size'] = paint['text-size'];
123
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
102
124
  delete paint['text-size'];
103
125
  }
104
126
 
127
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
105
128
  if (paint['icon-size']) {
106
129
  if (!layer.layout) layer.layout = {};
130
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
107
131
  layer.layout['icon-size'] = paint['icon-size'];
132
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
108
133
  delete paint['icon-size'];
109
134
  }
110
135
  });
111
136
  });
112
137
 
113
138
  function migrateFontstackURL(input) {
139
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
114
140
  const inputParsed = new URL(input);
115
141
  const inputPathnameParts = inputParsed.pathname.split('/');
116
142
 
@@ -139,15 +165,17 @@ export default function (style) {
139
165
  }
140
166
  }
141
167
 
168
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
142
169
  if (style.glyphs) {
170
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
143
171
  style.glyphs = migrateFontstackURL(style.glyphs);
144
172
  }
145
173
 
146
174
  function migrateFontStack(font) {
147
175
  function splitAndTrim(string) {
148
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
176
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
149
177
  return string.split(',').map((s) => {
150
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
178
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
151
179
  return s.trim();
152
180
  });
153
181
  }
@@ -162,7 +190,9 @@ export default function (style) {
162
190
  return splitAndTrim(font);
163
191
 
164
192
  } else if (typeof font === 'object') {
193
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
165
194
  font.stops.forEach((stop) => {
195
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
166
196
  stop[1] = splitAndTrim(stop[1]);
167
197
  });
168
198
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -173,9 +203,12 @@ export default function (style) {
173
203
  }
174
204
  }
175
205
 
206
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
176
207
  eachLayer(style, (layer) => {
177
208
  eachLayout(layer, (layout) => {
209
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
178
210
  if (layout['text-font']) {
211
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
179
212
  layout['text-font'] = migrateFontStack(layout['text-font']);
180
213
  }
181
214
  });
@@ -195,16 +228,22 @@ export default function (style) {
195
228
  // Symbol layers that are below another type (line, fill) of layer preserve their draw order.
196
229
 
197
230
  let firstSymbolLayer = 0;
231
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
198
232
  for (let i = style.layers.length - 1; i >= 0; i--) {
233
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
199
234
  const layer = style.layers[i];
235
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
200
236
  if (layer.type !== 'symbol') {
201
237
  firstSymbolLayer = i + 1;
202
238
  break;
203
239
  }
204
240
  }
205
241
 
242
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
206
243
  const symbolLayers = style.layers.splice(firstSymbolLayer);
244
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
207
245
  symbolLayers.reverse();
246
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
208
247
  style.layers = style.layers.concat(symbolLayers);
209
248
 
210
249
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
package/migrate/v9.ts CHANGED
@@ -3,21 +3,26 @@
3
3
  import deref from '../deref';
4
4
 
5
5
  function eachLayer(style, callback) {
6
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6
7
  for (const k in style.layers) {
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
7
9
  callback(style.layers[k]);
8
10
  }
9
11
  }
10
12
 
11
13
  export default function (style) {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
12
15
  style.version = 9;
13
16
 
14
17
  // remove user-specified refs
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
15
19
  style.layers = deref(style.layers);
16
20
 
17
21
  // remove class-specific paint properties
18
22
  eachLayer(style, (layer) => {
19
23
  for (const k in layer) {
20
24
  if (/paint\..*/.test(k)) {
25
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
26
  delete layer[k];
22
27
  }
23
28
  }
package/migrate.ts CHANGED
@@ -20,6 +20,7 @@ export default function (style: {version: 7} | StyleSpecification): StyleSpecifi
20
20
  let migrated = false;
21
21
 
22
22
  if (style.version === 7) {
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
23
24
  style = migrateToV8(style);
24
25
  migrated = true;
25
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/mapbox-gl-style-spec",
3
- "version": "14.15.0-beta.2",
3
+ "version": "14.15.0",
4
4
  "description": "a specification for mapbox gl styles",
5
5
  "author": "Mapbox",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
package/read_style.ts CHANGED
@@ -6,8 +6,10 @@ import type {StyleSpecification} from './types';
6
6
  export default function readStyle(style: string | Buffer | StyleSpecification): StyleSpecification {
7
7
  if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
8
8
  try {
9
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
9
10
  return jsonlint.parse(style.toString()) as StyleSpecification;
10
11
  } catch (e) {
12
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
11
13
  throw new ParsingError(e);
12
14
  }
13
15
  }