@mapbox/mapbox-gl-style-spec 14.14.0 → 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.
@@ -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
 
@@ -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
 
@@ -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,8 +359,9 @@ 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
366
  return expression as Result<StylePropertyExpression, Array<ParsingError>>;
359
367
  }
@@ -446,12 +454,13 @@ export function normalizePropertyExpression<T>(
446
454
  specification: StylePropertySpecification,
447
455
  scope?: string | null,
448
456
  options?: ConfigOptions | null,
457
+ iconImageUseTheme?: string | null
449
458
  ): StylePropertyExpression {
450
459
  if (isFunction(value)) {
451
460
  return new StylePropertyFunction(value, specification) as unknown as StylePropertyExpression;
452
461
 
453
462
  } else if (isExpression(value) || (Array.isArray(value) && value.length > 0)) {
454
- const expression = createPropertyExpression(value, specification, scope, options);
463
+ const expression = createPropertyExpression(value, specification, scope, options, iconImageUseTheme);
455
464
  if (expression.result === 'error') {
456
465
  // this should have been caught in validation
457
466
  throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/mapbox-gl-style-spec",
3
- "version": "14.14.0",
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/reference/v8.json CHANGED
@@ -2955,6 +2955,7 @@
2955
2955
  "doc": "Name of image in sprite to use for drawing an image background.",
2956
2956
  "tokens": true,
2957
2957
  "appearance": true,
2958
+ "use-theme": true,
2958
2959
  "sdk-support": {
2959
2960
  "basic functionality": {
2960
2961
  "js": "0.10.0",
package/types.ts CHANGED
@@ -770,6 +770,7 @@ export type SymbolLayerSpecification = {
770
770
  "icon-text-fit"?: DataDrivenPropertyValueSpecification<"none" | "width" | "height" | "both">,
771
771
  "icon-text-fit-padding"?: DataDrivenPropertyValueSpecification<[number, number, number, number]>,
772
772
  "icon-image"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>,
773
+ "icon-image-use-theme"?: PropertyValueSpecification<string>,
773
774
  "icon-rotate"?: DataDrivenPropertyValueSpecification<number>,
774
775
  "icon-padding"?: PropertyValueSpecification<number>,
775
776
  "icon-keep-upright"?: PropertyValueSpecification<boolean>,
@@ -28,7 +28,7 @@ export default function validateProperty(options: PropertyValidationOptions, pro
28
28
  if (!layerSpec) return [];
29
29
 
30
30
  const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
31
- if (propertyType === 'paint' && useThemeMatch && layerSpec[useThemeMatch[1]]) {
31
+ if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
32
32
  if (isExpression(value)) {
33
33
  const errors: ValidationError[] = [];
34
34
  return errors.concat(validate({