@mapbox/mapbox-gl-style-spec 14.23.0 → 14.24.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.
Files changed (50) hide show
  1. package/composite.ts +5 -3
  2. package/diff.ts +37 -80
  3. package/dist/index.cjs +159 -113
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.es.js +159 -113
  7. package/dist/index.es.js.map +1 -1
  8. package/error/parsing_error.ts +3 -1
  9. package/expression/compound_expression.ts +11 -4
  10. package/expression/definitions/assertion.ts +2 -3
  11. package/expression/definitions/case.ts +1 -1
  12. package/expression/definitions/coercion.ts +4 -4
  13. package/expression/definitions/format.ts +1 -1
  14. package/expression/definitions/image.ts +2 -2
  15. package/expression/definitions/in.ts +1 -1
  16. package/expression/definitions/index.ts +7 -8
  17. package/expression/definitions/interpolate.ts +1 -1
  18. package/expression/definitions/let.ts +4 -2
  19. package/expression/definitions/match.ts +1 -1
  20. package/expression/definitions/step.ts +1 -1
  21. package/expression/is_constant.ts +2 -2
  22. package/expression/parsing_context.ts +18 -4
  23. package/expression/stops.ts +2 -1
  24. package/expression/types/image_variant.ts +5 -3
  25. package/feature_filter/index.ts +7 -30
  26. package/function/index.ts +7 -6
  27. package/migrate/v9.ts +1 -1
  28. package/package.json +1 -1
  29. package/reference/v8.json +20 -0
  30. package/types.ts +5 -1
  31. package/util/color.ts +2 -7
  32. package/util/geometry_util.ts +3 -8
  33. package/util/interpolate.ts +2 -3
  34. package/util/lerp.ts +3 -0
  35. package/util/properties.ts +4 -1
  36. package/validate/validate_enum.ts +2 -2
  37. package/validate/validate_fog.ts +3 -2
  38. package/validate/validate_function.ts +2 -2
  39. package/validate/validate_glyphs_url.ts +2 -2
  40. package/validate/validate_layer.ts +6 -5
  41. package/validate/validate_light.ts +3 -2
  42. package/validate/validate_lights.ts +3 -2
  43. package/validate/validate_model.ts +1 -1
  44. package/validate/validate_object.ts +1 -3
  45. package/validate/validate_property.ts +7 -5
  46. package/validate/validate_rain.ts +2 -1
  47. package/validate/validate_snow.ts +2 -1
  48. package/validate/validate_style.ts +1 -0
  49. package/validate/validate_terrain.ts +3 -2
  50. package/validate_mapbox_api_supported.ts +9 -8
package/dist/index.cjs CHANGED
@@ -8184,6 +8184,26 @@
8184
8184
  ]
8185
8185
  },
8186
8186
  "property-type": "data-constant"
8187
+ },
8188
+ "line-blend-additive-clamp": {
8189
+ type: "number",
8190
+ "default": 0,
8191
+ minimum: 0,
8192
+ doc: "Controls the brightness of lines in additive blend mode. When set to 0 (the default), brightness is adjusted automatically based on the density of lines visible on screen. Increase this value if the lines appear too bright, or decrease it if they appear too faint.",
8193
+ experimental: true,
8194
+ "private": true,
8195
+ "sdk-support": {
8196
+ "basic functionality": {
8197
+ js: "3.21.0"
8198
+ }
8199
+ },
8200
+ expression: {
8201
+ interpolated: true,
8202
+ parameters: [
8203
+ "zoom"
8204
+ ]
8205
+ },
8206
+ "property-type": "data-constant"
8187
8207
  }
8188
8208
  };
8189
8209
  var paint_circle = {
@@ -13553,21 +13573,6 @@
13553
13573
  function number(a, b, t) {
13554
13574
  return a * (1 - t) + b * t;
13555
13575
  }
13556
- function color(from, to, t) {
13557
- return new Color(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
13558
- }
13559
- function array(from, to, t) {
13560
- return from.map((d, i) => {
13561
- return number(d, to[i], t);
13562
- });
13563
- }
13564
-
13565
- var interpolate$1 = /*#__PURE__*/Object.freeze({
13566
- __proto__: null,
13567
- array: array,
13568
- color: color,
13569
- number: number
13570
- });
13571
13576
 
13572
13577
  class Color {
13573
13578
  constructor(r, g, b, a = 1) {
@@ -13607,12 +13612,7 @@
13607
13612
  * translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
13608
13613
  */
13609
13614
  toString() {
13610
- const [r, g, b, a] = [
13611
- this.r,
13612
- this.g,
13613
- this.b,
13614
- this.a
13615
- ];
13615
+ const {r, g, b, a} = this;
13616
13616
  return `rgba(${ Math.round(r * 255) },${ Math.round(g * 255) },${ Math.round(b * 255) },${ a })`;
13617
13617
  }
13618
13618
  toNonPremultipliedRenderColor(lut) {
@@ -13939,7 +13939,10 @@
13939
13939
  return JSON.stringify(this);
13940
13940
  }
13941
13941
  static parse(str) {
13942
- let id, params, sx, sy;
13942
+ let id;
13943
+ let params;
13944
+ let sx;
13945
+ let sy;
13943
13946
  try {
13944
13947
  ({id, params, sx, sy} = JSON.parse(str) || {});
13945
13948
  } catch (e) {
@@ -14321,7 +14324,7 @@
14321
14324
  if (!textColor)
14322
14325
  return null;
14323
14326
  }
14324
- const lastExpression = sections[sections.length - 1];
14327
+ const lastExpression = sections.at(-1);
14325
14328
  lastExpression.scale = scale;
14326
14329
  lastExpression.font = font;
14327
14330
  lastExpression.textColor = textColor;
@@ -14463,7 +14466,7 @@
14463
14466
  }
14464
14467
  parsedParams[key] = value;
14465
14468
  }
14466
- imageExpression[imageExpression.length - 1].options.params = parsedParams;
14469
+ imageExpression.at(-1).options.params = parsedParams;
14467
14470
  }
14468
14471
  if (iconset) {
14469
14472
  if (typeof iconset !== 'object' || iconset.constructor !== Object) {
@@ -14474,7 +14477,7 @@
14474
14477
  optionsContext.error(`Image options "iconset" should have an "id" property`);
14475
14478
  return false;
14476
14479
  }
14477
- imageExpression[imageExpression.length - 1].options.iconset = iconset;
14480
+ imageExpression.at(-1).options.iconset = iconset;
14478
14481
  }
14479
14482
  nextArgId++;
14480
14483
  return true;
@@ -14880,7 +14883,11 @@
14880
14883
  continue;
14881
14884
  overloadParams.push(params);
14882
14885
  overloadIndex++;
14883
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, void 0, context._scope, context.options, context.iconImageUseTheme);
14886
+ if (signatureContext === null) {
14887
+ signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, [], context._scope, context.options, context.iconImageUseTheme);
14888
+ } else {
14889
+ signatureContext.errors.length = 0;
14890
+ }
14884
14891
  const parsedArgs = [];
14885
14892
  let argParseFailed = false;
14886
14893
  for (let i = 1; i < args.length; i++) {
@@ -14905,7 +14912,7 @@
14905
14912
  for (let i = 0; i < parsedArgs.length; i++) {
14906
14913
  const expected = Array.isArray(params) ? params[i] : params.type;
14907
14914
  const arg = parsedArgs[i];
14908
- signatureContext.concat(i + 1).checkSubtype(expected, arg.type);
14915
+ signatureContext.checkSubtype(expected, arg.type, i + 1);
14909
14916
  }
14910
14917
  if (signatureContext.errors.length === 0) {
14911
14918
  return new CompoundExpression(op, type, evaluate, parsedArgs, overloadIndex);
@@ -15879,7 +15886,7 @@
15879
15886
  const d = this.distance(p0, p1);
15880
15887
  sum += d;
15881
15888
  if (sum > dist)
15882
- return interpolate(p0, p1, (dist - (sum - d)) / d);
15889
+ return interpolate$1(p0, p1, (dist - (sum - d)) / d);
15883
15890
  }
15884
15891
  return line[line.length - 1];
15885
15892
  }
@@ -16018,10 +16025,10 @@
16018
16025
  const d = this.distance(p0, p1);
16019
16026
  sum += d;
16020
16027
  if (sum > start && slice.length === 0) {
16021
- slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
16028
+ slice.push(interpolate$1(p0, p1, (start - (sum - d)) / d));
16022
16029
  }
16023
16030
  if (sum >= stop) {
16024
- slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
16031
+ slice.push(interpolate$1(p0, p1, (stop - (sum - d)) / d));
16025
16032
  return slice;
16026
16033
  }
16027
16034
  if (sum > start)
@@ -16097,7 +16104,7 @@
16097
16104
  * @param {number} t
16098
16105
  * @returns {[number, number]}
16099
16106
  */
16100
- function interpolate(a, b, t) {
16107
+ function interpolate$1(a, b, t) {
16101
16108
  const dx = wrap(b[0] - a[0]);
16102
16109
  const dy = b[1] - a[1];
16103
16110
  return [
@@ -16791,7 +16798,7 @@
16791
16798
  return false;
16792
16799
  } else if (e.name === 'properties' || e.name === 'geometry-type' || e.name === 'id') {
16793
16800
  return false;
16794
- } else if (/^filter-/.test(e.name)) {
16801
+ } else if (e.name.startsWith('filter-')) {
16795
16802
  return false;
16796
16803
  }
16797
16804
  }
@@ -16827,7 +16834,7 @@
16827
16834
  return result;
16828
16835
  }
16829
16836
  function isGlobalPropertyConstant(e, properties) {
16830
- if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {
16837
+ if (e instanceof CompoundExpression && properties.includes(e.name)) {
16831
16838
  return false;
16832
16839
  }
16833
16840
  let result = true;
@@ -17007,12 +17014,6 @@
17007
17014
  constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options, iconImageUseTheme) {
17008
17015
  this.registry = registry;
17009
17016
  this.path = path;
17010
- this.key = path.map(part => {
17011
- if (typeof part === 'string') {
17012
- return `['${ part }']`;
17013
- }
17014
- return `[${ part }]`;
17015
- }).join('');
17016
17017
  this.scope = scope;
17017
17018
  this.errors = errors;
17018
17019
  this.expectedType = expectedType;
@@ -17020,6 +17021,18 @@
17020
17021
  this.options = options;
17021
17022
  this.iconImageUseTheme = iconImageUseTheme;
17022
17023
  }
17024
+ get key() {
17025
+ if (this._key === void 0) {
17026
+ const path = this.path;
17027
+ let key = '';
17028
+ for (let i = 0; i < path.length; i++) {
17029
+ const part = path[i];
17030
+ key += typeof part === 'string' ? `['${ part }']` : `[${ part }]`;
17031
+ }
17032
+ this._key = key;
17033
+ }
17034
+ return this._key;
17035
+ }
17023
17036
  /**
17024
17037
  * @param expr the JSON expression to parse
17025
17038
  * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed
@@ -17132,10 +17145,10 @@
17132
17145
  * Returns null if `t` is a subtype of `expected`; otherwise returns an
17133
17146
  * error message and also pushes it to `this.errors`.
17134
17147
  */
17135
- checkSubtype(expected, t) {
17148
+ checkSubtype(expected, t, index) {
17136
17149
  const error = checkSubtype(expected, t);
17137
17150
  if (error)
17138
- this.error(error);
17151
+ this.error(error, ...typeof index === 'number' ? [index] : []);
17139
17152
  return error;
17140
17153
  }
17141
17154
  }
@@ -17187,7 +17200,8 @@
17187
17200
  let lowerIndex = 0;
17188
17201
  let upperIndex = lastIndex;
17189
17202
  let currentIndex = 0;
17190
- let currentValue, nextValue;
17203
+ let currentValue;
17204
+ let nextValue;
17191
17205
  while (lowerIndex <= upperIndex) {
17192
17206
  currentIndex = Math.floor((lowerIndex + upperIndex) / 2);
17193
17207
  currentValue = stops[currentIndex];
@@ -17240,7 +17254,7 @@
17240
17254
  if (typeof label !== 'number') {
17241
17255
  return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
17242
17256
  }
17243
- if (stops.length && stops[stops.length - 1][0] >= label) {
17257
+ if (stops.length && stops.at(-1)[0] >= label) {
17244
17258
  return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey);
17245
17259
  }
17246
17260
  const parsed = context.parse(value, valueKey, outputType);
@@ -17372,6 +17386,22 @@
17372
17386
  var unitbezierExports = requireUnitbezier();
17373
17387
  var UnitBezier = /*@__PURE__*/getDefaultExportFromCjs(unitbezierExports);
17374
17388
 
17389
+ function color(from, to, t) {
17390
+ return new Color(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
17391
+ }
17392
+ function array(from, to, t) {
17393
+ return from.map((d, i) => {
17394
+ return number(d, to[i], t);
17395
+ });
17396
+ }
17397
+
17398
+ var interpolate = /*#__PURE__*/Object.freeze({
17399
+ __proto__: null,
17400
+ array: array,
17401
+ color: color,
17402
+ number: number
17403
+ });
17404
+
17375
17405
  const Xn = 0.95047, Yn = 1, Zn = 1.08883, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
17376
17406
  function xyz2lab(t) {
17377
17407
  return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
@@ -17536,7 +17566,7 @@
17536
17566
  if (typeof label !== 'number') {
17537
17567
  return context.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
17538
17568
  }
17539
- if (stops.length && stops[stops.length - 1][0] >= label) {
17569
+ if (stops.length && stops.at(-1)[0] >= label) {
17540
17570
  return context.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', labelKey);
17541
17571
  }
17542
17572
  const parsed = context.parse(value, valueKey, outputType);
@@ -17574,7 +17604,7 @@
17574
17604
  const outputLower = outputs[index].evaluate(ctx);
17575
17605
  const outputUpper = outputs[index + 1].evaluate(ctx);
17576
17606
  if (this.operator === 'interpolate') {
17577
- return interpolate$1[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
17607
+ return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
17578
17608
  } else if (this.operator === 'interpolate-hcl') {
17579
17609
  return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
17580
17610
  } else {
@@ -17695,6 +17725,7 @@
17695
17725
  }
17696
17726
  }
17697
17727
 
17728
+ const INVALID_VAR_CHAR_RE = /[^a-zA-Z0-9_]/;
17698
17729
  class Let {
17699
17730
  constructor(bindings, result) {
17700
17731
  this.type = result.type;
@@ -17720,7 +17751,7 @@
17720
17751
  if (typeof name !== 'string') {
17721
17752
  return context.error(`Expected string, but found ${ typeof name } instead.`, i);
17722
17753
  }
17723
- if (/[^a-zA-Z0-9_]/.test(name)) {
17754
+ if (INVALID_VAR_CHAR_RE.test(name)) {
17724
17755
  return context.error(`Variable names must contain only alphanumeric characters or '_'.`, i);
17725
17756
  }
17726
17757
  const value = context.parse(args[i + 1], i + 1);
@@ -17731,7 +17762,7 @@
17731
17762
  value
17732
17763
  ]);
17733
17764
  }
17734
- const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);
17765
+ const result = context.parse(args.at(-1), args.length - 1, context.expectedType, bindings);
17735
17766
  if (!result)
17736
17767
  return null;
17737
17768
  return new Let(bindings, result);
@@ -17895,7 +17926,7 @@
17895
17926
  ])) {
17896
17927
  throw new RuntimeError(`Expected second argument to be of type array or string, but found ${ toString$1(typeOf(haystack)) } instead.`);
17897
17928
  }
17898
- return haystack.indexOf(needle) >= 0;
17929
+ return haystack.includes(needle);
17899
17930
  }
17900
17931
  eachChild(fn) {
17901
17932
  fn(this.needle);
@@ -18057,7 +18088,7 @@
18057
18088
  const input = context.parse(args[1], 1, ValueType);
18058
18089
  if (!input)
18059
18090
  return null;
18060
- const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);
18091
+ const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
18061
18092
  if (!otherwise)
18062
18093
  return null;
18063
18094
  if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {
@@ -18146,7 +18177,7 @@
18146
18177
  ]);
18147
18178
  outputType = outputType || result.type;
18148
18179
  }
18149
- const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);
18180
+ const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
18150
18181
  if (!otherwise)
18151
18182
  return null;
18152
18183
  return new Case(outputType, branches, otherwise);
@@ -19183,14 +19214,14 @@
19183
19214
  'filter-type-in': [
19184
19215
  BooleanType,
19185
19216
  [array$1(StringType)],
19186
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
19187
- (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0
19217
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
19218
+ (ctx, [v]) => v.value.includes(ctx.geometryType())
19188
19219
  ],
19189
19220
  'filter-id-in': [
19190
19221
  BooleanType,
19191
19222
  [array$1(ValueType)],
19192
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
19193
- (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0
19223
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
19224
+ (ctx, [v]) => v.value.includes(ctx.id())
19194
19225
  ],
19195
19226
  'filter-in-small': [
19196
19227
  BooleanType,
@@ -19199,8 +19230,8 @@
19199
19230
  array$1(ValueType)
19200
19231
  ],
19201
19232
  // assumes v is an array literal
19202
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
19203
- (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0
19233
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
19234
+ (ctx, [k, v]) => v.value.includes(ctx.properties()[k.value])
19204
19235
  ],
19205
19236
  'filter-in-large': [
19206
19237
  BooleanType,
@@ -19371,8 +19402,10 @@
19371
19402
  };
19372
19403
  }
19373
19404
 
19405
+ const TRANSITION_KEY_RE = /^(.*)-transition$/;
19406
+ const USE_THEME_KEY_RE = /^(.*)-use-theme$/;
19374
19407
  function expressionHasParameter(expression, parameter) {
19375
- return !!expression && !!expression.parameters && expression.parameters.indexOf(parameter) > -1;
19408
+ return !!expression && !!expression.parameters && expression.parameters.includes(parameter);
19376
19409
  }
19377
19410
  function supportsPropertyExpression(spec) {
19378
19411
  return spec['property-type'] === 'data-driven';
@@ -19500,7 +19533,7 @@
19500
19533
  interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
19501
19534
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
19502
19535
  zoomStops: parameters.stops.map(s => s[0]),
19503
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
19536
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
19504
19537
  evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
19505
19538
  };
19506
19539
  } else {
@@ -19558,7 +19591,7 @@
19558
19591
  parameters.stops[index + 1][0]);
19559
19592
  const outputLower = parameters.stops[index][1];
19560
19593
  const outputUpper = parameters.stops[index + 1][1];
19561
- let interp = interpolate$1[propertySpec.type] || identityFunction;
19594
+ let interp = interpolate[propertySpec.type] || identityFunction;
19562
19595
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
19563
19596
  const colorspace = colorSpaces[parameters.colorSpace];
19564
19597
  interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
@@ -20289,13 +20322,13 @@ ${ JSON.stringify(filterExp, null, 2) }
20289
20322
  isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[i]);
20290
20323
  branches.push(filter[i + 1]);
20291
20324
  }
20292
- branches.push(filter[filter.length - 1]);
20325
+ branches.push(filter.at(-1));
20293
20326
  } else if (filter[0] === 'match') {
20294
20327
  isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
20295
20328
  for (let i = 2; i < filter.length - 1; i += 2) {
20296
20329
  branches.push(filter[i + 1]);
20297
20330
  }
20298
- branches.push(filter[filter.length - 1]);
20331
+ branches.push(filter.at(-1));
20299
20332
  } else if (filter[0] === 'step') {
20300
20333
  isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
20301
20334
  for (let i = 1; i < filter.length - 1; i += 2) {
@@ -20695,6 +20728,7 @@ ${ JSON.stringify(filterExp, null, 2) }
20695
20728
  return style;
20696
20729
  }
20697
20730
 
20731
+ const MAPBOX_URL_RE = /^mapbox:\/\/(.*)/;
20698
20732
  function composite (style) {
20699
20733
  const styleIDs = [];
20700
20734
  const sourceIDs = [];
@@ -20703,7 +20737,7 @@ ${ JSON.stringify(filterExp, null, 2) }
20703
20737
  const source = style.sources[id];
20704
20738
  if (source.type !== 'vector')
20705
20739
  continue;
20706
- const match = /^mapbox:\/\/(.*)/.exec(source.url);
20740
+ const match = MAPBOX_URL_RE.exec(source.url);
20707
20741
  if (!match)
20708
20742
  continue;
20709
20743
  styleIDs.push(id);
@@ -20720,10 +20754,10 @@ ${ JSON.stringify(filterExp, null, 2) }
20720
20754
  'url': `mapbox://${ compositeID }`
20721
20755
  };
20722
20756
  style.layers.forEach(layer => {
20723
- if (styleIDs.indexOf(layer.source) >= 0) {
20757
+ if (styleIDs.includes(layer.source)) {
20724
20758
  layer.source = compositeID;
20725
20759
  if ('source-layer' in layer) {
20726
- if (compositedSourceLayers.indexOf(layer['source-layer']) >= 0) {
20760
+ if (compositedSourceLayers.includes(layer['source-layer'])) {
20727
20761
  throw new Error('Conflicting source layer names');
20728
20762
  } else {
20729
20763
  compositedSourceLayers.push(layer['source-layer']);
@@ -20954,14 +20988,14 @@ ${ JSON.stringify(filterExp, null, 2) }
20954
20988
  function canUpdateGeoJSON(before, after, sourceId) {
20955
20989
  let prop;
20956
20990
  for (prop in before[sourceId]) {
20957
- if (!before[sourceId].hasOwnProperty(prop))
20991
+ if (!Object.hasOwn(before[sourceId], prop))
20958
20992
  continue;
20959
20993
  if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {
20960
20994
  return false;
20961
20995
  }
20962
20996
  }
20963
20997
  for (prop in after[sourceId]) {
20964
- if (!after[sourceId].hasOwnProperty(prop))
20998
+ if (!Object.hasOwn(after[sourceId], prop))
20965
20999
  continue;
20966
21000
  if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {
20967
21001
  return false;
@@ -20974,17 +21008,17 @@ ${ JSON.stringify(filterExp, null, 2) }
20974
21008
  after = after || {};
20975
21009
  let sourceId;
20976
21010
  for (sourceId in before) {
20977
- if (!before.hasOwnProperty(sourceId))
21011
+ if (!Object.hasOwn(before, sourceId))
20978
21012
  continue;
20979
- if (!after.hasOwnProperty(sourceId)) {
21013
+ if (!Object.hasOwn(after, sourceId)) {
20980
21014
  removeSource(sourceId, commands, sourcesRemoved);
20981
21015
  }
20982
21016
  }
20983
21017
  for (sourceId in after) {
20984
- if (!after.hasOwnProperty(sourceId))
21018
+ if (!Object.hasOwn(after, sourceId))
20985
21019
  continue;
20986
21020
  const source = after[sourceId];
20987
- if (!before.hasOwnProperty(sourceId)) {
21021
+ if (!Object.hasOwn(before, sourceId)) {
20988
21022
  addSource(sourceId, after, commands);
20989
21023
  } else if (!deepEqual(before[sourceId], source)) {
20990
21024
  if (before[sourceId].type === 'geojson' && source.type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {
@@ -21006,7 +21040,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21006
21040
  after = after || {};
21007
21041
  let prop;
21008
21042
  for (prop in before) {
21009
- if (!before.hasOwnProperty(prop))
21043
+ if (!Object.hasOwn(before, prop))
21010
21044
  continue;
21011
21045
  if (!deepEqual(before[prop], after[prop])) {
21012
21046
  commands.push({
@@ -21021,7 +21055,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21021
21055
  }
21022
21056
  }
21023
21057
  for (prop in after) {
21024
- if (!after.hasOwnProperty(prop) || before.hasOwnProperty(prop))
21058
+ if (!Object.hasOwn(after, prop) || Object.hasOwn(before, prop))
21025
21059
  continue;
21026
21060
  if (!deepEqual(before[prop], after[prop])) {
21027
21061
  commands.push({
@@ -21053,10 +21087,16 @@ ${ JSON.stringify(filterExp, null, 2) }
21053
21087
  const tracker = beforeOrder.slice();
21054
21088
  const clean = /* @__PURE__ */
21055
21089
  Object.create(null);
21056
- let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;
21090
+ let i;
21091
+ let d;
21092
+ let layerId;
21093
+ let beforeLayer;
21094
+ let afterLayer;
21095
+ let insertBeforeLayerId;
21096
+ let prop;
21057
21097
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
21058
21098
  layerId = beforeOrder[i];
21059
- if (!afterIndex.hasOwnProperty(layerId)) {
21099
+ if (!Object.hasOwn(afterIndex, layerId)) {
21060
21100
  commands.push({
21061
21101
  command: operations.removeLayer,
21062
21102
  args: [layerId]
@@ -21070,7 +21110,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21070
21110
  layerId = afterOrder[afterOrder.length - 1 - i];
21071
21111
  if (tracker[tracker.length - 1 - i] === layerId)
21072
21112
  continue;
21073
- if (beforeIndex.hasOwnProperty(layerId)) {
21113
+ if (Object.hasOwn(beforeIndex, layerId)) {
21074
21114
  commands.push({
21075
21115
  command: operations.removeLayer,
21076
21116
  args: [layerId]
@@ -21142,7 +21182,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21142
21182
  });
21143
21183
  }
21144
21184
  for (prop in beforeLayer) {
21145
- if (!beforeLayer.hasOwnProperty(prop))
21185
+ if (!Object.hasOwn(beforeLayer, prop))
21146
21186
  continue;
21147
21187
  if (prop === 'layout' || prop === 'paint' || prop === 'filter' || prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot')
21148
21188
  continue;
@@ -21160,7 +21200,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21160
21200
  }
21161
21201
  }
21162
21202
  for (prop in afterLayer) {
21163
- if (!afterLayer.hasOwnProperty(prop) || beforeLayer.hasOwnProperty(prop))
21203
+ if (!Object.hasOwn(afterLayer, prop) || Object.hasOwn(beforeLayer, prop))
21164
21204
  continue;
21165
21205
  if (prop === 'layout' || prop === 'paint' || prop === 'filter' || prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot')
21166
21206
  continue;
@@ -21187,10 +21227,13 @@ ${ JSON.stringify(filterExp, null, 2) }
21187
21227
  const beforeIndex = before.reduce(indexById, {});
21188
21228
  const afterIndex = after.reduce(indexById, {});
21189
21229
  const tracker = beforeOrder.slice();
21190
- let i, d, importId, insertBefore;
21230
+ let i;
21231
+ let d;
21232
+ let importId;
21233
+ let insertBefore;
21191
21234
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
21192
21235
  importId = beforeOrder[i];
21193
- if (!afterIndex.hasOwnProperty(importId)) {
21236
+ if (!Object.hasOwn(afterIndex, importId)) {
21194
21237
  commands.push({
21195
21238
  command: operations.removeImport,
21196
21239
  args: [importId]
@@ -21204,7 +21247,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21204
21247
  importId = afterOrder[afterOrder.length - 1 - i];
21205
21248
  if (tracker[tracker.length - 1 - i] === importId)
21206
21249
  continue;
21207
- if (beforeIndex.hasOwnProperty(importId)) {
21250
+ if (Object.hasOwn(beforeIndex, importId)) {
21208
21251
  commands.push({
21209
21252
  command: operations.removeImport,
21210
21253
  args: [importId]
@@ -21244,9 +21287,9 @@ ${ JSON.stringify(filterExp, null, 2) }
21244
21287
  after = after || {};
21245
21288
  let iconsetId;
21246
21289
  for (iconsetId in before) {
21247
- if (!before.hasOwnProperty(iconsetId))
21290
+ if (!Object.hasOwn(before, iconsetId))
21248
21291
  continue;
21249
- if (!after.hasOwnProperty(iconsetId)) {
21292
+ if (!Object.hasOwn(after, iconsetId)) {
21250
21293
  commands.push({
21251
21294
  command: operations.removeIconset,
21252
21295
  args: [iconsetId]
@@ -21254,10 +21297,10 @@ ${ JSON.stringify(filterExp, null, 2) }
21254
21297
  }
21255
21298
  }
21256
21299
  for (iconsetId in after) {
21257
- if (!after.hasOwnProperty(iconsetId))
21300
+ if (!Object.hasOwn(after, iconsetId))
21258
21301
  continue;
21259
21302
  const iconset = after[iconsetId];
21260
- if (!before.hasOwnProperty(iconsetId)) {
21303
+ if (!Object.hasOwn(before, iconsetId)) {
21261
21304
  commands.push({
21262
21305
  command: operations.addIconset,
21263
21306
  args: [
@@ -21447,11 +21490,12 @@ ${ JSON.stringify(filterExp, null, 2) }
21447
21490
  class ValidationWarning extends ValidationError {
21448
21491
  }
21449
21492
 
21493
+ const LINE_NUMBER_RE = /line (\d+)/;
21450
21494
  class ParsingError {
21451
21495
  constructor(error) {
21452
21496
  this.error = error;
21453
21497
  this.message = error.message;
21454
- const match = error.message.match(/line (\d+)/);
21498
+ const match = error.message.match(LINE_NUMBER_RE);
21455
21499
  this.line = match ? parseInt(match[1], 10) : 0;
21456
21500
  }
21457
21501
  }
@@ -21849,11 +21893,11 @@ ${ JSON.stringify(filterExp, null, 2) }
21849
21893
  const valueSpec = options.valueSpec;
21850
21894
  const errors = [];
21851
21895
  if (Array.isArray(valueSpec.values)) {
21852
- if (valueSpec.values.indexOf(unbundle(value)) === -1) {
21896
+ if (!valueSpec.values.includes(unbundle(value))) {
21853
21897
  errors.push(new ValidationError(key, value, `expected one of [${ valueSpec.values.join(', ') }], ${ JSON.stringify(value) } found`));
21854
21898
  }
21855
21899
  } else {
21856
- if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
21900
+ if (!Object.keys(valueSpec.values).includes(unbundle(value))) {
21857
21901
  errors.push(new ValidationError(key, value, `expected one of [${ Object.keys(valueSpec.values).join(', ') }], ${ JSON.stringify(value) } found`));
21858
21902
  }
21859
21903
  }
@@ -21955,6 +21999,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21955
21999
  return errors;
21956
22000
  }
21957
22001
 
22002
+ const TOKEN_PATTERN_RE = /^{([^}]+)}$/;
21958
22003
  function validateProperty(options, propertyType) {
21959
22004
  const key = options.key;
21960
22005
  const style = options.style;
@@ -21965,7 +22010,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21965
22010
  const layerSpec = styleSpec[`${ propertyType }_${ options.layerType }`];
21966
22011
  if (!layerSpec)
21967
22012
  return [];
21968
- const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
22013
+ const useThemeMatch = propertyKey.match(USE_THEME_KEY_RE);
21969
22014
  if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
21970
22015
  if (isExpression(deepUnbundle(value))) {
21971
22016
  const errors2 = [];
@@ -21998,7 +22043,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21998
22043
  styleSpec
21999
22044
  });
22000
22045
  }
22001
- const transitionMatch = propertyKey.match(/^(.*)-transition$/);
22046
+ const transitionMatch = propertyKey.match(TRANSITION_KEY_RE);
22002
22047
  if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {
22003
22048
  return validate({
22004
22049
  key,
@@ -22014,7 +22059,7 @@ ${ JSON.stringify(filterExp, null, 2) }
22014
22059
  return [new ValidationWarning(key, value, `unknown property "${ propertyKey }"`)];
22015
22060
  }
22016
22061
  let tokenMatch;
22017
- if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
22062
+ if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = TOKEN_PATTERN_RE.exec(value))) {
22018
22063
  const example = `\`{ "type": "identity", "property": ${ tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"' } }\``;
22019
22064
  return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax
22020
22065
  Use an identity property function instead: ${ example }.`)];
@@ -22027,7 +22072,7 @@ Use an identity property function instead: ${ example }.`)];
22027
22072
  if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {
22028
22073
  errors.push(new ValidationError(key, value, '"text-font" does not support identity functions'));
22029
22074
  }
22030
- } else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
22075
+ } else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && Object.hasOwn(layer.layout, 'model-id')) {
22031
22076
  if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
22032
22077
  const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
22033
22078
  const expressionValue = expression.value;
@@ -22195,8 +22240,10 @@ Use an identity property function instead: ${ example }.`)];
22195
22240
  'raster-particle'
22196
22241
  ].includes(type)) {
22197
22242
  errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type 'raster'.`));
22198
- } else if (type === 'line' && layer.paint && (layer.paint['line-gradient'] || layer.paint['line-trim-offset']) && (sourceType === 'geojson' && !source.lineMetrics)) {
22243
+ } else if (type === 'line' && layer.paint && layer.paint['line-gradient'] && (sourceType === 'geojson' && !source.lineMetrics)) {
22199
22244
  errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`));
22245
+ } else if (type === 'line' && layer.paint && layer.paint['line-trim-offset'] && (sourceType === 'geojson' && !source.lineMetrics)) {
22246
+ errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`));
22200
22247
  } else if (type === 'raster-particle' && sourceType !== 'raster-array') {
22201
22248
  errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a 'raster-array' source.`));
22202
22249
  }
@@ -22471,7 +22518,7 @@ Use an identity property function instead: ${ example }.`)];
22471
22518
  }
22472
22519
 
22473
22520
  function isValidUrl(str, allowRelativeUrls) {
22474
- const isRelative = str.indexOf('://') === -1;
22521
+ const isRelative = !str.includes('://');
22475
22522
  try {
22476
22523
  new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : void 0);
22477
22524
  return true;
@@ -22506,8 +22553,8 @@ Use an identity property function instead: ${ example }.`)];
22506
22553
  }
22507
22554
  let errors = [];
22508
22555
  for (const key in light) {
22509
- const transitionMatch = key.match(/^(.*)-transition$/);
22510
- const useThemeMatch = key.match(/^(.*)-use-theme$/);
22556
+ const transitionMatch = key.match(TRANSITION_KEY_RE);
22557
+ const useThemeMatch = key.match(USE_THEME_KEY_RE);
22511
22558
  if (useThemeMatch && lightSpec[useThemeMatch[1]]) {
22512
22559
  errors = errors.concat(validate({
22513
22560
  key,
@@ -22591,8 +22638,8 @@ Use an identity property function instead: ${ example }.`)];
22591
22638
  return errors;
22592
22639
  }
22593
22640
  for (const propertyKey in properties) {
22594
- const transitionMatch = propertyKey.match(/^(.*)-transition$/);
22595
- const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
22641
+ const transitionMatch = propertyKey.match(TRANSITION_KEY_RE);
22642
+ const useThemeMatch = propertyKey.match(USE_THEME_KEY_RE);
22596
22643
  if (useThemeMatch && lightPropertySpec[useThemeMatch[1]]) {
22597
22644
  errors = errors.concat(validate({
22598
22645
  key: key2,
@@ -22655,8 +22702,8 @@ Use an identity property function instead: ${ example }.`)];
22655
22702
  }
22656
22703
  let errors = [];
22657
22704
  for (const key2 in terrain) {
22658
- const transitionMatch = key2.match(/^(.*)-transition$/);
22659
- const useThemeMatch = key2.match(/^(.*)-use-theme$/);
22705
+ const transitionMatch = key2.match(TRANSITION_KEY_RE);
22706
+ const useThemeMatch = key2.match(USE_THEME_KEY_RE);
22660
22707
  if (useThemeMatch && terrainSpec[useThemeMatch[1]]) {
22661
22708
  errors = errors.concat(validate({
22662
22709
  key: key2,
@@ -22716,8 +22763,8 @@ Use an identity property function instead: ${ example }.`)];
22716
22763
  }
22717
22764
  let errors = [];
22718
22765
  for (const key in fog) {
22719
- const transitionMatch = key.match(/^(.*)-transition$/);
22720
- const useThemeMatch = key.match(/^(.*)-use-theme$/);
22766
+ const transitionMatch = key.match(TRANSITION_KEY_RE);
22767
+ const useThemeMatch = key.match(USE_THEME_KEY_RE);
22721
22768
  if (useThemeMatch && fogSpec[useThemeMatch[1]]) {
22722
22769
  errors = errors.concat(validate({
22723
22770
  key,
@@ -22906,7 +22953,6 @@ Use an identity property function instead: ${ example }.`)];
22906
22953
  errors = errors.concat(validateElement({
22907
22954
  key: (key ? `${ key }.` : key) + objectKey,
22908
22955
  value: object[objectKey],
22909
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
22910
22956
  valueSpec: elementSpec,
22911
22957
  style,
22912
22958
  styleSpec,
@@ -22934,10 +22980,10 @@ Use an identity property function instead: ${ example }.`)];
22934
22980
  if (errors.length)
22935
22981
  return errors;
22936
22982
  const str = value;
22937
- if (str.indexOf('{fontstack}') === -1) {
22983
+ if (!str.includes('{fontstack}')) {
22938
22984
  errors.push(new ValidationError(key, value, '"glyphs" url must include a "{fontstack}" token'));
22939
22985
  }
22940
- if (str.indexOf('{range}') === -1) {
22986
+ if (!str.includes('{range}')) {
22941
22987
  errors.push(new ValidationError(key, value, '"glyphs" url must include a "{range}" token'));
22942
22988
  }
22943
22989
  return errors;
@@ -22948,7 +22994,7 @@ Use an identity property function instead: ${ example }.`)];
22948
22994
  key: options.key || '',
22949
22995
  value: style,
22950
22996
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
22951
- valueSpec: Object.assign(styleSpec.$root, // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
22997
+ valueSpec: Object.assign({}, styleSpec.$root, // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
22952
22998
  { '*': { type: '*' } }),
22953
22999
  styleSpec,
22954
23000
  style,
@@ -23107,6 +23153,10 @@ Use an identity property function instead: ${ example }.`)];
23107
23153
  return validateStyle$1(s, styleSpec);
23108
23154
  }
23109
23155
 
23156
+ const MAPBOX_SOURCE_URL_RE = /^mapbox:\/\/([^/]*)$/;
23157
+ const MAPBOX_GLYPH_URL_RE = /^mapbox:\/\/fonts\/([^/]*)\/{fontstack}\/{range}.pbf$/;
23158
+ const MAPBOX_SPRITE_URL_RE = /^mapbox:\/\/sprites\/([^/]*)\/([^/]*)\/?([^/]*)?$/;
23159
+ const VISIBILITY_RE = /^(public|private)$/;
23110
23160
  const SUPPORTED_SPEC_VERSION = 8;
23111
23161
  const MAX_SOURCES_IN_STYLE = 15;
23112
23162
  function isValid(value, regex) {
@@ -23146,8 +23196,7 @@ Use an identity property function instead: ${ example }.`)];
23146
23196
  if (!acceptedSourceTypes.has(String(source.type))) {
23147
23197
  errors.push(new ValidationError(`sources[${ i }].type`, source.type, `Expected one of [${ Array.from(acceptedSourceTypes).join(', ') }]`));
23148
23198
  }
23149
- const sourceUrlPattern = /^mapbox:\/\/([^/]*)$/;
23150
- if (!('url' in source) || !isValid(source.url, sourceUrlPattern)) {
23199
+ if (!('url' in source) || !isValid(source.url, MAPBOX_SOURCE_URL_RE)) {
23151
23200
  errors.push(new ValidationError(`sources[${ i }].url`, source.url, 'Expected a valid Mapbox tileset url'));
23152
23201
  }
23153
23202
  return errors;
@@ -23219,16 +23268,13 @@ Use an identity property function instead: ${ example }.`)];
23219
23268
  if (style.version > SUPPORTED_SPEC_VERSION || style.version < SUPPORTED_SPEC_VERSION) {
23220
23269
  errors.push(new ValidationError('version', style.version, `Style version must be ${ SUPPORTED_SPEC_VERSION }`));
23221
23270
  }
23222
- const glyphUrlPattern = /^mapbox:\/\/fonts\/([^/]*)\/{fontstack}\/{range}.pbf$/;
23223
- if (!isValid(style.glyphs, glyphUrlPattern)) {
23271
+ if (!isValid(style.glyphs, MAPBOX_GLYPH_URL_RE)) {
23224
23272
  errors.push(new ValidationError('glyphs', style.glyphs, 'Styles must reference glyphs hosted by Mapbox'));
23225
23273
  }
23226
- const spriteUrlPattern = /^mapbox:\/\/sprites\/([^/]*)\/([^/]*)\/?([^/]*)?$/;
23227
- if (!isValid(style.sprite, spriteUrlPattern)) {
23274
+ if (!isValid(style.sprite, MAPBOX_SPRITE_URL_RE)) {
23228
23275
  errors.push(new ValidationError('sprite', style.sprite, 'Styles must reference sprites hosted by Mapbox'));
23229
23276
  }
23230
- const visibilityPattern = /^(public|private)$/;
23231
- if (!isValid(style.visibility, visibilityPattern)) {
23277
+ if (!isValid(style.visibility, VISIBILITY_RE)) {
23232
23278
  errors.push(new ValidationError('visibility', style.visibility, 'Style visibility must be public or private'));
23233
23279
  }
23234
23280
  if (style.protected !== void 0 && !isBoolean(style.protected)) {