@mapbox/mapbox-gl-style-spec 13.24.0-alpha.1 → 13.24.0-alpha.6
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/CHANGELOG.md +6 -0
- package/bin/gl-style-composite.js +21 -0
- package/bin/{gl-style-format → gl-style-format.js} +8 -4
- package/bin/gl-style-migrate.js +21 -0
- package/bin/{gl-style-validate → gl-style-validate.js} +15 -12
- package/build/.gitkeep +0 -0
- package/deref.js +8 -7
- package/diff.js +11 -6
- package/dist/index.cjs +15 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +15 -54
- package/dist/index.es.js.map +1 -1
- package/empty.js +9 -28
- package/expression/definitions/coalesce.js +7 -5
- package/expression/definitions/in.js +1 -1
- package/expression/evaluation_context.js +1 -1
- package/expression/index.js +3 -3
- package/feature_filter/convert.js +1 -1
- package/feature_filter/index.js +1 -1
- package/flow-typed/gl-matrix.js +103 -0
- package/flow-typed/grid-index.js +13 -0
- package/flow-typed/pbf.js +2 -1
- package/flow-typed/point-geometry.js +4 -2
- package/flow-typed/potpack.js +1 -0
- package/flow-typed/tiny-sdf.js +31 -0
- package/flow-typed/vector-tile.js +1 -0
- package/group_by_layout.js +8 -10
- package/package.json +9 -7
- package/style-spec.js +6 -3
- package/test.js +31 -0
- package/util/color_spaces.js +2 -2
- package/util/extend.js +1 -1
- package/util/interpolate.js +2 -2
- package/util/ref_properties.js +1 -1
- package/util/unbundle_jsonlint.js +1 -1
- package/validate/validate.js +0 -2
- package/validate_mapbox_api_supported.js +8 -6
- package/validate_style.js +14 -9
- package/validate_style.min.js +32 -47
- package/bin/gl-style-composite +0 -9
- package/bin/gl-style-migrate +0 -9
- package/declass.js +0 -42
- package/validate/latest.js +0 -11
- package/validate/validate_constants.js +0 -13
package/empty.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (spec.required) {
|
|
11
|
-
let value = null;
|
|
12
|
-
if (styleKey === 'version') {
|
|
13
|
-
value = version;
|
|
14
|
-
} else {
|
|
15
|
-
if (spec.type === 'array') {
|
|
16
|
-
value = [];
|
|
17
|
-
} else {
|
|
18
|
-
value = {};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (value != null) {
|
|
23
|
-
style[styleKey] = value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return style;
|
|
1
|
+
// @flow
|
|
2
|
+
import type {StyleSpecification} from './types.js';
|
|
3
|
+
|
|
4
|
+
export default function emptyStyle(): StyleSpecification {
|
|
5
|
+
return {
|
|
6
|
+
version: 8,
|
|
7
|
+
layers: [],
|
|
8
|
+
sources: {}
|
|
9
|
+
};
|
|
29
10
|
}
|
|
@@ -54,19 +54,21 @@ class Coalesce implements Expression {
|
|
|
54
54
|
evaluate(ctx: EvaluationContext) {
|
|
55
55
|
let result = null;
|
|
56
56
|
let argCount = 0;
|
|
57
|
-
let
|
|
57
|
+
let firstImage;
|
|
58
58
|
for (const arg of this.args) {
|
|
59
59
|
argCount++;
|
|
60
60
|
result = arg.evaluate(ctx);
|
|
61
61
|
// we need to keep track of the first requested image in a coalesce statement
|
|
62
|
-
// if coalesce can't find a valid image, we return the first image
|
|
62
|
+
// if coalesce can't find a valid image, we return the first image so styleimagemissing can fire
|
|
63
63
|
if (result && result instanceof ResolvedImage && !result.available) {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
// set to first image
|
|
65
|
+
if (!firstImage) {
|
|
66
|
+
firstImage = result;
|
|
66
67
|
}
|
|
67
68
|
result = null;
|
|
69
|
+
// if we reach the end, return the first image
|
|
68
70
|
if (argCount === this.args.length) {
|
|
69
|
-
|
|
71
|
+
return firstImage;
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -42,7 +42,7 @@ class In implements Expression {
|
|
|
42
42
|
const needle = (this.needle.evaluate(ctx): any);
|
|
43
43
|
const haystack = (this.haystack.evaluate(ctx): any);
|
|
44
44
|
|
|
45
|
-
if (
|
|
45
|
+
if (haystack == null) return false;
|
|
46
46
|
|
|
47
47
|
if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {
|
|
48
48
|
throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString(typeOf(needle))} instead.`);
|
package/expression/index.js
CHANGED
|
@@ -286,11 +286,11 @@ export class StylePropertyFunction<T> {
|
|
|
286
286
|
extend(this, createFunction(this._parameters, this._specification));
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
static deserialize(serialized: {_parameters: PropertyValueSpecification<T>, _specification: StylePropertySpecification}) {
|
|
290
|
-
return
|
|
289
|
+
static deserialize(serialized: {_parameters: PropertyValueSpecification<T>, _specification: StylePropertySpecification}): StylePropertyFunction<T> {
|
|
290
|
+
return new StylePropertyFunction(serialized._parameters, serialized._specification);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
static serialize(input: StylePropertyFunction<T>) {
|
|
293
|
+
static serialize(input: StylePropertyFunction<T>): {_parameters: PropertyValueSpecification<T>, _specification: StylePropertySpecification} {
|
|
294
294
|
return {
|
|
295
295
|
_parameters: input._parameters,
|
|
296
296
|
_specification: input._specification
|
|
@@ -94,7 +94,7 @@ function _convertFilter(filter: FilterSpecification, expectedTypes: ExpectedType
|
|
|
94
94
|
const children = (filter: any).slice(1).map(f => _convertFilter(f, expectedTypes));
|
|
95
95
|
return children.length > 1 ? ['all'].concat(children) : [].concat(...children);
|
|
96
96
|
} else if (op === 'none') {
|
|
97
|
-
return ['!', _convertFilter(['any'].concat(filter.slice(1)), {})];
|
|
97
|
+
return ['!', _convertFilter(['any'].concat((filter: any).slice(1)), {})];
|
|
98
98
|
} else if (op === 'in') {
|
|
99
99
|
converted = convertInOp((filter[1]: any), filter.slice(2));
|
|
100
100
|
} else if (op === '!in') {
|
package/feature_filter/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import type {CanonicalTileID} from '../../source/tile_id.js';
|
|
|
9
9
|
import type Point from '@mapbox/point-geometry';
|
|
10
10
|
|
|
11
11
|
export type FeatureDistanceData = {bearing: [number, number], center: [number, number], scale: number};
|
|
12
|
-
type FilterExpression = (globalProperties: GlobalProperties, feature: Feature, canonical?: CanonicalTileID, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData) => boolean;
|
|
12
|
+
export type FilterExpression = (globalProperties: GlobalProperties, feature: Feature, canonical?: CanonicalTileID, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData) => boolean;
|
|
13
13
|
export type FeatureFilter = {filter: FilterExpression, dynamicFilter?: FilterExpression, needGeometry: boolean, needFeature: boolean};
|
|
14
14
|
|
|
15
15
|
export default createFilter;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
type VecType = Array<number> | Float32Array | Float64Array;
|
|
3
|
+
|
|
4
|
+
declare module "gl-matrix" {
|
|
5
|
+
declare type Vec2 = VecType;
|
|
6
|
+
declare type Vec3 = VecType;
|
|
7
|
+
declare type Vec4 = VecType;
|
|
8
|
+
declare type Quat = VecType;
|
|
9
|
+
declare type Mat2 = VecType;
|
|
10
|
+
declare type Mat3 = VecType;
|
|
11
|
+
declare type Mat4 = VecType;
|
|
12
|
+
|
|
13
|
+
declare var vec2: {
|
|
14
|
+
exactEquals(Vec2, Vec2): boolean
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare var vec3: {
|
|
18
|
+
create(): Float32Array,
|
|
19
|
+
fromValues(number, number, number): Float32Array,
|
|
20
|
+
length(Vec3): number,
|
|
21
|
+
len(Vec3): number,
|
|
22
|
+
squaredLength(Vec3): number,
|
|
23
|
+
dot(Vec3, Vec3): number,
|
|
24
|
+
equals(Vec3, Vec3): boolean,
|
|
25
|
+
exactEquals(Vec3, Vec3): boolean,
|
|
26
|
+
|
|
27
|
+
clone<T: Vec3>(T): T,
|
|
28
|
+
normalize<T: Vec3>(T, Vec3): T,
|
|
29
|
+
add<T: Vec3>(T, Vec3, Vec3): T,
|
|
30
|
+
sub<T: Vec3>(T, Vec3, Vec3): T,
|
|
31
|
+
subtract<T: Vec3>(T, Vec3, Vec3): T,
|
|
32
|
+
cross<T: Vec3>(T, Vec3, Vec3): T,
|
|
33
|
+
negate<T: Vec3>(T, Vec3): T,
|
|
34
|
+
scale<T: Vec3>(T, Vec3, number): T,
|
|
35
|
+
scaleAndAdd<T: Vec3>(T, Vec3, Vec3, number): T,
|
|
36
|
+
multiply<T: Vec3>(T, Vec3, Vec3): T,
|
|
37
|
+
mul<T: Vec3>(T, Vec3, Vec3): T,
|
|
38
|
+
div<T: Vec3>(T, Vec3, Vec3): T,
|
|
39
|
+
min<T: Vec3>(T, Vec3, Vec3): T,
|
|
40
|
+
max<T: Vec3>(T, Vec3, Vec3): T,
|
|
41
|
+
lerp<T: Vec3>(T, Vec3, Vec3, number): T,
|
|
42
|
+
transformQuat<T: Vec3>(T, Vec3, Quat): T,
|
|
43
|
+
transformMat3<T: Vec3>(T, Vec3, Mat3): T,
|
|
44
|
+
transformMat4<T: Vec3>(T, Vec3, Mat4): T
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
declare var vec4: {
|
|
48
|
+
scale<T: Vec4>(T, Vec4, number): T,
|
|
49
|
+
mul<T: Vec4>(T, Vec4, Vec4): T,
|
|
50
|
+
transformMat4<T: Vec4>(T, Vec4, Mat4): T
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare var mat2: {
|
|
54
|
+
create(): Float32Array,
|
|
55
|
+
rotate<T: Mat2>(T, Mat2, number): T,
|
|
56
|
+
invert<T: Mat2>(T, Mat2): T,
|
|
57
|
+
scale<T: Mat2>(T, Mat2, Vec2): T
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare var mat3: {
|
|
61
|
+
create(): Float32Array,
|
|
62
|
+
|
|
63
|
+
fromMat4<T: Mat3>(T, Mat4): T,
|
|
64
|
+
fromRotation<T: Mat3>(T, number): T,
|
|
65
|
+
mul<T: Mat3>(T, Mat3, Mat3): T,
|
|
66
|
+
multiply<T: Mat3>(T, Mat3, Mat3): T,
|
|
67
|
+
adjoint<T: Mat3>(T, Mat3): T,
|
|
68
|
+
transpose<T: Mat3>(T, Mat3): T
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
declare var mat4: {
|
|
72
|
+
create(): Float32Array,
|
|
73
|
+
|
|
74
|
+
fromScaling<T: Mat4>(T, Vec3): T,
|
|
75
|
+
fromQuat<T: Mat4>(T, Quat): T,
|
|
76
|
+
ortho<T: Mat4>(T, number, number, number, number, number, number): T,
|
|
77
|
+
perspective<T: Mat4>(T, number, number, number, number): T,
|
|
78
|
+
identity<T: Mat4>(T): T,
|
|
79
|
+
scale<T: Mat4>(T, Mat4, Vec3): T,
|
|
80
|
+
mul<T: Mat4>(T, Mat4, Mat4): T,
|
|
81
|
+
multiply<T: Mat4>(T, Mat4, Mat4): T,
|
|
82
|
+
rotateX<T: Mat4>(T, Mat4, number): T,
|
|
83
|
+
rotateY<T: Mat4>(T, Mat4, number): T,
|
|
84
|
+
rotateZ<T: Mat4>(T, Mat4, number): T,
|
|
85
|
+
translate<T: Mat4>(T, Mat4, Vec3): T,
|
|
86
|
+
invert<T: Mat4>(T, Mat4): T,
|
|
87
|
+
copy<T: Mat4>(T, Mat4): T,
|
|
88
|
+
clone<T: Mat4>(T): T
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare var quat: {
|
|
92
|
+
create(): Float32Array,
|
|
93
|
+
length(Quat): number,
|
|
94
|
+
exactEquals(Quat, Quat): boolean,
|
|
95
|
+
|
|
96
|
+
normalize<T: Quat>(T, Quat): T,
|
|
97
|
+
conjugate<T: Quat>(T, Quat): T,
|
|
98
|
+
identity<T: Quat>(T): T,
|
|
99
|
+
rotateX<T: Quat>(T, Quat, number): T,
|
|
100
|
+
rotateY<T: Quat>(T, Quat, number): T,
|
|
101
|
+
rotateZ<T: Quat>(T, Quat, number): T
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
declare module 'grid-index' {
|
|
3
|
+
declare class GridIndex {
|
|
4
|
+
constructor(extent: number, n: number, padding: number): GridIndex;
|
|
5
|
+
constructor(data: ArrayBuffer): GridIndex;
|
|
6
|
+
|
|
7
|
+
insert(key: number, x1: number, y1: number, x2: number, y2: number): void;
|
|
8
|
+
query(x1: number, y1: number, x2: number, y2: number, intersectionText?: (number, number, number, number) => boolean): Array<number>;
|
|
9
|
+
toArrayBuffer(): ArrayBuffer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare export default Class<GridIndex>;
|
|
13
|
+
}
|
package/flow-typed/pbf.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
declare module "pbf" {
|
|
2
3
|
declare type ReadFunction<T> = (tag: number, result: T, pbf: Pbf) => void;
|
|
3
4
|
|
|
@@ -21,5 +22,5 @@ declare module "pbf" {
|
|
|
21
22
|
readBytes(): Uint8Array;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
declare
|
|
25
|
+
declare export default Class<Pbf>;
|
|
25
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// @flow strict
|
|
1
2
|
declare module "@mapbox/point-geometry" {
|
|
2
|
-
declare type PointLike = Point | [number, number];
|
|
3
|
+
declare export type PointLike = Point | [number, number];
|
|
3
4
|
|
|
4
5
|
declare class Point {
|
|
5
6
|
x: number;
|
|
@@ -40,5 +41,6 @@ declare module "@mapbox/point-geometry" {
|
|
|
40
41
|
_round(): Point;
|
|
41
42
|
static convert(a: PointLike): Point;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
|
|
45
|
+
declare export default Class<Point>;
|
|
44
46
|
}
|
package/flow-typed/potpack.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
declare module '@mapbox/tiny-sdf' {
|
|
3
|
+
declare type TinySDFOptions = {
|
|
4
|
+
fontSize?: number;
|
|
5
|
+
buffer?: number;
|
|
6
|
+
radius?: number;
|
|
7
|
+
cutoff?: number;
|
|
8
|
+
fontFamily?: string;
|
|
9
|
+
fontWeight?: string;
|
|
10
|
+
fontStyle?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare type TinySDFGlyph = {
|
|
14
|
+
data: Uint8ClampedArray;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
glyphWidth: number;
|
|
18
|
+
glyphHeight: number;
|
|
19
|
+
glyphTop: number;
|
|
20
|
+
glyphLeft: number;
|
|
21
|
+
glyphAdvance: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare class TinySDF {
|
|
25
|
+
fontWeight: string;
|
|
26
|
+
constructor(options: TinySDFOptions): TinySDF;
|
|
27
|
+
draw(char: string): TinySDFGlyph;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare export default Class<TinySDF>;
|
|
31
|
+
}
|
package/group_by_layout.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import type {LayerSpecification} from './types.js';
|
|
1
4
|
|
|
2
5
|
import refProperties from './util/ref_properties.js';
|
|
3
6
|
|
|
4
7
|
function stringify(obj) {
|
|
5
|
-
|
|
6
|
-
if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)
|
|
8
|
+
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
|
|
7
9
|
return JSON.stringify(obj);
|
|
8
10
|
|
|
9
11
|
if (Array.isArray(obj)) {
|
|
@@ -14,11 +16,9 @@ function stringify(obj) {
|
|
|
14
16
|
return `${str}]`;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
const keys = Object.keys(obj).sort();
|
|
18
|
-
|
|
19
19
|
let str = '{';
|
|
20
|
-
for (
|
|
21
|
-
str += `${
|
|
20
|
+
for (const key of Object.keys(obj).sort()) {
|
|
21
|
+
str += `${key}:${stringify((obj: any)[key])},`;
|
|
22
22
|
}
|
|
23
23
|
return `${str}}`;
|
|
24
24
|
}
|
|
@@ -26,13 +26,11 @@ function stringify(obj) {
|
|
|
26
26
|
function getKey(layer) {
|
|
27
27
|
let key = '';
|
|
28
28
|
for (const k of refProperties) {
|
|
29
|
-
key += `/${stringify(layer[k])}`;
|
|
29
|
+
key += `/${stringify((layer: any)[k])}`;
|
|
30
30
|
}
|
|
31
31
|
return key;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export default groupByLayout;
|
|
35
|
-
|
|
36
34
|
/**
|
|
37
35
|
* Given an array of layers, return an array of arrays of layers where all
|
|
38
36
|
* layers in each group have identical layout-affecting properties. These
|
|
@@ -48,7 +46,7 @@ export default groupByLayout;
|
|
|
48
46
|
* @param {Object} [cachedKeys] - an object to keep already calculated keys.
|
|
49
47
|
* @returns {Array<Array<Layer>>}
|
|
50
48
|
*/
|
|
51
|
-
function groupByLayout(layers
|
|
49
|
+
export default function groupByLayout(layers: Array<LayerSpecification>, cachedKeys: {[id: string]: string}): Array<Array<LayerSpecification>> {
|
|
52
50
|
const groups = {};
|
|
53
51
|
|
|
54
52
|
for (let i = 0; i < layers.length; i++) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapbox/mapbox-gl-style-spec",
|
|
3
3
|
"description": "a specification for mapbox gl styles",
|
|
4
|
-
"version": "13.24.0-alpha.
|
|
4
|
+
"version": "13.24.0-alpha.6",
|
|
5
5
|
"author": "Mapbox",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mapbox",
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
+
"pretest": "npm run build",
|
|
26
|
+
"test": "node ./test.js",
|
|
25
27
|
"copy-flow-typed": "cp -R ../../flow-typed .",
|
|
26
28
|
"build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm",
|
|
27
|
-
"prepublishOnly": "
|
|
29
|
+
"prepublishOnly": "npm run copy-flow-typed && npm run build",
|
|
28
30
|
"postpublish": "rm -r flow-typed dist/index.cjs"
|
|
29
31
|
},
|
|
30
32
|
"repository": {
|
|
@@ -32,15 +34,15 @@
|
|
|
32
34
|
"url": "git@github.com:mapbox/mapbox-gl-js.git"
|
|
33
35
|
},
|
|
34
36
|
"bin": {
|
|
35
|
-
"gl-style-migrate": "bin/gl-style-migrate",
|
|
36
|
-
"gl-style-validate": "bin/gl-style-validate",
|
|
37
|
-
"gl-style-format": "bin/gl-style-format",
|
|
38
|
-
"gl-style-composite": "bin/gl-style-composite"
|
|
37
|
+
"gl-style-migrate": "./bin/gl-style-migrate.js",
|
|
38
|
+
"gl-style-validate": "./bin/gl-style-validate.js",
|
|
39
|
+
"gl-style-format": "./bin/gl-style-format.js",
|
|
40
|
+
"gl-style-composite": "./bin/gl-style-composite.js"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"@mapbox/jsonlint-lines-primitives": "~2.0.2",
|
|
42
|
-
"@mapbox/unitbezier": "^0.0.0",
|
|
43
44
|
"@mapbox/point-geometry": "^0.1.0",
|
|
45
|
+
"@mapbox/unitbezier": "^0.0.0",
|
|
44
46
|
"csscolorparser": "~1.0.2",
|
|
45
47
|
"json-stringify-pretty-compact": "^2.0.0",
|
|
46
48
|
"minimist": "^1.2.5",
|
package/style-spec.js
CHANGED
|
@@ -57,6 +57,12 @@ export type StylePropertySpecification = {
|
|
|
57
57
|
length?: number,
|
|
58
58
|
transition: boolean,
|
|
59
59
|
default?: Array<string>
|
|
60
|
+
} | {
|
|
61
|
+
type: 'resolvedImage',
|
|
62
|
+
'property-type': ExpressionType,
|
|
63
|
+
expression?: ExpressionSpecification,
|
|
64
|
+
transition: boolean,
|
|
65
|
+
default?: string
|
|
60
66
|
};
|
|
61
67
|
|
|
62
68
|
import v8 from './reference/v8.json';
|
|
@@ -119,6 +125,3 @@ export {
|
|
|
119
125
|
validateMapboxApiSupported,
|
|
120
126
|
visit
|
|
121
127
|
};
|
|
122
|
-
|
|
123
|
-
validate.parsed = validate;
|
|
124
|
-
validate.latest = validate;
|
package/test.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-process-exit */
|
|
3
|
+
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import {execSync} from 'child_process';
|
|
6
|
+
import {createRequire} from 'module';
|
|
7
|
+
|
|
8
|
+
const packageJson = JSON.parse(fs.readFileSync('./package.json'));
|
|
9
|
+
|
|
10
|
+
process.on('unhandledRejection', error => {
|
|
11
|
+
// don't log `error` directly, because errors from child_process.execSync
|
|
12
|
+
// contain an (undocumented) `envPairs` with environment variable values
|
|
13
|
+
console.log(error.message || 'unhandledRejection');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const stylePath = require.resolve('mapbox-gl-styles/styles/basic-v9.json');
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
for (const bin in packageJson.bin) {
|
|
22
|
+
const script = packageJson.bin[bin];
|
|
23
|
+
const command = [script, stylePath].join(' ');
|
|
24
|
+
|
|
25
|
+
console.log(command);
|
|
26
|
+
execSync(command).toString();
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.log(error.message);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
package/util/color_spaces.js
CHANGED
|
@@ -79,7 +79,7 @@ function labToRgb(labColor: LABColor): Color {
|
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
function interpolateLab(from: LABColor, to: LABColor, t: number) {
|
|
82
|
+
function interpolateLab(from: LABColor, to: LABColor, t: number): LABColor {
|
|
83
83
|
return {
|
|
84
84
|
l: interpolateNumber(from.l, to.l, t),
|
|
85
85
|
a: interpolateNumber(from.a, to.a, t),
|
|
@@ -117,7 +117,7 @@ function interpolateHue(a: number, b: number, t: number) {
|
|
|
117
117
|
return a + t * (d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function interpolateHcl(from: HCLColor, to: HCLColor, t: number) {
|
|
120
|
+
function interpolateHcl(from: HCLColor, to: HCLColor, t: number): HCLColor {
|
|
121
121
|
return {
|
|
122
122
|
h: interpolateHue(from.h, to.h, t),
|
|
123
123
|
c: interpolateNumber(from.c, to.c, t),
|
package/util/extend.js
CHANGED
package/util/interpolate.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import Color from './color.js';
|
|
4
4
|
|
|
5
|
-
export function number(a: number, b: number, t: number) {
|
|
5
|
+
export function number(a: number, b: number, t: number): number {
|
|
6
6
|
return (a * (1 - t)) + (b * t);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function color(from: Color, to: Color, t: number) {
|
|
9
|
+
export function color(from: Color, to: Color, t: number): Color {
|
|
10
10
|
return new Color(
|
|
11
11
|
number(from.r, to.r, t),
|
|
12
12
|
number(from.g, to.g, t),
|
package/util/ref_properties.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// @flow
|
|
2
2
|
export default ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
// Turn jsonlint-lines-primitives objects into primitive objects
|
|
4
|
-
export function unbundle(value: mixed) {
|
|
4
|
+
export function unbundle(value: mixed): mixed {
|
|
5
5
|
if (value instanceof Number || value instanceof String || value instanceof Boolean) {
|
|
6
6
|
return value.valueOf();
|
|
7
7
|
} else {
|
package/validate/validate.js
CHANGED
|
@@ -11,7 +11,6 @@ import validateArray from './validate_array.js';
|
|
|
11
11
|
import validateBoolean from './validate_boolean.js';
|
|
12
12
|
import validateNumber from './validate_number.js';
|
|
13
13
|
import validateColor from './validate_color.js';
|
|
14
|
-
import validateConstants from './validate_constants.js';
|
|
15
14
|
import validateEnum from './validate_enum.js';
|
|
16
15
|
import validateFilter from './validate_filter.js';
|
|
17
16
|
import validateLayer from './validate_layer.js';
|
|
@@ -32,7 +31,6 @@ const VALIDATORS = {
|
|
|
32
31
|
'boolean': validateBoolean,
|
|
33
32
|
'number': validateNumber,
|
|
34
33
|
'color': validateColor,
|
|
35
|
-
'constants': validateConstants,
|
|
36
34
|
'enum': validateEnum,
|
|
37
35
|
'filter': validateFilter,
|
|
38
36
|
'function': validateFunction,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import validateStyle from './validate_style.min.js';
|
|
3
|
+
import {validateStyle} from './validate_style.min.js';
|
|
4
4
|
import {v8} from './style-spec.js';
|
|
5
5
|
import readStyle from './read_style.js';
|
|
6
6
|
import ValidationError from './error/validation_error.js';
|
|
7
7
|
import getType from './util/get_type.js';
|
|
8
8
|
|
|
9
|
+
import type {ValidationErrors} from './validate_style.min.js';
|
|
10
|
+
|
|
9
11
|
const SUPPORTED_SPEC_VERSION = 8;
|
|
10
12
|
const MAX_SOURCES_IN_STYLE = 15;
|
|
11
13
|
|
|
@@ -22,7 +24,7 @@ function getSourceCount(source: Object): number {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
function getAllowedKeyErrors(obj: Object, keys: Array<*>, path: ?string): Array
|
|
27
|
+
function getAllowedKeyErrors(obj: Object, keys: Array<*>, path: ?string): Array<ValidationError> {
|
|
26
28
|
const allowed = new Set(keys);
|
|
27
29
|
const errors = [];
|
|
28
30
|
Object.keys(obj).forEach(k => {
|
|
@@ -35,7 +37,7 @@ function getAllowedKeyErrors(obj: Object, keys: Array<*>, path: ?string): Array<
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const acceptedSourceTypes = new Set(["vector", "raster", "raster-dem"]);
|
|
38
|
-
function getSourceErrors(source: Object, i: number): Array
|
|
40
|
+
function getSourceErrors(source: Object, i: number): Array<ValidationError> {
|
|
39
41
|
const errors = [];
|
|
40
42
|
|
|
41
43
|
/*
|
|
@@ -66,7 +68,7 @@ function getSourceErrors(source: Object, i: number): Array<?ValidationError> {
|
|
|
66
68
|
return errors;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
function getSourcesErrors(sources: Object): Array
|
|
71
|
+
function getSourcesErrors(sources: Object): Array<ValidationError> {
|
|
70
72
|
const errors = [];
|
|
71
73
|
let count = 0;
|
|
72
74
|
|
|
@@ -88,7 +90,7 @@ function getSourcesErrors(sources: Object): Array<?ValidationError> {
|
|
|
88
90
|
return errors;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
function getRootErrors(style: Object, specKeys: Array<any>): Array
|
|
93
|
+
function getRootErrors(style: Object, specKeys: Array<any>): Array<ValidationError> {
|
|
92
94
|
const errors = [];
|
|
93
95
|
|
|
94
96
|
/*
|
|
@@ -165,7 +167,7 @@ function getRootErrors(style: Object, specKeys: Array<any>): Array<?ValidationEr
|
|
|
165
167
|
* var validateMapboxApiSupported = require('mapbox-gl-style-spec/lib/validate_style_mapbox_api_supported.js');
|
|
166
168
|
* var errors = validateMapboxApiSupported(style);
|
|
167
169
|
*/
|
|
168
|
-
export default function validateMapboxApiSupported(style: Object):
|
|
170
|
+
export default function validateMapboxApiSupported(style: Object): ValidationErrors {
|
|
169
171
|
let s = style;
|
|
170
172
|
try {
|
|
171
173
|
s = readStyle(s);
|
package/validate_style.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import validateStyleMin from './validate_style.min.js';
|
|
1
|
+
// @flow
|
|
2
|
+
import {validateStyle as validateStyleMin} from './validate_style.min.js';
|
|
3
3
|
import {v8} from './style-spec.js';
|
|
4
4
|
import readStyle from './read_style.js';
|
|
5
5
|
|
|
6
|
+
import type {ValidationErrors} from './validate_style.min.js';
|
|
7
|
+
import type {StyleSpecification} from './types.js';
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Validate a Mapbox GL style against the style specification.
|
|
8
11
|
*
|
|
@@ -19,7 +22,7 @@ import readStyle from './read_style.js';
|
|
|
19
22
|
* var errors = validate(style);
|
|
20
23
|
*/
|
|
21
24
|
|
|
22
|
-
export default function validateStyle(style, styleSpec = v8) {
|
|
25
|
+
export default function validateStyle(style: StyleSpecification | string | Buffer, styleSpec: Object = v8): ValidationErrors {
|
|
23
26
|
let s = style;
|
|
24
27
|
|
|
25
28
|
try {
|
|
@@ -31,9 +34,11 @@ export default function validateStyle(style, styleSpec = v8) {
|
|
|
31
34
|
return validateStyleMin(s, styleSpec);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export {
|
|
38
|
+
validateSource as source,
|
|
39
|
+
validateLight as light,
|
|
40
|
+
validateLayer as layer,
|
|
41
|
+
validateFilter as filter,
|
|
42
|
+
validatePaintProperty as paintProperty,
|
|
43
|
+
validateLayoutProperty as layoutProperty
|
|
44
|
+
} from './validate_style.min.js';
|