@mapbox/mapbox-gl-style-spec 14.14.0-beta.2 → 14.15.0-alpha.ffa987fef46

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 (44) hide show
  1. package/composite.ts +5 -8
  2. package/dist/index.cjs +53 -27
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +48 -24
  5. package/dist/index.es.js +53 -27
  6. package/dist/index.es.js.map +1 -1
  7. package/expression/compound_expression.ts +1 -1
  8. package/expression/definitions/config.ts +1 -1
  9. package/expression/definitions/distance.ts +2 -3
  10. package/expression/definitions/image.ts +1 -1
  11. package/expression/definitions/index.ts +4 -20
  12. package/expression/definitions/interpolate.ts +6 -9
  13. package/expression/definitions/within.ts +14 -15
  14. package/expression/evaluation_context.ts +3 -1
  15. package/expression/index.ts +18 -11
  16. package/expression/parsing_context.ts +7 -3
  17. package/group_by_layout.ts +3 -6
  18. package/migrate.ts +6 -8
  19. package/package.json +1 -1
  20. package/read_style.ts +1 -2
  21. package/reference/v8.json +26 -0
  22. package/types.ts +35 -13
  23. package/util/geometry_util.ts +1 -2
  24. package/validate/validate.ts +5 -6
  25. package/validate/validate_array.ts +2 -2
  26. package/validate/validate_enum.ts +2 -2
  27. package/validate/validate_expression.ts +1 -2
  28. package/validate/validate_filter.ts +3 -4
  29. package/validate/validate_fog.ts +2 -5
  30. package/validate/validate_function.ts +6 -10
  31. package/validate/validate_iconset.ts +1 -2
  32. package/validate/validate_layer.ts +1 -2
  33. package/validate/validate_light.ts +1 -4
  34. package/validate/validate_lights.ts +1 -7
  35. package/validate/validate_model.ts +1 -4
  36. package/validate/validate_projection.ts +1 -2
  37. package/validate/validate_property.ts +3 -7
  38. package/validate/validate_rain.ts +1 -4
  39. package/validate/validate_snow.ts +1 -4
  40. package/validate/validate_source.ts +2 -3
  41. package/validate/validate_terrain.ts +1 -5
  42. package/validate_mapbox_api_supported.ts +2 -4
  43. package/validate_style.ts +1 -2
  44. package/visit.ts +2 -4
@@ -85,7 +85,7 @@ class CompoundExpression implements Expression {
85
85
 
86
86
  // Use a fresh context for each attempted signature so that, if
87
87
  // we eventually succeed, we haven't polluted `context.errors`.
88
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, undefined, context._scope, context.options);
88
+ signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, undefined, context._scope, context.options, context.iconImageUseTheme);
89
89
 
90
90
  // First parse all the args, potentially coercing to the
91
91
  // types expected by this overload.
@@ -12,7 +12,7 @@ import type EvaluationContext from '../evaluation_context';
12
12
 
13
13
  const FQIDSeparator = '\u001F';
14
14
 
15
- function makeConfigFQID(id: string, ownScope?: string | null, contextScope?: string | null): string {
15
+ export function makeConfigFQID(id: string, ownScope?: string | null, contextScope?: string | null): string {
16
16
  return [id, ownScope, contextScope].filter(Boolean).join(FQIDSeparator);
17
17
  }
18
18
 
@@ -142,12 +142,11 @@ function getLngLatPoint(coord: Point, canonical: CanonicalTileID) {
142
142
  return [lngFromMercatorX(x), latFromMercatorY(y)];
143
143
  }
144
144
 
145
- function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID) {
146
- const coords = [];
145
+ function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID): number[][] {
146
+ const coords: number[][] = [];
147
147
  for (let i = 0; i < coordinates.length; ++i) {
148
148
  coords.push(getLngLatPoint(coordinates[i], canonical));
149
149
  }
150
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
151
150
  return coords;
152
151
  }
153
152
 
@@ -2,9 +2,9 @@ import ResolvedImage from '../types/resolved_image';
2
2
  import {ImageId} from '../types/image_id';
3
3
  import {ColorType, ResolvedImageType, StringType} from '../types';
4
4
 
5
+ import type EvaluationContext from '../evaluation_context';
5
6
  import type Color from '../../util/color';
6
7
  import type ParsingContext from '../parsing_context';
7
- import type EvaluationContext from '../evaluation_context';
8
8
  import type {Type} from '../types';
9
9
  import type {Expression, SerializedExpression} from '../expression';
10
10
 
@@ -120,30 +120,16 @@ function hsla(ctx: EvaluationContext, [h, s, l, a]: Expression[]) {
120
120
  return color;
121
121
  }
122
122
 
123
- function has(
124
- key: string,
125
- obj: {
126
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
- [key: string]: any;
128
- },
129
- ): boolean {
123
+ function has<T extends object>(key: keyof T, obj: T): boolean {
130
124
  return key in obj;
131
125
  }
132
126
 
133
- function get(key: string, obj: {
134
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
- [key: string]: any;
136
- }) {
127
+ function get<T extends object>(key: keyof T, obj: T): T[keyof T] | null {
137
128
  const v = obj[key];
138
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
139
129
  return typeof v === 'undefined' ? null : v;
140
130
  }
141
131
 
142
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
- function binarySearch(v: any, a: {
144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
- [key: number]: any;
146
- }, i: number, j: number) {
132
+ function binarySearch(v: unknown, a: Record<number, unknown>, i: number, j: number): boolean {
147
133
  while (i <= j) {
148
134
  const m = (i + j) >> 1;
149
135
  if (a[m] === v)
@@ -237,7 +223,6 @@ CompoundExpression.register(expressions, {
237
223
  overloads: [
238
224
  [
239
225
  [StringType],
240
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
241
226
  (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())
242
227
  ], [
243
228
  [StringType, ObjectType],
@@ -249,8 +234,7 @@ CompoundExpression.register(expressions, {
249
234
  'feature-state': [
250
235
  ValueType,
251
236
  [StringType],
252
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
253
- (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})
237
+ (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {}) as Value
254
238
  ],
255
239
  'properties': [
256
240
  ObjectType,
@@ -157,20 +157,17 @@ class Interpolate implements Expression {
157
157
  const outputs = this.outputs;
158
158
 
159
159
  if (labels.length === 1) {
160
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
161
- return outputs[0].evaluate(ctx);
160
+ return outputs[0].evaluate(ctx) as Color;
162
161
  }
163
162
 
164
- const value = (this.input.evaluate(ctx) as number);
163
+ const value: number = this.input.evaluate(ctx);
165
164
  if (value <= labels[0]) {
166
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
167
- return outputs[0].evaluate(ctx);
165
+ return outputs[0].evaluate(ctx) as Color;
168
166
  }
169
167
 
170
168
  const stopCount = labels.length;
171
169
  if (value >= labels[stopCount - 1]) {
172
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
173
- return outputs[stopCount - 1].evaluate(ctx);
170
+ return outputs[stopCount - 1].evaluate(ctx) as Color;
174
171
  }
175
172
 
176
173
  const index = findStopLessThanOrEqualTo(labels, value);
@@ -178,8 +175,8 @@ class Interpolate implements Expression {
178
175
  const upper = labels[index + 1];
179
176
  const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);
180
177
 
181
- const outputLower = outputs[index].evaluate(ctx);
182
- const outputUpper = outputs[index + 1].evaluate(ctx);
178
+ const outputLower: Color = outputs[index].evaluate(ctx);
179
+ const outputUpper: Color = outputs[index + 1].evaluate(ctx);
183
180
 
184
181
  if (this.operator === 'interpolate') {
185
182
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -2,11 +2,11 @@ import {isValue} from '../values';
2
2
  import {BooleanType} from '../types';
3
3
  import {updateBBox, boxWithinBox, pointWithinPolygon, segmentIntersectSegment} from '../../util/geometry_util';
4
4
 
5
+ import type Point from '@mapbox/point-geometry';
5
6
  import type {Type} from '../types';
6
7
  import type {Expression, SerializedExpression} from '../expression';
7
8
  import type ParsingContext from '../parsing_context';
8
9
  import type EvaluationContext from '../evaluation_context';
9
- import type Point from '@mapbox/point-geometry';
10
10
  import type {CanonicalTileID} from '../../types/tile_id';
11
11
  import type {BBox} from '../../util/geometry_util';
12
12
 
@@ -74,10 +74,10 @@ function lineStringWithinPolygons(line: Array<GeoJSON.Position>, polygons: Array
74
74
  return false;
75
75
  }
76
76
 
77
- function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox, canonical: CanonicalTileID) {
78
- const polygon = [];
77
+ function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox, canonical: CanonicalTileID): Array<Array<number[]>> {
78
+ const polygon: Array<Array<number[]>> = [];
79
79
  for (let i = 0; i < coordinates.length; i++) {
80
- const ring = [];
80
+ const ring: number[][] = [];
81
81
  for (let j = 0; j < coordinates[i].length; j++) {
82
82
  const coord = getTileCoordinates(coordinates[i][j], canonical);
83
83
  updateBBox(bbox, coord);
@@ -85,17 +85,17 @@ function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox,
85
85
  }
86
86
  polygon.push(ring);
87
87
  }
88
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
88
+
89
89
  return polygon;
90
90
  }
91
91
 
92
- function getTilePolygons(coordinates: Array<Array<Array<GeoJSON.Position>>>, bbox: BBox, canonical: CanonicalTileID) {
93
- const polygons = [];
92
+ function getTilePolygons(coordinates: Array<Array<Array<GeoJSON.Position>>>, bbox: BBox, canonical: CanonicalTileID): Array<Array<Array<number[]>>> {
93
+ const polygons: Array<Array<Array<number[]>>> = [];
94
94
  for (let i = 0; i < coordinates.length; i++) {
95
95
  const polygon = getTilePolygon(coordinates[i], bbox, canonical);
96
96
  polygons.push(polygon);
97
97
  }
98
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
98
+
99
99
  return polygons;
100
100
  }
101
101
 
@@ -116,11 +116,10 @@ function resetBBox(bbox: BBox) {
116
116
  bbox[2] = bbox[3] = -Infinity;
117
117
  }
118
118
 
119
- function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID) {
119
+ function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID): Array<number[]> {
120
120
  const worldSize = Math.pow(2, canonical.z) * EXTENT;
121
121
  const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
122
- const tilePoints = [];
123
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
122
+ const tilePoints: Array<number[]> = [];
124
123
  if (!geometry) return tilePoints;
125
124
  for (const points of geometry) {
126
125
  for (const point of points) {
@@ -129,11 +128,11 @@ function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBB
129
128
  tilePoints.push(p);
130
129
  }
131
130
  }
132
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
131
+
133
132
  return tilePoints;
134
133
  }
135
134
 
136
- function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID) {
135
+ function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID): Array<Array<GeoJSON.Position>> {
137
136
  const worldSize = Math.pow(2, canonical.z) * EXTENT;
138
137
  const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
139
138
  const tileLines: Array<Array<GeoJSON.Position>> = [];
@@ -158,7 +157,7 @@ function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox
158
157
  return tileLines;
159
158
  }
160
159
 
161
- function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
160
+ function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons): boolean {
162
161
  const pointBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
163
162
  const polyBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
164
163
 
@@ -189,7 +188,7 @@ function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPo
189
188
  return true;
190
189
  }
191
190
 
192
- function linesWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
191
+ function linesWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons): boolean {
193
192
  const lineBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
194
193
  const polyBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
195
194
 
@@ -21,12 +21,13 @@ class EvaluationContext {
21
21
  featureDistanceData: FeatureDistanceData | null | undefined;
22
22
  scope: string | null | undefined;
23
23
  options: ConfigOptions | null | undefined;
24
+ iconImageUseTheme: string | null | undefined;
24
25
 
25
26
  _parseColorCache: {
26
27
  [_: string]: Color | null | undefined;
27
28
  };
28
29
 
29
- constructor(scope?: string | null, options?: ConfigOptions | null) {
30
+ constructor(scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string) {
30
31
  this.globals = null;
31
32
  this.feature = null;
32
33
  this.featureState = null;
@@ -38,6 +39,7 @@ class EvaluationContext {
38
39
  this.featureDistanceData = null;
39
40
  this.scope = scope;
40
41
  this.options = options;
42
+ this.iconImageUseTheme = iconImageUseTheme;
41
43
  }
42
44
 
43
45
  id(): string | number | null {
@@ -72,10 +72,10 @@ export class StyleExpression {
72
72
  _enumValues?: {[_: string]: unknown};
73
73
  configDependencies: Set<string>;
74
74
 
75
- constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions) {
75
+ constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions, iconImageUseTheme?: string) {
76
76
  this.expression = expression;
77
77
  this._warningHistory = {};
78
- this._evaluator = new EvaluationContext(scope, options);
78
+ this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
79
79
  this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
80
80
  this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
81
81
  this.configDependencies = isConstant.getConfigDependencies(expression);
@@ -113,6 +113,7 @@ export class StyleExpression {
113
113
  formattedSection?: FormattedSection,
114
114
  featureTileCoord?: Point,
115
115
  featureDistanceData?: FeatureDistanceData,
116
+ iconImageUseTheme?: string
116
117
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
118
  ): any {
118
119
  this._evaluator.globals = globals;
@@ -123,6 +124,7 @@ export class StyleExpression {
123
124
  this._evaluator.formattedSection = formattedSection || null;
124
125
  this._evaluator.featureTileCoord = featureTileCoord || null;
125
126
  this._evaluator.featureDistanceData = featureDistanceData || null;
127
+ this._evaluator.iconImageUseTheme = iconImageUseTheme || null;
126
128
 
127
129
  try {
128
130
  const val = this.expression.evaluate(this._evaluator);
@@ -165,8 +167,9 @@ export function createExpression(
165
167
  propertySpec?: StylePropertySpecification | null,
166
168
  scope?: string | null,
167
169
  options?: ConfigOptions | null,
170
+ iconImageUseTheme?: string | null
168
171
  ): Result<StyleExpression, Array<ParsingError>> {
169
- const parser = new ParsingContext(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, scope, options);
172
+ const parser = new ParsingContext(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, scope, options, iconImageUseTheme);
170
173
 
171
174
  // For string-valued properties, coerce to string at the top level rather than asserting.
172
175
  const parsed = parser.parse(expression, undefined, undefined, undefined,
@@ -177,7 +180,7 @@ export function createExpression(
177
180
  return error(parser.errors);
178
181
  }
179
182
 
180
- return success(new StyleExpression(parsed, propertySpec, scope, options));
183
+ return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
181
184
  }
182
185
 
183
186
  export class ZoomConstantExpression<Kind extends EvaluationKind> {
@@ -216,9 +219,10 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
216
219
  canonical?: CanonicalTileID,
217
220
  availableImages?: ImageId[],
218
221
  formattedSection?: FormattedSection,
222
+ iconImageUseTheme?: string
219
223
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
224
  ): any {
221
- return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
225
+ return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, undefined, undefined, iconImageUseTheme);
222
226
  }
223
227
  }
224
228
 
@@ -286,6 +290,8 @@ export type ConstantExpression = {
286
290
  featureState?: FeatureState,
287
291
  canonical?: CanonicalTileID,
288
292
  availableImages?: ImageId[],
293
+ formattedSection?: FormattedSection,
294
+ iconImageUseTheme?: string
289
295
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
290
296
  ) => any;
291
297
  };
@@ -337,6 +343,7 @@ export interface CompositeExpression {
337
343
  canonical?: CanonicalTileID,
338
344
  availableImages?: ImageId[],
339
345
  formattedSection?: FormattedSection,
346
+ iconImageUseTheme?: string
340
347
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
341
348
  ) => any;
342
349
  readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
@@ -352,11 +359,11 @@ export function createPropertyExpression(
352
359
  propertySpec: StylePropertySpecification,
353
360
  scope?: string | null,
354
361
  options?: ConfigOptions | null,
362
+ iconImageUseTheme?: string | null
355
363
  ): Result<StylePropertyExpression, Array<ParsingError>> {
356
- expression = createExpression(expression, propertySpec, scope, options);
364
+ expression = createExpression(expression, propertySpec, scope, options, iconImageUseTheme);
357
365
  if (expression.result === 'error') {
358
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
359
- return expression;
366
+ return expression as Result<StylePropertyExpression, Array<ParsingError>>;
360
367
  }
361
368
 
362
369
  const parsed = expression.value.expression;
@@ -447,12 +454,13 @@ export function normalizePropertyExpression<T>(
447
454
  specification: StylePropertySpecification,
448
455
  scope?: string | null,
449
456
  options?: ConfigOptions | null,
457
+ iconImageUseTheme?: string | null
450
458
  ): StylePropertyExpression {
451
459
  if (isFunction(value)) {
452
460
  return new StylePropertyFunction(value, specification) as unknown as StylePropertyExpression;
453
461
 
454
462
  } else if (isExpression(value) || (Array.isArray(value) && value.length > 0)) {
455
- const expression = createPropertyExpression(value, specification, scope, options);
463
+ const expression = createPropertyExpression(value, specification, scope, options, iconImageUseTheme);
456
464
  if (expression.result === 'error') {
457
465
  // this should have been caught in validation
458
466
  throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));
@@ -476,7 +484,7 @@ export function normalizePropertyExpression<T>(
476
484
  // expression (collectively referred to as a "curve"). The curve may be wrapped in one or more "let" or
477
485
  // "coalesce" expressions.
478
486
  function findZoomCurve(expression: Expression): Step | Interpolate | ParsingError | null {
479
- let result = null;
487
+ let result: Step | Interpolate | ParsingError | null = null;
480
488
  if (expression instanceof Let) {
481
489
  result = findZoomCurve(expression.result);
482
490
 
@@ -508,7 +516,6 @@ function findZoomCurve(expression: Expression): Step | Interpolate | ParsingErro
508
516
  }
509
517
  });
510
518
 
511
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
512
519
  return result;
513
520
  }
514
521
 
@@ -29,6 +29,7 @@ class ParsingContext {
29
29
  errors: Array<ParsingError>;
30
30
  _scope: string | null | undefined;
31
31
  options: ConfigOptions | null | undefined;
32
+ iconImageUseTheme: string;
32
33
 
33
34
  // The expected type of this expression. Provided only to allow Expression
34
35
  // implementations to infer argument types: Expression#parse() need not
@@ -43,7 +44,8 @@ class ParsingContext {
43
44
  scope: Scope = new Scope(),
44
45
  errors: Array<ParsingError> = [],
45
46
  _scope?: string | null,
46
- options?: ConfigOptions | null
47
+ options?: ConfigOptions | null,
48
+ iconImageUseTheme?: string
47
49
  ) {
48
50
  this.registry = registry;
49
51
  this.path = path;
@@ -53,6 +55,7 @@ class ParsingContext {
53
55
  this.expectedType = expectedType;
54
56
  this._scope = _scope;
55
57
  this.options = options;
58
+ this.iconImageUseTheme = iconImageUseTheme;
56
59
  }
57
60
 
58
61
  /**
@@ -154,7 +157,7 @@ class ParsingContext {
154
157
  // parsed/compiled result. Expressions that expect an image should
155
158
  // not be resolved here so we can later get the available images.
156
159
  if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && isConstant(parsed)) {
157
- const ec = new EvaluationContext(this._scope, this.options);
160
+ const ec = new EvaluationContext(this._scope, this.options, this.iconImageUseTheme);
158
161
  try {
159
162
  parsed = new Literal(parsed.type, parsed.evaluate(ec));
160
163
  } catch (e) {
@@ -201,7 +204,8 @@ class ParsingContext {
201
204
  scope,
202
205
  this.errors,
203
206
  this._scope,
204
- this.options
207
+ this.options,
208
+ this.iconImageUseTheme
205
209
  );
206
210
  }
207
211
 
@@ -2,8 +2,7 @@ import refProperties from './util/ref_properties';
2
2
 
3
3
  import type {LayerSpecification} from './types';
4
4
 
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- function stringify(obj: any) {
5
+ function stringify(obj: unknown) {
7
6
  if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
8
7
  return JSON.stringify(obj);
9
8
 
@@ -30,8 +29,7 @@ function getKey(layer: LayerSpecification) {
30
29
  return key;
31
30
  }
32
31
 
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- function containsKey(obj: any, key: string) {
32
+ function containsKey(obj: unknown, key: string) {
35
33
  function recursiveSearch(item) {
36
34
  if (typeof item === 'string' && item === key) {
37
35
  return true;
@@ -106,12 +104,11 @@ export default function groupByLayout(
106
104
  group.push(layer);
107
105
  }
108
106
 
109
- const result = [];
107
+ const result: LayerSpecification[][] = [];
110
108
 
111
109
  for (const k in groups) {
112
110
  result.push(groups[k]);
113
111
  }
114
112
 
115
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
116
113
  return result;
117
114
  }
package/migrate.ts CHANGED
@@ -1,9 +1,8 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- // @ts-nocheck
3
-
4
1
  import migrateToV8 from './migrate/v8';
5
2
  import migrateToExpressions from './migrate/expressions';
6
3
 
4
+ import type {StyleSpecification} from './types';
5
+
7
6
  /**
8
7
  * Migrate a Mapbox GL Style to the latest version.
9
8
  *
@@ -17,7 +16,7 @@ import migrateToExpressions from './migrate/expressions';
17
16
  * var style = fs.readFileSync('./style.json', 'utf8');
18
17
  * fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
19
18
  */
20
- export default function (style) {
19
+ export default function (style: {version: 7} | StyleSpecification): StyleSpecification {
21
20
  let migrated = false;
22
21
 
23
22
  if (style.version === 7) {
@@ -26,14 +25,13 @@ export default function (style) {
26
25
  }
27
26
 
28
27
  if (style.version === 8) {
29
- migrated = migrateToExpressions(style);
28
+ style = migrateToExpressions(style);
30
29
  migrated = true;
31
30
  }
32
31
 
33
32
  if (!migrated) {
34
- throw new Error('cannot migrate from', style.version);
33
+ throw new Error(`Cannot migrate from ${style.version}`);
35
34
  }
36
35
 
37
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
38
- return style;
36
+ return style as StyleSpecification;
39
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/mapbox-gl-style-spec",
3
- "version": "14.14.0-beta.2",
3
+ "version": "14.15.0-alpha.ffa987fef46",
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,7 @@ 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-return
10
- return jsonlint.parse(style.toString());
9
+ return jsonlint.parse(style.toString()) as StyleSpecification;
11
10
  } catch (e) {
12
11
  throw new ParsingError(e);
13
12
  }
package/reference/v8.json CHANGED
@@ -1553,6 +1553,27 @@
1553
1553
  "paint": {
1554
1554
  "type": "paint",
1555
1555
  "doc": "Default paint properties for this layer."
1556
+ },
1557
+ "appearances": {
1558
+ "type": "array",
1559
+ "value": "appearance",
1560
+ "supported-layer-types": ["symbol"],
1561
+ "private": true,
1562
+ "doc": "Conditional styling applied to layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Can be used in appearances' are supported."
1563
+ }
1564
+ },
1565
+ "appearance": {
1566
+ "condition": {
1567
+ "type": "expression",
1568
+ "doc": "A boolean expression that determines when this appearance should be applied."
1569
+ },
1570
+ "name": {
1571
+ "type": "string",
1572
+ "doc": "Optional name for this appearance. Non-empty names should be unique within a layer."
1573
+ },
1574
+ "properties": {
1575
+ "type": "*",
1576
+ "doc": "Style properties to apply when the condition is met."
1556
1577
  }
1557
1578
  },
1558
1579
  "layout": [
@@ -2789,6 +2810,7 @@
2789
2810
  "minimum": 0,
2790
2811
  "units": "factor of the original icon size",
2791
2812
  "doc": "Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image.",
2813
+ "appearance": true,
2792
2814
  "requires": [
2793
2815
  "icon-image"
2794
2816
  ],
@@ -2932,6 +2954,8 @@
2932
2954
  "type": "resolvedImage",
2933
2955
  "doc": "Name of image in sprite to use for drawing an image background.",
2934
2956
  "tokens": true,
2957
+ "appearance": true,
2958
+ "use-theme": true,
2935
2959
  "sdk-support": {
2936
2960
  "basic functionality": {
2937
2961
  "js": "0.10.0",
@@ -2959,6 +2983,7 @@
2959
2983
  "period": 360,
2960
2984
  "units": "degrees",
2961
2985
  "doc": "Rotates the icon clockwise.",
2986
+ "appearance": true,
2962
2987
  "requires": [
2963
2988
  "icon-image"
2964
2989
  ],
@@ -3047,6 +3072,7 @@
3047
3072
  0
3048
3073
  ],
3049
3074
  "doc": "Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up.",
3075
+ "appearance": true,
3050
3076
  "requires": [
3051
3077
  "icon-image"
3052
3078
  ],