@mapbox/mapbox-gl-style-spec 14.12.0-beta.1 → 14.13.0-beta.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.
Files changed (81) hide show
  1. package/composite.ts +2 -0
  2. package/deref.ts +5 -5
  3. package/diff.ts +21 -21
  4. package/dist/index.cjs +455 -241
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +64 -30
  7. package/dist/index.es.js +455 -241
  8. package/dist/index.es.js.map +1 -1
  9. package/error/validation_error.ts +1 -3
  10. package/expression/definitions/assertion.ts +2 -1
  11. package/expression/definitions/at.ts +1 -1
  12. package/expression/definitions/at_interpolated.ts +1 -1
  13. package/expression/definitions/case.ts +3 -1
  14. package/expression/definitions/coalesce.ts +1 -0
  15. package/expression/definitions/coercion.ts +3 -1
  16. package/expression/definitions/collator.ts +2 -1
  17. package/expression/definitions/comparison.ts +15 -1
  18. package/expression/definitions/config.ts +33 -10
  19. package/expression/definitions/distance.ts +6 -4
  20. package/expression/definitions/format.ts +3 -2
  21. package/expression/definitions/index.ts +29 -3
  22. package/expression/definitions/index_of.ts +1 -0
  23. package/expression/definitions/interpolate.ts +5 -1
  24. package/expression/definitions/let.ts +1 -0
  25. package/expression/definitions/literal.ts +3 -3
  26. package/expression/definitions/match.ts +5 -3
  27. package/expression/definitions/number_format.ts +3 -4
  28. package/expression/definitions/slice.ts +1 -0
  29. package/expression/definitions/step.ts +1 -0
  30. package/expression/definitions/var.ts +1 -0
  31. package/expression/definitions/within.ts +6 -2
  32. package/expression/expression.ts +3 -0
  33. package/expression/index.ts +18 -3
  34. package/expression/is_constant.ts +4 -0
  35. package/expression/parsing_context.ts +1 -1
  36. package/expression/types/formatted.ts +1 -1
  37. package/expression/types/image_variant.ts +2 -2
  38. package/expression/types.ts +9 -0
  39. package/expression/values.ts +1 -3
  40. package/feature_filter/convert.ts +13 -6
  41. package/feature_filter/index.ts +16 -0
  42. package/format.ts +1 -0
  43. package/function/convert.ts +5 -1
  44. package/function/index.ts +28 -0
  45. package/group_by_layout.ts +17 -8
  46. package/migrate/expressions.ts +2 -2
  47. package/migrate/v8.ts +9 -0
  48. package/migrate/v9.ts +1 -0
  49. package/migrate.ts +1 -0
  50. package/package.json +1 -1
  51. package/read_style.ts +1 -0
  52. package/reference/latest.ts +1 -0
  53. package/reference/v8.json +209 -21
  54. package/types.ts +21 -2
  55. package/union-to-intersection.ts +1 -1
  56. package/util/color.ts +85 -69
  57. package/util/extend.ts +1 -0
  58. package/util/geometry_util.ts +7 -8
  59. package/util/interpolate.ts +0 -4
  60. package/validate/validate.ts +6 -0
  61. package/validate/validate_array.ts +2 -0
  62. package/validate/validate_enum.ts +1 -0
  63. package/validate/validate_expression.ts +4 -0
  64. package/validate/validate_filter.ts +4 -2
  65. package/validate/validate_fog.ts +3 -0
  66. package/validate/validate_function.ts +7 -2
  67. package/validate/validate_iconset.ts +1 -0
  68. package/validate/validate_layer.ts +1 -0
  69. package/validate/validate_light.ts +3 -0
  70. package/validate/validate_lights.ts +27 -21
  71. package/validate/validate_model.ts +4 -0
  72. package/validate/validate_object.ts +2 -2
  73. package/validate/validate_projection.ts +1 -0
  74. package/validate/validate_property.ts +4 -0
  75. package/validate/validate_rain.ts +3 -0
  76. package/validate/validate_snow.ts +3 -0
  77. package/validate/validate_source.ts +8 -6
  78. package/validate/validate_terrain.ts +4 -0
  79. package/validate_mapbox_api_supported.ts +30 -19
  80. package/validate_style.ts +1 -0
  81. package/visit.ts +3 -1
package/composite.ts CHANGED
@@ -21,6 +21,7 @@ export default function (style) {
21
21
  }
22
22
 
23
23
  if (styleIDs.length < 2)
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
24
25
  return style;
25
26
 
26
27
  styleIDs.forEach((id) => {
@@ -48,5 +49,6 @@ export default function (style) {
48
49
  }
49
50
  });
50
51
 
52
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
51
53
  return style;
52
54
  }
package/deref.ts CHANGED
@@ -3,7 +3,7 @@ import refProperties from './util/ref_properties';
3
3
  import type {LayerSpecification} from './types';
4
4
 
5
5
  function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpecification {
6
- const result: Record<string, any> = {};
6
+ const result = {} as LayerSpecification;
7
7
 
8
8
  for (const k in layer) {
9
9
  if (k !== 'ref') {
@@ -13,11 +13,11 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
13
13
 
14
14
  refProperties.forEach((k) => {
15
15
  if (k in parent) {
16
- result[k] = (parent as any)[k];
16
+ result[k] = parent[k];
17
17
  }
18
18
  });
19
19
 
20
- return result as LayerSpecification;
20
+ return result;
21
21
  }
22
22
 
23
23
  /**
@@ -36,14 +36,14 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
36
36
  export default function derefLayers(layers: Array<LayerSpecification>): Array<LayerSpecification> {
37
37
  layers = layers.slice();
38
38
 
39
- const map: any = Object.create(null);
39
+ const map: Record<string, LayerSpecification> = Object.create(null);
40
40
  for (let i = 0; i < layers.length; i++) {
41
41
  map[layers[i].id] = layers[i];
42
42
  }
43
43
 
44
44
  for (let i = 0; i < layers.length; i++) {
45
45
  if ('ref' in layers[i]) {
46
- layers[i] = deref(layers[i], map[(layers[i] as any).ref]);
46
+ layers[i] = deref(layers[i], map[(layers[i] as LayerSpecification & {ref: string}).ref]);
47
47
  }
48
48
  }
49
49
 
package/diff.ts CHANGED
@@ -8,7 +8,7 @@ type Sources = {
8
8
 
9
9
  type Command = {
10
10
  command: string;
11
- args: Array<any>;
11
+ args: unknown[];
12
12
  };
13
13
 
14
14
  export const operations = {
@@ -240,7 +240,16 @@ function diffSources(before: Sources, after: Sources, commands: Array<Command>,
240
240
  }
241
241
  }
242
242
 
243
- function diffLayerPropertyChanges(before: any, after: any, commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string) {
243
+ function diffLayerPropertyChanges(before: LayerSpecification['layout'], after: LayerSpecification['layout'], commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string): void;
244
+ function diffLayerPropertyChanges(before: LayerSpecification['paint'], after: LayerSpecification['paint'], commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string): void;
245
+ function diffLayerPropertyChanges(
246
+ before: LayerSpecification['paint'] | LayerSpecification['layout'],
247
+ after: LayerSpecification['paint'] | LayerSpecification['layout'],
248
+ commands: Command[],
249
+ layerId: string,
250
+ klass: string | null | undefined,
251
+ command: string
252
+ ) {
244
253
  before = before || {};
245
254
  after = after || {};
246
255
 
@@ -260,22 +269,11 @@ function diffLayerPropertyChanges(before: any, after: any, commands: Array<Comma
260
269
  }
261
270
  }
262
271
 
263
- function pluckId<T extends {
264
- id: string;
265
- }>(item: T): string {
272
+ function pluckId<T extends {id: string}>(item: T): string {
266
273
  return item.id;
267
274
  }
268
275
 
269
- function indexById<T extends {
270
- id: string;
271
- }>(
272
- group: {
273
- [key: string]: T;
274
- },
275
- item: T,
276
- ): {
277
- [id: string]: T;
278
- } {
276
+ function indexById<T extends {id: string}>(group: {[key: string]: T}, item: T): {[id: string]: T} {
279
277
  group[item.id] = item;
280
278
  return group;
281
279
  }
@@ -289,14 +287,14 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
289
287
  const afterOrder = after.map(pluckId);
290
288
 
291
289
  // index of layer by id
292
- const beforeIndex = before.reduce<Record<string, any>>(indexById, {});
293
- const afterIndex = after.reduce<Record<string, any>>(indexById, {});
290
+ const beforeIndex = before.reduce(indexById, {});
291
+ const afterIndex = after.reduce(indexById, {});
294
292
 
295
293
  // track order of layers as if they have been mutated
296
294
  const tracker = beforeOrder.slice();
297
295
 
298
296
  // layers that have been added do not need to be diffed
299
- const clean: any = Object.create(null);
297
+ const clean = Object.create(null);
300
298
 
301
299
  let i, d, layerId, beforeLayer: LayerSpecification, afterLayer: LayerSpecification, insertBeforeLayerId, prop;
302
300
 
@@ -401,8 +399,8 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
401
399
  const afterOrder = after.map(pluckId);
402
400
 
403
401
  // index imports by id
404
- const beforeIndex = before.reduce<Record<string, any>>(indexById, {});
405
- const afterIndex = after.reduce<Record<string, any>>(indexById, {});
402
+ const beforeIndex = before.reduce(indexById, {});
403
+ const afterIndex = after.reduce(indexById, {});
406
404
 
407
405
  // track order of imports as if they have been mutated
408
406
  const tracker = beforeOrder.slice();
@@ -446,7 +444,9 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
446
444
  // update imports
447
445
  for (const afterImport of after) {
448
446
  const beforeImport = beforeIndex[afterImport.id];
449
- if (!beforeImport || isEqual(beforeImport, afterImport)) continue;
447
+ if (!beforeImport) continue;
448
+ delete beforeImport.data;
449
+ if (isEqual(beforeImport, afterImport)) continue;
450
450
 
451
451
  commands.push({command: operations.updateImport, args: [afterImport.id, afterImport]});
452
452
  }