@mapbox/mapbox-gl-style-spec 13.24.0-alpha.6 → 13.25.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 (74) hide show
  1. package/.eslintrc +10 -0
  2. package/CHANGELOG.md +23 -4
  3. package/bin/gl-style-composite.js +6 -2
  4. package/bin/gl-style-format.js +6 -2
  5. package/bin/gl-style-migrate.js +6 -2
  6. package/bin/gl-style-validate.js +5 -1
  7. package/dist/index.cjs +435 -225
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.es.js +427 -217
  10. package/dist/index.es.js.map +1 -1
  11. package/expression/compound_expression.js +2 -2
  12. package/expression/definitions/assertion.js +3 -3
  13. package/expression/definitions/at.js +5 -5
  14. package/expression/definitions/case.js +4 -4
  15. package/expression/definitions/coalesce.js +4 -4
  16. package/expression/definitions/coercion.js +3 -3
  17. package/expression/definitions/collator.js +4 -4
  18. package/expression/definitions/comparison.js +22 -22
  19. package/expression/definitions/format.js +4 -4
  20. package/expression/definitions/image.js +4 -4
  21. package/expression/definitions/in.js +5 -5
  22. package/expression/definitions/index_of.js +5 -5
  23. package/expression/definitions/interpolate.js +6 -5
  24. package/expression/definitions/length.js +5 -5
  25. package/expression/definitions/let.js +5 -5
  26. package/expression/definitions/literal.js +5 -5
  27. package/expression/definitions/match.js +4 -4
  28. package/expression/definitions/number_format.js +4 -4
  29. package/expression/definitions/slice.js +5 -5
  30. package/expression/definitions/step.js +4 -4
  31. package/expression/definitions/var.js +4 -4
  32. package/expression/definitions/within.js +16 -8
  33. package/expression/evaluation_context.js +8 -8
  34. package/expression/expression.js +1 -1
  35. package/expression/index.js +5 -5
  36. package/expression/is_constant.js +3 -3
  37. package/expression/parsing_context.js +1 -1
  38. package/expression/runtime_error.js +1 -1
  39. package/expression/scope.js +1 -1
  40. package/expression/stops.js +1 -1
  41. package/expression/values.js +1 -1
  42. package/feature_filter/index.js +1 -1
  43. package/flow-typed/gl-matrix.js +8 -1
  44. package/function/convert.js +4 -4
  45. package/migrate/expressions.js +1 -1
  46. package/package.json +1 -1
  47. package/reference/latest.js +4 -0
  48. package/reference/v8.json +144 -7
  49. package/types.js +6 -2
  50. package/util/color.js +35 -0
  51. package/validate/validate.js +13 -1
  52. package/validate/validate_array.js +10 -2
  53. package/validate/validate_boolean.js +4 -1
  54. package/validate/validate_color.js +4 -1
  55. package/validate/validate_enum.js +4 -1
  56. package/validate/validate_expression.js +5 -2
  57. package/validate/validate_filter.js +12 -4
  58. package/validate/validate_fog.js +4 -1
  59. package/validate/validate_formatted.js +5 -1
  60. package/validate/validate_function.js +24 -15
  61. package/validate/validate_glyphs_url.js +4 -1
  62. package/validate/validate_image.js +5 -1
  63. package/validate/validate_layer.js +17 -2
  64. package/validate/validate_layout_property.js +5 -1
  65. package/validate/validate_light.js +4 -1
  66. package/validate/validate_number.js +8 -1
  67. package/validate/validate_object.js +12 -2
  68. package/validate/validate_paint_property.js +5 -1
  69. package/validate/validate_projection.js +5 -1
  70. package/validate/validate_property.js +9 -1
  71. package/validate/validate_source.js +4 -1
  72. package/validate/validate_string.js +4 -1
  73. package/validate/validate_terrain.js +5 -2
  74. package/validate_style.min.js +1 -1
@@ -1,9 +1,12 @@
1
+ // @flow
1
2
 
2
3
  import ValidationError from '../error/validation_error.js';
3
4
  import getType from '../util/get_type.js';
4
5
  import validate from './validate.js';
5
6
 
6
- export default function validateLight(options) {
7
+ import type {ValidationOptions} from './validate.js';
8
+
9
+ export default function validateLight(options: ValidationOptions): Array<ValidationError> {
7
10
  const light = options.value;
8
11
  const styleSpec = options.styleSpec;
9
12
  const lightSpec = styleSpec.light;
@@ -1,8 +1,15 @@
1
+ // @flow
1
2
 
2
3
  import getType from '../util/get_type.js';
3
4
  import ValidationError from '../error/validation_error.js';
4
5
 
5
- export default function validateNumber(options) {
6
+ import type {ValidationOptions} from './validate.js';
7
+
8
+ type Options = ValidationOptions & {
9
+ arrayIndex: number;
10
+ }
11
+
12
+ export default function validateNumber(options: Options): Array<ValidationError> {
6
13
  const key = options.key;
7
14
  const value = options.value;
8
15
  const valueSpec = options.valueSpec;
@@ -1,9 +1,16 @@
1
+ // @flow
1
2
 
2
3
  import ValidationError from '../error/validation_error.js';
3
4
  import getType from '../util/get_type.js';
4
5
  import validateSpec from './validate.js';
5
6
 
6
- export default function validateObject(options) {
7
+ import type {ValidationOptions} from './validate.js';
8
+
9
+ type Options = ValidationOptions & {
10
+ objectElementValidators?: Function;
11
+ };
12
+
13
+ export default function validateObject(options: Options): Array<ValidationError> {
7
14
  const key = options.key;
8
15
  const object = options.value;
9
16
  const elementSpecs = options.valueSpec || {};
@@ -30,7 +37,9 @@ export default function validateObject(options) {
30
37
  validateElement = elementValidators['*'];
31
38
  } else if (elementSpecs['*']) {
32
39
  validateElement = validateSpec;
33
- } else {
40
+ }
41
+
42
+ if (!validateElement) {
34
43
  errors.push(new ValidationError(key, object[objectKey], `unknown property "${objectKey}"`));
35
44
  continue;
36
45
  }
@@ -43,6 +52,7 @@ export default function validateObject(options) {
43
52
  styleSpec,
44
53
  object,
45
54
  objectKey
55
+ // $FlowFixMe[extra-arg]
46
56
  }, object));
47
57
  }
48
58
 
@@ -1,6 +1,10 @@
1
+ // @flow
1
2
 
2
3
  import validateProperty from './validate_property.js';
3
4
 
4
- export default function validatePaintProperty(options) {
5
+ import type ValidationError from '../error/validation_error.js';
6
+ import type {PropertyValidationOptions} from './validate_property.js';
7
+
8
+ export default function validatePaintProperty(options: PropertyValidationOptions): Array<ValidationError> {
5
9
  return validateProperty(options, 'paint');
6
10
  }
@@ -1,8 +1,12 @@
1
+ // @flow
2
+
1
3
  import ValidationError from '../error/validation_error.js';
2
4
  import getType from '../util/get_type.js';
3
5
  import validate from './validate.js';
4
6
 
5
- export default function validateProjection(options) {
7
+ import type {ValidationOptions} from './validate.js';
8
+
9
+ export default function validateProjection(options: ValidationOptions): Array<ValidationError> {
6
10
  const projection = options.value;
7
11
  const styleSpec = options.styleSpec;
8
12
  const projectionSpec = styleSpec.projection;
@@ -1,3 +1,4 @@
1
+ // @flow
1
2
 
2
3
  import validate from './validate.js';
3
4
  import ValidationError from '../error/validation_error.js';
@@ -6,7 +7,14 @@ import {isFunction} from '../function/index.js';
6
7
  import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint.js';
7
8
  import {supportsPropertyExpression} from '../util/properties.js';
8
9
 
9
- export default function validateProperty(options, propertyType) {
10
+ import type {ValidationOptions} from './validate.js';
11
+
12
+ export type PropertyValidationOptions = ValidationOptions & {
13
+ objectKey: string;
14
+ layerType: string;
15
+ }
16
+
17
+ export default function validateProperty(options: PropertyValidationOptions, propertyType: string): Array<ValidationError> {
10
18
  const key = options.key;
11
19
  const style = options.style;
12
20
  const styleSpec = options.styleSpec;
@@ -1,3 +1,4 @@
1
+ // @flow
1
2
 
2
3
  import ValidationError from '../error/validation_error.js';
3
4
  import {unbundle} from '../util/unbundle_jsonlint.js';
@@ -7,11 +8,13 @@ import validateExpression from './validate_expression.js';
7
8
  import validateString from './validate_string.js';
8
9
  import getType from '../util/get_type.js';
9
10
 
11
+ import type {ValidationOptions} from './validate.js';
12
+
10
13
  const objectElementValidators = {
11
14
  promoteId: validatePromoteId
12
15
  };
13
16
 
14
- export default function validateSource(options) {
17
+ export default function validateSource(options: ValidationOptions): Array<ValidationError> {
15
18
  const value = options.value;
16
19
  const key = options.key;
17
20
  const styleSpec = options.styleSpec;
@@ -1,8 +1,11 @@
1
+ // @flow
1
2
 
2
3
  import getType from '../util/get_type.js';
3
4
  import ValidationError from '../error/validation_error.js';
4
5
 
5
- export default function validateString(options) {
6
+ import type {ValidationOptions} from './validate.js';
7
+
8
+ export default function validateString(options: $Shape<ValidationOptions>): Array<ValidationError> {
6
9
  const value = options.value;
7
10
  const key = options.key;
8
11
  const type = getType(value);
@@ -1,10 +1,13 @@
1
+ // @flow
1
2
 
2
3
  import ValidationError from '../error/validation_error.js';
3
4
  import validate from './validate.js';
4
5
  import getType from '../util/get_type.js';
5
6
  import {unbundle} from '../util/unbundle_jsonlint.js';
6
7
 
7
- export default function validateTerrain(options) {
8
+ import type {ValidationOptions} from './validate.js';
9
+
10
+ export default function validateTerrain(options: ValidationOptions): Array<ValidationError> {
8
11
  const terrain = options.value;
9
12
  const key = options.key;
10
13
  const style = options.style;
@@ -52,7 +55,7 @@ export default function validateTerrain(options) {
52
55
  if (!source) {
53
56
  errors.push(new ValidationError(key, terrain.source, `source "${terrain.source}" not found`));
54
57
  } else if (sourceType !== 'raster-dem') {
55
- errors.push(new ValidationError(key, terrain.source, `terrain cannot be used with a source of type ${sourceType}, it only be used with a "raster-dem" source type`));
58
+ errors.push(new ValidationError(key, terrain.source, `terrain cannot be used with a source of type ${String(sourceType)}, it only be used with a "raster-dem" source type`));
56
59
  }
57
60
  }
58
61
 
@@ -63,5 +63,5 @@ export const validatePaintProperty: Validator = opts => sortErrors(_validatePain
63
63
  export const validateLayoutProperty: Validator = opts => sortErrors(_validateLayoutProperty(opts));
64
64
 
65
65
  function sortErrors(errors) {
66
- return errors.slice().sort((a, b) => a.line - b.line);
66
+ return errors.slice().sort((a, b) => a.line && b.line ? a.line - b.line : 0);
67
67
  }