@mapbox/mapbox-gl-style-spec 14.4.0 → 14.5.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/bin/gl-style-composite.js +0 -5
- package/bin/gl-style-format.js +0 -5
- package/bin/gl-style-migrate.js +0 -5
- package/bin/gl-style-validate.js +0 -5
- package/{composite.js → composite.ts} +1 -1
- package/data/{extent.js → extent.ts} +0 -2
- package/{deref.js → deref.ts} +7 -9
- package/{diff.js → diff.ts} +44 -21
- package/dist/index.cjs +794 -1226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1746 -0
- package/dist/index.es.js +794 -1226
- package/dist/index.es.js.map +1 -1
- package/{empty.js → empty.ts} +1 -2
- package/error/{parsing_error.js → parsing_error.ts} +0 -2
- package/error/{validation_error.js → validation_error.ts} +5 -5
- package/expression/{compound_expression.js → compound_expression.ts} +29 -19
- package/expression/definitions/{assertion.js → assertion.ts} +16 -13
- package/expression/definitions/{at.js → at.ts} +12 -13
- package/expression/definitions/{case.js → case.ts} +12 -11
- package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
- package/expression/definitions/{coercion.js → coercion.ts} +21 -20
- package/expression/definitions/{collator.js → collator.ts} +11 -11
- package/expression/definitions/{comparison.js → comparison.ts} +30 -24
- package/expression/definitions/{config.js → config.ts} +16 -16
- package/expression/definitions/{distance.js → distance.ts} +60 -52
- package/expression/definitions/{format.js → format.ts} +26 -15
- package/expression/definitions/{image.js → image.ts} +12 -12
- package/expression/definitions/{in.js → in.ts} +22 -13
- package/expression/definitions/{index.js → index.ts} +70 -83
- package/expression/definitions/{index_of.js → index_of.ts} +24 -15
- package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
- package/expression/definitions/{length.js → length.ts} +11 -10
- package/expression/definitions/{let.js → let.ts} +10 -7
- package/expression/definitions/{literal.js → literal.ts} +11 -12
- package/expression/definitions/{match.js → match.ts} +25 -15
- package/expression/definitions/{number_format.js → number_format.ts} +10 -10
- package/expression/definitions/{slice.js → slice.ts} +23 -15
- package/expression/definitions/{step.js → step.ts} +14 -12
- package/expression/definitions/{var.js → var.ts} +5 -7
- package/expression/definitions/{within.js → within.ts} +41 -29
- package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
- package/expression/expression.ts +29 -0
- package/expression/{index.js → index.ts} +208 -110
- package/expression/{is_constant.js → is_constant.ts} +5 -7
- package/expression/{parsing_context.js → parsing_context.ts} +47 -34
- package/expression/{parsing_error.js → parsing_error.ts} +0 -2
- package/expression/{runtime_error.js → runtime_error.ts} +0 -2
- package/expression/{scope.js → scope.ts} +5 -5
- package/expression/{stops.js → stops.ts} +2 -4
- package/expression/types/{collator.js → collator.ts} +1 -3
- package/expression/types/{formatted.js → formatted.ts} +8 -7
- package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
- package/expression/{types.js → types.ts} +53 -45
- package/expression/{values.js → values.ts} +12 -12
- package/feature_filter/{convert.js → convert.ts} +19 -18
- package/feature_filter/{index.js → index.ts} +39 -21
- package/{format.js → format.ts} +3 -3
- package/function/{convert.js → convert.ts} +44 -44
- package/function/{index.js → index.ts} +12 -12
- package/{group_by_layout.js → group_by_layout.ts} +11 -8
- package/migrate/{expressions.js → expressions.ts} +7 -16
- package/migrate/{v8.js → v8.ts} +2 -2
- package/migrate/{v9.js → v9.ts} +2 -2
- package/{migrate.js → migrate.ts} +3 -3
- package/package.json +19 -18
- package/{read_style.js → read_style.ts} +5 -4
- package/reference/latest.ts +5 -0
- package/reference/v8.json +264 -7
- package/rollup.config.js +6 -24
- package/{style-spec.js → style-spec.ts} +41 -36
- package/test.js +3 -2
- package/types/config_options.ts +13 -0
- package/types/lut.ts +7 -0
- package/types/tile_id.ts +5 -0
- package/{types.js → types.ts} +527 -165
- package/util/{color.js → color.ts} +89 -3
- package/util/{color_spaces.js → color_spaces.ts} +12 -14
- package/util/{deep_equal.js → deep_equal.ts} +1 -3
- package/util/{extend.js → extend.ts} +1 -3
- package/util/{geometry_util.js → geometry_util.ts} +23 -11
- package/util/{get_type.js → get_type.ts} +1 -3
- package/util/{interpolate.js → interpolate.ts} +1 -3
- package/util/{properties.js → properties.ts} +5 -4
- package/util/{random.js → random.ts} +0 -2
- package/util/{ref_properties.js → ref_properties.ts} +0 -1
- package/util/{result.js → result.ts} +7 -5
- package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
- package/validate/{validate.js → validate.ts} +33 -35
- package/validate/{validate_array.js → validate_array.ts} +5 -7
- package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
- package/validate/{validate_color.js → validate_color.ts} +3 -5
- package/validate/{validate_enum.js → validate_enum.ts} +4 -5
- package/validate/{validate_expression.js → validate_expression.ts} +7 -9
- package/validate/{validate_filter.js → validate_filter.ts} +16 -12
- package/validate/{validate_fog.js → validate_fog.ts} +4 -6
- package/validate/validate_formatted.ts +13 -0
- package/validate/{validate_function.js → validate_function.ts} +14 -16
- package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
- package/validate/validate_image.ts +13 -0
- package/validate/{validate_import.js → validate_import.ts} +6 -8
- package/validate/{validate_layer.js → validate_layer.ts} +17 -15
- package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
- package/validate/{validate_light.js → validate_light.ts} +4 -6
- package/validate/{validate_lights.js → validate_lights.ts} +7 -9
- package/validate/{validate_model.js → validate_model.ts} +4 -6
- package/validate/{validate_number.js → validate_number.ts} +4 -6
- package/validate/{validate_object.js → validate_object.ts} +5 -8
- package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
- package/validate/{validate_projection.js → validate_projection.ts} +4 -6
- package/validate/{validate_property.js → validate_property.ts} +15 -15
- package/validate/{validate_source.js → validate_source.ts} +16 -13
- package/validate/validate_string.ts +16 -0
- package/validate/validate_style.ts +33 -0
- package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
- package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
- package/{validate_style.min.js → validate_style.min.ts} +20 -21
- package/{validate_style.js → validate_style.ts} +9 -9
- package/{visit.js → visit.ts} +22 -17
- package/.eslintrc +0 -10
- package/expression/expression.js +0 -28
- package/flow-typed/cheap-ruler.js +0 -25
- package/flow-typed/geojson.js +0 -44
- package/flow-typed/gl-matrix.js +0 -119
- package/flow-typed/gl.js +0 -5
- package/flow-typed/intl.js +0 -58
- package/flow-typed/kdbush.js +0 -9
- package/flow-typed/mapbox-gl-supported.js +0 -16
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -26
- package/flow-typed/point-geometry.js +0 -46
- package/flow-typed/potpack.js +0 -13
- package/flow-typed/tiny-sdf.js +0 -31
- package/flow-typed/tracked_parameters_proxy.js +0 -82
- package/flow-typed/vector-tile.js +0 -49
- package/flow-typed/webgl2.js +0 -41
- package/reference/latest.js +0 -7
- package/validate/validate_formatted.js +0 -15
- package/validate/validate_image.js +0 -15
- package/validate/validate_string.js +0 -18
- package/validate/validate_style.js +0 -29
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
|
|
5
|
-
import type {StylePropertySpecification} from '../style-spec
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
base: number;
|
|
13
|
-
property: string;
|
|
14
|
-
type: 'identity' | 'exponential' | 'interval' | 'categorical';
|
|
15
|
-
colorSpace: 'rgb' | 'lab' | 'hcl';
|
|
16
|
-
default: mixed;
|
|
17
|
-
};
|
|
3
|
+
import type {StylePropertySpecification} from '../style-spec';
|
|
4
|
+
import type {
|
|
5
|
+
FunctionSpecification,
|
|
6
|
+
PropertyFunctionStop,
|
|
7
|
+
ZoomAndPropertyFunctionStop,
|
|
8
|
+
ExpressionSpecification,
|
|
9
|
+
} from '../types';
|
|
18
10
|
|
|
19
|
-
function convertLiteral(value:
|
|
11
|
+
function convertLiteral(value: unknown) {
|
|
20
12
|
return typeof value === 'object' ? ['literal', value] : value;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
export default function convertFunction(parameters:
|
|
15
|
+
export default function convertFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification {
|
|
24
16
|
let stops = parameters.stops;
|
|
25
17
|
if (!stops) {
|
|
26
18
|
// identity function
|
|
@@ -36,19 +28,19 @@ export default function convertFunction(parameters: FunctionParameters, property
|
|
|
36
28
|
return [stop[0], convertTokenString(stop[1])];
|
|
37
29
|
}
|
|
38
30
|
return [stop[0], convertLiteral(stop[1])];
|
|
39
|
-
});
|
|
31
|
+
}) as FunctionSpecification<T>['stops'];
|
|
40
32
|
|
|
41
33
|
if (zoomAndFeatureDependent) {
|
|
42
|
-
return convertZoomAndPropertyFunction(parameters, propertySpec, stops);
|
|
34
|
+
return convertZoomAndPropertyFunction(parameters, propertySpec, stops as Array<ZoomAndPropertyFunctionStop<T>>);
|
|
43
35
|
} else if (zoomDependent) {
|
|
44
|
-
return convertZoomFunction(parameters, propertySpec, stops);
|
|
36
|
+
return convertZoomFunction(parameters, propertySpec, stops as PropertyFunctionStop<T>[]);
|
|
45
37
|
} else {
|
|
46
|
-
return convertPropertyFunction(parameters, propertySpec, stops);
|
|
38
|
+
return convertPropertyFunction(parameters, propertySpec, stops as PropertyFunctionStop<T>[]);
|
|
47
39
|
}
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
function convertIdentityFunction(parameters:
|
|
51
|
-
const get = ['get', parameters.property];
|
|
42
|
+
function convertIdentityFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification {
|
|
43
|
+
const get: ExpressionSpecification = ['get', parameters.property];
|
|
52
44
|
|
|
53
45
|
if (parameters.default === undefined) {
|
|
54
46
|
// By default, expressions for string-valued properties get coerced. To preserve
|
|
@@ -63,7 +55,7 @@ function convertIdentityFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
63
55
|
parameters.default
|
|
64
56
|
];
|
|
65
57
|
} else {
|
|
66
|
-
const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];
|
|
58
|
+
const expression: ExpressionSpecification = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];
|
|
67
59
|
if (propertySpec.type === 'array') {
|
|
68
60
|
expression.splice(1, 0, propertySpec.value, propertySpec.length || null);
|
|
69
61
|
}
|
|
@@ -71,7 +63,7 @@ function convertIdentityFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
71
63
|
}
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
function getInterpolateOperator(parameters:
|
|
66
|
+
function getInterpolateOperator<T>(parameters: FunctionSpecification<T>) {
|
|
75
67
|
switch (parameters.colorSpace) {
|
|
76
68
|
case 'hcl': return 'interpolate-hcl';
|
|
77
69
|
case 'lab': return 'interpolate-lab';
|
|
@@ -79,9 +71,13 @@ function getInterpolateOperator(parameters: FunctionParameters) {
|
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
73
|
|
|
82
|
-
function convertZoomAndPropertyFunction
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
function convertZoomAndPropertyFunction<T>(
|
|
75
|
+
parameters: FunctionSpecification<T>,
|
|
76
|
+
propertySpec: StylePropertySpecification,
|
|
77
|
+
stops: Array<ZoomAndPropertyFunctionStop<T>>,
|
|
78
|
+
): ExpressionSpecification {
|
|
79
|
+
const featureFunctionParameters: Record<string, any> = {};
|
|
80
|
+
const featureFunctionStops: Record<string, any> = {};
|
|
85
81
|
const zoomStops = [];
|
|
86
82
|
for (let s = 0; s < stops.length; s++) {
|
|
87
83
|
const stop = stops[s];
|
|
@@ -103,9 +99,9 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
103
99
|
// function is determined directly from the style property specification
|
|
104
100
|
// for which it's being used: linear for interpolatable properties, step
|
|
105
101
|
// otherwise.
|
|
106
|
-
const functionType = getFunctionType({}
|
|
102
|
+
const functionType = getFunctionType({} as FunctionSpecification<unknown>, propertySpec);
|
|
107
103
|
if (functionType === 'exponential') {
|
|
108
|
-
const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];
|
|
104
|
+
const expression: ExpressionSpecification = [getInterpolateOperator(parameters), ['linear'], ['zoom']];
|
|
109
105
|
|
|
110
106
|
for (const z of zoomStops) {
|
|
111
107
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
@@ -114,7 +110,7 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
114
110
|
|
|
115
111
|
return expression;
|
|
116
112
|
} else {
|
|
117
|
-
const expression = ['step', ['zoom']];
|
|
113
|
+
const expression: ExpressionSpecification = ['step', ['zoom']];
|
|
118
114
|
|
|
119
115
|
for (const z of zoomStops) {
|
|
120
116
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
@@ -127,12 +123,12 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
function coalesce(a:
|
|
126
|
+
function coalesce(a: unknown, b: unknown) {
|
|
131
127
|
if (a !== undefined) return a;
|
|
132
128
|
if (b !== undefined) return b;
|
|
133
129
|
}
|
|
134
130
|
|
|
135
|
-
function getFallback(parameters:
|
|
131
|
+
function getFallback<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification) {
|
|
136
132
|
const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));
|
|
137
133
|
|
|
138
134
|
/*
|
|
@@ -147,12 +143,16 @@ function getFallback(parameters: FunctionParameters, propertySpec: StyleProperty
|
|
|
147
143
|
return defaultValue;
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
function convertPropertyFunction
|
|
146
|
+
function convertPropertyFunction<T>(
|
|
147
|
+
parameters: FunctionSpecification<T>,
|
|
148
|
+
propertySpec: StylePropertySpecification,
|
|
149
|
+
stops: Array<PropertyFunctionStop<T>>,
|
|
150
|
+
): ExpressionSpecification {
|
|
151
151
|
const type = getFunctionType(parameters, propertySpec);
|
|
152
|
-
const get = ['get', parameters.property];
|
|
152
|
+
const get: ExpressionSpecification = ['get', parameters.property];
|
|
153
153
|
if (type === 'categorical' && typeof stops[0][0] === 'boolean') {
|
|
154
154
|
assert(parameters.stops.length > 0 && parameters.stops.length <= 2);
|
|
155
|
-
const expression = ['case'];
|
|
155
|
+
const expression: ExpressionSpecification = ['case'];
|
|
156
156
|
for (const stop of stops) {
|
|
157
157
|
expression.push(['==', get, stop[0]], stop[1]);
|
|
158
158
|
}
|
|
@@ -160,14 +160,14 @@ function convertPropertyFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
160
160
|
expression.push(getFallback(parameters, propertySpec));
|
|
161
161
|
return expression;
|
|
162
162
|
} else if (type === 'categorical') {
|
|
163
|
-
const expression = ['match', get];
|
|
163
|
+
const expression: ExpressionSpecification = ['match', get];
|
|
164
164
|
for (const stop of stops) {
|
|
165
165
|
appendStopPair(expression, stop[0], stop[1], false);
|
|
166
166
|
}
|
|
167
167
|
expression.push(getFallback(parameters, propertySpec));
|
|
168
168
|
return expression;
|
|
169
169
|
} else if (type === 'interval') {
|
|
170
|
-
const expression = ['step', ['number', get]];
|
|
170
|
+
const expression: ExpressionSpecification = ['step', ['number', get]];
|
|
171
171
|
for (const stop of stops) {
|
|
172
172
|
appendStopPair(expression, stop[0], stop[1], true);
|
|
173
173
|
}
|
|
@@ -180,7 +180,7 @@ function convertPropertyFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
180
180
|
];
|
|
181
181
|
} else if (type === 'exponential') {
|
|
182
182
|
const base = parameters.base !== undefined ? parameters.base : 1;
|
|
183
|
-
const expression = [
|
|
183
|
+
const expression: ExpressionSpecification = [
|
|
184
184
|
getInterpolateOperator(parameters),
|
|
185
185
|
base === 1 ? ["linear"] : ["exponential", base],
|
|
186
186
|
["number", get]
|
|
@@ -200,7 +200,7 @@ function convertPropertyFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
function convertZoomFunction(parameters:
|
|
203
|
+
function convertZoomFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification, stops: Array<PropertyFunctionStop<T>>, input: Array<string> = ['zoom']) {
|
|
204
204
|
const type = getFunctionType(parameters, propertySpec);
|
|
205
205
|
let expression;
|
|
206
206
|
let isStep = false;
|
|
@@ -232,7 +232,7 @@ function fixupDegenerateStepCurve(expression: ExpressionSpecification) {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
function appendStopPair(curve: ExpressionSpecification, input:
|
|
235
|
+
function appendStopPair(curve: ExpressionSpecification, input: unknown, output: unknown, isStep: boolean) {
|
|
236
236
|
// Skip duplicate stop values. They were not validated for functions, but they are for expressions.
|
|
237
237
|
// https://github.com/mapbox/mapbox-gl-js/issues/4107
|
|
238
238
|
if (curve.length > 3 && input === curve[curve.length - 2]) {
|
|
@@ -245,18 +245,18 @@ function appendStopPair(curve: ExpressionSpecification, input: mixed, output: mi
|
|
|
245
245
|
curve.push(output);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
function getFunctionType(parameters:
|
|
248
|
+
function getFunctionType<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): string {
|
|
249
249
|
if (parameters.type) {
|
|
250
250
|
return parameters.type;
|
|
251
251
|
} else {
|
|
252
252
|
assert(propertySpec.expression);
|
|
253
|
-
return (propertySpec.expression
|
|
253
|
+
return (propertySpec.expression as any).interpolated ? 'exponential' : 'interval';
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
// "String with {name} token" => ["concat", "String with ", ["get", "name"], " token"]
|
|
258
258
|
export function convertTokenString(s: string): string | ExpressionSpecification {
|
|
259
|
-
const result = ['concat'];
|
|
259
|
+
const result: ExpressionSpecification = ['concat'];
|
|
260
260
|
const re = /{([^{}]+)}/g;
|
|
261
261
|
let pos = 0;
|
|
262
262
|
for (let match = re.exec(s); match !== null; match = re.exec(s)) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
import * as colorSpaces from '../util/color_spaces
|
|
4
|
-
import Color from '../util/color
|
|
5
|
-
import extend from '../util/extend
|
|
6
|
-
import getType from '../util/get_type
|
|
7
|
-
import * as interpolate from '../util/interpolate
|
|
8
|
-
import Interpolate from '../expression/definitions/interpolate
|
|
9
|
-
import Formatted from '../expression/types/formatted
|
|
10
|
-
import ResolvedImage from '../expression/types/resolved_image
|
|
11
|
-
import {supportsInterpolation} from '../util/properties
|
|
12
|
-
import {findStopLessThanOrEqualTo} from '../expression/stops
|
|
3
|
+
import * as colorSpaces from '../util/color_spaces';
|
|
4
|
+
import Color from '../util/color';
|
|
5
|
+
import extend from '../util/extend';
|
|
6
|
+
import getType from '../util/get_type';
|
|
7
|
+
import * as interpolate from '../util/interpolate';
|
|
8
|
+
import Interpolate from '../expression/definitions/interpolate';
|
|
9
|
+
import Formatted from '../expression/types/formatted';
|
|
10
|
+
import ResolvedImage from '../expression/types/resolved_image';
|
|
11
|
+
import {supportsInterpolation} from '../util/properties';
|
|
12
|
+
import {findStopLessThanOrEqualTo} from '../expression/stops';
|
|
13
13
|
|
|
14
14
|
export function isFunction(value) {
|
|
15
15
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -72,7 +72,7 @@ export function createFunction(parameters, propertySpec) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (zoomAndFeatureDependent) {
|
|
75
|
-
const featureFunctions = {};
|
|
75
|
+
const featureFunctions: Record<string, any> = {};
|
|
76
76
|
const zoomStops = [];
|
|
77
77
|
for (let s = 0; s < parameters.stops.length; s++) {
|
|
78
78
|
const stop = parameters.stops[s];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type {LayerSpecification} from './types';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import refProperties from './util/ref_properties.js';
|
|
3
|
+
import refProperties from './util/ref_properties';
|
|
6
4
|
|
|
7
5
|
function stringify(obj: any) {
|
|
8
6
|
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
|
|
@@ -18,7 +16,7 @@ function stringify(obj: any) {
|
|
|
18
16
|
|
|
19
17
|
let str = '{';
|
|
20
18
|
for (const key of Object.keys(obj).sort()) {
|
|
21
|
-
str += `${key}:${stringify((obj
|
|
19
|
+
str += `${key}:${stringify((obj)[key])},`;
|
|
22
20
|
}
|
|
23
21
|
return `${str}}`;
|
|
24
22
|
}
|
|
@@ -26,7 +24,7 @@ function stringify(obj: any) {
|
|
|
26
24
|
function getKey(layer: LayerSpecification) {
|
|
27
25
|
let key = '';
|
|
28
26
|
for (const k of refProperties) {
|
|
29
|
-
key += `/${stringify((layer
|
|
27
|
+
key += `/${stringify((layer as any)[k])}`;
|
|
30
28
|
}
|
|
31
29
|
return key;
|
|
32
30
|
}
|
|
@@ -46,8 +44,13 @@ function getKey(layer: LayerSpecification) {
|
|
|
46
44
|
* @param {Object} [cachedKeys] - an object to keep already calculated keys.
|
|
47
45
|
* @returns {Array<Array<Layer>>}
|
|
48
46
|
*/
|
|
49
|
-
export default function groupByLayout(
|
|
50
|
-
|
|
47
|
+
export default function groupByLayout(
|
|
48
|
+
layers: Array<LayerSpecification>,
|
|
49
|
+
cachedKeys: {
|
|
50
|
+
[id: string]: string;
|
|
51
|
+
},
|
|
52
|
+
): Array<Array<LayerSpecification>> {
|
|
53
|
+
const groups: Record<string, any> = {};
|
|
51
54
|
|
|
52
55
|
for (let i = 0; i < layers.length; i++) {
|
|
53
56
|
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import {eachLayer, eachProperty} from '../visit';
|
|
2
|
+
import {isExpression} from '../expression/index';
|
|
3
|
+
import convertFunction, {convertTokenString} from '../function/convert';
|
|
4
|
+
import convertFilter from '../feature_filter/convert';
|
|
2
5
|
|
|
3
|
-
import {
|
|
4
|
-
eachLayer,
|
|
5
|
-
eachProperty
|
|
6
|
-
} from '../visit.js';
|
|
7
|
-
import {isExpression} from '../expression/index.js';
|
|
8
|
-
import convertFunction, {convertTokenString} from '../function/convert.js';
|
|
9
|
-
import convertFilter from '../feature_filter/convert.js';
|
|
10
|
-
|
|
11
|
-
import type {StyleSpecification} from '../types.js';
|
|
6
|
+
import type {StyleSpecification, FunctionSpecification} from '../types';
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
9
|
* Migrate the given style object in place to use expressions. Specifically,
|
|
@@ -20,17 +15,14 @@ export default function(style: StyleSpecification): StyleSpecification {
|
|
|
20
15
|
|
|
21
16
|
eachLayer(style, (layer) => {
|
|
22
17
|
if (layer.filter) {
|
|
23
|
-
layer.filter = (convertFilter(layer.filter)
|
|
18
|
+
layer.filter = (convertFilter(layer.filter) as any);
|
|
24
19
|
}
|
|
25
20
|
});
|
|
26
21
|
|
|
27
22
|
eachProperty(style, {paint: true, layout: true}, ({path, value, reference, set}) => {
|
|
28
23
|
if (isExpression(value)) return;
|
|
29
24
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
30
|
-
|
|
31
|
-
// $FlowFixMe[incompatible-call]
|
|
32
|
-
// $FlowFixMe[incompatible-variance]
|
|
33
|
-
set(convertFunction(value, reference));
|
|
25
|
+
set(convertFunction(value as FunctionSpecification<unknown>, reference));
|
|
34
26
|
converted.push(path.join('.'));
|
|
35
27
|
} else if (reference.tokens && typeof value === 'string') {
|
|
36
28
|
set(convertTokenString(value));
|
|
@@ -39,4 +31,3 @@ export default function(style: StyleSpecification): StyleSpecification {
|
|
|
39
31
|
|
|
40
32
|
return style;
|
|
41
33
|
}
|
|
42
|
-
|
package/migrate/{v8.js → v8.ts}
RENAMED
package/migrate/{v9.js → v9.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
import migrateToV8 from './migrate/v8
|
|
4
|
-
import migrateToExpressions from './migrate/expressions
|
|
3
|
+
import migrateToV8 from './migrate/v8';
|
|
4
|
+
import migrateToExpressions from './migrate/expressions';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Migrate a Mapbox GL Style to the latest version.
|
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapbox/mapbox-gl-style-spec",
|
|
3
|
+
"version": "14.5.0",
|
|
3
4
|
"description": "a specification for mapbox gl styles",
|
|
4
|
-
"version": "14.4.0",
|
|
5
5
|
"author": "Mapbox",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git@github.com:mapbox/mapbox-gl-js.git"
|
|
10
|
+
},
|
|
6
11
|
"keywords": [
|
|
7
12
|
"mapbox",
|
|
8
13
|
"mapbox-gl",
|
|
9
14
|
"mapbox-gl-js"
|
|
10
15
|
],
|
|
11
|
-
"license": "SEE LICENSE IN LICENSE.txt",
|
|
12
16
|
"main": "./dist/index.cjs",
|
|
13
17
|
"module": "./dist/index.es.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
14
19
|
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
15
21
|
"exports": {
|
|
16
22
|
".": {
|
|
17
23
|
"require": "./dist/index.cjs",
|
|
@@ -24,14 +30,11 @@
|
|
|
24
30
|
"scripts": {
|
|
25
31
|
"pretest": "npm run build",
|
|
26
32
|
"test": "node ./test.js",
|
|
27
|
-
"
|
|
28
|
-
"build": "
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "git@github.com:mapbox/mapbox-gl-js.git"
|
|
33
|
+
"build": "npm run build-spec && npm run build-dts",
|
|
34
|
+
"build-dts": "dts-bundle-generator --no-banner --export-referenced-types=false -o ./dist/index.d.ts ./style-spec.ts",
|
|
35
|
+
"build-spec": "rollup -c && rollup -c --environment esm",
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"postpublish": "rm dist/index.cjs dist/index.d.ts"
|
|
35
38
|
},
|
|
36
39
|
"bin": {
|
|
37
40
|
"gl-style-migrate": "./bin/gl-style-migrate.js",
|
|
@@ -42,15 +45,13 @@
|
|
|
42
45
|
"dependencies": {
|
|
43
46
|
"@mapbox/jsonlint-lines-primitives": "~2.0.2",
|
|
44
47
|
"@mapbox/point-geometry": "^0.1.0",
|
|
45
|
-
"@mapbox/unitbezier": "^0.0.
|
|
48
|
+
"@mapbox/unitbezier": "^0.0.1",
|
|
49
|
+
"cheap-ruler": "^4.0.0",
|
|
46
50
|
"csscolorparser": "~1.0.2",
|
|
47
|
-
"json-stringify-pretty-compact": "^
|
|
51
|
+
"json-stringify-pretty-compact": "^4.0.0",
|
|
48
52
|
"minimist": "^1.2.6",
|
|
49
|
-
"rw": "^1.3.3",
|
|
50
|
-
"sort-object": "^0.3.2",
|
|
51
53
|
"quickselect": "^2.0.0",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
}
|
|
55
|
-
"sideEffects": false
|
|
54
|
+
"rw": "^1.3.3",
|
|
55
|
+
"tinyqueue": "^2.0.3"
|
|
56
|
+
}
|
|
56
57
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
import ParsingError from './error/parsing_error
|
|
3
|
+
import ParsingError from './error/parsing_error';
|
|
4
4
|
import jsonlint from '@mapbox/jsonlint-lines-primitives';
|
|
5
5
|
|
|
6
6
|
export default function readStyle(style) {
|
|
7
|
-
if (style instanceof String || typeof style === 'string' || style
|
|
7
|
+
if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
|
|
8
8
|
try {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
9
10
|
return jsonlint.parse(style.toString());
|
|
10
|
-
} catch (e) {
|
|
11
|
+
} catch (e: any) {
|
|
11
12
|
throw new ParsingError(e);
|
|
12
13
|
}
|
|
13
14
|
}
|