ol 7.3.0 → 7.3.1-dev

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 (535) hide show
  1. package/Collection.d.ts +2 -2
  2. package/Collection.d.ts.map +1 -1
  3. package/DataTile.d.ts +1 -1
  4. package/DataTile.d.ts.map +1 -1
  5. package/DataTile.js +2 -1
  6. package/Feature.d.ts +1 -1
  7. package/Feature.d.ts.map +1 -1
  8. package/Geolocation.d.ts +2 -2
  9. package/Geolocation.d.ts.map +1 -1
  10. package/Image.d.ts +1 -1
  11. package/Image.d.ts.map +1 -1
  12. package/ImageBase.d.ts +1 -1
  13. package/ImageBase.d.ts.map +1 -1
  14. package/ImageCanvas.d.ts +1 -1
  15. package/ImageCanvas.d.ts.map +1 -1
  16. package/ImageTile.d.ts +1 -1
  17. package/ImageTile.d.ts.map +1 -1
  18. package/Map.d.ts +7 -7
  19. package/Map.d.ts.map +1 -1
  20. package/Map.js +2 -1
  21. package/MapBrowserEvent.d.ts +1 -1
  22. package/MapBrowserEvent.d.ts.map +1 -1
  23. package/MapBrowserEventHandler.d.ts +1 -1
  24. package/MapBrowserEventHandler.d.ts.map +1 -1
  25. package/MapEvent.d.ts +1 -1
  26. package/MapEvent.d.ts.map +1 -1
  27. package/Object.d.ts +2 -2
  28. package/Object.d.ts.map +1 -1
  29. package/Observable.d.ts +1 -1
  30. package/Observable.d.ts.map +1 -1
  31. package/Overlay.d.ts +1 -1
  32. package/Overlay.d.ts.map +1 -1
  33. package/Tile.d.ts +1 -1
  34. package/Tile.d.ts.map +1 -1
  35. package/TileCache.d.ts +1 -1
  36. package/TileCache.d.ts.map +1 -1
  37. package/TileQueue.d.ts +1 -1
  38. package/TileQueue.d.ts.map +1 -1
  39. package/VectorRenderTile.d.ts +1 -1
  40. package/VectorRenderTile.d.ts.map +1 -1
  41. package/VectorTile.d.ts +1 -1
  42. package/VectorTile.d.ts.map +1 -1
  43. package/View.d.ts +10 -6
  44. package/View.d.ts.map +1 -1
  45. package/View.js +9 -6
  46. package/array.d.ts.map +1 -1
  47. package/array.js +38 -20
  48. package/control/Attribution.d.ts +1 -1
  49. package/control/Attribution.d.ts.map +1 -1
  50. package/control/Control.d.ts +1 -1
  51. package/control/Control.d.ts.map +1 -1
  52. package/control/FullScreen.d.ts +1 -1
  53. package/control/FullScreen.d.ts.map +1 -1
  54. package/control/MousePosition.d.ts +1 -1
  55. package/control/MousePosition.d.ts.map +1 -1
  56. package/control/OverviewMap.d.ts +3 -3
  57. package/control/OverviewMap.d.ts.map +1 -1
  58. package/control/Rotate.d.ts +1 -1
  59. package/control/Rotate.d.ts.map +1 -1
  60. package/control/ScaleLine.d.ts +1 -1
  61. package/control/ScaleLine.d.ts.map +1 -1
  62. package/control/Zoom.d.ts +1 -1
  63. package/control/Zoom.d.ts.map +1 -1
  64. package/control/ZoomSlider.d.ts +1 -1
  65. package/control/ZoomSlider.d.ts.map +1 -1
  66. package/control/ZoomToExtent.d.ts +1 -1
  67. package/control/ZoomToExtent.d.ts.map +1 -1
  68. package/control/defaults.d.ts +1 -1
  69. package/control/defaults.d.ts.map +1 -1
  70. package/dist/ol.js +2 -2
  71. package/dist/ol.js.map +1 -1
  72. package/events/Key.d.ts +8 -0
  73. package/events/Key.d.ts.map +1 -0
  74. package/events/Key.js +14 -0
  75. package/events/Target.d.ts +1 -1
  76. package/events/Target.d.ts.map +1 -1
  77. package/events/condition.d.ts +2 -2
  78. package/events/condition.d.ts.map +1 -1
  79. package/extent.d.ts.map +1 -1
  80. package/extent.js +7 -2
  81. package/format/EsriJSON.d.ts +1 -1
  82. package/format/EsriJSON.d.ts.map +1 -1
  83. package/format/GML.d.ts +1 -1
  84. package/format/GML.d.ts.map +1 -1
  85. package/format/GML2.d.ts +1 -1
  86. package/format/GML2.d.ts.map +1 -1
  87. package/format/GML3.d.ts +5 -5
  88. package/format/GML3.d.ts.map +1 -1
  89. package/format/GML32.d.ts +1 -1
  90. package/format/GML32.d.ts.map +1 -1
  91. package/format/GMLBase.d.ts +9 -9
  92. package/format/GMLBase.d.ts.map +1 -1
  93. package/format/GPX.d.ts +2 -2
  94. package/format/GPX.d.ts.map +1 -1
  95. package/format/GeoJSON.d.ts +1 -1
  96. package/format/GeoJSON.d.ts.map +1 -1
  97. package/format/IGC.d.ts +1 -1
  98. package/format/IGC.d.ts.map +1 -1
  99. package/format/IIIFInfo.d.ts +8 -8
  100. package/format/IIIFInfo.d.ts.map +1 -1
  101. package/format/IIIFInfo.js +10 -9
  102. package/format/JSONFeature.d.ts +1 -1
  103. package/format/JSONFeature.d.ts.map +1 -1
  104. package/format/JSONFeature.js +2 -1
  105. package/format/KML.d.ts +121 -5
  106. package/format/KML.d.ts.map +1 -1
  107. package/format/KML.js +105 -7
  108. package/format/MVT.d.ts +2 -2
  109. package/format/MVT.d.ts.map +1 -1
  110. package/format/OSMXML.d.ts +1 -1
  111. package/format/OSMXML.d.ts.map +1 -1
  112. package/format/OSMXML.js +11 -4
  113. package/format/OWS.d.ts +1 -1
  114. package/format/OWS.d.ts.map +1 -1
  115. package/format/Polyline.d.ts +2 -2
  116. package/format/Polyline.d.ts.map +1 -1
  117. package/format/TextFeature.d.ts +1 -1
  118. package/format/TextFeature.d.ts.map +1 -1
  119. package/format/TopoJSON.d.ts +1 -1
  120. package/format/TopoJSON.d.ts.map +1 -1
  121. package/format/WFS.d.ts +2 -2
  122. package/format/WFS.d.ts.map +1 -1
  123. package/format/WFS.js +8 -4
  124. package/format/WKB.d.ts +1 -1
  125. package/format/WKB.d.ts.map +1 -1
  126. package/format/WKB.js +6 -4
  127. package/format/WKT.d.ts +1 -1
  128. package/format/WKT.d.ts.map +1 -1
  129. package/format/WMSCapabilities.d.ts +1 -1
  130. package/format/WMSCapabilities.d.ts.map +1 -1
  131. package/format/WMSGetFeatureInfo.d.ts +1 -1
  132. package/format/WMSGetFeatureInfo.d.ts.map +1 -1
  133. package/format/WMTSCapabilities.d.ts +1 -1
  134. package/format/WMTSCapabilities.d.ts.map +1 -1
  135. package/format/XML.d.ts.map +1 -1
  136. package/format/XML.js +4 -2
  137. package/format/XMLFeature.d.ts +1 -1
  138. package/format/XMLFeature.d.ts.map +1 -1
  139. package/format/XMLFeature.js +16 -8
  140. package/format/filter/And.d.ts +1 -1
  141. package/format/filter/And.d.ts.map +1 -1
  142. package/format/filter/Bbox.d.ts +1 -1
  143. package/format/filter/Bbox.d.ts.map +1 -1
  144. package/format/filter/Comparison.d.ts +1 -1
  145. package/format/filter/Comparison.d.ts.map +1 -1
  146. package/format/filter/ComparisonBinary.d.ts +1 -1
  147. package/format/filter/ComparisonBinary.d.ts.map +1 -1
  148. package/format/filter/Contains.d.ts +1 -1
  149. package/format/filter/Contains.d.ts.map +1 -1
  150. package/format/filter/DWithin.d.ts +1 -1
  151. package/format/filter/DWithin.d.ts.map +1 -1
  152. package/format/filter/Disjoint.d.ts +1 -1
  153. package/format/filter/Disjoint.d.ts.map +1 -1
  154. package/format/filter/During.d.ts +1 -1
  155. package/format/filter/During.d.ts.map +1 -1
  156. package/format/filter/EqualTo.d.ts +1 -1
  157. package/format/filter/EqualTo.d.ts.map +1 -1
  158. package/format/filter/GreaterThan.d.ts +1 -1
  159. package/format/filter/GreaterThan.d.ts.map +1 -1
  160. package/format/filter/GreaterThanOrEqualTo.d.ts +1 -1
  161. package/format/filter/GreaterThanOrEqualTo.d.ts.map +1 -1
  162. package/format/filter/Intersects.d.ts +1 -1
  163. package/format/filter/Intersects.d.ts.map +1 -1
  164. package/format/filter/IsBetween.d.ts +1 -1
  165. package/format/filter/IsBetween.d.ts.map +1 -1
  166. package/format/filter/IsLike.d.ts +1 -1
  167. package/format/filter/IsLike.d.ts.map +1 -1
  168. package/format/filter/IsNull.d.ts +1 -1
  169. package/format/filter/IsNull.d.ts.map +1 -1
  170. package/format/filter/LessThan.d.ts +1 -1
  171. package/format/filter/LessThan.d.ts.map +1 -1
  172. package/format/filter/LessThanOrEqualTo.d.ts +1 -1
  173. package/format/filter/LessThanOrEqualTo.d.ts.map +1 -1
  174. package/format/filter/LogicalNary.d.ts +1 -1
  175. package/format/filter/LogicalNary.d.ts.map +1 -1
  176. package/format/filter/Not.d.ts +1 -1
  177. package/format/filter/Not.d.ts.map +1 -1
  178. package/format/filter/NotEqualTo.d.ts +1 -1
  179. package/format/filter/NotEqualTo.d.ts.map +1 -1
  180. package/format/filter/Or.d.ts +2 -2
  181. package/format/filter/Or.d.ts.map +1 -1
  182. package/format/filter/Or.js +1 -1
  183. package/format/filter/ResourceId.d.ts +1 -1
  184. package/format/filter/ResourceId.d.ts.map +1 -1
  185. package/format/filter/Spatial.d.ts +1 -1
  186. package/format/filter/Spatial.d.ts.map +1 -1
  187. package/format/filter/Within.d.ts +1 -1
  188. package/format/filter/Within.d.ts.map +1 -1
  189. package/format/filter.d.ts +20 -20
  190. package/format/filter.d.ts.map +1 -1
  191. package/geom/Circle.d.ts +1 -1
  192. package/geom/Circle.d.ts.map +1 -1
  193. package/geom/Circle.js +1 -17
  194. package/geom/Geometry.d.ts +1 -1
  195. package/geom/Geometry.d.ts.map +1 -1
  196. package/geom/GeometryCollection.d.ts +1 -1
  197. package/geom/GeometryCollection.d.ts.map +1 -1
  198. package/geom/LineString.d.ts +1 -1
  199. package/geom/LineString.d.ts.map +1 -1
  200. package/geom/LinearRing.d.ts +1 -1
  201. package/geom/LinearRing.d.ts.map +1 -1
  202. package/geom/MultiLineString.d.ts +2 -2
  203. package/geom/MultiLineString.d.ts.map +1 -1
  204. package/geom/MultiPoint.d.ts +2 -2
  205. package/geom/MultiPoint.d.ts.map +1 -1
  206. package/geom/MultiPolygon.d.ts +3 -3
  207. package/geom/MultiPolygon.d.ts.map +1 -1
  208. package/geom/Point.d.ts +1 -1
  209. package/geom/Point.d.ts.map +1 -1
  210. package/geom/Polygon.d.ts +3 -3
  211. package/geom/Polygon.d.ts.map +1 -1
  212. package/geom/SimpleGeometry.d.ts +1 -1
  213. package/geom/SimpleGeometry.d.ts.map +1 -1
  214. package/geom/flat/interpolate.d.ts.map +1 -1
  215. package/geom/flat/interpolate.js +4 -2
  216. package/geom/flat/orient.d.ts +1 -1
  217. package/geom/flat/orient.js +1 -1
  218. package/interaction/DblClickDragZoom.d.ts +110 -0
  219. package/interaction/DblClickDragZoom.d.ts.map +1 -0
  220. package/interaction/DblClickDragZoom.js +251 -0
  221. package/interaction/DoubleClickZoom.d.ts +1 -1
  222. package/interaction/DoubleClickZoom.d.ts.map +1 -1
  223. package/interaction/DragAndDrop.d.ts +2 -2
  224. package/interaction/DragAndDrop.d.ts.map +1 -1
  225. package/interaction/DragBox.d.ts +2 -2
  226. package/interaction/DragBox.d.ts.map +1 -1
  227. package/interaction/DragPan.d.ts +1 -1
  228. package/interaction/DragPan.d.ts.map +1 -1
  229. package/interaction/DragRotate.d.ts +1 -1
  230. package/interaction/DragRotate.d.ts.map +1 -1
  231. package/interaction/DragRotateAndZoom.d.ts +1 -1
  232. package/interaction/DragRotateAndZoom.d.ts.map +1 -1
  233. package/interaction/DragZoom.d.ts +1 -1
  234. package/interaction/DragZoom.d.ts.map +1 -1
  235. package/interaction/Draw.d.ts +6 -6
  236. package/interaction/Draw.d.ts.map +1 -1
  237. package/interaction/Extent.d.ts +2 -2
  238. package/interaction/Extent.d.ts.map +1 -1
  239. package/interaction/Extent.js +2 -1
  240. package/interaction/Interaction.d.ts +1 -1
  241. package/interaction/Interaction.d.ts.map +1 -1
  242. package/interaction/KeyboardPan.d.ts +1 -1
  243. package/interaction/KeyboardPan.d.ts.map +1 -1
  244. package/interaction/KeyboardPan.js +9 -9
  245. package/interaction/KeyboardZoom.d.ts +1 -1
  246. package/interaction/KeyboardZoom.d.ts.map +1 -1
  247. package/interaction/Link.d.ts +1 -1
  248. package/interaction/Link.d.ts.map +1 -1
  249. package/interaction/Modify.d.ts +6 -6
  250. package/interaction/Modify.d.ts.map +1 -1
  251. package/interaction/Modify.js +6 -1
  252. package/interaction/MouseWheelZoom.d.ts +1 -1
  253. package/interaction/MouseWheelZoom.d.ts.map +1 -1
  254. package/interaction/PinchRotate.d.ts +1 -1
  255. package/interaction/PinchRotate.d.ts.map +1 -1
  256. package/interaction/PinchZoom.d.ts +1 -1
  257. package/interaction/PinchZoom.d.ts.map +1 -1
  258. package/interaction/Pointer.d.ts +1 -1
  259. package/interaction/Pointer.d.ts.map +1 -1
  260. package/interaction/Select.d.ts +5 -5
  261. package/interaction/Select.d.ts.map +1 -1
  262. package/interaction/Snap.d.ts +1 -1
  263. package/interaction/Snap.d.ts.map +1 -1
  264. package/interaction/Snap.js +10 -4
  265. package/interaction/Translate.d.ts +4 -4
  266. package/interaction/Translate.d.ts.map +1 -1
  267. package/interaction/Translate.js +18 -3
  268. package/interaction/defaults.d.ts +1 -1
  269. package/interaction/defaults.d.ts.map +1 -1
  270. package/interaction.d.ts +1 -0
  271. package/interaction.js +1 -0
  272. package/layer/Base.d.ts +4 -3
  273. package/layer/Base.d.ts.map +1 -1
  274. package/layer/Base.js +3 -2
  275. package/layer/BaseImage.d.ts +1 -1
  276. package/layer/BaseImage.d.ts.map +1 -1
  277. package/layer/BaseTile.d.ts +1 -1
  278. package/layer/BaseTile.d.ts.map +1 -1
  279. package/layer/BaseVector.d.ts +10 -4
  280. package/layer/BaseVector.d.ts.map +1 -1
  281. package/layer/BaseVector.js +9 -3
  282. package/layer/Graticule.d.ts +6 -6
  283. package/layer/Graticule.d.ts.map +1 -1
  284. package/layer/Group.d.ts +4 -4
  285. package/layer/Group.d.ts.map +1 -1
  286. package/layer/Heatmap.d.ts +2 -2
  287. package/layer/Heatmap.d.ts.map +1 -1
  288. package/layer/Image.d.ts +2 -2
  289. package/layer/Image.d.ts.map +1 -1
  290. package/layer/Layer.d.ts +14 -11
  291. package/layer/Layer.d.ts.map +1 -1
  292. package/layer/Layer.js +28 -8
  293. package/layer/MapboxVector.d.ts +1 -1
  294. package/layer/MapboxVector.d.ts.map +1 -1
  295. package/layer/Tile.d.ts +2 -2
  296. package/layer/Tile.d.ts.map +1 -1
  297. package/layer/Vector.d.ts +2 -2
  298. package/layer/Vector.d.ts.map +1 -1
  299. package/layer/VectorImage.d.ts +2 -2
  300. package/layer/VectorImage.d.ts.map +1 -1
  301. package/layer/VectorTile.d.ts +2 -2
  302. package/layer/VectorTile.d.ts.map +1 -1
  303. package/layer/WebGLPoints.d.ts +4 -4
  304. package/layer/WebGLPoints.d.ts.map +1 -1
  305. package/layer/WebGLPoints.js +13 -4
  306. package/layer/WebGLTile.d.ts +9 -2
  307. package/layer/WebGLTile.d.ts.map +1 -1
  308. package/layer/WebGLTile.js +6 -6
  309. package/package.json +2 -2
  310. package/proj/proj4.d.ts +2 -2
  311. package/proj/proj4.d.ts.map +1 -1
  312. package/proj/proj4.js +1 -1
  313. package/proj.d.ts +9 -9
  314. package/proj.d.ts.map +1 -1
  315. package/proj.js +9 -8
  316. package/render/Box.d.ts +1 -1
  317. package/render/Box.d.ts.map +1 -1
  318. package/render/Event.d.ts +1 -1
  319. package/render/Event.d.ts.map +1 -1
  320. package/render/Feature.d.ts +7 -7
  321. package/render/Feature.d.ts.map +1 -1
  322. package/render/canvas/Builder.d.ts +1 -1
  323. package/render/canvas/Builder.d.ts.map +1 -1
  324. package/render/canvas/ImageBuilder.d.ts +1 -1
  325. package/render/canvas/ImageBuilder.d.ts.map +1 -1
  326. package/render/canvas/Immediate.d.ts +1 -1
  327. package/render/canvas/Immediate.d.ts.map +1 -1
  328. package/render/canvas/Immediate.js +9 -1
  329. package/render/canvas/LineStringBuilder.d.ts +1 -1
  330. package/render/canvas/LineStringBuilder.d.ts.map +1 -1
  331. package/render/canvas/PolygonBuilder.d.ts +1 -1
  332. package/render/canvas/PolygonBuilder.d.ts.map +1 -1
  333. package/render/canvas/TextBuilder.d.ts +1 -1
  334. package/render/canvas/TextBuilder.d.ts.map +1 -1
  335. package/render/canvas.d.ts +1 -1
  336. package/render/canvas.d.ts.map +1 -1
  337. package/render/webgl/MixedGeometryBatch.d.ts +37 -131
  338. package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
  339. package/render/webgl/MixedGeometryBatch.js +230 -147
  340. package/render/webgl/VectorStyleRenderer.d.ts +256 -0
  341. package/render/webgl/VectorStyleRenderer.d.ts.map +1 -0
  342. package/render/webgl/VectorStyleRenderer.js +440 -0
  343. package/render/webgl/constants.d.ts +1 -1
  344. package/render/webgl/constants.js +1 -1
  345. package/render/webgl/renderinstructions.d.ts +36 -0
  346. package/render/webgl/renderinstructions.d.ts.map +1 -0
  347. package/render/webgl/renderinstructions.js +241 -0
  348. package/render/webgl/utils.d.ts +4 -4
  349. package/render/webgl/utils.d.ts.map +1 -1
  350. package/render/webgl/utils.js +9 -9
  351. package/render.d.ts +1 -1
  352. package/render.d.ts.map +1 -1
  353. package/renderer/Composite.d.ts +1 -1
  354. package/renderer/Composite.d.ts.map +1 -1
  355. package/renderer/Layer.d.ts +1 -1
  356. package/renderer/Layer.d.ts.map +1 -1
  357. package/renderer/Map.d.ts +1 -1
  358. package/renderer/Map.d.ts.map +1 -1
  359. package/renderer/canvas/ImageLayer.d.ts +1 -1
  360. package/renderer/canvas/ImageLayer.d.ts.map +1 -1
  361. package/renderer/canvas/Layer.d.ts +1 -1
  362. package/renderer/canvas/Layer.d.ts.map +1 -1
  363. package/renderer/canvas/TileLayer.d.ts +1 -1
  364. package/renderer/canvas/TileLayer.d.ts.map +1 -1
  365. package/renderer/canvas/VectorImageLayer.d.ts +1 -1
  366. package/renderer/canvas/VectorImageLayer.d.ts.map +1 -1
  367. package/renderer/canvas/VectorLayer.d.ts +3 -3
  368. package/renderer/canvas/VectorLayer.d.ts.map +1 -1
  369. package/renderer/canvas/VectorTileLayer.d.ts +2 -2
  370. package/renderer/canvas/VectorTileLayer.d.ts.map +1 -1
  371. package/renderer/webgl/Layer.d.ts +2 -2
  372. package/renderer/webgl/Layer.d.ts.map +1 -1
  373. package/renderer/webgl/PointsLayer.d.ts +3 -3
  374. package/renderer/webgl/PointsLayer.d.ts.map +1 -1
  375. package/renderer/webgl/PointsLayer.js +5 -8
  376. package/renderer/webgl/TileLayer.d.ts +32 -99
  377. package/renderer/webgl/TileLayer.d.ts.map +1 -1
  378. package/renderer/webgl/TileLayer.js +103 -644
  379. package/renderer/webgl/TileLayerBase.d.ts +194 -0
  380. package/renderer/webgl/TileLayerBase.d.ts.map +1 -0
  381. package/renderer/webgl/TileLayerBase.js +750 -0
  382. package/renderer/webgl/VectorLayer.d.ts +59 -60
  383. package/renderer/webgl/VectorLayer.d.ts.map +1 -1
  384. package/renderer/webgl/VectorLayer.js +118 -156
  385. package/renderer/webgl/VectorTileLayer.d.ts +87 -0
  386. package/renderer/webgl/VectorTileLayer.d.ts.map +1 -0
  387. package/renderer/webgl/VectorTileLayer.js +201 -0
  388. package/reproj/DataTile.d.ts +1 -1
  389. package/reproj/DataTile.d.ts.map +1 -1
  390. package/reproj/Image.d.ts +1 -1
  391. package/reproj/Image.d.ts.map +1 -1
  392. package/reproj/Image.js +22 -8
  393. package/reproj/Tile.d.ts +1 -1
  394. package/reproj/Tile.d.ts.map +1 -1
  395. package/reproj/Triangulation.js +2 -2
  396. package/source/BingMaps.d.ts +1 -1
  397. package/source/BingMaps.d.ts.map +1 -1
  398. package/source/CartoDB.d.ts +1 -1
  399. package/source/CartoDB.d.ts.map +1 -1
  400. package/source/Cluster.d.ts +3 -3
  401. package/source/Cluster.d.ts.map +1 -1
  402. package/source/DataTile.d.ts +4 -4
  403. package/source/DataTile.d.ts.map +1 -1
  404. package/source/DataTile.js +1 -1
  405. package/source/GeoTIFF.d.ts +1 -1
  406. package/source/GeoTIFF.d.ts.map +1 -1
  407. package/source/IIIF.d.ts +1 -1
  408. package/source/IIIF.d.ts.map +1 -1
  409. package/source/Image.d.ts +2 -2
  410. package/source/Image.d.ts.map +1 -1
  411. package/source/ImageArcGISRest.d.ts +1 -1
  412. package/source/ImageArcGISRest.d.ts.map +1 -1
  413. package/source/ImageCanvas.d.ts +1 -1
  414. package/source/ImageCanvas.d.ts.map +1 -1
  415. package/source/ImageMapGuide.d.ts +1 -1
  416. package/source/ImageMapGuide.d.ts.map +1 -1
  417. package/source/ImageStatic.d.ts +1 -1
  418. package/source/ImageStatic.d.ts.map +1 -1
  419. package/source/ImageWMS.d.ts +1 -1
  420. package/source/ImageWMS.d.ts.map +1 -1
  421. package/source/OGCMapTile.d.ts +1 -1
  422. package/source/OGCMapTile.d.ts.map +1 -1
  423. package/source/OGCVectorTile.d.ts +1 -1
  424. package/source/OGCVectorTile.d.ts.map +1 -1
  425. package/source/OSM.d.ts +1 -1
  426. package/source/OSM.d.ts.map +1 -1
  427. package/source/Raster.d.ts +3 -3
  428. package/source/Raster.d.ts.map +1 -1
  429. package/source/Source.d.ts +5 -5
  430. package/source/Source.d.ts.map +1 -1
  431. package/source/Source.js +2 -2
  432. package/source/Stamen.d.ts +1 -1
  433. package/source/Stamen.d.ts.map +1 -1
  434. package/source/Tile.d.ts +2 -2
  435. package/source/Tile.d.ts.map +1 -1
  436. package/source/TileArcGISRest.d.ts +1 -1
  437. package/source/TileArcGISRest.d.ts.map +1 -1
  438. package/source/TileDebug.d.ts +1 -1
  439. package/source/TileDebug.d.ts.map +1 -1
  440. package/source/TileImage.d.ts +4 -4
  441. package/source/TileImage.d.ts.map +1 -1
  442. package/source/TileJSON.d.ts +1 -1
  443. package/source/TileJSON.d.ts.map +1 -1
  444. package/source/TileWMS.d.ts +1 -1
  445. package/source/TileWMS.d.ts.map +1 -1
  446. package/source/UTFGrid.d.ts +2 -2
  447. package/source/UTFGrid.d.ts.map +1 -1
  448. package/source/UrlTile.d.ts +1 -1
  449. package/source/UrlTile.d.ts.map +1 -1
  450. package/source/Vector.d.ts +3 -3
  451. package/source/Vector.d.ts.map +1 -1
  452. package/source/Vector.js +6 -3
  453. package/source/VectorTile.d.ts +4 -4
  454. package/source/VectorTile.d.ts.map +1 -1
  455. package/source/WMTS.d.ts +1 -1
  456. package/source/WMTS.d.ts.map +1 -1
  457. package/source/XYZ.d.ts +1 -1
  458. package/source/XYZ.d.ts.map +1 -1
  459. package/source/Zoomify.d.ts +2 -2
  460. package/source/Zoomify.d.ts.map +1 -1
  461. package/structs/LRUCache.d.ts.map +1 -1
  462. package/structs/LRUCache.js +2 -1
  463. package/style/Circle.d.ts +1 -1
  464. package/style/Circle.d.ts.map +1 -1
  465. package/style/Icon.d.ts +4 -78
  466. package/style/Icon.d.ts.map +1 -1
  467. package/style/Icon.js +89 -86
  468. package/style/IconImage.d.ts +1 -1
  469. package/style/IconImage.d.ts.map +1 -1
  470. package/style/RegularShape.d.ts +1 -1
  471. package/style/RegularShape.d.ts.map +1 -1
  472. package/style/RegularShape.js +1 -1
  473. package/style/Style.d.ts +2 -2
  474. package/style/Style.d.ts.map +1 -1
  475. package/style/Text.d.ts +5 -5
  476. package/style/Text.d.ts.map +1 -1
  477. package/style/Text.js +2 -2
  478. package/style/expressions.d.ts +42 -17
  479. package/style/expressions.d.ts.map +1 -1
  480. package/style/expressions.js +258 -118
  481. package/style/flat.d.ts +14 -0
  482. package/style/flat.d.ts.map +1 -1
  483. package/style/flat.js +6 -0
  484. package/style/literal.d.ts +204 -3
  485. package/style/literal.d.ts.map +1 -1
  486. package/style/literal.js +106 -3
  487. package/tilegrid/TileGrid.d.ts +1 -9
  488. package/tilegrid/TileGrid.d.ts.map +1 -1
  489. package/tilegrid/TileGrid.js +0 -18
  490. package/tilegrid/WMTS.d.ts +1 -1
  491. package/tilegrid/WMTS.d.ts.map +1 -1
  492. package/tilegrid.d.ts +1 -1
  493. package/tilegrid.d.ts.map +1 -1
  494. package/util.d.ts.map +1 -1
  495. package/util.js +1 -1
  496. package/webgl/BaseTileRepresentation.d.ts +72 -0
  497. package/webgl/BaseTileRepresentation.d.ts.map +1 -0
  498. package/webgl/BaseTileRepresentation.js +108 -0
  499. package/webgl/Buffer.d.ts +9 -6
  500. package/webgl/Buffer.d.ts.map +1 -1
  501. package/webgl/Buffer.js +6 -0
  502. package/webgl/Helper.d.ts +19 -12
  503. package/webgl/Helper.d.ts.map +1 -1
  504. package/webgl/Helper.js +79 -71
  505. package/webgl/ShaderBuilder.d.ts +75 -65
  506. package/webgl/ShaderBuilder.d.ts.map +1 -1
  507. package/webgl/ShaderBuilder.js +382 -241
  508. package/webgl/TileGeometry.d.ts +29 -0
  509. package/webgl/TileGeometry.d.ts.map +1 -0
  510. package/webgl/TileGeometry.js +73 -0
  511. package/webgl/TileTexture.d.ts +8 -51
  512. package/webgl/TileTexture.d.ts.map +1 -1
  513. package/webgl/TileTexture.js +11 -62
  514. package/webgl/styleparser.d.ts +61 -0
  515. package/webgl/styleparser.d.ts.map +1 -0
  516. package/webgl/styleparser.js +406 -0
  517. package/worker/webgl.js +1 -1
  518. package/events/KeyCode.d.ts +0 -8
  519. package/events/KeyCode.d.ts.map +0 -1
  520. package/events/KeyCode.js +0 -14
  521. package/render/webgl/BatchRenderer.d.ts +0 -92
  522. package/render/webgl/BatchRenderer.d.ts.map +0 -1
  523. package/render/webgl/BatchRenderer.js +0 -200
  524. package/render/webgl/LineStringBatchRenderer.d.ts +0 -27
  525. package/render/webgl/LineStringBatchRenderer.d.ts.map +0 -1
  526. package/render/webgl/LineStringBatchRenderer.js +0 -114
  527. package/render/webgl/PointBatchRenderer.d.ts +0 -26
  528. package/render/webgl/PointBatchRenderer.d.ts.map +0 -1
  529. package/render/webgl/PointBatchRenderer.js +0 -95
  530. package/render/webgl/PolygonBatchRenderer.d.ts +0 -25
  531. package/render/webgl/PolygonBatchRenderer.d.ts.map +0 -1
  532. package/render/webgl/PolygonBatchRenderer.js +0 -115
  533. package/renderer/webgl/shaders.d.ts +0 -43
  534. package/renderer/webgl/shaders.d.ts.map +0 -1
  535. package/renderer/webgl/shaders.js +0 -198
@@ -21,15 +21,16 @@ import {asArray, fromString, isStringColor} from '../color.js';
21
21
  * of bands, depending on the underlying data source and
22
22
  * {@link import("../source/GeoTIFF.js").Options configuration}. `xOffset` and `yOffset` are optional
23
23
  * and allow specifying pixel offsets for x and y. This is used for sampling data from neighboring pixels.
24
- * * `['get', 'attributeName']` fetches a feature attribute (it will be prefixed by `a_` in the shader)
25
- * Note: those will be taken from the attributes provided to the renderer
24
+ * * `['get', 'attributeName', typeHint]` fetches a feature property value, similar to `feature.get('attributeName')`
25
+ * A type hint can optionally be specified, in case the resulting expression contains a type ambiguity which
26
+ * will make it invalid. Type hints can be one of: 'string', 'color', 'number', 'boolean', 'number[]'
26
27
  * * `['resolution']` returns the current resolution
27
28
  * * `['time']` returns the time in seconds since the creation of the layer
28
- * * `['var', 'varName']` fetches a value from the style variables, or 0 if undefined
29
+ * * `['var', 'varName']` fetches a value from the style variables; will throw an error if that variable is undefined
29
30
  * * `['zoom']` returns the current zoom level
30
31
  *
31
32
  * * Math operators:
32
- * * `['*', value1, value2]` multiplies `value1` by `value2`
33
+ * * `['*', value1, value2]` multiplies `value1` by `value2` (either numbers or colors)
33
34
  * * `['/', value1, value2]` divides `value1` by `value2`
34
35
  * * `['+', value1, value2]` adds `value1` and `value2`
35
36
  * * `['-', value1, value2]` subtracts `value2` from `value1`
@@ -90,6 +91,7 @@ import {asArray, fromString, isStringColor} from '../color.js';
90
91
  * Literal values can be of the following types:
91
92
  * * `boolean`
92
93
  * * `number`
94
+ * * `number[]` (number arrays can only have a length of 2, 3 or 4)
93
95
  * * `string`
94
96
  * * {@link module:ol/color~Color}
95
97
  *
@@ -112,14 +114,36 @@ export const ValueTypes = {
112
114
  NONE: 0,
113
115
  };
114
116
 
117
+ /**
118
+ * @param {string} typeHint Type hint
119
+ * @return {ValueTypes} Resulting value type (will be a single type)
120
+ */
121
+ function getTypeFromHint(typeHint) {
122
+ switch (typeHint) {
123
+ case 'string':
124
+ return ValueTypes.STRING;
125
+ case 'color':
126
+ return ValueTypes.COLOR;
127
+ case 'number':
128
+ return ValueTypes.NUMBER;
129
+ case 'boolean':
130
+ return ValueTypes.BOOLEAN;
131
+ case 'number[]':
132
+ return ValueTypes.NUMBER_ARRAY;
133
+ default:
134
+ throw new Error(`Unrecognized type hint: ${typeHint}`);
135
+ }
136
+ }
137
+
115
138
  /**
116
139
  * An operator declaration must contain two methods: `getReturnType` which returns a type based on
117
140
  * the operator arguments, and `toGlsl` which returns a GLSL-compatible string.
118
141
  * Note: both methods can process arguments recursively.
119
142
  * @typedef {Object} Operator
120
143
  * @property {function(Array<ExpressionValue>): ValueTypes|number} getReturnType Returns one or several types
121
- * @property {function(ParsingContext, Array<ExpressionValue>, ValueTypes=): string} toGlsl Returns a GLSL-compatible string
122
- * Note: takes in an optional type hint as 3rd parameter
144
+ * @property {function(ParsingContext, Array<ExpressionValue>, ValueTypes): string} toGlsl Returns a GLSL-compatible string
145
+ * given a parsing context, an array of arguments and an expected type.
146
+ * Note: the expected type can be a combination such as ValueTypes.NUMBER | ValueTypes.STRING or ValueTypes.ANY for instance
123
147
  */
124
148
 
125
149
  /**
@@ -185,16 +209,48 @@ export function isTypeUnique(valueType) {
185
209
  return Math.log2(valueType) % 1 === 0;
186
210
  }
187
211
 
212
+ /**
213
+ * Print types as a readable string
214
+ * @param {ValueTypes|number} valueType Number containing value type binary flags
215
+ * @return {string} Types
216
+ */
217
+ function printTypes(valueType) {
218
+ const result = [];
219
+ if ((valueType & ValueTypes.NUMBER) > 0) {
220
+ result.push('number');
221
+ }
222
+ if ((valueType & ValueTypes.COLOR) > 0) {
223
+ result.push('color');
224
+ }
225
+ if ((valueType & ValueTypes.BOOLEAN) > 0) {
226
+ result.push('boolean');
227
+ }
228
+ if ((valueType & ValueTypes.NUMBER_ARRAY) > 0) {
229
+ result.push('number[]');
230
+ }
231
+ if ((valueType & ValueTypes.STRING) > 0) {
232
+ result.push('string');
233
+ }
234
+ return result.length > 0 ? result.join(', ') : '(no type)';
235
+ }
236
+
237
+ /**
238
+ * @typedef {Object} ParsingContextExternal
239
+ * @property {string} name Name, unprefixed
240
+ * @property {ValueTypes} type One of the value types constants
241
+ */
242
+
188
243
  /**
189
244
  * Context available during the parsing of an expression.
190
245
  * @typedef {Object} ParsingContext
191
246
  * @property {boolean} [inFragmentShader] If false, means the expression output should be made for a vertex shader
192
- * @property {Array<string>} variables List of variables used in the expression; contains **unprefixed names**
193
- * @property {Array<string>} attributes List of attributes used in the expression; contains **unprefixed names**
247
+ * @property {Array<ParsingContextExternal>} variables External variables used in the expression
248
+ * @property {Array<ParsingContextExternal>} attributes External attributes used in the expression
194
249
  * @property {Object<string, number>} stringLiteralsMap This object maps all encountered string values to a number
195
250
  * @property {Object<string, string>} functions Lookup of functions used by the style.
196
251
  * @property {number} [bandCount] Number of bands per pixel.
197
252
  * @property {Array<PaletteTexture>} [paletteTextures] List of palettes used by the style.
253
+ * @property {import("../style/literal").LiteralStyle} style The style being parsed
198
254
  */
199
255
 
200
256
  /**
@@ -229,15 +285,15 @@ export function arrayToGlsl(array) {
229
285
  * @return {string} The color expressed in the `vec4(1.0, 1.0, 1.0, 1.0)` form.
230
286
  */
231
287
  export function colorToGlsl(color) {
232
- const array = asArray(color).slice();
233
- if (array.length < 4) {
234
- array.push(1);
235
- }
236
- return arrayToGlsl(
237
- array.map(function (c, i) {
238
- return i < 3 ? c / 255 : c;
239
- })
240
- );
288
+ const array = asArray(color);
289
+ const alpha = array.length > 3 ? array[3] : 1;
290
+ // all components are premultiplied with alpha value
291
+ return arrayToGlsl([
292
+ (array[0] / 255) * alpha,
293
+ (array[1] / 255) * alpha,
294
+ (array[2] / 255) * alpha,
295
+ alpha,
296
+ ]);
241
297
  }
242
298
 
243
299
  /**
@@ -271,10 +327,13 @@ export function stringToGlsl(context, string) {
271
327
  * will be read and modified during the parsing operation.
272
328
  * @param {ParsingContext} context Parsing context
273
329
  * @param {ExpressionValue} value Value
274
- * @param {ValueTypes|number} [typeHint] Hint for the expected final type (can be several types combined)
330
+ * @param {ValueTypes|number} [expectedType] Expected final type (can be several types combined)
331
+ * If omitted, defaults to ValueTypes.NUMBER
275
332
  * @return {string} GLSL-compatible output
276
333
  */
277
- export function expressionToGlsl(context, value, typeHint) {
334
+ export function expressionToGlsl(context, value, expectedType) {
335
+ const returnType =
336
+ expectedType !== undefined ? expectedType : ValueTypes.NUMBER;
278
337
  // operator
279
338
  if (Array.isArray(value) && typeof value[0] === 'string') {
280
339
  const operator = Operators[value[0]];
@@ -283,41 +342,39 @@ export function expressionToGlsl(context, value, typeHint) {
283
342
  `Unrecognized expression operator: ${JSON.stringify(value)}`
284
343
  );
285
344
  }
286
- return operator.toGlsl(context, value.slice(1), typeHint);
345
+ return operator.toGlsl(context, value.slice(1), returnType);
287
346
  }
288
347
 
289
- const valueType = getValueType(value);
290
- if ((valueType & ValueTypes.NUMBER) > 0) {
348
+ const possibleType = getValueType(value) & returnType;
349
+ assertNotEmptyType(value, possibleType, '');
350
+
351
+ if ((possibleType & ValueTypes.NUMBER) > 0) {
291
352
  return numberToGlsl(/** @type {number} */ (value));
292
353
  }
293
354
 
294
- if ((valueType & ValueTypes.BOOLEAN) > 0) {
355
+ if ((possibleType & ValueTypes.BOOLEAN) > 0) {
295
356
  return value.toString();
296
357
  }
297
358
 
298
- if (
299
- (valueType & ValueTypes.STRING) > 0 &&
300
- (typeHint === undefined || typeHint == ValueTypes.STRING)
301
- ) {
359
+ if ((possibleType & ValueTypes.STRING) > 0) {
302
360
  return stringToGlsl(context, value.toString());
303
361
  }
304
362
 
305
- if (
306
- (valueType & ValueTypes.COLOR) > 0 &&
307
- (typeHint === undefined || typeHint == ValueTypes.COLOR)
308
- ) {
363
+ if ((possibleType & ValueTypes.COLOR) > 0) {
309
364
  return colorToGlsl(/** @type {Array<number> | string} */ (value));
310
365
  }
311
366
 
312
- if ((valueType & ValueTypes.NUMBER_ARRAY) > 0) {
367
+ if ((possibleType & ValueTypes.NUMBER_ARRAY) > 0) {
313
368
  return arrayToGlsl(/** @type {Array<number>} */ (value));
314
369
  }
315
370
 
316
- throw new Error(`Unexpected expression ${value} (expected type ${typeHint})`);
371
+ throw new Error(
372
+ `Unexpected expression ${value} (expected type ${printTypes(returnType)})`
373
+ );
317
374
  }
318
375
 
319
376
  function assertNumber(value) {
320
- if (!(getValueType(value) & ValueTypes.NUMBER)) {
377
+ if ((getValueType(value) & ValueTypes.NUMBER) === 0) {
321
378
  throw new Error(
322
379
  `A numeric value was expected, got ${JSON.stringify(value)} instead`
323
380
  );
@@ -329,14 +386,14 @@ function assertNumbers(values) {
329
386
  }
330
387
  }
331
388
  function assertString(value) {
332
- if (!(getValueType(value) & ValueTypes.STRING)) {
389
+ if ((getValueType(value) & ValueTypes.STRING) === 0) {
333
390
  throw new Error(
334
391
  `A string value was expected, got ${JSON.stringify(value)} instead`
335
392
  );
336
393
  }
337
394
  }
338
395
  function assertBoolean(value) {
339
- if (!(getValueType(value) & ValueTypes.BOOLEAN)) {
396
+ if ((getValueType(value) & ValueTypes.BOOLEAN) === 0) {
340
397
  throw new Error(
341
398
  `A boolean value was expected, got ${JSON.stringify(value)} instead`
342
399
  );
@@ -366,40 +423,81 @@ function assertArgsMaxCount(args, count) {
366
423
  function assertArgsEven(args) {
367
424
  if (args.length % 2 !== 0) {
368
425
  throw new Error(
369
- `An even amount of arguments was expected, got ${args} instead`
426
+ `An even amount of arguments was expected, got ${JSON.stringify(
427
+ args
428
+ )} instead`
370
429
  );
371
430
  }
372
431
  }
373
432
  function assertArgsOdd(args) {
374
433
  if (args.length % 2 === 0) {
375
434
  throw new Error(
376
- `An odd amount of arguments was expected, got ${args} instead`
435
+ `An odd amount of arguments was expected, got ${JSON.stringify(
436
+ args
437
+ )} instead`
377
438
  );
378
439
  }
379
440
  }
380
- function assertUniqueInferredType(args, types) {
381
- if (!isTypeUnique(types)) {
441
+ function assertNotEmptyType(args, types, descriptor) {
442
+ if (types === ValueTypes.NONE) {
382
443
  throw new Error(
383
- `Could not infer only one type from the following expression: ${JSON.stringify(
444
+ `No matching type was found for the following expression ${descriptor}: ${JSON.stringify(
384
445
  args
385
446
  )}`
386
447
  );
387
448
  }
388
449
  }
450
+ function assertSingleType(args, types, descriptor) {
451
+ assertNotEmptyType(args, types, descriptor);
452
+ if (!isTypeUnique(types)) {
453
+ throw new Error(
454
+ `Expected to have a unique type for the following expression ${descriptor}: ${JSON.stringify(
455
+ args
456
+ )}
457
+ Got the following types instead: ${printTypes(types)}`
458
+ );
459
+ }
460
+ }
461
+ function assertOfType(args, types, expectedTypes, descriptor) {
462
+ if ((types & expectedTypes) === ValueTypes.NONE) {
463
+ throw new Error(
464
+ `Expected the ${descriptor} type of the following expression: ${JSON.stringify(
465
+ args
466
+ )} to be of the following types: ${printTypes(expectedTypes)}
467
+ Got these types instead: ${printTypes(types)}`
468
+ );
469
+ }
470
+ }
389
471
 
390
472
  Operators['get'] = {
391
473
  getReturnType: function (args) {
474
+ if (args.length === 2) {
475
+ const hint = args[1];
476
+ return getTypeFromHint(/** @type {string} */ (hint));
477
+ }
392
478
  return ValueTypes.ANY;
393
479
  },
394
- toGlsl: function (context, args) {
395
- assertArgsCount(args, 1);
480
+ toGlsl: function (context, args, expectedType) {
481
+ assertArgsMinCount(args, 1);
482
+ assertArgsMaxCount(args, 2);
396
483
  assertString(args[0]);
397
- const value = args[0].toString();
398
- if (!context.attributes.includes(value)) {
399
- context.attributes.push(value);
484
+ const outputType = expectedType & Operators['get'].getReturnType(args);
485
+ assertSingleType(['get', ...args], outputType, '');
486
+ const name = args[0].toString();
487
+ const existing = context.attributes.find((a) => a.name === name);
488
+ if (!existing) {
489
+ context.attributes.push({
490
+ name: name,
491
+ type: outputType,
492
+ });
493
+ } else if (outputType !== existing.type) {
494
+ throw new Error(
495
+ `The following attribute was used in different places with incompatible types: ${name}
496
+ Types were: ${printTypes(existing.type)} and ${printTypes(outputType)}`
497
+ );
400
498
  }
401
499
  const prefix = context.inFragmentShader ? 'v_' : 'a_';
402
- return prefix + value;
500
+ return prefix + name;
403
501
  },
404
502
  };
405
503
 
@@ -413,17 +511,37 @@ export function uniformNameForVariable(variableName) {
413
511
  }
414
512
 
415
513
  Operators['var'] = {
416
- getReturnType: function (args) {
514
+ getReturnType: function () {
417
515
  return ValueTypes.ANY;
418
516
  },
419
- toGlsl: function (context, args) {
517
+ toGlsl: function (context, args, expectedType) {
420
518
  assertArgsCount(args, 1);
421
519
  assertString(args[0]);
422
- const value = args[0].toString();
423
- if (!context.variables.includes(value)) {
424
- context.variables.push(value);
520
+ const name = args[0].toString();
521
+ if (
522
+ !context.style.variables ||
523
+ context.style.variables[name] === undefined
524
+ ) {
525
+ throw new Error(
526
+ `The following variable is missing from the style: ${name}`
527
+ );
425
528
  }
426
- return uniformNameForVariable(value);
529
+ const initialValue = context.style.variables[name];
530
+ const outputType = expectedType & getValueType(initialValue);
531
+ assertSingleType(['var', ...args], outputType, '');
532
+ const existing = context.variables.find((a) => a.name === name);
533
+ if (!existing) {
534
+ context.variables.push({
535
+ name: name,
536
+ type: outputType,
537
+ });
538
+ } else if (outputType !== existing.type) {
539
+ throw new Error(
540
+ `The following variable was used in different places with incompatible types: ${name}
541
+ Types were: ${printTypes(existing.type)} and ${printTypes(outputType)}`
542
+ );
543
+ }
544
+ return uniformNameForVariable(name);
427
545
  },
428
546
  };
429
547
 
@@ -431,7 +549,7 @@ export const PALETTE_TEXTURE_ARRAY = 'u_paletteTextures';
431
549
 
432
550
  // ['palette', index, colors]
433
551
  Operators['palette'] = {
434
- getReturnType: function (args) {
552
+ getReturnType: function () {
435
553
  return ValueTypes.COLOR;
436
554
  },
437
555
  toGlsl: function (context, args) {
@@ -489,7 +607,7 @@ Operators['palette'] = {
489
607
  const GET_BAND_VALUE_FUNC = 'getBandValue';
490
608
 
491
609
  Operators['band'] = {
492
- getReturnType: function (args) {
610
+ getReturnType: function () {
493
611
  return ValueTypes.NUMBER;
494
612
  },
495
613
  toGlsl: function (context, args) {
@@ -532,7 +650,7 @@ Operators['band'] = {
532
650
  };
533
651
 
534
652
  Operators['time'] = {
535
- getReturnType: function (args) {
653
+ getReturnType: function () {
536
654
  return ValueTypes.NUMBER;
537
655
  },
538
656
  toGlsl: function (context, args) {
@@ -542,7 +660,7 @@ Operators['time'] = {
542
660
  };
543
661
 
544
662
  Operators['zoom'] = {
545
- getReturnType: function (args) {
663
+ getReturnType: function () {
546
664
  return ValueTypes.NUMBER;
547
665
  },
548
666
  toGlsl: function (context, args) {
@@ -552,7 +670,7 @@ Operators['zoom'] = {
552
670
  };
553
671
 
554
672
  Operators['resolution'] = {
555
- getReturnType: function (args) {
673
+ getReturnType: function () {
556
674
  return ValueTypes.NUMBER;
557
675
  },
558
676
  toGlsl: function (context, args) {
@@ -563,17 +681,32 @@ Operators['resolution'] = {
563
681
 
564
682
  Operators['*'] = {
565
683
  getReturnType: function (args) {
566
- return ValueTypes.NUMBER;
684
+ let outputType = ValueTypes.NUMBER | ValueTypes.COLOR;
685
+ for (let i = 0; i < args.length; i++) {
686
+ outputType = outputType & getValueType(args[i]);
687
+ }
688
+ return outputType;
567
689
  },
568
- toGlsl: function (context, args) {
690
+ toGlsl: function (context, args, expectedType) {
569
691
  assertArgsMinCount(args, 2);
570
- assertNumbers(args);
571
- return `(${args.map((arg) => expressionToGlsl(context, arg)).join(' * ')})`;
692
+ let outputType = expectedType;
693
+ for (let i = 0; i < args.length; i++) {
694
+ outputType = outputType & getValueType(args[i]);
695
+ }
696
+ assertOfType(
697
+ args,
698
+ outputType,
699
+ ValueTypes.NUMBER | ValueTypes.COLOR,
700
+ 'output'
701
+ );
702
+ return `(${args
703
+ .map((arg) => expressionToGlsl(context, arg, outputType))
704
+ .join(' * ')})`;
572
705
  },
573
706
  };
574
707
 
575
708
  Operators['/'] = {
576
- getReturnType: function (args) {
709
+ getReturnType: function () {
577
710
  return ValueTypes.NUMBER;
578
711
  },
579
712
  toGlsl: function (context, args) {
@@ -587,19 +720,18 @@ Operators['/'] = {
587
720
  };
588
721
 
589
722
  Operators['+'] = {
590
- getReturnType: function (args) {
723
+ getReturnType: function () {
591
724
  return ValueTypes.NUMBER;
592
725
  },
593
726
  toGlsl: function (context, args) {
594
727
  assertArgsMinCount(args, 2);
595
728
  assertNumbers(args);
596
-
597
729
  return `(${args.map((arg) => expressionToGlsl(context, arg)).join(' + ')})`;
598
730
  },
599
731
  };
600
732
 
601
733
  Operators['-'] = {
602
- getReturnType: function (args) {
734
+ getReturnType: function () {
603
735
  return ValueTypes.NUMBER;
604
736
  },
605
737
  toGlsl: function (context, args) {
@@ -613,7 +745,7 @@ Operators['-'] = {
613
745
  };
614
746
 
615
747
  Operators['clamp'] = {
616
- getReturnType: function (args) {
748
+ getReturnType: function () {
617
749
  return ValueTypes.NUMBER;
618
750
  },
619
751
  toGlsl: function (context, args) {
@@ -626,7 +758,7 @@ Operators['clamp'] = {
626
758
  };
627
759
 
628
760
  Operators['%'] = {
629
- getReturnType: function (args) {
761
+ getReturnType: function () {
630
762
  return ValueTypes.NUMBER;
631
763
  },
632
764
  toGlsl: function (context, args) {
@@ -640,7 +772,7 @@ Operators['%'] = {
640
772
  };
641
773
 
642
774
  Operators['^'] = {
643
- getReturnType: function (args) {
775
+ getReturnType: function () {
644
776
  return ValueTypes.NUMBER;
645
777
  },
646
778
  toGlsl: function (context, args) {
@@ -654,7 +786,7 @@ Operators['^'] = {
654
786
  };
655
787
 
656
788
  Operators['abs'] = {
657
- getReturnType: function (args) {
789
+ getReturnType: function () {
658
790
  return ValueTypes.NUMBER;
659
791
  },
660
792
  toGlsl: function (context, args) {
@@ -665,7 +797,7 @@ Operators['abs'] = {
665
797
  };
666
798
 
667
799
  Operators['floor'] = {
668
- getReturnType: function (args) {
800
+ getReturnType: function () {
669
801
  return ValueTypes.NUMBER;
670
802
  },
671
803
  toGlsl: function (context, args) {
@@ -676,7 +808,7 @@ Operators['floor'] = {
676
808
  };
677
809
 
678
810
  Operators['round'] = {
679
- getReturnType: function (args) {
811
+ getReturnType: function () {
680
812
  return ValueTypes.NUMBER;
681
813
  },
682
814
  toGlsl: function (context, args) {
@@ -687,7 +819,7 @@ Operators['round'] = {
687
819
  };
688
820
 
689
821
  Operators['ceil'] = {
690
- getReturnType: function (args) {
822
+ getReturnType: function () {
691
823
  return ValueTypes.NUMBER;
692
824
  },
693
825
  toGlsl: function (context, args) {
@@ -698,7 +830,7 @@ Operators['ceil'] = {
698
830
  };
699
831
 
700
832
  Operators['sin'] = {
701
- getReturnType: function (args) {
833
+ getReturnType: function () {
702
834
  return ValueTypes.NUMBER;
703
835
  },
704
836
  toGlsl: function (context, args) {
@@ -709,7 +841,7 @@ Operators['sin'] = {
709
841
  };
710
842
 
711
843
  Operators['cos'] = {
712
- getReturnType: function (args) {
844
+ getReturnType: function () {
713
845
  return ValueTypes.NUMBER;
714
846
  },
715
847
  toGlsl: function (context, args) {
@@ -720,7 +852,7 @@ Operators['cos'] = {
720
852
  };
721
853
 
722
854
  Operators['atan'] = {
723
- getReturnType: function (args) {
855
+ getReturnType: function () {
724
856
  return ValueTypes.NUMBER;
725
857
  },
726
858
  toGlsl: function (context, args) {
@@ -737,7 +869,7 @@ Operators['atan'] = {
737
869
  };
738
870
 
739
871
  Operators['>'] = {
740
- getReturnType: function (args) {
872
+ getReturnType: function () {
741
873
  return ValueTypes.BOOLEAN;
742
874
  },
743
875
  toGlsl: function (context, args) {
@@ -751,7 +883,7 @@ Operators['>'] = {
751
883
  };
752
884
 
753
885
  Operators['>='] = {
754
- getReturnType: function (args) {
886
+ getReturnType: function () {
755
887
  return ValueTypes.BOOLEAN;
756
888
  },
757
889
  toGlsl: function (context, args) {
@@ -765,7 +897,7 @@ Operators['>='] = {
765
897
  };
766
898
 
767
899
  Operators['<'] = {
768
- getReturnType: function (args) {
900
+ getReturnType: function () {
769
901
  return ValueTypes.BOOLEAN;
770
902
  },
771
903
  toGlsl: function (context, args) {
@@ -779,7 +911,7 @@ Operators['<'] = {
779
911
  };
780
912
 
781
913
  Operators['<='] = {
782
- getReturnType: function (args) {
914
+ getReturnType: function () {
783
915
  return ValueTypes.BOOLEAN;
784
916
  },
785
917
  toGlsl: function (context, args) {
@@ -794,7 +926,7 @@ Operators['<='] = {
794
926
 
795
927
  function getEqualOperator(operator) {
796
928
  return {
797
- getReturnType: function (args) {
929
+ getReturnType: function () {
798
930
  return ValueTypes.BOOLEAN;
799
931
  },
800
932
  toGlsl: function (context, args) {
@@ -831,19 +963,19 @@ Operators['=='] = getEqualOperator('==');
831
963
  Operators['!='] = getEqualOperator('!=');
832
964
 
833
965
  Operators['!'] = {
834
- getReturnType: function (args) {
966
+ getReturnType: function () {
835
967
  return ValueTypes.BOOLEAN;
836
968
  },
837
969
  toGlsl: function (context, args) {
838
970
  assertArgsCount(args, 1);
839
971
  assertBoolean(args[0]);
840
- return `(!${expressionToGlsl(context, args[0])})`;
972
+ return `(!${expressionToGlsl(context, args[0], ValueTypes.BOOLEAN)})`;
841
973
  },
842
974
  };
843
975
 
844
976
  function getDecisionOperator(operator) {
845
977
  return {
846
- getReturnType: function (args) {
978
+ getReturnType: function () {
847
979
  return ValueTypes.BOOLEAN;
848
980
  },
849
981
  toGlsl: function (context, args) {
@@ -851,9 +983,8 @@ function getDecisionOperator(operator) {
851
983
  for (let i = 0; i < args.length; i++) {
852
984
  assertBoolean(args[i]);
853
985
  }
854
- let result = '';
855
- result = args
856
- .map((arg) => expressionToGlsl(context, arg))
986
+ let result = args
987
+ .map((arg) => expressionToGlsl(context, arg, ValueTypes.BOOLEAN))
857
988
  .join(` ${operator} `);
858
989
  result = `(${result})`;
859
990
  return result;
@@ -866,7 +997,7 @@ Operators['all'] = getDecisionOperator('&&');
866
997
  Operators['any'] = getDecisionOperator('||');
867
998
 
868
999
  Operators['between'] = {
869
- getReturnType: function (args) {
1000
+ getReturnType: function () {
870
1001
  return ValueTypes.BOOLEAN;
871
1002
  },
872
1003
  toGlsl: function (context, args) {
@@ -880,7 +1011,7 @@ Operators['between'] = {
880
1011
  };
881
1012
 
882
1013
  Operators['array'] = {
883
- getReturnType: function (args) {
1014
+ getReturnType: function () {
884
1015
  return ValueTypes.NUMBER_ARRAY;
885
1016
  },
886
1017
  toGlsl: function (context, args) {
@@ -888,31 +1019,28 @@ Operators['array'] = {
888
1019
  assertArgsMaxCount(args, 4);
889
1020
  assertNumbers(args);
890
1021
  const parsedArgs = args.map(function (val) {
891
- return expressionToGlsl(context, val, ValueTypes.NUMBER);
1022
+ return expressionToGlsl(context, val);
892
1023
  });
893
1024
  return `vec${args.length}(${parsedArgs.join(', ')})`;
894
1025
  },
895
1026
  };
896
1027
 
897
1028
  Operators['color'] = {
898
- getReturnType: function (args) {
1029
+ getReturnType: function () {
899
1030
  return ValueTypes.COLOR;
900
1031
  },
901
1032
  toGlsl: function (context, args) {
902
1033
  assertArgsMinCount(args, 3);
903
1034
  assertArgsMaxCount(args, 4);
904
1035
  assertNumbers(args);
905
- const array = /** @type {Array<number>} */ (args);
1036
+ const parsedArgs = args
1037
+ .slice(0, 3)
1038
+ .map((val) => `${expressionToGlsl(context, val)} / 255.0`);
906
1039
  if (args.length === 3) {
907
- array.push(1);
1040
+ return `vec4(${parsedArgs.join(', ')}, 1.0)`;
908
1041
  }
909
- const parsedArgs = args.map(function (val, i) {
910
- return (
911
- expressionToGlsl(context, val, ValueTypes.NUMBER) +
912
- (i < 3 ? ' / 255.0' : '')
913
- );
914
- });
915
- return `vec${args.length}(${parsedArgs.join(', ')})`;
1042
+ const alpha = expressionToGlsl(context, args[3]);
1043
+ return `(${alpha} * vec4(${parsedArgs.join(', ')}, 1.0))`;
916
1044
  },
917
1045
  };
918
1046
 
@@ -924,7 +1052,7 @@ Operators['interpolate'] = {
924
1052
  }
925
1053
  return type;
926
1054
  },
927
- toGlsl: function (context, args, typeHint) {
1055
+ toGlsl: function (context, args, expectedType) {
928
1056
  assertArgsEven(args);
929
1057
  assertArgsMinCount(args, 6);
930
1058
 
@@ -950,19 +1078,20 @@ Operators['interpolate'] = {
950
1078
  }
951
1079
 
952
1080
  // compute input/output types
953
- typeHint = typeHint !== undefined ? typeHint : ValueTypes.ANY;
954
- const outputType = Operators['interpolate'].getReturnType(args) & typeHint;
955
- assertUniqueInferredType(args, outputType);
1081
+ const inputType = ValueTypes.NUMBER;
1082
+ const outputType =
1083
+ Operators['interpolate'].getReturnType(args) & expectedType;
1084
+ assertSingleType(['interpolate', ...args], outputType, 'output');
956
1085
 
957
- const input = expressionToGlsl(context, args[1]);
1086
+ const input = expressionToGlsl(context, args[1], inputType);
958
1087
  const exponent = numberToGlsl(interpolation);
959
1088
 
960
1089
  let result = '';
961
1090
  for (let i = 2; i < args.length - 2; i += 2) {
962
- const stop1 = expressionToGlsl(context, args[i]);
1091
+ const stop1 = expressionToGlsl(context, args[i], inputType);
963
1092
  const output1 =
964
1093
  result || expressionToGlsl(context, args[i + 1], outputType);
965
- const stop2 = expressionToGlsl(context, args[i + 2]);
1094
+ const stop2 = expressionToGlsl(context, args[i + 2], inputType);
966
1095
  const output2 = expressionToGlsl(context, args[i + 3], outputType);
967
1096
  result = `mix(${output1}, ${output2}, pow(clamp((${input} - ${stop1}) / (${stop2} - ${stop1}), 0.0, 1.0), ${exponent}))`;
968
1097
  }
@@ -979,15 +1108,27 @@ Operators['match'] = {
979
1108
  type = type & getValueType(args[args.length - 1]);
980
1109
  return type;
981
1110
  },
982
- toGlsl: function (context, args, typeHint) {
1111
+ toGlsl: function (context, args, expectedType) {
983
1112
  assertArgsEven(args);
984
1113
  assertArgsMinCount(args, 4);
985
1114
 
986
- typeHint = typeHint !== undefined ? typeHint : ValueTypes.ANY;
987
- const outputType = Operators['match'].getReturnType(args) & typeHint;
988
- assertUniqueInferredType(args, outputType);
1115
+ let inputType = getValueType(args[0]);
1116
+ for (let i = 1; i < args.length - 1; i += 2) {
1117
+ inputType = inputType & getValueType(args[i]);
1118
+ }
1119
+ assertOfType(
1120
+ ['match', ...args],
1121
+ inputType,
1122
+ ValueTypes.STRING | ValueTypes.NUMBER | ValueTypes.BOOLEAN,
1123
+ 'input'
1124
+ );
1125
+ inputType =
1126
+ (ValueTypes.STRING | ValueTypes.NUMBER | ValueTypes.BOOLEAN) & inputType;
1127
+
1128
+ const outputType = Operators['match'].getReturnType(args) & expectedType;
1129
+ assertSingleType(['match', ...args], outputType, 'output');
989
1130
 
990
- const input = expressionToGlsl(context, args[0]);
1131
+ const input = expressionToGlsl(context, args[0], inputType);
991
1132
  const fallback = expressionToGlsl(
992
1133
  context,
993
1134
  args[args.length - 1],
@@ -995,7 +1136,7 @@ Operators['match'] = {
995
1136
  );
996
1137
  let result = null;
997
1138
  for (let i = args.length - 3; i >= 1; i -= 2) {
998
- const match = expressionToGlsl(context, args[i]);
1139
+ const match = expressionToGlsl(context, args[i], inputType);
999
1140
  const output = expressionToGlsl(context, args[i + 1], outputType);
1000
1141
  result = `(${input} == ${match} ? ${output} : ${result || fallback})`;
1001
1142
  }
@@ -1012,13 +1153,12 @@ Operators['case'] = {
1012
1153
  type = type & getValueType(args[args.length - 1]);
1013
1154
  return type;
1014
1155
  },
1015
- toGlsl: function (context, args, typeHint) {
1156
+ toGlsl: function (context, args, expectedType) {
1016
1157
  assertArgsOdd(args);
1017
1158
  assertArgsMinCount(args, 3);
1018
1159
 
1019
- typeHint = typeHint !== undefined ? typeHint : ValueTypes.ANY;
1020
- const outputType = Operators['case'].getReturnType(args) & typeHint;
1021
- assertUniqueInferredType(args, outputType);
1160
+ const outputType = Operators['case'].getReturnType(args) & expectedType;
1161
+ assertSingleType(['case', ...args], outputType, 'output');
1022
1162
  for (let i = 0; i < args.length - 1; i += 2) {
1023
1163
  assertBoolean(args[i]);
1024
1164
  }
@@ -1030,7 +1170,7 @@ Operators['case'] = {
1030
1170
  );
1031
1171
  let result = null;
1032
1172
  for (let i = args.length - 3; i >= 0; i -= 2) {
1033
- const condition = expressionToGlsl(context, args[i]);
1173
+ const condition = expressionToGlsl(context, args[i], ValueTypes.BOOLEAN);
1034
1174
  const output = expressionToGlsl(context, args[i + 1], outputType);
1035
1175
  result = `(${condition} ? ${output} : ${result || fallback})`;
1036
1176
  }