@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/deref.ts CHANGED
@@ -7,12 +7,14 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
7
7
 
8
8
  for (const k in layer) {
9
9
  if (k !== 'ref') {
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
10
11
  result[k] = layer[k];
11
12
  }
12
13
  }
13
14
 
14
15
  refProperties.forEach((k) => {
15
16
  if (k in parent) {
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
16
18
  result[k] = parent[k];
17
19
  }
18
20
  });
@@ -36,6 +38,7 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
36
38
  export default function derefLayers(layers: Array<LayerSpecification>): Array<LayerSpecification> {
37
39
  layers = layers.slice();
38
40
 
41
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
39
42
  const map: Record<string, LayerSpecification> = Object.create(null);
40
43
  for (let i = 0; i < layers.length; i++) {
41
44
  map[layers[i].id] = layers[i];
package/diff.ts CHANGED
@@ -195,13 +195,17 @@ function updateSource(sourceId: string, after: Sources, commands: Array<Command>
195
195
  function canUpdateGeoJSON(before: Sources, after: Sources, sourceId: string) {
196
196
  let prop;
197
197
  for (prop in before[sourceId]) {
198
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
198
199
  if (!before[sourceId].hasOwnProperty(prop)) continue;
200
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
199
201
  if (prop !== 'data' && !isEqual(before[sourceId][prop], after[sourceId][prop])) {
200
202
  return false;
201
203
  }
202
204
  }
203
205
  for (prop in after[sourceId]) {
206
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
204
207
  if (!after[sourceId].hasOwnProperty(prop)) continue;
208
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
205
209
  if (prop !== 'data' && !isEqual(before[sourceId][prop], after[sourceId][prop])) {
206
210
  return false;
207
211
  }
@@ -217,23 +221,33 @@ function diffSources(before: Sources, after: Sources, commands: Array<Command>,
217
221
 
218
222
  // look for sources to remove
219
223
  for (sourceId in before) {
224
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
220
225
  if (!before.hasOwnProperty(sourceId)) continue;
226
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
221
227
  if (!after.hasOwnProperty(sourceId)) {
228
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
222
229
  removeSource(sourceId, commands, sourcesRemoved);
223
230
  }
224
231
  }
225
232
 
226
233
  // look for sources to add/update
227
234
  for (sourceId in after) {
235
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
228
236
  if (!after.hasOwnProperty(sourceId)) continue;
237
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
229
238
  const source = after[sourceId];
239
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
230
240
  if (!before.hasOwnProperty(sourceId)) {
241
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
231
242
  addSource(sourceId, after, commands);
243
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
232
244
  } else if (!isEqual(before[sourceId], source)) {
245
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
233
246
  if (before[sourceId].type === 'geojson' && source.type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {
234
247
  commands.push({command: operations.setGeoJSONSourceData, args: [sourceId, source.data]});
235
248
  } else {
236
249
  // no update command, must remove then add
250
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
237
251
  updateSource(sourceId, after, commands, sourcesRemoved);
238
252
  }
239
253
  }
@@ -256,14 +270,20 @@ function diffLayerPropertyChanges(
256
270
  let prop;
257
271
 
258
272
  for (prop in before) {
273
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
259
274
  if (!before.hasOwnProperty(prop)) continue;
275
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
260
276
  if (!isEqual(before[prop], after[prop])) {
277
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
261
278
  commands.push({command, args: [layerId, prop, after[prop], klass]});
262
279
  }
263
280
  }
264
281
  for (prop in after) {
282
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
265
283
  if (!after.hasOwnProperty(prop) || before.hasOwnProperty(prop)) continue;
284
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
266
285
  if (!isEqual(before[prop], after[prop])) {
286
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
267
287
  commands.push({command, args: [layerId, prop, after[prop], klass]});
268
288
  }
269
289
  }
@@ -294,15 +314,19 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
294
314
  const tracker = beforeOrder.slice();
295
315
 
296
316
  // layers that have been added do not need to be diffed
317
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
297
318
  const clean = Object.create(null);
298
319
 
299
320
  let i, d, layerId, beforeLayer: LayerSpecification, afterLayer: LayerSpecification, insertBeforeLayerId, prop;
300
321
 
301
322
  // remove layers
302
323
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
324
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
303
325
  layerId = beforeOrder[i];
326
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
304
327
  if (!afterIndex.hasOwnProperty(layerId)) {
305
328
  commands.push({command: operations.removeLayer, args: [layerId]});
329
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
306
330
  tracker.splice(tracker.indexOf(layerId, d), 1);
307
331
  } else {
308
332
  // limit where in tracker we need to look for a match
@@ -317,9 +341,11 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
317
341
 
318
342
  if (tracker[tracker.length - 1 - i] === layerId) continue;
319
343
 
344
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
320
345
  if (beforeIndex.hasOwnProperty(layerId)) {
321
346
  // remove the layer before we insert at the correct position
322
347
  commands.push({command: operations.removeLayer, args: [layerId]});
348
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
323
349
  tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);
324
350
  } else {
325
351
  // limit where in tracker we need to look for a match
@@ -328,18 +354,25 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
328
354
 
329
355
  // add layer at correct position
330
356
  insertBeforeLayerId = tracker[tracker.length - i];
357
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
331
358
  commands.push({command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId]});
359
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
332
360
  tracker.splice(tracker.length - i, 0, layerId);
361
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
333
362
  clean[layerId] = true;
334
363
  }
335
364
 
336
365
  // update layers
337
366
  for (i = 0; i < afterOrder.length; i++) {
367
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
338
368
  layerId = afterOrder[i];
369
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
339
370
  beforeLayer = beforeIndex[layerId];
371
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
340
372
  afterLayer = afterIndex[layerId];
341
373
 
342
374
  // no need to update if previously added (new or moved)
375
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
343
376
  if (clean[layerId] || isEqual(beforeLayer, afterLayer)) continue;
344
377
 
345
378
  // If source, source-layer, or type have changes, then remove the layer
@@ -348,13 +381,16 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
348
381
  commands.push({command: operations.removeLayer, args: [layerId]});
349
382
  // we add the layer back at the same position it was already in, so
350
383
  // there's no need to update the `tracker`
384
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
351
385
  insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];
352
386
  commands.push({command: operations.addLayer, args: [afterLayer, insertBeforeLayerId]});
353
387
  continue;
354
388
  }
355
389
 
356
390
  // layout, paint, filter, minzoom, maxzoom
391
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
357
392
  diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);
393
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
358
394
  diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);
359
395
  if (!isEqual(beforeLayer.slot, afterLayer.slot)) {
360
396
  commands.push({command: operations.setSlot, args: [layerId, afterLayer.slot]});
@@ -368,22 +404,32 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
368
404
 
369
405
  // handle all other layer props, including paint.*
370
406
  for (prop in beforeLayer) {
407
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
371
408
  if (!beforeLayer.hasOwnProperty(prop)) continue;
372
409
  if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||
373
410
  prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot') continue;
411
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
374
412
  if (prop.indexOf('paint.') === 0) {
413
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
375
414
  diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);
415
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
376
416
  } else if (!isEqual(beforeLayer[prop], afterLayer[prop])) {
417
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
377
418
  commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]});
378
419
  }
379
420
  }
380
421
  for (prop in afterLayer) {
422
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
381
423
  if (!afterLayer.hasOwnProperty(prop) || beforeLayer.hasOwnProperty(prop)) continue;
382
424
  if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||
383
425
  prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot') continue;
426
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
384
427
  if (prop.indexOf('paint.') === 0) {
428
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
385
429
  diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);
430
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
386
431
  } else if (!isEqual(beforeLayer[prop], afterLayer[prop])) {
432
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
387
433
  commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]});
388
434
  }
389
435
  }
@@ -409,9 +455,12 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
409
455
 
410
456
  // remove imports
411
457
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
458
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
412
459
  importId = beforeOrder[i];
460
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
413
461
  if (!afterIndex.hasOwnProperty(importId)) {
414
462
  commands.push({command: operations.removeImport, args: [importId]});
463
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
415
464
  tracker.splice(tracker.indexOf(importId, d), 1);
416
465
  } else {
417
466
  // limit where in tracker we need to look for a match
@@ -426,9 +475,11 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
426
475
 
427
476
  if (tracker[tracker.length - 1 - i] === importId) continue;
428
477
 
478
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
429
479
  if (beforeIndex.hasOwnProperty(importId)) {
430
480
  // remove the import before we insert at the correct position
431
481
  commands.push({command: operations.removeImport, args: [importId]});
482
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
432
483
  tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
433
484
  } else {
434
485
  // limit where in tracker we need to look for a match
@@ -437,14 +488,18 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
437
488
 
438
489
  // add import at correct position
439
490
  insertBefore = tracker[tracker.length - i];
491
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
440
492
  commands.push({command: operations.addImport, args: [afterIndex[importId], insertBefore]});
493
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
441
494
  tracker.splice(tracker.length - i, 0, importId);
442
495
  }
443
496
 
444
497
  // update imports
445
498
  for (const afterImport of after) {
499
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
446
500
  const beforeImport = beforeIndex[afterImport.id];
447
501
  if (!beforeImport) continue;
502
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
448
503
  delete beforeImport.data;
449
504
  if (isEqual(beforeImport, afterImport)) continue;
450
505
 
@@ -460,7 +515,9 @@ function diffIconsets(before: IconsetsSpecification, after: IconsetsSpecificatio
460
515
 
461
516
  // look for iconsets to remove
462
517
  for (iconsetId in before) {
518
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
463
519
  if (!before.hasOwnProperty(iconsetId)) continue;
520
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
464
521
  if (!after.hasOwnProperty(iconsetId)) {
465
522
  commands.push({command: operations.removeIconset, args: [iconsetId]});
466
523
  }
@@ -468,10 +525,14 @@ function diffIconsets(before: IconsetsSpecification, after: IconsetsSpecificatio
468
525
 
469
526
  // look for iconsets to add/update
470
527
  for (iconsetId in after) {
528
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
471
529
  if (!after.hasOwnProperty(iconsetId)) continue;
530
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
472
531
  const iconset = after[iconsetId];
532
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
473
533
  if (!before.hasOwnProperty(iconsetId)) {
474
534
  commands.push({command: operations.addIconset, args: [iconsetId, iconset]});
535
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
475
536
  } else if (!isEqual(before[iconsetId], iconset)) {
476
537
  commands.push({command: operations.removeIconset, args: [iconsetId]});
477
538
  commands.push({command: operations.addIconset, args: [iconsetId, iconset]});
@@ -569,6 +630,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
569
630
 
570
631
  // First collect the {add,remove}Source commands
571
632
  const removeOrAddSourceCommands = [];
633
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
572
634
  diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);
573
635
 
574
636
  // Push a removeLayer command for each style layer that depends on a
@@ -605,6 +667,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
605
667
  }
606
668
 
607
669
  // Handle changes to `layers`
670
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
608
671
  diffLayers(beforeLayers, after.layers, commands);
609
672
  } catch (e) {
610
673
  // fall back to setStyle