isard 1.0.0 → 1.2.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.
Files changed (268) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/{basemaps.d.ts → basemap/basemaps.d.ts} +3 -3
  3. package/dist/{basemaps.js → basemap/basemaps.js} +3 -3
  4. package/dist/basemap/basemaps.js.map +1 -0
  5. package/dist/{grid.d.ts → basemap/grid.d.ts} +6 -6
  6. package/dist/{grid.js → basemap/grid.js} +61 -67
  7. package/dist/basemap/grid.js.map +1 -0
  8. package/dist/{mvt.d.ts → basemap/mvt.d.ts} +1 -1
  9. package/dist/{mvt.js → basemap/mvt.js} +6 -6
  10. package/dist/basemap/mvt.js.map +1 -0
  11. package/dist/{pmtiles.d.ts → basemap/pmtiles.d.ts} +16 -10
  12. package/dist/{pmtiles.js → basemap/pmtiles.js} +41 -33
  13. package/dist/basemap/pmtiles.js.map +1 -0
  14. package/dist/{resample.d.ts → basemap/resample.d.ts} +11 -2
  15. package/dist/{resample.js → basemap/resample.js} +18 -16
  16. package/dist/basemap/resample.js.map +1 -0
  17. package/dist/{terrain.d.ts → basemap/terrain.d.ts} +3 -3
  18. package/dist/{terrain.js → basemap/terrain.js} +7 -7
  19. package/dist/basemap/terrain.js.map +1 -0
  20. package/dist/{vectorstyle.d.ts → basemap/vectorstyle.d.ts} +12 -10
  21. package/dist/{vectorstyle.js → basemap/vectorstyle.js} +129 -111
  22. package/dist/basemap/vectorstyle.js.map +1 -0
  23. package/dist/{vectortiles.d.ts → basemap/vectortiles.d.ts} +18 -18
  24. package/dist/{vectortiles.js → basemap/vectortiles.js} +157 -109
  25. package/dist/basemap/vectortiles.js.map +1 -0
  26. package/dist/{wmts.d.ts → basemap/wmts.d.ts} +3 -3
  27. package/dist/{wmts.js → basemap/wmts.js} +19 -14
  28. package/dist/basemap/wmts.js.map +1 -0
  29. package/dist/basemap.worker.js +2 -2
  30. package/dist/basemap.worker.js.map +14 -13
  31. package/dist/bind/layers.d.ts +46 -0
  32. package/dist/bind/layers.js +154 -0
  33. package/dist/bind/layers.js.map +1 -0
  34. package/dist/{crs.d.ts → data/crs.d.ts} +11 -11
  35. package/dist/{crs.js → data/crs.js} +38 -34
  36. package/dist/data/crs.js.map +1 -0
  37. package/dist/{gpx.d.ts → data/gpx.d.ts} +2 -2
  38. package/dist/{gpx.js → data/gpx.js} +20 -20
  39. package/dist/data/gpx.js.map +1 -0
  40. package/dist/{kml.d.ts → data/kml.d.ts} +2 -2
  41. package/dist/{kml.js → data/kml.js} +42 -39
  42. package/dist/data/kml.js.map +1 -0
  43. package/dist/{topojson.d.ts → data/topojson.d.ts} +2 -2
  44. package/dist/{topojson.js → data/topojson.js} +15 -10
  45. package/dist/data/topojson.js.map +1 -0
  46. package/dist/{xml.d.ts → data/xml.d.ts} +5 -5
  47. package/dist/{xml.js → data/xml.js} +19 -18
  48. package/dist/data/xml.js.map +1 -0
  49. package/dist/decoder.worker.js +4 -4
  50. package/dist/decoder.worker.js.map +7 -7
  51. package/dist/{decoders.d.ts → engine/decoders.d.ts} +3 -3
  52. package/dist/{decoders.js → engine/decoders.js} +28 -25
  53. package/dist/engine/decoders.js.map +1 -0
  54. package/dist/{loader.d.ts → engine/loader.d.ts} +1 -1
  55. package/dist/{loader.js → engine/loader.js} +17 -14
  56. package/dist/engine/loader.js.map +1 -0
  57. package/dist/{protocol.d.ts → engine/protocol.d.ts} +1 -1
  58. package/dist/engine/protocol.js +3 -0
  59. package/dist/engine/protocol.js.map +1 -0
  60. package/dist/{requests.d.ts → engine/requests.d.ts} +1 -1
  61. package/dist/{requests.js → engine/requests.js} +19 -16
  62. package/dist/engine/requests.js.map +1 -0
  63. package/dist/engine-loader.d.ts +13 -9
  64. package/dist/engine-loader.js +30 -30
  65. package/dist/engine-loader.js.map +1 -1
  66. package/dist/formats.d.ts +3 -3
  67. package/dist/formats.js +3 -3
  68. package/dist/formats.js.map +1 -1
  69. package/dist/geoplateforme.d.ts +13 -13
  70. package/dist/geoplateforme.js +23 -21
  71. package/dist/geoplateforme.js.map +1 -1
  72. package/dist/index.d.ts +30 -29
  73. package/dist/index.js +18 -18
  74. package/dist/index.js.map +1 -1
  75. package/dist/isard_bg.wasm +0 -0
  76. package/dist/isard_core_bg.wasm +0 -0
  77. package/dist/isard_points_bg.wasm +0 -0
  78. package/dist/{extrusions.d.ts → layers/extrusions.d.ts} +1 -1
  79. package/dist/{extrusions.js → layers/extrusions.js} +10 -5
  80. package/dist/layers/extrusions.js.map +1 -0
  81. package/dist/{features.d.ts → layers/features.d.ts} +10 -10
  82. package/dist/{features.js → layers/features.js} +44 -45
  83. package/dist/layers/features.js.map +1 -0
  84. package/dist/{glyphs.d.ts → layers/glyphs.d.ts} +6 -6
  85. package/dist/{glyphs.js → layers/glyphs.js} +45 -41
  86. package/dist/layers/glyphs.js.map +1 -0
  87. package/dist/{icons.d.ts → layers/icons.d.ts} +10 -10
  88. package/dist/{icons.js → layers/icons.js} +84 -69
  89. package/dist/layers/icons.js.map +1 -0
  90. package/dist/{layers.d.ts → layers/layers.d.ts} +9 -4
  91. package/dist/{layers.js → layers/layers.js} +35 -31
  92. package/dist/layers/layers.js.map +1 -0
  93. package/dist/{panoramas.d.ts → layers/panoramas.d.ts} +3 -3
  94. package/dist/{panoramas.js → layers/panoramas.js} +54 -43
  95. package/dist/layers/panoramas.js.map +1 -0
  96. package/dist/{pointclouds.d.ts → layers/pointclouds.d.ts} +5 -5
  97. package/dist/{pointclouds.js → layers/pointclouds.js} +26 -34
  98. package/dist/layers/pointclouds.js.map +1 -0
  99. package/dist/{symbols.d.ts → layers/symbols.d.ts} +3 -3
  100. package/dist/{symbols.js → layers/symbols.js} +69 -72
  101. package/dist/layers/symbols.js.map +1 -0
  102. package/dist/map/basemap-layers.d.ts +26 -0
  103. package/dist/map/basemap-layers.js +61 -0
  104. package/dist/map/basemap-layers.js.map +1 -0
  105. package/dist/map/canvas.d.ts +17 -0
  106. package/dist/map/canvas.js +56 -0
  107. package/dist/map/canvas.js.map +1 -0
  108. package/dist/map/checks.d.ts +11 -0
  109. package/dist/map/checks.js +39 -0
  110. package/dist/map/checks.js.map +1 -0
  111. package/dist/map/credits.d.ts +17 -0
  112. package/dist/map/credits.js +34 -0
  113. package/dist/map/credits.js.map +1 -0
  114. package/dist/map/engine-settings.d.ts +15 -0
  115. package/dist/map/engine-settings.js +45 -0
  116. package/dist/map/engine-settings.js.map +1 -0
  117. package/dist/map/engines.d.ts +41 -0
  118. package/dist/map/engines.js +77 -0
  119. package/dist/map/engines.js.map +1 -0
  120. package/dist/map/events.d.ts +14 -0
  121. package/dist/map/events.js +46 -0
  122. package/dist/map/events.js.map +1 -0
  123. package/dist/map/frame-loop.d.ts +61 -0
  124. package/dist/map/frame-loop.js +139 -0
  125. package/dist/map/frame-loop.js.map +1 -0
  126. package/dist/map/hover-pick.d.ts +30 -0
  127. package/dist/map/hover-pick.js +56 -0
  128. package/dist/map/hover-pick.js.map +1 -0
  129. package/dist/map/layer-spec.d.ts +42 -0
  130. package/dist/map/layer-spec.js +34 -0
  131. package/dist/map/layer-spec.js.map +1 -0
  132. package/dist/map/layer-stack.d.ts +36 -0
  133. package/dist/map/layer-stack.js +101 -0
  134. package/dist/map/layer-stack.js.map +1 -0
  135. package/dist/map/overlay-host.d.ts +36 -0
  136. package/dist/map/overlay-host.js +101 -0
  137. package/dist/map/overlay-host.js.map +1 -0
  138. package/dist/map/panorama-host.d.ts +5 -0
  139. package/dist/map/panorama-host.js +32 -0
  140. package/dist/map/panorama-host.js.map +1 -0
  141. package/dist/map/raster-source.d.ts +11 -0
  142. package/dist/map/raster-source.js +26 -0
  143. package/dist/map/raster-source.js.map +1 -0
  144. package/dist/map/symbol-atlases.d.ts +26 -0
  145. package/dist/map/symbol-atlases.js +59 -0
  146. package/dist/map/symbol-atlases.js.map +1 -0
  147. package/dist/map/viewshed.d.ts +5 -0
  148. package/dist/map/viewshed.js +28 -0
  149. package/dist/map/viewshed.js.map +1 -0
  150. package/dist/map/workers.d.ts +46 -0
  151. package/dist/map/workers.js +73 -0
  152. package/dist/map/workers.js.map +1 -0
  153. package/dist/map.d.ts +46 -127
  154. package/dist/map.js +183 -698
  155. package/dist/map.js.map +1 -1
  156. package/dist/projections.d.ts +3 -3
  157. package/dist/projections.js +2 -2
  158. package/dist/projections.js.map +1 -1
  159. package/dist/react/Control.d.ts +11 -0
  160. package/dist/react/Control.js +18 -0
  161. package/dist/react/Control.js.map +1 -0
  162. package/dist/react/CustomLayer.d.ts +11 -0
  163. package/dist/react/CustomLayer.js +30 -0
  164. package/dist/react/CustomLayer.js.map +1 -0
  165. package/dist/react/IsardMap.d.ts +43 -0
  166. package/dist/react/IsardMap.js +146 -0
  167. package/dist/react/IsardMap.js.map +1 -0
  168. package/dist/react/Layer.d.ts +42 -0
  169. package/dist/react/Layer.js +74 -0
  170. package/dist/react/Layer.js.map +1 -0
  171. package/dist/react/Marker.d.ts +24 -0
  172. package/dist/react/Marker.js +53 -0
  173. package/dist/react/Marker.js.map +1 -0
  174. package/dist/react/Panel.d.ts +11 -0
  175. package/dist/react/Panel.js +37 -0
  176. package/dist/react/Panel.js.map +1 -0
  177. package/dist/react/Popup.d.ts +18 -0
  178. package/dist/react/Popup.js +60 -0
  179. package/dist/react/Popup.js.map +1 -0
  180. package/dist/react/Swipe.d.ts +9 -0
  181. package/dist/react/Swipe.js +41 -0
  182. package/dist/react/Swipe.js.map +1 -0
  183. package/dist/react/Viewshed.d.ts +5 -0
  184. package/dist/react/Viewshed.js +28 -0
  185. package/dist/react/Viewshed.js.map +1 -0
  186. package/dist/react/context.d.ts +32 -0
  187. package/dist/react/context.js +20 -0
  188. package/dist/react/context.js.map +1 -0
  189. package/dist/react/index.d.ts +26 -0
  190. package/dist/react/index.js +22 -0
  191. package/dist/react/index.js.map +1 -0
  192. package/dist/settings.d.ts +6 -10
  193. package/dist/settings.js +19 -17
  194. package/dist/settings.js.map +1 -1
  195. package/dist/types.d.ts +8 -8
  196. package/dist/types.js +1 -0
  197. package/dist/types.js.map +1 -1
  198. package/dist/{controls.d.ts → ui/controls.d.ts} +1 -1
  199. package/dist/{controls.js → ui/controls.js} +6 -4
  200. package/dist/ui/controls.js.map +1 -0
  201. package/dist/{interaction.d.ts → ui/interaction.d.ts} +9 -5
  202. package/dist/{interaction.js → ui/interaction.js} +9 -8
  203. package/dist/ui/interaction.js.map +1 -0
  204. package/dist/{overlay.d.ts → ui/overlay.d.ts} +2 -2
  205. package/dist/{overlay.js → ui/overlay.js} +18 -20
  206. package/dist/ui/overlay.js.map +1 -0
  207. package/dist/{style.d.ts → ui/style.d.ts} +1 -1
  208. package/dist/{style.js → ui/style.js} +2 -2
  209. package/dist/ui/style.js.map +1 -0
  210. package/dist/{animation.d.ts → util/animation.d.ts} +9 -5
  211. package/dist/{animation.js → util/animation.js} +6 -6
  212. package/dist/util/animation.js.map +1 -0
  213. package/dist/{color.d.ts → util/color.d.ts} +1 -1
  214. package/dist/{color.js → util/color.js} +14 -16
  215. package/dist/util/color.js.map +1 -0
  216. package/dist/{geo.d.ts → util/geo.d.ts} +6 -6
  217. package/dist/{geo.js → util/geo.js} +12 -12
  218. package/dist/util/geo.js.map +1 -0
  219. package/dist/util/guards.d.ts +7 -0
  220. package/dist/util/guards.js +8 -0
  221. package/dist/util/guards.js.map +1 -0
  222. package/dist/util/lru.js.map +1 -0
  223. package/dist/wasm/isard.d.ts +168 -0
  224. package/dist/wasm/isard.js +146 -0
  225. package/dist/wasm/isard_core.d.ts +144 -0
  226. package/dist/wasm/isard_core.js +122 -0
  227. package/dist/{basemap.worker.d.ts → workers/basemap.worker.d.ts} +17 -7
  228. package/dist/workers/basemap.worker.js +658 -0
  229. package/dist/workers/basemap.worker.js.map +1 -0
  230. package/package.json +24 -1
  231. package/vite.js +1 -1
  232. package/dist/animation.js.map +0 -1
  233. package/dist/basemaps.js.map +0 -1
  234. package/dist/color.js.map +0 -1
  235. package/dist/controls.js.map +0 -1
  236. package/dist/crs.js.map +0 -1
  237. package/dist/decoders.js.map +0 -1
  238. package/dist/extrusions.js.map +0 -1
  239. package/dist/features.js.map +0 -1
  240. package/dist/geo.js.map +0 -1
  241. package/dist/glyphs.js.map +0 -1
  242. package/dist/gpx.js.map +0 -1
  243. package/dist/grid.js.map +0 -1
  244. package/dist/icons.js.map +0 -1
  245. package/dist/interaction.js.map +0 -1
  246. package/dist/kml.js.map +0 -1
  247. package/dist/layers.js.map +0 -1
  248. package/dist/loader.js.map +0 -1
  249. package/dist/lru.js.map +0 -1
  250. package/dist/mvt.js.map +0 -1
  251. package/dist/overlay.js.map +0 -1
  252. package/dist/panoramas.js.map +0 -1
  253. package/dist/pmtiles.js.map +0 -1
  254. package/dist/pointclouds.js.map +0 -1
  255. package/dist/protocol.js +0 -2
  256. package/dist/protocol.js.map +0 -1
  257. package/dist/requests.js.map +0 -1
  258. package/dist/resample.js.map +0 -1
  259. package/dist/style.js.map +0 -1
  260. package/dist/symbols.js.map +0 -1
  261. package/dist/terrain.js.map +0 -1
  262. package/dist/topojson.js.map +0 -1
  263. package/dist/vectorstyle.js.map +0 -1
  264. package/dist/vectortiles.js.map +0 -1
  265. package/dist/wmts.js.map +0 -1
  266. package/dist/xml.js.map +0 -1
  267. /package/dist/{lru.d.ts → util/lru.d.ts} +0 -0
  268. /package/dist/{lru.js → util/lru.js} +0 -0
@@ -6,43 +6,52 @@
6
6
  * `format`, conversions and assertions, `upcase`, `downcase`, `literal`…; others give null, with a warning), colors
7
7
  * interpolated in RGBA, `{token}` text fields.
8
8
  */
9
- import { parseCssColor } from "./color.js";
9
+ import { parseCssColor } from "../util/color.js";
10
+ import { isRecord } from "../util/guards.js";
11
+ /** A MapLibre style, as far as the basemap reads it: its sources and its layers (an id and a type each) */
12
+ export const isStyle = (value) => isRecord(value) &&
13
+ isRecord(value.sources) &&
14
+ Object.values(value.sources).every((s) => isRecord(s) && typeof s.type === 'string') &&
15
+ Array.isArray(value.layers) &&
16
+ value.layers.every((l) => isRecord(l) && typeof l.id === 'string' && typeof l.type === 'string');
10
17
  const TYPES = ['Unknown', 'Point', 'LineString', 'Polygon'];
11
- export function context(feature, zoom) {
18
+ export const context = (feature, zoom) => {
12
19
  return { zoom, properties: feature.properties, type: TYPES[feature.type] ?? 'Unknown' };
13
- }
20
+ };
14
21
  // ── Colors ──
15
22
  /** A color to RGBA 0-1, undefined if it is not one */
16
- export function color(value) {
23
+ export const color = (value) => {
17
24
  return parseCssColor(value);
18
- }
19
- export function css([r, g, b, a]) {
25
+ };
26
+ export const css = ([r, g, b, a]) => {
20
27
  return `rgba(${Math.round(r * 255)},${Math.round(g * 255)},${Math.round(b * 255)},${a})`;
21
- }
28
+ };
22
29
  // ── Interpolation ──
23
30
  /** Factor between two stops: linear, or exponential of `base` */
24
- function factor(x, x0, x1, base = 1) {
31
+ const factor = (x, x0, x1, base = 1) => {
25
32
  const d = x1 - x0;
26
33
  if (d === 0)
27
34
  return 0;
28
35
  const t = x - x0;
29
36
  return base === 1 ? t / d : (base ** t - 1) / (base ** d - 1);
30
- }
31
- function mix(a, b, t) {
37
+ };
38
+ const mix = (a, b, t) => {
32
39
  if (typeof a === 'number' && typeof b === 'number')
33
40
  return a + (b - a) * t;
34
41
  const ca = color(a);
35
42
  const cb = color(b);
36
- if (ca && cb)
37
- return css([0, 1, 2, 3].map((i) => (ca[i] ?? 0) + ((cb[i] ?? 0) - (ca[i] ?? 0)) * t));
43
+ if (ca && cb) {
44
+ const lerp = (i) => ca[i] + (cb[i] - ca[i]) * t;
45
+ return css([lerp(0), lerp(1), lerp(2), lerp(3)]);
46
+ }
38
47
  if (Array.isArray(a) && Array.isArray(b))
39
48
  return a.map((v, i) => mix(v, b[i], t));
40
49
  return t < 0.5 ? a : b;
41
- }
42
- function isFunction(v) {
50
+ };
51
+ const isFunction = (v) => {
43
52
  return typeof v === 'object' && v !== null && !Array.isArray(v) && Array.isArray(v.stops);
44
- }
45
- function legacy(f, ctx) {
53
+ };
54
+ const legacy = (f, ctx) => {
46
55
  const input = f.property === undefined ? ctx.zoom : ctx.properties[f.property];
47
56
  const stops = f.stops;
48
57
  const type = f.type ?? (f.property === undefined || typeof stops[0]?.[0] === 'number' ? 'exponential' : 'categorical');
@@ -53,30 +62,45 @@ function legacy(f, ctx) {
53
62
  if (typeof input !== 'number' || !stops.length)
54
63
  return f.default ?? stops[0]?.[1];
55
64
  // Zoom-and-property stops ({ zoom, value } keys) are taken at their zoom only
56
- const key = (s) => typeof s[0] === 'object' && s[0] !== null ? Number(s[0].zoom) : Number(s[0]);
65
+ const key = ([k]) => {
66
+ if (Array.isArray(k))
67
+ return Number.NaN;
68
+ return isRecord(k) ? Number(k.zoom) : Number(k);
69
+ };
57
70
  const first = stops[0];
58
71
  if (!first)
59
72
  return f.default;
60
73
  if (input <= key(first))
61
74
  return first[1];
62
- for (let i = 1; i < stops.length; i += 1) {
63
- const [s0, s1] = [stops[i - 1], stops[i]];
64
- if (!s0 || !s1)
65
- continue;
66
- if (input < key(s1)) {
67
- if (type === 'interval')
68
- return s0[1];
69
- return mix(s0[1], s1[1], factor(input, key(s0), key(s1), f.base ?? 1));
70
- }
71
- }
72
- return stops.at(-1)?.[1];
73
- }
75
+ const at = stops.findIndex((s1, i) => i > 0 && Boolean(stops[i - 1]) && Boolean(s1) && input < key(s1));
76
+ const [s0, s1] = [stops[at - 1], stops[at]];
77
+ if (at < 0 || !s0 || !s1)
78
+ return stops.at(-1)?.[1];
79
+ if (type === 'interval')
80
+ return s0[1];
81
+ return mix(s0[1], s1[1], factor(input, key(s0), key(s1), f.base ?? 1));
82
+ };
74
83
  // ── Expressions ──
75
- function get(ctx, key) {
84
+ /** A list of values to look a value up in (any value: `includes` compares with `===`) */
85
+ const labels = (values) => values;
86
+ const ORDERS = {
87
+ '<': (a, b) => a < b,
88
+ '<=': (a, b) => a <= b,
89
+ '>': (a, b) => a > b,
90
+ '>=': (a, b) => a >= b,
91
+ };
92
+ /** A comparison of any two values the way JavaScript's operators make it: two strings (lists and objects as their
93
+ * text) in text order, anything else as numbers */
94
+ const compare = (op, a, b) => {
95
+ const text = (v) => (typeof v === 'object' && v !== null ? String(v) : v);
96
+ const [x, y] = [text(a), text(b)];
97
+ return typeof x === 'string' && typeof y === 'string' ? ORDERS[op](x, y) : ORDERS[op](Number(x), Number(y));
98
+ };
99
+ const get = (ctx, key) => {
76
100
  if (key === '$type')
77
101
  return ctx.type;
78
102
  return typeof key === 'string' ? ctx.properties[key] : undefined;
79
- }
103
+ };
80
104
  /** The operators `evaluate` knows */
81
105
  const OPERATORS = new Set([
82
106
  'literal',
@@ -142,13 +166,13 @@ const OPERATORS = new Set([
142
166
  'e',
143
167
  ]);
144
168
  /** Whether a value is an expression (an array starting with a known operator), not a literal array */
145
- export function isExpression(e) {
169
+ export const isExpression = (e) => {
146
170
  return Array.isArray(e) && typeof e[0] === 'string' && OPERATORS.has(e[0]);
147
- }
171
+ };
148
172
  /** Operators already warned about */
149
173
  const warned = new Set();
150
174
  const str = (v) => (v === undefined || v === null ? '' : String(v));
151
- export function evaluate(e, ctx) {
175
+ export const evaluate = (e, ctx) => {
152
176
  if (isFunction(e))
153
177
  return legacy(e, ctx);
154
178
  if (!Array.isArray(e))
@@ -184,13 +208,17 @@ export function evaluate(e, ctx) {
184
208
  case 'image':
185
209
  return ev(0);
186
210
  case 'number-format': {
187
- const options = (args[1] ?? {});
211
+ const options = isRecord(args[1]) ? args[1] : {};
212
+ const option = (key) => {
213
+ const v = options[key];
214
+ return typeof v === 'number' ? v : undefined;
215
+ };
188
216
  const n = num(0);
189
217
  if (!Number.isFinite(n))
190
218
  return '';
191
- return n.toLocaleString(options.locale, {
192
- minimumFractionDigits: options['min-fraction-digits'],
193
- maximumFractionDigits: options['max-fraction-digits'],
219
+ return n.toLocaleString(typeof options.locale === 'string' ? options.locale : undefined, {
220
+ minimumFractionDigits: option('min-fraction-digits'),
221
+ maximumFractionDigits: option('max-fraction-digits'),
194
222
  });
195
223
  }
196
224
  case 'to-number': {
@@ -262,13 +290,10 @@ export function evaluate(e, ctx) {
262
290
  case '!=':
263
291
  return ev(0) !== ev(1);
264
292
  case '<':
265
- return ev(0) < ev(1);
266
293
  case '<=':
267
- return ev(0) <= ev(1);
268
294
  case '>':
269
- return ev(0) > ev(1);
270
295
  case '>=':
271
- return ev(0) >= ev(1);
296
+ return compare(op, ev(0), ev(1));
272
297
  case 'in': {
273
298
  const haystack = ev(1);
274
299
  const needle = ev(0);
@@ -277,19 +302,15 @@ export function evaluate(e, ctx) {
277
302
  return Array.isArray(haystack) && haystack.includes(needle);
278
303
  }
279
304
  case 'case': {
280
- for (let i = 0; i + 1 < args.length; i += 2)
281
- if (ev(i))
282
- return ev(i + 1);
283
- return ev(args.length - 1);
305
+ const hit = args.findIndex((_, i) => i % 2 === 0 && i + 1 < args.length && Boolean(ev(i)));
306
+ return hit < 0 ? ev(args.length - 1) : ev(hit + 1);
284
307
  }
285
308
  case 'match': {
286
309
  const input = ev(0);
287
- for (let i = 1; i + 1 < args.length; i += 2) {
288
- const label = args[i];
289
- if (Array.isArray(label) ? label.includes(input) : label === input)
290
- return ev(i + 1);
291
- }
292
- return ev(args.length - 1);
310
+ const hit = args.findIndex((label, i) => i % 2 === 1 &&
311
+ i + 1 < args.length &&
312
+ (Array.isArray(label) ? labels(label).includes(input) : label === input));
313
+ return hit < 0 ? ev(args.length - 1) : ev(hit + 1);
293
314
  }
294
315
  case 'step': {
295
316
  const input = num(0);
@@ -308,20 +329,20 @@ export function evaluate(e, ctx) {
308
329
  const kind = args[0];
309
330
  const input = num(1);
310
331
  const base = Array.isArray(kind) && kind[0] === 'exponential' ? Number(kind[1]) : 1;
311
- const stops = [];
312
- for (let i = 2; i + 1 < args.length; i += 2)
313
- stops.push([Number(args[i]), args[i + 1] ?? null]);
332
+ const stops = Array.from({ length: Math.floor((args.length - 2) / 2) }, (_, k) => [
333
+ Number(args[2 + 2 * k]),
334
+ args[3 + 2 * k] ?? null,
335
+ ]);
314
336
  const first = stops[0];
315
337
  if (!first)
316
338
  return null;
317
339
  if (input <= first[0])
318
340
  return evaluate(first[1], ctx);
319
- for (let i = 1; i < stops.length; i += 1) {
320
- const [s0, s1] = [stops[i - 1], stops[i]];
321
- if (s0 && s1 && input < s1[0])
322
- return mix(evaluate(s0[1], ctx), evaluate(s1[1], ctx), factor(input, s0[0], s1[0], base));
323
- }
324
- return evaluate(stops.at(-1)?.[1] ?? null, ctx);
341
+ const at = stops.findIndex((s1, i) => i > 0 && input < s1[0]);
342
+ const [s0, s1] = [stops[at - 1], stops[at]];
343
+ if (at < 0 || !s0 || !s1)
344
+ return evaluate(stops.at(-1)?.[1] ?? null, ctx);
345
+ return mix(evaluate(s0[1], ctx), evaluate(s1[1], ctx), factor(input, s0[0], s1[0], base));
325
346
  }
326
347
  case 'rgb':
327
348
  case 'rgba':
@@ -371,12 +392,12 @@ export function evaluate(e, ctx) {
371
392
  }
372
393
  return null;
373
394
  }
374
- }
395
+ };
375
396
  // ── Filters ──
376
397
  const LEGACY_COMPARISONS = new Set(['==', '!=', '<', '<=', '>', '>=']);
377
398
  /** Whether a filter (not `all`, `any`, `none`) is in the legacy form: `["==", "key", value]`, `["in", "key", a, b]`,
378
399
  * `["has", "key"]`; a key and literal values, as MapLibre tells them from expressions */
379
- function isLegacyLeaf(f) {
400
+ const isLegacyLeaf = (f) => {
380
401
  const [op, a, ...rest] = f;
381
402
  if (typeof op !== 'string' || typeof a !== 'string' || rest.some(Array.isArray))
382
403
  return false;
@@ -385,8 +406,8 @@ function isLegacyLeaf(f) {
385
406
  if (op === 'in')
386
407
  return f.length !== 3 || !Array.isArray(f[2]);
387
408
  return op === '!in' || op === 'has' || op === '!has';
388
- }
389
- function legacyFilter(f, ctx) {
409
+ };
410
+ const legacyFilter = (f, ctx) => {
390
411
  const [op, key, ...rest] = f;
391
412
  const v = get(ctx, key);
392
413
  switch (op) {
@@ -395,17 +416,14 @@ function legacyFilter(f, ctx) {
395
416
  case '!=':
396
417
  return v !== rest[0];
397
418
  case '<':
398
- return v < rest[0];
399
419
  case '<=':
400
- return v <= rest[0];
401
420
  case '>':
402
- return v > rest[0];
403
421
  case '>=':
404
- return v >= rest[0];
422
+ return compare(op, v, rest[0]);
405
423
  case 'in':
406
- return rest.includes(v);
424
+ return labels(rest).includes(v);
407
425
  case '!in':
408
- return !rest.includes(v);
426
+ return !labels(rest).includes(v);
409
427
  case 'has':
410
428
  return v !== undefined;
411
429
  case '!has':
@@ -413,53 +431,53 @@ function legacyFilter(f, ctx) {
413
431
  default:
414
432
  return true;
415
433
  }
416
- }
434
+ };
417
435
  /** Compiled filters, by filter object */
418
436
  const compiled = new WeakMap();
419
437
  /** A filter as a function: `all`, `any`, `none` of their parts, each part legacy or an expression (they may mix) */
420
- function compile(f) {
438
+ const compile = (f) => {
421
439
  if (!Array.isArray(f))
422
440
  return () => Boolean(f);
423
441
  const hit = compiled.get(f);
424
442
  if (hit)
425
443
  return hit;
426
- let test;
427
- const op = f[0];
428
- if (op === 'all' || op === 'any' || op === 'none') {
429
- const parts = f.slice(1).map(compile);
430
- if (op === 'all')
431
- test = (ctx) => parts.every((p) => p(ctx));
432
- else if (op === 'any')
433
- test = (ctx) => parts.some((p) => p(ctx));
434
- else
435
- test = (ctx) => !parts.some((p) => p(ctx));
436
- }
437
- else if (isLegacyLeaf(f)) {
438
- test = (ctx) => legacyFilter(f, ctx);
439
- }
440
- else {
441
- test = (ctx) => Boolean(evaluate(f, ctx));
442
- }
444
+ const make = () => {
445
+ const op = f[0];
446
+ if (op === 'all' || op === 'any' || op === 'none') {
447
+ const parts = f.slice(1).map(compile);
448
+ if (op === 'all')
449
+ return (ctx) => parts.every((p) => p(ctx));
450
+ if (op === 'any')
451
+ return (ctx) => parts.some((p) => p(ctx));
452
+ return (ctx) => !parts.some((p) => p(ctx));
453
+ }
454
+ if (isLegacyLeaf(f))
455
+ return (ctx) => legacyFilter(f, ctx);
456
+ return (ctx) => Boolean(evaluate(f, ctx));
457
+ };
458
+ const test = make();
443
459
  compiled.set(f, test);
444
460
  return test;
445
- }
446
- export function filter(f, ctx) {
461
+ };
462
+ export const filter = (f, ctx) => {
447
463
  if (f === undefined || f === null)
448
464
  return true;
449
465
  return compile(f)(ctx);
450
- }
466
+ };
467
+ /** The operators that read the feature */
468
+ const FEATURE_OPERATORS = new Set(['get', 'has', '!has', 'geometry-type', 'properties', 'id']);
451
469
  /** Whether a value depends on the feature (else only on the zoom, evaluated once per tile) */
452
- export function isFeatureDependent(e) {
470
+ export const isFeatureDependent = (e) => {
453
471
  if (e !== undefined && isFunction(e))
454
472
  return e.property !== undefined;
455
473
  if (!Array.isArray(e))
456
474
  return false;
457
- if (['get', 'has', '!has', 'geometry-type', 'properties', 'id'].includes(e[0]))
475
+ if (FEATURE_OPERATORS.has(e[0]))
458
476
  return true;
459
477
  return e.some((x) => isFeatureDependent(x));
460
- }
478
+ };
461
479
  /** A `{token}` text field (or an expression) to the text of a feature */
462
- export function text(field, ctx) {
480
+ export const text = (field, ctx) => {
463
481
  if (field === undefined || field === null)
464
482
  return '';
465
483
  if (typeof field === 'string') {
@@ -474,45 +492,45 @@ export function text(field, ctx) {
474
492
  return v.filter((x) => typeof x === 'string').join('');
475
493
  }
476
494
  return v === undefined || v === null ? '' : String(v);
477
- }
495
+ };
478
496
  /** The font of a label from the first of its `text-font`: a family without its weight takes the regular one */
479
- export function labelFont(font) {
497
+ export const labelFont = (font) => {
480
498
  return /Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(font) ? font : `${font} Regular`;
481
- }
499
+ };
482
500
  /**
483
501
  * A value of the zoom only (an expression: `interpolate`, `step` of `["zoom"]`) as stops `[[zoom, value], …]` for the
484
502
  * engine, which interpolates them linearly: evaluated at its own stops and at the whole zooms between (an exponential
485
503
  * curve followed closely), a step kept sharp just before its threshold
486
504
  */
487
- export function zoomStops(e) {
505
+ export const zoomStops = (e) => {
488
506
  const zooms = new Set();
507
+ // The inputs of the stops of an `interpolate` or a `step` (from its fourth argument, one in two)
508
+ const stopInputs = (x) => x.filter((_, i) => i >= 3 && i % 2 === 1).map(Number);
489
509
  const walk = (x) => {
490
510
  if (!Array.isArray(x))
491
511
  return;
492
512
  const zoomInput = (input) => Array.isArray(input) && input[0] === 'zoom';
493
513
  if ((x[0] === 'interpolate' || x[0] === 'interpolate-hcl' || x[0] === 'interpolate-lab') && zoomInput(x[2])) {
494
- for (let i = 3; i < x.length; i += 2)
495
- zooms.add(Number(x[i]));
514
+ stopInputs(x).forEach((t) => {
515
+ zooms.add(t);
516
+ });
496
517
  }
497
518
  else if (x[0] === 'step' && zoomInput(x[1])) {
498
- for (let i = 3; i < x.length; i += 2) {
499
- const t = Number(x[i]);
519
+ stopInputs(x).forEach((t) => {
500
520
  zooms.add(t);
501
521
  zooms.add(t - 0.01);
502
- }
522
+ });
503
523
  }
504
- for (const y of x)
505
- walk(y);
524
+ x.forEach(walk);
506
525
  };
507
526
  walk(e);
508
527
  const finite = [...zooms].filter(Number.isFinite);
509
528
  if (finite.length === 0)
510
529
  finite.push(0);
511
530
  const [lo, hi] = [Math.min(...finite), Math.max(...finite)];
512
- for (let z = Math.ceil(lo); z <= Math.floor(hi); z += 1)
513
- finite.push(z);
531
+ finite.push(...Array.from({ length: Math.floor(hi) - Math.ceil(lo) + 1 }, (_, i) => Math.ceil(lo) + i));
514
532
  return [...new Set(finite)]
515
533
  .sort((a, b) => a - b)
516
534
  .map((zoom) => [zoom, Number(evaluate(e, { zoom, properties: {}, type: 'Unknown' }))]);
517
- }
535
+ };
518
536
  //# sourceMappingURL=vectorstyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorstyle.js","sourceRoot":"","sources":["../../src/basemap/vectorstyle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AA6B7C,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CACxD,QAAQ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B,CAAC,CAAC;IAEF,IAAI,CAAC,CAAC,CAAC,CAAC;IAER,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAExC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAE5D,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAExG,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;SACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;SACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC,CAAC","sourcesContent":["/**\n * The parts of the MapLibre style specification a vector basemap needs, evaluated on the page: filters (legacy\n * `[\"==\", \"key\", value]` forms and expressions), property values given as constants, legacy functions (`{ stops }`\n * of zoom or of a property: exponential, interval, categorical, identity) or expressions (`get`, `has`, `concat`,\n * `interpolate`, `step`, `match`, `case`, `coalesce`, comparisons, `all`, `any`, `!`, `in`, `zoom`, arithmetic,\n * `format`, conversions and assertions, `upcase`, `downcase`, `literal`…; others give null, with a warning), colors\n * interpolated in RGBA, `{token}` text fields.\n */\nimport { parseCssColor } from '../util/color.ts';\nimport { isRecord } from '../util/guards.ts';\nimport type { TileFeature, Value } from './mvt.ts';\n\nexport type Json = null | boolean | number | string | Json[] | { [key: string]: Json };\n\nexport interface StyleLayer {\n id: string;\n type: string;\n source?: string;\n 'source-layer'?: string;\n minzoom?: number;\n maxzoom?: number;\n filter?: Json;\n layout?: Record<string, Json>;\n paint?: Record<string, Json>;\n}\n\nexport interface Style {\n version: number;\n sources: Record<\n string,\n { type: string; tiles?: string[]; url?: string; maxzoom?: number; minzoom?: number; tileSize?: number }\n >;\n layers: StyleLayer[];\n glyphs?: string;\n /** One sprite's URL (without extension), or several with their ids (`id:name` names their images) */\n sprite?: string | { id: string; url: string }[];\n}\n\n/** A MapLibre style, as far as the basemap reads it: its sources and its layers (an id and a type each) */\nexport const isStyle = (value: unknown): value is Style =>\n isRecord(value) &&\n isRecord(value.sources) &&\n Object.values(value.sources).every((s) => isRecord(s) && typeof s.type === 'string') &&\n Array.isArray(value.layers) &&\n value.layers.every((l) => isRecord(l) && typeof l.id === 'string' && typeof l.type === 'string');\n\n/** A raster source of a style: its tile URL, its deepest level and the CSS pixels of its tiles (MapLibre's\n * `tileSize`: 512 by default) */\nexport interface RasterSource {\n tiles: string;\n maxzoom: number;\n tileSize: number;\n}\n\n/** How a label's text or icon meets the others (`*-allow-overlap` and `*-ignore-placement`, see `Overlap`) */\nexport type CandidateOverlap = boolean | 'allow' | 'ignore';\n\n/** The icon of a label, in style terms evaluated at the tile's zoom */\nexport interface CandidateIcon {\n /** Its image in the style's sprite */\n image: string;\n /** A number, or zoom stops */\n size: Json;\n anchor: string;\n offset: [number, number];\n rotate: number;\n /** `map` or `viewport` (`auto` resolved) */\n alignment: 'map' | 'viewport';\n overlap: CandidateOverlap;\n optional: boolean;\n fit: 'none' | 'width' | 'height' | 'both';\n padding: [number, number, number, number];\n color: string;\n opacity: number;\n}\n\n/** A label to shape and place, in style terms evaluated at the tile's zoom */\nexport interface LabelCandidate {\n /** Index of its style layer: higher ones are placed first */\n layer: number;\n /** Its text, empty for an icon alone */\n text: string;\n lon: number;\n lat: number;\n /** On a line: the direction there (degrees of longitude and latitude) */\n along?: [number, number];\n /** Its text runs along the line (`symbol-placement: line`, `text-rotation-alignment` not `viewport`) */\n textAlong?: boolean;\n textOptional?: boolean;\n icon?: CandidateIcon;\n font: string;\n size: Json;\n color: string;\n haloColor: string;\n haloWidth: number;\n anchor: string;\n offset: [number, number];\n maxWidth: number;\n lineHeight: number;\n overlap: CandidateOverlap;\n}\n\n/** What expressions see of a feature */\nexport interface Context {\n zoom: number;\n properties: Record<string, Value>;\n /** 'Point', 'LineString' or 'Polygon' */\n type: string;\n}\n\nconst TYPES = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nexport const context = (feature: TileFeature, zoom: number): Context => {\n return { zoom, properties: feature.properties, type: TYPES[feature.type] ?? 'Unknown' };\n};\n\n// ── Colors ──\n\n/** A color to RGBA 0-1, undefined if it is not one */\nexport const color = (value: unknown): [number, number, number, number] | undefined => {\n return parseCssColor(value);\n};\n\nexport const css = ([r, g, b, a]: [number, number, number, number]): string => {\n return `rgba(${Math.round(r * 255)},${Math.round(g * 255)},${Math.round(b * 255)},${a})`;\n};\n\n// ── Interpolation ──\n\n/** Factor between two stops: linear, or exponential of `base` */\nconst factor = (x: number, x0: number, x1: number, base = 1): number => {\n const d = x1 - x0;\n\n if (d === 0) return 0;\n\n const t = x - x0;\n\n return base === 1 ? t / d : (base ** t - 1) / (base ** d - 1);\n};\n\nconst mix = (a: unknown, b: unknown, t: number): unknown => {\n if (typeof a === 'number' && typeof b === 'number') return a + (b - a) * t;\n\n const ca = color(a);\n const cb = color(b);\n\n if (ca && cb) {\n const lerp = (i: 0 | 1 | 2 | 3) => ca[i] + (cb[i] - ca[i]) * t;\n\n return css([lerp(0), lerp(1), lerp(2), lerp(3)]);\n }\n if (Array.isArray(a) && Array.isArray(b)) return a.map((v, i) => mix(v, b[i], t));\n\n return t < 0.5 ? a : b;\n};\n\n// ── Legacy functions ──\n\ninterface LegacyFunction {\n stops: [Json, Json][];\n base?: number;\n type?: string;\n property?: string;\n default?: Json;\n}\n\nconst isFunction = (v: Json): v is { [key: string]: Json } & LegacyFunction => {\n return typeof v === 'object' && v !== null && !Array.isArray(v) && Array.isArray(v.stops);\n};\n\nconst legacy = (f: LegacyFunction, ctx: Context): unknown => {\n const input = f.property === undefined ? ctx.zoom : ctx.properties[f.property];\n const stops = f.stops;\n const type =\n f.type ?? (f.property === undefined || typeof stops[0]?.[0] === 'number' ? 'exponential' : 'categorical');\n\n if (type === 'identity') return input ?? f.default;\n if (type === 'categorical') return stops.find(([k]) => k === input)?.[1] ?? f.default;\n if (typeof input !== 'number' || !stops.length) return f.default ?? stops[0]?.[1];\n\n // Zoom-and-property stops ({ zoom, value } keys) are taken at their zoom only\n const key = ([k]: [Json, Json]) => {\n if (Array.isArray(k)) return Number.NaN;\n\n return isRecord(k) ? Number(k.zoom) : Number(k);\n };\n const first = stops[0];\n\n if (!first) return f.default;\n if (input <= key(first)) return first[1];\n\n const at = stops.findIndex((s1, i) => i > 0 && Boolean(stops[i - 1]) && Boolean(s1) && input < key(s1));\n const [s0, s1] = [stops[at - 1], stops[at]];\n\n if (at < 0 || !s0 || !s1) return stops.at(-1)?.[1];\n if (type === 'interval') return s0[1];\n\n return mix(s0[1], s1[1], factor(input, key(s0), key(s1), f.base ?? 1));\n};\n\n// ── Expressions ──\n\n/** A list of values to look a value up in (any value: `includes` compares with `===`) */\nconst labels = (values: readonly Json[]): readonly unknown[] => values;\n\ntype Comparison = '<' | '<=' | '>' | '>=';\n\nconst ORDERS: Record<Comparison, (a: number | string, b: number | string) => boolean> = {\n '<': (a, b) => a < b,\n '<=': (a, b) => a <= b,\n '>': (a, b) => a > b,\n '>=': (a, b) => a >= b,\n};\n\n/** A comparison of any two values the way JavaScript's operators make it: two strings (lists and objects as their\n * text) in text order, anything else as numbers */\nconst compare = (op: Comparison, a: unknown, b: unknown): boolean => {\n const text = (v: unknown) => (typeof v === 'object' && v !== null ? String(v) : v);\n const [x, y] = [text(a), text(b)];\n\n return typeof x === 'string' && typeof y === 'string' ? ORDERS[op](x, y) : ORDERS[op](Number(x), Number(y));\n};\n\nconst get = (ctx: Context, key: unknown): unknown => {\n if (key === '$type') return ctx.type;\n\n return typeof key === 'string' ? ctx.properties[key] : undefined;\n};\n\n/** The operators `evaluate` knows */\nconst OPERATORS = new Set([\n 'literal',\n 'zoom',\n 'get',\n 'has',\n '!has',\n 'properties',\n 'id',\n 'geometry-type',\n 'concat',\n 'format',\n 'image',\n 'number-format',\n 'to-number',\n 'to-string',\n 'to-boolean',\n 'to-color',\n 'number',\n 'string',\n 'boolean',\n 'typeof',\n 'length',\n 'at',\n 'upcase',\n 'downcase',\n 'coalesce',\n '!',\n 'all',\n 'any',\n '==',\n '!=',\n '<',\n '<=',\n '>',\n '>=',\n 'in',\n 'case',\n 'match',\n 'step',\n 'interpolate',\n 'interpolate-hcl',\n 'interpolate-lab',\n 'rgb',\n 'rgba',\n '+',\n '-',\n '*',\n '/',\n '%',\n '^',\n 'min',\n 'max',\n 'abs',\n 'round',\n 'floor',\n 'ceil',\n 'sqrt',\n 'ln',\n 'log10',\n 'log2',\n 'pi',\n 'e',\n]);\n\n/** Whether a value is an expression (an array starting with a known operator), not a literal array */\nexport const isExpression = (e: unknown): e is Json[] => {\n return Array.isArray(e) && typeof e[0] === 'string' && OPERATORS.has(e[0]);\n};\n\n/** Operators already warned about */\nconst warned = new Set<string>();\n\nconst str = (v: unknown) => (v === undefined || v === null ? '' : String(v));\n\nexport const evaluate = (e: Json, ctx: Context): unknown => {\n if (isFunction(e)) return legacy(e, ctx);\n if (!Array.isArray(e)) return e;\n\n const [op, ...args] = e;\n\n if (typeof op !== 'string') return e;\n\n const ev = (i: number) => evaluate(args[i] ?? null, ctx);\n const num = (i: number) => Number(ev(i));\n const nums = () => args.map((_, i) => num(i));\n\n switch (op) {\n case 'literal':\n return args[0];\n case 'zoom':\n return ctx.zoom;\n case 'get':\n return get(ctx, ev(0));\n case 'has':\n return get(ctx, ev(0)) !== undefined;\n case '!has':\n return get(ctx, ev(0)) === undefined;\n case 'properties':\n return ctx.properties;\n case 'id':\n return null;\n case 'geometry-type':\n return ctx.type;\n case 'concat':\n return args.map((_, i) => str(ev(i))).join('');\n case 'format':\n // Its text sections, the options of each (objects) left out\n return args.map((a, i) => (a !== null && typeof a === 'object' && !Array.isArray(a) ? '' : str(ev(i)))).join('');\n case 'image':\n return ev(0);\n case 'number-format': {\n const options = isRecord(args[1]) ? args[1] : {};\n const option = (key: string) => {\n const v = options[key];\n\n return typeof v === 'number' ? v : undefined;\n };\n const n = num(0);\n\n if (!Number.isFinite(n)) return '';\n\n return n.toLocaleString(typeof options.locale === 'string' ? options.locale : undefined, {\n minimumFractionDigits: option('min-fraction-digits'),\n maximumFractionDigits: option('max-fraction-digits'),\n });\n }\n case 'to-number': {\n for (let i = 0; i < args.length; i += 1) {\n const v = ev(i);\n const n = typeof v === 'string' && v.trim() === '' ? Number.NaN : Number(v);\n\n if (v !== null && v !== undefined && !Number.isNaN(n)) return n;\n }\n\n return 0;\n }\n case 'to-string':\n return str(ev(0));\n case 'to-boolean': {\n const v = ev(0);\n\n return !(v === '' || v === 0 || v === false || v === null || v === undefined || Number.isNaN(v));\n }\n case 'to-color':\n case 'number':\n case 'string':\n case 'boolean': {\n // Assertions: the first value of the type, else the last one\n const types: Record<string, (v: unknown) => boolean> = {\n 'to-color': (v) => color(v) !== undefined,\n number: (v) => typeof v === 'number',\n string: (v) => typeof v === 'string',\n boolean: (v) => typeof v === 'boolean',\n };\n\n for (let i = 0; i < args.length; i += 1) {\n const v = ev(i);\n\n if (types[op]?.(v)) return v;\n }\n\n return args.length ? ev(args.length - 1) : null;\n }\n case 'typeof': {\n const v = ev(0);\n\n if (v === null || v === undefined) return 'null';\n\n return Array.isArray(v) ? 'array' : typeof v;\n }\n case 'length': {\n const v = ev(0);\n\n return typeof v === 'string' || Array.isArray(v) ? v.length : 0;\n }\n case 'at': {\n const v = ev(1);\n\n return Array.isArray(v) ? (v[num(0)] ?? null) : null;\n }\n case 'upcase':\n return str(ev(0)).toUpperCase();\n case 'downcase':\n return str(ev(0)).toLowerCase();\n case 'coalesce':\n for (let i = 0; i < args.length; i += 1) {\n const v = ev(i);\n\n if (v !== undefined && v !== null) return v;\n }\n\n return null;\n case '!':\n return !ev(0);\n case 'all':\n return args.every((_, i) => Boolean(ev(i)));\n case 'any':\n return args.some((_, i) => Boolean(ev(i)));\n case '==':\n return ev(0) === ev(1);\n case '!=':\n return ev(0) !== ev(1);\n case '<':\n case '<=':\n case '>':\n case '>=':\n return compare(op, ev(0), ev(1));\n case 'in': {\n const haystack = ev(1);\n const needle = ev(0);\n\n if (typeof haystack === 'string') return haystack.includes(String(needle));\n\n return Array.isArray(haystack) && haystack.includes(needle);\n }\n case 'case': {\n const hit = args.findIndex((_, i) => i % 2 === 0 && i + 1 < args.length && Boolean(ev(i)));\n\n return hit < 0 ? ev(args.length - 1) : ev(hit + 1);\n }\n case 'match': {\n const input = ev(0);\n const hit = args.findIndex(\n (label, i) =>\n i % 2 === 1 &&\n i + 1 < args.length &&\n (Array.isArray(label) ? labels(label).includes(input) : label === input),\n );\n\n return hit < 0 ? ev(args.length - 1) : ev(hit + 1);\n }\n case 'step': {\n const input = num(0);\n let out = ev(1);\n\n for (let i = 2; i + 1 < args.length; i += 2) {\n if (input >= Number(args[i])) out = ev(i + 1);\n else break;\n }\n\n return out;\n }\n case 'interpolate':\n case 'interpolate-hcl':\n case 'interpolate-lab': {\n const kind = args[0];\n const input = num(1);\n const base = Array.isArray(kind) && kind[0] === 'exponential' ? Number(kind[1]) : 1;\n const stops = Array.from({ length: Math.floor((args.length - 2) / 2) }, (_, k): [number, Json] => [\n Number(args[2 + 2 * k]),\n args[3 + 2 * k] ?? null,\n ]);\n const first = stops[0];\n\n if (!first) return null;\n if (input <= first[0]) return evaluate(first[1], ctx);\n\n const at = stops.findIndex((s1, i) => i > 0 && input < s1[0]);\n const [s0, s1] = [stops[at - 1], stops[at]];\n\n if (at < 0 || !s0 || !s1) return evaluate(stops.at(-1)?.[1] ?? null, ctx);\n\n return mix(evaluate(s0[1], ctx), evaluate(s1[1], ctx), factor(input, s0[0], s1[0], base));\n }\n case 'rgb':\n case 'rgba':\n return css([num(0) / 255, num(1) / 255, num(2) / 255, args.length > 3 ? num(3) : 1]);\n case '+':\n return nums().reduce((a, b) => a + b, 0);\n case '*':\n return nums().reduce((a, b) => a * b, 1);\n case '-':\n return args.length === 1 ? -num(0) : num(0) - num(1);\n case '/':\n return num(0) / num(1);\n case '%':\n return num(0) % num(1);\n case '^':\n return num(0) ** num(1);\n case 'min':\n return Math.min(...nums());\n case 'max':\n return Math.max(...nums());\n case 'abs':\n return Math.abs(num(0));\n case 'round':\n // Half away from zero, as MapLibre\n return Math.sign(num(0)) * Math.round(Math.abs(num(0)));\n case 'floor':\n return Math.floor(num(0));\n case 'ceil':\n return Math.ceil(num(0));\n case 'sqrt':\n return Math.sqrt(num(0));\n case 'ln':\n return Math.log(num(0));\n case 'log10':\n return Math.log10(num(0));\n case 'log2':\n return Math.log2(num(0));\n case 'pi':\n return Math.PI;\n case 'e':\n return Math.E;\n default:\n // Unsupported: no value (a filter drops the feature, a property takes its default)\n if (!warned.has(op)) {\n warned.add(op);\n console.warn(`isard: the style expression \"${op}\" is not supported`);\n }\n\n return null;\n }\n};\n\n// ── Filters ──\n\nconst LEGACY_COMPARISONS = new Set(['==', '!=', '<', '<=', '>', '>=']);\n\n/** Whether a filter (not `all`, `any`, `none`) is in the legacy form: `[\"==\", \"key\", value]`, `[\"in\", \"key\", a, b]`,\n * `[\"has\", \"key\"]`; a key and literal values, as MapLibre tells them from expressions */\nconst isLegacyLeaf = (f: Json[]): boolean => {\n const [op, a, ...rest] = f;\n\n if (typeof op !== 'string' || typeof a !== 'string' || rest.some(Array.isArray)) return false;\n if (LEGACY_COMPARISONS.has(op)) return f.length === 3;\n if (op === 'in') return f.length !== 3 || !Array.isArray(f[2]);\n\n return op === '!in' || op === 'has' || op === '!has';\n};\n\nconst legacyFilter = (f: Json[], ctx: Context): boolean => {\n const [op, key, ...rest] = f;\n const v = get(ctx, key);\n\n switch (op) {\n case '==':\n return v === rest[0];\n case '!=':\n return v !== rest[0];\n case '<':\n case '<=':\n case '>':\n case '>=':\n return compare(op, v, rest[0]);\n case 'in':\n return labels(rest).includes(v);\n case '!in':\n return !labels(rest).includes(v);\n case 'has':\n return v !== undefined;\n case '!has':\n return v === undefined;\n default:\n return true;\n }\n};\n\ntype Test = (ctx: Context) => boolean;\n\n/** Compiled filters, by filter object */\nconst compiled = new WeakMap<Json[], Test>();\n\n/** A filter as a function: `all`, `any`, `none` of their parts, each part legacy or an expression (they may mix) */\nconst compile = (f: Json): Test => {\n if (!Array.isArray(f)) return () => Boolean(f);\n\n const hit = compiled.get(f);\n\n if (hit) return hit;\n\n const make = (): Test => {\n const op = f[0];\n\n if (op === 'all' || op === 'any' || op === 'none') {\n const parts = f.slice(1).map(compile);\n\n if (op === 'all') return (ctx) => parts.every((p) => p(ctx));\n if (op === 'any') return (ctx) => parts.some((p) => p(ctx));\n\n return (ctx) => !parts.some((p) => p(ctx));\n }\n if (isLegacyLeaf(f)) return (ctx) => legacyFilter(f, ctx);\n\n return (ctx) => Boolean(evaluate(f, ctx));\n };\n const test = make();\n\n compiled.set(f, test);\n\n return test;\n};\n\nexport const filter = (f: Json | undefined, ctx: Context): boolean => {\n if (f === undefined || f === null) return true;\n\n return compile(f)(ctx);\n};\n\n/** The operators that read the feature */\nconst FEATURE_OPERATORS: ReadonlySet<unknown> = new Set(['get', 'has', '!has', 'geometry-type', 'properties', 'id']);\n\n/** Whether a value depends on the feature (else only on the zoom, evaluated once per tile) */\nexport const isFeatureDependent = (e: Json | undefined): boolean => {\n if (e !== undefined && isFunction(e)) return e.property !== undefined;\n if (!Array.isArray(e)) return false;\n if (FEATURE_OPERATORS.has(e[0])) return true;\n\n return e.some((x) => isFeatureDependent(x));\n};\n\n/** A `{token}` text field (or an expression) to the text of a feature */\nexport const text = (field: Json | undefined, ctx: Context): string => {\n if (field === undefined || field === null) return '';\n if (typeof field === 'string') {\n return field.replace(/\\{([^}]+)\\}/g, (_, key: string) => {\n const v = ctx.properties[key];\n\n return v === undefined ? '' : String(v);\n });\n }\n\n const v = evaluate(field, ctx);\n\n if (Array.isArray(v)) {\n // A `format` value: its strings\n return v.filter((x) => typeof x === 'string').join('');\n }\n\n return v === undefined || v === null ? '' : String(v);\n};\n\n/** The font of a label from the first of its `text-font`: a family without its weight takes the regular one */\nexport const labelFont = (font: string): string => {\n return /Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(font) ? font : `${font} Regular`;\n};\n\n/**\n * A value of the zoom only (an expression: `interpolate`, `step` of `[\"zoom\"]`) as stops `[[zoom, value], …]` for the\n * engine, which interpolates them linearly: evaluated at its own stops and at the whole zooms between (an exponential\n * curve followed closely), a step kept sharp just before its threshold\n */\nexport const zoomStops = (e: Json): [number, number][] => {\n const zooms = new Set<number>();\n // The inputs of the stops of an `interpolate` or a `step` (from its fourth argument, one in two)\n const stopInputs = (x: Json[]) => x.filter((_, i) => i >= 3 && i % 2 === 1).map(Number);\n const walk = (x: Json) => {\n if (!Array.isArray(x)) return;\n\n const zoomInput = (input: Json | undefined) => Array.isArray(input) && input[0] === 'zoom';\n\n if ((x[0] === 'interpolate' || x[0] === 'interpolate-hcl' || x[0] === 'interpolate-lab') && zoomInput(x[2])) {\n stopInputs(x).forEach((t) => {\n zooms.add(t);\n });\n } else if (x[0] === 'step' && zoomInput(x[1])) {\n stopInputs(x).forEach((t) => {\n zooms.add(t);\n zooms.add(t - 0.01);\n });\n }\n x.forEach(walk);\n };\n\n walk(e);\n\n const finite = [...zooms].filter(Number.isFinite);\n\n if (finite.length === 0) finite.push(0);\n\n const [lo, hi] = [Math.min(...finite), Math.max(...finite)];\n\n finite.push(...Array.from({ length: Math.floor(hi) - Math.ceil(lo) + 1 }, (_, i) => Math.ceil(lo) + i));\n\n return [...new Set(finite)]\n .sort((a, b) => a - b)\n .map((zoom) => [zoom, Number(evaluate(e, { zoom, properties: {}, type: 'Unknown' }))]);\n};\n"]}
@@ -8,14 +8,14 @@
8
8
  * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:
9
9
  * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.
10
10
  */
11
- import type { Priority } from './basemap.worker.ts';
12
- import type { Feature, Size } from './features.ts';
13
- import type { Layer, RasterLayer } from './layers.ts';
14
- import type { GeoMap } from './map.ts';
15
- import type { SymbolLayer } from './symbols.ts';
16
- import type { RasterOptions } from './types.ts';
11
+ import type { Feature, Size } from '../layers/features.ts';
12
+ import type { Layer, RasterLayer } from '../layers/layers.ts';
13
+ import type { SymbolLayer } from '../layers/symbols.ts';
14
+ import type { GeoMap } from '../map.ts';
15
+ import type { RasterOptions } from '../types.ts';
16
+ import type { Camera } from '../wasm/isard.js';
17
+ import type { Priority } from '../workers/basemap.worker.ts';
17
18
  import { type Json, type LabelCandidate, type RasterSource, type Style, type StyleLayer } from './vectorstyle.ts';
18
- import type { Camera } from './wasm/isard.js';
19
19
  /** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */
20
20
  export declare const OPENFREEMAP_STYLES: {
21
21
  readonly positron: "https://tiles.openfreemap.org/styles/positron";
@@ -49,27 +49,27 @@ export interface VectorTilesOptions {
49
49
  attribution?: string;
50
50
  }
51
51
  /** The credits of a known style: OpenFreeMap's, PLAN.IGN's */
52
- export declare function styleAttribution(style: string | Style): string | undefined;
52
+ export declare const styleAttribution: (style: string | Style) => string | undefined;
53
53
  /** Text or icon size of a style (a number, legacy stops, or the stops of a zoom expression made by the worker) as a
54
54
  * size for the symbol layer */
55
- export declare function size(value: Json, fallback?: number): Size;
55
+ export declare const size: (value: Json, fallback?: number) => Size;
56
56
  /** Default size of a basemap worker pool: cores - 1, 1 to 4 */
57
- export declare function defaultWorkerCount(): number;
57
+ export declare const defaultWorkerCount: () => number;
58
58
  /** Default URL of the basemap worker: in the page's assets folder (`isard/vite`), else next to the module */
59
- export declare function defaultWorkerUrl(assetsUrl?: string | URL): string | URL;
59
+ export declare const defaultWorkerUrl: (assetsUrl?: string | URL) => string | URL;
60
60
  /** Fetch priority of a raster tile drawn by the workers: 'high' near the center of the view, at the current zoom or
61
61
  * coarser; 'low' far from it or finer (prefetch); 'auto' between */
62
- export declare function tilePriority(z: number, x: number, y: number, camera: Pick<Camera, 'center' | 'zoom'>): Priority;
62
+ export declare const tilePriority: (z: number, x: number, y: number, camera: Pick<Camera, "center" | "zoom">) => Priority;
63
63
  /** The worker of a vector tile among `count`: always the same one */
64
- export declare function workerIndex(vz: number, vx: number, vy: number, count: number): number;
64
+ export declare const workerIndex: (vz: number, vx: number, vy: number, count: number) => number;
65
65
  /** The worker-side key of a renderer: unique across the `VectorTiles` sharing a pool */
66
- export declare function rendererKey(namespace: string, n: number): string;
66
+ export declare const rendererKey: (namespace: string, n: number) => string;
67
67
  /** What the pool needs of a worker (a `Worker`, or a stand-in in tests) */
68
68
  export type PoolWorker = Pick<Worker, 'postMessage' | 'terminate' | 'onmessage' | 'onerror' | 'onmessageerror'>;
69
69
  /** The labels of a vector tile: features by style layer (its index in the style), the higher layers first */
70
70
  type TileLabels = [layer: number, features: Feature<LabelCandidate>[]][];
71
71
  /** A tile's label candidates as features, by style layer */
72
- export declare function tileLabels(candidates: readonly LabelCandidate[]): TileLabels;
72
+ export declare const tileLabels: (candidates: readonly LabelCandidate[]) => TileLabels;
73
73
  export declare class VectorTiles {
74
74
  private readonly map;
75
75
  private readonly pool;
@@ -144,12 +144,12 @@ export declare class VectorTiles {
144
144
  * layer, the `name` of points as labels. `source` is the style's vector source (`url`: TileJSON or `pmtiles://…`, or
145
145
  * `tiles`)
146
146
  */
147
- export declare function basicStyle(source: {
147
+ export declare const basicStyle: (source: {
148
148
  url?: string;
149
149
  tiles?: string[];
150
150
  minzoom?: number;
151
151
  maxzoom?: number;
152
- }, layers: readonly string[]): Style;
152
+ }, layers: readonly string[]) => Style;
153
153
  /** Options of `GeoMap.addPmtiles` */
154
154
  export interface PmtilesOptions {
155
155
  /** What the archive holds (default from its header: raster images or vector tiles) */
@@ -165,5 +165,5 @@ export interface PmtilesOptions {
165
165
  }
166
166
  /** A raster loader reading the tiles of a `pmtiles://` archive URL (images of any size, drawn at `size`); undefined
167
167
  * for another URL */
168
- export declare function pmtilesRasterLoader(url: string, size: number): RasterOptions['loader'];
168
+ export declare const pmtilesRasterLoader: (url: string, size: number) => RasterOptions["loader"];
169
169
  export {};