@mapbox/mapbox-gl-style-spec 14.11.0-beta.2 → 14.12.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/diff.ts +47 -11
- package/dist/index.cjs +687 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +186 -13
- package/dist/index.es.js +687 -30
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +1 -1
- package/expression/definitions/coalesce.ts +2 -2
- package/expression/definitions/config.ts +1 -1
- package/expression/definitions/image.ts +1 -11
- package/expression/definitions/index.ts +3 -2
- package/expression/definitions/interpolate.ts +3 -3
- package/expression/definitions/match.ts +1 -1
- package/expression/definitions/step.ts +1 -1
- package/expression/evaluation_context.ts +3 -5
- package/expression/index.ts +4 -8
- package/expression/parsing_context.ts +1 -1
- package/expression/types/image_id.ts +6 -8
- package/expression/types.ts +1 -1
- package/expression/values.ts +1 -3
- package/feature_filter/index.ts +1 -1
- package/function/index.ts +3 -3
- package/migrate/expressions.ts +1 -1
- package/migrate/v8.ts +1 -1
- package/migrate/v9.ts +1 -1
- package/migrate.ts +1 -1
- package/package.json +1 -1
- package/read_style.ts +4 -6
- package/reference/v8.json +313 -0
- package/test.js +2 -5
- package/types.ts +195 -0
- package/util/extend.ts +1 -1
- package/util/geometry_util.ts +19 -2
- package/util/interpolate.ts +4 -0
- package/validate/validate_fog.ts +1 -1
- package/validate/validate_glyphs_url.ts +1 -1
- package/validate/validate_layer.ts +2 -2
- package/validate/validate_light.ts +1 -1
- package/validate/validate_lights.ts +1 -1
- package/validate/validate_property.ts +1 -1
- package/validate/validate_source.ts +2 -4
- package/validate/validate_style.ts +2 -1
- package/validate/validate_terrain.ts +1 -1
- package/validate_mapbox_api_supported.ts +1 -1
- package/validate_style.min.ts +17 -15
- package/validate_style.ts +3 -3
- package/visit.ts +1 -1
|
@@ -21,7 +21,7 @@ class Coalesce implements Expression {
|
|
|
21
21
|
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Coalesce'.
|
|
22
22
|
return context.error("Expectected at least one argument.");
|
|
23
23
|
}
|
|
24
|
-
let outputType: Type =
|
|
24
|
+
let outputType: Type = null;
|
|
25
25
|
const expectedType = context.expectedType;
|
|
26
26
|
if (expectedType && expectedType.kind !== 'value') {
|
|
27
27
|
outputType = expectedType;
|
|
@@ -46,7 +46,7 @@ class Coalesce implements Expression {
|
|
|
46
46
|
|
|
47
47
|
return needsAnnotation ?
|
|
48
48
|
new Coalesce(ValueType, parsedArgs) :
|
|
49
|
-
new Coalesce(
|
|
49
|
+
new Coalesce(outputType, parsedArgs);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
evaluate(ctx: EvaluationContext): any {
|
|
@@ -101,7 +101,7 @@ class Config implements Expression {
|
|
|
101
101
|
if (typeof result === 'number') {
|
|
102
102
|
result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
|
|
103
103
|
} else if (Array.isArray(result)) {
|
|
104
|
-
result = result.map((item) => typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
|
|
104
|
+
result = result.map((item) => (typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -167,17 +167,7 @@ export default class ImageExpression implements Expression {
|
|
|
167
167
|
for (const key in params) {
|
|
168
168
|
if (params[key]) {
|
|
169
169
|
try {
|
|
170
|
-
|
|
171
|
-
const msg = `Ignoring image parameter "${key}" with semi-transparent color ${color.toString()}`;
|
|
172
|
-
|
|
173
|
-
if (color.a !== 1) {
|
|
174
|
-
if (!this._imageWarnHistory[msg]) {
|
|
175
|
-
console.warn(msg);
|
|
176
|
-
this._imageWarnHistory[msg] = true;
|
|
177
|
-
}
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
result[key] = color;
|
|
170
|
+
result[key] = params[key].evaluate(ctx);
|
|
181
171
|
} catch (err) {
|
|
182
172
|
continue;
|
|
183
173
|
}
|
|
@@ -47,6 +47,7 @@ import Distance from './distance';
|
|
|
47
47
|
import {mulberry32} from '../../util/random';
|
|
48
48
|
|
|
49
49
|
import type {Type} from '../types';
|
|
50
|
+
import type {Value} from '../values';
|
|
50
51
|
import type EvaluationContext from '../evaluation_context';
|
|
51
52
|
import type {Varargs} from '../compound_expression';
|
|
52
53
|
import type {Expression, ExpressionRegistry} from '../expression';
|
|
@@ -242,7 +243,7 @@ CompoundExpression.register(expressions, {
|
|
|
242
243
|
'properties': [
|
|
243
244
|
ObjectType,
|
|
244
245
|
[],
|
|
245
|
-
(ctx) => ctx.properties()
|
|
246
|
+
(ctx) => ctx.properties() as Value
|
|
246
247
|
],
|
|
247
248
|
'geometry-type': [
|
|
248
249
|
StringType,
|
|
@@ -302,7 +303,7 @@ CompoundExpression.register(expressions, {
|
|
|
302
303
|
'accumulated': [
|
|
303
304
|
ValueType,
|
|
304
305
|
[],
|
|
305
|
-
(ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated
|
|
306
|
+
(ctx) => (ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated)
|
|
306
307
|
],
|
|
307
308
|
'+': [
|
|
308
309
|
NumberType,
|
|
@@ -91,7 +91,7 @@ class Interpolate implements Expression {
|
|
|
91
91
|
|
|
92
92
|
interpolation = {
|
|
93
93
|
name: 'cubic-bezier',
|
|
94
|
-
controlPoints
|
|
94
|
+
controlPoints
|
|
95
95
|
};
|
|
96
96
|
} else {
|
|
97
97
|
return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);
|
|
@@ -110,7 +110,7 @@ class Interpolate implements Expression {
|
|
|
110
110
|
|
|
111
111
|
const stops: Stops = [];
|
|
112
112
|
|
|
113
|
-
let outputType: Type =
|
|
113
|
+
let outputType: Type = null;
|
|
114
114
|
if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {
|
|
115
115
|
outputType = ColorType;
|
|
116
116
|
} else if (context.expectedType && context.expectedType.kind !== 'value') {
|
|
@@ -179,7 +179,7 @@ class Interpolate implements Expression {
|
|
|
179
179
|
const outputUpper = outputs[index + 1].evaluate(ctx);
|
|
180
180
|
|
|
181
181
|
if (this.operator === 'interpolate') {
|
|
182
|
-
return (interpolate[this.type.kind.toLowerCase()] as any)(outputLower, outputUpper, t);
|
|
182
|
+
return (interpolate[this.type.kind.toLowerCase()] as any)(outputLower, outputUpper, t);
|
|
183
183
|
} else if (this.operator === 'interpolate-hcl') {
|
|
184
184
|
return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
|
|
185
185
|
} else {
|
|
@@ -138,7 +138,7 @@ class Match implements Expression {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const coerceLabel = (label: number | string) => this.inputType.kind === 'number' ? Number(label) : label;
|
|
141
|
+
const coerceLabel = (label: number | string) => (this.inputType.kind === 'number' ? Number(label) : label);
|
|
142
142
|
|
|
143
143
|
for (const [outputIndex, labels] of groupedByOutput) {
|
|
144
144
|
if (labels.length === 1) {
|
|
@@ -27,7 +27,7 @@ class EvaluationContext {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
constructor(scope?: string | null, options?: ConfigOptions | null) {
|
|
30
|
-
this.globals =
|
|
30
|
+
this.globals = null;
|
|
31
31
|
this.feature = null;
|
|
32
32
|
this.featureState = null;
|
|
33
33
|
this.formattedSection = null;
|
|
@@ -40,7 +40,7 @@ class EvaluationContext {
|
|
|
40
40
|
this.options = options;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
id(): number | null {
|
|
43
|
+
id(): string | number | null {
|
|
44
44
|
return this.feature && this.feature.id !== undefined ? this.feature.id : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -56,9 +56,7 @@ class EvaluationContext {
|
|
|
56
56
|
return this.canonical;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
properties(): {
|
|
60
|
-
[key: string]: any;
|
|
61
|
-
} {
|
|
59
|
+
properties(): {readonly [key: string]: unknown} {
|
|
62
60
|
return (this.feature && this.feature.properties) || {};
|
|
63
61
|
}
|
|
64
62
|
|
package/expression/index.ts
CHANGED
|
@@ -39,13 +39,9 @@ import type {ImageId} from './types/image_id';
|
|
|
39
39
|
|
|
40
40
|
export interface Feature {
|
|
41
41
|
readonly type: 0 | 1 | 2 | 3 | 'Unknown' | 'Point' | 'LineString' | 'Polygon';
|
|
42
|
-
readonly id?: number | null;
|
|
43
|
-
readonly properties:
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
readonly patterns?: {
|
|
47
|
-
[_: string]: string;
|
|
48
|
-
};
|
|
42
|
+
readonly id?: string | number | null;
|
|
43
|
+
readonly properties: Record<PropertyKey, unknown>;
|
|
44
|
+
readonly patterns?: Record<PropertyKey, string>;
|
|
49
45
|
readonly geometry?: Array<Array<Point>>;
|
|
50
46
|
}
|
|
51
47
|
|
|
@@ -135,7 +131,7 @@ export class StyleExpression {
|
|
|
135
131
|
throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);
|
|
136
132
|
}
|
|
137
133
|
return val;
|
|
138
|
-
} catch (e
|
|
134
|
+
} catch (e) {
|
|
139
135
|
if (!this._warningHistory[e.message]) {
|
|
140
136
|
this._warningHistory[e.message] = true;
|
|
141
137
|
if (typeof console !== 'undefined') {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {Brand} from '../../types/brand';
|
|
2
2
|
|
|
3
|
+
const separator = '\u001F';
|
|
4
|
+
|
|
3
5
|
export type ImageIdSpec = {
|
|
4
6
|
name: string;
|
|
5
7
|
iconsetId?: string;
|
|
@@ -35,16 +37,12 @@ export class ImageId {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
static toString(id: ImageId | ImageIdSpec): StringifiedImageId {
|
|
38
|
-
return
|
|
40
|
+
return (id.iconsetId ? `${id.name}${separator}${id.iconsetId}` : id.name) as StringifiedImageId;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
static parse(str: StringifiedImageId): ImageId | null {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return new ImageId({name, iconsetId});
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
44
|
+
const [name, iconsetId] = str.split(separator);
|
|
45
|
+
return new ImageId({name, iconsetId});
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
static isEqual(a: ImageId | ImageIdSpec, b: ImageId | ImageIdSpec): boolean {
|
|
@@ -52,7 +50,7 @@ export class ImageId {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
toString(): StringifiedImageId {
|
|
55
|
-
return
|
|
53
|
+
return ImageId.toString(this);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
serialize(): ImageIdSpec {
|
package/expression/types.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type ResolvedImageTypeT = {
|
|
|
34
34
|
|
|
35
35
|
export type EvaluationKind = 'constant' | 'source' | 'camera' | 'composite';
|
|
36
36
|
|
|
37
|
-
export type Type = NullTypeT | NumberTypeT | StringTypeT | BooleanTypeT | ColorTypeT | ObjectTypeT | ValueTypeT |
|
|
37
|
+
export type Type = NullTypeT | NumberTypeT | StringTypeT | BooleanTypeT | ColorTypeT | ObjectTypeT | ValueTypeT |
|
|
38
38
|
ArrayType | ErrorTypeT | CollatorTypeT | FormattedTypeT | ResolvedImageTypeT;
|
|
39
39
|
|
|
40
40
|
export type ArrayType = {
|
package/expression/values.ts
CHANGED
|
@@ -51,9 +51,7 @@ export function validateHSLA(h: unknown, s: unknown, l: unknown, a?: unknown): s
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {
|
|
55
|
-
readonly [key: string]: Value;
|
|
56
|
-
};
|
|
54
|
+
export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {readonly [key: string]: Value};
|
|
57
55
|
|
|
58
56
|
export function isValue(mixed: unknown): boolean {
|
|
59
57
|
if (mixed === null) {
|
package/feature_filter/index.ts
CHANGED
|
@@ -99,7 +99,7 @@ function createFilter(filter?: FilterSpecification, scope: string = "", options:
|
|
|
99
99
|
let staticFilter = true;
|
|
100
100
|
try {
|
|
101
101
|
staticFilter = extractStaticFilter(filterExp);
|
|
102
|
-
} catch (e
|
|
102
|
+
} catch (e) {
|
|
103
103
|
console.warn(
|
|
104
104
|
`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
|
|
105
105
|
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
|
package/function/index.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function createFunction(parameters, propertySpec) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
|
|
46
|
+
if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
|
|
47
47
|
throw new Error(`Unknown color space: ${parameters.colorSpace}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -175,10 +175,10 @@ function evaluateExponentialFunction(parameters, propertySpec, input) {
|
|
|
175
175
|
|
|
176
176
|
const outputLower = parameters.stops[index][1];
|
|
177
177
|
const outputUpper = parameters.stops[index + 1][1];
|
|
178
|
-
let interp = interpolate[propertySpec.type] || identityFunction;
|
|
178
|
+
let interp = interpolate[propertySpec.type] || identityFunction;
|
|
179
179
|
|
|
180
180
|
if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
|
|
181
|
-
const colorspace = colorSpaces[parameters.colorSpace];
|
|
181
|
+
const colorspace = colorSpaces[parameters.colorSpace];
|
|
182
182
|
interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
|
|
183
183
|
}
|
|
184
184
|
|
package/migrate/expressions.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {StyleSpecification, FunctionSpecification} from '../types';
|
|
|
10
10
|
* this will convert (a) "stop" functions, and (b) legacy filters to their
|
|
11
11
|
* expression equivalents.
|
|
12
12
|
*/
|
|
13
|
-
export default function(style: StyleSpecification): StyleSpecification {
|
|
13
|
+
export default function (style: StyleSpecification): StyleSpecification {
|
|
14
14
|
const converted = [];
|
|
15
15
|
|
|
16
16
|
eachLayer(style, (layer) => {
|
package/migrate/v8.ts
CHANGED
package/migrate/v9.ts
CHANGED
package/migrate.ts
CHANGED
|
@@ -17,7 +17,7 @@ import migrateToExpressions from './migrate/expressions';
|
|
|
17
17
|
* var style = fs.readFileSync('./style.json', 'utf8');
|
|
18
18
|
* fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
|
|
19
19
|
*/
|
|
20
|
-
export default function(style) {
|
|
20
|
+
export default function (style) {
|
|
21
21
|
let migrated = false;
|
|
22
22
|
|
|
23
23
|
if (style.version === 7) {
|
package/package.json
CHANGED
package/read_style.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
|
|
4
1
|
import ParsingError from './error/parsing_error';
|
|
5
2
|
import jsonlint from '@mapbox/jsonlint-lines-primitives';
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
import type {StyleSpecification} from './types';
|
|
5
|
+
|
|
6
|
+
export default function readStyle(style: string | Buffer | StyleSpecification): StyleSpecification {
|
|
8
7
|
if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
|
|
9
8
|
try {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
11
9
|
return jsonlint.parse(style.toString());
|
|
12
|
-
} catch (e
|
|
10
|
+
} catch (e) {
|
|
13
11
|
throw new ParsingError(e);
|
|
14
12
|
}
|
|
15
13
|
}
|