@mapbox/mapbox-gl-style-spec 14.27.0 → 14.28.0-alpha.fa7f708fbcc
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/dist/index.cjs +115 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +56 -48
- package/dist/index.es.js +115 -152
- package/dist/index.es.js.map +1 -1
- package/error/parsing_error.ts +1 -1
- package/expression/definitions/config.ts +1 -3
- package/expression/definitions/index.ts +56 -7
- package/expression/index.ts +3 -3
- package/expression/types/resolved_image.ts +5 -1
- package/package.json +1 -1
- package/read_style.ts +2 -2
- package/reference/v8.json +59 -5
- package/types.ts +10 -46
- package/util/color.ts +12 -15
- package/util/geometry_util.ts +30 -30
- package/util/interpolate.ts +1 -1
- package/validate_mapbox_api_supported.ts +1 -2
- package/expression/definitions/in.ts +0 -86
- package/expression/definitions/index_of.ts +0 -104
- package/expression/definitions/split.ts +0 -56
|
@@ -87,7 +87,7 @@ function getSourcesErrors(sources: SourcesSpecification): {
|
|
|
87
87
|
errors: Array<ValidationError>;
|
|
88
88
|
sourcesCount: number;
|
|
89
89
|
} {
|
|
90
|
-
const errors = [];
|
|
90
|
+
const errors: ValidationError[] = [];
|
|
91
91
|
let sourcesCount = 0;
|
|
92
92
|
|
|
93
93
|
Object.keys(sources).forEach((s: string, i: number) => {
|
|
@@ -101,7 +101,6 @@ function getSourcesErrors(sources: SourcesSpecification): {
|
|
|
101
101
|
errors.push(...sourceErrors);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
105
104
|
return {errors, sourcesCount};
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BooleanType,
|
|
3
|
-
StringType,
|
|
4
|
-
ValueType,
|
|
5
|
-
NullType,
|
|
6
|
-
toString,
|
|
7
|
-
NumberType,
|
|
8
|
-
isValidType,
|
|
9
|
-
isValidNativeType,
|
|
10
|
-
} from '../types';
|
|
11
|
-
import RuntimeError from '../runtime_error';
|
|
12
|
-
import {typeOf} from '../values';
|
|
13
|
-
|
|
14
|
-
import type {Expression, SerializedExpression} from '../expression';
|
|
15
|
-
import type ParsingContext from '../parsing_context';
|
|
16
|
-
import type EvaluationContext from '../evaluation_context';
|
|
17
|
-
import type {Type} from '../types';
|
|
18
|
-
|
|
19
|
-
class In implements Expression {
|
|
20
|
-
type: Type;
|
|
21
|
-
needle: Expression;
|
|
22
|
-
haystack: Expression;
|
|
23
|
-
|
|
24
|
-
constructor(needle: Expression, haystack: Expression) {
|
|
25
|
-
this.type = BooleanType;
|
|
26
|
-
this.needle = needle;
|
|
27
|
-
this.haystack = haystack;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): In | null | undefined {
|
|
31
|
-
if (args.length !== 3) {
|
|
32
|
-
context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const needle = context.parse(args[1], 1, ValueType);
|
|
37
|
-
|
|
38
|
-
const haystack = context.parse(args[2], 2, ValueType);
|
|
39
|
-
|
|
40
|
-
if (!needle || !haystack) return null;
|
|
41
|
-
|
|
42
|
-
if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {
|
|
43
|
-
context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString(needle.type)} instead`);
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return new In(needle, haystack);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
evaluate(ctx: EvaluationContext): boolean {
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
52
|
-
const needle = (this.needle.evaluate(ctx));
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
54
|
-
const haystack = (this.haystack.evaluate(ctx));
|
|
55
|
-
|
|
56
|
-
if (haystack == null) return false;
|
|
57
|
-
|
|
58
|
-
if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
60
|
-
throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString(typeOf(needle))} instead.`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!isValidNativeType(haystack, ['string', 'array'])) {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
65
|
-
throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString(typeOf(haystack))} instead.`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Type assertions safe due to isValidNativeType checks above
|
|
69
|
-
return (haystack as string | unknown[]).includes(needle as string);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
eachChild(fn: (_: Expression) => void) {
|
|
73
|
-
fn(this.needle);
|
|
74
|
-
fn(this.haystack);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
outputDefined(): boolean {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
serialize(): SerializedExpression {
|
|
82
|
-
return ["in", this.needle.serialize(), this.haystack.serialize()];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default In;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BooleanType,
|
|
3
|
-
StringType,
|
|
4
|
-
ValueType,
|
|
5
|
-
NullType,
|
|
6
|
-
toString,
|
|
7
|
-
NumberType,
|
|
8
|
-
isValidType,
|
|
9
|
-
isValidNativeType,
|
|
10
|
-
} from '../types';
|
|
11
|
-
import RuntimeError from '../runtime_error';
|
|
12
|
-
import {typeOf} from '../values';
|
|
13
|
-
|
|
14
|
-
import type {Expression, SerializedExpression} from '../expression';
|
|
15
|
-
import type ParsingContext from '../parsing_context';
|
|
16
|
-
import type EvaluationContext from '../evaluation_context';
|
|
17
|
-
import type {Type} from '../types';
|
|
18
|
-
|
|
19
|
-
class IndexOf implements Expression {
|
|
20
|
-
type: Type;
|
|
21
|
-
needle: Expression;
|
|
22
|
-
haystack: Expression;
|
|
23
|
-
fromIndex: Expression | null | undefined;
|
|
24
|
-
|
|
25
|
-
constructor(needle: Expression, haystack: Expression, fromIndex?: Expression) {
|
|
26
|
-
this.type = NumberType;
|
|
27
|
-
this.needle = needle;
|
|
28
|
-
this.haystack = haystack;
|
|
29
|
-
this.fromIndex = fromIndex;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): IndexOf | null | undefined {
|
|
33
|
-
if (args.length <= 2 || args.length >= 5) {
|
|
34
|
-
context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const needle = context.parse(args[1], 1, ValueType);
|
|
39
|
-
|
|
40
|
-
const haystack = context.parse(args[2], 2, ValueType);
|
|
41
|
-
|
|
42
|
-
if (!needle || !haystack) return null;
|
|
43
|
-
if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {
|
|
44
|
-
context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString(needle.type)} instead`);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (args.length === 4) {
|
|
49
|
-
const fromIndex = context.parse(args[3], 3, NumberType);
|
|
50
|
-
if (!fromIndex) return null;
|
|
51
|
-
return new IndexOf(needle, haystack, fromIndex);
|
|
52
|
-
} else {
|
|
53
|
-
return new IndexOf(needle, haystack);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
evaluate(ctx: EvaluationContext): any {
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
60
|
-
const needle = (this.needle.evaluate(ctx));
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
|
-
const haystack = (this.haystack.evaluate(ctx));
|
|
63
|
-
|
|
64
|
-
if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
66
|
-
throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString(typeOf(needle))} instead.`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!isValidNativeType(haystack, ['string', 'array'])) {
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
71
|
-
throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString(typeOf(haystack))} instead.`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Type assertions safe due to isValidNativeType checks above
|
|
75
|
-
if (this.fromIndex) {
|
|
76
|
-
const fromIndex = (this.fromIndex.evaluate(ctx) as number);
|
|
77
|
-
return (haystack as string | unknown[]).indexOf(needle as string, fromIndex);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (haystack as string | unknown[]).indexOf(needle as string);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
eachChild(fn: (_: Expression) => void) {
|
|
84
|
-
fn(this.needle);
|
|
85
|
-
fn(this.haystack);
|
|
86
|
-
if (this.fromIndex) {
|
|
87
|
-
fn(this.fromIndex);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
outputDefined(): boolean {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
serialize(): SerializedExpression {
|
|
96
|
-
if (this.fromIndex != null && this.fromIndex !== undefined) {
|
|
97
|
-
const fromIndex = this.fromIndex.serialize();
|
|
98
|
-
return ["index-of", this.needle.serialize(), this.haystack.serialize(), fromIndex];
|
|
99
|
-
}
|
|
100
|
-
return ["index-of", this.needle.serialize(), this.haystack.serialize()];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default IndexOf;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
StringType,
|
|
3
|
-
array,
|
|
4
|
-
} from '../types';
|
|
5
|
-
|
|
6
|
-
import type {Expression, SerializedExpression} from '../expression';
|
|
7
|
-
import type ParsingContext from '../parsing_context';
|
|
8
|
-
import type EvaluationContext from '../evaluation_context';
|
|
9
|
-
import type {Type} from '../types';
|
|
10
|
-
|
|
11
|
-
class Split implements Expression {
|
|
12
|
-
type: Type;
|
|
13
|
-
str: Expression;
|
|
14
|
-
delimiter: Expression;
|
|
15
|
-
|
|
16
|
-
constructor(str: Expression, delimiter: Expression) {
|
|
17
|
-
this.type = array(StringType);
|
|
18
|
-
this.str = str;
|
|
19
|
-
this.delimiter = delimiter;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Split | void {
|
|
23
|
-
if (args.length !== 3) {
|
|
24
|
-
return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const str = context.parse(args[1], 1, StringType);
|
|
28
|
-
const delimiter = context.parse(args[2], 2, StringType);
|
|
29
|
-
|
|
30
|
-
if (!str || !delimiter) return;
|
|
31
|
-
|
|
32
|
-
return new Split(str, delimiter);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
evaluate(ctx: EvaluationContext): string[] {
|
|
36
|
-
const str = (this.str.evaluate(ctx) as string);
|
|
37
|
-
const delimiter = (this.delimiter.evaluate(ctx) as string);
|
|
38
|
-
|
|
39
|
-
return str.split(delimiter);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
eachChild(fn: (_: Expression) => void) {
|
|
43
|
-
fn(this.str);
|
|
44
|
-
fn(this.delimiter);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
outputDefined(): boolean {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
serialize(): SerializedExpression {
|
|
52
|
-
return ["split", this.str.serialize(), this.delimiter.serialize()];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default Split;
|