@mapbox/mapbox-gl-style-spec 14.4.0 → 14.5.0
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/bin/gl-style-composite.js +0 -5
- package/bin/gl-style-format.js +0 -5
- package/bin/gl-style-migrate.js +0 -5
- package/bin/gl-style-validate.js +0 -5
- package/{composite.js → composite.ts} +1 -1
- package/data/{extent.js → extent.ts} +0 -2
- package/{deref.js → deref.ts} +7 -9
- package/{diff.js → diff.ts} +44 -21
- package/dist/index.cjs +794 -1226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1746 -0
- package/dist/index.es.js +794 -1226
- package/dist/index.es.js.map +1 -1
- package/{empty.js → empty.ts} +1 -2
- package/error/{parsing_error.js → parsing_error.ts} +0 -2
- package/error/{validation_error.js → validation_error.ts} +5 -5
- package/expression/{compound_expression.js → compound_expression.ts} +29 -19
- package/expression/definitions/{assertion.js → assertion.ts} +16 -13
- package/expression/definitions/{at.js → at.ts} +12 -13
- package/expression/definitions/{case.js → case.ts} +12 -11
- package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
- package/expression/definitions/{coercion.js → coercion.ts} +21 -20
- package/expression/definitions/{collator.js → collator.ts} +11 -11
- package/expression/definitions/{comparison.js → comparison.ts} +30 -24
- package/expression/definitions/{config.js → config.ts} +16 -16
- package/expression/definitions/{distance.js → distance.ts} +60 -52
- package/expression/definitions/{format.js → format.ts} +26 -15
- package/expression/definitions/{image.js → image.ts} +12 -12
- package/expression/definitions/{in.js → in.ts} +22 -13
- package/expression/definitions/{index.js → index.ts} +70 -83
- package/expression/definitions/{index_of.js → index_of.ts} +24 -15
- package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
- package/expression/definitions/{length.js → length.ts} +11 -10
- package/expression/definitions/{let.js → let.ts} +10 -7
- package/expression/definitions/{literal.js → literal.ts} +11 -12
- package/expression/definitions/{match.js → match.ts} +25 -15
- package/expression/definitions/{number_format.js → number_format.ts} +10 -10
- package/expression/definitions/{slice.js → slice.ts} +23 -15
- package/expression/definitions/{step.js → step.ts} +14 -12
- package/expression/definitions/{var.js → var.ts} +5 -7
- package/expression/definitions/{within.js → within.ts} +41 -29
- package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
- package/expression/expression.ts +29 -0
- package/expression/{index.js → index.ts} +208 -110
- package/expression/{is_constant.js → is_constant.ts} +5 -7
- package/expression/{parsing_context.js → parsing_context.ts} +47 -34
- package/expression/{parsing_error.js → parsing_error.ts} +0 -2
- package/expression/{runtime_error.js → runtime_error.ts} +0 -2
- package/expression/{scope.js → scope.ts} +5 -5
- package/expression/{stops.js → stops.ts} +2 -4
- package/expression/types/{collator.js → collator.ts} +1 -3
- package/expression/types/{formatted.js → formatted.ts} +8 -7
- package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
- package/expression/{types.js → types.ts} +53 -45
- package/expression/{values.js → values.ts} +12 -12
- package/feature_filter/{convert.js → convert.ts} +19 -18
- package/feature_filter/{index.js → index.ts} +39 -21
- package/{format.js → format.ts} +3 -3
- package/function/{convert.js → convert.ts} +44 -44
- package/function/{index.js → index.ts} +12 -12
- package/{group_by_layout.js → group_by_layout.ts} +11 -8
- package/migrate/{expressions.js → expressions.ts} +7 -16
- package/migrate/{v8.js → v8.ts} +2 -2
- package/migrate/{v9.js → v9.ts} +2 -2
- package/{migrate.js → migrate.ts} +3 -3
- package/package.json +19 -18
- package/{read_style.js → read_style.ts} +5 -4
- package/reference/latest.ts +5 -0
- package/reference/v8.json +264 -7
- package/rollup.config.js +6 -24
- package/{style-spec.js → style-spec.ts} +41 -36
- package/test.js +3 -2
- package/types/config_options.ts +13 -0
- package/types/lut.ts +7 -0
- package/types/tile_id.ts +5 -0
- package/{types.js → types.ts} +527 -165
- package/util/{color.js → color.ts} +89 -3
- package/util/{color_spaces.js → color_spaces.ts} +12 -14
- package/util/{deep_equal.js → deep_equal.ts} +1 -3
- package/util/{extend.js → extend.ts} +1 -3
- package/util/{geometry_util.js → geometry_util.ts} +23 -11
- package/util/{get_type.js → get_type.ts} +1 -3
- package/util/{interpolate.js → interpolate.ts} +1 -3
- package/util/{properties.js → properties.ts} +5 -4
- package/util/{random.js → random.ts} +0 -2
- package/util/{ref_properties.js → ref_properties.ts} +0 -1
- package/util/{result.js → result.ts} +7 -5
- package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
- package/validate/{validate.js → validate.ts} +33 -35
- package/validate/{validate_array.js → validate_array.ts} +5 -7
- package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
- package/validate/{validate_color.js → validate_color.ts} +3 -5
- package/validate/{validate_enum.js → validate_enum.ts} +4 -5
- package/validate/{validate_expression.js → validate_expression.ts} +7 -9
- package/validate/{validate_filter.js → validate_filter.ts} +16 -12
- package/validate/{validate_fog.js → validate_fog.ts} +4 -6
- package/validate/validate_formatted.ts +13 -0
- package/validate/{validate_function.js → validate_function.ts} +14 -16
- package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
- package/validate/validate_image.ts +13 -0
- package/validate/{validate_import.js → validate_import.ts} +6 -8
- package/validate/{validate_layer.js → validate_layer.ts} +17 -15
- package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
- package/validate/{validate_light.js → validate_light.ts} +4 -6
- package/validate/{validate_lights.js → validate_lights.ts} +7 -9
- package/validate/{validate_model.js → validate_model.ts} +4 -6
- package/validate/{validate_number.js → validate_number.ts} +4 -6
- package/validate/{validate_object.js → validate_object.ts} +5 -8
- package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
- package/validate/{validate_projection.js → validate_projection.ts} +4 -6
- package/validate/{validate_property.js → validate_property.ts} +15 -15
- package/validate/{validate_source.js → validate_source.ts} +16 -13
- package/validate/validate_string.ts +16 -0
- package/validate/validate_style.ts +33 -0
- package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
- package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
- package/{validate_style.min.js → validate_style.min.ts} +20 -21
- package/{validate_style.js → validate_style.ts} +9 -9
- package/{visit.js → visit.ts} +22 -17
- package/.eslintrc +0 -10
- package/expression/expression.js +0 -28
- package/flow-typed/cheap-ruler.js +0 -25
- package/flow-typed/geojson.js +0 -44
- package/flow-typed/gl-matrix.js +0 -119
- package/flow-typed/gl.js +0 -5
- package/flow-typed/intl.js +0 -58
- package/flow-typed/kdbush.js +0 -9
- package/flow-typed/mapbox-gl-supported.js +0 -16
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -26
- package/flow-typed/point-geometry.js +0 -46
- package/flow-typed/potpack.js +0 -13
- package/flow-typed/tiny-sdf.js +0 -31
- package/flow-typed/tracked_parameters_proxy.js +0 -82
- package/flow-typed/vector-tile.js +0 -49
- package/flow-typed/webgl2.js +0 -41
- package/reference/latest.js +0 -7
- package/validate/validate_formatted.js +0 -15
- package/validate/validate_image.js +0 -15
- package/validate/validate_string.js +0 -18
- package/validate/validate_style.js +0 -29
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import {toString, ValueType, BooleanType, CollatorType} from '../types';
|
|
2
|
+
import Assertion from './assertion';
|
|
3
|
+
import {typeOf} from '../values';
|
|
4
|
+
import RuntimeError from '../runtime_error';
|
|
2
5
|
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
6
|
+
import type {Expression, SerializedExpression, ExpressionRegistration} from '../expression';
|
|
7
|
+
import type EvaluationContext from '../evaluation_context';
|
|
8
|
+
import type ParsingContext from '../parsing_context';
|
|
9
|
+
import type {Type} from '../types';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
import type EvaluationContext from '../evaluation_context.js';
|
|
10
|
-
import type ParsingContext from '../parsing_context.js';
|
|
11
|
-
import type {Type} from '../types.js';
|
|
12
|
-
|
|
13
|
-
type ComparisonOperator = '==' | '!=' | '<' | '>' | '<=' | '>=' ;
|
|
11
|
+
type ComparisonOperator = '==' | '!=' | '<' | '>' | '<=' | '>=';
|
|
14
12
|
|
|
15
13
|
function isComparableType(op: ComparisonOperator, type: Type) {
|
|
16
14
|
if (op === '==' || op === '!=') {
|
|
@@ -59,18 +57,21 @@ function gteqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean {
|
|
|
59
57
|
*
|
|
60
58
|
* @private
|
|
61
59
|
*/
|
|
62
|
-
function makeComparison(
|
|
60
|
+
function makeComparison(
|
|
61
|
+
op: ComparisonOperator,
|
|
62
|
+
compareBasic: (arg1: EvaluationContext, arg2?: any, arg3?: any) => boolean,
|
|
63
|
+
compareWithCollator: (arg1: EvaluationContext, arg2?: any, arg3?: any, arg4?: any) => boolean,
|
|
64
|
+
): ExpressionRegistration {
|
|
63
65
|
const isOrderComparison = op !== '==' && op !== '!=';
|
|
64
66
|
|
|
65
|
-
// $FlowFixMe[method-unbinding]
|
|
66
67
|
return class Comparison implements Expression {
|
|
67
68
|
type: Type;
|
|
68
69
|
lhs: Expression;
|
|
69
70
|
rhs: Expression;
|
|
70
|
-
collator:
|
|
71
|
+
collator: Expression | null | undefined;
|
|
71
72
|
hasUntypedArgument: boolean;
|
|
72
73
|
|
|
73
|
-
constructor(lhs: Expression, rhs: Expression, collator
|
|
74
|
+
constructor(lhs: Expression, rhs: Expression, collator?: Expression | null) {
|
|
74
75
|
this.type = BooleanType;
|
|
75
76
|
this.lhs = lhs;
|
|
76
77
|
this.rhs = rhs;
|
|
@@ -78,21 +79,23 @@ function makeComparison(op: ComparisonOperator, compareBasic: (EvaluationContext
|
|
|
78
79
|
this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
static parse(args: $ReadOnlyArray<mixed>, context: ParsingContext): ?Expression {
|
|
82
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | null | undefined {
|
|
83
83
|
if (args.length !== 3 && args.length !== 4)
|
|
84
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
84
85
|
return context.error(`Expected two or three arguments.`);
|
|
85
86
|
|
|
86
|
-
const op: ComparisonOperator = (args[0]
|
|
87
|
+
const op: ComparisonOperator = (args[0] as any);
|
|
87
88
|
|
|
88
89
|
let lhs = context.parse(args[1], 1, ValueType);
|
|
89
90
|
if (!lhs) return null;
|
|
90
91
|
if (!isComparableType(op, lhs.type)) {
|
|
92
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
91
93
|
return context.concat(1).error(`"${op}" comparisons are not supported for type '${toString(lhs.type)}'.`);
|
|
92
94
|
}
|
|
93
95
|
let rhs = context.parse(args[2], 2, ValueType);
|
|
94
96
|
if (!rhs) return null;
|
|
95
97
|
if (!isComparableType(op, rhs.type)) {
|
|
98
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
96
99
|
return context.concat(2).error(`"${op}" comparisons are not supported for type '${toString(rhs.type)}'.`);
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -101,6 +104,7 @@ function makeComparison(op: ComparisonOperator, compareBasic: (EvaluationContext
|
|
|
101
104
|
lhs.type.kind !== 'value' &&
|
|
102
105
|
rhs.type.kind !== 'value'
|
|
103
106
|
) {
|
|
107
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
104
108
|
return context.error(`Cannot compare types '${toString(lhs.type)}' and '${toString(rhs.type)}'.`);
|
|
105
109
|
}
|
|
106
110
|
|
|
@@ -123,6 +127,7 @@ function makeComparison(op: ComparisonOperator, compareBasic: (EvaluationContext
|
|
|
123
127
|
lhs.type.kind !== 'value' &&
|
|
124
128
|
rhs.type.kind !== 'value'
|
|
125
129
|
) {
|
|
130
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
126
131
|
return context.error(`Cannot use collator to compare non-string types.`);
|
|
127
132
|
}
|
|
128
133
|
collator = context.parse(args[3], 3, CollatorType);
|
|
@@ -172,15 +177,16 @@ function makeComparison(op: ComparisonOperator, compareBasic: (EvaluationContext
|
|
|
172
177
|
|
|
173
178
|
serialize(): SerializedExpression {
|
|
174
179
|
const serialized = [op];
|
|
180
|
+
// @ts-expect-error - TS2345 - Argument of type 'SerializedExpression' is not assignable to parameter of type 'ComparisonOperator'.
|
|
175
181
|
this.eachChild(child => { serialized.push(child.serialize()); });
|
|
176
182
|
return serialized;
|
|
177
183
|
}
|
|
178
184
|
};
|
|
179
185
|
}
|
|
180
186
|
|
|
181
|
-
export const Equals:
|
|
182
|
-
export const NotEquals:
|
|
183
|
-
export const LessThan:
|
|
184
|
-
export const GreaterThan:
|
|
185
|
-
export const LessThanOrEqual:
|
|
186
|
-
export const GreaterThanOrEqual:
|
|
187
|
+
export const Equals: ReturnType<typeof makeComparison> = makeComparison('==', eq, eqCollate);
|
|
188
|
+
export const NotEquals: ReturnType<typeof makeComparison> = makeComparison('!=', neq, neqCollate);
|
|
189
|
+
export const LessThan: ReturnType<typeof makeComparison> = makeComparison('<', lt, ltCollate);
|
|
190
|
+
export const GreaterThan: ReturnType<typeof makeComparison> = makeComparison('>', gt, gtCollate);
|
|
191
|
+
export const LessThanOrEqual: ReturnType<typeof makeComparison> = makeComparison('<=', lteq, lteqCollate);
|
|
192
|
+
export const GreaterThanOrEqual: ReturnType<typeof makeComparison> = makeComparison('>=', gteq, gteqCollate);
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {ValueType} from '../types';
|
|
2
|
+
import {Color, typeOf, toString as valueToString} from '../values';
|
|
3
|
+
import Formatted from '../types/formatted';
|
|
4
|
+
import ResolvedImage from '../types/resolved_image';
|
|
5
|
+
import Literal from './literal';
|
|
2
6
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {Color, typeOf, toString as valueToString} from '../values.js';
|
|
8
|
-
import Formatted from '../types/formatted.js';
|
|
9
|
-
import ResolvedImage from '../types/resolved_image.js';
|
|
10
|
-
import Literal from './literal.js';
|
|
11
|
-
|
|
12
|
-
import type {Expression, SerializedExpression} from '../expression.js';
|
|
13
|
-
import type ParsingContext from '../parsing_context.js';
|
|
14
|
-
import type EvaluationContext from '../evaluation_context.js';
|
|
7
|
+
import type {Type} from '../types';
|
|
8
|
+
import type {Expression, SerializedExpression} from '../expression';
|
|
9
|
+
import type ParsingContext from '../parsing_context';
|
|
10
|
+
import type EvaluationContext from '../evaluation_context';
|
|
15
11
|
|
|
16
12
|
function coerceValue(type: string, value: any): any {
|
|
17
13
|
switch (type) {
|
|
@@ -29,7 +25,7 @@ function coerceValue(type: string, value: any): any {
|
|
|
29
25
|
return value;
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
function clampToAllowedNumber(value: number, min
|
|
28
|
+
function clampToAllowedNumber(value: number, min?: number, max?: number, step?: number): number {
|
|
33
29
|
if (step !== undefined) {
|
|
34
30
|
value = step * Math.round(value / step);
|
|
35
31
|
}
|
|
@@ -45,7 +41,7 @@ function clampToAllowedNumber(value: number, min: number | void, max: number | v
|
|
|
45
41
|
class Config implements Expression {
|
|
46
42
|
type: Type;
|
|
47
43
|
key: string;
|
|
48
|
-
scope:
|
|
44
|
+
scope: string | null | undefined;
|
|
49
45
|
|
|
50
46
|
constructor(type: Type, key: string, scope?: string) {
|
|
51
47
|
this.type = type;
|
|
@@ -53,23 +49,26 @@ class Config implements Expression {
|
|
|
53
49
|
this.scope = scope;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
static parse(args:
|
|
52
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Config | null | undefined {
|
|
57
53
|
let type = context.expectedType;
|
|
58
54
|
if (type === null || type === undefined) {
|
|
59
55
|
type = ValueType;
|
|
60
56
|
}
|
|
61
57
|
if (args.length < 2 || args.length > 3) {
|
|
58
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Config'.
|
|
62
59
|
return context.error(`Invalid number of arguments for 'config' expression.`);
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
const configKey = context.parse(args[1], 1);
|
|
66
63
|
if (!(configKey instanceof Literal)) {
|
|
64
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Config'.
|
|
67
65
|
return context.error(`Key name of 'config' expression must be a string literal.`);
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
if (args.length >= 3) {
|
|
71
69
|
const configScope = context.parse(args[2], 2);
|
|
72
70
|
if (!(configScope instanceof Literal)) {
|
|
71
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Config'.
|
|
73
72
|
return context.error(`Scope of 'config' expression must be a string literal.`);
|
|
74
73
|
}
|
|
75
74
|
return new Config(type, valueToString(configKey.value), valueToString(configScope.value));
|
|
@@ -117,6 +116,7 @@ class Config implements Expression {
|
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
|
|
119
|
+
// @ts-expect-error - TS2367 - This comparison appears to be unintentional because the types 'string' and 'Type' have no overlap.
|
|
120
120
|
if ((type && type !== this.type) || (result !== undefined && typeOf(result) !== this.type)) {
|
|
121
121
|
result = coerceValue(this.type.kind, result);
|
|
122
122
|
}
|
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import type {Type} from "../types.js";
|
|
5
|
-
import {NumberType} from "../types.js";
|
|
6
|
-
import type {Expression} from "../expression.js";
|
|
7
|
-
import type ParsingContext from "../parsing_context.js";
|
|
8
|
-
import type EvaluationContext from "../evaluation_context.js";
|
|
9
|
-
import type {
|
|
10
|
-
GeoJSON,
|
|
11
|
-
GeoJSONPosition,
|
|
12
|
-
GeoJSONPoint,
|
|
13
|
-
GeoJSONMultiPoint,
|
|
14
|
-
GeoJSONLineString,
|
|
15
|
-
GeoJSONMultiLineString,
|
|
16
|
-
GeoJSONPolygon,
|
|
17
|
-
GeoJSONMultiPolygon
|
|
18
|
-
} from "@mapbox/geojson-types";
|
|
19
|
-
import type {CanonicalTileID} from '../../../source/tile_id.js';
|
|
20
|
-
import {classifyRings, updateBBox, boxWithinBox, pointWithinPolygon, segmentIntersectSegment} from '../../util/geometry_util.js';
|
|
21
|
-
import type {BBox} from '../../util/geometry_util.js';
|
|
1
|
+
import {isValue} from '../values';
|
|
2
|
+
import {NumberType} from '../types';
|
|
3
|
+
import {classifyRings, updateBBox, boxWithinBox, pointWithinPolygon, segmentIntersectSegment} from '../../util/geometry_util';
|
|
22
4
|
import CheapRuler from "cheap-ruler";
|
|
23
5
|
import Point from "@mapbox/point-geometry";
|
|
24
6
|
import TinyQueue from "tinyqueue";
|
|
25
|
-
import EXTENT from
|
|
7
|
+
import EXTENT from '../../data/extent';
|
|
26
8
|
|
|
27
|
-
type
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
import type ParsingContext from '../parsing_context';
|
|
10
|
+
import type {BBox} from '../../util/geometry_util';
|
|
11
|
+
import type {Type} from '../types';
|
|
12
|
+
import type {Expression} from '../expression';
|
|
13
|
+
import type {CanonicalTileID} from '../../types/tile_id';
|
|
14
|
+
import type EvaluationContext from '../evaluation_context';
|
|
15
|
+
|
|
16
|
+
type DistanceGeometry = GeoJSON.Point | GeoJSON.MultiPoint | GeoJSON.LineString | GeoJSON.MultiLineString | GeoJSON.Polygon | GeoJSON.MultiPolygon;
|
|
34
17
|
|
|
35
18
|
// Inclusive index range for multipoint or linestring container
|
|
36
19
|
type IndexRange = [number, number];
|
|
37
|
-
type DistPair = {
|
|
20
|
+
type DistPair = {
|
|
21
|
+
dist: number;
|
|
22
|
+
range1: IndexRange;
|
|
23
|
+
range2: IndexRange;
|
|
24
|
+
};
|
|
38
25
|
function compareMax(a: DistPair, b: DistPair) {
|
|
39
26
|
return b.dist - a.dist;
|
|
40
27
|
}
|
|
@@ -92,19 +79,21 @@ function splitRange(range: IndexRange, isLine: boolean) {
|
|
|
92
79
|
}
|
|
93
80
|
}
|
|
94
81
|
|
|
95
|
-
function getBBox(pointSets: Array<
|
|
82
|
+
function getBBox(pointSets: Array<GeoJSON.Position>, range: IndexRange) {
|
|
96
83
|
const bbox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
97
84
|
if (!isRangeSafe(range, pointSets.length)) return bbox;
|
|
98
85
|
for (let i = range[0]; i <= range[1]; ++i) {
|
|
86
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
99
87
|
updateBBox(bbox, pointSets[i]);
|
|
100
88
|
}
|
|
101
89
|
return bbox;
|
|
102
90
|
}
|
|
103
91
|
|
|
104
|
-
function getPolygonBBox(polygon: Array<Array<
|
|
92
|
+
function getPolygonBBox(polygon: Array<Array<GeoJSON.Position>>) {
|
|
105
93
|
const bbox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
106
94
|
for (let i = 0; i < polygon.length; ++i) {
|
|
107
95
|
for (let j = 0; j < polygon[i].length; ++j) {
|
|
96
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
108
97
|
updateBBox(bbox, polygon[i][j]);
|
|
109
98
|
}
|
|
110
99
|
}
|
|
@@ -163,12 +152,14 @@ function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID)
|
|
|
163
152
|
return coords;
|
|
164
153
|
}
|
|
165
154
|
|
|
166
|
-
function pointToLineDistance(point:
|
|
155
|
+
function pointToLineDistance(point: GeoJSON.Position, line: Array<GeoJSON.Position>, ruler: CheapRuler) {
|
|
156
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position[]' is not assignable to parameter of type 'Line'.
|
|
167
157
|
const nearestPoint = ruler.pointOnLine(line, point).point;
|
|
158
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
168
159
|
return ruler.distance(point, nearestPoint);
|
|
169
160
|
}
|
|
170
161
|
|
|
171
|
-
function pointsToLineDistance(points: Array<
|
|
162
|
+
function pointsToLineDistance(points: Array<GeoJSON.Position>, rangeA: IndexRange, line: Array<GeoJSON.Position>, rangeB: IndexRange, ruler: CheapRuler) {
|
|
172
163
|
const subLine = line.slice(rangeB[0], rangeB[1] + 1);
|
|
173
164
|
let dist = Infinity;
|
|
174
165
|
for (let i = rangeA[0]; i <= rangeA[1]; ++i) {
|
|
@@ -178,20 +169,24 @@ function pointsToLineDistance(points: Array<GeoJSONPosition>, rangeA: IndexRange
|
|
|
178
169
|
}
|
|
179
170
|
|
|
180
171
|
// precondition is two segments are not intersecting with each other
|
|
181
|
-
function segmentToSegmentDistance(p1:
|
|
172
|
+
function segmentToSegmentDistance(p1: GeoJSON.Position, p2: GeoJSON.Position, q1: GeoJSON.Position, q2: GeoJSON.Position, ruler: CheapRuler) {
|
|
182
173
|
const dist1 = Math.min(
|
|
174
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
183
175
|
ruler.pointToSegmentDistance(p1, q1, q2),
|
|
176
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
184
177
|
ruler.pointToSegmentDistance(p2, q1, q2)
|
|
185
178
|
);
|
|
186
179
|
const dist2 = Math.min(
|
|
180
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
187
181
|
ruler.pointToSegmentDistance(q1, p1, p2),
|
|
182
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
188
183
|
ruler.pointToSegmentDistance(q2, p1, p2)
|
|
189
184
|
);
|
|
190
185
|
|
|
191
186
|
return Math.min(dist1, dist2);
|
|
192
187
|
}
|
|
193
188
|
|
|
194
|
-
function lineToLineDistance(line1: Array<
|
|
189
|
+
function lineToLineDistance(line1: Array<GeoJSON.Position>, range1: IndexRange, line2: Array<GeoJSON.Position>, range2: IndexRange, ruler: CheapRuler) {
|
|
195
190
|
if (!isRangeSafe(range1, line1.length) || !isRangeSafe(range2, line2.length)) {
|
|
196
191
|
return NaN;
|
|
197
192
|
}
|
|
@@ -205,20 +200,21 @@ function lineToLineDistance(line1: Array<GeoJSONPosition>, range1: IndexRange, l
|
|
|
205
200
|
return dist;
|
|
206
201
|
}
|
|
207
202
|
|
|
208
|
-
function pointsToPointsDistance(pointSet1: Array<
|
|
203
|
+
function pointsToPointsDistance(pointSet1: Array<GeoJSON.Position>, range1: IndexRange, pointSet2: Array<GeoJSON.Position>, range2: IndexRange, ruler: CheapRuler) {
|
|
209
204
|
if (!isRangeSafe(range1, pointSet1.length) || !isRangeSafe(range2, pointSet2.length)) {
|
|
210
205
|
return NaN;
|
|
211
206
|
}
|
|
212
207
|
let dist = Infinity;
|
|
213
208
|
for (let i = range1[0]; i <= range1[1]; ++i) {
|
|
214
209
|
for (let j = range2[0]; j <= range2[1]; ++j) {
|
|
210
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
215
211
|
if ((dist = Math.min(dist, ruler.distance(pointSet1[i], pointSet2[j]))) === 0.0) return dist;
|
|
216
212
|
}
|
|
217
213
|
}
|
|
218
214
|
return dist;
|
|
219
215
|
}
|
|
220
216
|
|
|
221
|
-
function pointToPolygonDistance(point:
|
|
217
|
+
function pointToPolygonDistance(point: GeoJSON.Position, polygon: Array<Array<GeoJSON.Position>>, ruler: CheapRuler) {
|
|
222
218
|
if (pointWithinPolygon(point, polygon, true /*trueOnBoundary*/)) return 0.0;
|
|
223
219
|
let dist = Infinity;
|
|
224
220
|
for (const ring of polygon) {
|
|
@@ -228,6 +224,7 @@ function pointToPolygonDistance(point: GeoJSONPosition, polygon: Array<Array<Geo
|
|
|
228
224
|
return NaN;
|
|
229
225
|
}
|
|
230
226
|
if (ring[0] !== ring[ringLen - 1]) {
|
|
227
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
231
228
|
if ((dist = Math.min(dist, ruler.pointToSegmentDistance(point, ring[ringLen - 1], ring[0]))) === 0.0) return dist;
|
|
232
229
|
}
|
|
233
230
|
if ((dist = Math.min(dist, pointToLineDistance(point, ring, ruler))) === 0.0) return dist;
|
|
@@ -235,7 +232,7 @@ function pointToPolygonDistance(point: GeoJSONPosition, polygon: Array<Array<Geo
|
|
|
235
232
|
return dist;
|
|
236
233
|
}
|
|
237
234
|
|
|
238
|
-
function lineToPolygonDistance(line: Array<
|
|
235
|
+
function lineToPolygonDistance(line: Array<GeoJSON.Position>, range: IndexRange, polygon: Array<Array<GeoJSON.Position>>, ruler: CheapRuler) {
|
|
239
236
|
if (!isRangeSafe(range, line.length)) {
|
|
240
237
|
return NaN;
|
|
241
238
|
}
|
|
@@ -254,7 +251,7 @@ function lineToPolygonDistance(line: Array<GeoJSONPosition>, range: IndexRange,
|
|
|
254
251
|
return dist;
|
|
255
252
|
}
|
|
256
253
|
|
|
257
|
-
function polygonIntersect(polygon1: Array<Array<
|
|
254
|
+
function polygonIntersect(polygon1: Array<Array<GeoJSON.Position>>, polygon2: Array<Array<GeoJSON.Position>>) {
|
|
258
255
|
for (const ring of polygon1) {
|
|
259
256
|
for (let i = 0; i <= ring.length - 1; ++i) {
|
|
260
257
|
if (pointWithinPolygon(ring[i], polygon2, true /*trueOnBoundary*/)) return true;
|
|
@@ -263,12 +260,14 @@ function polygonIntersect(polygon1: Array<Array<GeoJSONPosition>>, polygon2: Arr
|
|
|
263
260
|
return false;
|
|
264
261
|
}
|
|
265
262
|
|
|
266
|
-
function polygonToPolygonDistance(polygon1: Array<Array<
|
|
263
|
+
function polygonToPolygonDistance(polygon1: Array<Array<GeoJSON.Position>>, polygon2: Array<Array<GeoJSON.Position>>, ruler: CheapRuler, currentMiniDist: number = Infinity) {
|
|
267
264
|
const bbox1 = getPolygonBBox(polygon1);
|
|
268
265
|
const bbox2 = getPolygonBBox(polygon2);
|
|
266
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
269
267
|
if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, ruler) >= currentMiniDist) {
|
|
270
268
|
return currentMiniDist;
|
|
271
269
|
}
|
|
270
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
272
271
|
if (boxWithinBox(bbox1, bbox2)) {
|
|
273
272
|
if (polygonIntersect(polygon1, polygon2)) return 0.0;
|
|
274
273
|
} else if (polygonIntersect(polygon2, polygon1)) {
|
|
@@ -288,8 +287,9 @@ function polygonToPolygonDistance(polygon1: Array<Array<GeoJSONPosition>>, polyg
|
|
|
288
287
|
return dist;
|
|
289
288
|
}
|
|
290
289
|
|
|
291
|
-
function updateQueue(distQueue: any, miniDist: number, ruler: CheapRuler, pointSet1: Array<
|
|
290
|
+
function updateQueue(distQueue: any, miniDist: number, ruler: CheapRuler, pointSet1: Array<GeoJSON.Position>, pointSet2: Array<GeoJSON.Position>, r1: IndexRange | null, r2: IndexRange | null) {
|
|
292
291
|
if (r1 === null || r2 === null) return;
|
|
292
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
293
293
|
const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
|
|
294
294
|
// Insert new pair to the queue if the bbox distance is less than miniDist, the pair with biggest distance will be at the top
|
|
295
295
|
if (tempDist < miniDist) distQueue.push({dist: tempDist, range1: r1, range2: r2});
|
|
@@ -297,7 +297,8 @@ function updateQueue(distQueue: any, miniDist: number, ruler: CheapRuler, pointS
|
|
|
297
297
|
|
|
298
298
|
// Divide and conquer, the time complexity is O(n*lgn), faster than Brute force O(n*n)
|
|
299
299
|
// Most of the time, use index for in-place processing.
|
|
300
|
-
function pointSetToPolygonDistance(pointSets: Array<
|
|
300
|
+
function pointSetToPolygonDistance(pointSets: Array<GeoJSON.Position>, isLine: boolean, polygon: Array<Array<GeoJSON.Position>>, ruler: CheapRuler, currentMiniDist: number = Infinity) {
|
|
301
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
301
302
|
let miniDist = Math.min(ruler.distance(pointSets[0], polygon[0][0]), currentMiniDist);
|
|
302
303
|
if (miniDist === 0.0) return miniDist;
|
|
303
304
|
const initialDistPair: DistPair = {
|
|
@@ -329,10 +330,12 @@ function pointSetToPolygonDistance(pointSets: Array<GeoJSONPosition>, isLine: bo
|
|
|
329
330
|
} else {
|
|
330
331
|
const newRanges = splitRange(range, isLine);
|
|
331
332
|
if (newRanges[0] !== null) {
|
|
333
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
332
334
|
const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[0]), polyBBox, ruler);
|
|
333
335
|
if (tempDist < miniDist) distQueue.push({dist: tempDist, range1: newRanges[0], range2: [0, 0]});
|
|
334
336
|
}
|
|
335
337
|
if (newRanges[1] !== null) {
|
|
338
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
336
339
|
const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[1]), polyBBox, ruler);
|
|
337
340
|
if (tempDist < miniDist) distQueue.push({dist: tempDist, range1: newRanges[1], range2: [0, 0]});
|
|
338
341
|
}
|
|
@@ -341,7 +344,8 @@ function pointSetToPolygonDistance(pointSets: Array<GeoJSONPosition>, isLine: bo
|
|
|
341
344
|
return miniDist;
|
|
342
345
|
}
|
|
343
346
|
|
|
344
|
-
function pointSetsDistance(pointSet1: Array<
|
|
347
|
+
function pointSetsDistance(pointSet1: Array<GeoJSON.Position>, isLine1: boolean, pointSet2: Array<GeoJSON.Position>, isLine2: boolean, ruler: CheapRuler, currentMiniDist: number = Infinity) {
|
|
348
|
+
// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
345
349
|
let miniDist = Math.min(currentMiniDist, ruler.distance(pointSet1[0], pointSet2[0]));
|
|
346
350
|
if (miniDist === 0.0) return miniDist;
|
|
347
351
|
const initialDistPair: DistPair = {
|
|
@@ -386,10 +390,11 @@ function pointSetsDistance(pointSet1: Array<GeoJSONPosition>, isLine1: boolean,
|
|
|
386
390
|
return miniDist;
|
|
387
391
|
}
|
|
388
392
|
|
|
389
|
-
function pointSetToLinesDistance(pointSet: Array<
|
|
393
|
+
function pointSetToLinesDistance(pointSet: Array<GeoJSON.Position>, isLine: boolean, lines: Array<Array<GeoJSON.Position>>, ruler: CheapRuler, currentMiniDist: number = Infinity) {
|
|
390
394
|
let dist = currentMiniDist;
|
|
391
395
|
const bbox1 = getBBox(pointSet, [0, pointSet.length - 1]);
|
|
392
396
|
for (const line of lines) {
|
|
397
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
393
398
|
if (dist !== Infinity && bboxToBBoxDistance(bbox1, getBBox(line, [0, line.length - 1]), ruler) >= dist) continue;
|
|
394
399
|
dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true /*isLine*/, ruler, dist));
|
|
395
400
|
if (dist === 0.0) return dist;
|
|
@@ -397,10 +402,11 @@ function pointSetToLinesDistance(pointSet: Array<GeoJSONPosition>, isLine: boole
|
|
|
397
402
|
return dist;
|
|
398
403
|
}
|
|
399
404
|
|
|
400
|
-
function pointSetToPolygonsDistance(points: Array<
|
|
405
|
+
function pointSetToPolygonsDistance(points: Array<GeoJSON.Position>, isLine: boolean, polygons: Array<Array<Array<GeoJSON.Position>>>, ruler: CheapRuler, currentMiniDist: number = Infinity) {
|
|
401
406
|
let dist = currentMiniDist;
|
|
402
407
|
const bbox1 = getBBox(points, [0, points.length - 1]);
|
|
403
408
|
for (const polygon of polygons) {
|
|
409
|
+
// @ts-expect-error - TS2345 - Argument of type 'number[]' is not assignable to parameter of type 'BBox'.
|
|
404
410
|
if (dist !== Infinity && bboxToBBoxDistance(bbox1, getPolygonBBox(polygon), ruler) >= dist) continue;
|
|
405
411
|
const tempDist = pointSetToPolygonDistance(points, isLine, polygon, ruler, dist);
|
|
406
412
|
if (isNaN(tempDist)) return tempDist;
|
|
@@ -409,7 +415,7 @@ function pointSetToPolygonsDistance(points: Array<GeoJSONPosition>, isLine: bool
|
|
|
409
415
|
return dist;
|
|
410
416
|
}
|
|
411
417
|
|
|
412
|
-
function polygonsToPolygonsDistance(polygons1: Array<Array<Array<
|
|
418
|
+
function polygonsToPolygonsDistance(polygons1: Array<Array<Array<GeoJSON.Position>>>, polygons2: Array<Array<Array<GeoJSON.Position>>>, ruler: CheapRuler) {
|
|
413
419
|
let dist = Infinity;
|
|
414
420
|
for (const polygon1 of polygons1) {
|
|
415
421
|
for (const polygon2 of polygons2) {
|
|
@@ -526,24 +532,25 @@ function isTypeValid(type: string) {
|
|
|
526
532
|
}
|
|
527
533
|
class Distance implements Expression {
|
|
528
534
|
type: Type;
|
|
529
|
-
geojson: GeoJSON;
|
|
535
|
+
geojson: GeoJSON.GeoJSON;
|
|
530
536
|
geometries: DistanceGeometry;
|
|
531
537
|
|
|
532
|
-
constructor(geojson: GeoJSON, geometries: DistanceGeometry) {
|
|
538
|
+
constructor(geojson: GeoJSON.GeoJSON, geometries: DistanceGeometry) {
|
|
533
539
|
this.type = NumberType;
|
|
534
540
|
this.geojson = geojson;
|
|
535
541
|
this.geometries = geometries;
|
|
536
542
|
}
|
|
537
543
|
|
|
538
|
-
static parse(args:
|
|
544
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Distance | null | undefined {
|
|
539
545
|
if (args.length !== 2) {
|
|
546
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Distance'.
|
|
540
547
|
return context.error(
|
|
541
548
|
`'distance' expression requires either one argument, but found ' ${args.length -
|
|
542
549
|
1} instead.`
|
|
543
550
|
);
|
|
544
551
|
}
|
|
545
552
|
if (isValue(args[1])) {
|
|
546
|
-
const geojson = (args[1]
|
|
553
|
+
const geojson = (args[1] as any);
|
|
547
554
|
if (geojson.type === 'FeatureCollection') {
|
|
548
555
|
for (let i = 0; i < geojson.features.length; ++i) {
|
|
549
556
|
if (isTypeValid(geojson.features[i].geometry.type)) {
|
|
@@ -558,6 +565,7 @@ class Distance implements Expression {
|
|
|
558
565
|
return new Distance(geojson, geojson);
|
|
559
566
|
}
|
|
560
567
|
}
|
|
568
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Distance'.
|
|
561
569
|
return context.error(
|
|
562
570
|
"'distance' expression needs to be an array with format [\'Distance\', GeoJSONObj]."
|
|
563
571
|
);
|
|
@@ -589,7 +597,7 @@ class Distance implements Expression {
|
|
|
589
597
|
return true;
|
|
590
598
|
}
|
|
591
599
|
|
|
592
|
-
serialize(): Array<
|
|
600
|
+
serialize(): Array<unknown> {
|
|
593
601
|
return ['distance', this.geojson];
|
|
594
602
|
}
|
|
595
603
|
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
NumberType,
|
|
3
|
+
ValueType,
|
|
4
|
+
FormattedType,
|
|
5
|
+
array,
|
|
6
|
+
StringType,
|
|
7
|
+
ColorType,
|
|
8
|
+
ResolvedImageType,
|
|
9
|
+
} from '../types';
|
|
10
|
+
import Formatted, {FormattedSection} from '../types/formatted';
|
|
11
|
+
import {toString, typeOf} from '../values';
|
|
12
|
+
|
|
13
|
+
import type {Expression, SerializedExpression} from '../expression';
|
|
14
|
+
import type EvaluationContext from '../evaluation_context';
|
|
15
|
+
import type ParsingContext from '../parsing_context';
|
|
16
|
+
import type {Type} from '../types';
|
|
11
17
|
|
|
12
18
|
export type FormattedSectionExpression = {
|
|
13
19
|
// Content of a section may be Image expression or other
|
|
14
20
|
// type of expression that is coercable to 'string'.
|
|
15
|
-
content: Expression
|
|
21
|
+
content: Expression;
|
|
16
22
|
scale: Expression | null;
|
|
17
23
|
font: Expression | null;
|
|
18
24
|
textColor: Expression | null;
|
|
19
|
-
}
|
|
25
|
+
};
|
|
20
26
|
|
|
21
27
|
export default class FormatExpression implements Expression {
|
|
22
28
|
type: Type;
|
|
@@ -27,20 +33,22 @@ export default class FormatExpression implements Expression {
|
|
|
27
33
|
this.sections = sections;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
static parse(args:
|
|
36
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | null | undefined {
|
|
31
37
|
if (args.length < 2) {
|
|
38
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
32
39
|
return context.error(`Expected at least one argument.`);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
const firstArg = args[1];
|
|
36
43
|
if (!Array.isArray(firstArg) && typeof firstArg === 'object') {
|
|
44
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
37
45
|
return context.error(`First argument must be an image or text section.`);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
const sections: Array<FormattedSectionExpression> = [];
|
|
41
49
|
let nextTokenMayBeObject = false;
|
|
42
50
|
for (let i = 1; i <= args.length - 1; ++i) {
|
|
43
|
-
const arg = (args[i]
|
|
51
|
+
const arg = (args[i] as any);
|
|
44
52
|
|
|
45
53
|
if (nextTokenMayBeObject && typeof arg === "object" && !Array.isArray(arg)) {
|
|
46
54
|
nextTokenMayBeObject = false;
|
|
@@ -73,6 +81,7 @@ export default class FormatExpression implements Expression {
|
|
|
73
81
|
|
|
74
82
|
const kind = content.type.kind;
|
|
75
83
|
if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')
|
|
84
|
+
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
76
85
|
return context.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);
|
|
77
86
|
|
|
78
87
|
nextTokenMayBeObject = true;
|
|
@@ -126,8 +135,9 @@ export default class FormatExpression implements Expression {
|
|
|
126
135
|
serialize(): SerializedExpression {
|
|
127
136
|
const serialized = ["format"];
|
|
128
137
|
for (const section of this.sections) {
|
|
138
|
+
// @ts-expect-error - TS2345 - Argument of type 'SerializedExpression' is not assignable to parameter of type 'string'.
|
|
129
139
|
serialized.push(section.content.serialize());
|
|
130
|
-
const options = {};
|
|
140
|
+
const options: Record<string, any> = {};
|
|
131
141
|
if (section.scale) {
|
|
132
142
|
options['font-scale'] = section.scale.serialize();
|
|
133
143
|
}
|
|
@@ -137,6 +147,7 @@ export default class FormatExpression implements Expression {
|
|
|
137
147
|
if (section.textColor) {
|
|
138
148
|
options['text-color'] = section.textColor.serialize();
|
|
139
149
|
}
|
|
150
|
+
// @ts-expect-error - TS2345 - Argument of type 'Record<string, any>' is not assignable to parameter of type 'string'.
|
|
140
151
|
serialized.push(options);
|
|
141
152
|
}
|
|
142
153
|
return serialized;
|