@mapbox/mapbox-gl-style-spec 14.35.0 → 14.36.0-rc.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/dist/index.cjs CHANGED
@@ -2967,13 +2967,13 @@
2967
2967
  type: "enum",
2968
2968
  values: {
2969
2969
  auto: {
2970
- doc: "Sorts symbols by `symbol-sort-key` if set. Otherwise, sorts symbols by their y-position relative to the viewport if `icon-allow-overlap` or `text-allow-overlap` is set to `true` or `icon-ignore-placement` or `text-ignore-placement` is `false`."
2970
+ doc: "Behaves as `source`, if `symbol-sort-key` is set. Otherwise behaves as `viewport-y`. I.e.: Sorts symbols by `symbol-sort-key` if `symbol-sort-key` is set. Otherwise, sorts symbols by their y-position relative to the viewport if any of the following is set to `true`: `icon-allow-overlap`, `text-allow-overlap`, `icon-ignore-placement`, `text-ignore-placement`. Or else, no sorting is applied; symbols are rendered in the same order as the source data."
2971
2971
  },
2972
2972
  "viewport-y": {
2973
- doc: "Sorts symbols by their y-position relative to the viewport if any of the following is set to `true`: `icon-allow-overlap`, `text-allow-overlap`, `icon-ignore-placement`, `text-ignore-placement`."
2973
+ doc: "Sorts symbols by their y-position relative to the viewport if any of the following is set to `true`: `icon-allow-overlap`, `text-allow-overlap`, `icon-ignore-placement`, `text-ignore-placement`. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data."
2974
2974
  },
2975
2975
  source: {
2976
- doc: "Sorts symbols by `symbol-sort-key` if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data."
2976
+ doc: "Sorts symbols by `symbol-sort-key` if `symbol-sort-key` is set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data."
2977
2977
  }
2978
2978
  },
2979
2979
  "default": "auto",
@@ -13652,7 +13652,6 @@
13652
13652
  }
13653
13653
  return new Assertion(type, parsed);
13654
13654
  }
13655
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13656
13655
  evaluate(ctx) {
13657
13656
  for (let i = 0; i < this.args.length; i++) {
13658
13657
  const value = this.args[i].evaluate(ctx);
@@ -14082,13 +14081,12 @@
14082
14081
  }
14083
14082
  return new Coercion(type, parsed);
14084
14083
  }
14085
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14086
14084
  evaluate(ctx) {
14087
14085
  if (this.type.kind === "boolean") {
14088
14086
  return Boolean(this.args[0].evaluate(ctx));
14089
14087
  } else if (this.type.kind === "color") {
14090
14088
  let input;
14091
- let error;
14089
+ let error = null;
14092
14090
  for (const arg of this.args) {
14093
14091
  input = arg.evaluate(ctx);
14094
14092
  error = null;
@@ -14980,6 +14978,7 @@
14980
14978
  }
14981
14979
  class Within {
14982
14980
  constructor(geojson, geometries) {
14981
+ this.featureConstant = false;
14983
14982
  this.type = BooleanType;
14984
14983
  this.geojson = geojson;
14985
14984
  this.geometries = geometries;
@@ -15100,133 +15099,6 @@
15100
15099
 
15101
15100
  var EXTENT = 8192;
15102
15101
 
15103
- const FQIDSeparator = "";
15104
- function makeConfigFQID(id, ownScope, contextScope) {
15105
- let fqid = id || "";
15106
- if (ownScope) fqid = fqid ? fqid + FQIDSeparator + ownScope : ownScope;
15107
- if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
15108
- return fqid;
15109
- }
15110
- function coerceValue(type, value) {
15111
- switch (type) {
15112
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15113
- case "string":
15114
- return toString(value);
15115
- case "number":
15116
- return +value;
15117
- case "boolean":
15118
- return !!value;
15119
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15120
- case "color":
15121
- return Color.parse(value);
15122
- case "formatted": {
15123
- return Formatted.fromString(toString(value));
15124
- }
15125
- case "resolvedImage": {
15126
- return ResolvedImage.build(toString(value));
15127
- }
15128
- }
15129
- return value;
15130
- }
15131
- function clampToAllowedNumber(value, min, max, step) {
15132
- if (step !== void 0) {
15133
- value = step * Math.round(value / step);
15134
- }
15135
- if (min !== void 0 && value < min) {
15136
- value = min;
15137
- }
15138
- if (max !== void 0 && value > max) {
15139
- value = max;
15140
- }
15141
- return value;
15142
- }
15143
- class Config {
15144
- constructor(type, key, scope, featureConstant = false) {
15145
- this.type = type;
15146
- this.key = key;
15147
- this.scope = scope;
15148
- this.featureConstant = featureConstant;
15149
- }
15150
- static parse(args, context) {
15151
- let type = context.expectedType;
15152
- type ?? (type = ValueType);
15153
- if (args.length < 2 || args.length > 3) {
15154
- return context.error(`Invalid number of arguments for 'config' expression.`);
15155
- }
15156
- const configKey = context.parse(args[1], 1);
15157
- if (!(configKey instanceof Literal)) {
15158
- return context.error(`Key name of 'config' expression must be a string literal.`);
15159
- }
15160
- let featureConstant = true;
15161
- let configScopeValue;
15162
- const configKeyValue = toString(configKey.value);
15163
- if (args.length >= 3) {
15164
- const configScope = context.parse(args[2], 2);
15165
- if (!(configScope instanceof Literal)) {
15166
- return context.error(`Scope of 'config' expression must be a string literal.`);
15167
- }
15168
- configScopeValue = toString(configScope.value);
15169
- }
15170
- if (context.options) {
15171
- const fqid = makeConfigFQID(configKeyValue, configScopeValue, context._scope);
15172
- const config = context.options.get(fqid);
15173
- if (config) {
15174
- featureConstant = isFeatureConstant(config.value || config.default);
15175
- }
15176
- }
15177
- return new Config(type, configKeyValue, configScopeValue, featureConstant);
15178
- }
15179
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15180
- evaluate(ctx) {
15181
- const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
15182
- const config = ctx.getConfig(fqid);
15183
- if (!config) return null;
15184
- const { type, value, values, minValue, maxValue, stepValue } = config;
15185
- const defaultValue = config.default.evaluate(ctx);
15186
- let result = defaultValue;
15187
- if (value) {
15188
- const originalScope = ctx.scope;
15189
- const scope = originalScope || "";
15190
- const sep = scope.indexOf(FQIDSeparator);
15191
- ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
15192
- result = value.evaluate(ctx);
15193
- ctx.scope = originalScope;
15194
- }
15195
- if (type) {
15196
- result = coerceValue(type, result);
15197
- }
15198
- if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
15199
- if (typeof result === "number") {
15200
- result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
15201
- } else if (Array.isArray(result)) {
15202
- result = result.map((item) => typeof item === "number" ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
15203
- }
15204
- }
15205
- if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
15206
- result = defaultValue;
15207
- if (type) {
15208
- result = coerceValue(type, result);
15209
- }
15210
- }
15211
- if (type && type !== this.type || result !== void 0 && !typeEquals(typeOf(result), this.type)) {
15212
- result = coerceValue(this.type.kind, result);
15213
- }
15214
- return result;
15215
- }
15216
- eachChild() {
15217
- }
15218
- outputDefined() {
15219
- return false;
15220
- }
15221
- serialize() {
15222
- const res = ["config", this.key];
15223
- if (this.scope) {
15224
- res.push(this.scope);
15225
- }
15226
- return res;
15227
- }
15228
- }
15229
-
15230
15102
  function isFeatureConstant(e) {
15231
15103
  if (e instanceof CompoundExpression) {
15232
15104
  if (e.name === "get" && e.args.length === 1) {
@@ -15241,13 +15113,7 @@
15241
15113
  return false;
15242
15114
  }
15243
15115
  }
15244
- if (e instanceof Within) {
15245
- return false;
15246
- }
15247
- if (e instanceof Distance) {
15248
- return false;
15249
- }
15250
- if (e instanceof Config) {
15116
+ if (e.featureConstant !== void 0) {
15251
15117
  return e.featureConstant;
15252
15118
  }
15253
15119
  let result = true;
@@ -15862,6 +15728,7 @@
15862
15728
  }
15863
15729
  class Distance {
15864
15730
  constructor(geojson) {
15731
+ this.featureConstant = false;
15865
15732
  this.type = NumberType;
15866
15733
  this.geojson = geojson;
15867
15734
  }
@@ -15929,6 +15796,132 @@
15929
15796
  }
15930
15797
  }
15931
15798
 
15799
+ const FQIDSeparator = "";
15800
+ function makeConfigFQID(id, ownScope, contextScope) {
15801
+ let fqid = id || "";
15802
+ if (ownScope) fqid = fqid ? fqid + FQIDSeparator + ownScope : ownScope;
15803
+ if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
15804
+ return fqid;
15805
+ }
15806
+ function coerceValue(type, value) {
15807
+ switch (type) {
15808
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15809
+ case "string":
15810
+ return toString(value);
15811
+ case "number":
15812
+ return +value;
15813
+ case "boolean":
15814
+ return !!value;
15815
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15816
+ case "color":
15817
+ return Color.parse(value);
15818
+ case "formatted": {
15819
+ return Formatted.fromString(toString(value));
15820
+ }
15821
+ case "resolvedImage": {
15822
+ return ResolvedImage.build(toString(value));
15823
+ }
15824
+ }
15825
+ return value;
15826
+ }
15827
+ function clampToAllowedNumber(value, min, max, step) {
15828
+ if (step !== void 0) {
15829
+ value = step * Math.round(value / step);
15830
+ }
15831
+ if (min !== void 0 && value < min) {
15832
+ value = min;
15833
+ }
15834
+ if (max !== void 0 && value > max) {
15835
+ value = max;
15836
+ }
15837
+ return value;
15838
+ }
15839
+ class Config {
15840
+ constructor(type, key, scope, featureConstant = false) {
15841
+ this.type = type;
15842
+ this.key = key;
15843
+ this.scope = scope;
15844
+ this.featureConstant = featureConstant;
15845
+ }
15846
+ static parse(args, context) {
15847
+ let type = context.expectedType;
15848
+ type ?? (type = ValueType);
15849
+ if (args.length < 2 || args.length > 3) {
15850
+ return context.error(`Invalid number of arguments for 'config' expression.`);
15851
+ }
15852
+ const configKey = context.parse(args[1], 1);
15853
+ if (!(configKey instanceof Literal)) {
15854
+ return context.error(`Key name of 'config' expression must be a string literal.`);
15855
+ }
15856
+ let featureConstant = true;
15857
+ let configScopeValue;
15858
+ const configKeyValue = toString(configKey.value);
15859
+ if (args.length >= 3) {
15860
+ const configScope = context.parse(args[2], 2);
15861
+ if (!(configScope instanceof Literal)) {
15862
+ return context.error(`Scope of 'config' expression must be a string literal.`);
15863
+ }
15864
+ configScopeValue = toString(configScope.value);
15865
+ }
15866
+ if (context.options) {
15867
+ const fqid = makeConfigFQID(configKeyValue, configScopeValue, context._scope);
15868
+ const config = context.options.get(fqid);
15869
+ if (config) {
15870
+ featureConstant = isFeatureConstant(config.value || config.default);
15871
+ }
15872
+ }
15873
+ return new Config(type, configKeyValue, configScopeValue, featureConstant);
15874
+ }
15875
+ evaluate(ctx) {
15876
+ const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
15877
+ const config = ctx.getConfig(fqid);
15878
+ if (!config) return null;
15879
+ const { type, value, values, minValue, maxValue, stepValue } = config;
15880
+ const defaultValue = config.default.evaluate(ctx);
15881
+ let result = defaultValue;
15882
+ if (value) {
15883
+ const originalScope = ctx.scope;
15884
+ const scope = originalScope || "";
15885
+ const sep = scope.indexOf(FQIDSeparator);
15886
+ ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
15887
+ result = value.evaluate(ctx);
15888
+ ctx.scope = originalScope;
15889
+ }
15890
+ if (type) {
15891
+ result = coerceValue(type, result);
15892
+ }
15893
+ if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
15894
+ if (typeof result === "number") {
15895
+ result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
15896
+ } else if (Array.isArray(result)) {
15897
+ result = result.map((item) => typeof item === "number" ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
15898
+ }
15899
+ }
15900
+ if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
15901
+ result = defaultValue;
15902
+ if (type) {
15903
+ result = coerceValue(type, result);
15904
+ }
15905
+ }
15906
+ if (type && type !== this.type || result !== void 0 && !typeEquals(typeOf(result), this.type)) {
15907
+ result = coerceValue(this.type.kind, result);
15908
+ }
15909
+ return result;
15910
+ }
15911
+ eachChild() {
15912
+ }
15913
+ outputDefined() {
15914
+ return false;
15915
+ }
15916
+ serialize() {
15917
+ const res = ["config", this.key];
15918
+ if (this.scope) {
15919
+ res.push(this.scope);
15920
+ }
15921
+ return res;
15922
+ }
15923
+ }
15924
+
15932
15925
  class Var {
15933
15926
  constructor(name, boundExpression) {
15934
15927
  this.type = boundExpression.type;
@@ -15944,7 +15937,6 @@
15944
15937
  }
15945
15938
  return new Var(name, context.scope.get(name));
15946
15939
  }
15947
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15948
15940
  evaluate(ctx) {
15949
15941
  return this.boundExpression.evaluate(ctx);
15950
15942
  }
@@ -16256,7 +16248,6 @@
16256
16248
  }
16257
16249
  return new Step(outputType, input, stops);
16258
16250
  }
16259
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16260
16251
  evaluate(ctx) {
16261
16252
  const labels = this.labels;
16262
16253
  const outputs = this.outputs;
@@ -16641,7 +16632,6 @@
16641
16632
  const needsAnnotation = expectedType && parsedArgs.some((arg) => checkSubtype(expectedType, arg.type));
16642
16633
  return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
16643
16634
  }
16644
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16645
16635
  evaluate(ctx) {
16646
16636
  let result = null;
16647
16637
  let argCount = 0;
@@ -16684,7 +16674,6 @@
16684
16674
  this.bindings = [].concat(bindings);
16685
16675
  this.result = result;
16686
16676
  }
16687
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16688
16677
  evaluate(ctx) {
16689
16678
  return this.result.evaluate(ctx);
16690
16679
  }
@@ -16878,7 +16867,6 @@
16878
16867
  }
16879
16868
  return new Match(inputType, outputType, input, cases, outputs, otherwise);
16880
16869
  }
16881
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16882
16870
  evaluate(ctx) {
16883
16871
  const input = this.input.evaluate(ctx);
16884
16872
  const output = typeEquals(typeOf(input), this.inputType) && this.outputs[this.cases[input]] || this.otherwise;
@@ -16952,7 +16940,6 @@
16952
16940
  if (!otherwise) return null;
16953
16941
  return new Case(outputType, branches, otherwise);
16954
16942
  }
16955
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16956
16943
  evaluate(ctx) {
16957
16944
  for (const [test, expression] of this.branches) {
16958
16945
  if (test.evaluate(ctx)) {
@@ -17007,7 +16994,6 @@
17007
16994
  return new Slice(input.type, input, beginIndex);
17008
16995
  }
17009
16996
  }
17010
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17011
16997
  evaluate(ctx) {
17012
16998
  const input = this.input.evaluate(ctx);
17013
16999
  const beginIndex = this.beginIndex.evaluate(ctx);
@@ -17369,22 +17355,22 @@
17369
17355
  "config": Config
17370
17356
  });
17371
17357
  function rgba(ctx, [r, g, b, a]) {
17372
- r = r.evaluate(ctx);
17373
- g = g.evaluate(ctx);
17374
- b = b.evaluate(ctx);
17358
+ const red = r.evaluate(ctx);
17359
+ const green = g.evaluate(ctx);
17360
+ const blue = b.evaluate(ctx);
17375
17361
  const alpha = a ? a.evaluate(ctx) : 1;
17376
- const error = validateRGBA(r, g, b, alpha);
17362
+ const error = validateRGBA(red, green, blue, alpha);
17377
17363
  if (error) throw new RuntimeError(error);
17378
- return new Color(r / 255, g / 255, b / 255, alpha);
17364
+ return new Color(red / 255, green / 255, blue / 255, alpha);
17379
17365
  }
17380
17366
  function hsla(ctx, [h, s, l, a]) {
17381
- h = h.evaluate(ctx);
17382
- s = s.evaluate(ctx);
17383
- l = l.evaluate(ctx);
17367
+ const hValue = h.evaluate(ctx);
17368
+ const sValue = s.evaluate(ctx);
17369
+ const lValue = l.evaluate(ctx);
17384
17370
  const alpha = a ? a.evaluate(ctx) : 1;
17385
- const error = validateHSLA(h, s, l, alpha);
17371
+ const error = validateHSLA(hValue, sValue, lValue, alpha);
17386
17372
  if (error) throw new RuntimeError(error);
17387
- const hue = h % 360 / 360, sat = s / 100, lum = l / 100;
17373
+ const hue = hValue % 360 / 360, sat = sValue / 100, lum = lValue / 100;
17388
17374
  const m2 = lum <= 0.5 ? lum * (sat + 1) : lum + sat - lum * sat;
17389
17375
  const m1 = lum * 2 - m2;
17390
17376
  return new Color(hueToByte(m1, m2, hue + 1 / 3), hueToByte(m1, m2, hue), hueToByte(m1, m2, hue - 1 / 3), alpha);
@@ -18841,7 +18827,6 @@ ${JSON.stringify(filterExp, null, 2)}
18841
18827
  return {
18842
18828
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18843
18829
  filter: filterFunc,
18844
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18845
18830
  dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : void 0,
18846
18831
  needGeometry,
18847
18832
  needFeature: !!needFeature
@@ -20049,12 +20034,10 @@ ${JSON.stringify(filterExp, null, 2)}
20049
20034
  });
20050
20035
  }
20051
20036
  const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
20052
- if (options.expressionContext === "property" && options.propertyKey === "text-font" && // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
20053
- !expressionObj.outputDefined()) {
20037
+ if (options.expressionContext === "property" && options.propertyKey === "text-font" && !expressionObj.outputDefined()) {
20054
20038
  return [new ValidationError(options.key, options.value, `Invalid data expression for "${options.propertyKey}". Output values must be contained as literals within the expression.`)];
20055
20039
  }
20056
- if (options.expressionContext === "property" && options.propertyType === "layout" && // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
20057
- !isStateConstant(expressionObj)) {
20040
+ if (options.expressionContext === "property" && options.propertyType === "layout" && !isStateConstant(expressionObj)) {
20058
20041
  return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with layout properties.')];
20059
20042
  }
20060
20043
  if (options.expressionContext === "filter") {