@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.
Files changed (142) hide show
  1. package/bin/gl-style-composite.js +0 -5
  2. package/bin/gl-style-format.js +0 -5
  3. package/bin/gl-style-migrate.js +0 -5
  4. package/bin/gl-style-validate.js +0 -5
  5. package/{composite.js → composite.ts} +1 -1
  6. package/data/{extent.js → extent.ts} +0 -2
  7. package/{deref.js → deref.ts} +7 -9
  8. package/{diff.js → diff.ts} +44 -21
  9. package/dist/index.cjs +800 -1357
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +1726 -0
  12. package/dist/index.es.js +800 -1357
  13. package/dist/index.es.js.map +1 -1
  14. package/{empty.js → empty.ts} +1 -2
  15. package/error/{parsing_error.js → parsing_error.ts} +0 -2
  16. package/error/{validation_error.js → validation_error.ts} +5 -5
  17. package/expression/{compound_expression.js → compound_expression.ts} +29 -19
  18. package/expression/definitions/{assertion.js → assertion.ts} +16 -13
  19. package/expression/definitions/{at.js → at.ts} +12 -13
  20. package/expression/definitions/{case.js → case.ts} +12 -11
  21. package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
  22. package/expression/definitions/{coercion.js → coercion.ts} +21 -20
  23. package/expression/definitions/{collator.js → collator.ts} +11 -11
  24. package/expression/definitions/{comparison.js → comparison.ts} +30 -24
  25. package/expression/definitions/{config.js → config.ts} +16 -16
  26. package/expression/definitions/{distance.js → distance.ts} +60 -52
  27. package/expression/definitions/{format.js → format.ts} +26 -15
  28. package/expression/definitions/{image.js → image.ts} +12 -12
  29. package/expression/definitions/{in.js → in.ts} +22 -13
  30. package/expression/definitions/{index.js → index.ts} +70 -83
  31. package/expression/definitions/{index_of.js → index_of.ts} +24 -15
  32. package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
  33. package/expression/definitions/{length.js → length.ts} +11 -10
  34. package/expression/definitions/{let.js → let.ts} +10 -7
  35. package/expression/definitions/{literal.js → literal.ts} +11 -12
  36. package/expression/definitions/{match.js → match.ts} +25 -15
  37. package/expression/definitions/{number_format.js → number_format.ts} +10 -10
  38. package/expression/definitions/{slice.js → slice.ts} +23 -15
  39. package/expression/definitions/{step.js → step.ts} +14 -12
  40. package/expression/definitions/{var.js → var.ts} +5 -7
  41. package/expression/definitions/{within.js → within.ts} +41 -29
  42. package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
  43. package/expression/expression.ts +29 -0
  44. package/expression/{index.js → index.ts} +208 -110
  45. package/expression/{is_constant.js → is_constant.ts} +5 -7
  46. package/expression/{parsing_context.js → parsing_context.ts} +47 -34
  47. package/expression/{parsing_error.js → parsing_error.ts} +0 -2
  48. package/expression/{runtime_error.js → runtime_error.ts} +0 -2
  49. package/expression/{scope.js → scope.ts} +5 -5
  50. package/expression/{stops.js → stops.ts} +2 -4
  51. package/expression/types/{collator.js → collator.ts} +1 -3
  52. package/expression/types/{formatted.js → formatted.ts} +8 -7
  53. package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
  54. package/expression/{types.js → types.ts} +53 -45
  55. package/expression/{values.js → values.ts} +12 -12
  56. package/feature_filter/{convert.js → convert.ts} +19 -18
  57. package/feature_filter/{index.js → index.ts} +33 -18
  58. package/{format.js → format.ts} +3 -3
  59. package/function/{convert.js → convert.ts} +36 -25
  60. package/function/{index.js → index.ts} +12 -12
  61. package/{group_by_layout.js → group_by_layout.ts} +11 -8
  62. package/migrate/{expressions.js → expressions.ts} +8 -14
  63. package/migrate/{v8.js → v8.ts} +2 -2
  64. package/migrate/{v9.js → v9.ts} +2 -2
  65. package/{migrate.js → migrate.ts} +3 -3
  66. package/package.json +20 -18
  67. package/{read_style.js → read_style.ts} +5 -4
  68. package/reference/latest.ts +5 -0
  69. package/reference/v8.json +224 -1
  70. package/rollup.config.js +6 -23
  71. package/{style-spec.js → style-spec.ts} +28 -30
  72. package/test.js +3 -2
  73. package/types/config_options.ts +13 -0
  74. package/types/lut.ts +7 -0
  75. package/types/tile_id.ts +5 -0
  76. package/{types.js → types.ts} +636 -183
  77. package/util/{color.js → color.ts} +89 -3
  78. package/util/{color_spaces.js → color_spaces.ts} +12 -14
  79. package/util/{deep_equal.js → deep_equal.ts} +1 -3
  80. package/util/{extend.js → extend.ts} +1 -3
  81. package/util/{geometry_util.js → geometry_util.ts} +23 -11
  82. package/util/{get_type.js → get_type.ts} +1 -3
  83. package/util/{interpolate.js → interpolate.ts} +1 -3
  84. package/util/{properties.js → properties.ts} +5 -4
  85. package/util/{random.js → random.ts} +0 -2
  86. package/util/{ref_properties.js → ref_properties.ts} +0 -1
  87. package/util/{result.js → result.ts} +7 -5
  88. package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
  89. package/validate/{validate.js → validate.ts} +33 -35
  90. package/validate/{validate_array.js → validate_array.ts} +5 -7
  91. package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
  92. package/validate/{validate_color.js → validate_color.ts} +3 -5
  93. package/validate/{validate_enum.js → validate_enum.ts} +4 -5
  94. package/validate/{validate_expression.js → validate_expression.ts} +7 -9
  95. package/validate/{validate_filter.js → validate_filter.ts} +16 -12
  96. package/validate/{validate_fog.js → validate_fog.ts} +4 -6
  97. package/validate/validate_formatted.ts +13 -0
  98. package/validate/{validate_function.js → validate_function.ts} +14 -16
  99. package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
  100. package/validate/validate_image.ts +13 -0
  101. package/validate/{validate_import.js → validate_import.ts} +6 -8
  102. package/validate/{validate_layer.js → validate_layer.ts} +17 -15
  103. package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
  104. package/validate/{validate_light.js → validate_light.ts} +4 -6
  105. package/validate/{validate_lights.js → validate_lights.ts} +7 -9
  106. package/validate/{validate_model.js → validate_model.ts} +4 -6
  107. package/validate/{validate_number.js → validate_number.ts} +4 -6
  108. package/validate/{validate_object.js → validate_object.ts} +5 -8
  109. package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
  110. package/validate/{validate_projection.js → validate_projection.ts} +4 -6
  111. package/validate/{validate_property.js → validate_property.ts} +15 -15
  112. package/validate/{validate_source.js → validate_source.ts} +16 -13
  113. package/validate/validate_string.ts +16 -0
  114. package/validate/validate_style.ts +33 -0
  115. package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
  116. package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
  117. package/{validate_style.min.js → validate_style.min.ts} +20 -21
  118. package/{validate_style.js → validate_style.ts} +9 -9
  119. package/{visit.js → visit.ts} +22 -17
  120. package/.eslintrc +0 -10
  121. package/expression/expression.js +0 -28
  122. package/flow-typed/cheap-ruler.js +0 -25
  123. package/flow-typed/geojson.js +0 -44
  124. package/flow-typed/gl-matrix.js +0 -119
  125. package/flow-typed/gl.js +0 -5
  126. package/flow-typed/intl.js +0 -58
  127. package/flow-typed/kdbush.js +0 -9
  128. package/flow-typed/mapbox-gl-supported.js +0 -16
  129. package/flow-typed/mapbox-unitbezier.js +0 -14
  130. package/flow-typed/offscreen-canvas.js +0 -9
  131. package/flow-typed/pbf.js +0 -26
  132. package/flow-typed/point-geometry.js +0 -46
  133. package/flow-typed/potpack.js +0 -13
  134. package/flow-typed/tiny-sdf.js +0 -31
  135. package/flow-typed/tracked_parameters_proxy.js +0 -82
  136. package/flow-typed/vector-tile.js +0 -49
  137. package/flow-typed/webgl2.js +0 -41
  138. package/reference/latest.js +0 -7
  139. package/validate/validate_formatted.js +0 -15
  140. package/validate/validate_image.js +0 -15
  141. package/validate/validate_string.js +0 -18
  142. 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.js';
6
- import type {ExpressionSpecification} from '../types.js';
3
+ import type {StylePropertySpecification} from '../style-spec';
4
+ import type {ExpressionSpecification} from '../types';
7
5
 
8
- type Stop = [{zoom: number, value: string | number | boolean}, mixed];
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: mixed;
17
+ default: unknown;
17
18
  };
18
19
 
19
- function convertLiteral(value: mixed) {
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): Array<mixed> {
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(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>) {
83
- const featureFunctionParameters = {};
84
- const featureFunctionStops = {};
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: mixed, b: mixed) {
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(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>) {
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: mixed, output: mixed, isStep: boolean) {
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: any).interpolated ? 'exponential' : 'interval';
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
- // @noflow
1
+ // @ts-nocheck
2
2
 
3
- import * as colorSpaces from '../util/color_spaces.js';
4
- import Color from '../util/color.js';
5
- import extend from '../util/extend.js';
6
- import getType from '../util/get_type.js';
7
- import * as interpolate from '../util/interpolate.js';
8
- import Interpolate from '../expression/definitions/interpolate.js';
9
- import Formatted from '../expression/types/formatted.js';
10
- import ResolvedImage from '../expression/types/resolved_image.js';
11
- import {supportsInterpolation} from '../util/properties.js';
12
- import {findStopLessThanOrEqualTo} from '../expression/stops.js';
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
- // @flow
1
+ import type {LayerSpecification} from './types';
2
2
 
3
- import type {LayerSpecification} from './types.js';
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: any)[key])},`;
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: any)[k])}`;
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(layers: Array<LayerSpecification>, cachedKeys: {[id: string]: string}): Array<Array<LayerSpecification>> {
50
- const groups = {};
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
- // @flow
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): any);
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
- // $FlowFixMe[prop-missing]
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
  }
@@ -1,5 +1,5 @@
1
- // @noflow
2
- import {eachSource, eachLayer, eachProperty} from '../visit.js';
1
+ // @ts-nocheck
2
+ import {eachSource, eachLayer, eachProperty} from '../visit';
3
3
 
4
4
  function eachLayout(layer, callback) {
5
5
  for (const k in layer) {
@@ -1,5 +1,5 @@
1
- // @noflow
2
- import deref from '../deref.js';
1
+ // @ts-nocheck
2
+ import deref from '../deref';
3
3
 
4
4
  function eachLayer(style, callback) {
5
5
  for (const k in style.layers) {
@@ -1,7 +1,7 @@
1
- // @noflow
1
+ // @ts-nocheck
2
2
 
3
- import migrateToV8 from './migrate/v8.js';
4
- import migrateToExpressions from './migrate/expressions.js';
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
- "copy-flow-typed": "cp -R ../../flow-typed .",
28
- "build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm",
29
- "prepublishOnly": "npm run copy-flow-typed && npm run build",
30
- "postpublish": "rm -r flow-typed dist/index.cjs"
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.0",
48
+ "@mapbox/unitbezier": "^0.0.1",
49
+ "cheap-ruler": "^3.0.1",
46
50
  "csscolorparser": "~1.0.2",
47
- "json-stringify-pretty-compact": "^2.0.0",
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
- "tinyqueue": "^2.0.3",
53
- "cheap-ruler": "^3.0.1"
54
- },
55
- "sideEffects": false
54
+ "rw": "^1.3.3",
55
+ "sort-object": "^3.0.3",
56
+ "tinyqueue": "^2.0.3"
57
+ }
56
58
  }
@@ -1,13 +1,14 @@
1
- // @noflow
1
+ // @ts-nocheck
2
2
 
3
- import ParsingError from './error/parsing_error.js';
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 instanceof Buffer) {
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
  }
@@ -0,0 +1,5 @@
1
+ import spec from './v8.json';
2
+
3
+ export type StyleReference = Record<any, any>;
4
+
5
+ export default spec as StyleReference;