ts-maps 0.3.2 → 0.3.4

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.
Files changed (54) hide show
  1. package/dist/core-map/control/FullscreenControl.d.ts +39 -0
  2. package/dist/core-map/control/GeocoderControl.d.ts +61 -0
  3. package/dist/core-map/control/LocateControl.d.ts +5 -2
  4. package/dist/core-map/control/NavigationControl.d.ts +39 -0
  5. package/dist/core-map/control/index.d.ts +6 -0
  6. package/dist/core-map/game/TerritoryLog.d.ts +66 -0
  7. package/dist/core-map/game/TerritoryStore.d.ts +59 -0
  8. package/dist/core-map/game/index.d.ts +11 -0
  9. package/dist/core-map/game/loop.d.ts +61 -0
  10. package/dist/core-map/geo/area.d.ts +52 -0
  11. package/dist/core-map/geo/index.d.ts +30 -0
  12. package/dist/core-map/geo/index.js +826 -1
  13. package/dist/core-map/geo/polygonClip.d.ts +75 -0
  14. package/dist/core-map/geo/validate.d.ts +54 -0
  15. package/dist/core-map/index.d.ts +7 -2
  16. package/dist/core-map/layer/GeoJSONTileSource.d.ts +50 -0
  17. package/dist/core-map/layer/RunTrailLayer.d.ts +35 -0
  18. package/dist/core-map/layer/TerritoryLayer.d.ts +62 -0
  19. package/dist/core-map/layer/index.d.ts +6 -0
  20. package/dist/core-map/layer/tile/RasterDEMLayer.d.ts +4 -0
  21. package/dist/core-map/layer/tile/VectorTileMapLayer.d.ts +59 -11
  22. package/dist/core-map/layer/tile/urlTemplate.d.ts +1 -2
  23. package/dist/core-map/map/Map.d.ts +32 -1
  24. package/dist/core-map/mvt/DecodedTile.d.ts +20 -0
  25. package/dist/core-map/mvt/FlatTile.d.ts +25 -0
  26. package/dist/core-map/mvt/VectorTileFeature.d.ts +8 -0
  27. package/dist/core-map/style-spec/expressions/formatted.d.ts +36 -0
  28. package/dist/core-map/style-spec/expressions/operators/binding.d.ts +1 -0
  29. package/dist/core-map/style-spec/expressions/operators/geometry.d.ts +19 -0
  30. package/dist/core-map/style-spec/expressions/types.d.ts +3 -0
  31. package/dist/core-map/style-spec/index.js +459 -42
  32. package/dist/core-map/style-spec/schema.d.ts +43 -3
  33. package/dist/core-map/style-spec/types.d.ts +47 -7
  34. package/dist/core-map/styles/basemap.d.ts +41 -0
  35. package/dist/core-map/styles/index.d.ts +5 -0
  36. package/dist/core-map/styles/palette.d.ts +31 -0
  37. package/dist/core-map/symbols/CollisionIndex.d.ts +22 -5
  38. package/dist/core-map/symbols/GlyphAtlas.d.ts +6 -1
  39. package/dist/core-map/symbols/GlyphProvider.d.ts +21 -0
  40. package/dist/core-map/symbols/GlyphRenderer.d.ts +48 -0
  41. package/dist/core-map/symbols/IconAtlas.d.ts +10 -1
  42. package/dist/core-map/symbols/SymbolOverlay.d.ts +47 -0
  43. package/dist/core-map/symbols/index.d.ts +4 -0
  44. package/dist/core-map/symbols/index.js +1071 -67
  45. package/dist/core-map/symbols/loadGlyphs.d.ts +53 -0
  46. package/dist/core-map/symbols/loadSprite.d.ts +57 -0
  47. package/dist/core-map/symbols/placement.d.ts +67 -0
  48. package/dist/core-map/symbols/sdf.d.ts +37 -0
  49. package/dist/core-map/symbols/sections.d.ts +32 -0
  50. package/dist/core-map/workers/WorkerPool.d.ts +40 -0
  51. package/dist/core-map/workers/decodeMvtFlat.d.ts +52 -0
  52. package/dist/index.js +11548 -5996
  53. package/package.json +1 -1
  54. package/src/core-map/ts-maps.css +392 -99
@@ -575,7 +575,7 @@ var init_registry = __esm(() => {
575
575
  OPERATORS = {};
576
576
  });
577
577
 
578
- // src/core-map/style-spec/expressions/operators/conversion.ts
578
+ // src/core-map/style-spec/expressions/operators/binding.ts
579
579
  function mergeDeps(children) {
580
580
  let z = false;
581
581
  let f = false;
@@ -590,6 +590,70 @@ function mergeDeps(children) {
590
590
  }
591
591
  return { dependsOnZoom: z, dependsOnFeature: f, dependsOnFeatureState: s };
592
592
  }
593
+ function registerBindingOps() {
594
+ registerOperator("let", (args, compile, path) => {
595
+ if (args.length < 3 || args.length % 2 === 0)
596
+ throw new ExpressionError(`"let" expects name/value pairs followed by a body, got ${args.length} arguments`, ["let", ...args], path);
597
+ const names = [];
598
+ const values = [];
599
+ for (let i = 0;i < args.length - 1; i += 2) {
600
+ const name = args[i];
601
+ if (typeof name !== "string")
602
+ throw new ExpressionError(`"let": binding name must be a string, got ${typeof name}`, ["let", ...args], path);
603
+ names.push(name);
604
+ values.push(compile(args[i + 1], "value", path.concat(i + 2)));
605
+ }
606
+ const body = compile(args[args.length - 1], "value", path.concat(args.length));
607
+ return {
608
+ evaluate: (ctx) => {
609
+ const bindings = { ...ctx.bindings };
610
+ for (let i = 0;i < names.length; i++)
611
+ bindings[names[i]] = values[i].evaluate(ctx);
612
+ return body.evaluate({ ...ctx, bindings });
613
+ },
614
+ returnType: body.returnType,
615
+ ...mergeDeps([...values, body])
616
+ };
617
+ });
618
+ registerOperator("var", (args, _compile, path) => {
619
+ if (args.length !== 1)
620
+ throw new ExpressionError(`"var" expects 1 argument, got ${args.length}`, ["var", ...args], path);
621
+ const name = args[0];
622
+ if (typeof name !== "string")
623
+ throw new ExpressionError(`"var": name must be a string, got ${typeof name}`, ["var", ...args], path);
624
+ return {
625
+ evaluate: (ctx) => {
626
+ if (!ctx.bindings || !(name in ctx.bindings))
627
+ throw new ExpressionError(`"var": unbound name ${JSON.stringify(name)}`, ["var", name]);
628
+ return ctx.bindings[name];
629
+ },
630
+ returnType: "value",
631
+ dependsOnZoom: false,
632
+ dependsOnFeature: false,
633
+ dependsOnFeatureState: false
634
+ };
635
+ });
636
+ }
637
+ var init_binding = __esm(() => {
638
+ init_errors();
639
+ init_registry();
640
+ });
641
+
642
+ // src/core-map/style-spec/expressions/operators/conversion.ts
643
+ function mergeDeps2(children) {
644
+ let z = false;
645
+ let f = false;
646
+ let s = false;
647
+ for (const c of children) {
648
+ if (c.dependsOnZoom)
649
+ z = true;
650
+ if (c.dependsOnFeature)
651
+ f = true;
652
+ if (c.dependsOnFeatureState)
653
+ s = true;
654
+ }
655
+ return { dependsOnZoom: z, dependsOnFeature: f, dependsOnFeatureState: s };
656
+ }
593
657
  function registerConversionOps() {
594
658
  registerOperator("to-string", (args, compile, path) => {
595
659
  if (args.length !== 1)
@@ -611,7 +675,7 @@ function registerConversionOps() {
611
675
  }
612
676
  },
613
677
  returnType: "string",
614
- ...mergeDeps([inner])
678
+ ...mergeDeps2([inner])
615
679
  };
616
680
  });
617
681
  registerOperator("to-number", (args, compile, path) => {
@@ -644,7 +708,7 @@ function registerConversionOps() {
644
708
  throw new ExpressionError('"to-number": could not convert any argument to a number', expr);
645
709
  },
646
710
  returnType: "number",
647
- ...mergeDeps(children)
711
+ ...mergeDeps2(children)
648
712
  };
649
713
  });
650
714
  registerOperator("to-boolean", (args, compile, path) => {
@@ -669,7 +733,7 @@ function registerConversionOps() {
669
733
  return Boolean(v);
670
734
  },
671
735
  returnType: "boolean",
672
- ...mergeDeps([inner])
736
+ ...mergeDeps2([inner])
673
737
  };
674
738
  });
675
739
  registerOperator("to-rgba", (args, compile, path) => {
@@ -691,7 +755,7 @@ function registerConversionOps() {
691
755
  ];
692
756
  },
693
757
  returnType: "array",
694
- ...mergeDeps([inner])
758
+ ...mergeDeps2([inner])
695
759
  };
696
760
  });
697
761
  registerOperator("to-color", (args, compile, path) => {
@@ -710,7 +774,7 @@ function registerConversionOps() {
710
774
  throw new ExpressionError('"to-color": could not convert any argument to a color', expr);
711
775
  },
712
776
  returnType: "color",
713
- ...mergeDeps(children)
777
+ ...mergeDeps2(children)
714
778
  };
715
779
  });
716
780
  }
@@ -744,8 +808,142 @@ var init_conversion = __esm(() => {
744
808
  init_registry();
745
809
  });
746
810
 
811
+ // src/core-map/style-spec/expressions/operators/geometry.ts
812
+ function toRadians(degrees) {
813
+ return degrees * Math.PI / 180;
814
+ }
815
+ function haversine(a, b) {
816
+ const [lng1, lat1] = a;
817
+ const [lng2, lat2] = b;
818
+ const dLat = toRadians(lat2 - lat1);
819
+ const dLng = toRadians(lng2 - lng1);
820
+ const sinLat = Math.sin(dLat / 2);
821
+ const sinLng = Math.sin(dLng / 2);
822
+ const h = sinLat * sinLat + Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * sinLng * sinLng;
823
+ return 2 * EARTH_RADIUS * Math.asin(Math.min(1, Math.sqrt(h)));
824
+ }
825
+ function pointInRing(point, ring) {
826
+ const [x, y] = point;
827
+ let inside = false;
828
+ for (let i = 0, j = ring.length - 1;i < ring.length; j = i++) {
829
+ const [xi, yi] = ring[i];
830
+ const [xj, yj] = ring[j];
831
+ const cross = (xj - xi) * (y - yi) - (yj - yi) * (x - xi);
832
+ if (Math.abs(cross) < 0.000000000001 && Math.min(xi, xj) - 0.000000000001 <= x && x <= Math.max(xi, xj) + 0.000000000001 && Math.min(yi, yj) - 0.000000000001 <= y && y <= Math.max(yi, yj) + 0.000000000001) {
833
+ return true;
834
+ }
835
+ if (yi > y !== yj > y) {
836
+ const at = xi + (y - yi) / (yj - yi) * (xj - xi);
837
+ if (x < at)
838
+ inside = !inside;
839
+ }
840
+ }
841
+ return inside;
842
+ }
843
+ function pointInPolygon(point, polygon) {
844
+ if (!polygon.length || !pointInRing(point, polygon[0]))
845
+ return false;
846
+ for (let i = 1;i < polygon.length; i++) {
847
+ if (pointInRing(point, polygon[i]))
848
+ return false;
849
+ }
850
+ return true;
851
+ }
852
+ function polygonsOf(geometry) {
853
+ if (!geometry)
854
+ return [];
855
+ if (geometry.type === "Polygon")
856
+ return [geometry.coordinates];
857
+ if (geometry.type === "MultiPolygon")
858
+ return geometry.coordinates;
859
+ if (geometry.type === "Feature")
860
+ return polygonsOf(geometry.geometry);
861
+ if (geometry.type === "FeatureCollection")
862
+ return (geometry.features ?? []).flatMap((f) => polygonsOf(f));
863
+ return [];
864
+ }
865
+ function positionsOf(geometry) {
866
+ if (!geometry)
867
+ return [];
868
+ switch (geometry.type) {
869
+ case "Point":
870
+ return [geometry.coordinates];
871
+ case "MultiPoint":
872
+ case "LineString":
873
+ return geometry.coordinates;
874
+ case "MultiLineString":
875
+ case "Polygon":
876
+ return geometry.coordinates.flat();
877
+ case "MultiPolygon":
878
+ return geometry.coordinates.flat(2);
879
+ case "Feature":
880
+ return positionsOf(geometry.geometry);
881
+ case "FeatureCollection":
882
+ return (geometry.features ?? []).flatMap((f) => positionsOf(f));
883
+ default:
884
+ return [];
885
+ }
886
+ }
887
+ function featureGeometry(ctx) {
888
+ const accessor = ctx.feature?.geometry;
889
+ return typeof accessor === "function" ? accessor() : undefined;
890
+ }
891
+ function noDeps() {
892
+ return { dependsOnZoom: false, dependsOnFeature: true, dependsOnFeatureState: false };
893
+ }
894
+ function registerGeometryOps() {
895
+ registerOperator("within", (args, _compile, path) => {
896
+ if (args.length !== 1)
897
+ throw new ExpressionError(`"within" expects 1 argument, got ${args.length}`, ["within", ...args], path);
898
+ const polygons = polygonsOf(args[0]);
899
+ if (!polygons.length)
900
+ throw new ExpressionError('"within": argument must be a GeoJSON Polygon or MultiPolygon', ["within", ...args], path);
901
+ return {
902
+ evaluate: (ctx) => {
903
+ const geometry = featureGeometry(ctx);
904
+ const points = positionsOf(geometry);
905
+ if (!points.length)
906
+ return false;
907
+ return points.every((point) => polygons.some((polygon) => pointInPolygon(point, polygon)));
908
+ },
909
+ returnType: "boolean",
910
+ ...noDeps()
911
+ };
912
+ });
913
+ registerOperator("distance", (args, _compile, path) => {
914
+ if (args.length !== 1)
915
+ throw new ExpressionError(`"distance" expects 1 argument, got ${args.length}`, ["distance", ...args], path);
916
+ const targets = positionsOf(args[0]);
917
+ if (!targets.length)
918
+ throw new ExpressionError('"distance": argument must be a GeoJSON geometry', ["distance", ...args], path);
919
+ return {
920
+ evaluate: (ctx) => {
921
+ const points = positionsOf(featureGeometry(ctx));
922
+ if (!points.length)
923
+ return Infinity;
924
+ let nearest = Infinity;
925
+ for (const point of points) {
926
+ for (const target of targets) {
927
+ const d = haversine(point, target);
928
+ if (d < nearest)
929
+ nearest = d;
930
+ }
931
+ }
932
+ return nearest;
933
+ },
934
+ returnType: "number",
935
+ ...noDeps()
936
+ };
937
+ });
938
+ }
939
+ var EARTH_RADIUS = 6371008.8;
940
+ var init_geometry = __esm(() => {
941
+ init_errors();
942
+ init_registry();
943
+ });
944
+
747
945
  // src/core-map/style-spec/expressions/operators/interpolate.ts
748
- function mergeDeps2(children) {
946
+ function mergeDeps3(children) {
749
947
  let z = false;
750
948
  let f = false;
751
949
  let s = false;
@@ -967,7 +1165,7 @@ function registerInterpolateOps() {
967
1165
  return blend(stopOutputs[idx].evaluate(ctx), stopOutputs[idx + 1].evaluate(ctx), t);
968
1166
  },
969
1167
  returnType,
970
- ...mergeDeps2(children)
1168
+ ...mergeDeps3(children)
971
1169
  };
972
1170
  });
973
1171
  registerOperator("step", (args, compile, path, expected) => {
@@ -1001,7 +1199,7 @@ function registerInterpolateOps() {
1001
1199
  return stopOutputs[idx].evaluate(ctx);
1002
1200
  },
1003
1201
  returnType,
1004
- ...mergeDeps2(children)
1202
+ ...mergeDeps3(children)
1005
1203
  };
1006
1204
  });
1007
1205
  }
@@ -1012,7 +1210,7 @@ var init_interpolate = __esm(() => {
1012
1210
  });
1013
1211
 
1014
1212
  // src/core-map/style-spec/expressions/operators/logical.ts
1015
- function mergeDeps3(children) {
1213
+ function mergeDeps4(children) {
1016
1214
  let z = false;
1017
1215
  let f = false;
1018
1216
  let s = false;
@@ -1049,7 +1247,7 @@ function registerLogicalOps() {
1049
1247
  return {
1050
1248
  evaluate: (ctx) => !inner.evaluate(ctx),
1051
1249
  returnType: "boolean",
1052
- ...mergeDeps3([inner])
1250
+ ...mergeDeps4([inner])
1053
1251
  };
1054
1252
  });
1055
1253
  registerOperator("==", (args, compile, path) => {
@@ -1060,7 +1258,7 @@ function registerLogicalOps() {
1060
1258
  return {
1061
1259
  evaluate: (ctx) => strictEq(a.evaluate(ctx), b.evaluate(ctx)),
1062
1260
  returnType: "boolean",
1063
- ...mergeDeps3([a, b])
1261
+ ...mergeDeps4([a, b])
1064
1262
  };
1065
1263
  });
1066
1264
  registerOperator("!=", (args, compile, path) => {
@@ -1071,7 +1269,7 @@ function registerLogicalOps() {
1071
1269
  return {
1072
1270
  evaluate: (ctx) => !strictEq(a.evaluate(ctx), b.evaluate(ctx)),
1073
1271
  returnType: "boolean",
1074
- ...mergeDeps3([a, b])
1272
+ ...mergeDeps4([a, b])
1075
1273
  };
1076
1274
  });
1077
1275
  const comparator = (name) => {
@@ -1097,7 +1295,7 @@ function registerLogicalOps() {
1097
1295
  }
1098
1296
  },
1099
1297
  returnType: "boolean",
1100
- ...mergeDeps3([a, b])
1298
+ ...mergeDeps4([a, b])
1101
1299
  };
1102
1300
  });
1103
1301
  };
@@ -1115,7 +1313,7 @@ function registerLogicalOps() {
1115
1313
  return true;
1116
1314
  },
1117
1315
  returnType: "boolean",
1118
- ...mergeDeps3(children)
1316
+ ...mergeDeps4(children)
1119
1317
  };
1120
1318
  });
1121
1319
  registerOperator("any", (args, compile, path) => {
@@ -1128,7 +1326,7 @@ function registerLogicalOps() {
1128
1326
  return false;
1129
1327
  },
1130
1328
  returnType: "boolean",
1131
- ...mergeDeps3(children)
1329
+ ...mergeDeps4(children)
1132
1330
  };
1133
1331
  });
1134
1332
  registerOperator("none", (args, compile, path) => {
@@ -1141,7 +1339,7 @@ function registerLogicalOps() {
1141
1339
  return true;
1142
1340
  },
1143
1341
  returnType: "boolean",
1144
- ...mergeDeps3(children)
1342
+ ...mergeDeps4(children)
1145
1343
  };
1146
1344
  });
1147
1345
  registerOperator("case", (args, compile, path, expected) => {
@@ -1170,7 +1368,7 @@ function registerLogicalOps() {
1170
1368
  return fallback.evaluate(ctx);
1171
1369
  },
1172
1370
  returnType: expected,
1173
- ...mergeDeps3(all)
1371
+ ...mergeDeps4(all)
1174
1372
  };
1175
1373
  });
1176
1374
  registerOperator("match", (args, compile, path, expected) => {
@@ -1207,7 +1405,7 @@ function registerLogicalOps() {
1207
1405
  return fallback.evaluate(ctx);
1208
1406
  },
1209
1407
  returnType: expected,
1210
- ...mergeDeps3(all)
1408
+ ...mergeDeps4(all)
1211
1409
  };
1212
1410
  });
1213
1411
  registerOperator("coalesce", (args, compile, path, expected) => {
@@ -1224,12 +1422,29 @@ function registerLogicalOps() {
1224
1422
  return null;
1225
1423
  },
1226
1424
  returnType: expected,
1227
- ...mergeDeps3(children)
1425
+ ...mergeDeps4(children)
1228
1426
  };
1229
1427
  });
1230
1428
  registerOperator("in", (args, compile, path) => {
1231
1429
  if (args.length < 1)
1232
1430
  throw new ExpressionError('"in" expects at least 1 argument', ["in", ...args], path);
1431
+ if (args.length === 2 && Array.isArray(args[1])) {
1432
+ const needle = compile(args[0], "value", path.concat(1));
1433
+ const haystack2 = compile(args[1], "value", path.concat(2));
1434
+ return {
1435
+ evaluate: (ctx) => {
1436
+ const x = needle.evaluate(ctx);
1437
+ const hay = haystack2.evaluate(ctx);
1438
+ if (Array.isArray(hay))
1439
+ return hay.some((value) => strictEq(x, value));
1440
+ if (typeof hay === "string")
1441
+ return typeof x === "string" && hay.includes(x);
1442
+ return false;
1443
+ },
1444
+ returnType: "boolean",
1445
+ ...mergeDeps4([needle, haystack2])
1446
+ };
1447
+ }
1233
1448
  const input = compile(args[0], "value", path.concat(1));
1234
1449
  const haystack = args.slice(1);
1235
1450
  return {
@@ -1241,7 +1456,7 @@ function registerLogicalOps() {
1241
1456
  return false;
1242
1457
  },
1243
1458
  returnType: "boolean",
1244
- ...mergeDeps3([input])
1459
+ ...mergeDeps4([input])
1245
1460
  };
1246
1461
  });
1247
1462
  registerOperator("!in", (args, compile, path) => {
@@ -1258,7 +1473,7 @@ function registerLogicalOps() {
1258
1473
  return true;
1259
1474
  },
1260
1475
  returnType: "boolean",
1261
- ...mergeDeps3([input])
1476
+ ...mergeDeps4([input])
1262
1477
  };
1263
1478
  });
1264
1479
  registerOperator("!has", (args, _compile, path) => {
@@ -1468,6 +1683,17 @@ function registerLookupOps() {
1468
1683
  dependsOnFeatureState: false
1469
1684
  };
1470
1685
  });
1686
+ registerOperator("heatmap-density", (args, _compile, path) => {
1687
+ if (args.length !== 0)
1688
+ throw new ExpressionError(`"heatmap-density" takes no arguments, got ${args.length}`, ["heatmap-density", ...args], path);
1689
+ return {
1690
+ evaluate: (ctx) => ctx.heatmapDensity ?? 0,
1691
+ returnType: "number",
1692
+ dependsOnZoom: false,
1693
+ dependsOnFeature: false,
1694
+ dependsOnFeatureState: false
1695
+ };
1696
+ });
1471
1697
  registerOperator("feature-state", (args, _compile, path) => {
1472
1698
  if (args.length !== 1)
1473
1699
  throw new ExpressionError(`"feature-state" expects 1 argument, got ${args.length}`, ["feature-state", ...args], path);
@@ -1510,7 +1736,7 @@ function expectNumber(value, op, expr) {
1510
1736
  throw new ExpressionError(`"${op}": expected number, got ${String(value)}`, expr);
1511
1737
  return value;
1512
1738
  }
1513
- function mergeDeps4(children) {
1739
+ function mergeDeps5(children) {
1514
1740
  let z = false;
1515
1741
  let f = false;
1516
1742
  let s = false;
@@ -1536,7 +1762,7 @@ function registerMathOps() {
1536
1762
  return acc;
1537
1763
  },
1538
1764
  returnType: "number",
1539
- ...mergeDeps4(children)
1765
+ ...mergeDeps5(children)
1540
1766
  };
1541
1767
  });
1542
1768
  registerOperator("*", (args, compile, path) => {
@@ -1550,7 +1776,7 @@ function registerMathOps() {
1550
1776
  return acc;
1551
1777
  },
1552
1778
  returnType: "number",
1553
- ...mergeDeps4(children)
1779
+ ...mergeDeps5(children)
1554
1780
  };
1555
1781
  });
1556
1782
  registerOperator("-", (args, compile, path) => {
@@ -1563,7 +1789,7 @@ function registerMathOps() {
1563
1789
  return {
1564
1790
  evaluate: (ctx) => -expectNumber(a2.evaluate(ctx), "-", expr),
1565
1791
  returnType: "number",
1566
- ...mergeDeps4(children)
1792
+ ...mergeDeps5(children)
1567
1793
  };
1568
1794
  }
1569
1795
  const a = children[0];
@@ -1571,7 +1797,7 @@ function registerMathOps() {
1571
1797
  return {
1572
1798
  evaluate: (ctx) => expectNumber(a.evaluate(ctx), "-", expr) - expectNumber(b.evaluate(ctx), "-", expr),
1573
1799
  returnType: "number",
1574
- ...mergeDeps4(children)
1800
+ ...mergeDeps5(children)
1575
1801
  };
1576
1802
  });
1577
1803
  registerOperator("/", (args, compile, path) => {
@@ -1589,7 +1815,7 @@ function registerMathOps() {
1589
1815
  return av / bv;
1590
1816
  },
1591
1817
  returnType: "number",
1592
- ...mergeDeps4([a, b])
1818
+ ...mergeDeps5([a, b])
1593
1819
  };
1594
1820
  });
1595
1821
  registerOperator("%", (args, compile, path) => {
@@ -1607,7 +1833,7 @@ function registerMathOps() {
1607
1833
  return av % bv;
1608
1834
  },
1609
1835
  returnType: "number",
1610
- ...mergeDeps4([a, b])
1836
+ ...mergeDeps5([a, b])
1611
1837
  };
1612
1838
  });
1613
1839
  registerOperator("^", (args, compile, path) => {
@@ -1619,7 +1845,7 @@ function registerMathOps() {
1619
1845
  return {
1620
1846
  evaluate: (ctx) => expectNumber(a.evaluate(ctx), "^", expr) ** expectNumber(b.evaluate(ctx), "^", expr),
1621
1847
  returnType: "number",
1622
- ...mergeDeps4([a, b])
1848
+ ...mergeDeps5([a, b])
1623
1849
  };
1624
1850
  });
1625
1851
  registerOperator("min", (args, compile, path) => {
@@ -1638,7 +1864,7 @@ function registerMathOps() {
1638
1864
  return m;
1639
1865
  },
1640
1866
  returnType: "number",
1641
- ...mergeDeps4(children)
1867
+ ...mergeDeps5(children)
1642
1868
  };
1643
1869
  });
1644
1870
  registerOperator("max", (args, compile, path) => {
@@ -1657,7 +1883,7 @@ function registerMathOps() {
1657
1883
  return m;
1658
1884
  },
1659
1885
  returnType: "number",
1660
- ...mergeDeps4(children)
1886
+ ...mergeDeps5(children)
1661
1887
  };
1662
1888
  });
1663
1889
  const unary = (name, fn, validate) => {
@@ -1674,7 +1900,7 @@ function registerMathOps() {
1674
1900
  return fn(v);
1675
1901
  },
1676
1902
  returnType: "number",
1677
- ...mergeDeps4([inner])
1903
+ ...mergeDeps5([inner])
1678
1904
  };
1679
1905
  });
1680
1906
  };
@@ -1698,6 +1924,18 @@ function registerMathOps() {
1698
1924
  if (n <= 0)
1699
1925
  throw new ExpressionError('"log2": input must be positive', expr);
1700
1926
  });
1927
+ unary("sin", Math.sin);
1928
+ unary("cos", Math.cos);
1929
+ unary("tan", Math.tan);
1930
+ unary("asin", Math.asin, (n, expr) => {
1931
+ if (n < -1 || n > 1)
1932
+ throw new ExpressionError('"asin": input must be in [-1, 1]', expr);
1933
+ });
1934
+ unary("acos", Math.acos, (n, expr) => {
1935
+ if (n < -1 || n > 1)
1936
+ throw new ExpressionError('"acos": input must be in [-1, 1]', expr);
1937
+ });
1938
+ unary("atan", Math.atan);
1701
1939
  registerOperator("e", (args, _compile, path) => {
1702
1940
  if (args.length !== 0)
1703
1941
  throw new ExpressionError(`"e" takes no arguments, got ${args.length}`, ["e", ...args], path);
@@ -1746,7 +1984,7 @@ function registerMathOps() {
1746
1984
  return a + (b - a) * Math.random();
1747
1985
  },
1748
1986
  returnType: "number",
1749
- ...mergeDeps4(children)
1987
+ ...mergeDeps5(children)
1750
1988
  };
1751
1989
  });
1752
1990
  }
@@ -1755,8 +1993,31 @@ var init_math = __esm(() => {
1755
1993
  init_registry();
1756
1994
  });
1757
1995
 
1996
+ // src/core-map/style-spec/expressions/formatted.ts
1997
+ class Formatted {
1998
+ sections;
1999
+ constructor(sections) {
2000
+ this.sections = sections;
2001
+ }
2002
+ toString() {
2003
+ let out = "";
2004
+ for (const section of this.sections)
2005
+ out += section.text;
2006
+ return out;
2007
+ }
2008
+ get uniform() {
2009
+ return isUniform(this.sections);
2010
+ }
2011
+ }
2012
+ function isUniform(sections) {
2013
+ return sections.every((s) => s.scale === undefined && s.fontStack === undefined && s.color === undefined);
2014
+ }
2015
+ function isFormatted(value) {
2016
+ return value instanceof Formatted || !!value && typeof value === "object" && Array.isArray(value.sections);
2017
+ }
2018
+
1758
2019
  // src/core-map/style-spec/expressions/operators/string.ts
1759
- function mergeDeps5(children) {
2020
+ function mergeDeps6(children) {
1760
2021
  let z = false;
1761
2022
  let f = false;
1762
2023
  let s = false;
@@ -1794,7 +2055,7 @@ function registerStringOps() {
1794
2055
  return out;
1795
2056
  },
1796
2057
  returnType: "string",
1797
- ...mergeDeps5(children)
2058
+ ...mergeDeps6(children)
1798
2059
  };
1799
2060
  });
1800
2061
  registerOperator("downcase", (args, compile, path) => {
@@ -1804,7 +2065,7 @@ function registerStringOps() {
1804
2065
  return {
1805
2066
  evaluate: (ctx) => toStr(inner.evaluate(ctx)).toLowerCase(),
1806
2067
  returnType: "string",
1807
- ...mergeDeps5([inner])
2068
+ ...mergeDeps6([inner])
1808
2069
  };
1809
2070
  });
1810
2071
  registerOperator("upcase", (args, compile, path) => {
@@ -1814,7 +2075,122 @@ function registerStringOps() {
1814
2075
  return {
1815
2076
  evaluate: (ctx) => toStr(inner.evaluate(ctx)).toUpperCase(),
1816
2077
  returnType: "string",
1817
- ...mergeDeps5([inner])
2078
+ ...mergeDeps6([inner])
2079
+ };
2080
+ });
2081
+ registerOperator("index-of", (args, compile, path) => {
2082
+ if (args.length !== 2 && args.length !== 3)
2083
+ throw new ExpressionError(`"index-of" expects 2 or 3 arguments, got ${args.length}`, ["index-of", ...args], path);
2084
+ const needle = compile(args[0], "value", path.concat(1));
2085
+ const haystack = compile(args[1], "value", path.concat(2));
2086
+ const from = args.length === 3 ? compile(args[2], "number", path.concat(3)) : undefined;
2087
+ const children = from ? [needle, haystack, from] : [needle, haystack];
2088
+ return {
2089
+ evaluate: (ctx) => {
2090
+ const target = needle.evaluate(ctx);
2091
+ const source = haystack.evaluate(ctx);
2092
+ const start = from ? Number(from.evaluate(ctx)) : 0;
2093
+ if (Array.isArray(source))
2094
+ return source.indexOf(target, start);
2095
+ return toStr(source).indexOf(toStr(target), start);
2096
+ },
2097
+ returnType: "number",
2098
+ ...mergeDeps6(children)
2099
+ };
2100
+ });
2101
+ registerOperator("slice", (args, compile, path) => {
2102
+ if (args.length !== 2 && args.length !== 3)
2103
+ throw new ExpressionError(`"slice" expects 2 or 3 arguments, got ${args.length}`, ["slice", ...args], path);
2104
+ const input = compile(args[0], "value", path.concat(1));
2105
+ const start = compile(args[1], "number", path.concat(2));
2106
+ const end = args.length === 3 ? compile(args[2], "number", path.concat(3)) : undefined;
2107
+ const children = end ? [input, start, end] : [input, start];
2108
+ return {
2109
+ evaluate: (ctx) => {
2110
+ const source = input.evaluate(ctx);
2111
+ const from = Number(start.evaluate(ctx));
2112
+ const to = end ? Number(end.evaluate(ctx)) : undefined;
2113
+ if (Array.isArray(source))
2114
+ return to === undefined ? source.slice(from) : source.slice(from, to);
2115
+ const text = toStr(source);
2116
+ return to === undefined ? text.slice(from) : text.slice(from, to);
2117
+ },
2118
+ returnType: "value",
2119
+ ...mergeDeps6(children)
2120
+ };
2121
+ });
2122
+ registerOperator("number-format", (args, compile, path) => {
2123
+ if (args.length !== 2)
2124
+ throw new ExpressionError(`"number-format" expects 2 arguments, got ${args.length}`, ["number-format", ...args], path);
2125
+ const value = compile(args[0], "number", path.concat(1));
2126
+ const rawOptions = args[1];
2127
+ if (rawOptions === null || typeof rawOptions !== "object" || Array.isArray(rawOptions))
2128
+ throw new ExpressionError('"number-format": second argument must be an options object', ["number-format", ...args], path);
2129
+ const opts = rawOptions;
2130
+ const locale = typeof opts.locale === "string" ? opts.locale : undefined;
2131
+ const format = {};
2132
+ if (typeof opts.currency === "string") {
2133
+ format.style = "currency";
2134
+ format.currency = opts.currency;
2135
+ }
2136
+ if (typeof opts["min-fraction-digits"] === "number")
2137
+ format.minimumFractionDigits = opts["min-fraction-digits"];
2138
+ if (typeof opts["max-fraction-digits"] === "number")
2139
+ format.maximumFractionDigits = opts["max-fraction-digits"];
2140
+ const formatter = new Intl.NumberFormat(locale, format);
2141
+ return {
2142
+ evaluate: (ctx) => formatter.format(Number(value.evaluate(ctx))),
2143
+ returnType: "string",
2144
+ ...mergeDeps6([value])
2145
+ };
2146
+ });
2147
+ registerOperator("format", (args, compile, path) => {
2148
+ if (args.length === 0)
2149
+ throw new ExpressionError('"format" expects at least 1 argument', ["format"], path);
2150
+ const sections = [];
2151
+ for (let i = 0;i < args.length; i++) {
2152
+ const arg = args[i];
2153
+ const isOptions = arg !== null && typeof arg === "object" && !Array.isArray(arg);
2154
+ if (isOptions)
2155
+ continue;
2156
+ const section = { value: compile(arg, "value", path.concat(i + 1)) };
2157
+ const options = args[i + 1];
2158
+ if (options !== null && typeof options === "object" && !Array.isArray(options)) {
2159
+ const opts = options;
2160
+ const scale = opts["font-scale"];
2161
+ if (typeof scale === "number")
2162
+ section.scale = scale;
2163
+ else if (Array.isArray(scale))
2164
+ section.scale = compile(scale, "number", path.concat(i + 2, "font-scale"));
2165
+ const font = opts["text-font"];
2166
+ if (Array.isArray(font) && font[0] === "literal" && Array.isArray(font[1]))
2167
+ section.fontStack = font[1].map(String);
2168
+ else if (Array.isArray(font) && font.every((f) => typeof f === "string"))
2169
+ section.fontStack = font;
2170
+ const color = opts["text-color"];
2171
+ if (typeof color === "string")
2172
+ section.color = color;
2173
+ else if (Array.isArray(color))
2174
+ section.color = compile(color, "value", path.concat(i + 2, "text-color"));
2175
+ }
2176
+ sections.push(section);
2177
+ }
2178
+ const deps = sections.flatMap((s) => [
2179
+ s.value,
2180
+ typeof s.scale === "object" ? s.scale : undefined,
2181
+ typeof s.color === "object" ? s.color : undefined
2182
+ ].filter(Boolean));
2183
+ return {
2184
+ evaluate: (ctx) => {
2185
+ return new Formatted(sections.map((section) => ({
2186
+ text: toStr(section.value.evaluate(ctx)),
2187
+ scale: typeof section.scale === "object" ? Number(section.scale.evaluate(ctx)) : section.scale,
2188
+ fontStack: section.fontStack,
2189
+ color: typeof section.color === "object" ? toStr(section.color.evaluate(ctx)) : section.color
2190
+ })));
2191
+ },
2192
+ returnType: "formatted",
2193
+ ...mergeDeps6(deps)
1818
2194
  };
1819
2195
  });
1820
2196
  registerOperator("resolved-locale", (args, _compile, path) => {
@@ -1845,6 +2221,8 @@ function boot() {
1845
2221
  registerConversionOps();
1846
2222
  registerStringOps();
1847
2223
  registerInterpolateOps();
2224
+ registerBindingOps();
2225
+ registerGeometryOps();
1848
2226
  }
1849
2227
  function compileLiteral(value, expected, path) {
1850
2228
  if (expected === "color") {
@@ -1899,7 +2277,9 @@ var BOOTED = false;
1899
2277
  var init_compile = __esm(() => {
1900
2278
  init_Color();
1901
2279
  init_errors();
2280
+ init_binding();
1902
2281
  init_conversion();
2282
+ init_geometry();
1903
2283
  init_interpolate();
1904
2284
  init_logical();
1905
2285
  init_lookup();
@@ -2015,6 +2395,18 @@ var init_legacyFilter = __esm(() => {
2015
2395
  });
2016
2396
 
2017
2397
  // src/core-map/style-spec/expressions/index.ts
2398
+ var exports_expressions = {};
2399
+ __export(exports_expressions, {
2400
+ ExpressionError: () => ExpressionError,
2401
+ compile: () => compile,
2402
+ convertLegacyFilter: () => convertLegacyFilter,
2403
+ evaluate: () => evaluate,
2404
+ formatColor: () => formatColor,
2405
+ isExpression: () => isExpression,
2406
+ lerpColor: () => lerpColor,
2407
+ parseColor: () => parseColor,
2408
+ validateExpression: () => validateExpression
2409
+ });
2018
2410
  function evaluate(expr, ctx, expectedType = "value") {
2019
2411
  if (!isExpression(expr)) {
2020
2412
  if (Array.isArray(expr))
@@ -2044,7 +2436,7 @@ var init_expressions = __esm(() => {
2044
2436
  });
2045
2437
 
2046
2438
  // src/core-map/style-spec/schema.ts
2047
- var backgroundPaint, fillPaint, fillExtrusionPaint, linePaint, circlePaint, symbolPaint, rasterPaint, paintPropertySchemas, visibility, backgroundLayout, fillLayout, fillExtrusionLayout, lineLayout, circleLayout, symbolLayout, rasterLayout, layoutPropertySchemas, layerTypes, sourceTypes;
2439
+ var backgroundPaint, fillPaint, fillExtrusionPaint, linePaint, circlePaint, symbolPaint, rasterPaint, hillshadePaint, heatmapPaint, paintPropertySchemas, visibility, backgroundLayout, fillLayout, fillExtrusionLayout, lineLayout, circleLayout, symbolLayout, rasterLayout, hillshadeLayout, heatmapLayout, layoutPropertySchemas, layerTypes, sourceTypes;
2048
2440
  var init_schema = __esm(() => {
2049
2441
  backgroundPaint = {
2050
2442
  "background-color": { type: "color", default: "#000000", transition: true, sdk: "gl" },
@@ -2122,6 +2514,21 @@ var init_schema = __esm(() => {
2122
2514
  "raster-resampling": { type: "enum", values: ["linear", "nearest"], default: "linear", sdk: "gl" },
2123
2515
  "raster-fade-duration": { type: "number", default: 300, minimum: 0, sdk: "gl" }
2124
2516
  };
2517
+ hillshadePaint = {
2518
+ "hillshade-illumination-direction": { type: "number", default: 335, minimum: 0, maximum: 359, sdk: "gl" },
2519
+ "hillshade-illumination-anchor": { type: "enum", values: ["map", "viewport"], default: "viewport", sdk: "gl" },
2520
+ "hillshade-exaggeration": { type: "number", default: 0.5, minimum: 0, maximum: 1, transition: true, sdk: "gl" },
2521
+ "hillshade-shadow-color": { type: "color", default: "#000000", transition: true, sdk: "gl" },
2522
+ "hillshade-highlight-color": { type: "color", default: "#FFFFFF", transition: true, sdk: "gl" },
2523
+ "hillshade-accent-color": { type: "color", default: "#000000", transition: true, sdk: "gl" }
2524
+ };
2525
+ heatmapPaint = {
2526
+ "heatmap-radius": { type: "number", default: 30, minimum: 1, transition: true, sdk: "gl" },
2527
+ "heatmap-weight": { type: "number", default: 1, minimum: 0, sdk: "gl" },
2528
+ "heatmap-intensity": { type: "number", default: 1, minimum: 0, transition: true, sdk: "gl" },
2529
+ "heatmap-color": { type: "color", default: undefined, sdk: "gl" },
2530
+ "heatmap-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, sdk: "gl" }
2531
+ };
2125
2532
  paintPropertySchemas = {
2126
2533
  background: backgroundPaint,
2127
2534
  fill: fillPaint,
@@ -2129,7 +2536,9 @@ var init_schema = __esm(() => {
2129
2536
  line: linePaint,
2130
2537
  circle: circlePaint,
2131
2538
  symbol: symbolPaint,
2132
- raster: rasterPaint
2539
+ raster: rasterPaint,
2540
+ hillshade: hillshadePaint,
2541
+ heatmap: heatmapPaint
2133
2542
  };
2134
2543
  visibility = { type: "enum", values: ["visible", "none"], default: "visible", sdk: "gl" };
2135
2544
  backgroundLayout = {
@@ -2211,6 +2620,12 @@ var init_schema = __esm(() => {
2211
2620
  rasterLayout = {
2212
2621
  visibility
2213
2622
  };
2623
+ hillshadeLayout = {
2624
+ visibility
2625
+ };
2626
+ heatmapLayout = {
2627
+ visibility
2628
+ };
2214
2629
  layoutPropertySchemas = {
2215
2630
  background: backgroundLayout,
2216
2631
  fill: fillLayout,
@@ -2218,9 +2633,11 @@ var init_schema = __esm(() => {
2218
2633
  line: lineLayout,
2219
2634
  circle: circleLayout,
2220
2635
  symbol: symbolLayout,
2221
- raster: rasterLayout
2636
+ raster: rasterLayout,
2637
+ hillshade: hillshadeLayout,
2638
+ heatmap: heatmapLayout
2222
2639
  };
2223
- layerTypes = ["background", "fill", "fill-extrusion", "line", "circle", "symbol", "raster"];
2640
+ layerTypes = ["background", "fill", "fill-extrusion", "line", "circle", "symbol", "raster", "hillshade", "heatmap"];
2224
2641
  sourceTypes = ["vector", "raster", "raster-dem", "geojson"];
2225
2642
  });
2226
2643