@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.d.ts CHANGED
@@ -1829,7 +1829,7 @@ declare const _exports: {
1829
1829
  doc: string;
1830
1830
  };
1831
1831
  };
1832
- default: any[];
1832
+ default: never[];
1833
1833
  doc: string;
1834
1834
  "sdk-support": {
1835
1835
  "basic functionality": {
@@ -1846,7 +1846,7 @@ declare const _exports: {
1846
1846
  "clip-layer-scope": {
1847
1847
  type: string;
1848
1848
  value: string;
1849
- default: any[];
1849
+ default: never[];
1850
1850
  doc: string;
1851
1851
  "sdk-support": {
1852
1852
  "basic functionality": {
@@ -7300,7 +7300,7 @@ declare const _exports: {
7300
7300
  private: boolean;
7301
7301
  expression: {
7302
7302
  interpolated: boolean;
7303
- parameters: any[];
7303
+ parameters: never[];
7304
7304
  };
7305
7305
  transition: boolean;
7306
7306
  doc: string;
@@ -9300,7 +9300,7 @@ declare const _exports: {
9300
9300
  })[];
9301
9301
  expression: {
9302
9302
  interpolated: boolean;
9303
- parameters: any[];
9303
+ parameters: never[];
9304
9304
  };
9305
9305
  "property-type": string;
9306
9306
  experimental: boolean;
@@ -9909,7 +9909,7 @@ declare const _exports: {
9909
9909
  };
9910
9910
  expression: {
9911
9911
  interpolated: boolean;
9912
- parameters: any[];
9912
+ parameters: never[];
9913
9913
  };
9914
9914
  experimental: boolean;
9915
9915
  "property-type": string;
@@ -12615,6 +12615,11 @@ type SerializedExpression = Array<unknown> | Array<string> | string | number | b
12615
12615
  interface Expression {
12616
12616
  readonly type: Type;
12617
12617
  value?: any;
12618
+ /**
12619
+ * Set by expressions whose feature-dependence can't be derived from their children
12620
+ * (e.g. `within`, `distance`, `config`); `isFeatureConstant` returns it without recursing.
12621
+ */
12622
+ readonly featureConstant?: boolean;
12618
12623
  evaluate: (ctx: EvaluationContext) => any;
12619
12624
  eachChild: (fn: (arg1: Expression) => void) => void;
12620
12625
  /**
@@ -12878,7 +12883,7 @@ declare function createFunction(input: unknown, propertySpec: StylePropertySpeci
12878
12883
  interpolationType: {
12879
12884
  name: "exponential";
12880
12885
  base: number;
12881
- };
12886
+ } | null;
12882
12887
  interpolationFactor: (input: number, lower: number, upper: number) => number;
12883
12888
  zoomStops: (string | number | boolean | {
12884
12889
  zoom: number;
package/dist/index.es.js CHANGED
@@ -2961,13 +2961,13 @@ var layout_symbol = {
2961
2961
  type: "enum",
2962
2962
  values: {
2963
2963
  auto: {
2964
- 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`."
2964
+ 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."
2965
2965
  },
2966
2966
  "viewport-y": {
2967
- 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`."
2967
+ 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."
2968
2968
  },
2969
2969
  source: {
2970
- 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."
2970
+ 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."
2971
2971
  }
2972
2972
  },
2973
2973
  "default": "auto",
@@ -13646,7 +13646,6 @@ class Assertion {
13646
13646
  }
13647
13647
  return new Assertion(type, parsed);
13648
13648
  }
13649
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13650
13649
  evaluate(ctx) {
13651
13650
  for (let i = 0; i < this.args.length; i++) {
13652
13651
  const value = this.args[i].evaluate(ctx);
@@ -14076,13 +14075,12 @@ class Coercion {
14076
14075
  }
14077
14076
  return new Coercion(type, parsed);
14078
14077
  }
14079
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14080
14078
  evaluate(ctx) {
14081
14079
  if (this.type.kind === "boolean") {
14082
14080
  return Boolean(this.args[0].evaluate(ctx));
14083
14081
  } else if (this.type.kind === "color") {
14084
14082
  let input;
14085
- let error;
14083
+ let error = null;
14086
14084
  for (const arg of this.args) {
14087
14085
  input = arg.evaluate(ctx);
14088
14086
  error = null;
@@ -14974,6 +14972,7 @@ function linesWithinPolygons(ctx, polygonGeometry) {
14974
14972
  }
14975
14973
  class Within {
14976
14974
  constructor(geojson, geometries) {
14975
+ this.featureConstant = false;
14977
14976
  this.type = BooleanType;
14978
14977
  this.geojson = geojson;
14979
14978
  this.geometries = geometries;
@@ -15094,133 +15093,6 @@ class TinyQueue {
15094
15093
 
15095
15094
  var EXTENT = 8192;
15096
15095
 
15097
- const FQIDSeparator = "";
15098
- function makeConfigFQID(id, ownScope, contextScope) {
15099
- let fqid = id || "";
15100
- if (ownScope) fqid = fqid ? fqid + FQIDSeparator + ownScope : ownScope;
15101
- if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
15102
- return fqid;
15103
- }
15104
- function coerceValue(type, value) {
15105
- switch (type) {
15106
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15107
- case "string":
15108
- return toString(value);
15109
- case "number":
15110
- return +value;
15111
- case "boolean":
15112
- return !!value;
15113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15114
- case "color":
15115
- return Color.parse(value);
15116
- case "formatted": {
15117
- return Formatted.fromString(toString(value));
15118
- }
15119
- case "resolvedImage": {
15120
- return ResolvedImage.build(toString(value));
15121
- }
15122
- }
15123
- return value;
15124
- }
15125
- function clampToAllowedNumber(value, min, max, step) {
15126
- if (step !== void 0) {
15127
- value = step * Math.round(value / step);
15128
- }
15129
- if (min !== void 0 && value < min) {
15130
- value = min;
15131
- }
15132
- if (max !== void 0 && value > max) {
15133
- value = max;
15134
- }
15135
- return value;
15136
- }
15137
- class Config {
15138
- constructor(type, key, scope, featureConstant = false) {
15139
- this.type = type;
15140
- this.key = key;
15141
- this.scope = scope;
15142
- this.featureConstant = featureConstant;
15143
- }
15144
- static parse(args, context) {
15145
- let type = context.expectedType;
15146
- type ?? (type = ValueType);
15147
- if (args.length < 2 || args.length > 3) {
15148
- return context.error(`Invalid number of arguments for 'config' expression.`);
15149
- }
15150
- const configKey = context.parse(args[1], 1);
15151
- if (!(configKey instanceof Literal)) {
15152
- return context.error(`Key name of 'config' expression must be a string literal.`);
15153
- }
15154
- let featureConstant = true;
15155
- let configScopeValue;
15156
- const configKeyValue = toString(configKey.value);
15157
- if (args.length >= 3) {
15158
- const configScope = context.parse(args[2], 2);
15159
- if (!(configScope instanceof Literal)) {
15160
- return context.error(`Scope of 'config' expression must be a string literal.`);
15161
- }
15162
- configScopeValue = toString(configScope.value);
15163
- }
15164
- if (context.options) {
15165
- const fqid = makeConfigFQID(configKeyValue, configScopeValue, context._scope);
15166
- const config = context.options.get(fqid);
15167
- if (config) {
15168
- featureConstant = isFeatureConstant(config.value || config.default);
15169
- }
15170
- }
15171
- return new Config(type, configKeyValue, configScopeValue, featureConstant);
15172
- }
15173
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15174
- evaluate(ctx) {
15175
- const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
15176
- const config = ctx.getConfig(fqid);
15177
- if (!config) return null;
15178
- const { type, value, values, minValue, maxValue, stepValue } = config;
15179
- const defaultValue = config.default.evaluate(ctx);
15180
- let result = defaultValue;
15181
- if (value) {
15182
- const originalScope = ctx.scope;
15183
- const scope = originalScope || "";
15184
- const sep = scope.indexOf(FQIDSeparator);
15185
- ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
15186
- result = value.evaluate(ctx);
15187
- ctx.scope = originalScope;
15188
- }
15189
- if (type) {
15190
- result = coerceValue(type, result);
15191
- }
15192
- if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
15193
- if (typeof result === "number") {
15194
- result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
15195
- } else if (Array.isArray(result)) {
15196
- result = result.map((item) => typeof item === "number" ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
15197
- }
15198
- }
15199
- if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
15200
- result = defaultValue;
15201
- if (type) {
15202
- result = coerceValue(type, result);
15203
- }
15204
- }
15205
- if (type && type !== this.type || result !== void 0 && !typeEquals(typeOf(result), this.type)) {
15206
- result = coerceValue(this.type.kind, result);
15207
- }
15208
- return result;
15209
- }
15210
- eachChild() {
15211
- }
15212
- outputDefined() {
15213
- return false;
15214
- }
15215
- serialize() {
15216
- const res = ["config", this.key];
15217
- if (this.scope) {
15218
- res.push(this.scope);
15219
- }
15220
- return res;
15221
- }
15222
- }
15223
-
15224
15096
  function isFeatureConstant(e) {
15225
15097
  if (e instanceof CompoundExpression) {
15226
15098
  if (e.name === "get" && e.args.length === 1) {
@@ -15235,13 +15107,7 @@ function isFeatureConstant(e) {
15235
15107
  return false;
15236
15108
  }
15237
15109
  }
15238
- if (e instanceof Within) {
15239
- return false;
15240
- }
15241
- if (e instanceof Distance) {
15242
- return false;
15243
- }
15244
- if (e instanceof Config) {
15110
+ if (e.featureConstant !== void 0) {
15245
15111
  return e.featureConstant;
15246
15112
  }
15247
15113
  let result = true;
@@ -15856,6 +15722,7 @@ function extractDistanceGeometry(value) {
15856
15722
  }
15857
15723
  class Distance {
15858
15724
  constructor(geojson) {
15725
+ this.featureConstant = false;
15859
15726
  this.type = NumberType;
15860
15727
  this.geojson = geojson;
15861
15728
  }
@@ -15923,6 +15790,132 @@ class Distance {
15923
15790
  }
15924
15791
  }
15925
15792
 
15793
+ const FQIDSeparator = "";
15794
+ function makeConfigFQID(id, ownScope, contextScope) {
15795
+ let fqid = id || "";
15796
+ if (ownScope) fqid = fqid ? fqid + FQIDSeparator + ownScope : ownScope;
15797
+ if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
15798
+ return fqid;
15799
+ }
15800
+ function coerceValue(type, value) {
15801
+ switch (type) {
15802
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15803
+ case "string":
15804
+ return toString(value);
15805
+ case "number":
15806
+ return +value;
15807
+ case "boolean":
15808
+ return !!value;
15809
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
15810
+ case "color":
15811
+ return Color.parse(value);
15812
+ case "formatted": {
15813
+ return Formatted.fromString(toString(value));
15814
+ }
15815
+ case "resolvedImage": {
15816
+ return ResolvedImage.build(toString(value));
15817
+ }
15818
+ }
15819
+ return value;
15820
+ }
15821
+ function clampToAllowedNumber(value, min, max, step) {
15822
+ if (step !== void 0) {
15823
+ value = step * Math.round(value / step);
15824
+ }
15825
+ if (min !== void 0 && value < min) {
15826
+ value = min;
15827
+ }
15828
+ if (max !== void 0 && value > max) {
15829
+ value = max;
15830
+ }
15831
+ return value;
15832
+ }
15833
+ class Config {
15834
+ constructor(type, key, scope, featureConstant = false) {
15835
+ this.type = type;
15836
+ this.key = key;
15837
+ this.scope = scope;
15838
+ this.featureConstant = featureConstant;
15839
+ }
15840
+ static parse(args, context) {
15841
+ let type = context.expectedType;
15842
+ type ?? (type = ValueType);
15843
+ if (args.length < 2 || args.length > 3) {
15844
+ return context.error(`Invalid number of arguments for 'config' expression.`);
15845
+ }
15846
+ const configKey = context.parse(args[1], 1);
15847
+ if (!(configKey instanceof Literal)) {
15848
+ return context.error(`Key name of 'config' expression must be a string literal.`);
15849
+ }
15850
+ let featureConstant = true;
15851
+ let configScopeValue;
15852
+ const configKeyValue = toString(configKey.value);
15853
+ if (args.length >= 3) {
15854
+ const configScope = context.parse(args[2], 2);
15855
+ if (!(configScope instanceof Literal)) {
15856
+ return context.error(`Scope of 'config' expression must be a string literal.`);
15857
+ }
15858
+ configScopeValue = toString(configScope.value);
15859
+ }
15860
+ if (context.options) {
15861
+ const fqid = makeConfigFQID(configKeyValue, configScopeValue, context._scope);
15862
+ const config = context.options.get(fqid);
15863
+ if (config) {
15864
+ featureConstant = isFeatureConstant(config.value || config.default);
15865
+ }
15866
+ }
15867
+ return new Config(type, configKeyValue, configScopeValue, featureConstant);
15868
+ }
15869
+ evaluate(ctx) {
15870
+ const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
15871
+ const config = ctx.getConfig(fqid);
15872
+ if (!config) return null;
15873
+ const { type, value, values, minValue, maxValue, stepValue } = config;
15874
+ const defaultValue = config.default.evaluate(ctx);
15875
+ let result = defaultValue;
15876
+ if (value) {
15877
+ const originalScope = ctx.scope;
15878
+ const scope = originalScope || "";
15879
+ const sep = scope.indexOf(FQIDSeparator);
15880
+ ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
15881
+ result = value.evaluate(ctx);
15882
+ ctx.scope = originalScope;
15883
+ }
15884
+ if (type) {
15885
+ result = coerceValue(type, result);
15886
+ }
15887
+ if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
15888
+ if (typeof result === "number") {
15889
+ result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
15890
+ } else if (Array.isArray(result)) {
15891
+ result = result.map((item) => typeof item === "number" ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
15892
+ }
15893
+ }
15894
+ if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
15895
+ result = defaultValue;
15896
+ if (type) {
15897
+ result = coerceValue(type, result);
15898
+ }
15899
+ }
15900
+ if (type && type !== this.type || result !== void 0 && !typeEquals(typeOf(result), this.type)) {
15901
+ result = coerceValue(this.type.kind, result);
15902
+ }
15903
+ return result;
15904
+ }
15905
+ eachChild() {
15906
+ }
15907
+ outputDefined() {
15908
+ return false;
15909
+ }
15910
+ serialize() {
15911
+ const res = ["config", this.key];
15912
+ if (this.scope) {
15913
+ res.push(this.scope);
15914
+ }
15915
+ return res;
15916
+ }
15917
+ }
15918
+
15926
15919
  class Var {
15927
15920
  constructor(name, boundExpression) {
15928
15921
  this.type = boundExpression.type;
@@ -15938,7 +15931,6 @@ class Var {
15938
15931
  }
15939
15932
  return new Var(name, context.scope.get(name));
15940
15933
  }
15941
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15942
15934
  evaluate(ctx) {
15943
15935
  return this.boundExpression.evaluate(ctx);
15944
15936
  }
@@ -16250,7 +16242,6 @@ class Step {
16250
16242
  }
16251
16243
  return new Step(outputType, input, stops);
16252
16244
  }
16253
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16254
16245
  evaluate(ctx) {
16255
16246
  const labels = this.labels;
16256
16247
  const outputs = this.outputs;
@@ -16635,7 +16626,6 @@ class Coalesce {
16635
16626
  const needsAnnotation = expectedType && parsedArgs.some((arg) => checkSubtype(expectedType, arg.type));
16636
16627
  return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
16637
16628
  }
16638
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16639
16629
  evaluate(ctx) {
16640
16630
  let result = null;
16641
16631
  let argCount = 0;
@@ -16678,7 +16668,6 @@ class Let {
16678
16668
  this.bindings = [].concat(bindings);
16679
16669
  this.result = result;
16680
16670
  }
16681
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16682
16671
  evaluate(ctx) {
16683
16672
  return this.result.evaluate(ctx);
16684
16673
  }
@@ -16872,7 +16861,6 @@ class Match {
16872
16861
  }
16873
16862
  return new Match(inputType, outputType, input, cases, outputs, otherwise);
16874
16863
  }
16875
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16876
16864
  evaluate(ctx) {
16877
16865
  const input = this.input.evaluate(ctx);
16878
16866
  const output = typeEquals(typeOf(input), this.inputType) && this.outputs[this.cases[input]] || this.otherwise;
@@ -16946,7 +16934,6 @@ class Case {
16946
16934
  if (!otherwise) return null;
16947
16935
  return new Case(outputType, branches, otherwise);
16948
16936
  }
16949
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16950
16937
  evaluate(ctx) {
16951
16938
  for (const [test, expression] of this.branches) {
16952
16939
  if (test.evaluate(ctx)) {
@@ -17001,7 +16988,6 @@ class Slice {
17001
16988
  return new Slice(input.type, input, beginIndex);
17002
16989
  }
17003
16990
  }
17004
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17005
16991
  evaluate(ctx) {
17006
16992
  const input = this.input.evaluate(ctx);
17007
16993
  const beginIndex = this.beginIndex.evaluate(ctx);
@@ -17363,22 +17349,22 @@ const expressions = Object.assign(/* @__PURE__ */ Object.create(null), {
17363
17349
  "config": Config
17364
17350
  });
17365
17351
  function rgba(ctx, [r, g, b, a]) {
17366
- r = r.evaluate(ctx);
17367
- g = g.evaluate(ctx);
17368
- b = b.evaluate(ctx);
17352
+ const red = r.evaluate(ctx);
17353
+ const green = g.evaluate(ctx);
17354
+ const blue = b.evaluate(ctx);
17369
17355
  const alpha = a ? a.evaluate(ctx) : 1;
17370
- const error = validateRGBA(r, g, b, alpha);
17356
+ const error = validateRGBA(red, green, blue, alpha);
17371
17357
  if (error) throw new RuntimeError(error);
17372
- return new Color(r / 255, g / 255, b / 255, alpha);
17358
+ return new Color(red / 255, green / 255, blue / 255, alpha);
17373
17359
  }
17374
17360
  function hsla(ctx, [h, s, l, a]) {
17375
- h = h.evaluate(ctx);
17376
- s = s.evaluate(ctx);
17377
- l = l.evaluate(ctx);
17361
+ const hValue = h.evaluate(ctx);
17362
+ const sValue = s.evaluate(ctx);
17363
+ const lValue = l.evaluate(ctx);
17378
17364
  const alpha = a ? a.evaluate(ctx) : 1;
17379
- const error = validateHSLA(h, s, l, alpha);
17365
+ const error = validateHSLA(hValue, sValue, lValue, alpha);
17380
17366
  if (error) throw new RuntimeError(error);
17381
- const hue = h % 360 / 360, sat = s / 100, lum = l / 100;
17367
+ const hue = hValue % 360 / 360, sat = sValue / 100, lum = lValue / 100;
17382
17368
  const m2 = lum <= 0.5 ? lum * (sat + 1) : lum + sat - lum * sat;
17383
17369
  const m1 = lum * 2 - m2;
17384
17370
  return new Color(hueToByte(m1, m2, hue + 1 / 3), hueToByte(m1, m2, hue), hueToByte(m1, m2, hue - 1 / 3), alpha);
@@ -18835,7 +18821,6 @@ ${JSON.stringify(filterExp, null, 2)}
18835
18821
  return {
18836
18822
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18837
18823
  filter: filterFunc,
18838
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18839
18824
  dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : void 0,
18840
18825
  needGeometry,
18841
18826
  needFeature: !!needFeature
@@ -20043,12 +20028,10 @@ function validateExpression(options) {
20043
20028
  });
20044
20029
  }
20045
20030
  const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
20046
- if (options.expressionContext === "property" && options.propertyKey === "text-font" && // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
20047
- !expressionObj.outputDefined()) {
20031
+ if (options.expressionContext === "property" && options.propertyKey === "text-font" && !expressionObj.outputDefined()) {
20048
20032
  return [new ValidationError(options.key, options.value, `Invalid data expression for "${options.propertyKey}". Output values must be contained as literals within the expression.`)];
20049
20033
  }
20050
- if (options.expressionContext === "property" && options.propertyType === "layout" && // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
20051
- !isStateConstant(expressionObj)) {
20034
+ if (options.expressionContext === "property" && options.propertyType === "layout" && !isStateConstant(expressionObj)) {
20052
20035
  return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with layout properties.')];
20053
20036
  }
20054
20037
  if (options.expressionContext === "filter") {