@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
|
@@ -97,19 +97,28 @@ const expressions: ExpressionRegistry = {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
function rgba(ctx: EvaluationContext, [r, g, b, a]: Expression[]) {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
100
101
|
r = r.evaluate(ctx);
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
101
103
|
g = g.evaluate(ctx);
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
102
105
|
b = b.evaluate(ctx);
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
107
|
const alpha = a ? a.evaluate(ctx) : 1;
|
|
104
108
|
const error = validateRGBA(r, g, b, alpha);
|
|
105
109
|
if (error) throw new RuntimeError(error);
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
106
111
|
return new Color(r as unknown as number / 255, g as unknown as number / 255, b as unknown as number / 255, alpha);
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
function hsla(ctx: EvaluationContext, [h, s, l, a]: Expression[]) {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
110
116
|
h = h.evaluate(ctx);
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
111
118
|
s = s.evaluate(ctx);
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
112
120
|
l = l.evaluate(ctx);
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
113
122
|
const alpha = a ? a.evaluate(ctx) : 1;
|
|
114
123
|
const error = validateHSLA(h, s, l, alpha);
|
|
115
124
|
if (error) throw new RuntimeError(error);
|
|
@@ -163,18 +172,20 @@ CompoundExpression.register(expressions, {
|
|
|
163
172
|
'error': [
|
|
164
173
|
ErrorType,
|
|
165
174
|
[StringType],
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
166
176
|
(ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }
|
|
167
177
|
],
|
|
168
178
|
'typeof': [
|
|
169
179
|
StringType,
|
|
170
180
|
[ValueType],
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
171
182
|
(ctx, [v]) => typeToString(typeOf(v.evaluate(ctx)))
|
|
172
183
|
],
|
|
173
184
|
'to-rgba': [
|
|
174
185
|
array(NumberType, 4),
|
|
175
186
|
[ColorType],
|
|
176
187
|
(ctx, [v]) => {
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
178
189
|
return v.evaluate(ctx).toNonPremultipliedRenderColor(null).toArray();
|
|
179
190
|
}
|
|
180
191
|
],
|
|
@@ -182,7 +193,7 @@ CompoundExpression.register(expressions, {
|
|
|
182
193
|
array(NumberType, 4),
|
|
183
194
|
[ColorType],
|
|
184
195
|
(ctx, [v]) => {
|
|
185
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
186
197
|
return v.evaluate(ctx).toNonPremultipliedRenderColor(null).toHslaArray();
|
|
187
198
|
}
|
|
188
199
|
],
|
|
@@ -211,9 +222,11 @@ CompoundExpression.register(expressions, {
|
|
|
211
222
|
overloads: [
|
|
212
223
|
[
|
|
213
224
|
[StringType],
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
214
226
|
(ctx, [key]) => has(key.evaluate(ctx), ctx.properties())
|
|
215
227
|
], [
|
|
216
228
|
[StringType, ObjectType],
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
217
230
|
(ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))
|
|
218
231
|
]
|
|
219
232
|
]
|
|
@@ -223,10 +236,11 @@ CompoundExpression.register(expressions, {
|
|
|
223
236
|
overloads: [
|
|
224
237
|
[
|
|
225
238
|
[StringType],
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
226
240
|
(ctx, [key]) => get(key.evaluate(ctx), ctx.properties())
|
|
227
241
|
], [
|
|
228
242
|
[StringType, ObjectType],
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
|
|
230
244
|
(ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))
|
|
231
245
|
]
|
|
232
246
|
]
|
|
@@ -234,6 +248,7 @@ CompoundExpression.register(expressions, {
|
|
|
234
248
|
'feature-state': [
|
|
235
249
|
ValueType,
|
|
236
250
|
[StringType],
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
237
252
|
(ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {}) as Value
|
|
238
253
|
],
|
|
239
254
|
'properties': [
|
|
@@ -274,6 +289,7 @@ CompoundExpression.register(expressions, {
|
|
|
274
289
|
'measure-light': [
|
|
275
290
|
NumberType,
|
|
276
291
|
[StringType],
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
277
293
|
(ctx, [s]) => ctx.measureLight(s.evaluate(ctx))
|
|
278
294
|
],
|
|
279
295
|
'heatmap-density': [
|
|
@@ -368,99 +384,116 @@ CompoundExpression.register(expressions, {
|
|
|
368
384
|
'^': [
|
|
369
385
|
NumberType,
|
|
370
386
|
[NumberType, NumberType],
|
|
387
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
371
388
|
(ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))
|
|
372
389
|
],
|
|
373
390
|
'sqrt': [
|
|
374
391
|
NumberType,
|
|
375
392
|
[NumberType],
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
376
394
|
(ctx, [x]) => Math.sqrt(x.evaluate(ctx))
|
|
377
395
|
],
|
|
378
396
|
'log10': [
|
|
379
397
|
NumberType,
|
|
380
398
|
[NumberType],
|
|
399
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
381
400
|
(ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10
|
|
382
401
|
],
|
|
383
402
|
'ln': [
|
|
384
403
|
NumberType,
|
|
385
404
|
[NumberType],
|
|
405
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
386
406
|
(ctx, [n]) => Math.log(n.evaluate(ctx))
|
|
387
407
|
],
|
|
388
408
|
'log2': [
|
|
389
409
|
NumberType,
|
|
390
410
|
[NumberType],
|
|
391
|
-
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
412
|
+
(ctx, [n]) => Math.log2(n.evaluate(ctx))
|
|
392
413
|
],
|
|
393
414
|
'sin': [
|
|
394
415
|
NumberType,
|
|
395
416
|
[NumberType],
|
|
417
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
396
418
|
(ctx, [n]) => Math.sin(n.evaluate(ctx))
|
|
397
419
|
],
|
|
398
420
|
'cos': [
|
|
399
421
|
NumberType,
|
|
400
422
|
[NumberType],
|
|
423
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
401
424
|
(ctx, [n]) => Math.cos(n.evaluate(ctx))
|
|
402
425
|
],
|
|
403
426
|
'tan': [
|
|
404
427
|
NumberType,
|
|
405
428
|
[NumberType],
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
406
430
|
(ctx, [n]) => Math.tan(n.evaluate(ctx))
|
|
407
431
|
],
|
|
408
432
|
'asin': [
|
|
409
433
|
NumberType,
|
|
410
434
|
[NumberType],
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
411
436
|
(ctx, [n]) => Math.asin(n.evaluate(ctx))
|
|
412
437
|
],
|
|
413
438
|
'acos': [
|
|
414
439
|
NumberType,
|
|
415
440
|
[NumberType],
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
416
442
|
(ctx, [n]) => Math.acos(n.evaluate(ctx))
|
|
417
443
|
],
|
|
418
444
|
'atan': [
|
|
419
445
|
NumberType,
|
|
420
446
|
[NumberType],
|
|
447
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
421
448
|
(ctx, [n]) => Math.atan(n.evaluate(ctx))
|
|
422
449
|
],
|
|
423
450
|
'min': [
|
|
424
451
|
NumberType,
|
|
425
452
|
varargs(NumberType),
|
|
426
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
453
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
|
|
427
454
|
(ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))
|
|
428
455
|
],
|
|
429
456
|
'max': [
|
|
430
457
|
NumberType,
|
|
431
458
|
varargs(NumberType),
|
|
432
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
459
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
|
|
433
460
|
(ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))
|
|
434
461
|
],
|
|
435
462
|
'abs': [
|
|
436
463
|
NumberType,
|
|
437
464
|
[NumberType],
|
|
465
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
438
466
|
(ctx, [n]) => Math.abs(n.evaluate(ctx))
|
|
439
467
|
],
|
|
440
468
|
'round': [
|
|
441
469
|
NumberType,
|
|
442
470
|
[NumberType],
|
|
443
471
|
(ctx, [n]) => {
|
|
472
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
444
473
|
const v = n.evaluate(ctx);
|
|
445
474
|
// Javascript's Math.round() rounds towards +Infinity for halfway
|
|
446
475
|
// values, even when they're negative. It's more common to round
|
|
447
476
|
// away from 0 (e.g., this is what python and C++ do)
|
|
477
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
448
478
|
return v < 0 ? -Math.round(-v) : Math.round(v);
|
|
449
479
|
}
|
|
450
480
|
],
|
|
451
481
|
'floor': [
|
|
452
482
|
NumberType,
|
|
453
483
|
[NumberType],
|
|
484
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
454
485
|
(ctx, [n]) => Math.floor(n.evaluate(ctx))
|
|
455
486
|
],
|
|
456
487
|
'ceil': [
|
|
457
488
|
NumberType,
|
|
458
489
|
[NumberType],
|
|
490
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
459
491
|
(ctx, [n]) => Math.ceil(n.evaluate(ctx))
|
|
460
492
|
],
|
|
461
493
|
'filter-==': [
|
|
462
494
|
BooleanType,
|
|
463
495
|
[StringType, ValueType],
|
|
496
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
464
497
|
(ctx, [k, v]) => ctx.properties()[(k).value] === (v).value
|
|
465
498
|
],
|
|
466
499
|
'filter-id-==': [
|
|
@@ -477,7 +510,9 @@ CompoundExpression.register(expressions, {
|
|
|
477
510
|
BooleanType,
|
|
478
511
|
[StringType, ValueType],
|
|
479
512
|
(ctx, [k, v]) => {
|
|
513
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
480
514
|
const a = ctx.properties()[(k).value];
|
|
515
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
481
516
|
const b = (v).value;
|
|
482
517
|
return typeof a === typeof b && a < b;
|
|
483
518
|
}
|
|
@@ -487,6 +522,7 @@ CompoundExpression.register(expressions, {
|
|
|
487
522
|
[ValueType],
|
|
488
523
|
(ctx, [v]) => {
|
|
489
524
|
const a = ctx.id();
|
|
525
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
490
526
|
const b = (v).value;
|
|
491
527
|
return typeof a === typeof b && a < b;
|
|
492
528
|
}
|
|
@@ -495,7 +531,9 @@ CompoundExpression.register(expressions, {
|
|
|
495
531
|
BooleanType,
|
|
496
532
|
[StringType, ValueType],
|
|
497
533
|
(ctx, [k, v]) => {
|
|
534
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
498
535
|
const a = ctx.properties()[(k).value];
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
499
537
|
const b = (v).value;
|
|
500
538
|
return typeof a === typeof b && a > b;
|
|
501
539
|
}
|
|
@@ -505,6 +543,7 @@ CompoundExpression.register(expressions, {
|
|
|
505
543
|
[ValueType],
|
|
506
544
|
(ctx, [v]) => {
|
|
507
545
|
const a = ctx.id();
|
|
546
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
508
547
|
const b = (v).value;
|
|
509
548
|
return typeof a === typeof b && a > b;
|
|
510
549
|
}
|
|
@@ -513,7 +552,9 @@ CompoundExpression.register(expressions, {
|
|
|
513
552
|
BooleanType,
|
|
514
553
|
[StringType, ValueType],
|
|
515
554
|
(ctx, [k, v]) => {
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
516
556
|
const a = ctx.properties()[(k).value];
|
|
557
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
517
558
|
const b = (v).value;
|
|
518
559
|
return typeof a === typeof b && a <= b;
|
|
519
560
|
}
|
|
@@ -523,6 +564,7 @@ CompoundExpression.register(expressions, {
|
|
|
523
564
|
[ValueType],
|
|
524
565
|
(ctx, [v]) => {
|
|
525
566
|
const a = ctx.id();
|
|
567
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
526
568
|
const b = (v).value;
|
|
527
569
|
return typeof a === typeof b && a <= b;
|
|
528
570
|
}
|
|
@@ -531,7 +573,9 @@ CompoundExpression.register(expressions, {
|
|
|
531
573
|
BooleanType,
|
|
532
574
|
[StringType, ValueType],
|
|
533
575
|
(ctx, [k, v]) => {
|
|
576
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
534
577
|
const a = ctx.properties()[(k).value];
|
|
578
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
535
579
|
const b = (v).value;
|
|
536
580
|
return typeof a === typeof b && a >= b;
|
|
537
581
|
}
|
|
@@ -541,6 +585,7 @@ CompoundExpression.register(expressions, {
|
|
|
541
585
|
[ValueType],
|
|
542
586
|
(ctx, [v]) => {
|
|
543
587
|
const a = ctx.id();
|
|
588
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
544
589
|
const b = (v).value;
|
|
545
590
|
return typeof a === typeof b && a >= b;
|
|
546
591
|
}
|
|
@@ -558,23 +603,27 @@ CompoundExpression.register(expressions, {
|
|
|
558
603
|
'filter-type-in': [
|
|
559
604
|
BooleanType,
|
|
560
605
|
[array(StringType)],
|
|
606
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
561
607
|
(ctx, [v]) => (v).value.indexOf(ctx.geometryType()) >= 0
|
|
562
608
|
],
|
|
563
609
|
'filter-id-in': [
|
|
564
610
|
BooleanType,
|
|
565
611
|
[array(ValueType)],
|
|
612
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
566
613
|
(ctx, [v]) => (v).value.indexOf(ctx.id()) >= 0
|
|
567
614
|
],
|
|
568
615
|
'filter-in-small': [
|
|
569
616
|
BooleanType,
|
|
570
617
|
[StringType, array(ValueType)],
|
|
571
618
|
// assumes v is an array literal
|
|
619
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
572
620
|
(ctx, [k, v]) => (v).value.indexOf(ctx.properties()[(k).value]) >= 0
|
|
573
621
|
],
|
|
574
622
|
'filter-in-large': [
|
|
575
623
|
BooleanType,
|
|
576
624
|
[StringType, array(ValueType)],
|
|
577
625
|
// assumes v is a array literal with values sorted in ascending order and of a single type
|
|
626
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
|
578
627
|
(ctx, [k, v]) => binarySearch(ctx.properties()[(k).value], (v).value, 0, (v).value.length - 1)
|
|
579
628
|
],
|
|
580
629
|
'all': {
|
|
@@ -629,6 +678,7 @@ CompoundExpression.register(expressions, {
|
|
|
629
678
|
(ctx, [s]) => {
|
|
630
679
|
const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;
|
|
631
680
|
if (isSupportedScript) {
|
|
681
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
632
682
|
return isSupportedScript(s.evaluate(ctx));
|
|
633
683
|
}
|
|
634
684
|
return true;
|
|
@@ -637,31 +687,32 @@ CompoundExpression.register(expressions, {
|
|
|
637
687
|
'upcase': [
|
|
638
688
|
StringType,
|
|
639
689
|
[StringType],
|
|
640
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
690
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
641
691
|
(ctx, [s]) => s.evaluate(ctx).toUpperCase()
|
|
642
692
|
],
|
|
643
693
|
'downcase': [
|
|
644
694
|
StringType,
|
|
645
695
|
[StringType],
|
|
646
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
696
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
647
697
|
(ctx, [s]) => s.evaluate(ctx).toLowerCase()
|
|
648
698
|
],
|
|
649
699
|
'concat': [
|
|
650
700
|
StringType,
|
|
651
701
|
varargs(ValueType),
|
|
702
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
652
703
|
(ctx, args) => args.map(arg => valueToString(arg.evaluate(ctx))).join('')
|
|
653
704
|
],
|
|
654
705
|
'resolved-locale': [
|
|
655
706
|
StringType,
|
|
656
707
|
[CollatorType],
|
|
657
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
708
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
658
709
|
(ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()
|
|
659
710
|
],
|
|
660
711
|
'random': [
|
|
661
712
|
NumberType,
|
|
662
713
|
[NumberType, NumberType, ValueType],
|
|
663
714
|
(ctx, args) => {
|
|
664
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
715
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment
|
|
665
716
|
const [min, max, seed] = args.map(arg => arg.evaluate(ctx));
|
|
666
717
|
if (min > max) {
|
|
667
718
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -679,6 +730,7 @@ CompoundExpression.register(expressions, {
|
|
|
679
730
|
} else {
|
|
680
731
|
throw new RuntimeError(`Invalid seed input: ${seed}`);
|
|
681
732
|
}
|
|
733
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
682
734
|
const random = mulberry32(seedVal)();
|
|
683
735
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
684
736
|
return min + random * (max - min);
|
|
@@ -56,22 +56,28 @@ class IndexOf implements Expression {
|
|
|
56
56
|
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
58
|
evaluate(ctx: EvaluationContext): any {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
59
60
|
const needle = (this.needle.evaluate(ctx));
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
60
62
|
const haystack = (this.haystack.evaluate(ctx));
|
|
61
63
|
|
|
62
64
|
if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
63
66
|
throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString(typeOf(needle))} instead.`);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
if (!isValidNativeType(haystack, ['string', 'array'])) {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
67
71
|
throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString(typeOf(haystack))} instead.`);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
if (this.fromIndex) {
|
|
71
75
|
const fromIndex = (this.fromIndex.evaluate(ctx) as number);
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
72
77
|
return haystack.indexOf(needle, fromIndex);
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
75
81
|
return haystack.indexOf(needle);
|
|
76
82
|
}
|
|
77
83
|
|
|
@@ -73,6 +73,7 @@ class Interpolate implements Expression {
|
|
|
73
73
|
if (interpolation[0] === 'linear') {
|
|
74
74
|
interpolation = {name: 'linear'};
|
|
75
75
|
} else if (interpolation[0] === 'exponential') {
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
76
77
|
const base = interpolation[1];
|
|
77
78
|
if (typeof base !== 'number')
|
|
78
79
|
return context.error(`Exponential interpolation requires a numeric base.`, 1, 1);
|
|
@@ -160,6 +161,7 @@ class Interpolate implements Expression {
|
|
|
160
161
|
return outputs[0].evaluate(ctx) as Color;
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
163
165
|
const value: number = this.input.evaluate(ctx);
|
|
164
166
|
if (value <= labels[0]) {
|
|
165
167
|
return outputs[0].evaluate(ctx) as Color;
|
|
@@ -175,11 +177,13 @@ class Interpolate implements Expression {
|
|
|
175
177
|
const upper = labels[index + 1];
|
|
176
178
|
const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);
|
|
177
179
|
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
178
181
|
const outputLower: Color = outputs[index].evaluate(ctx);
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
179
183
|
const outputUpper: Color = outputs[index + 1].evaluate(ctx);
|
|
180
184
|
|
|
181
185
|
if (this.operator === 'interpolate') {
|
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
183
187
|
return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
|
|
184
188
|
} else if (this.operator === 'interpolate-hcl') {
|
|
185
189
|
return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
|
|
@@ -32,12 +32,14 @@ class Length implements Expression {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
evaluate(ctx: EvaluationContext): number {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
35
36
|
const input = this.input.evaluate(ctx);
|
|
36
37
|
if (typeof input === 'string') {
|
|
37
38
|
return input.length;
|
|
38
39
|
} else if (Array.isArray(input)) {
|
|
39
40
|
return input.length;
|
|
40
41
|
} else {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
41
43
|
throw new RuntimeError(`Expected value to be of type string or array, but found ${toString(typeOf(input))} instead.`);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -10,6 +10,7 @@ class Let implements Expression {
|
|
|
10
10
|
|
|
11
11
|
constructor(bindings: Array<[string, Expression]>, result: Expression) {
|
|
12
12
|
this.type = result.type;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
13
14
|
this.bindings = [].concat(bindings);
|
|
14
15
|
this.result = result;
|
|
15
16
|
}
|
|
@@ -66,6 +66,7 @@ class Match implements Expression {
|
|
|
66
66
|
|
|
67
67
|
} else if (!inputType) {
|
|
68
68
|
inputType = typeOf(label);
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
69
70
|
} else if (labelContext.checkSubtype(inputType, typeOf(label))) {
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
@@ -91,16 +92,20 @@ class Match implements Expression {
|
|
|
91
92
|
|
|
92
93
|
assert(inputType && outputType);
|
|
93
94
|
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
94
96
|
if (input.type.kind !== 'value' && context.concat(1).checkSubtype((inputType), input.type)) {
|
|
95
97
|
return null;
|
|
96
98
|
}
|
|
97
99
|
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
98
101
|
return new Match(inputType, outputType, input, cases, outputs, otherwise);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
105
|
evaluate(ctx: EvaluationContext): any {
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
107
|
const input = (this.input.evaluate(ctx));
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
104
109
|
const output = (typeEquals(typeOf(input), this.inputType) && this.outputs[this.cases[input]]) || this.otherwise;
|
|
105
110
|
return output.evaluate(ctx);
|
|
106
111
|
}
|
|
@@ -70,20 +70,27 @@ export default class NumberFormat implements Expression {
|
|
|
70
70
|
if (!maxFractionDigits) return null;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
73
74
|
return new NumberFormat(number, locale, currency, unit, minFractionDigits, maxFractionDigits);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
evaluate(ctx: EvaluationContext): string {
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
79
|
return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [],
|
|
78
80
|
{
|
|
79
81
|
style:
|
|
80
82
|
(this.currency && "currency") ||
|
|
81
83
|
(this.unit && "unit") ||
|
|
82
84
|
"decimal",
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
83
86
|
currency: this.currency ? this.currency.evaluate(ctx) : undefined,
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
84
88
|
unit: this.unit ? this.unit.evaluate(ctx) : undefined,
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
85
90
|
minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
86
92
|
maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
87
94
|
}).format(this.number.evaluate(ctx));
|
|
88
95
|
}
|
|
89
96
|
|
|
@@ -56,18 +56,22 @@ class Slice implements Expression {
|
|
|
56
56
|
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
58
|
evaluate(ctx: EvaluationContext): any {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
59
60
|
const input = (this.input.evaluate(ctx));
|
|
60
61
|
const beginIndex = (this.beginIndex.evaluate(ctx) as number);
|
|
61
62
|
|
|
62
63
|
if (!isValidNativeType(input, ['string', 'array'])) {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
63
65
|
throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString(typeOf(input))} instead.`);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
if (this.endIndex) {
|
|
67
69
|
const endIndex = (this.endIndex.evaluate(ctx) as number);
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
68
71
|
return input.slice(beginIndex, endIndex);
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
71
75
|
return input.slice(beginIndex);
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -144,6 +144,7 @@ function getTileLines(geometry: Array<Array<Point>> | null | undefined, lineBBox
|
|
|
144
144
|
updateBBox(lineBBox, p);
|
|
145
145
|
tileLine.push(p);
|
|
146
146
|
}
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
147
148
|
tileLines.push(tileLine);
|
|
148
149
|
}
|
|
149
150
|
if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {
|