@mapbox/mapbox-gl-style-spec 13.24.0-alpha.3 → 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/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 +11 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +11 -50
- package/dist/index.es.js.map +1 -1
- package/empty.js +9 -28
- package/expression/definitions/in.js +1 -1
- package/feature_filter/index.js +1 -1
- package/flow-typed/gl-matrix.js +1 -0
- package/group_by_layout.js +8 -10
- package/package.json +9 -7
- package/style-spec.js +0 -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
|
}
|
|
@@ -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/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;
|
package/flow-typed/gl-matrix.js
CHANGED
|
@@ -38,6 +38,7 @@ declare module "gl-matrix" {
|
|
|
38
38
|
div<T: Vec3>(T, Vec3, Vec3): T,
|
|
39
39
|
min<T: Vec3>(T, Vec3, Vec3): T,
|
|
40
40
|
max<T: Vec3>(T, Vec3, Vec3): T,
|
|
41
|
+
lerp<T: Vec3>(T, Vec3, Vec3, number): T,
|
|
41
42
|
transformQuat<T: Vec3>(T, Vec3, Quat): T,
|
|
42
43
|
transformMat3<T: Vec3>(T, Vec3, Mat3): T,
|
|
43
44
|
transformMat4<T: Vec3>(T, Vec3, Mat4): T
|
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
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';
|
package/validate_style.min.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import validateConstants from './validate/validate_constants.js';
|
|
1
|
+
// @flow
|
|
3
2
|
import validate from './validate/validate.js';
|
|
4
3
|
import latestStyleSpec from './reference/latest.js';
|
|
5
4
|
import validateGlyphsURL from './validate/validate_glyphs_url.js';
|
|
6
5
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
6
|
+
import _validateSource from './validate/validate_source.js';
|
|
7
|
+
import _validateLight from './validate/validate_light.js';
|
|
8
|
+
import _validateTerrain from './validate/validate_terrain.js';
|
|
9
|
+
import _validateFog from './validate/validate_fog.js';
|
|
10
|
+
import _validateLayer from './validate/validate_layer.js';
|
|
11
|
+
import _validateFilter from './validate/validate_filter.js';
|
|
12
|
+
import _validatePaintProperty from './validate/validate_paint_property.js';
|
|
13
|
+
import _validateLayoutProperty from './validate/validate_layout_property.js';
|
|
14
|
+
|
|
15
|
+
import type {StyleSpecification} from './types.js';
|
|
16
|
+
|
|
17
|
+
export type ValidationError = {
|
|
18
|
+
message: string;
|
|
19
|
+
identifier?: ?string;
|
|
20
|
+
line?: ?number;
|
|
21
|
+
};
|
|
22
|
+
export type ValidationErrors = $ReadOnlyArray<ValidationError>;
|
|
23
|
+
export type Validator = (Object) => ValidationErrors;
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* Validate a Mapbox GL style against the style specification. This entrypoint,
|
|
@@ -28,11 +37,9 @@ import validateLayoutProperty from './validate/validate_layout_property.js';
|
|
|
28
37
|
* var validate = require('mapbox-gl-style-spec/lib/validate_style.min');
|
|
29
38
|
* var errors = validate(style);
|
|
30
39
|
*/
|
|
31
|
-
function
|
|
40
|
+
export function validateStyle(style: StyleSpecification, styleSpec: Object = latestStyleSpec): ValidationErrors {
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
errors = errors.concat(validate({
|
|
42
|
+
const errors = validate({
|
|
36
43
|
key: '',
|
|
37
44
|
value: style,
|
|
38
45
|
valueSpec: styleSpec.$root,
|
|
@@ -40,43 +47,21 @@ function validateStyleMin(style, styleSpec = latestStyleSpec) {
|
|
|
40
47
|
style,
|
|
41
48
|
objectElementValidators: {
|
|
42
49
|
glyphs: validateGlyphsURL,
|
|
43
|
-
'*'()
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
50
|
+
'*': () => []
|
|
46
51
|
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
if (style.constants) {
|
|
50
|
-
errors = errors.concat(validateConstants({
|
|
51
|
-
key: 'constants',
|
|
52
|
-
value: style.constants,
|
|
53
|
-
style,
|
|
54
|
-
styleSpec
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
|
|
52
|
+
});
|
|
58
53
|
return sortErrors(errors);
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
export const validateSource: Validator = opts => sortErrors(_validateSource(opts));
|
|
57
|
+
export const validateLight: Validator = opts => sortErrors(_validateLight(opts));
|
|
58
|
+
export const validateTerrain: Validator = opts => sortErrors(_validateTerrain(opts));
|
|
59
|
+
export const validateFog: Validator = opts => sortErrors(_validateFog(opts));
|
|
60
|
+
export const validateLayer: Validator = opts => sortErrors(_validateLayer(opts));
|
|
61
|
+
export const validateFilter: Validator = opts => sortErrors(_validateFilter(opts));
|
|
62
|
+
export const validatePaintProperty: Validator = opts => sortErrors(_validatePaintProperty(opts));
|
|
63
|
+
export const validateLayoutProperty: Validator = opts => sortErrors(_validateLayoutProperty(opts));
|
|
69
64
|
|
|
70
65
|
function sortErrors(errors) {
|
|
71
|
-
return
|
|
72
|
-
return a.line - b.line;
|
|
73
|
-
});
|
|
66
|
+
return errors.slice().sort((a, b) => a.line - b.line);
|
|
74
67
|
}
|
|
75
|
-
|
|
76
|
-
function wrapCleanErrors(inner) {
|
|
77
|
-
return function(...args) {
|
|
78
|
-
return sortErrors(inner.apply(this, args));
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default validateStyleMin;
|
package/bin/gl-style-composite
DELETED
package/bin/gl-style-migrate
DELETED
package/declass.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import extend from './util/extend.js';
|
|
3
|
-
|
|
4
|
-
export default declassStyle;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Returns a new style with the given 'paint classes' merged into each layer's
|
|
8
|
-
* main `paint` definiton, and with all `paint.*` properties removed.
|
|
9
|
-
*
|
|
10
|
-
* @private
|
|
11
|
-
* @param {Object} style A style JSON object.
|
|
12
|
-
* @param {Array<string>} classes An array of paint classes to apply, in order.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* var declass = require('mapbox-gl-style-spec/lib/declass')
|
|
16
|
-
* var baseStyle = { ... style with a 'paint.night' property in some layers ... }
|
|
17
|
-
* var nightStyle = declass(baseStyle, ['night'])
|
|
18
|
-
* // nightStyle now has each layer's `paint.night` properties merged in to the
|
|
19
|
-
* // main `paint` property.
|
|
20
|
-
*/
|
|
21
|
-
function declassStyle(style, classes) {
|
|
22
|
-
return extend({}, style, {
|
|
23
|
-
layers: style.layers.map((layer) => {
|
|
24
|
-
const result = classes.reduce(declassLayer, layer);
|
|
25
|
-
|
|
26
|
-
// strip away all `paint.CLASS` definitions
|
|
27
|
-
for (const key in result) {
|
|
28
|
-
if (/paint\..*/.test(key)) {
|
|
29
|
-
delete result[key];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return result;
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function declassLayer(layer, klass) {
|
|
39
|
-
return extend({}, layer, {
|
|
40
|
-
paint: extend({}, layer.paint, layer[`paint.${klass}`])
|
|
41
|
-
});
|
|
42
|
-
}
|
package/validate/latest.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import validateStyle from '../validate_style.min.js';
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Validate a style against the latest specification. This method is optimized
|
|
6
|
-
* to keep its bundle size small by refraining from requiring jslint or old
|
|
7
|
-
* style spec versions.
|
|
8
|
-
* @see validateStyleMin
|
|
9
|
-
* @deprecated This file exists for backwards compatibility and will be dropped in the next minor release.
|
|
10
|
-
*/
|
|
11
|
-
export default validateStyle;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import ValidationError from '../error/validation_error.js';
|
|
3
|
-
|
|
4
|
-
export default function validateConstants(options) {
|
|
5
|
-
const key = options.key;
|
|
6
|
-
const constants = options.value;
|
|
7
|
-
|
|
8
|
-
if (constants) {
|
|
9
|
-
return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];
|
|
10
|
-
} else {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
}
|