@mapbox/mapbox-gl-style-spec 13.28.0 → 14.0.0-beta.2
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/LICENSE.txt +47 -0
- package/README.md +7 -0
- package/data/extent.js +18 -0
- package/deref.js +1 -1
- package/diff.js +36 -15
- package/dist/index.cjs +5839 -2015
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +5837 -2011
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.js +2 -1
- package/expression/definitions/assertion.js +2 -2
- package/expression/definitions/coercion.js +54 -15
- package/expression/definitions/comparison.js +2 -0
- package/expression/definitions/distance.js +597 -0
- package/expression/definitions/format.js +2 -2
- package/expression/definitions/image.js +34 -14
- package/expression/definitions/index.js +122 -8
- package/expression/definitions/interpolate.js +1 -1
- package/expression/definitions/match.js +2 -2
- package/expression/definitions/within.js +21 -92
- package/expression/evaluation_context.js +12 -1
- package/expression/index.js +74 -43
- package/expression/is_constant.js +19 -1
- package/expression/parsing_context.js +20 -16
- package/expression/types/formatted.js +2 -2
- package/expression/types/resolved_image.js +19 -8
- package/expression/types.js +2 -1
- package/expression/values.js +25 -0
- package/feature_filter/convert.js +1 -1
- package/feature_filter/index.js +4 -4
- package/flow-typed/cheap-ruler.js +25 -0
- package/flow-typed/geojson.js +8 -7
- package/flow-typed/gl-matrix.js +4 -2
- package/flow-typed/kdbush.js +9 -0
- package/function/convert.js +23 -12
- package/group_by_layout.js +2 -2
- package/migrate/expressions.js +3 -0
- package/package.json +6 -3
- package/reference/v8.json +1771 -114
- package/style-spec.js +4 -3
- package/types.js +190 -24
- package/util/color.js +31 -0
- package/util/geometry_util.js +145 -0
- package/util/properties.js +10 -2
- package/util/random.js +12 -0
- package/validate/validate.js +17 -7
- package/validate/validate_array.js +1 -1
- package/validate/validate_filter.js +4 -12
- package/validate/validate_function.js +2 -2
- package/validate/validate_import.js +31 -0
- package/validate/validate_layer.js +3 -2
- package/validate/validate_lights.js +84 -0
- package/validate/validate_model.js +38 -0
- package/validate/validate_property.js +18 -4
- package/validate/validate_source.js +3 -2
- package/validate/validate_style.js +29 -0
- package/validate_mapbox_api_supported.js +55 -11
- package/validate_style.js +4 -0
- package/validate_style.min.js +11 -19
- package/visit.js +3 -2
package/flow-typed/gl-matrix.js
CHANGED
|
@@ -24,7 +24,6 @@ declare module "gl-matrix" {
|
|
|
24
24
|
dot(Vec3, Vec3): number,
|
|
25
25
|
equals(Vec3, Vec3): boolean,
|
|
26
26
|
exactEquals(Vec3, Vec3): boolean,
|
|
27
|
-
|
|
28
27
|
clone<T: Vec3>(T): T,
|
|
29
28
|
normalize<T: Vec3>(T, Vec3): T,
|
|
30
29
|
add<T: Vec3>(T, Vec3, Vec3): T,
|
|
@@ -72,6 +71,7 @@ declare module "gl-matrix" {
|
|
|
72
71
|
mul<T: Mat3>(T, Mat3, Mat3): T,
|
|
73
72
|
multiply<T: Mat3>(T, Mat3, Mat3): T,
|
|
74
73
|
adjoint<T: Mat3>(T, Mat3): T,
|
|
74
|
+
invert<T: Mat3>(T, Mat3): T,
|
|
75
75
|
transpose<T: Mat3>(T, Mat3): T
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -94,6 +94,7 @@ declare module "gl-matrix" {
|
|
|
94
94
|
fromRotation<T: Mat4>(T, number, Vec3): T,
|
|
95
95
|
translate<T: Mat4>(T, Mat4, Vec3): T,
|
|
96
96
|
invert<T: Mat4>(T, Mat4): T,
|
|
97
|
+
transpose<T: Mat4>(T, Mat4): T,
|
|
97
98
|
copy<T: Mat4>(T, Mat4): T,
|
|
98
99
|
clone<T: Mat4>(T): T
|
|
99
100
|
};
|
|
@@ -108,6 +109,7 @@ declare module "gl-matrix" {
|
|
|
108
109
|
identity<T: Quat>(T): T,
|
|
109
110
|
rotateX<T: Quat>(T, Quat, number): T,
|
|
110
111
|
rotateY<T: Quat>(T, Quat, number): T,
|
|
111
|
-
rotateZ<T: Quat>(T, Quat, number): T
|
|
112
|
+
rotateZ<T: Quat>(T, Quat, number): T,
|
|
113
|
+
rotationTo<T:Quat>(T, Quat, Quat): T
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
declare module 'kdbush' {
|
|
3
|
+
declare export default class KDBush {
|
|
4
|
+
constructor(numPoints: number, nodeSize?: number, arrayType?: Class<$ArrayBufferView>): KDBush;
|
|
5
|
+
add(x: number, y: number): number;
|
|
6
|
+
finish(): void;
|
|
7
|
+
range(minX: number, minY: number, maxX: number, maxY: number): Array<number>;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/function/convert.js
CHANGED
|
@@ -5,11 +5,22 @@ import assert from 'assert';
|
|
|
5
5
|
import type {StylePropertySpecification} from '../style-spec.js';
|
|
6
6
|
import type {ExpressionSpecification} from '../types.js';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type Stop = [{zoom: number, value: string | number | boolean}, mixed];
|
|
9
|
+
|
|
10
|
+
type FunctionParameters = {
|
|
11
|
+
stops: Array<Stop>;
|
|
12
|
+
base: number;
|
|
13
|
+
property: string;
|
|
14
|
+
type: 'identity' | 'exponential' | 'interval' | 'categorical';
|
|
15
|
+
colorSpace: 'rgb' | 'lab' | 'hcl';
|
|
16
|
+
default: mixed;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function convertLiteral(value: mixed) {
|
|
9
20
|
return typeof value === 'object' ? ['literal', value] : value;
|
|
10
21
|
}
|
|
11
22
|
|
|
12
|
-
export default function convertFunction(parameters:
|
|
23
|
+
export default function convertFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification {
|
|
13
24
|
let stops = parameters.stops;
|
|
14
25
|
if (!stops) {
|
|
15
26
|
// identity function
|
|
@@ -36,7 +47,7 @@ export default function convertFunction(parameters: any, propertySpec: StyleProp
|
|
|
36
47
|
}
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
function convertIdentityFunction(parameters, propertySpec): Array<mixed> {
|
|
50
|
+
function convertIdentityFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): Array<mixed> {
|
|
40
51
|
const get = ['get', parameters.property];
|
|
41
52
|
|
|
42
53
|
if (parameters.default === undefined) {
|
|
@@ -60,7 +71,7 @@ function convertIdentityFunction(parameters, propertySpec): Array<mixed> {
|
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
function getInterpolateOperator(parameters) {
|
|
74
|
+
function getInterpolateOperator(parameters: FunctionParameters) {
|
|
64
75
|
switch (parameters.colorSpace) {
|
|
65
76
|
case 'hcl': return 'interpolate-hcl';
|
|
66
77
|
case 'lab': return 'interpolate-lab';
|
|
@@ -68,7 +79,7 @@ function getInterpolateOperator(parameters) {
|
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
function convertZoomAndPropertyFunction(parameters, propertySpec, stops) {
|
|
82
|
+
function convertZoomAndPropertyFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>) {
|
|
72
83
|
const featureFunctionParameters = {};
|
|
73
84
|
const featureFunctionStops = {};
|
|
74
85
|
const zoomStops = [];
|
|
@@ -116,12 +127,12 @@ function convertZoomAndPropertyFunction(parameters, propertySpec, stops) {
|
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
|
|
119
|
-
function coalesce(a, b) {
|
|
130
|
+
function coalesce(a: mixed, b: mixed) {
|
|
120
131
|
if (a !== undefined) return a;
|
|
121
132
|
if (b !== undefined) return b;
|
|
122
133
|
}
|
|
123
134
|
|
|
124
|
-
function getFallback(parameters, propertySpec) {
|
|
135
|
+
function getFallback(parameters: FunctionParameters, propertySpec: StylePropertySpecification) {
|
|
125
136
|
const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));
|
|
126
137
|
|
|
127
138
|
/*
|
|
@@ -136,7 +147,7 @@ function getFallback(parameters, propertySpec) {
|
|
|
136
147
|
return defaultValue;
|
|
137
148
|
}
|
|
138
149
|
|
|
139
|
-
function convertPropertyFunction(parameters, propertySpec, stops) {
|
|
150
|
+
function convertPropertyFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>) {
|
|
140
151
|
const type = getFunctionType(parameters, propertySpec);
|
|
141
152
|
const get = ['get', parameters.property];
|
|
142
153
|
if (type === 'categorical' && typeof stops[0][0] === 'boolean') {
|
|
@@ -189,7 +200,7 @@ function convertPropertyFunction(parameters, propertySpec, stops) {
|
|
|
189
200
|
}
|
|
190
201
|
}
|
|
191
202
|
|
|
192
|
-
function convertZoomFunction(parameters, propertySpec, stops
|
|
203
|
+
function convertZoomFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>, input: Array<string> = ['zoom']) {
|
|
193
204
|
const type = getFunctionType(parameters, propertySpec);
|
|
194
205
|
let expression;
|
|
195
206
|
let isStep = false;
|
|
@@ -213,7 +224,7 @@ function convertZoomFunction(parameters, propertySpec, stops, input = ['zoom'])
|
|
|
213
224
|
return expression;
|
|
214
225
|
}
|
|
215
226
|
|
|
216
|
-
function fixupDegenerateStepCurve(expression) {
|
|
227
|
+
function fixupDegenerateStepCurve(expression: ExpressionSpecification) {
|
|
217
228
|
// degenerate step curve (i.e. a constant function): add a noop stop
|
|
218
229
|
if (expression[0] === 'step' && expression.length === 3) {
|
|
219
230
|
expression.push(0);
|
|
@@ -221,7 +232,7 @@ function fixupDegenerateStepCurve(expression) {
|
|
|
221
232
|
}
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
function appendStopPair(curve, input, output, isStep) {
|
|
235
|
+
function appendStopPair(curve: ExpressionSpecification, input: mixed, output: mixed, isStep: boolean) {
|
|
225
236
|
// Skip duplicate stop values. They were not validated for functions, but they are for expressions.
|
|
226
237
|
// https://github.com/mapbox/mapbox-gl-js/issues/4107
|
|
227
238
|
if (curve.length > 3 && input === curve[curve.length - 2]) {
|
|
@@ -234,7 +245,7 @@ function appendStopPair(curve, input, output, isStep) {
|
|
|
234
245
|
curve.push(output);
|
|
235
246
|
}
|
|
236
247
|
|
|
237
|
-
function getFunctionType(parameters, propertySpec) {
|
|
248
|
+
function getFunctionType(parameters: FunctionParameters, propertySpec: StylePropertySpecification): string {
|
|
238
249
|
if (parameters.type) {
|
|
239
250
|
return parameters.type;
|
|
240
251
|
} else {
|
package/group_by_layout.js
CHANGED
|
@@ -4,7 +4,7 @@ import type {LayerSpecification} from './types.js';
|
|
|
4
4
|
|
|
5
5
|
import refProperties from './util/ref_properties.js';
|
|
6
6
|
|
|
7
|
-
function stringify(obj) {
|
|
7
|
+
function stringify(obj: any) {
|
|
8
8
|
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
|
|
9
9
|
return JSON.stringify(obj);
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ function stringify(obj) {
|
|
|
23
23
|
return `${str}}`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function getKey(layer) {
|
|
26
|
+
function getKey(layer: LayerSpecification) {
|
|
27
27
|
let key = '';
|
|
28
28
|
for (const k of refProperties) {
|
|
29
29
|
key += `/${stringify((layer: any)[k])}`;
|
package/migrate/expressions.js
CHANGED
|
@@ -27,6 +27,9 @@ export default function(style: StyleSpecification): StyleSpecification {
|
|
|
27
27
|
eachProperty(style, {paint: true, layout: true}, ({path, value, reference, set}) => {
|
|
28
28
|
if (isExpression(value)) return;
|
|
29
29
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
30
|
+
// $FlowFixMe[prop-missing]
|
|
31
|
+
// $FlowFixMe[incompatible-call]
|
|
32
|
+
// $FlowFixMe[incompatible-variance]
|
|
30
33
|
set(convertFunction(value, reference));
|
|
31
34
|
converted.push(path.join('.'));
|
|
32
35
|
} else if (reference.tokens && typeof value === 'string') {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapbox/mapbox-gl-style-spec",
|
|
3
3
|
"description": "a specification for mapbox gl styles",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.0-beta.2",
|
|
5
5
|
"author": "Mapbox",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mapbox",
|
|
8
8
|
"mapbox-gl",
|
|
9
9
|
"mapbox-gl-js"
|
|
10
10
|
],
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
12
12
|
"main": "./dist/index.cjs",
|
|
13
13
|
"module": "./dist/index.es.js",
|
|
14
14
|
"type": "module",
|
|
@@ -47,7 +47,10 @@
|
|
|
47
47
|
"json-stringify-pretty-compact": "^2.0.0",
|
|
48
48
|
"minimist": "^1.2.6",
|
|
49
49
|
"rw": "^1.3.3",
|
|
50
|
-
"sort-object": "^0.3.2"
|
|
50
|
+
"sort-object": "^0.3.2",
|
|
51
|
+
"quickselect": "^2.0.0",
|
|
52
|
+
"tinyqueue": "^2.0.3",
|
|
53
|
+
"cheap-ruler": "^3.0.1"
|
|
51
54
|
},
|
|
52
55
|
"sideEffects": false
|
|
53
56
|
}
|