ts-maps 0.3.1 → 0.3.3

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 (57) 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 +56 -0
  4. package/dist/core-map/control/NavigationControl.d.ts +39 -0
  5. package/dist/core-map/control/index.d.ts +8 -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 +856 -31
  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/geometry/index.js +28 -28
  16. package/dist/core-map/index.d.ts +8 -2
  17. package/dist/core-map/layer/GeoJSONTileSource.d.ts +50 -0
  18. package/dist/core-map/layer/RunTrailLayer.d.ts +35 -0
  19. package/dist/core-map/layer/TerritoryLayer.d.ts +62 -0
  20. package/dist/core-map/layer/index.d.ts +6 -0
  21. package/dist/core-map/layer/tile/RasterDEMLayer.d.ts +4 -0
  22. package/dist/core-map/layer/tile/VectorTileMapLayer.d.ts +59 -11
  23. package/dist/core-map/layer/tile/urlTemplate.d.ts +1 -2
  24. package/dist/core-map/map/Map.d.ts +32 -1
  25. package/dist/core-map/mvt/DecodedTile.d.ts +20 -0
  26. package/dist/core-map/mvt/FlatTile.d.ts +25 -0
  27. package/dist/core-map/mvt/VectorTileFeature.d.ts +8 -0
  28. package/dist/core-map/services/index.js +48 -48
  29. package/dist/core-map/storage/index.js +5 -5
  30. package/dist/core-map/style-spec/expressions/formatted.d.ts +36 -0
  31. package/dist/core-map/style-spec/expressions/operators/binding.d.ts +1 -0
  32. package/dist/core-map/style-spec/expressions/operators/geometry.d.ts +19 -0
  33. package/dist/core-map/style-spec/expressions/types.d.ts +3 -0
  34. package/dist/core-map/style-spec/index.js +460 -60
  35. package/dist/core-map/style-spec/schema.d.ts +43 -3
  36. package/dist/core-map/style-spec/types.d.ts +47 -7
  37. package/dist/core-map/styles/basemap.d.ts +41 -0
  38. package/dist/core-map/styles/index.d.ts +5 -0
  39. package/dist/core-map/styles/palette.d.ts +31 -0
  40. package/dist/core-map/symbols/CollisionIndex.d.ts +22 -5
  41. package/dist/core-map/symbols/GlyphAtlas.d.ts +6 -1
  42. package/dist/core-map/symbols/GlyphProvider.d.ts +21 -0
  43. package/dist/core-map/symbols/GlyphRenderer.d.ts +48 -0
  44. package/dist/core-map/symbols/IconAtlas.d.ts +10 -1
  45. package/dist/core-map/symbols/SymbolOverlay.d.ts +47 -0
  46. package/dist/core-map/symbols/index.d.ts +4 -0
  47. package/dist/core-map/symbols/index.js +1072 -68
  48. package/dist/core-map/symbols/loadGlyphs.d.ts +53 -0
  49. package/dist/core-map/symbols/loadSprite.d.ts +57 -0
  50. package/dist/core-map/symbols/placement.d.ts +67 -0
  51. package/dist/core-map/symbols/sdf.d.ts +37 -0
  52. package/dist/core-map/symbols/sections.d.ts +32 -0
  53. package/dist/core-map/workers/WorkerPool.d.ts +40 -0
  54. package/dist/core-map/workers/decodeMvtFlat.d.ts +52 -0
  55. package/dist/index.js +11783 -6100
  56. package/package.json +2 -2
  57. package/src/core-map/ts-maps.css +576 -79
@@ -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,7 +1422,7 @@ 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) => {
@@ -1241,7 +1439,7 @@ function registerLogicalOps() {
1241
1439
  return false;
1242
1440
  },
1243
1441
  returnType: "boolean",
1244
- ...mergeDeps3([input])
1442
+ ...mergeDeps4([input])
1245
1443
  };
1246
1444
  });
1247
1445
  registerOperator("!in", (args, compile, path) => {
@@ -1258,7 +1456,7 @@ function registerLogicalOps() {
1258
1456
  return true;
1259
1457
  },
1260
1458
  returnType: "boolean",
1261
- ...mergeDeps3([input])
1459
+ ...mergeDeps4([input])
1262
1460
  };
1263
1461
  });
1264
1462
  registerOperator("!has", (args, _compile, path) => {
@@ -1468,6 +1666,17 @@ function registerLookupOps() {
1468
1666
  dependsOnFeatureState: false
1469
1667
  };
1470
1668
  });
1669
+ registerOperator("heatmap-density", (args, _compile, path) => {
1670
+ if (args.length !== 0)
1671
+ throw new ExpressionError(`"heatmap-density" takes no arguments, got ${args.length}`, ["heatmap-density", ...args], path);
1672
+ return {
1673
+ evaluate: (ctx) => ctx.heatmapDensity ?? 0,
1674
+ returnType: "number",
1675
+ dependsOnZoom: false,
1676
+ dependsOnFeature: false,
1677
+ dependsOnFeatureState: false
1678
+ };
1679
+ });
1471
1680
  registerOperator("feature-state", (args, _compile, path) => {
1472
1681
  if (args.length !== 1)
1473
1682
  throw new ExpressionError(`"feature-state" expects 1 argument, got ${args.length}`, ["feature-state", ...args], path);
@@ -1510,7 +1719,7 @@ function expectNumber(value, op, expr) {
1510
1719
  throw new ExpressionError(`"${op}": expected number, got ${String(value)}`, expr);
1511
1720
  return value;
1512
1721
  }
1513
- function mergeDeps4(children) {
1722
+ function mergeDeps5(children) {
1514
1723
  let z = false;
1515
1724
  let f = false;
1516
1725
  let s = false;
@@ -1536,7 +1745,7 @@ function registerMathOps() {
1536
1745
  return acc;
1537
1746
  },
1538
1747
  returnType: "number",
1539
- ...mergeDeps4(children)
1748
+ ...mergeDeps5(children)
1540
1749
  };
1541
1750
  });
1542
1751
  registerOperator("*", (args, compile, path) => {
@@ -1550,7 +1759,7 @@ function registerMathOps() {
1550
1759
  return acc;
1551
1760
  },
1552
1761
  returnType: "number",
1553
- ...mergeDeps4(children)
1762
+ ...mergeDeps5(children)
1554
1763
  };
1555
1764
  });
1556
1765
  registerOperator("-", (args, compile, path) => {
@@ -1563,7 +1772,7 @@ function registerMathOps() {
1563
1772
  return {
1564
1773
  evaluate: (ctx) => -expectNumber(a2.evaluate(ctx), "-", expr),
1565
1774
  returnType: "number",
1566
- ...mergeDeps4(children)
1775
+ ...mergeDeps5(children)
1567
1776
  };
1568
1777
  }
1569
1778
  const a = children[0];
@@ -1571,7 +1780,7 @@ function registerMathOps() {
1571
1780
  return {
1572
1781
  evaluate: (ctx) => expectNumber(a.evaluate(ctx), "-", expr) - expectNumber(b.evaluate(ctx), "-", expr),
1573
1782
  returnType: "number",
1574
- ...mergeDeps4(children)
1783
+ ...mergeDeps5(children)
1575
1784
  };
1576
1785
  });
1577
1786
  registerOperator("/", (args, compile, path) => {
@@ -1589,7 +1798,7 @@ function registerMathOps() {
1589
1798
  return av / bv;
1590
1799
  },
1591
1800
  returnType: "number",
1592
- ...mergeDeps4([a, b])
1801
+ ...mergeDeps5([a, b])
1593
1802
  };
1594
1803
  });
1595
1804
  registerOperator("%", (args, compile, path) => {
@@ -1607,7 +1816,7 @@ function registerMathOps() {
1607
1816
  return av % bv;
1608
1817
  },
1609
1818
  returnType: "number",
1610
- ...mergeDeps4([a, b])
1819
+ ...mergeDeps5([a, b])
1611
1820
  };
1612
1821
  });
1613
1822
  registerOperator("^", (args, compile, path) => {
@@ -1619,7 +1828,7 @@ function registerMathOps() {
1619
1828
  return {
1620
1829
  evaluate: (ctx) => expectNumber(a.evaluate(ctx), "^", expr) ** expectNumber(b.evaluate(ctx), "^", expr),
1621
1830
  returnType: "number",
1622
- ...mergeDeps4([a, b])
1831
+ ...mergeDeps5([a, b])
1623
1832
  };
1624
1833
  });
1625
1834
  registerOperator("min", (args, compile, path) => {
@@ -1638,7 +1847,7 @@ function registerMathOps() {
1638
1847
  return m;
1639
1848
  },
1640
1849
  returnType: "number",
1641
- ...mergeDeps4(children)
1850
+ ...mergeDeps5(children)
1642
1851
  };
1643
1852
  });
1644
1853
  registerOperator("max", (args, compile, path) => {
@@ -1657,7 +1866,7 @@ function registerMathOps() {
1657
1866
  return m;
1658
1867
  },
1659
1868
  returnType: "number",
1660
- ...mergeDeps4(children)
1869
+ ...mergeDeps5(children)
1661
1870
  };
1662
1871
  });
1663
1872
  const unary = (name, fn, validate) => {
@@ -1674,7 +1883,7 @@ function registerMathOps() {
1674
1883
  return fn(v);
1675
1884
  },
1676
1885
  returnType: "number",
1677
- ...mergeDeps4([inner])
1886
+ ...mergeDeps5([inner])
1678
1887
  };
1679
1888
  });
1680
1889
  };
@@ -1698,6 +1907,18 @@ function registerMathOps() {
1698
1907
  if (n <= 0)
1699
1908
  throw new ExpressionError('"log2": input must be positive', expr);
1700
1909
  });
1910
+ unary("sin", Math.sin);
1911
+ unary("cos", Math.cos);
1912
+ unary("tan", Math.tan);
1913
+ unary("asin", Math.asin, (n, expr) => {
1914
+ if (n < -1 || n > 1)
1915
+ throw new ExpressionError('"asin": input must be in [-1, 1]', expr);
1916
+ });
1917
+ unary("acos", Math.acos, (n, expr) => {
1918
+ if (n < -1 || n > 1)
1919
+ throw new ExpressionError('"acos": input must be in [-1, 1]', expr);
1920
+ });
1921
+ unary("atan", Math.atan);
1701
1922
  registerOperator("e", (args, _compile, path) => {
1702
1923
  if (args.length !== 0)
1703
1924
  throw new ExpressionError(`"e" takes no arguments, got ${args.length}`, ["e", ...args], path);
@@ -1746,7 +1967,7 @@ function registerMathOps() {
1746
1967
  return a + (b - a) * Math.random();
1747
1968
  },
1748
1969
  returnType: "number",
1749
- ...mergeDeps4(children)
1970
+ ...mergeDeps5(children)
1750
1971
  };
1751
1972
  });
1752
1973
  }
@@ -1755,8 +1976,31 @@ var init_math = __esm(() => {
1755
1976
  init_registry();
1756
1977
  });
1757
1978
 
1979
+ // src/core-map/style-spec/expressions/formatted.ts
1980
+ class Formatted {
1981
+ sections;
1982
+ constructor(sections) {
1983
+ this.sections = sections;
1984
+ }
1985
+ toString() {
1986
+ let out = "";
1987
+ for (const section of this.sections)
1988
+ out += section.text;
1989
+ return out;
1990
+ }
1991
+ get uniform() {
1992
+ return isUniform(this.sections);
1993
+ }
1994
+ }
1995
+ function isUniform(sections) {
1996
+ return sections.every((s) => s.scale === undefined && s.fontStack === undefined && s.color === undefined);
1997
+ }
1998
+ function isFormatted(value) {
1999
+ return value instanceof Formatted || !!value && typeof value === "object" && Array.isArray(value.sections);
2000
+ }
2001
+
1758
2002
  // src/core-map/style-spec/expressions/operators/string.ts
1759
- function mergeDeps5(children) {
2003
+ function mergeDeps6(children) {
1760
2004
  let z = false;
1761
2005
  let f = false;
1762
2006
  let s = false;
@@ -1794,7 +2038,7 @@ function registerStringOps() {
1794
2038
  return out;
1795
2039
  },
1796
2040
  returnType: "string",
1797
- ...mergeDeps5(children)
2041
+ ...mergeDeps6(children)
1798
2042
  };
1799
2043
  });
1800
2044
  registerOperator("downcase", (args, compile, path) => {
@@ -1804,7 +2048,7 @@ function registerStringOps() {
1804
2048
  return {
1805
2049
  evaluate: (ctx) => toStr(inner.evaluate(ctx)).toLowerCase(),
1806
2050
  returnType: "string",
1807
- ...mergeDeps5([inner])
2051
+ ...mergeDeps6([inner])
1808
2052
  };
1809
2053
  });
1810
2054
  registerOperator("upcase", (args, compile, path) => {
@@ -1814,7 +2058,122 @@ function registerStringOps() {
1814
2058
  return {
1815
2059
  evaluate: (ctx) => toStr(inner.evaluate(ctx)).toUpperCase(),
1816
2060
  returnType: "string",
1817
- ...mergeDeps5([inner])
2061
+ ...mergeDeps6([inner])
2062
+ };
2063
+ });
2064
+ registerOperator("index-of", (args, compile, path) => {
2065
+ if (args.length !== 2 && args.length !== 3)
2066
+ throw new ExpressionError(`"index-of" expects 2 or 3 arguments, got ${args.length}`, ["index-of", ...args], path);
2067
+ const needle = compile(args[0], "value", path.concat(1));
2068
+ const haystack = compile(args[1], "value", path.concat(2));
2069
+ const from = args.length === 3 ? compile(args[2], "number", path.concat(3)) : undefined;
2070
+ const children = from ? [needle, haystack, from] : [needle, haystack];
2071
+ return {
2072
+ evaluate: (ctx) => {
2073
+ const target = needle.evaluate(ctx);
2074
+ const source = haystack.evaluate(ctx);
2075
+ const start = from ? Number(from.evaluate(ctx)) : 0;
2076
+ if (Array.isArray(source))
2077
+ return source.indexOf(target, start);
2078
+ return toStr(source).indexOf(toStr(target), start);
2079
+ },
2080
+ returnType: "number",
2081
+ ...mergeDeps6(children)
2082
+ };
2083
+ });
2084
+ registerOperator("slice", (args, compile, path) => {
2085
+ if (args.length !== 2 && args.length !== 3)
2086
+ throw new ExpressionError(`"slice" expects 2 or 3 arguments, got ${args.length}`, ["slice", ...args], path);
2087
+ const input = compile(args[0], "value", path.concat(1));
2088
+ const start = compile(args[1], "number", path.concat(2));
2089
+ const end = args.length === 3 ? compile(args[2], "number", path.concat(3)) : undefined;
2090
+ const children = end ? [input, start, end] : [input, start];
2091
+ return {
2092
+ evaluate: (ctx) => {
2093
+ const source = input.evaluate(ctx);
2094
+ const from = Number(start.evaluate(ctx));
2095
+ const to = end ? Number(end.evaluate(ctx)) : undefined;
2096
+ if (Array.isArray(source))
2097
+ return to === undefined ? source.slice(from) : source.slice(from, to);
2098
+ const text = toStr(source);
2099
+ return to === undefined ? text.slice(from) : text.slice(from, to);
2100
+ },
2101
+ returnType: "value",
2102
+ ...mergeDeps6(children)
2103
+ };
2104
+ });
2105
+ registerOperator("number-format", (args, compile, path) => {
2106
+ if (args.length !== 2)
2107
+ throw new ExpressionError(`"number-format" expects 2 arguments, got ${args.length}`, ["number-format", ...args], path);
2108
+ const value = compile(args[0], "number", path.concat(1));
2109
+ const rawOptions = args[1];
2110
+ if (rawOptions === null || typeof rawOptions !== "object" || Array.isArray(rawOptions))
2111
+ throw new ExpressionError('"number-format": second argument must be an options object', ["number-format", ...args], path);
2112
+ const opts = rawOptions;
2113
+ const locale = typeof opts.locale === "string" ? opts.locale : undefined;
2114
+ const format = {};
2115
+ if (typeof opts.currency === "string") {
2116
+ format.style = "currency";
2117
+ format.currency = opts.currency;
2118
+ }
2119
+ if (typeof opts["min-fraction-digits"] === "number")
2120
+ format.minimumFractionDigits = opts["min-fraction-digits"];
2121
+ if (typeof opts["max-fraction-digits"] === "number")
2122
+ format.maximumFractionDigits = opts["max-fraction-digits"];
2123
+ const formatter = new Intl.NumberFormat(locale, format);
2124
+ return {
2125
+ evaluate: (ctx) => formatter.format(Number(value.evaluate(ctx))),
2126
+ returnType: "string",
2127
+ ...mergeDeps6([value])
2128
+ };
2129
+ });
2130
+ registerOperator("format", (args, compile, path) => {
2131
+ if (args.length === 0)
2132
+ throw new ExpressionError('"format" expects at least 1 argument', ["format"], path);
2133
+ const sections = [];
2134
+ for (let i = 0;i < args.length; i++) {
2135
+ const arg = args[i];
2136
+ const isOptions = arg !== null && typeof arg === "object" && !Array.isArray(arg);
2137
+ if (isOptions)
2138
+ continue;
2139
+ const section = { value: compile(arg, "value", path.concat(i + 1)) };
2140
+ const options = args[i + 1];
2141
+ if (options !== null && typeof options === "object" && !Array.isArray(options)) {
2142
+ const opts = options;
2143
+ const scale = opts["font-scale"];
2144
+ if (typeof scale === "number")
2145
+ section.scale = scale;
2146
+ else if (Array.isArray(scale))
2147
+ section.scale = compile(scale, "number", path.concat(i + 2, "font-scale"));
2148
+ const font = opts["text-font"];
2149
+ if (Array.isArray(font) && font[0] === "literal" && Array.isArray(font[1]))
2150
+ section.fontStack = font[1].map(String);
2151
+ else if (Array.isArray(font) && font.every((f) => typeof f === "string"))
2152
+ section.fontStack = font;
2153
+ const color = opts["text-color"];
2154
+ if (typeof color === "string")
2155
+ section.color = color;
2156
+ else if (Array.isArray(color))
2157
+ section.color = compile(color, "value", path.concat(i + 2, "text-color"));
2158
+ }
2159
+ sections.push(section);
2160
+ }
2161
+ const deps = sections.flatMap((s) => [
2162
+ s.value,
2163
+ typeof s.scale === "object" ? s.scale : undefined,
2164
+ typeof s.color === "object" ? s.color : undefined
2165
+ ].filter(Boolean));
2166
+ return {
2167
+ evaluate: (ctx) => {
2168
+ return new Formatted(sections.map((section) => ({
2169
+ text: toStr(section.value.evaluate(ctx)),
2170
+ scale: typeof section.scale === "object" ? Number(section.scale.evaluate(ctx)) : section.scale,
2171
+ fontStack: section.fontStack,
2172
+ color: typeof section.color === "object" ? toStr(section.color.evaluate(ctx)) : section.color
2173
+ })));
2174
+ },
2175
+ returnType: "formatted",
2176
+ ...mergeDeps6(deps)
1818
2177
  };
1819
2178
  });
1820
2179
  registerOperator("resolved-locale", (args, _compile, path) => {
@@ -1845,6 +2204,8 @@ function boot() {
1845
2204
  registerConversionOps();
1846
2205
  registerStringOps();
1847
2206
  registerInterpolateOps();
2207
+ registerBindingOps();
2208
+ registerGeometryOps();
1848
2209
  }
1849
2210
  function compileLiteral(value, expected, path) {
1850
2211
  if (expected === "color") {
@@ -1899,7 +2260,9 @@ var BOOTED = false;
1899
2260
  var init_compile = __esm(() => {
1900
2261
  init_Color();
1901
2262
  init_errors();
2263
+ init_binding();
1902
2264
  init_conversion();
2265
+ init_geometry();
1903
2266
  init_interpolate();
1904
2267
  init_logical();
1905
2268
  init_lookup();
@@ -2015,6 +2378,18 @@ var init_legacyFilter = __esm(() => {
2015
2378
  });
2016
2379
 
2017
2380
  // src/core-map/style-spec/expressions/index.ts
2381
+ var exports_expressions = {};
2382
+ __export(exports_expressions, {
2383
+ ExpressionError: () => ExpressionError,
2384
+ compile: () => compile,
2385
+ convertLegacyFilter: () => convertLegacyFilter,
2386
+ evaluate: () => evaluate,
2387
+ formatColor: () => formatColor,
2388
+ isExpression: () => isExpression,
2389
+ lerpColor: () => lerpColor,
2390
+ parseColor: () => parseColor,
2391
+ validateExpression: () => validateExpression
2392
+ });
2018
2393
  function evaluate(expr, ctx, expectedType = "value") {
2019
2394
  if (!isExpression(expr)) {
2020
2395
  if (Array.isArray(expr))
@@ -2044,7 +2419,7 @@ var init_expressions = __esm(() => {
2044
2419
  });
2045
2420
 
2046
2421
  // 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;
2422
+ 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
2423
  var init_schema = __esm(() => {
2049
2424
  backgroundPaint = {
2050
2425
  "background-color": { type: "color", default: "#000000", transition: true, sdk: "gl" },
@@ -2122,6 +2497,21 @@ var init_schema = __esm(() => {
2122
2497
  "raster-resampling": { type: "enum", values: ["linear", "nearest"], default: "linear", sdk: "gl" },
2123
2498
  "raster-fade-duration": { type: "number", default: 300, minimum: 0, sdk: "gl" }
2124
2499
  };
2500
+ hillshadePaint = {
2501
+ "hillshade-illumination-direction": { type: "number", default: 335, minimum: 0, maximum: 359, sdk: "gl" },
2502
+ "hillshade-illumination-anchor": { type: "enum", values: ["map", "viewport"], default: "viewport", sdk: "gl" },
2503
+ "hillshade-exaggeration": { type: "number", default: 0.5, minimum: 0, maximum: 1, transition: true, sdk: "gl" },
2504
+ "hillshade-shadow-color": { type: "color", default: "#000000", transition: true, sdk: "gl" },
2505
+ "hillshade-highlight-color": { type: "color", default: "#FFFFFF", transition: true, sdk: "gl" },
2506
+ "hillshade-accent-color": { type: "color", default: "#000000", transition: true, sdk: "gl" }
2507
+ };
2508
+ heatmapPaint = {
2509
+ "heatmap-radius": { type: "number", default: 30, minimum: 1, transition: true, sdk: "gl" },
2510
+ "heatmap-weight": { type: "number", default: 1, minimum: 0, sdk: "gl" },
2511
+ "heatmap-intensity": { type: "number", default: 1, minimum: 0, transition: true, sdk: "gl" },
2512
+ "heatmap-color": { type: "color", default: undefined, sdk: "gl" },
2513
+ "heatmap-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, sdk: "gl" }
2514
+ };
2125
2515
  paintPropertySchemas = {
2126
2516
  background: backgroundPaint,
2127
2517
  fill: fillPaint,
@@ -2129,7 +2519,9 @@ var init_schema = __esm(() => {
2129
2519
  line: linePaint,
2130
2520
  circle: circlePaint,
2131
2521
  symbol: symbolPaint,
2132
- raster: rasterPaint
2522
+ raster: rasterPaint,
2523
+ hillshade: hillshadePaint,
2524
+ heatmap: heatmapPaint
2133
2525
  };
2134
2526
  visibility = { type: "enum", values: ["visible", "none"], default: "visible", sdk: "gl" };
2135
2527
  backgroundLayout = {
@@ -2211,6 +2603,12 @@ var init_schema = __esm(() => {
2211
2603
  rasterLayout = {
2212
2604
  visibility
2213
2605
  };
2606
+ hillshadeLayout = {
2607
+ visibility
2608
+ };
2609
+ heatmapLayout = {
2610
+ visibility
2611
+ };
2214
2612
  layoutPropertySchemas = {
2215
2613
  background: backgroundLayout,
2216
2614
  fill: fillLayout,
@@ -2218,9 +2616,11 @@ var init_schema = __esm(() => {
2218
2616
  line: lineLayout,
2219
2617
  circle: circleLayout,
2220
2618
  symbol: symbolLayout,
2221
- raster: rasterLayout
2619
+ raster: rasterLayout,
2620
+ hillshade: hillshadeLayout,
2621
+ heatmap: heatmapLayout
2222
2622
  };
2223
- layerTypes = ["background", "fill", "fill-extrusion", "line", "circle", "symbol", "raster"];
2623
+ layerTypes = ["background", "fill", "fill-extrusion", "line", "circle", "symbol", "raster", "hillshade", "heatmap"];
2224
2624
  sourceTypes = ["vector", "raster", "raster-dem", "geojson"];
2225
2625
  });
2226
2626
 
@@ -2507,23 +2907,23 @@ init_expressions();
2507
2907
  init_schema();
2508
2908
  init_validate2();
2509
2909
  export {
2510
- validateStyle,
2511
- validateSource,
2512
- validatePaintProperty,
2513
- validateLayoutProperty,
2514
- validateLayer,
2515
- validateExpression,
2516
- sourceTypes,
2517
- parseColor,
2518
- paintPropertySchemas,
2519
- lerpColor,
2520
- layoutPropertySchemas,
2521
- layerTypes,
2522
- isExpression,
2523
- formatColor,
2524
- evaluate as evaluateExpression,
2525
- diffStyles,
2526
- convertLegacyFilter,
2910
+ ExpressionError,
2527
2911
  compile as compileExpression,
2528
- ExpressionError
2912
+ convertLegacyFilter,
2913
+ diffStyles,
2914
+ evaluate as evaluateExpression,
2915
+ formatColor,
2916
+ isExpression,
2917
+ layerTypes,
2918
+ layoutPropertySchemas,
2919
+ lerpColor,
2920
+ paintPropertySchemas,
2921
+ parseColor,
2922
+ sourceTypes,
2923
+ validateExpression,
2924
+ validateLayer,
2925
+ validateLayoutProperty,
2926
+ validatePaintProperty,
2927
+ validateSource,
2928
+ validateStyle
2529
2929
  };