@mapbox/mapbox-gl-style-spec 14.11.0 → 14.12.0-beta.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.
@@ -73,7 +73,7 @@ class CompoundExpression implements Expression {
73
73
 
74
74
  const overloadParams = [];
75
75
 
76
- let signatureContext: ParsingContext = (null as any);
76
+ let signatureContext: ParsingContext = null;
77
77
 
78
78
  let overloadIndex = -1;
79
79
 
@@ -21,7 +21,7 @@ class Coalesce implements Expression {
21
21
  // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Coalesce'.
22
22
  return context.error("Expectected at least one argument.");
23
23
  }
24
- let outputType: Type = (null as any);
24
+ let outputType: Type = null;
25
25
  const expectedType = context.expectedType;
26
26
  if (expectedType && expectedType.kind !== 'value') {
27
27
  outputType = expectedType;
@@ -46,7 +46,7 @@ class Coalesce implements Expression {
46
46
 
47
47
  return needsAnnotation ?
48
48
  new Coalesce(ValueType, parsedArgs) :
49
- new Coalesce((outputType as any), parsedArgs);
49
+ new Coalesce(outputType, parsedArgs);
50
50
  }
51
51
 
52
52
  evaluate(ctx: EvaluationContext): any {
@@ -101,7 +101,7 @@ class Config implements Expression {
101
101
  if (typeof result === 'number') {
102
102
  result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
103
103
  } else if (Array.isArray(result)) {
104
- result = result.map((item) => typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
104
+ result = result.map((item) => (typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item));
105
105
  }
106
106
  }
107
107
 
@@ -47,6 +47,7 @@ import Distance from './distance';
47
47
  import {mulberry32} from '../../util/random';
48
48
 
49
49
  import type {Type} from '../types';
50
+ import type {Value} from '../values';
50
51
  import type EvaluationContext from '../evaluation_context';
51
52
  import type {Varargs} from '../compound_expression';
52
53
  import type {Expression, ExpressionRegistry} from '../expression';
@@ -242,7 +243,7 @@ CompoundExpression.register(expressions, {
242
243
  'properties': [
243
244
  ObjectType,
244
245
  [],
245
- (ctx) => ctx.properties()
246
+ (ctx) => ctx.properties() as Value
246
247
  ],
247
248
  'geometry-type': [
248
249
  StringType,
@@ -302,7 +303,7 @@ CompoundExpression.register(expressions, {
302
303
  'accumulated': [
303
304
  ValueType,
304
305
  [],
305
- (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated
306
+ (ctx) => (ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated)
306
307
  ],
307
308
  '+': [
308
309
  NumberType,
@@ -91,7 +91,7 @@ class Interpolate implements Expression {
91
91
 
92
92
  interpolation = {
93
93
  name: 'cubic-bezier',
94
- controlPoints: (controlPoints as any)
94
+ controlPoints
95
95
  };
96
96
  } else {
97
97
  return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);
@@ -110,7 +110,7 @@ class Interpolate implements Expression {
110
110
 
111
111
  const stops: Stops = [];
112
112
 
113
- let outputType: Type = (null as any);
113
+ let outputType: Type = null;
114
114
  if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {
115
115
  outputType = ColorType;
116
116
  } else if (context.expectedType && context.expectedType.kind !== 'value') {
@@ -138,7 +138,7 @@ class Match implements Expression {
138
138
  }
139
139
  }
140
140
 
141
- const coerceLabel = (label: number | string) => this.inputType.kind === 'number' ? Number(label) : label;
141
+ const coerceLabel = (label: number | string) => (this.inputType.kind === 'number' ? Number(label) : label);
142
142
 
143
143
  for (const [outputIndex, labels] of groupedByOutput) {
144
144
  if (labels.length === 1) {
@@ -40,7 +40,7 @@ class Step implements Expression {
40
40
 
41
41
  const stops: Stops = [];
42
42
 
43
- let outputType: Type = (null as any);
43
+ let outputType: Type = null;
44
44
  if (context.expectedType && context.expectedType.kind !== 'value') {
45
45
  outputType = context.expectedType;
46
46
  }
@@ -27,7 +27,7 @@ class EvaluationContext {
27
27
  };
28
28
 
29
29
  constructor(scope?: string | null, options?: ConfigOptions | null) {
30
- this.globals = (null as any);
30
+ this.globals = null;
31
31
  this.feature = null;
32
32
  this.featureState = null;
33
33
  this.formattedSection = null;
@@ -40,7 +40,7 @@ class EvaluationContext {
40
40
  this.options = options;
41
41
  }
42
42
 
43
- id(): number | null {
43
+ id(): string | number | null {
44
44
  return this.feature && this.feature.id !== undefined ? this.feature.id : null;
45
45
  }
46
46
 
@@ -56,9 +56,7 @@ class EvaluationContext {
56
56
  return this.canonical;
57
57
  }
58
58
 
59
- properties(): {
60
- [key: string]: any;
61
- } {
59
+ properties(): {readonly [key: string]: unknown} {
62
60
  return (this.feature && this.feature.properties) || {};
63
61
  }
64
62
 
@@ -39,13 +39,9 @@ import type {ImageId} from './types/image_id';
39
39
 
40
40
  export interface Feature {
41
41
  readonly type: 0 | 1 | 2 | 3 | 'Unknown' | 'Point' | 'LineString' | 'Polygon';
42
- readonly id?: number | null;
43
- readonly properties: {
44
- [_: string]: any;
45
- };
46
- readonly patterns?: {
47
- [_: string]: string;
48
- };
42
+ readonly id?: string | number | null;
43
+ readonly properties: Record<PropertyKey, unknown>;
44
+ readonly patterns?: Record<PropertyKey, string>;
49
45
  readonly geometry?: Array<Array<Point>>;
50
46
  }
51
47
 
@@ -135,7 +131,7 @@ export class StyleExpression {
135
131
  throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);
136
132
  }
137
133
  return val;
138
- } catch (e: any) {
134
+ } catch (e) {
139
135
  if (!this._warningHistory[e.message]) {
140
136
  this._warningHistory[e.message] = true;
141
137
  if (typeof console !== 'undefined') {
@@ -157,7 +157,7 @@ class ParsingContext {
157
157
  const ec = new EvaluationContext(this._scope, this.options);
158
158
  try {
159
159
  parsed = new Literal(parsed.type, parsed.evaluate(ec));
160
- } catch (e: any) {
160
+ } catch (e) {
161
161
  this.error(e.message);
162
162
  return null;
163
163
  }
@@ -51,9 +51,7 @@ export function validateHSLA(h: unknown, s: unknown, l: unknown, a?: unknown): s
51
51
  return null;
52
52
  }
53
53
 
54
- export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {
55
- readonly [key: string]: Value;
56
- };
54
+ export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {readonly [key: string]: Value};
57
55
 
58
56
  export function isValue(mixed: unknown): boolean {
59
57
  if (mixed === null) {
@@ -99,7 +99,7 @@ function createFilter(filter?: FilterSpecification, scope: string = "", options:
99
99
  let staticFilter = true;
100
100
  try {
101
101
  staticFilter = extractStaticFilter(filterExp);
102
- } catch (e: any) {
102
+ } catch (e) {
103
103
  console.warn(
104
104
  `Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
105
105
  This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
@@ -10,7 +10,7 @@ import type {StyleSpecification, FunctionSpecification} from '../types';
10
10
  * this will convert (a) "stop" functions, and (b) legacy filters to their
11
11
  * expression equivalents.
12
12
  */
13
- export default function(style: StyleSpecification): StyleSpecification {
13
+ export default function (style: StyleSpecification): StyleSpecification {
14
14
  const converted = [];
15
15
 
16
16
  eachLayer(style, (layer) => {
package/migrate/v8.ts CHANGED
@@ -34,7 +34,7 @@ function renameProperty(obj, from, to) {
34
34
  obj[to] = obj[from]; delete obj[from];
35
35
  }
36
36
 
37
- export default function(style) {
37
+ export default function (style) {
38
38
  style.version = 8;
39
39
 
40
40
  // Rename properties, reverse coordinates in source and layers
package/migrate/v9.ts CHANGED
@@ -8,7 +8,7 @@ function eachLayer(style, callback) {
8
8
  }
9
9
  }
10
10
 
11
- export default function(style) {
11
+ export default function (style) {
12
12
  style.version = 9;
13
13
 
14
14
  // remove user-specified refs
package/migrate.ts CHANGED
@@ -17,7 +17,7 @@ import migrateToExpressions from './migrate/expressions';
17
17
  * var style = fs.readFileSync('./style.json', 'utf8');
18
18
  * fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
19
19
  */
20
- export default function(style) {
20
+ export default function (style) {
21
21
  let migrated = false;
22
22
 
23
23
  if (style.version === 7) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/mapbox-gl-style-spec",
3
- "version": "14.11.0",
3
+ "version": "14.12.0-beta.1",
4
4
  "description": "a specification for mapbox gl styles",
5
5
  "author": "Mapbox",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
package/reference/v8.json CHANGED
@@ -1367,6 +1367,13 @@
1367
1367
  }
1368
1368
  }
1369
1369
  },
1370
+ "building": {
1371
+ "doc": "A procedural 3D building.",
1372
+ "sdk-support": {
1373
+ },
1374
+ "experimental": true,
1375
+ "private": true
1376
+ },
1370
1377
  "raster": {
1371
1378
  "doc": "Raster map textures such as satellite imagery.",
1372
1379
  "sdk-support": {
@@ -1508,6 +1515,7 @@
1508
1515
  "layout_circle",
1509
1516
  "layout_heatmap",
1510
1517
  "layout_fill-extrusion",
1518
+ "layout_building",
1511
1519
  "layout_symbol",
1512
1520
  "layout_raster",
1513
1521
  "layout_raster-particle",
@@ -1957,6 +1965,115 @@
1957
1965
  "property-type": "constant"
1958
1966
  }
1959
1967
  },
1968
+ "layout_building": {
1969
+ "visibility": {
1970
+ "type": "enum",
1971
+ "values": {
1972
+ "visible": {
1973
+ "doc": "The layer is shown."
1974
+ },
1975
+ "none": {
1976
+ "doc": "The layer is not shown."
1977
+ }
1978
+ },
1979
+ "default": "visible",
1980
+ "doc": "Whether this layer is displayed.",
1981
+ "sdk-support": {
1982
+ "basic functionality": {
1983
+ }
1984
+ },
1985
+ "expression": {
1986
+ "interpolated": false
1987
+ },
1988
+ "property-type": "constant"
1989
+ },
1990
+ "building-roof-shape": {
1991
+ "type": "enum",
1992
+ "values": {
1993
+ "flat": {
1994
+ "doc": "Use regular extruded buildings with flat roofs."
1995
+ },
1996
+ "hipped": {
1997
+ "doc": "Use hipped roof for the procedurally generated buildings."
1998
+ },
1999
+ "gabled": {
2000
+ "doc": "Use gabled roof for the procedurally generated buildings."
2001
+ },
2002
+ "parapet": {
2003
+ "doc": "Use parapet roof for the procedurally generated buildings."
2004
+ },
2005
+ "mansard": {
2006
+ "doc": "Use mansard roof for the procedurally generated buildings."
2007
+ },
2008
+ "skillion": {
2009
+ "doc": "Use skillion roof for the procedurally generated buildings."
2010
+ },
2011
+ "pyramidal": {
2012
+ "doc": "Use pyramidal roof for the procedurally generated buildings."
2013
+ }
2014
+ },
2015
+ "default": "flat",
2016
+ "doc": "Roof type to use for the procedural buildings.",
2017
+ "experimental": true,
2018
+ "private": true,
2019
+ "sdk-support": {
2020
+ "basic functionality": {
2021
+ },
2022
+ "data-driven styling": {
2023
+ }
2024
+ },
2025
+ "expression": {
2026
+ "interpolated": false,
2027
+ "parameters": [
2028
+ "feature"
2029
+ ]
2030
+ },
2031
+ "property-type": "data-driven"
2032
+ },
2033
+ "building-height": {
2034
+ "type": "number",
2035
+ "default": 0,
2036
+ "minimum": 0,
2037
+ "units": "meters",
2038
+ "doc": "The height of the procedural buildings.",
2039
+ "transition": true,
2040
+ "experimental": true,
2041
+ "private": true,
2042
+ "sdk-support": {
2043
+ "basic functionality": {
2044
+ },
2045
+ "data-driven styling": {
2046
+ }
2047
+ },
2048
+ "expression": {
2049
+ "interpolated": false
2050
+ },
2051
+ "property-type": "data-driven"
2052
+ },
2053
+ "building-base": {
2054
+ "type": "number",
2055
+ "default": 0,
2056
+ "minimum": 0,
2057
+ "units": "meters",
2058
+ "doc": "The height with which to extrude the base of this layer. Must be less than or equal to `building-height`.",
2059
+ "transition": true,
2060
+ "requires": [
2061
+ "building-height"
2062
+ ],
2063
+ "experimental": true,
2064
+ "private": true,
2065
+ "sdk-support": {
2066
+ "basic functionality": {
2067
+ },
2068
+ "data-driven styling": {
2069
+ }
2070
+ },
2071
+ "expression": {
2072
+ "interpolated": false
2073
+ },
2074
+ "property-type": "data-driven"
2075
+ }
2076
+ },
1960
2077
  "layout_line": {
1961
2078
  "line-cap": {
1962
2079
  "type": "enum",
@@ -3925,6 +4042,17 @@
3925
4042
  "parameters": ["zoom", "feature"]
3926
4043
  }
3927
4044
  },
4045
+ "filter_building": {
4046
+ "type": "boolean",
4047
+ "doc": "Expression which determines whether or not to display a Polygon. Building layer does NOT support dynamic filtering, meaning this expression can NOT use the `[\"pitch\"]` and `[\"distance-from-center\"]` expressions to reference the current state of the view.",
4048
+ "default": false,
4049
+ "transition": false,
4050
+ "property-type": "data-driven",
4051
+ "expression": {
4052
+ "interpolated": false,
4053
+ "parameters": ["zoom", "feature"]
4054
+ }
4055
+ },
3928
4056
  "filter_heatmap": {
3929
4057
  "type": "boolean",
3930
4058
  "doc": "Expression used to determine whether a point is being displayed or not. Heatmap layer does NOT support dynamic filtering, meaning this expression can NOT use the `[\"pitch\"]` and `[\"distance-from-center\"]` expressions to reference the current state of the view.",
@@ -6247,6 +6375,7 @@
6247
6375
  "paint_circle",
6248
6376
  "paint_heatmap",
6249
6377
  "paint_fill-extrusion",
6378
+ "paint_building",
6250
6379
  "paint_symbol",
6251
6380
  "paint_raster",
6252
6381
  "paint_raster-particle",
@@ -7235,6 +7364,189 @@
7235
7364
  "property-type": "data-constant"
7236
7365
  }
7237
7366
  },
7367
+ "paint_building": {
7368
+ "building-opacity": {
7369
+ "type": "number",
7370
+ "default": 1,
7371
+ "minimum": 0,
7372
+ "maximum": 1,
7373
+ "doc": "The opacity of the entire procedural buildings layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available.",
7374
+ "transition": true,
7375
+ "experimental": true,
7376
+ "private": true,
7377
+ "sdk-support": {
7378
+ "basic functionality": {
7379
+ }
7380
+ },
7381
+ "expression": {
7382
+ "interpolated": true,
7383
+ "parameters": [
7384
+ "zoom"
7385
+ ]
7386
+ },
7387
+ "property-type": "data-constant"
7388
+ },
7389
+ "building-ambient-occlusion-wall-intensity": {
7390
+ "property-type": "data-constant",
7391
+ "type": "number",
7392
+ "default": 0,
7393
+ "minimum": 0,
7394
+ "maximum": 1,
7395
+ "experimental": true,
7396
+ "private": true,
7397
+ "expression": {
7398
+ "interpolated": true,
7399
+ "parameters": [
7400
+ "zoom"
7401
+ ]
7402
+ },
7403
+ "transition": true,
7404
+ "doc": "Controls the intensity of shading concave angles between walls and building elements, such as facades and rooftop.",
7405
+ "sdk-support": {
7406
+ "basic functionality": {
7407
+ }
7408
+ }
7409
+ },
7410
+ "building-ambient-occlusion-ground-intensity": {
7411
+ "property-type": "data-constant",
7412
+ "type": "number",
7413
+ "default": 0,
7414
+ "minimum": 0,
7415
+ "maximum": 1,
7416
+ "experimental": true,
7417
+ "private": true,
7418
+ "expression": {
7419
+ "interpolated": true,
7420
+ "parameters": [
7421
+ "zoom"
7422
+ ]
7423
+ },
7424
+ "transition": true,
7425
+ "doc": "Controls the intensity of shading near ground",
7426
+ "sdk-support": {
7427
+ "basic functionality": {
7428
+ }
7429
+ }
7430
+ },
7431
+ "building-ambient-occlusion-ground-radius": {
7432
+ "property-type": "data-constant",
7433
+ "type": "number",
7434
+ "experimental": true,
7435
+ "private": true,
7436
+ "default": 3.0,
7437
+ "minimum": 0,
7438
+ "expression": {
7439
+ "interpolated": true,
7440
+ "parameters": [
7441
+ "zoom"
7442
+ ]
7443
+ },
7444
+ "transition": true,
7445
+ "doc": "The extent of the ambient occlusion effect on the ground beneath the procedural buildings in meters.",
7446
+ "sdk-support": {
7447
+ "basic functionality": {
7448
+ }
7449
+ }
7450
+ },
7451
+ "building-ambient-occlusion-ground-attenuation": {
7452
+ "property-type": "data-constant",
7453
+ "type": "number",
7454
+ "experimental": true,
7455
+ "private": true,
7456
+ "default": 0.69,
7457
+ "minimum": 0.0,
7458
+ "maximum": 1.0,
7459
+ "doc": "Provides a control to further fine-tune the look of the ambient occlusion on the ground beneath the procedural buildings. Lower values give the effect a more solid look while higher values make it smoother.",
7460
+ "transition": true,
7461
+ "expression": {
7462
+ "interpolated": true,
7463
+ "parameters": [
7464
+ "zoom"
7465
+ ]
7466
+ },
7467
+ "sdk-support": {
7468
+ "basic functionality": {
7469
+ }
7470
+ }
7471
+ },
7472
+ "building-vertical-scale": {
7473
+ "property-type": "data-constant",
7474
+ "type": "number",
7475
+ "experimental": true,
7476
+ "private": true,
7477
+ "default": 1.0,
7478
+ "minimum": 0.0,
7479
+ "doc": "A global multiplier that can be used to scale base and height of the procedural buildings.",
7480
+ "transition": true,
7481
+ "expression": {
7482
+ "interpolated": true,
7483
+ "parameters": [
7484
+ "zoom"
7485
+ ]
7486
+ },
7487
+ "sdk-support": {
7488
+ "basic functionality": {
7489
+ }
7490
+ }
7491
+ },
7492
+ "building-cast-shadows": {
7493
+ "type": "boolean",
7494
+ "default": true,
7495
+ "doc": "Enable/Disable shadow casting for this layer",
7496
+ "transition": false,
7497
+ "experimental": true,
7498
+ "private": true,
7499
+ "sdk-support": {
7500
+ "basic functionality": {
7501
+ }
7502
+ },
7503
+ "property-type": "data-constant"
7504
+ },
7505
+ "building-color": {
7506
+ "type": "color",
7507
+ "default": "rgba(193, 154, 127, 1)",
7508
+ "doc": "Color buildings. This can be styled using different building parts (e.g. windows, wall, roof, etc.). This won't be used if `building-roof-shape` has a value `flat`.",
7509
+ "experimental": true,
7510
+ "private": true,
7511
+ "sdk-support": {
7512
+ "basic functionality": {
7513
+ },
7514
+ "data-driven styling": {
7515
+ }
7516
+ },
7517
+ "expression": {
7518
+ "interpolated": true,
7519
+ "parameters": [
7520
+ "feature",
7521
+ "feature-state"
7522
+ ]
7523
+ },
7524
+ "property-type": "data-driven"
7525
+ },
7526
+ "building-emissive-strength": {
7527
+ "type": "number",
7528
+ "default": 0,
7529
+ "minimum": 0,
7530
+ "doc": "Controls the intensity of light emitted on the source features.",
7531
+ "experimental": true,
7532
+ "private": true,
7533
+ "sdk-support": {
7534
+ "basic functionality": {
7535
+ },
7536
+ "data-driven styling": {
7537
+ }
7538
+ },
7539
+ "expression": {
7540
+ "interpolated": true,
7541
+ "parameters": [
7542
+ "feature",
7543
+ "feature-state",
7544
+ "measure-light"
7545
+ ]
7546
+ },
7547
+ "property-type": "data-driven"
7548
+ }
7549
+ },
7238
7550
  "paint_line": {
7239
7551
  "line-opacity": {
7240
7552
  "type": "number",
package/test.js CHANGED
@@ -4,13 +4,11 @@ import fs from 'fs';
4
4
  import {execSync} from 'child_process';
5
5
  import {createRequire} from 'module';
6
6
 
7
- // @ts-expect-error - TS2345 - Argument of type 'Buffer' is not assignable to parameter of type 'string'.
8
- const packageJson = JSON.parse(fs.readFileSync('./package.json'));
7
+ const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
9
8
 
10
- process.on('unhandledRejection', (error) => {
9
+ process.on('unhandledRejection', (/** @type {Error} */ error) => {
11
10
  // don't log `error` directly, because errors from child_process.execSync
12
11
  // contain an (undocumented) `envPairs` with environment variable values
13
- // @ts-expect-error - TS2339 - Property 'message' does not exist on type 'unknown'.
14
12
  console.log(error.message || 'unhandledRejection');
15
13
  process.exit(1);
16
14
  });