@mapbox/mapbox-gl-style-spec 14.24.0 → 14.25.0-rc.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 (57) hide show
  1. package/bin/gl-style-composite.js +9 -4
  2. package/bin/gl-style-format.js +10 -4
  3. package/bin/gl-style-migrate.js +9 -4
  4. package/bin/gl-style-validate.js +16 -15
  5. package/deref.ts +8 -6
  6. package/dist/index.cjs +7771 -9448
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +14 -11
  9. package/dist/index.es.js +7771 -9448
  10. package/dist/index.es.js.map +1 -1
  11. package/expression/compound_expression.ts +1 -1
  12. package/expression/definitions/assertion.ts +1 -1
  13. package/expression/definitions/at_interpolated.ts +2 -1
  14. package/expression/definitions/case.ts +1 -1
  15. package/expression/definitions/coalesce.ts +1 -1
  16. package/expression/definitions/coercion.ts +1 -1
  17. package/expression/definitions/distance.ts +1 -9
  18. package/expression/definitions/interpolate.ts +3 -3
  19. package/expression/definitions/literal.ts +1 -1
  20. package/expression/definitions/match.ts +1 -1
  21. package/expression/definitions/number_format.ts +8 -6
  22. package/expression/definitions/within.ts +1 -8
  23. package/expression/evaluation_context.ts +1 -10
  24. package/expression/index.ts +1 -1
  25. package/expression/values.ts +3 -4
  26. package/feature_filter/index.ts +1 -1
  27. package/function/convert.ts +1 -1
  28. package/group_by_layout.ts +8 -2
  29. package/package.json +4 -6
  30. package/read_style.ts +4 -4
  31. package/reference/v8.json +41 -7
  32. package/rollup.config.js +7 -4
  33. package/test.js +1 -1
  34. package/types/config_options.ts +7 -7
  35. package/types/lut.ts +5 -5
  36. package/types/tile_id.ts +3 -3
  37. package/types.ts +8 -1
  38. package/union-to-intersection.ts +2 -2
  39. package/util/assert.ts +3 -0
  40. package/util/color.ts +33 -18
  41. package/util/deep_equal.ts +6 -4
  42. package/util/geometry_util.ts +1 -1
  43. package/util/lerp.ts +3 -1
  44. package/util/mercator.ts +16 -0
  45. package/util/unbundle_jsonlint.ts +3 -2
  46. package/validate/validate.ts +2 -0
  47. package/validate/validate_appearance.ts +1 -1
  48. package/validate/validate_color.ts +5 -2
  49. package/validate/validate_expression.ts +16 -8
  50. package/validate/validate_function.ts +3 -2
  51. package/validate/validate_iconset.ts +1 -1
  52. package/validate/validate_import.ts +7 -0
  53. package/validate/validate_layer.ts +4 -1
  54. package/validate/validate_object.ts +20 -7
  55. package/validate/validate_option.ts +37 -0
  56. package/validate/validate_terrain.ts +1 -1
  57. package/validate_style.ts +3 -3
@@ -2,17 +2,22 @@
2
2
  /* eslint-disable no-process-exit */
3
3
 
4
4
  import fs from 'fs';
5
- import minimist from 'minimist';
5
+ import {parseArgs} from 'util';
6
6
  import {format, composite} from '@mapbox/mapbox-gl-style-spec';
7
7
 
8
- const argv = minimist(process.argv.slice(2));
8
+ const {values: argv, positionals} = parseArgs({
9
+ options: {
10
+ help: {type: 'boolean', short: 'h'}
11
+ },
12
+ allowPositionals: true
13
+ });
9
14
 
10
- if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
15
+ if (argv.help || (!positionals.length && process.stdin.isTTY)) {
11
16
  help();
12
17
  process.exit(0);
13
18
  }
14
19
 
15
- console.log(format(composite(JSON.parse(fs.readFileSync(argv._[0]).toString()))));
20
+ console.log(format(composite(JSON.parse(fs.readFileSync(positionals[0]).toString()))));
16
21
 
17
22
  function help() {
18
23
  console.log('usage:');
@@ -2,17 +2,23 @@
2
2
  /* eslint-disable no-process-exit */
3
3
 
4
4
  import fs from 'fs';
5
- import minimist from 'minimist';
5
+ import {parseArgs} from 'util';
6
6
  import {format} from '@mapbox/mapbox-gl-style-spec';
7
7
 
8
- const argv = minimist(process.argv.slice(2));
8
+ const {values: argv, positionals} = parseArgs({
9
+ options: {
10
+ space: {type: 'string'},
11
+ help: {type: 'boolean', short: 'h'}
12
+ },
13
+ allowPositionals: true
14
+ });
9
15
 
10
- if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
16
+ if (argv.help || (!positionals.length && process.stdin.isTTY)) {
11
17
  help();
12
18
  process.exit(0);
13
19
  }
14
20
 
15
- console.log(format(JSON.parse(fs.readFileSync(argv._[0]).toString()), argv.space));
21
+ console.log(format(JSON.parse(fs.readFileSync(positionals[0]).toString()), argv.space ? Number(argv.space) : undefined));
16
22
 
17
23
  function help() {
18
24
  console.log('usage:');
@@ -2,17 +2,22 @@
2
2
  /* eslint-disable no-process-exit */
3
3
 
4
4
  import fs from 'fs';
5
- import minimist from 'minimist';
5
+ import {parseArgs} from 'util';
6
6
  import {format, migrate} from '@mapbox/mapbox-gl-style-spec';
7
7
 
8
- const argv = minimist(process.argv.slice(2));
8
+ const {values: argv, positionals} = parseArgs({
9
+ options: {
10
+ help: {type: 'boolean', short: 'h'}
11
+ },
12
+ allowPositionals: true
13
+ });
9
14
 
10
- if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
15
+ if (argv.help || (!positionals.length && process.stdin.isTTY)) {
11
16
  help();
12
17
  process.exit(0);
13
18
  }
14
19
 
15
- console.log(format(migrate(JSON.parse(fs.readFileSync(argv._[0]).toString()))));
20
+ console.log(format(migrate(JSON.parse(fs.readFileSync(positionals[0]).toString()))));
16
21
 
17
22
  function help() {
18
23
  console.log('usage:');
@@ -1,32 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  /* eslint-disable no-process-exit */
3
3
 
4
- import rw from 'rw';
5
- import minimist from 'minimist';
4
+ import fs from 'fs';
5
+ import {parseArgs} from 'util';
6
6
  import {validate, validateMapboxApiSupported} from '@mapbox/mapbox-gl-style-spec';
7
7
 
8
- const argv = minimist(process.argv.slice(2), {
9
- boolean: ['json', 'mapbox-api-supported'],
8
+ const {values: argv, positionals} = parseArgs({
9
+ options: {
10
+ json: {type: 'boolean'},
11
+ 'mapbox-api-supported': {type: 'boolean'},
12
+ help: {type: 'boolean', short: 'h'}
13
+ },
14
+ allowPositionals: true
10
15
  });
11
16
 
12
17
  let status = 0;
13
18
 
14
- if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
19
+ if (argv.help || (!positionals.length && process.stdin.isTTY)) {
15
20
  help();
16
21
  process.exit(status);
17
22
  }
18
23
 
19
- if (!argv._.length) {
20
- argv._.push('/dev/stdin');
21
- }
24
+ const files = positionals.length ? positionals : [0];
22
25
 
23
- argv._.forEach((file) => {
24
- let errors = [];
25
- if (argv['mapbox-api-supported']) {
26
- errors = validateMapboxApiSupported(rw.readFileSync(file, 'utf8'));
27
- } else {
28
- errors = validate(rw.readFileSync(file, 'utf8'));
29
- }
26
+ files.forEach((file) => {
27
+ const source = fs.readFileSync(file, 'utf8');
28
+ const errors = argv['mapbox-api-supported'] ?
29
+ validateMapboxApiSupported(source) :
30
+ validate(source);
30
31
  if (errors.length) {
31
32
  if (argv.json) {
32
33
  process.stdout.write(JSON.stringify(errors, null, 2));
package/deref.ts CHANGED
@@ -5,17 +5,19 @@ import type {LayerSpecification} from './types';
5
5
  function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpecification {
6
6
  const result = {} as LayerSpecification;
7
7
 
8
- for (const k in layer) {
8
+ const layerRec = layer as Record<string, unknown>;
9
+ const parentRec = parent as Record<string, unknown>;
10
+ const resultRec = result as Record<string, unknown>;
11
+
12
+ for (const k in layerRec) {
9
13
  if (k !== 'ref') {
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11
- result[k] = layer[k];
14
+ resultRec[k] = layerRec[k];
12
15
  }
13
16
  }
14
17
 
15
18
  refProperties.forEach((k) => {
16
- if (k in parent) {
17
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18
- result[k] = parent[k];
19
+ if (k in parentRec) {
20
+ resultRec[k] = parentRec[k];
19
21
  }
20
22
  });
21
23