@mapbox/mapbox-gl-style-spec 14.14.0-beta.2 → 14.14.0
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/composite.ts +5 -8
- package/dist/index.cjs +31 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -15
- package/dist/index.es.js +31 -9
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/distance.ts +2 -3
- package/expression/definitions/index.ts +4 -20
- package/expression/definitions/interpolate.ts +6 -9
- package/expression/definitions/within.ts +14 -15
- package/expression/index.ts +2 -4
- package/group_by_layout.ts +3 -6
- package/migrate.ts +6 -8
- package/package.json +1 -1
- package/read_style.ts +1 -2
- package/reference/v8.json +25 -0
- package/types.ts +34 -13
- package/util/geometry_util.ts +1 -2
- package/validate/validate.ts +5 -6
- package/validate/validate_array.ts +2 -2
- package/validate/validate_enum.ts +2 -2
- package/validate/validate_expression.ts +1 -2
- package/validate/validate_filter.ts +3 -4
- package/validate/validate_fog.ts +2 -5
- package/validate/validate_function.ts +6 -10
- package/validate/validate_iconset.ts +1 -2
- package/validate/validate_layer.ts +1 -2
- package/validate/validate_light.ts +1 -4
- package/validate/validate_lights.ts +1 -7
- package/validate/validate_model.ts +1 -4
- package/validate/validate_projection.ts +1 -2
- package/validate/validate_property.ts +2 -6
- package/validate/validate_rain.ts +1 -4
- package/validate/validate_snow.ts +1 -4
- package/validate/validate_source.ts +2 -3
- package/validate/validate_terrain.ts +1 -5
- package/validate_mapbox_api_supported.ts +2 -4
- package/validate_style.ts +1 -2
- package/visit.ts +2 -4
|
@@ -142,12 +142,11 @@ function getLngLatPoint(coord: Point, canonical: CanonicalTileID) {
|
|
|
142
142
|
return [lngFromMercatorX(x), latFromMercatorY(y)];
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID) {
|
|
146
|
-
const coords = [];
|
|
145
|
+
function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID): number[][] {
|
|
146
|
+
const coords: number[][] = [];
|
|
147
147
|
for (let i = 0; i < coordinates.length; ++i) {
|
|
148
148
|
coords.push(getLngLatPoint(coordinates[i], canonical));
|
|
149
149
|
}
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
151
150
|
return coords;
|
|
152
151
|
}
|
|
153
152
|
|
|
@@ -120,30 +120,16 @@ function hsla(ctx: EvaluationContext, [h, s, l, a]: Expression[]) {
|
|
|
120
120
|
return color;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function has(
|
|
124
|
-
key: string,
|
|
125
|
-
obj: {
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
-
[key: string]: any;
|
|
128
|
-
},
|
|
129
|
-
): boolean {
|
|
123
|
+
function has<T extends object>(key: keyof T, obj: T): boolean {
|
|
130
124
|
return key in obj;
|
|
131
125
|
}
|
|
132
126
|
|
|
133
|
-
function get(key:
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
-
[key: string]: any;
|
|
136
|
-
}) {
|
|
127
|
+
function get<T extends object>(key: keyof T, obj: T): T[keyof T] | null {
|
|
137
128
|
const v = obj[key];
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
139
129
|
return typeof v === 'undefined' ? null : v;
|
|
140
130
|
}
|
|
141
131
|
|
|
142
|
-
|
|
143
|
-
function binarySearch(v: any, a: {
|
|
144
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
[key: number]: any;
|
|
146
|
-
}, i: number, j: number) {
|
|
132
|
+
function binarySearch(v: unknown, a: Record<number, unknown>, i: number, j: number): boolean {
|
|
147
133
|
while (i <= j) {
|
|
148
134
|
const m = (i + j) >> 1;
|
|
149
135
|
if (a[m] === v)
|
|
@@ -237,7 +223,6 @@ CompoundExpression.register(expressions, {
|
|
|
237
223
|
overloads: [
|
|
238
224
|
[
|
|
239
225
|
[StringType],
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
241
226
|
(ctx, [key]) => get(key.evaluate(ctx), ctx.properties())
|
|
242
227
|
], [
|
|
243
228
|
[StringType, ObjectType],
|
|
@@ -249,8 +234,7 @@ CompoundExpression.register(expressions, {
|
|
|
249
234
|
'feature-state': [
|
|
250
235
|
ValueType,
|
|
251
236
|
[StringType],
|
|
252
|
-
|
|
253
|
-
(ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})
|
|
237
|
+
(ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {}) as Value
|
|
254
238
|
],
|
|
255
239
|
'properties': [
|
|
256
240
|
ObjectType,
|
|
@@ -157,20 +157,17 @@ class Interpolate implements Expression {
|
|
|
157
157
|
const outputs = this.outputs;
|
|
158
158
|
|
|
159
159
|
if (labels.length === 1) {
|
|
160
|
-
|
|
161
|
-
return outputs[0].evaluate(ctx);
|
|
160
|
+
return outputs[0].evaluate(ctx) as Color;
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
const value =
|
|
163
|
+
const value: number = this.input.evaluate(ctx);
|
|
165
164
|
if (value <= labels[0]) {
|
|
166
|
-
|
|
167
|
-
return outputs[0].evaluate(ctx);
|
|
165
|
+
return outputs[0].evaluate(ctx) as Color;
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
const stopCount = labels.length;
|
|
171
169
|
if (value >= labels[stopCount - 1]) {
|
|
172
|
-
|
|
173
|
-
return outputs[stopCount - 1].evaluate(ctx);
|
|
170
|
+
return outputs[stopCount - 1].evaluate(ctx) as Color;
|
|
174
171
|
}
|
|
175
172
|
|
|
176
173
|
const index = findStopLessThanOrEqualTo(labels, value);
|
|
@@ -178,8 +175,8 @@ class Interpolate implements Expression {
|
|
|
178
175
|
const upper = labels[index + 1];
|
|
179
176
|
const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);
|
|
180
177
|
|
|
181
|
-
const outputLower = outputs[index].evaluate(ctx);
|
|
182
|
-
const outputUpper = outputs[index + 1].evaluate(ctx);
|
|
178
|
+
const outputLower: Color = outputs[index].evaluate(ctx);
|
|
179
|
+
const outputUpper: Color = outputs[index + 1].evaluate(ctx);
|
|
183
180
|
|
|
184
181
|
if (this.operator === 'interpolate') {
|
|
185
182
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -2,11 +2,11 @@ import {isValue} from '../values';
|
|
|
2
2
|
import {BooleanType} from '../types';
|
|
3
3
|
import {updateBBox, boxWithinBox, pointWithinPolygon, segmentIntersectSegment} from '../../util/geometry_util';
|
|
4
4
|
|
|
5
|
+
import type Point from '@mapbox/point-geometry';
|
|
5
6
|
import type {Type} from '../types';
|
|
6
7
|
import type {Expression, SerializedExpression} from '../expression';
|
|
7
8
|
import type ParsingContext from '../parsing_context';
|
|
8
9
|
import type EvaluationContext from '../evaluation_context';
|
|
9
|
-
import type Point from '@mapbox/point-geometry';
|
|
10
10
|
import type {CanonicalTileID} from '../../types/tile_id';
|
|
11
11
|
import type {BBox} from '../../util/geometry_util';
|
|
12
12
|
|
|
@@ -74,10 +74,10 @@ function lineStringWithinPolygons(line: Array<GeoJSON.Position>, polygons: Array
|
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox, canonical: CanonicalTileID) {
|
|
78
|
-
const polygon = [];
|
|
77
|
+
function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox, canonical: CanonicalTileID): Array<Array<number[]>> {
|
|
78
|
+
const polygon: Array<Array<number[]>> = [];
|
|
79
79
|
for (let i = 0; i < coordinates.length; i++) {
|
|
80
|
-
const ring = [];
|
|
80
|
+
const ring: number[][] = [];
|
|
81
81
|
for (let j = 0; j < coordinates[i].length; j++) {
|
|
82
82
|
const coord = getTileCoordinates(coordinates[i][j], canonical);
|
|
83
83
|
updateBBox(bbox, coord);
|
|
@@ -85,17 +85,17 @@ function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox,
|
|
|
85
85
|
}
|
|
86
86
|
polygon.push(ring);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
return polygon;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function getTilePolygons(coordinates: Array<Array<Array<GeoJSON.Position>>>, bbox: BBox, canonical: CanonicalTileID) {
|
|
93
|
-
const polygons = [];
|
|
92
|
+
function getTilePolygons(coordinates: Array<Array<Array<GeoJSON.Position>>>, bbox: BBox, canonical: CanonicalTileID): Array<Array<Array<number[]>>> {
|
|
93
|
+
const polygons: Array<Array<Array<number[]>>> = [];
|
|
94
94
|
for (let i = 0; i < coordinates.length; i++) {
|
|
95
95
|
const polygon = getTilePolygon(coordinates[i], bbox, canonical);
|
|
96
96
|
polygons.push(polygon);
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
return polygons;
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -116,11 +116,10 @@ function resetBBox(bbox: BBox) {
|
|
|
116
116
|
bbox[2] = bbox[3] = -Infinity;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID) {
|
|
119
|
+
function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID): Array<number[]> {
|
|
120
120
|
const worldSize = Math.pow(2, canonical.z) * EXTENT;
|
|
121
121
|
const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
|
|
122
|
-
const tilePoints = [];
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
122
|
+
const tilePoints: Array<number[]> = [];
|
|
124
123
|
if (!geometry) return tilePoints;
|
|
125
124
|
for (const points of geometry) {
|
|
126
125
|
for (const point of points) {
|
|
@@ -129,11 +128,11 @@ function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBB
|
|
|
129
128
|
tilePoints.push(p);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
|
-
|
|
131
|
+
|
|
133
132
|
return tilePoints;
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID) {
|
|
135
|
+
function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox: BBox, polyBBox: Array<number>, canonical: CanonicalTileID): Array<Array<GeoJSON.Position>> {
|
|
137
136
|
const worldSize = Math.pow(2, canonical.z) * EXTENT;
|
|
138
137
|
const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
|
|
139
138
|
const tileLines: Array<Array<GeoJSON.Position>> = [];
|
|
@@ -158,7 +157,7 @@ function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox
|
|
|
158
157
|
return tileLines;
|
|
159
158
|
}
|
|
160
159
|
|
|
161
|
-
function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
|
|
160
|
+
function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons): boolean {
|
|
162
161
|
const pointBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
163
162
|
const polyBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
164
163
|
|
|
@@ -189,7 +188,7 @@ function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPo
|
|
|
189
188
|
return true;
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
function linesWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
|
|
191
|
+
function linesWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons): boolean {
|
|
193
192
|
const lineBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
194
193
|
const polyBBox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
195
194
|
|
package/expression/index.ts
CHANGED
|
@@ -355,8 +355,7 @@ export function createPropertyExpression(
|
|
|
355
355
|
): Result<StylePropertyExpression, Array<ParsingError>> {
|
|
356
356
|
expression = createExpression(expression, propertySpec, scope, options);
|
|
357
357
|
if (expression.result === 'error') {
|
|
358
|
-
|
|
359
|
-
return expression;
|
|
358
|
+
return expression as Result<StylePropertyExpression, Array<ParsingError>>;
|
|
360
359
|
}
|
|
361
360
|
|
|
362
361
|
const parsed = expression.value.expression;
|
|
@@ -476,7 +475,7 @@ export function normalizePropertyExpression<T>(
|
|
|
476
475
|
// expression (collectively referred to as a "curve"). The curve may be wrapped in one or more "let" or
|
|
477
476
|
// "coalesce" expressions.
|
|
478
477
|
function findZoomCurve(expression: Expression): Step | Interpolate | ParsingError | null {
|
|
479
|
-
let result = null;
|
|
478
|
+
let result: Step | Interpolate | ParsingError | null = null;
|
|
480
479
|
if (expression instanceof Let) {
|
|
481
480
|
result = findZoomCurve(expression.result);
|
|
482
481
|
|
|
@@ -508,7 +507,6 @@ function findZoomCurve(expression: Expression): Step | Interpolate | ParsingErro
|
|
|
508
507
|
}
|
|
509
508
|
});
|
|
510
509
|
|
|
511
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
512
510
|
return result;
|
|
513
511
|
}
|
|
514
512
|
|
package/group_by_layout.ts
CHANGED
|
@@ -2,8 +2,7 @@ import refProperties from './util/ref_properties';
|
|
|
2
2
|
|
|
3
3
|
import type {LayerSpecification} from './types';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
function stringify(obj: any) {
|
|
5
|
+
function stringify(obj: unknown) {
|
|
7
6
|
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
|
|
8
7
|
return JSON.stringify(obj);
|
|
9
8
|
|
|
@@ -30,8 +29,7 @@ function getKey(layer: LayerSpecification) {
|
|
|
30
29
|
return key;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
function containsKey(obj: any, key: string) {
|
|
32
|
+
function containsKey(obj: unknown, key: string) {
|
|
35
33
|
function recursiveSearch(item) {
|
|
36
34
|
if (typeof item === 'string' && item === key) {
|
|
37
35
|
return true;
|
|
@@ -106,12 +104,11 @@ export default function groupByLayout(
|
|
|
106
104
|
group.push(layer);
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
const result = [];
|
|
107
|
+
const result: LayerSpecification[][] = [];
|
|
110
108
|
|
|
111
109
|
for (const k in groups) {
|
|
112
110
|
result.push(groups[k]);
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
116
113
|
return result;
|
|
117
114
|
}
|
package/migrate.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
|
|
4
1
|
import migrateToV8 from './migrate/v8';
|
|
5
2
|
import migrateToExpressions from './migrate/expressions';
|
|
6
3
|
|
|
4
|
+
import type {StyleSpecification} from './types';
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Migrate a Mapbox GL Style to the latest version.
|
|
9
8
|
*
|
|
@@ -17,7 +16,7 @@ import migrateToExpressions from './migrate/expressions';
|
|
|
17
16
|
* var style = fs.readFileSync('./style.json', 'utf8');
|
|
18
17
|
* fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
|
|
19
18
|
*/
|
|
20
|
-
export default function (style) {
|
|
19
|
+
export default function (style: {version: 7} | StyleSpecification): StyleSpecification {
|
|
21
20
|
let migrated = false;
|
|
22
21
|
|
|
23
22
|
if (style.version === 7) {
|
|
@@ -26,14 +25,13 @@ export default function (style) {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
if (style.version === 8) {
|
|
29
|
-
|
|
28
|
+
style = migrateToExpressions(style);
|
|
30
29
|
migrated = true;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
if (!migrated) {
|
|
34
|
-
throw new Error(
|
|
33
|
+
throw new Error(`Cannot migrate from ${style.version}`);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
return style;
|
|
36
|
+
return style as StyleSpecification;
|
|
39
37
|
}
|
package/package.json
CHANGED
package/read_style.ts
CHANGED
|
@@ -6,8 +6,7 @@ import type {StyleSpecification} from './types';
|
|
|
6
6
|
export default function readStyle(style: string | Buffer | StyleSpecification): StyleSpecification {
|
|
7
7
|
if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
return jsonlint.parse(style.toString());
|
|
9
|
+
return jsonlint.parse(style.toString()) as StyleSpecification;
|
|
11
10
|
} catch (e) {
|
|
12
11
|
throw new ParsingError(e);
|
|
13
12
|
}
|
package/reference/v8.json
CHANGED
|
@@ -1553,6 +1553,27 @@
|
|
|
1553
1553
|
"paint": {
|
|
1554
1554
|
"type": "paint",
|
|
1555
1555
|
"doc": "Default paint properties for this layer."
|
|
1556
|
+
},
|
|
1557
|
+
"appearances": {
|
|
1558
|
+
"type": "array",
|
|
1559
|
+
"value": "appearance",
|
|
1560
|
+
"supported-layer-types": ["symbol"],
|
|
1561
|
+
"private": true,
|
|
1562
|
+
"doc": "Conditional styling applied to layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Can be used in appearances' are supported."
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
"appearance": {
|
|
1566
|
+
"condition": {
|
|
1567
|
+
"type": "expression",
|
|
1568
|
+
"doc": "A boolean expression that determines when this appearance should be applied."
|
|
1569
|
+
},
|
|
1570
|
+
"name": {
|
|
1571
|
+
"type": "string",
|
|
1572
|
+
"doc": "Optional name for this appearance. Non-empty names should be unique within a layer."
|
|
1573
|
+
},
|
|
1574
|
+
"properties": {
|
|
1575
|
+
"type": "*",
|
|
1576
|
+
"doc": "Style properties to apply when the condition is met."
|
|
1556
1577
|
}
|
|
1557
1578
|
},
|
|
1558
1579
|
"layout": [
|
|
@@ -2789,6 +2810,7 @@
|
|
|
2789
2810
|
"minimum": 0,
|
|
2790
2811
|
"units": "factor of the original icon size",
|
|
2791
2812
|
"doc": "Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image.",
|
|
2813
|
+
"appearance": true,
|
|
2792
2814
|
"requires": [
|
|
2793
2815
|
"icon-image"
|
|
2794
2816
|
],
|
|
@@ -2932,6 +2954,7 @@
|
|
|
2932
2954
|
"type": "resolvedImage",
|
|
2933
2955
|
"doc": "Name of image in sprite to use for drawing an image background.",
|
|
2934
2956
|
"tokens": true,
|
|
2957
|
+
"appearance": true,
|
|
2935
2958
|
"sdk-support": {
|
|
2936
2959
|
"basic functionality": {
|
|
2937
2960
|
"js": "0.10.0",
|
|
@@ -2959,6 +2982,7 @@
|
|
|
2959
2982
|
"period": 360,
|
|
2960
2983
|
"units": "degrees",
|
|
2961
2984
|
"doc": "Rotates the icon clockwise.",
|
|
2985
|
+
"appearance": true,
|
|
2962
2986
|
"requires": [
|
|
2963
2987
|
"icon-image"
|
|
2964
2988
|
],
|
|
@@ -3047,6 +3071,7 @@
|
|
|
3047
3071
|
0
|
|
3048
3072
|
],
|
|
3049
3073
|
"doc": "Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up.",
|
|
3074
|
+
"appearance": true,
|
|
3050
3075
|
"requires": [
|
|
3051
3076
|
"icon-image"
|
|
3052
3077
|
],
|
package/types.ts
CHANGED
|
@@ -382,6 +382,12 @@ export type SelectorPropertySpecification = {
|
|
|
382
382
|
[_: string]: unknown
|
|
383
383
|
};
|
|
384
384
|
|
|
385
|
+
export type AppearanceSpecification = {
|
|
386
|
+
"condition"?: ExpressionSpecification,
|
|
387
|
+
"name"?: string,
|
|
388
|
+
"properties"?: unknown
|
|
389
|
+
};
|
|
390
|
+
|
|
385
391
|
export type VectorSourceSpecification = {
|
|
386
392
|
"type": "vector",
|
|
387
393
|
"url"?: string,
|
|
@@ -627,7 +633,8 @@ export type FillLayerSpecification = {
|
|
|
627
633
|
"fill-tunnel-structure-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>,
|
|
628
634
|
"fill-tunnel-structure-color-transition"?: TransitionSpecification,
|
|
629
635
|
"fill-tunnel-structure-color-use-theme"?: PropertyValueSpecification<string>
|
|
630
|
-
}
|
|
636
|
+
},
|
|
637
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
631
638
|
};
|
|
632
639
|
|
|
633
640
|
/**
|
|
@@ -716,7 +723,8 @@ export type LineLayerSpecification = {
|
|
|
716
723
|
"line-border-color-use-theme"?: PropertyValueSpecification<string>,
|
|
717
724
|
"line-occlusion-opacity"?: PropertyValueSpecification<number>,
|
|
718
725
|
"line-occlusion-opacity-transition"?: TransitionSpecification
|
|
719
|
-
}
|
|
726
|
+
},
|
|
727
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
720
728
|
};
|
|
721
729
|
|
|
722
730
|
/**
|
|
@@ -845,7 +853,8 @@ export type SymbolLayerSpecification = {
|
|
|
845
853
|
*/
|
|
846
854
|
"symbol-z-offset"?: DataDrivenPropertyValueSpecification<number>,
|
|
847
855
|
"symbol-z-offset-transition"?: TransitionSpecification
|
|
848
|
-
}
|
|
856
|
+
},
|
|
857
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
849
858
|
};
|
|
850
859
|
|
|
851
860
|
/**
|
|
@@ -900,7 +909,8 @@ export type CircleLayerSpecification = {
|
|
|
900
909
|
"circle-stroke-opacity-transition"?: TransitionSpecification,
|
|
901
910
|
"circle-emissive-strength"?: PropertyValueSpecification<number>,
|
|
902
911
|
"circle-emissive-strength-transition"?: TransitionSpecification
|
|
903
|
-
}
|
|
912
|
+
},
|
|
913
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
904
914
|
};
|
|
905
915
|
|
|
906
916
|
/**
|
|
@@ -936,7 +946,8 @@ export type HeatmapLayerSpecification = {
|
|
|
936
946
|
"heatmap-color-use-theme"?: PropertyValueSpecification<string>,
|
|
937
947
|
"heatmap-opacity"?: PropertyValueSpecification<number>,
|
|
938
948
|
"heatmap-opacity-transition"?: TransitionSpecification
|
|
939
|
-
}
|
|
949
|
+
},
|
|
950
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
940
951
|
};
|
|
941
952
|
|
|
942
953
|
/**
|
|
@@ -1053,7 +1064,8 @@ export type FillExtrusionLayerSpecification = {
|
|
|
1053
1064
|
"fill-extrusion-line-width"?: DataDrivenPropertyValueSpecification<number>,
|
|
1054
1065
|
"fill-extrusion-line-width-transition"?: TransitionSpecification,
|
|
1055
1066
|
"fill-extrusion-cast-shadows"?: boolean
|
|
1056
|
-
}
|
|
1067
|
+
},
|
|
1068
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1057
1069
|
};
|
|
1058
1070
|
|
|
1059
1071
|
/**
|
|
@@ -1154,7 +1166,8 @@ export type BuildingLayerSpecification = {
|
|
|
1154
1166
|
*/
|
|
1155
1167
|
"building-facade-emissive-chance"?: PropertyValueSpecification<number>,
|
|
1156
1168
|
"building-cutoff-fade-range"?: ExpressionSpecification
|
|
1157
|
-
}
|
|
1169
|
+
},
|
|
1170
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1158
1171
|
};
|
|
1159
1172
|
|
|
1160
1173
|
/**
|
|
@@ -1212,7 +1225,8 @@ export type RasterLayerSpecification = {
|
|
|
1212
1225
|
*/
|
|
1213
1226
|
"raster-elevation"?: PropertyValueSpecification<number>,
|
|
1214
1227
|
"raster-elevation-transition"?: TransitionSpecification
|
|
1215
|
-
}
|
|
1228
|
+
},
|
|
1229
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1216
1230
|
};
|
|
1217
1231
|
|
|
1218
1232
|
/**
|
|
@@ -1251,7 +1265,8 @@ export type RasterParticleLayerSpecification = {
|
|
|
1251
1265
|
"raster-particle-reset-rate-factor"?: number,
|
|
1252
1266
|
"raster-particle-elevation"?: PropertyValueSpecification<number>,
|
|
1253
1267
|
"raster-particle-elevation-transition"?: TransitionSpecification
|
|
1254
|
-
}
|
|
1268
|
+
},
|
|
1269
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1255
1270
|
};
|
|
1256
1271
|
|
|
1257
1272
|
/**
|
|
@@ -1293,7 +1308,8 @@ export type HillshadeLayerSpecification = {
|
|
|
1293
1308
|
"hillshade-accent-color-use-theme"?: PropertyValueSpecification<string>,
|
|
1294
1309
|
"hillshade-emissive-strength"?: PropertyValueSpecification<number>,
|
|
1295
1310
|
"hillshade-emissive-strength-transition"?: TransitionSpecification
|
|
1296
|
-
}
|
|
1311
|
+
},
|
|
1312
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1297
1313
|
};
|
|
1298
1314
|
|
|
1299
1315
|
/**
|
|
@@ -1347,7 +1363,8 @@ export type ModelLayerSpecification = {
|
|
|
1347
1363
|
"model-height-based-emissive-strength-multiplier-transition"?: TransitionSpecification,
|
|
1348
1364
|
"model-cutoff-fade-range"?: ExpressionSpecification,
|
|
1349
1365
|
"model-front-cutoff"?: PropertyValueSpecification<[number, number, number]>
|
|
1350
|
-
}
|
|
1366
|
+
},
|
|
1367
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1351
1368
|
};
|
|
1352
1369
|
|
|
1353
1370
|
/**
|
|
@@ -1386,7 +1403,8 @@ export type BackgroundLayerSpecification = {
|
|
|
1386
1403
|
"background-opacity-transition"?: TransitionSpecification,
|
|
1387
1404
|
"background-emissive-strength"?: PropertyValueSpecification<number>,
|
|
1388
1405
|
"background-emissive-strength-transition"?: TransitionSpecification
|
|
1389
|
-
}
|
|
1406
|
+
},
|
|
1407
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1390
1408
|
};
|
|
1391
1409
|
|
|
1392
1410
|
/**
|
|
@@ -1426,7 +1444,8 @@ export type SkyLayerSpecification = {
|
|
|
1426
1444
|
"sky-atmosphere-color-use-theme"?: PropertyValueSpecification<string>,
|
|
1427
1445
|
"sky-opacity"?: PropertyValueSpecification<number>,
|
|
1428
1446
|
"sky-opacity-transition"?: TransitionSpecification
|
|
1429
|
-
}
|
|
1447
|
+
},
|
|
1448
|
+
"appearances"?: Array<AppearanceSpecification>
|
|
1430
1449
|
};
|
|
1431
1450
|
|
|
1432
1451
|
/**
|
|
@@ -1449,6 +1468,7 @@ export type SlotLayerSpecification = {
|
|
|
1449
1468
|
"minzoom"?: never,
|
|
1450
1469
|
"maxzoom"?: never,
|
|
1451
1470
|
"filter"?: never,
|
|
1471
|
+
"appearances"?: Array<AppearanceSpecification>,
|
|
1452
1472
|
"layout"?: never,
|
|
1453
1473
|
"paint"?: never
|
|
1454
1474
|
};
|
|
@@ -1467,6 +1487,7 @@ export type ClipLayerSpecification = {
|
|
|
1467
1487
|
"clip-layer-types"?: ExpressionSpecification,
|
|
1468
1488
|
"clip-layer-scope"?: ExpressionSpecification
|
|
1469
1489
|
},
|
|
1490
|
+
"appearances"?: Array<AppearanceSpecification>,
|
|
1470
1491
|
"paint"?: never
|
|
1471
1492
|
};
|
|
1472
1493
|
|
package/util/geometry_util.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array
|
|
|
31
31
|
|
|
32
32
|
if (len <= 1) return [rings];
|
|
33
33
|
|
|
34
|
-
const polygons = [];
|
|
34
|
+
const polygons: Array<Array<Ring>> = [];
|
|
35
35
|
let polygon,
|
|
36
36
|
ccw;
|
|
37
37
|
|
|
@@ -63,7 +63,6 @@ export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
67
66
|
return polygons;
|
|
68
67
|
}
|
|
69
68
|
|
package/validate/validate.ts
CHANGED
|
@@ -30,10 +30,8 @@ import type {StyleReference} from '../reference/latest';
|
|
|
30
30
|
import type {StyleSpecification} from '../types';
|
|
31
31
|
import type ValidationError from '../error/validation_error';
|
|
32
32
|
|
|
33
|
-
const VALIDATORS = {
|
|
34
|
-
'*'()
|
|
35
|
-
return [];
|
|
36
|
-
},
|
|
33
|
+
const VALIDATORS: Record<string, (unknown) => ValidationError[]> = {
|
|
34
|
+
'*': () => [],
|
|
37
35
|
'array': validateArray,
|
|
38
36
|
'boolean': validateBoolean,
|
|
39
37
|
'number': validateNumber,
|
|
@@ -79,6 +77,9 @@ export type ValidationOptions = {
|
|
|
79
77
|
objectKey?: string;
|
|
80
78
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
79
|
objectElementValidators?: Record<string, (...args: any[]) => Array<ValidationError>>;
|
|
80
|
+
propertyKey?: string
|
|
81
|
+
propertyType?: string
|
|
82
|
+
expressionContext?: 'property';
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
export default function validate(options: ValidationOptions, arrayAsExpression: boolean = false): Array<ValidationError> {
|
|
@@ -87,7 +88,6 @@ export default function validate(options: ValidationOptions, arrayAsExpression:
|
|
|
87
88
|
const styleSpec = options.styleSpec;
|
|
88
89
|
|
|
89
90
|
if (valueSpec.expression && isFunction(unbundle(value))) {
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
91
91
|
return validateFunction(options);
|
|
92
92
|
} else if (valueSpec.expression && isExpression(deepUnbundle(value))) {
|
|
93
93
|
return validateExpression(options);
|
|
@@ -97,7 +97,6 @@ export default function validate(options: ValidationOptions, arrayAsExpression:
|
|
|
97
97
|
// Try to validate as an expression
|
|
98
98
|
return validateExpression(options);
|
|
99
99
|
} else {
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
101
100
|
return valid;
|
|
102
101
|
}
|
|
103
102
|
} else {
|
|
@@ -45,7 +45,7 @@ export default function validateArray(options: Options): Array<ValidationError>
|
|
|
45
45
|
arrayElementSpec = arraySpec.value;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
let errors = [];
|
|
48
|
+
let errors: ValidationError[] = [];
|
|
49
49
|
for (let i = 0; i < array.length; i++) {
|
|
50
50
|
errors = errors.concat(validateArrayElement({
|
|
51
51
|
array,
|
|
@@ -57,6 +57,6 @@ export default function validateArray(options: Options): Array<ValidationError>
|
|
|
57
57
|
key: `${key}[${i}]`
|
|
58
58
|
}, true));
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
return errors;
|
|
62
62
|
}
|
|
@@ -7,7 +7,7 @@ export default function validateEnum(options: ValidationOptions): Array<Validati
|
|
|
7
7
|
const key = options.key;
|
|
8
8
|
const value = options.value;
|
|
9
9
|
const valueSpec = options.valueSpec;
|
|
10
|
-
const errors = [];
|
|
10
|
+
const errors: ValidationError[] = [];
|
|
11
11
|
|
|
12
12
|
if (Array.isArray(valueSpec.values)) { // <=v7
|
|
13
13
|
if (valueSpec.values.indexOf(unbundle(value)) === -1) {
|
|
@@ -18,6 +18,6 @@ export default function validateEnum(options: ValidationOptions): Array<Validati
|
|
|
18
18
|
errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
return errors;
|
|
23
23
|
}
|
|
@@ -62,7 +62,7 @@ export function disallowedFilterParameters(e: Expression, options: any): Array<V
|
|
|
62
62
|
if (disallowedParameters.size === 0) {
|
|
63
63
|
return [];
|
|
64
64
|
}
|
|
65
|
-
const errors = [];
|
|
65
|
+
const errors: ValidationError[] = [];
|
|
66
66
|
|
|
67
67
|
if (e instanceof CompoundExpression) {
|
|
68
68
|
if (disallowedParameters.has(e.name)) {
|
|
@@ -73,6 +73,5 @@ export function disallowedFilterParameters(e: Expression, options: any): Array<V
|
|
|
73
73
|
errors.push(...disallowedFilterParameters(arg, options));
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
77
76
|
return errors;
|
|
78
77
|
}
|