@mapbox/mapbox-gl-style-spec 14.16.0-beta.2 → 14.16.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.
package/dist/index.d.ts CHANGED
@@ -441,14 +441,17 @@ type ImportSpecification = {
441
441
  "color-theme"?: ColorThemeSpecification | null | undefined;
442
442
  };
443
443
  type IndoorSpecification = {
444
+ [_: string]: IndoorSourceSpecification;
445
+ };
446
+ type IndoorSourceSpecification = {
444
447
  /**
445
448
  * @experimental This property is experimental and subject to change in future versions.
446
449
  */
447
- "floorplanFeaturesetId"?: ExpressionSpecification;
450
+ "sourceId"?: string;
448
451
  /**
449
452
  * @experimental This property is experimental and subject to change in future versions.
450
453
  */
451
- "buildingFeaturesetId"?: ExpressionSpecification;
454
+ "sourceLayers"?: Array<string>;
452
455
  };
453
456
  type ConfigSpecification = {
454
457
  [_: string]: unknown;
@@ -2065,7 +2068,10 @@ interface GlobalProperties {
2065
2068
  }
2066
2069
  declare class StyleExpression {
2067
2070
  expression: Expression;
2068
- _evaluator: EvaluationContext;
2071
+ _scope?: string;
2072
+ _options?: ConfigOptions;
2073
+ _iconImageUseTheme?: string;
2074
+ _evaluator?: EvaluationContext;
2069
2075
  _defaultValue: Value;
2070
2076
  _warningHistory: {
2071
2077
  [key: string]: boolean;
package/dist/index.es.js CHANGED
@@ -127,6 +127,7 @@ var $root = {
127
127
  },
128
128
  indoor: {
129
129
  type: "indoor",
130
+ "private": true,
130
131
  experimental: true,
131
132
  doc: "Controls the behaviour of indoor features."
132
133
  },
@@ -831,7 +832,7 @@ var source_vector = {
831
832
  },
832
833
  promoteId: {
833
834
  type: "promoteId",
834
- doc: "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`. If specified as a string for a vector tile source, the same property is used across all its source layers. If specified as an object only specified source layers will have id overriden, others will fallback to original feature id"
835
+ doc: "A property to use as a feature id (for feature state). It can be a property name, or an expression to evaluate as the ID, or an object of the form `{<sourceLayer>: <propertyName/expression>}`. The expression can only be feature dependent if it is used. If specified as a string for a vector tile source, the same property is used across all its source layers. If specified as an object only specified source layers will have id overriden, others will fallback to original feature id"
835
836
  },
836
837
  volatile: {
837
838
  type: "boolean",
@@ -1197,7 +1198,7 @@ var source_geojson = {
1197
1198
  },
1198
1199
  promoteId: {
1199
1200
  type: "promoteId",
1200
- doc: "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`."
1201
+ doc: "A property to use as a feature id (for feature state). Either a property name, an expression to evaluate as the ID, or an object of the form `{<sourceLayer>: <propertyName/expression>}`. The expression can only be feature dependent if it is used."
1201
1202
  },
1202
1203
  dynamic: {
1203
1204
  type: "boolean",
@@ -1641,7 +1642,7 @@ var layer = {
1641
1642
  "symbol"
1642
1643
  ],
1643
1644
  "private": true,
1644
- 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."
1645
+ doc: "Conditional styling applied to symbol layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Works with appearances' are supported."
1645
1646
  }
1646
1647
  };
1647
1648
  var appearance = {
@@ -5603,6 +5604,7 @@ var expression_name = {
5603
5604
  doc: "Experimental. Returns `true` if the input floor id belongs to one of the active indoor floors, `false` otherwise. In case of array of strings, returns `true` if any of the input floor ids belongs to one of the active indoor floors, `false` otherwise. Only supported in filters.",
5604
5605
  group: "Indoor",
5605
5606
  experimental: true,
5607
+ "private": true,
5606
5608
  "sdk-support": {
5607
5609
  "basic functionality": {
5608
5610
  js: "3.16.0",
@@ -6470,26 +6472,29 @@ var colorTheme = {
6470
6472
  }
6471
6473
  }
6472
6474
  };
6473
- var indoor = {
6474
- floorplanFeaturesetId: {
6475
+ var indoor_source = {
6476
+ sourceId: {
6475
6477
  type: "string",
6476
- doc: "An ID of a featureset to be used to query indoor floorplans.",
6478
+ doc: "Source ID of a source to be used to retrieve indoor data.",
6477
6479
  experimental: true,
6480
+ "private": true,
6478
6481
  transition: false,
6479
- "property-type": "data-constant",
6480
- expression: {
6481
- interpolated: false
6482
- }
6482
+ "property-type": "data-constant"
6483
6483
  },
6484
- buildingFeaturesetId: {
6485
- type: "string",
6486
- doc: "An ID of a featureset to be used to add interactivity for building selection.",
6484
+ sourceLayers: {
6485
+ type: "array",
6486
+ value: "string",
6487
+ doc: "An array of source layers to be used to retrieve indoor data.",
6487
6488
  experimental: true,
6489
+ "private": true,
6488
6490
  transition: false,
6489
- "property-type": "data-constant",
6490
- expression: {
6491
- interpolated: false
6492
- }
6491
+ "property-type": "data-constant"
6492
+ }
6493
+ };
6494
+ var indoor = {
6495
+ "*": {
6496
+ type: "indoor_source",
6497
+ doc: "Specification of an indoor source - sourceId and sourceLayer required for vector source, for GeoJSON sourceLayers should be omitted."
6493
6498
  }
6494
6499
  };
6495
6500
  var light = {
@@ -10565,7 +10570,7 @@ var transition = {
10565
10570
  var promoteId = {
10566
10571
  "*": {
10567
10572
  type: "*",
10568
- doc: "A feature property name to use as the ID, or an expression to evaluate as the ID for feature state."
10573
+ doc: "A feature property name to use as the ID, or an expression to evaluate as the ID for feature state. The expression can only be feature dependent if it is used."
10569
10574
  }
10570
10575
  };
10571
10576
  var $doc = {
@@ -10907,6 +10912,7 @@ var v8 = {
10907
10912
  rain: rain,
10908
10913
  camera: camera,
10909
10914
  colorTheme: colorTheme,
10915
+ indoor_source: indoor_source,
10910
10916
  indoor: indoor,
10911
10917
  light: light,
10912
10918
  projection: projection,
@@ -14117,8 +14123,7 @@ class FormatExpression {
14117
14123
  }
14118
14124
  return new FormattedSection(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14119
14125
  toString(evaluatedContent), null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14120
- section.scale ? section.scale.evaluate(ctx) : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
14121
- section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14126
+ section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14122
14127
  section.textColor ? section.textColor.evaluate(ctx) : null);
14123
14128
  };
14124
14129
  return new Formatted(this.sections.map(evaluateSection));
@@ -16427,8 +16432,7 @@ function linesToGeometryDistance(originGeometry, canonical, geometry) {
16427
16432
  }
16428
16433
  const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
16429
16434
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
16430
- return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16431
- geometry.type === 'LineString', lngLatLines, ruler);
16435
+ return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
16432
16436
  }
16433
16437
  if (geometry.type === 'MultiLineString') {
16434
16438
  let dist = Infinity;
@@ -16465,8 +16469,7 @@ function polygonsToGeometryDistance(originGeometry, canonical, geometry) {
16465
16469
  }
16466
16470
  const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
16467
16471
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
16468
- return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16469
- geometry.type === 'LineString', lngLatPolygons, ruler);
16472
+ return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
16470
16473
  }
16471
16474
  if (geometry.type === 'MultiLineString') {
16472
16475
  let dist = Infinity;
@@ -16480,8 +16483,7 @@ function polygonsToGeometryDistance(originGeometry, canonical, geometry) {
16480
16483
  return dist;
16481
16484
  }
16482
16485
  if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
16483
- return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16484
- lngLatPolygons, ruler);
16486
+ return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, lngLatPolygons, ruler);
16485
16487
  }
16486
16488
  return null;
16487
16489
  }
@@ -17420,11 +17422,8 @@ class Coalesce {
17420
17422
  outputType = outputType || parsed.type;
17421
17423
  parsedArgs.push(parsed);
17422
17424
  }
17423
- const needsAnnotation = expectedType && // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
17424
- parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
17425
- return needsAnnotation ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
17426
- new Coalesce(ValueType, parsedArgs) : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
17427
- new Coalesce(outputType, parsedArgs);
17425
+ const needsAnnotation = expectedType && parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
17426
+ return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
17428
17427
  }
17429
17428
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17430
17429
  evaluate(ctx) {
@@ -19358,6 +19357,9 @@ class StyleExpression {
19358
19357
  constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
19359
19358
  this.expression = expression;
19360
19359
  this._warningHistory = {};
19360
+ this._scope = scope;
19361
+ this._options = options;
19362
+ this._iconImageUseTheme = iconImageUseTheme;
19361
19363
  this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
19362
19364
  this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
19363
19365
  this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
@@ -19376,6 +19378,9 @@ class StyleExpression {
19376
19378
  return this.expression.evaluate(this._evaluator);
19377
19379
  }
19378
19380
  evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
19381
+ if (!this._evaluator) {
19382
+ this._evaluator = new EvaluationContext(this._scope, this._options, this._iconImageUseTheme);
19383
+ }
19379
19384
  this._evaluator.globals = globals;
19380
19385
  this._evaluator.feature = feature || null;
19381
19386
  this._evaluator.featureState = featureState || null;
@@ -21637,14 +21642,12 @@ function validateNonExpressionFilter(options) {
21637
21642
  case '<':
21638
21643
  case '<=':
21639
21644
  case '>':
21640
- // @ts-expect-error - falls through
21641
21645
  case '>=':
21642
21646
  if (value.length >= 2 && unbundle(value[1]) === '$type') {
21643
21647
  errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
21644
21648
  }
21645
21649
  /* falls through */
21646
21650
  case '==':
21647
- // @ts-expect-error - falls through
21648
21651
  case '!=':
21649
21652
  if (value.length !== 3) {
21650
21653
  errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
@@ -21706,16 +21709,16 @@ function validateProperty(options, propertyType) {
21706
21709
  return [];
21707
21710
  const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
21708
21711
  if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
21709
- if (isExpression(value)) {
21712
+ if (isExpression(deepUnbundle(value))) {
21710
21713
  const errors2 = [];
21711
21714
  return errors2.concat(validate({
21712
- key: options.key,
21715
+ key,
21713
21716
  value,
21714
21717
  valueSpec: {
21715
- 'type': 'string',
21716
- 'expression': {
21717
- 'interpolated': false,
21718
- 'parameters': [
21718
+ type: 'string',
21719
+ expression: {
21720
+ interpolated: false,
21721
+ parameters: [
21719
21722
  'zoom',
21720
21723
  'feature'
21721
21724
  ]
@@ -21769,7 +21772,8 @@ Use an identity property function instead: ${ example }.`)];
21769
21772
  } else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
21770
21773
  if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
21771
21774
  const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
21772
- const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
21775
+ const expressionValue = expression.value;
21776
+ const expressionObj = 'expression' in expressionValue && expressionValue.expression || '_styleExpression' in expressionValue && expressionValue._styleExpression && expressionValue._styleExpression.expression;
21773
21777
  if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
21774
21778
  if (propertyKey !== 'model-emissive-strength' || (!isFeatureConstant(expressionObj) || !isStateConstant(expressionObj))) {
21775
21779
  errors.push(new ValidationError(key, value, `${ propertyKey } does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
@@ -21780,7 +21784,6 @@ Use an identity property function instead: ${ example }.`)];
21780
21784
  return errors.concat(validate({
21781
21785
  key: options.key,
21782
21786
  value,
21783
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21784
21787
  valueSpec,
21785
21788
  style,
21786
21789
  styleSpec,
@@ -21812,7 +21815,7 @@ function validateAppearance(options) {
21812
21815
  }, options2))
21813
21816
  }
21814
21817
  });
21815
- if (name !== 'hidden' && !condition) {
21818
+ if (name !== 'hidden' && condition === void 0) {
21816
21819
  errors.push(new ValidationError(options.key, 'name', `Appearance with name different than "hidden" must have a condition`));
21817
21820
  }
21818
21821
  return errors;
@@ -21836,7 +21839,6 @@ function validateProperties(options) {
21836
21839
  layer,
21837
21840
  layerType,
21838
21841
  value: properties[propertyKey],
21839
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21840
21842
  valueSpec: propertyType === 'paint' ? paintProperties[propertyKey] : layoutProperties[propertyKey]
21841
21843
  });
21842
21844
  errors.push(...validateProperty(propertyValidationOptions, propertyType));
@@ -21850,7 +21852,6 @@ function validateCondition(options) {
21850
21852
  errors.push(...validateExpression({
21851
21853
  key: options.key,
21852
21854
  value: condition,
21853
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
21854
21855
  valueSpec: v8['appearance']['condition'],
21855
21856
  expressionContext: 'appearance'
21856
21857
  }));
@@ -22153,10 +22154,11 @@ function validateSource(options) {
22153
22154
  }
22154
22155
  }
22155
22156
  function getSourceTypeValues(styleSpec) {
22156
- return styleSpec.source.reduce((memo, source) => {
22157
+ const sourceArray = styleSpec.source;
22158
+ return sourceArray.reduce((memo, source) => {
22157
22159
  const sourceType = styleSpec[source];
22158
22160
  if (sourceType.type.type === 'enum') {
22159
- memo = memo.concat(Object.keys(sourceType.type.values));
22161
+ memo = memo.concat(Object.keys(sourceType.type.values || {}));
22160
22162
  }
22161
22163
  return memo;
22162
22164
  }, []);
@@ -22517,7 +22519,6 @@ function validateProjection(options) {
22517
22519
  errors = errors.concat(validate({
22518
22520
  key,
22519
22521
  value: projection[key],
22520
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
22521
22522
  valueSpec: projectionSpec[key],
22522
22523
  style,
22523
22524
  styleSpec
@@ -22658,7 +22659,8 @@ function validateObject(options) {
22658
22659
  if (elementValidators[elementSpecKey]) {
22659
22660
  continue;
22660
22661
  }
22661
- if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === void 0 && object[elementSpecKey] === void 0) {
22662
+ const elementSpec = elementSpecs[elementSpecKey];
22663
+ if (elementSpec.required && elementSpec['default'] === void 0 && object[elementSpecKey] === void 0) {
22662
22664
  errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
22663
22665
  }
22664
22666
  }