@mapbox/mapbox-gl-style-spec 14.16.0-beta.3 → 14.16.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.
package/diff.ts CHANGED
@@ -629,8 +629,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
629
629
  const sourcesRemoved: Record<string, true> = {};
630
630
 
631
631
  // First collect the {add,remove}Source commands
632
- const removeOrAddSourceCommands = [];
633
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
632
+ const removeOrAddSourceCommands: Command[] = [];
634
633
  diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);
635
634
 
636
635
  // Push a removeLayer command for each style layer that depends on a
@@ -638,7 +637,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
638
637
  // Also, exclude any such layers them from the input to `diffLayers`
639
638
  // below, so that diffLayers produces the appropriate `addLayers`
640
639
  // command
641
- const beforeLayers = [];
640
+ const beforeLayers: LayerSpecification[] = [];
642
641
  if (before.layers) {
643
642
  before.layers.forEach((layer) => {
644
643
  if (layer.source && sourcesRemoved[layer.source]) {
@@ -667,7 +666,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
667
666
  }
668
667
 
669
668
  // Handle changes to `layers`
670
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
669
+
671
670
  diffLayers(beforeLayers, after.layers, commands);
672
671
  } catch (e) {
673
672
  // fall back to setStyle
package/dist/index.cjs CHANGED
@@ -838,7 +838,7 @@
838
838
  },
839
839
  promoteId: {
840
840
  type: "promoteId",
841
- 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"
841
+ 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"
842
842
  },
843
843
  volatile: {
844
844
  type: "boolean",
@@ -1204,7 +1204,7 @@
1204
1204
  },
1205
1205
  promoteId: {
1206
1206
  type: "promoteId",
1207
- doc: "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`."
1207
+ 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."
1208
1208
  },
1209
1209
  dynamic: {
1210
1210
  type: "boolean",
@@ -1647,8 +1647,8 @@
1647
1647
  "supported-layer-types": [
1648
1648
  "symbol"
1649
1649
  ],
1650
- "private": true,
1651
- 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."
1650
+ experimental: true,
1651
+ 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."
1652
1652
  }
1653
1653
  };
1654
1654
  var appearance = {
@@ -1656,7 +1656,7 @@
1656
1656
  type: "boolean",
1657
1657
  doc: "A boolean expression that determines when this appearance should be applied.",
1658
1658
  expression: {
1659
- interpolated: false,
1659
+ interpolated: true,
1660
1660
  parameters: [
1661
1661
  "zoom",
1662
1662
  "pitch",
@@ -6500,6 +6500,8 @@
6500
6500
  var indoor = {
6501
6501
  "*": {
6502
6502
  type: "indoor_source",
6503
+ "private": true,
6504
+ experimental: true,
6503
6505
  doc: "Specification of an indoor source - sourceId and sourceLayer required for vector source, for GeoJSON sourceLayers should be omitted."
6504
6506
  }
6505
6507
  };
@@ -10576,7 +10578,7 @@
10576
10578
  var promoteId = {
10577
10579
  "*": {
10578
10580
  type: "*",
10579
- doc: "A feature property name to use as the ID, or an expression to evaluate as the ID for feature state."
10581
+ 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."
10580
10582
  }
10581
10583
  };
10582
10584
  var $doc = {
@@ -14129,8 +14131,7 @@
14129
14131
  }
14130
14132
  return new FormattedSection(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14131
14133
  toString(evaluatedContent), null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14132
- 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
14133
- section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14134
+ section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14134
14135
  section.textColor ? section.textColor.evaluate(ctx) : null);
14135
14136
  };
14136
14137
  return new Formatted(this.sections.map(evaluateSection));
@@ -16439,8 +16440,7 @@
16439
16440
  }
16440
16441
  const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
16441
16442
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
16442
- return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16443
- geometry.type === 'LineString', lngLatLines, ruler);
16443
+ return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
16444
16444
  }
16445
16445
  if (geometry.type === 'MultiLineString') {
16446
16446
  let dist = Infinity;
@@ -16477,8 +16477,7 @@
16477
16477
  }
16478
16478
  const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
16479
16479
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
16480
- return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16481
- geometry.type === 'LineString', lngLatPolygons, ruler);
16480
+ return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
16482
16481
  }
16483
16482
  if (geometry.type === 'MultiLineString') {
16484
16483
  let dist = Infinity;
@@ -16492,8 +16491,7 @@
16492
16491
  return dist;
16493
16492
  }
16494
16493
  if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
16495
- return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
16496
- lngLatPolygons, ruler);
16494
+ return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, lngLatPolygons, ruler);
16497
16495
  }
16498
16496
  return null;
16499
16497
  }
@@ -17432,11 +17430,8 @@
17432
17430
  outputType = outputType || parsed.type;
17433
17431
  parsedArgs.push(parsed);
17434
17432
  }
17435
- const needsAnnotation = expectedType && // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
17436
- parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
17437
- return needsAnnotation ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
17438
- new Coalesce(ValueType, parsedArgs) : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
17439
- new Coalesce(outputType, parsedArgs);
17433
+ const needsAnnotation = expectedType && parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
17434
+ return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
17440
17435
  }
17441
17436
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17442
17437
  evaluate(ctx) {
@@ -19370,6 +19365,9 @@
19370
19365
  constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
19371
19366
  this.expression = expression;
19372
19367
  this._warningHistory = {};
19368
+ this._scope = scope;
19369
+ this._options = options;
19370
+ this._iconImageUseTheme = iconImageUseTheme;
19373
19371
  this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
19374
19372
  this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
19375
19373
  this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
@@ -19388,6 +19386,9 @@
19388
19386
  return this.expression.evaluate(this._evaluator);
19389
19387
  }
19390
19388
  evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
19389
+ if (!this._evaluator) {
19390
+ this._evaluator = new EvaluationContext(this._scope, this._options, this._iconImageUseTheme);
19391
+ }
19391
19392
  this._evaluator.globals = globals;
19392
19393
  this._evaluator.feature = feature || null;
19393
19394
  this._evaluator.featureState = featureState || null;
@@ -21645,23 +21646,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21645
21646
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21646
21647
  valueSpec: styleSpec.filter_operator
21647
21648
  });
21648
- switch (unbundle(value[0])) {
21649
- case '<':
21650
- case '<=':
21651
- case '>':
21652
- case '>=':
21653
- if (value.length >= 2 && unbundle(value[1]) === '$type') {
21654
- errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
21655
- }
21656
- /* falls through */
21657
- case '==':
21658
- case '!=':
21659
- if (value.length !== 3) {
21660
- errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
21661
- }
21662
- /* falls through */
21663
- case 'in':
21664
- case '!in':
21649
+ const validate = () => {
21665
21650
  if (value.length >= 2) {
21666
21651
  if (!isString(value[1])) {
21667
21652
  errors.push(new ValidationError(`${ key }[1]`, value[1], `string expected, ${ getType(value[1]) } found`));
@@ -21679,6 +21664,30 @@ ${ JSON.stringify(filterExp, null, 2) }
21679
21664
  errors.push(new ValidationError(`${ key }[${ i }]`, value[i], `string, number, or boolean expected, ${ getType(value[i]) } found.`));
21680
21665
  }
21681
21666
  }
21667
+ };
21668
+ switch (unbundle(value[0])) {
21669
+ case '<':
21670
+ case '<=':
21671
+ case '>':
21672
+ case '>=':
21673
+ if (value.length >= 2 && unbundle(value[1]) === '$type') {
21674
+ errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
21675
+ }
21676
+ if (value.length !== 3) {
21677
+ errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
21678
+ }
21679
+ validate();
21680
+ break;
21681
+ case '==':
21682
+ case '!=':
21683
+ if (value.length !== 3) {
21684
+ errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
21685
+ }
21686
+ validate();
21687
+ break;
21688
+ case 'in':
21689
+ case '!in':
21690
+ validate();
21682
21691
  break;
21683
21692
  case 'any':
21684
21693
  case 'all':
@@ -21779,7 +21788,8 @@ Use an identity property function instead: ${ example }.`)];
21779
21788
  } else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
21780
21789
  if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
21781
21790
  const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
21782
- const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
21791
+ const expressionValue = expression.value;
21792
+ const expressionObj = 'expression' in expressionValue && expressionValue.expression || '_styleExpression' in expressionValue && expressionValue._styleExpression && expressionValue._styleExpression.expression;
21783
21793
  if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
21784
21794
  if (propertyKey !== 'model-emissive-strength' || (!isFeatureConstant(expressionObj) || !isStateConstant(expressionObj))) {
21785
21795
  errors.push(new ValidationError(key, value, `${ propertyKey } does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
@@ -21858,7 +21868,6 @@ Use an identity property function instead: ${ example }.`)];
21858
21868
  errors.push(...validateExpression({
21859
21869
  key: options.key,
21860
21870
  value: condition,
21861
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
21862
21871
  valueSpec: v8['appearance']['condition'],
21863
21872
  expressionContext: 'appearance'
21864
21873
  }));
@@ -22161,10 +22170,11 @@ Use an identity property function instead: ${ example }.`)];
22161
22170
  }
22162
22171
  }
22163
22172
  function getSourceTypeValues(styleSpec) {
22164
- return styleSpec.source.reduce((memo, source) => {
22173
+ const sourceArray = styleSpec.source;
22174
+ return sourceArray.reduce((memo, source) => {
22165
22175
  const sourceType = styleSpec[source];
22166
22176
  if (sourceType.type.type === 'enum') {
22167
- memo = memo.concat(Object.keys(sourceType.type.values));
22177
+ memo = memo.concat(Object.keys(sourceType.type.values || {}));
22168
22178
  }
22169
22179
  return memo;
22170
22180
  }, []);
@@ -22525,7 +22535,6 @@ Use an identity property function instead: ${ example }.`)];
22525
22535
  errors = errors.concat(validate({
22526
22536
  key,
22527
22537
  value: projection[key],
22528
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
22529
22538
  valueSpec: projectionSpec[key],
22530
22539
  style,
22531
22540
  styleSpec
@@ -22666,7 +22675,8 @@ Use an identity property function instead: ${ example }.`)];
22666
22675
  if (elementValidators[elementSpecKey]) {
22667
22676
  continue;
22668
22677
  }
22669
- if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === void 0 && object[elementSpecKey] === void 0) {
22678
+ const elementSpec = elementSpecs[elementSpecKey];
22679
+ if (elementSpec.required && elementSpec['default'] === void 0 && object[elementSpecKey] === void 0) {
22670
22680
  errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
22671
22681
  }
22672
22682
  }
@@ -23879,7 +23889,6 @@ Use an identity property function instead: ${ example }.`)];
23879
23889
  }
23880
23890
  function getImportErrors(imports = []) {
23881
23891
  let errors = [];
23882
- let sourcesCount = 0;
23883
23892
  const validateImports = (imports2 = []) => {
23884
23893
  for (const importSpec of imports2) {
23885
23894
  const style = importSpec.data;
@@ -23891,7 +23900,6 @@ Use an identity property function instead: ${ example }.`)];
23891
23900
  errors = errors.concat(getRootErrors(style, Object.keys(v8.$root)));
23892
23901
  if (style.sources) {
23893
23902
  const sourcesErrors = getSourcesErrors(style.sources);
23894
- sourcesCount += sourcesErrors.sourcesCount;
23895
23903
  errors = errors.concat(sourcesErrors.errors);
23896
23904
  }
23897
23905
  }
@@ -23900,10 +23908,7 @@ Use an identity property function instead: ${ example }.`)];
23900
23908
  if (imports.length !== new Set(imports.map(i => i.id)).size) {
23901
23909
  errors.push(new ValidationError(null, null, 'Duplicate ids of imports'));
23902
23910
  }
23903
- return {
23904
- errors,
23905
- sourcesCount
23906
- };
23911
+ return errors;
23907
23912
  }
23908
23913
  function getRootErrors(style, specKeys) {
23909
23914
  const errors = [];
@@ -23960,8 +23965,7 @@ Use an identity property function instead: ${ example }.`)];
23960
23965
  }
23961
23966
  if (s.imports) {
23962
23967
  const importsErrors = getImportErrors(s.imports);
23963
- sourcesCount += importsErrors.sourcesCount;
23964
- errors = errors.concat(importsErrors.errors);
23968
+ errors = errors.concat(importsErrors);
23965
23969
  }
23966
23970
  errors = errors.concat(getMaxSourcesErrors(sourcesCount));
23967
23971
  return errors;