@mapbox/mapbox-gl-style-spec 14.4.0-beta.1 → 14.5.0-beta.1
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 +800 -1357
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1726 -0
- package/dist/index.es.js +800 -1357
- 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} +33 -18
- package/{format.js → format.ts} +3 -3
- package/function/{convert.js → convert.ts} +36 -25
- 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} +8 -14
- 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 +20 -18
- package/{read_style.js → read_style.ts} +5 -4
- package/reference/latest.ts +5 -0
- package/reference/v8.json +224 -1
- package/rollup.config.js +6 -23
- package/{style-spec.js → style-spec.ts} +28 -30
- 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} +636 -183
- 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,11 +1,12 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
|
|
5
|
-
import type {StylePropertySpecification} from '../style-spec
|
|
6
|
-
import type {ExpressionSpecification} from '../types
|
|
3
|
+
import type {StylePropertySpecification} from '../style-spec';
|
|
4
|
+
import type {ExpressionSpecification} from '../types';
|
|
7
5
|
|
|
8
|
-
type Stop = [{
|
|
6
|
+
type Stop = [{
|
|
7
|
+
zoom: number;
|
|
8
|
+
value: string | number | boolean;
|
|
9
|
+
}, unknown];
|
|
9
10
|
|
|
10
11
|
type FunctionParameters = {
|
|
11
12
|
stops: Array<Stop>;
|
|
@@ -13,10 +14,10 @@ type FunctionParameters = {
|
|
|
13
14
|
property: string;
|
|
14
15
|
type: 'identity' | 'exponential' | 'interval' | 'categorical';
|
|
15
16
|
colorSpace: 'rgb' | 'lab' | 'hcl';
|
|
16
|
-
default:
|
|
17
|
+
default: unknown;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
function convertLiteral(value:
|
|
20
|
+
function convertLiteral(value: unknown) {
|
|
20
21
|
return typeof value === 'object' ? ['literal', value] : value;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -32,6 +33,7 @@ export default function convertFunction(parameters: FunctionParameters, property
|
|
|
32
33
|
const zoomDependent = zoomAndFeatureDependent || !featureDependent;
|
|
33
34
|
|
|
34
35
|
stops = stops.map((stop) => {
|
|
36
|
+
// @ts-expect-error - TS2339 - Property 'tokens' does not exist on type 'StylePropertySpecification'.
|
|
35
37
|
if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {
|
|
36
38
|
return [stop[0], convertTokenString(stop[1])];
|
|
37
39
|
}
|
|
@@ -47,8 +49,8 @@ export default function convertFunction(parameters: FunctionParameters, property
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
function convertIdentityFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification):
|
|
51
|
-
const get = ['get', parameters.property];
|
|
52
|
+
function convertIdentityFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification {
|
|
53
|
+
const get: ExpressionSpecification = ['get', parameters.property];
|
|
52
54
|
|
|
53
55
|
if (parameters.default === undefined) {
|
|
54
56
|
// By default, expressions for string-valued properties get coerced. To preserve
|
|
@@ -63,7 +65,7 @@ function convertIdentityFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
63
65
|
parameters.default
|
|
64
66
|
];
|
|
65
67
|
} else {
|
|
66
|
-
const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];
|
|
68
|
+
const expression: ExpressionSpecification = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];
|
|
67
69
|
if (propertySpec.type === 'array') {
|
|
68
70
|
expression.splice(1, 0, propertySpec.value, propertySpec.length || null);
|
|
69
71
|
}
|
|
@@ -79,9 +81,13 @@ function getInterpolateOperator(parameters: FunctionParameters) {
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
function convertZoomAndPropertyFunction(
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
function convertZoomAndPropertyFunction(
|
|
85
|
+
parameters: FunctionParameters,
|
|
86
|
+
propertySpec: StylePropertySpecification,
|
|
87
|
+
stops: Array<Stop>,
|
|
88
|
+
): ExpressionSpecification {
|
|
89
|
+
const featureFunctionParameters: Record<string, any> = {};
|
|
90
|
+
const featureFunctionStops: Record<string, any> = {};
|
|
85
91
|
const zoomStops = [];
|
|
86
92
|
for (let s = 0; s < stops.length; s++) {
|
|
87
93
|
const stop = stops[s];
|
|
@@ -103,9 +109,10 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
103
109
|
// function is determined directly from the style property specification
|
|
104
110
|
// for which it's being used: linear for interpolatable properties, step
|
|
105
111
|
// otherwise.
|
|
112
|
+
// @ts-expect-error - TS2345 - Argument of type '{}' is not assignable to parameter of type 'FunctionParameters'.
|
|
106
113
|
const functionType = getFunctionType({}, propertySpec);
|
|
107
114
|
if (functionType === 'exponential') {
|
|
108
|
-
const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];
|
|
115
|
+
const expression: ExpressionSpecification = [getInterpolateOperator(parameters), ['linear'], ['zoom']];
|
|
109
116
|
|
|
110
117
|
for (const z of zoomStops) {
|
|
111
118
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
@@ -114,7 +121,7 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
114
121
|
|
|
115
122
|
return expression;
|
|
116
123
|
} else {
|
|
117
|
-
const expression = ['step', ['zoom']];
|
|
124
|
+
const expression: ExpressionSpecification = ['step', ['zoom']];
|
|
118
125
|
|
|
119
126
|
for (const z of zoomStops) {
|
|
120
127
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
@@ -127,7 +134,7 @@ function convertZoomAndPropertyFunction(parameters: FunctionParameters, property
|
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
function coalesce(a:
|
|
137
|
+
function coalesce(a: unknown, b: unknown) {
|
|
131
138
|
if (a !== undefined) return a;
|
|
132
139
|
if (b !== undefined) return b;
|
|
133
140
|
}
|
|
@@ -147,12 +154,16 @@ function getFallback(parameters: FunctionParameters, propertySpec: StyleProperty
|
|
|
147
154
|
return defaultValue;
|
|
148
155
|
}
|
|
149
156
|
|
|
150
|
-
function convertPropertyFunction(
|
|
157
|
+
function convertPropertyFunction(
|
|
158
|
+
parameters: FunctionParameters,
|
|
159
|
+
propertySpec: StylePropertySpecification,
|
|
160
|
+
stops: Array<Stop>,
|
|
161
|
+
): ExpressionSpecification {
|
|
151
162
|
const type = getFunctionType(parameters, propertySpec);
|
|
152
|
-
const get = ['get', parameters.property];
|
|
163
|
+
const get: ExpressionSpecification = ['get', parameters.property];
|
|
153
164
|
if (type === 'categorical' && typeof stops[0][0] === 'boolean') {
|
|
154
165
|
assert(parameters.stops.length > 0 && parameters.stops.length <= 2);
|
|
155
|
-
const expression = ['case'];
|
|
166
|
+
const expression: ExpressionSpecification = ['case'];
|
|
156
167
|
for (const stop of stops) {
|
|
157
168
|
expression.push(['==', get, stop[0]], stop[1]);
|
|
158
169
|
}
|
|
@@ -160,14 +171,14 @@ function convertPropertyFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
160
171
|
expression.push(getFallback(parameters, propertySpec));
|
|
161
172
|
return expression;
|
|
162
173
|
} else if (type === 'categorical') {
|
|
163
|
-
const expression = ['match', get];
|
|
174
|
+
const expression: ExpressionSpecification = ['match', get];
|
|
164
175
|
for (const stop of stops) {
|
|
165
176
|
appendStopPair(expression, stop[0], stop[1], false);
|
|
166
177
|
}
|
|
167
178
|
expression.push(getFallback(parameters, propertySpec));
|
|
168
179
|
return expression;
|
|
169
180
|
} else if (type === 'interval') {
|
|
170
|
-
const expression = ['step', ['number', get]];
|
|
181
|
+
const expression: ExpressionSpecification = ['step', ['number', get]];
|
|
171
182
|
for (const stop of stops) {
|
|
172
183
|
appendStopPair(expression, stop[0], stop[1], true);
|
|
173
184
|
}
|
|
@@ -180,7 +191,7 @@ function convertPropertyFunction(parameters: FunctionParameters, propertySpec: S
|
|
|
180
191
|
];
|
|
181
192
|
} else if (type === 'exponential') {
|
|
182
193
|
const base = parameters.base !== undefined ? parameters.base : 1;
|
|
183
|
-
const expression = [
|
|
194
|
+
const expression: ExpressionSpecification = [
|
|
184
195
|
getInterpolateOperator(parameters),
|
|
185
196
|
base === 1 ? ["linear"] : ["exponential", base],
|
|
186
197
|
["number", get]
|
|
@@ -232,7 +243,7 @@ function fixupDegenerateStepCurve(expression: ExpressionSpecification) {
|
|
|
232
243
|
}
|
|
233
244
|
}
|
|
234
245
|
|
|
235
|
-
function appendStopPair(curve: ExpressionSpecification, input:
|
|
246
|
+
function appendStopPair(curve: ExpressionSpecification, input: unknown, output: unknown, isStep: boolean) {
|
|
236
247
|
// Skip duplicate stop values. They were not validated for functions, but they are for expressions.
|
|
237
248
|
// https://github.com/mapbox/mapbox-gl-js/issues/4107
|
|
238
249
|
if (curve.length > 3 && input === curve[curve.length - 2]) {
|
|
@@ -250,13 +261,13 @@ function getFunctionType(parameters: FunctionParameters, propertySpec: StyleProp
|
|
|
250
261
|
return parameters.type;
|
|
251
262
|
} else {
|
|
252
263
|
assert(propertySpec.expression);
|
|
253
|
-
return (propertySpec.expression
|
|
264
|
+
return (propertySpec.expression as any).interpolated ? 'exponential' : 'interval';
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
|
|
257
268
|
// "String with {name} token" => ["concat", "String with ", ["get", "name"], " token"]
|
|
258
269
|
export function convertTokenString(s: string): string | ExpressionSpecification {
|
|
259
|
-
const result = ['concat'];
|
|
270
|
+
const result: ExpressionSpecification = ['concat'];
|
|
260
271
|
const re = /{([^{}]+)}/g;
|
|
261
272
|
let pos = 0;
|
|
262
273
|
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} from '../types';
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
9
|
* Migrate the given style object in place to use expressions. Specifically,
|
|
@@ -20,18 +15,17 @@ 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]
|
|
25
|
+
// @ts-expect-error - TS2345 - Argument of type 'object' is not assignable to parameter of type 'FunctionParameters'.
|
|
33
26
|
set(convertFunction(value, reference));
|
|
34
27
|
converted.push(path.join('.'));
|
|
28
|
+
// @ts-expect-error - TS2339 - Property 'tokens' does not exist on type 'StylePropertySpecification'.
|
|
35
29
|
} else if (reference.tokens && typeof value === 'string') {
|
|
36
30
|
set(convertTokenString(value));
|
|
37
31
|
}
|
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-beta.1",
|
|
3
4
|
"description": "a specification for mapbox gl styles",
|
|
4
|
-
"version": "14.4.0-beta.1",
|
|
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,14 @@
|
|
|
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": "^3.0.1",
|
|
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
|
-
|
|
54
|
+
"rw": "^1.3.3",
|
|
55
|
+
"sort-object": "^3.0.3",
|
|
56
|
+
"tinyqueue": "^2.0.3"
|
|
57
|
+
}
|
|
56
58
|
}
|
|
@@ -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
|
}
|