@mapbox/mapbox-gl-style-spec 14.15.0-beta.1 → 14.15.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/deref.ts +3 -0
- package/diff.ts +63 -0
- package/dist/index.cjs +743 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +85 -6
- package/dist/index.es.js +743 -65
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +4 -0
- package/expression/definitions/assertion.ts +7 -0
- package/expression/definitions/case.ts +2 -1
- package/expression/definitions/coalesce.ts +4 -0
- package/expression/definitions/coercion.ts +12 -0
- package/expression/definitions/collator.ts +8 -5
- package/expression/definitions/comparison.ts +12 -5
- package/expression/definitions/config.ts +12 -0
- package/expression/definitions/distance.ts +13 -2
- package/expression/definitions/format.ts +10 -0
- package/expression/definitions/image.ts +3 -0
- package/expression/definitions/in.ts +5 -0
- package/expression/definitions/index.ts +62 -10
- package/expression/definitions/index_of.ts +6 -0
- package/expression/definitions/interpolate.ts +5 -1
- package/expression/definitions/length.ts +2 -0
- package/expression/definitions/let.ts +1 -0
- package/expression/definitions/match.ts +5 -0
- package/expression/definitions/number_format.ts +7 -0
- package/expression/definitions/slice.ts +4 -0
- package/expression/definitions/within.ts +1 -0
- package/expression/index.ts +28 -19
- package/expression/parsing_context.ts +2 -0
- package/expression/types/image_variant.ts +3 -0
- package/expression/types.ts +1 -2
- package/expression/values.ts +1 -0
- package/feature_filter/convert.ts +9 -1
- package/feature_filter/index.ts +41 -1
- package/format.ts +5 -0
- package/function/convert.ts +5 -0
- package/function/index.ts +79 -25
- package/group_by_layout.ts +4 -5
- package/migrate/v8.ts +42 -3
- package/migrate/v9.ts +5 -0
- package/migrate.ts +1 -0
- package/package.json +1 -1
- package/read_style.ts +2 -0
- package/reference/v8.json +457 -12
- package/rollup.config.js +1 -0
- package/test.js +4 -0
- package/types.ts +74 -5
- package/util/color.ts +21 -26
- package/util/geometry_util.ts +4 -0
- package/validate/validate.ts +1 -0
- package/validate/validate_appearance.ts +101 -0
- package/validate/validate_array.ts +1 -0
- package/validate/validate_expression.ts +48 -3
- package/validate/validate_filter.ts +5 -3
- package/validate/validate_fog.ts +6 -0
- package/validate/validate_function.ts +2 -0
- package/validate/validate_iconset.ts +1 -0
- package/validate/validate_import.ts +2 -2
- package/validate/validate_layer.ts +37 -4
- package/validate/validate_light.ts +6 -0
- package/validate/validate_lights.ts +9 -0
- package/validate/validate_model.ts +1 -2
- package/validate/validate_number.ts +2 -0
- package/validate/validate_object.ts +7 -0
- package/validate/validate_projection.ts +2 -0
- package/validate/validate_property.ts +15 -4
- package/validate/validate_rain.ts +5 -0
- package/validate/validate_snow.ts +5 -0
- package/validate/validate_source.ts +12 -0
- package/validate/validate_style.ts +1 -0
- package/validate/validate_terrain.ts +6 -0
- package/validate_mapbox_api_supported.ts +1 -0
- package/visit.ts +2 -0
- package/util/extend.ts +0 -9
package/expression/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import extend from '../util/extend';
|
|
3
2
|
import ParsingError from './parsing_error';
|
|
4
3
|
import ParsingContext from './parsing_context';
|
|
5
4
|
import EvaluationContext from './evaluation_context';
|
|
@@ -127,6 +126,7 @@ export class StyleExpression {
|
|
|
127
126
|
this._evaluator.iconImageUseTheme = iconImageUseTheme || null;
|
|
128
127
|
|
|
129
128
|
try {
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
130
130
|
const val = this.expression.evaluate(this._evaluator);
|
|
131
131
|
// eslint-disable-next-line no-self-compare
|
|
132
132
|
if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {
|
|
@@ -137,9 +137,12 @@ export class StyleExpression {
|
|
|
137
137
|
}
|
|
138
138
|
return val;
|
|
139
139
|
} catch (e) {
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
140
141
|
if (!this._warningHistory[e.message]) {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
141
143
|
this._warningHistory[e.message] = true;
|
|
142
144
|
if (typeof console !== 'undefined') {
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
143
146
|
console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`);
|
|
144
147
|
}
|
|
145
148
|
}
|
|
@@ -284,7 +287,7 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
|
|
|
284
287
|
export type ConstantExpression = {
|
|
285
288
|
kind: 'constant';
|
|
286
289
|
configDependencies: Set<string>;
|
|
287
|
-
readonly evaluate: (
|
|
290
|
+
readonly evaluate: <T = unknown>(
|
|
288
291
|
globals: GlobalProperties,
|
|
289
292
|
feature?: Feature,
|
|
290
293
|
featureState?: FeatureState,
|
|
@@ -292,8 +295,7 @@ export type ConstantExpression = {
|
|
|
292
295
|
availableImages?: ImageId[],
|
|
293
296
|
formattedSection?: FormattedSection,
|
|
294
297
|
iconImageUseTheme?: string
|
|
295
|
-
|
|
296
|
-
) => any;
|
|
298
|
+
) => T;
|
|
297
299
|
};
|
|
298
300
|
|
|
299
301
|
export type SourceExpression = {
|
|
@@ -302,29 +304,27 @@ export type SourceExpression = {
|
|
|
302
304
|
isLightConstant: boolean | null | undefined;
|
|
303
305
|
isLineProgressConstant: boolean | null | undefined;
|
|
304
306
|
configDependencies: Set<string>;
|
|
305
|
-
readonly evaluate: (
|
|
307
|
+
readonly evaluate: <T = unknown>(
|
|
306
308
|
globals: GlobalProperties,
|
|
307
309
|
feature?: Feature,
|
|
308
310
|
featureState?: FeatureState,
|
|
309
311
|
canonical?: CanonicalTileID,
|
|
310
312
|
availableImages?: ImageId[],
|
|
311
313
|
formattedSection?: FormattedSection,
|
|
312
|
-
|
|
313
|
-
) => any;
|
|
314
|
+
) => T;
|
|
314
315
|
};
|
|
315
316
|
|
|
316
317
|
export type CameraExpression = {
|
|
317
318
|
kind: 'camera';
|
|
318
319
|
isStateDependent: boolean;
|
|
319
320
|
configDependencies: Set<string>;
|
|
320
|
-
readonly evaluate: (
|
|
321
|
+
readonly evaluate: <T = unknown>(
|
|
321
322
|
globals: GlobalProperties,
|
|
322
323
|
feature?: Feature,
|
|
323
324
|
featureState?: FeatureState,
|
|
324
325
|
canonical?: CanonicalTileID,
|
|
325
326
|
availableImages?: ImageId[],
|
|
326
|
-
|
|
327
|
-
) => any;
|
|
327
|
+
) => T;
|
|
328
328
|
readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
|
|
329
329
|
zoomStops: Array<number>;
|
|
330
330
|
interpolationType: InterpolationType | null | undefined;
|
|
@@ -336,7 +336,7 @@ export interface CompositeExpression {
|
|
|
336
336
|
isLightConstant: boolean | null | undefined;
|
|
337
337
|
isLineProgressConstant: boolean | null | undefined;
|
|
338
338
|
configDependencies: Set<string>;
|
|
339
|
-
readonly evaluate: (
|
|
339
|
+
readonly evaluate: <T = unknown>(
|
|
340
340
|
globals: GlobalProperties,
|
|
341
341
|
feature?: Feature,
|
|
342
342
|
featureState?: FeatureState,
|
|
@@ -344,8 +344,7 @@ export interface CompositeExpression {
|
|
|
344
344
|
availableImages?: ImageId[],
|
|
345
345
|
formattedSection?: FormattedSection,
|
|
346
346
|
iconImageUseTheme?: string
|
|
347
|
-
|
|
348
|
-
) => any;
|
|
347
|
+
) => T;
|
|
349
348
|
readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
|
|
350
349
|
zoomStops: Array<number>;
|
|
351
350
|
interpolationType: InterpolationType | null | undefined;
|
|
@@ -362,33 +361,40 @@ export function createPropertyExpression(
|
|
|
362
361
|
iconImageUseTheme?: string | null
|
|
363
362
|
): Result<StylePropertyExpression, Array<ParsingError>> {
|
|
364
363
|
expression = createExpression(expression, propertySpec, scope, options, iconImageUseTheme);
|
|
364
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
365
365
|
if (expression.result === 'error') {
|
|
366
366
|
return expression as Result<StylePropertyExpression, Array<ParsingError>>;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
369
370
|
const parsed = expression.value.expression;
|
|
370
371
|
|
|
372
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
371
373
|
const isFeatureConstant = isConstant.isFeatureConstant(parsed);
|
|
372
374
|
if (!isFeatureConstant && !supportsPropertyExpression(propertySpec)) {
|
|
373
375
|
return error([new ParsingError('', 'data expressions not supported')]);
|
|
374
376
|
}
|
|
375
377
|
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
376
379
|
const isZoomConstant = isConstant.isGlobalPropertyConstant(parsed, ['zoom', 'pitch', 'distance-from-center']);
|
|
377
380
|
if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {
|
|
378
381
|
return error([new ParsingError('', 'zoom expressions not supported')]);
|
|
379
382
|
}
|
|
380
383
|
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
381
385
|
const isLightConstant = isConstant.isGlobalPropertyConstant(parsed, ['measure-light']);
|
|
382
386
|
if (!isLightConstant && !supportsLightExpression(propertySpec)) {
|
|
383
387
|
return error([new ParsingError('', 'measure-light expression not supported')]);
|
|
384
388
|
}
|
|
385
389
|
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
386
391
|
const isLineProgressConstant = isConstant.isGlobalPropertyConstant(parsed, ['line-progress']);
|
|
387
392
|
if (!isLineProgressConstant && !supportsLineProgressExpression(propertySpec)) {
|
|
388
393
|
return error([new ParsingError('', 'line-progress expression not supported')]);
|
|
389
394
|
}
|
|
390
395
|
|
|
391
396
|
const canRelaxZoomRestriction = propertySpec.expression && propertySpec.expression.relaxZoomRestriction;
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
392
398
|
const zoomCurve = findZoomCurve(parsed);
|
|
393
399
|
if (!zoomCurve && !isZoomConstant && !canRelaxZoomRestriction) {
|
|
394
400
|
return error([new ParsingError('', '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')]);
|
|
@@ -400,14 +406,18 @@ export function createPropertyExpression(
|
|
|
400
406
|
|
|
401
407
|
if (!zoomCurve) {
|
|
402
408
|
return success((isFeatureConstant && isLineProgressConstant) ?
|
|
409
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
403
410
|
(new ZoomConstantExpression('constant', expression.value, isLightConstant, isLineProgressConstant) as ConstantExpression) :
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
404
412
|
(new ZoomConstantExpression('source', expression.value, isLightConstant, isLineProgressConstant) as SourceExpression));
|
|
405
413
|
}
|
|
406
414
|
|
|
407
415
|
const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;
|
|
408
416
|
|
|
409
417
|
return success((isFeatureConstant && isLineProgressConstant) ?
|
|
418
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
410
419
|
(new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant) as CameraExpression) :
|
|
420
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
411
421
|
(new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant) as CompositeExpression));
|
|
412
422
|
}
|
|
413
423
|
|
|
@@ -418,15 +428,14 @@ export class StylePropertyFunction<T> {
|
|
|
418
428
|
_specification: StylePropertySpecification;
|
|
419
429
|
|
|
420
430
|
kind: EvaluationKind;
|
|
421
|
-
|
|
422
|
-
evaluate: (globals: GlobalProperties, feature?: Feature) => any;
|
|
431
|
+
evaluate: <T = unknown>(globals: GlobalProperties, feature?: Feature) => T;
|
|
423
432
|
interpolationFactor: (input: number, lower: number, upper: number) => number | null | undefined;
|
|
424
433
|
zoomStops: Array<number> | null | undefined;
|
|
425
434
|
|
|
426
435
|
constructor(parameters: PropertyValueSpecification<T>, specification: StylePropertySpecification) {
|
|
427
436
|
this._parameters = parameters;
|
|
428
437
|
this._specification = specification;
|
|
429
|
-
|
|
438
|
+
Object.assign(this, createFunction(this._parameters, this._specification));
|
|
430
439
|
}
|
|
431
440
|
|
|
432
441
|
static deserialize<T>(
|
|
@@ -468,15 +477,15 @@ export function normalizePropertyExpression<T>(
|
|
|
468
477
|
return expression.value;
|
|
469
478
|
|
|
470
479
|
} else {
|
|
471
|
-
let constant = value
|
|
480
|
+
let constant = value;
|
|
472
481
|
if (typeof value === 'string' && specification.type === 'color') {
|
|
473
|
-
constant = Color.parse(value)
|
|
482
|
+
constant = Color.parse(value) as PropertyValueSpecification<T>;
|
|
474
483
|
}
|
|
475
484
|
return {
|
|
476
485
|
kind: 'constant',
|
|
477
486
|
configDependencies: new Set(),
|
|
478
487
|
evaluate: () => constant
|
|
479
|
-
};
|
|
488
|
+
} as ConstantExpression;
|
|
480
489
|
}
|
|
481
490
|
}
|
|
482
491
|
|
|
@@ -159,8 +159,10 @@ class ParsingContext {
|
|
|
159
159
|
if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && isConstant(parsed)) {
|
|
160
160
|
const ec = new EvaluationContext(this._scope, this.options, this.iconImageUseTheme);
|
|
161
161
|
try {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
162
163
|
parsed = new Literal(parsed.type, parsed.evaluate(ec));
|
|
163
164
|
} catch (e) {
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
164
166
|
this.error(e.message);
|
|
165
167
|
return null;
|
|
166
168
|
}
|
|
@@ -61,6 +61,7 @@ export class ImageVariant {
|
|
|
61
61
|
let name, iconsetId, params, transform;
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
64
65
|
({name, iconsetId, params, transform} = JSON.parse(str) || {});
|
|
65
66
|
} catch (e) {
|
|
66
67
|
return null;
|
|
@@ -68,7 +69,9 @@ export class ImageVariant {
|
|
|
68
69
|
|
|
69
70
|
if (!name) return null;
|
|
70
71
|
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
71
73
|
const {a, b, c, d, e, f} = transform || {};
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
72
75
|
return new ImageVariant({name, iconsetId}, {params, transform: new DOMMatrix([a, b, c, d, e, f])});
|
|
73
76
|
}
|
|
74
77
|
|
package/expression/types.ts
CHANGED
|
@@ -131,8 +131,7 @@ export function isValidType(provided: Type, allowedTypes: Array<Type>): boolean
|
|
|
131
131
|
return allowedTypes.some(t => t.kind === provided.kind);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
export function isValidNativeType(provided: any, allowedTypes: Array<NativeType>): boolean {
|
|
134
|
+
export function isValidNativeType(provided: unknown, allowedTypes: Array<NativeType>): boolean {
|
|
136
135
|
return allowedTypes.some(t => {
|
|
137
136
|
if (t === 'null') {
|
|
138
137
|
return provided === null;
|
package/expression/values.ts
CHANGED
|
@@ -81,29 +81,37 @@ function _convertFilter(filter: FilterSpecification, expectedTypes: ExpectedType
|
|
|
81
81
|
op === '>='
|
|
82
82
|
) {
|
|
83
83
|
const [, property, value] = filter;
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
84
85
|
converted = convertComparisonOp(property, value, op, expectedTypes);
|
|
85
86
|
} else if (op === 'any') {
|
|
86
87
|
const children = filter.slice(1).map(f => {
|
|
87
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
89
|
const types: Record<string, any> = {};
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
89
91
|
const child = _convertFilter(f, types);
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
90
93
|
const typechecks = runtimeTypeChecks(types);
|
|
91
94
|
return typechecks === true ? child : ['case', typechecks, child, false];
|
|
92
95
|
}) as ExpressionSpecification;
|
|
93
96
|
return ['any'].concat(children);
|
|
94
97
|
} else if (op === 'all') {
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
96
99
|
const children: any[] = (filter).slice(1).map(f => _convertFilter(f, expectedTypes));
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
97
101
|
return children.length > 1 ? ['all'].concat(children) : [].concat(...children);
|
|
98
102
|
} else if (op === 'none') {
|
|
99
103
|
return ['!', _convertFilter(['any'].concat((filter).slice(1)), {})];
|
|
100
104
|
} else if (op === 'in') {
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
101
106
|
converted = convertInOp((filter[1]), filter.slice(2));
|
|
102
107
|
} else if (op === '!in') {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
103
109
|
converted = convertInOp((filter[1]), filter.slice(2), true);
|
|
104
110
|
} else if (op === 'has') {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
105
112
|
converted = convertHasOp((filter[1]));
|
|
106
113
|
} else if (op === '!has') {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
107
115
|
converted = ['!', convertHasOp((filter[1]))];
|
|
108
116
|
} else {
|
|
109
117
|
converted = true;
|
package/feature_filter/index.ts
CHANGED
|
@@ -98,6 +98,7 @@ function createFilter(filter?: FilterSpecification, scope: string = "", options:
|
|
|
98
98
|
|
|
99
99
|
let staticFilter = true;
|
|
100
100
|
try {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
101
102
|
staticFilter = extractStaticFilter(filterExp);
|
|
102
103
|
} catch (e) {
|
|
103
104
|
console.warn(
|
|
@@ -114,8 +115,10 @@ ${JSON.stringify(filterExp, null, 2)}
|
|
|
114
115
|
let filterFunc = null;
|
|
115
116
|
let filterSpec = null;
|
|
116
117
|
if (layerType !== 'background' && layerType !== 'sky' && layerType !== 'slot') {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
117
119
|
filterSpec = latest[`filter_${layerType}`];
|
|
118
120
|
assert(filterSpec);
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
119
122
|
const compiledStaticFilter = createExpression(staticFilter, filterSpec, scope, options);
|
|
120
123
|
|
|
121
124
|
if (compiledStaticFilter.result === 'error') {
|
|
@@ -131,6 +134,7 @@ ${JSON.stringify(filterExp, null, 2)}
|
|
|
131
134
|
let dynamicFilterFunc = null;
|
|
132
135
|
let needFeature = null;
|
|
133
136
|
if (staticFilter !== filterExp) {
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
134
138
|
const compiledDynamicFilter = createExpression(filterExp, filterSpec, scope, options);
|
|
135
139
|
|
|
136
140
|
if (compiledDynamicFilter.result === 'error') {
|
|
@@ -146,7 +150,9 @@ ${JSON.stringify(filterExp, null, 2)}
|
|
|
146
150
|
const needGeometry = geometryNeeded(staticFilter);
|
|
147
151
|
|
|
148
152
|
return {
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
149
154
|
filter: filterFunc,
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
150
156
|
dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : undefined,
|
|
151
157
|
needGeometry,
|
|
152
158
|
needFeature: !!needFeature
|
|
@@ -177,11 +183,12 @@ function collapseDynamicBooleanExpressions(expression: any): any {
|
|
|
177
183
|
return expression;
|
|
178
184
|
}
|
|
179
185
|
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
180
187
|
const collapsed = collapsedExpression(expression);
|
|
181
188
|
if (collapsed === true) {
|
|
182
189
|
return collapsed;
|
|
183
190
|
} else {
|
|
184
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
185
192
|
return collapsed.map((subExpression) => collapseDynamicBooleanExpressions(subExpression));
|
|
186
193
|
}
|
|
187
194
|
}
|
|
@@ -200,35 +207,53 @@ function unionDynamicBranches(filter: any) {
|
|
|
200
207
|
let isBranchingDynamically = false;
|
|
201
208
|
const branches = [];
|
|
202
209
|
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
203
211
|
if (filter[0] === 'case') {
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
204
213
|
for (let i = 1; i < filter.length - 1; i += 2) {
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
205
215
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[i]);
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
206
217
|
branches.push(filter[i + 1]);
|
|
207
218
|
}
|
|
208
219
|
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
209
221
|
branches.push(filter[filter.length - 1]);
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
210
223
|
} else if (filter[0] === 'match') {
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
211
225
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
|
|
212
226
|
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
213
228
|
for (let i = 2; i < filter.length - 1; i += 2) {
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
214
230
|
branches.push(filter[i + 1]);
|
|
215
231
|
}
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
216
233
|
branches.push(filter[filter.length - 1]);
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
217
235
|
} else if (filter[0] === 'step') {
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
218
237
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
|
|
219
238
|
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
220
240
|
for (let i = 1; i < filter.length - 1; i += 2) {
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
221
242
|
branches.push(filter[i + 1]);
|
|
222
243
|
}
|
|
223
244
|
}
|
|
224
245
|
|
|
225
246
|
if (isBranchingDynamically) {
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
226
248
|
filter.length = 0;
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
227
250
|
filter.push('any', ...branches);
|
|
228
251
|
}
|
|
229
252
|
|
|
230
253
|
// traverse and recurse into children
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
231
255
|
for (let i = 1; i < filter.length; i++) {
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
232
257
|
unionDynamicBranches(filter[i]);
|
|
233
258
|
}
|
|
234
259
|
}
|
|
@@ -239,11 +264,13 @@ function isDynamicFilter(filter: any): boolean {
|
|
|
239
264
|
if (!Array.isArray(filter)) {
|
|
240
265
|
return false;
|
|
241
266
|
}
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
242
268
|
if (isRootExpressionDynamic(filter[0])) {
|
|
243
269
|
return true;
|
|
244
270
|
}
|
|
245
271
|
|
|
246
272
|
for (let i = 1; i < filter.length; i++) {
|
|
273
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
247
274
|
const child = filter[i];
|
|
248
275
|
if (isDynamicFilter(child)) {
|
|
249
276
|
return true;
|
|
@@ -271,9 +298,12 @@ const dynamicConditionExpressions = new Set([
|
|
|
271
298
|
|
|
272
299
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
300
|
function collapsedExpression(expression: any): any {
|
|
301
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
274
302
|
if (dynamicConditionExpressions.has(expression[0])) {
|
|
275
303
|
|
|
304
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
276
305
|
for (let i = 1; i < expression.length; i++) {
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
277
307
|
const param = expression[i];
|
|
278
308
|
if (isDynamicFilter(param)) {
|
|
279
309
|
return true;
|
|
@@ -293,6 +323,7 @@ function geometryNeeded(filter: Array<any> | boolean) {
|
|
|
293
323
|
if (!Array.isArray(filter)) return false;
|
|
294
324
|
if (filter[0] === 'within' || filter[0] === 'distance') return true;
|
|
295
325
|
for (let index = 1; index < filter.length; index++) {
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
296
327
|
if (geometryNeeded(filter[index])) return true;
|
|
297
328
|
}
|
|
298
329
|
return false;
|
|
@@ -301,23 +332,32 @@ function geometryNeeded(filter: Array<any> | boolean) {
|
|
|
301
332
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
302
333
|
function convertFilter(filter?: Array<any> | null): unknown {
|
|
303
334
|
if (!filter) return true;
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
304
336
|
const op = filter[0];
|
|
305
337
|
if (filter.length <= 1) return (op !== 'any');
|
|
306
338
|
const converted =
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
307
340
|
op === '==' ? convertComparisonOp(filter[1], filter[2], '==') :
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
308
342
|
op === '!=' ? convertNegation(convertComparisonOp(filter[1], filter[2], '==')) :
|
|
309
343
|
op === '<' ||
|
|
310
344
|
op === '>' ||
|
|
311
345
|
op === '<=' ||
|
|
346
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
312
347
|
op === '>=' ? convertComparisonOp(filter[1], filter[2], op) :
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
313
349
|
op === 'any' ? convertDisjunctionOp(filter.slice(1)) :
|
|
314
350
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
315
351
|
op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter)) :
|
|
316
352
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
317
353
|
op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter).map(convertNegation)) :
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
318
355
|
op === 'in' ? convertInOp(filter[1], filter.slice(2)) :
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
319
357
|
op === '!in' ? convertNegation(convertInOp(filter[1], filter.slice(2))) :
|
|
358
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
320
359
|
op === 'has' ? convertHasOp(filter[1]) :
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
321
361
|
op === '!has' ? convertNegation(convertHasOp(filter[1])) :
|
|
322
362
|
true;
|
|
323
363
|
return converted;
|
package/format.ts
CHANGED
|
@@ -8,12 +8,15 @@ function sortKeysBy(obj, reference) {
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
9
|
const result: Record<string, any> = {};
|
|
10
10
|
for (const key in reference) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
11
12
|
if (obj[key] !== undefined) {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
12
14
|
result[key] = obj[key];
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
for (const key in obj) {
|
|
16
18
|
if (result[key] === undefined) {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
17
20
|
result[key] = obj[key];
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -44,7 +47,9 @@ function sortKeysBy(obj, reference) {
|
|
|
44
47
|
function format(style, space = 2) {
|
|
45
48
|
style = sortKeysBy(style, reference.$root);
|
|
46
49
|
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
47
51
|
if (style.layers) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
48
53
|
style.layers = style.layers.map((layer) => sortKeysBy(layer, reference.layer));
|
|
49
54
|
}
|
|
50
55
|
|
package/function/convert.ts
CHANGED
|
@@ -95,6 +95,7 @@ function convertZoomAndPropertyFunction<T>(
|
|
|
95
95
|
featureFunctionStops[zoom] = [];
|
|
96
96
|
zoomStops.push(zoom);
|
|
97
97
|
}
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
98
99
|
featureFunctionStops[zoom].push([stop[0].value, stop[1]]);
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -107,6 +108,7 @@ function convertZoomAndPropertyFunction<T>(
|
|
|
107
108
|
const expression: ExpressionSpecification = [getInterpolateOperator(parameters), ['linear'], ['zoom']];
|
|
108
109
|
|
|
109
110
|
for (const z of zoomStops) {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
110
112
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
111
113
|
appendStopPair(expression, z, output, false);
|
|
112
114
|
}
|
|
@@ -116,6 +118,7 @@ function convertZoomAndPropertyFunction<T>(
|
|
|
116
118
|
const expression: ExpressionSpecification = ['step', ['zoom']];
|
|
117
119
|
|
|
118
120
|
for (const z of zoomStops) {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
119
122
|
const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);
|
|
120
123
|
appendStopPair(expression, z, output, true);
|
|
121
124
|
}
|
|
@@ -219,9 +222,11 @@ function convertZoomFunction<T>(parameters: FunctionSpecification<T>, propertySp
|
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
for (const stop of stops) {
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
222
226
|
appendStopPair(expression, stop[0], stop[1], isStep);
|
|
223
227
|
}
|
|
224
228
|
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
225
230
|
fixupDegenerateStepCurve(expression);
|
|
226
231
|
|
|
227
232
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|