ol 9.2.5-sh.2 → 10.0.1-dev.1722076459273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Collection.d.ts +1 -1
- package/Collection.d.ts.map +1 -1
- package/DataTile.d.ts +15 -1
- package/DataTile.d.ts.map +1 -1
- package/DataTile.js +26 -1
- package/Feature.d.ts +1 -1
- package/Feature.d.ts.map +1 -1
- package/Geolocation.d.ts +2 -2
- package/Geolocation.d.ts.map +1 -1
- package/Geolocation.js +1 -0
- package/Image.d.ts +4 -4
- package/Image.d.ts.map +1 -1
- package/ImageCanvas.d.ts +2 -1
- package/ImageCanvas.d.ts.map +1 -1
- package/ImageCanvas.js +2 -0
- package/ImageTile.d.ts.map +1 -1
- package/ImageTile.js +1 -1
- package/Map.d.ts +5 -4
- package/Map.d.ts.map +1 -1
- package/Map.js +15 -14
- package/MapBrowserEvent.d.ts +4 -2
- package/MapBrowserEvent.d.ts.map +1 -1
- package/MapBrowserEvent.js +4 -0
- package/MapBrowserEventHandler.d.ts +4 -1
- package/MapBrowserEventHandler.d.ts.map +1 -1
- package/MapBrowserEventHandler.js +4 -0
- package/MapBrowserEventType.d.ts +1 -1
- package/MapEvent.d.ts.map +1 -1
- package/MapEventType.d.ts +1 -1
- package/Object.d.ts.map +1 -1
- package/ObjectEventType.d.ts +1 -1
- package/Observable.d.ts +2 -2
- package/Observable.d.ts.map +1 -1
- package/Overlay.d.ts +2 -2
- package/Overlay.d.ts.map +1 -1
- package/Overlay.js +2 -2
- package/README.md +1 -1
- package/Tile.d.ts +10 -30
- package/Tile.d.ts.map +1 -1
- package/Tile.js +6 -79
- package/TileCache.d.ts +2 -1
- package/TileCache.d.ts.map +1 -1
- package/TileCache.js +4 -0
- package/TileQueue.d.ts +3 -2
- package/TileQueue.d.ts.map +1 -1
- package/TileQueue.js +7 -4
- package/VectorRenderTile.d.ts +8 -13
- package/VectorRenderTile.d.ts.map +1 -1
- package/VectorRenderTile.js +19 -24
- package/VectorTile.d.ts +6 -6
- package/VectorTile.d.ts.map +1 -1
- package/VectorTile.js +5 -4
- package/View.d.ts +1 -1
- package/View.d.ts.map +1 -1
- package/array.d.ts +2 -2
- package/array.d.ts.map +1 -1
- package/asserts.d.ts.map +1 -1
- package/centerconstraint.d.ts.map +1 -1
- package/color.d.ts.map +1 -1
- package/color.js +2 -2
- package/console.d.ts +1 -1
- package/console.d.ts.map +1 -1
- package/control/Attribution.d.ts.map +1 -1
- package/control/Attribution.js +5 -12
- package/control/Control.d.ts.map +1 -1
- package/control/Control.js +4 -6
- package/control/FullScreen.d.ts +1 -1
- package/control/FullScreen.d.ts.map +1 -1
- package/control/FullScreen.js +1 -0
- package/control/MousePosition.d.ts +1 -1
- package/control/MousePosition.d.ts.map +1 -1
- package/control/MousePosition.js +1 -0
- package/control/OverviewMap.d.ts.map +1 -1
- package/control/OverviewMap.js +16 -13
- package/control/Rotate.d.ts +4 -1
- package/control/Rotate.d.ts.map +1 -1
- package/control/Rotate.js +3 -0
- package/control/ScaleLine.d.ts +3 -3
- package/control/ScaleLine.d.ts.map +1 -1
- package/control/ZoomSlider.d.ts.map +1 -1
- package/control/ZoomSlider.js +1 -0
- package/control/ZoomToExtent.d.ts.map +1 -1
- package/control/defaults.d.ts.map +1 -1
- package/coordinate.d.ts +1 -1
- package/coordinate.d.ts.map +1 -1
- package/css.d.ts.map +1 -1
- package/dist/ol.d.ts +10 -8
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -3
- package/dist/ol.js.map +1 -1
- package/dom.d.ts +0 -5
- package/dom.d.ts.map +1 -1
- package/dom.js +1 -9
- package/events/SnapEvent.d.ts.map +1 -1
- package/events/Target.d.ts.map +1 -1
- package/events/Target.js +1 -0
- package/events/condition.d.ts +2 -2
- package/events/condition.d.ts.map +1 -1
- package/events/condition.js +1 -1
- package/events.d.ts.map +1 -1
- package/events.js +6 -4
- package/expr/cpu.d.ts +1 -1
- package/expr/cpu.d.ts.map +1 -1
- package/expr/cpu.js +2 -16
- package/expr/expression.d.ts +8 -15
- package/expr/expression.d.ts.map +1 -1
- package/expr/expression.js +388 -508
- package/expr/gpu.d.ts +3 -3
- package/expr/gpu.d.ts.map +1 -1
- package/expr/gpu.js +1 -14
- package/extent.d.ts +2 -2
- package/extent.d.ts.map +1 -1
- package/featureloader.d.ts +6 -6
- package/featureloader.d.ts.map +1 -1
- package/featureloader.js +3 -3
- package/format/EsriJSON.d.ts +9 -5
- package/format/EsriJSON.d.ts.map +1 -1
- package/format/EsriJSON.js +7 -0
- package/format/Feature.d.ts +12 -12
- package/format/Feature.d.ts.map +1 -1
- package/format/Feature.js +7 -5
- package/format/GML2.d.ts.map +1 -1
- package/format/GML2.js +7 -9
- package/format/GML3.d.ts +2 -1
- package/format/GML3.d.ts.map +1 -1
- package/format/GML3.js +23 -31
- package/format/GML32.d.ts.map +1 -1
- package/format/GML32.js +1 -0
- package/format/GMLBase.d.ts.map +1 -1
- package/format/GMLBase.js +3 -0
- package/format/GPX.d.ts.map +1 -1
- package/format/GPX.js +3 -0
- package/format/GeoJSON.d.ts +17 -13
- package/format/GeoJSON.d.ts.map +1 -1
- package/format/GeoJSON.js +17 -14
- package/format/IGC.d.ts +1 -1
- package/format/IGC.d.ts.map +1 -1
- package/format/IGC.js +2 -0
- package/format/IIIFInfo.d.ts.map +1 -1
- package/format/JSONFeature.d.ts +15 -11
- package/format/JSONFeature.d.ts.map +1 -1
- package/format/JSONFeature.js +17 -11
- package/format/KML.d.ts +6 -6
- package/format/KML.d.ts.map +1 -1
- package/format/KML.js +5 -1
- package/format/MVT.d.ts +15 -13
- package/format/MVT.d.ts.map +1 -1
- package/format/MVT.js +15 -14
- package/format/OSMXML.d.ts.map +1 -1
- package/format/OSMXML.js +1 -0
- package/format/OWS.d.ts.map +1 -1
- package/format/OWS.js +1 -0
- package/format/Polyline.d.ts +6 -3
- package/format/Polyline.d.ts.map +1 -1
- package/format/Polyline.js +6 -0
- package/format/TextFeature.d.ts +9 -5
- package/format/TextFeature.d.ts.map +1 -1
- package/format/TextFeature.js +8 -0
- package/format/TopoJSON.d.ts +1 -1
- package/format/TopoJSON.d.ts.map +1 -1
- package/format/TopoJSON.js +2 -0
- package/format/WFS.d.ts.map +1 -1
- package/format/WFS.js +3 -0
- package/format/WKB.d.ts +9 -5
- package/format/WKB.d.ts.map +1 -1
- package/format/WKB.js +8 -0
- package/format/WKT.d.ts.map +1 -1
- package/format/WKT.js +6 -0
- package/format/WMSCapabilities.d.ts.map +1 -1
- package/format/WMSCapabilities.js +1 -0
- package/format/WMSGetFeatureInfo.d.ts.map +1 -1
- package/format/WMSGetFeatureInfo.js +1 -0
- package/format/WMTSCapabilities.d.ts.map +1 -1
- package/format/WMTSCapabilities.js +1 -0
- package/format/XMLFeature.d.ts +11 -6
- package/format/XMLFeature.d.ts.map +1 -1
- package/format/XMLFeature.js +8 -0
- package/format/filter/Bbox.d.ts.map +1 -1
- package/format/filter/Comparison.d.ts.map +1 -1
- package/format/filter/ComparisonBinary.d.ts.map +1 -1
- package/format/filter/Contains.d.ts.map +1 -1
- package/format/filter/DWithin.d.ts.map +1 -1
- package/format/filter/Disjoint.d.ts.map +1 -1
- package/format/filter/During.d.ts.map +1 -1
- package/format/filter/EqualTo.d.ts.map +1 -1
- package/format/filter/Filter.d.ts.map +1 -1
- package/format/filter/GreaterThan.d.ts.map +1 -1
- package/format/filter/GreaterThanOrEqualTo.d.ts.map +1 -1
- package/format/filter/Intersects.d.ts.map +1 -1
- package/format/filter/IsBetween.d.ts.map +1 -1
- package/format/filter/IsLike.d.ts.map +1 -1
- package/format/filter/IsNull.d.ts.map +1 -1
- package/format/filter/LessThan.d.ts.map +1 -1
- package/format/filter/LessThanOrEqualTo.d.ts.map +1 -1
- package/format/filter/LogicalNary.d.ts.map +1 -1
- package/format/filter/Not.d.ts.map +1 -1
- package/format/filter/NotEqualTo.d.ts.map +1 -1
- package/format/filter/ResourceId.d.ts.map +1 -1
- package/format/filter/Spatial.d.ts.map +1 -1
- package/format/filter/Within.d.ts.map +1 -1
- package/format/filter.d.ts.map +1 -1
- package/functions.d.ts +2 -2
- package/functions.d.ts.map +1 -1
- package/functions.js +6 -5
- package/geom/Circle.d.ts +10 -3
- package/geom/Circle.d.ts.map +1 -1
- package/geom/Circle.js +13 -0
- package/geom/Geometry.d.ts +2 -2
- package/geom/GeometryCollection.d.ts +6 -3
- package/geom/GeometryCollection.d.ts.map +1 -1
- package/geom/GeometryCollection.js +13 -0
- package/geom/LineString.d.ts +9 -5
- package/geom/LineString.d.ts.map +1 -1
- package/geom/LineString.js +7 -0
- package/geom/LinearRing.d.ts +8 -4
- package/geom/LinearRing.d.ts.map +1 -1
- package/geom/LinearRing.js +7 -0
- package/geom/MultiLineString.d.ts +8 -4
- package/geom/MultiLineString.d.ts.map +1 -1
- package/geom/MultiLineString.js +7 -0
- package/geom/MultiPoint.d.ts +6 -3
- package/geom/MultiPoint.d.ts.map +1 -1
- package/geom/MultiPoint.js +6 -0
- package/geom/MultiPolygon.d.ts +8 -4
- package/geom/MultiPolygon.d.ts.map +1 -1
- package/geom/MultiPolygon.js +8 -0
- package/geom/Point.d.ts +4 -2
- package/geom/Point.d.ts.map +1 -1
- package/geom/Point.js +7 -0
- package/geom/Polygon.d.ts +8 -4
- package/geom/Polygon.d.ts.map +1 -1
- package/geom/Polygon.js +8 -0
- package/geom/SimpleGeometry.d.ts +2 -1
- package/geom/SimpleGeometry.d.ts.map +1 -1
- package/geom/SimpleGeometry.js +6 -0
- package/geom/flat/area.d.ts.map +1 -1
- package/geom/flat/area.js +9 -7
- package/geom/flat/center.d.ts.map +1 -1
- package/geom/flat/closest.d.ts.map +1 -1
- package/geom/flat/contains.d.ts.map +1 -1
- package/geom/flat/deflate.d.ts.map +1 -1
- package/geom/flat/flip.d.ts.map +1 -1
- package/geom/flat/geodesic.d.ts.map +1 -1
- package/geom/flat/inflate.d.ts.map +1 -1
- package/geom/flat/interiorpoint.d.ts.map +1 -1
- package/geom/flat/interpolate.d.ts.map +1 -1
- package/geom/flat/intersectsextent.d.ts.map +1 -1
- package/geom/flat/length.d.ts.map +1 -1
- package/geom/flat/linechunk.d.ts.map +1 -1
- package/geom/flat/orient.d.ts.map +1 -1
- package/geom/flat/reverse.d.ts.map +1 -1
- package/geom/flat/segments.d.ts +1 -1
- package/geom/flat/segments.d.ts.map +1 -1
- package/geom/flat/simplify.d.ts.map +1 -1
- package/geom/flat/straightchunk.d.ts.map +1 -1
- package/geom/flat/textpath.d.ts.map +1 -1
- package/geom/flat/topology.d.ts.map +1 -1
- package/geom/flat/transform.d.ts.map +1 -1
- package/interaction/DblClickDragZoom.d.ts.map +1 -1
- package/interaction/DblClickDragZoom.js +1 -0
- package/interaction/DoubleClickZoom.d.ts.map +1 -1
- package/interaction/DoubleClickZoom.js +1 -0
- package/interaction/DragAndDrop.d.ts +4 -3
- package/interaction/DragAndDrop.d.ts.map +1 -1
- package/interaction/DragAndDrop.js +2 -0
- package/interaction/DragBox.d.ts +3 -3
- package/interaction/DragBox.d.ts.map +1 -1
- package/interaction/DragBox.js +6 -2
- package/interaction/DragPan.d.ts +6 -4
- package/interaction/DragPan.d.ts.map +1 -1
- package/interaction/DragPan.js +6 -1
- package/interaction/DragRotate.d.ts +3 -3
- package/interaction/DragRotate.d.ts.map +1 -1
- package/interaction/DragRotate.js +5 -2
- package/interaction/DragRotateAndZoom.d.ts +2 -2
- package/interaction/DragRotateAndZoom.d.ts.map +1 -1
- package/interaction/DragRotateAndZoom.js +4 -1
- package/interaction/DragZoom.d.ts +3 -3
- package/interaction/DragZoom.d.ts.map +1 -1
- package/interaction/DragZoom.js +3 -2
- package/interaction/Draw.d.ts +8 -7
- package/interaction/Draw.d.ts.map +1 -1
- package/interaction/Draw.js +9 -5
- package/interaction/Extent.d.ts +4 -3
- package/interaction/Extent.d.ts.map +1 -1
- package/interaction/Extent.js +6 -1
- package/interaction/Interaction.d.ts +1 -1
- package/interaction/Interaction.d.ts.map +1 -1
- package/interaction/KeyboardPan.d.ts +2 -2
- package/interaction/KeyboardPan.d.ts.map +1 -1
- package/interaction/KeyboardPan.js +2 -1
- package/interaction/KeyboardZoom.d.ts +2 -2
- package/interaction/KeyboardZoom.d.ts.map +1 -1
- package/interaction/KeyboardZoom.js +2 -1
- package/interaction/Link.d.ts +1 -1
- package/interaction/Link.d.ts.map +1 -1
- package/interaction/Link.js +4 -0
- package/interaction/Modify.d.ts +13 -10
- package/interaction/Modify.d.ts.map +1 -1
- package/interaction/Modify.js +11 -3
- package/interaction/MouseWheelZoom.d.ts +3 -3
- package/interaction/MouseWheelZoom.d.ts.map +1 -1
- package/interaction/MouseWheelZoom.js +2 -1
- package/interaction/PinchRotate.d.ts.map +1 -1
- package/interaction/PinchRotate.js +3 -0
- package/interaction/PinchZoom.d.ts.map +1 -1
- package/interaction/PinchZoom.js +3 -0
- package/interaction/Pointer.d.ts.map +1 -1
- package/interaction/Pointer.js +1 -0
- package/interaction/Select.d.ts +14 -14
- package/interaction/Select.d.ts.map +1 -1
- package/interaction/Select.js +8 -6
- package/interaction/Snap.d.ts +3 -2
- package/interaction/Snap.d.ts.map +1 -1
- package/interaction/Snap.js +3 -0
- package/interaction/Translate.d.ts +11 -10
- package/interaction/Translate.d.ts.map +1 -1
- package/interaction/Translate.js +9 -4
- package/interaction/defaults.d.ts.map +1 -1
- package/layer/Base.d.ts +1 -1
- package/layer/Base.d.ts.map +1 -1
- package/layer/Base.js +1 -0
- package/layer/BaseImage.d.ts.map +1 -1
- package/layer/BaseTile.d.ts +22 -5
- package/layer/BaseTile.d.ts.map +1 -1
- package/layer/BaseTile.js +23 -3
- package/layer/BaseVector.d.ts.map +1 -1
- package/layer/BaseVector.js +3 -0
- package/layer/Graticule.d.ts +2 -1
- package/layer/Graticule.d.ts.map +1 -1
- package/layer/Graticule.js +1 -0
- package/layer/Group.d.ts +2 -2
- package/layer/Group.d.ts.map +1 -1
- package/layer/Group.js +3 -0
- package/layer/Heatmap.d.ts +8 -3
- package/layer/Heatmap.d.ts.map +1 -1
- package/layer/Heatmap.js +18 -7
- package/layer/Image.d.ts.map +1 -1
- package/layer/Image.js +4 -0
- package/layer/Layer.d.ts +4 -4
- package/layer/Layer.d.ts.map +1 -1
- package/layer/Layer.js +7 -8
- package/layer/Tile.d.ts +5 -2
- package/layer/Tile.d.ts.map +1 -1
- package/layer/Tile.js +6 -1
- package/layer/Vector.d.ts.map +1 -1
- package/layer/Vector.js +3 -0
- package/layer/VectorImage.d.ts +1 -1
- package/layer/VectorImage.d.ts.map +1 -1
- package/layer/VectorImage.js +3 -0
- package/layer/VectorTile.d.ts +32 -7
- package/layer/VectorTile.d.ts.map +1 -1
- package/layer/VectorTile.js +38 -6
- package/layer/WebGLPoints.d.ts +1 -2
- package/layer/WebGLPoints.d.ts.map +1 -1
- package/layer/WebGLPoints.js +3 -0
- package/layer/WebGLTile.d.ts +9 -12
- package/layer/WebGLTile.d.ts.map +1 -1
- package/layer/WebGLTile.js +20 -21
- package/loadingstrategy.d.ts.map +1 -1
- package/math.d.ts.map +1 -1
- package/net.d.ts.map +1 -1
- package/obj.d.ts.map +1 -1
- package/ol.css +4 -0
- package/package.json +4 -4
- package/pixel.d.ts.map +1 -1
- package/proj/Projection.d.ts +1 -1
- package/proj/Projection.d.ts.map +1 -1
- package/proj/Units.d.ts +1 -1
- package/proj/epsg3857.d.ts.map +1 -1
- package/proj/epsg4326.d.ts.map +1 -1
- package/proj/proj4.d.ts.map +1 -1
- package/proj.d.ts.map +1 -1
- package/render/Box.d.ts.map +1 -1
- package/render/Box.js +1 -0
- package/render/Event.d.ts.map +1 -1
- package/render/EventType.d.ts +2 -2
- package/render/Feature.d.ts +6 -4
- package/render/Feature.d.ts.map +1 -1
- package/render/Feature.js +2 -0
- package/render/canvas/Builder.d.ts.map +1 -1
- package/render/canvas/Builder.js +2 -0
- package/render/canvas/BuilderGroup.d.ts.map +1 -1
- package/render/canvas/Executor.d.ts +6 -27
- package/render/canvas/Executor.d.ts.map +1 -1
- package/render/canvas/Executor.js +7 -13
- package/render/canvas/ExecutorGroup.d.ts +4 -5
- package/render/canvas/ExecutorGroup.d.ts.map +1 -1
- package/render/canvas/ExecutorGroup.js +2 -1
- package/render/canvas/ImageBuilder.d.ts +2 -1
- package/render/canvas/ImageBuilder.d.ts.map +1 -1
- package/render/canvas/ImageBuilder.js +4 -0
- package/render/canvas/Immediate.d.ts +24 -12
- package/render/canvas/Immediate.d.ts.map +1 -1
- package/render/canvas/Immediate.js +14 -0
- package/render/canvas/Instruction.d.ts.map +1 -1
- package/render/canvas/LineStringBuilder.d.ts.map +1 -1
- package/render/canvas/LineStringBuilder.js +4 -0
- package/render/canvas/PolygonBuilder.d.ts.map +1 -1
- package/render/canvas/PolygonBuilder.js +4 -0
- package/render/canvas/TextBuilder.d.ts +4 -2
- package/render/canvas/TextBuilder.d.ts.map +1 -1
- package/render/canvas/TextBuilder.js +4 -0
- package/render/canvas/ZIndexContext.d.ts +2 -1
- package/render/canvas/ZIndexContext.d.ts.map +1 -1
- package/render/canvas/ZIndexContext.js +1 -0
- package/render/canvas/hitdetect.d.ts +1 -1
- package/render/canvas/hitdetect.d.ts.map +1 -1
- package/render/canvas/style.d.ts +3 -3
- package/render/canvas/style.d.ts.map +1 -1
- package/render/canvas/style.js +6 -5
- package/render/canvas.d.ts +1 -1
- package/render/canvas.d.ts.map +1 -1
- package/render/canvas.js +2 -1
- package/render/webgl/MixedGeometryBatch.d.ts +4 -1
- package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
- package/render/webgl/MixedGeometryBatch.js +4 -0
- package/render/webgl/VectorStyleRenderer.d.ts +56 -30
- package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
- package/render/webgl/VectorStyleRenderer.js +39 -0
- package/render/webgl/renderinstructions.d.ts +4 -4
- package/render/webgl/utils.d.ts +1 -1
- package/render/webgl/utils.d.ts.map +1 -1
- package/render.d.ts.map +1 -1
- package/renderer/Composite.d.ts +3 -2
- package/renderer/Composite.d.ts.map +1 -1
- package/renderer/Composite.js +10 -4
- package/renderer/Layer.d.ts +22 -29
- package/renderer/Layer.d.ts.map +1 -1
- package/renderer/Layer.js +33 -37
- package/renderer/Map.d.ts +1 -1
- package/renderer/Map.d.ts.map +1 -1
- package/renderer/canvas/ImageLayer.d.ts +6 -4
- package/renderer/canvas/ImageLayer.d.ts.map +1 -1
- package/renderer/canvas/ImageLayer.js +12 -9
- package/renderer/canvas/Layer.d.ts +4 -9
- package/renderer/canvas/Layer.d.ts.map +1 -1
- package/renderer/canvas/Layer.js +1 -6
- package/renderer/canvas/TileLayer.d.ts +105 -41
- package/renderer/canvas/TileLayer.d.ts.map +1 -1
- package/renderer/canvas/TileLayer.js +545 -329
- package/renderer/canvas/VectorImageLayer.d.ts +6 -3
- package/renderer/canvas/VectorImageLayer.d.ts.map +1 -1
- package/renderer/canvas/VectorImageLayer.js +10 -3
- package/renderer/canvas/VectorLayer.d.ts +6 -3
- package/renderer/canvas/VectorLayer.d.ts.map +1 -1
- package/renderer/canvas/VectorLayer.js +8 -0
- package/renderer/canvas/VectorTileLayer.d.ts +16 -14
- package/renderer/canvas/VectorTileLayer.d.ts.map +1 -1
- package/renderer/canvas/VectorTileLayer.js +78 -53
- package/renderer/vector.d.ts.map +1 -1
- package/renderer/webgl/Layer.d.ts +1 -6
- package/renderer/webgl/Layer.d.ts.map +1 -1
- package/renderer/webgl/Layer.js +2 -6
- package/renderer/webgl/PointsLayer.d.ts +23 -8
- package/renderer/webgl/PointsLayer.d.ts.map +1 -1
- package/renderer/webgl/PointsLayer.js +22 -1
- package/renderer/webgl/TileLayer.d.ts +16 -5
- package/renderer/webgl/TileLayer.d.ts.map +1 -1
- package/renderer/webgl/TileLayer.js +18 -0
- package/renderer/webgl/TileLayerBase.d.ts +7 -16
- package/renderer/webgl/TileLayerBase.d.ts.map +1 -1
- package/renderer/webgl/TileLayerBase.js +69 -84
- package/renderer/webgl/VectorLayer.d.ts +32 -8
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorLayer.js +53 -0
- package/renderer/webgl/VectorTileLayer.d.ts +34 -29
- package/renderer/webgl/VectorTileLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorTileLayer.js +27 -0
- package/renderer/webgl/worldUtil.d.ts.map +1 -1
- package/reproj/DataTile.d.ts.map +1 -1
- package/reproj/DataTile.js +121 -119
- package/reproj/Image.d.ts +2 -1
- package/reproj/Image.d.ts.map +1 -1
- package/reproj/Image.js +4 -2
- package/reproj/Tile.d.ts.map +1 -1
- package/reproj/Tile.js +16 -19
- package/reproj/Triangulation.d.ts.map +1 -1
- package/reproj.d.ts +1 -1
- package/reproj.d.ts.map +1 -1
- package/resolution.d.ts.map +1 -1
- package/resolutionconstraint.d.ts.map +1 -1
- package/rotationconstraint.d.ts.map +1 -1
- package/size.d.ts.map +1 -1
- package/source/BingMaps.d.ts +3 -3
- package/source/BingMaps.d.ts.map +1 -1
- package/source/BingMaps.js +1 -2
- package/source/CartoDB.d.ts +2 -2
- package/source/CartoDB.d.ts.map +1 -1
- package/source/CartoDB.js +1 -1
- package/source/Cluster.d.ts +5 -5
- package/source/Cluster.d.ts.map +1 -1
- package/source/Cluster.js +5 -2
- package/source/DataTile.d.ts +51 -22
- package/source/DataTile.d.ts.map +1 -1
- package/source/DataTile.js +67 -9
- package/source/GeoTIFF.d.ts +4 -7
- package/source/GeoTIFF.d.ts.map +1 -1
- package/source/GeoTIFF.js +4 -3
- package/source/Google.d.ts +2 -1
- package/source/Google.d.ts.map +1 -1
- package/source/Google.js +4 -2
- package/source/IIIF.d.ts +1 -1
- package/source/IIIF.js +1 -1
- package/source/Image.d.ts +3 -2
- package/source/Image.d.ts.map +1 -1
- package/source/Image.js +1 -0
- package/source/ImageArcGISRest.d.ts.map +1 -1
- package/source/ImageArcGISRest.js +4 -0
- package/source/ImageCanvas.d.ts +2 -1
- package/source/ImageCanvas.d.ts.map +1 -1
- package/source/ImageCanvas.js +1 -0
- package/source/ImageMapGuide.d.ts.map +1 -1
- package/source/ImageMapGuide.js +4 -0
- package/source/ImageStatic.d.ts.map +1 -1
- package/source/ImageStatic.js +1 -0
- package/source/ImageTile.d.ts +102 -0
- package/source/ImageTile.d.ts.map +1 -0
- package/source/ImageTile.js +206 -0
- package/source/ImageWMS.d.ts.map +1 -1
- package/source/ImageWMS.js +4 -0
- package/source/OGCMapTile.d.ts +2 -2
- package/source/OGCMapTile.js +1 -1
- package/source/OGCVectorTile.d.ts +4 -4
- package/source/OGCVectorTile.d.ts.map +1 -1
- package/source/OGCVectorTile.js +2 -2
- package/source/OSM.d.ts +2 -7
- package/source/OSM.d.ts.map +1 -1
- package/source/OSM.js +1 -3
- package/source/Raster.d.ts +41 -26
- package/source/Raster.d.ts.map +1 -1
- package/source/Raster.js +83 -102
- package/source/Source.d.ts +1 -1
- package/source/Source.d.ts.map +1 -1
- package/source/Source.js +5 -14
- package/source/StadiaMaps.d.ts +2 -2
- package/source/StadiaMaps.d.ts.map +1 -1
- package/source/StadiaMaps.js +2 -18
- package/source/Tile.d.ts +7 -36
- package/source/Tile.d.ts.map +1 -1
- package/source/Tile.js +9 -69
- package/source/TileArcGISRest.d.ts +2 -2
- package/source/TileArcGISRest.d.ts.map +1 -1
- package/source/TileArcGISRest.js +2 -1
- package/source/TileDebug.d.ts.map +1 -1
- package/source/TileDebug.js +0 -1
- package/source/TileEventType.d.ts +1 -1
- package/source/TileImage.d.ts +9 -12
- package/source/TileImage.d.ts.map +1 -1
- package/source/TileImage.js +21 -43
- package/source/TileJSON.d.ts +2 -2
- package/source/TileJSON.d.ts.map +1 -1
- package/source/TileJSON.js +1 -1
- package/source/TileWMS.d.ts +2 -2
- package/source/TileWMS.d.ts.map +1 -1
- package/source/TileWMS.js +3 -4
- package/source/UTFGrid.d.ts +5 -3
- package/source/UTFGrid.d.ts.map +1 -1
- package/source/UTFGrid.js +7 -8
- package/source/UrlTile.d.ts +16 -13
- package/source/UrlTile.d.ts.map +1 -1
- package/source/UrlTile.js +13 -7
- package/source/Vector.d.ts +10 -10
- package/source/Vector.d.ts.map +1 -1
- package/source/Vector.js +8 -5
- package/source/VectorEventType.d.ts +1 -1
- package/source/VectorTile.d.ts +8 -20
- package/source/VectorTile.d.ts.map +1 -1
- package/source/VectorTile.js +16 -85
- package/source/WMTS.d.ts +3 -3
- package/source/WMTS.d.ts.map +1 -1
- package/source/WMTS.js +5 -4
- package/source/XYZ.d.ts +14 -17
- package/source/XYZ.d.ts.map +1 -1
- package/source/XYZ.js +8 -8
- package/source/Zoomify.d.ts +5 -4
- package/source/Zoomify.d.ts.map +1 -1
- package/source/Zoomify.js +5 -2
- package/source/arcgisRest.d.ts +4 -4
- package/source/arcgisRest.d.ts.map +1 -1
- package/source/arcgisRest.js +5 -5
- package/source/mapguide.d.ts +3 -3
- package/source/mapguide.d.ts.map +1 -1
- package/source/mapguide.js +11 -8
- package/source/ogcTileUtil.d.ts +2 -2
- package/source/ogcTileUtil.d.ts.map +1 -1
- package/source/ogcTileUtil.js +7 -7
- package/source/static.d.ts +3 -3
- package/source/static.d.ts.map +1 -1
- package/source/static.js +7 -7
- package/source/wms.d.ts +2 -2
- package/source/wms.d.ts.map +1 -1
- package/source/wms.js +16 -19
- package/source.d.ts +1 -0
- package/source.d.ts.map +1 -1
- package/source.js +1 -0
- package/sphere.d.ts +1 -1
- package/structs/LRUCache.d.ts.map +1 -1
- package/structs/PriorityQueue.d.ts.map +1 -1
- package/structs/RBush.d.ts +10 -32
- package/structs/RBush.d.ts.map +1 -1
- package/structs/RBush.js +9 -12
- package/style/Circle.d.ts +2 -1
- package/style/Circle.d.ts.map +1 -1
- package/style/Circle.js +2 -1
- package/style/Fill.d.ts +3 -3
- package/style/Fill.d.ts.map +1 -1
- package/style/Fill.js +1 -1
- package/style/Icon.d.ts +8 -5
- package/style/Icon.d.ts.map +1 -1
- package/style/Icon.js +21 -0
- package/style/IconImage.d.ts.map +1 -1
- package/style/IconImage.js +3 -2
- package/style/IconImageCache.d.ts.map +1 -1
- package/style/Image.d.ts +3 -3
- package/style/Image.d.ts.map +1 -1
- package/style/RegularShape.d.ts +11 -5
- package/style/RegularShape.d.ts.map +1 -1
- package/style/RegularShape.js +23 -5
- package/style/Stroke.d.ts.map +1 -1
- package/style/Style.d.ts +5 -5
- package/style/Style.d.ts.map +1 -1
- package/style/Style.js +2 -2
- package/style/Text.d.ts +2 -2
- package/style/Text.d.ts.map +1 -1
- package/style/flat.d.ts.map +1 -1
- package/style/webgl.d.ts.map +1 -1
- package/tilecoord.d.ts +7 -0
- package/tilecoord.d.ts.map +1 -1
- package/tilecoord.js +11 -1
- package/tilegrid/TileGrid.d.ts +1 -1
- package/tilegrid/TileGrid.d.ts.map +1 -1
- package/tilegrid/WMTS.d.ts.map +1 -1
- package/tilegrid/WMTS.js +1 -1
- package/tileurlfunction.d.ts +3 -7
- package/tileurlfunction.d.ts.map +1 -1
- package/tileurlfunction.js +14 -47
- package/transform.d.ts +15 -15
- package/transform.d.ts.map +1 -1
- package/uri.d.ts +23 -3
- package/uri.d.ts.map +1 -1
- package/uri.js +75 -0
- package/util.d.ts.map +1 -1
- package/util.js +1 -1
- package/vec/mat4.d.ts.map +1 -1
- package/webgl/BaseTileRepresentation.d.ts +3 -3
- package/webgl/BaseTileRepresentation.d.ts.map +1 -1
- package/webgl/BaseTileRepresentation.js +9 -2
- package/webgl/Buffer.d.ts.map +1 -1
- package/webgl/Helper.d.ts.map +1 -1
- package/webgl/Helper.js +1 -0
- package/webgl/PostProcessingPass.d.ts +48 -12
- package/webgl/PostProcessingPass.d.ts.map +1 -1
- package/webgl/PostProcessingPass.js +42 -6
- package/webgl/RenderTarget.d.ts.map +1 -1
- package/webgl/ShaderBuilder.d.ts +1 -1
- package/webgl/TileGeometry.d.ts.map +1 -1
- package/webgl/TileGeometry.js +4 -1
- package/webgl/TileTexture.d.ts.map +1 -1
- package/webgl/TileTexture.js +14 -8
- package/webgl/styleparser.d.ts.map +1 -1
- package/webgl/styleparser.js +54 -66
- package/webgl.d.ts.map +1 -1
- package/worker/webgl.js +1 -1
- package/xml.d.ts.map +1 -1
- package/xml.js +27 -39
- package/source/SentinelHub.d.ts +0 -507
- package/source/SentinelHub.d.ts.map +0 -1
- package/source/SentinelHub.js +0 -616
- package/structs/LinkedList.d.ts +0 -130
- package/structs/LinkedList.d.ts.map +0 -1
- package/structs/LinkedList.js +0 -259
package/expr/expression.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @module ol/expr/expression
|
|
3
3
|
*/
|
|
4
4
|
import {ascending} from '../array.js';
|
|
5
|
-
import {
|
|
5
|
+
import {fromString as colorFromString} from '../color.js';
|
|
6
|
+
import {toSize} from '../size.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @fileoverview This module includes types and functions for parsing array encoded expressions.
|
|
@@ -148,6 +149,14 @@ const typeNames = {
|
|
|
148
149
|
|
|
149
150
|
const namedTypes = Object.keys(typeNames).map(Number).sort(ascending);
|
|
150
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @param {number} type The type.
|
|
154
|
+
* @return {boolean} The type is one of the specific types (not any or a union type).
|
|
155
|
+
*/
|
|
156
|
+
function isSpecific(type) {
|
|
157
|
+
return type in typeNames;
|
|
158
|
+
}
|
|
159
|
+
|
|
151
160
|
/**
|
|
152
161
|
* Get a string representation for a type.
|
|
153
162
|
* @param {number} type The type.
|
|
@@ -206,6 +215,11 @@ export class LiteralExpression {
|
|
|
206
215
|
* @param {LiteralValue} value The literal value.
|
|
207
216
|
*/
|
|
208
217
|
constructor(type, value) {
|
|
218
|
+
if (!isSpecific(type)) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
`literal expressions must have a specific type, got ${typeName(type)}`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
209
223
|
this.type = type;
|
|
210
224
|
this.value = value;
|
|
211
225
|
}
|
|
@@ -234,7 +248,6 @@ export class CallExpression {
|
|
|
234
248
|
* @property {Set<string>} properties Properties referenced with the 'get' operator.
|
|
235
249
|
* @property {boolean} featureId The style uses the feature id.
|
|
236
250
|
* @property {boolean} geometryType The style uses the feature geometry type.
|
|
237
|
-
* @property {import("../style/flat.js").FlatStyle|import("../style/webgl.js").WebGLStyle} style The style being parsed
|
|
238
251
|
*/
|
|
239
252
|
|
|
240
253
|
/**
|
|
@@ -246,7 +259,6 @@ export function newParsingContext() {
|
|
|
246
259
|
properties: new Set(),
|
|
247
260
|
featureId: false,
|
|
248
261
|
geometryType: false,
|
|
249
|
-
style: {},
|
|
250
262
|
};
|
|
251
263
|
}
|
|
252
264
|
|
|
@@ -256,31 +268,49 @@ export function newParsingContext() {
|
|
|
256
268
|
|
|
257
269
|
/**
|
|
258
270
|
* @param {EncodedExpression} encoded The encoded expression.
|
|
271
|
+
* @param {number} expectedType The expected type.
|
|
259
272
|
* @param {ParsingContext} context The parsing context.
|
|
260
|
-
* @param {number} [typeHint] Optional type hint
|
|
261
273
|
* @return {Expression} The parsed expression result.
|
|
262
274
|
*/
|
|
263
|
-
export function parse(encoded,
|
|
275
|
+
export function parse(encoded, expectedType, context) {
|
|
264
276
|
switch (typeof encoded) {
|
|
265
277
|
case 'boolean': {
|
|
278
|
+
if (isType(expectedType, StringType)) {
|
|
279
|
+
return new LiteralExpression(StringType, encoded ? 'true' : 'false');
|
|
280
|
+
}
|
|
281
|
+
if (!includesType(expectedType, BooleanType)) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
`got a boolean, but expected ${typeName(expectedType)}`,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
266
286
|
return new LiteralExpression(BooleanType, encoded);
|
|
267
287
|
}
|
|
268
288
|
case 'number': {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
289
|
+
if (isType(expectedType, SizeType)) {
|
|
290
|
+
return new LiteralExpression(SizeType, toSize(encoded));
|
|
291
|
+
}
|
|
292
|
+
if (isType(expectedType, BooleanType)) {
|
|
293
|
+
return new LiteralExpression(BooleanType, !!encoded);
|
|
294
|
+
}
|
|
295
|
+
if (isType(expectedType, StringType)) {
|
|
296
|
+
return new LiteralExpression(StringType, encoded.toString());
|
|
297
|
+
}
|
|
298
|
+
if (!includesType(expectedType, NumberType)) {
|
|
299
|
+
throw new Error(`got a number, but expected ${typeName(expectedType)}`);
|
|
300
|
+
}
|
|
301
|
+
return new LiteralExpression(NumberType, encoded);
|
|
273
302
|
}
|
|
274
303
|
case 'string': {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
304
|
+
if (isType(expectedType, ColorType)) {
|
|
305
|
+
return new LiteralExpression(ColorType, colorFromString(encoded));
|
|
306
|
+
}
|
|
307
|
+
if (isType(expectedType, BooleanType)) {
|
|
308
|
+
return new LiteralExpression(BooleanType, !!encoded);
|
|
278
309
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
type &= typeHint;
|
|
310
|
+
if (!includesType(expectedType, StringType)) {
|
|
311
|
+
throw new Error(`got a string, but expected ${typeName(expectedType)}`);
|
|
282
312
|
}
|
|
283
|
-
return new LiteralExpression(
|
|
313
|
+
return new LiteralExpression(StringType, encoded);
|
|
284
314
|
}
|
|
285
315
|
default: {
|
|
286
316
|
// pass
|
|
@@ -288,33 +318,51 @@ export function parse(encoded, context, typeHint) {
|
|
|
288
318
|
}
|
|
289
319
|
|
|
290
320
|
if (!Array.isArray(encoded)) {
|
|
291
|
-
throw new Error('
|
|
321
|
+
throw new Error('expression must be an array or a primitive value');
|
|
292
322
|
}
|
|
293
323
|
|
|
294
324
|
if (encoded.length === 0) {
|
|
295
|
-
throw new Error('
|
|
325
|
+
throw new Error('empty expression');
|
|
296
326
|
}
|
|
297
327
|
|
|
298
328
|
if (typeof encoded[0] === 'string') {
|
|
299
|
-
return parseCallExpression(encoded,
|
|
329
|
+
return parseCallExpression(encoded, expectedType, context);
|
|
300
330
|
}
|
|
301
331
|
|
|
302
332
|
for (const item of encoded) {
|
|
303
333
|
if (typeof item !== 'number') {
|
|
304
|
-
throw new Error('
|
|
334
|
+
throw new Error('expected an array of numbers');
|
|
305
335
|
}
|
|
306
336
|
}
|
|
307
337
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
338
|
+
if (isType(expectedType, SizeType)) {
|
|
339
|
+
if (encoded.length !== 2) {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`expected an array of two values for a size, got ${encoded.length}`,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
return new LiteralExpression(SizeType, encoded);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (isType(expectedType, ColorType)) {
|
|
348
|
+
if (encoded.length === 3) {
|
|
349
|
+
return new LiteralExpression(ColorType, [...encoded, 1]);
|
|
350
|
+
}
|
|
351
|
+
if (encoded.length === 4) {
|
|
352
|
+
return new LiteralExpression(ColorType, encoded);
|
|
353
|
+
}
|
|
354
|
+
throw new Error(
|
|
355
|
+
`expected an array of 3 or 4 values for a color, got ${encoded.length}`,
|
|
356
|
+
);
|
|
313
357
|
}
|
|
314
|
-
|
|
315
|
-
|
|
358
|
+
|
|
359
|
+
if (!includesType(expectedType, NumberArrayType)) {
|
|
360
|
+
throw new Error(
|
|
361
|
+
`got an array of numbers, but expected ${typeName(expectedType)}`,
|
|
362
|
+
);
|
|
316
363
|
}
|
|
317
|
-
|
|
364
|
+
|
|
365
|
+
return new LiteralExpression(NumberArrayType, encoded);
|
|
318
366
|
}
|
|
319
367
|
|
|
320
368
|
/**
|
|
@@ -369,292 +417,209 @@ export const Ops = {
|
|
|
369
417
|
};
|
|
370
418
|
|
|
371
419
|
/**
|
|
372
|
-
* @typedef {function(Array,
|
|
373
|
-
*
|
|
420
|
+
* @typedef {function(Array, number, ParsingContext):Expression} Parser
|
|
421
|
+
*
|
|
422
|
+
* Second argument is the expected type.
|
|
374
423
|
*/
|
|
375
424
|
|
|
376
425
|
/**
|
|
377
426
|
* @type {Object<string, Parser>}
|
|
378
427
|
*/
|
|
379
428
|
const parsers = {
|
|
380
|
-
[Ops.Get]:
|
|
381
|
-
[Ops.Var]:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
429
|
+
[Ops.Get]: createCallExpressionParser(hasArgsCount(1, Infinity), withGetArgs),
|
|
430
|
+
[Ops.Var]: createCallExpressionParser(hasArgsCount(1, 1), withVarArgs),
|
|
431
|
+
[Ops.Id]: createCallExpressionParser(usesFeatureId, withNoArgs),
|
|
432
|
+
[Ops.Concat]: createCallExpressionParser(
|
|
433
|
+
hasArgsCount(2, Infinity),
|
|
434
|
+
withArgsOfType(StringType),
|
|
385
435
|
),
|
|
386
|
-
[Ops.
|
|
387
|
-
[Ops.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
436
|
+
[Ops.GeometryType]: createCallExpressionParser(usesGeometryType, withNoArgs),
|
|
437
|
+
[Ops.Resolution]: createCallExpressionParser(withNoArgs),
|
|
438
|
+
[Ops.Zoom]: createCallExpressionParser(withNoArgs),
|
|
439
|
+
[Ops.Time]: createCallExpressionParser(withNoArgs),
|
|
440
|
+
[Ops.Any]: createCallExpressionParser(
|
|
441
|
+
hasArgsCount(2, Infinity),
|
|
442
|
+
withArgsOfType(BooleanType),
|
|
391
443
|
),
|
|
392
|
-
[Ops.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
[Ops.Time]: createParser(NumberType, withNoArgs),
|
|
396
|
-
[Ops.Any]: createParser(
|
|
397
|
-
BooleanType,
|
|
398
|
-
withArgsCount(2, Infinity),
|
|
399
|
-
parseArgsOfType(BooleanType),
|
|
444
|
+
[Ops.All]: createCallExpressionParser(
|
|
445
|
+
hasArgsCount(2, Infinity),
|
|
446
|
+
withArgsOfType(BooleanType),
|
|
400
447
|
),
|
|
401
|
-
[Ops.
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
parseArgsOfType(BooleanType),
|
|
448
|
+
[Ops.Not]: createCallExpressionParser(
|
|
449
|
+
hasArgsCount(1, 1),
|
|
450
|
+
withArgsOfType(BooleanType),
|
|
405
451
|
),
|
|
406
|
-
[Ops.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
parseArgsOfType(BooleanType),
|
|
452
|
+
[Ops.Equal]: createCallExpressionParser(
|
|
453
|
+
hasArgsCount(2, 2),
|
|
454
|
+
withArgsOfType(AnyType),
|
|
410
455
|
),
|
|
411
|
-
[Ops.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
parseArgsOfType(AnyType),
|
|
415
|
-
narrowArgsType,
|
|
456
|
+
[Ops.NotEqual]: createCallExpressionParser(
|
|
457
|
+
hasArgsCount(2, 2),
|
|
458
|
+
withArgsOfType(AnyType),
|
|
416
459
|
),
|
|
417
|
-
[Ops.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
parseArgsOfType(AnyType),
|
|
421
|
-
narrowArgsType,
|
|
460
|
+
[Ops.GreaterThan]: createCallExpressionParser(
|
|
461
|
+
hasArgsCount(2, 2),
|
|
462
|
+
withArgsOfType(NumberType),
|
|
422
463
|
),
|
|
423
|
-
[Ops.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
parseArgsOfType(AnyType),
|
|
427
|
-
narrowArgsType,
|
|
464
|
+
[Ops.GreaterThanOrEqualTo]: createCallExpressionParser(
|
|
465
|
+
hasArgsCount(2, 2),
|
|
466
|
+
withArgsOfType(NumberType),
|
|
428
467
|
),
|
|
429
|
-
[Ops.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
parseArgsOfType(AnyType),
|
|
433
|
-
narrowArgsType,
|
|
468
|
+
[Ops.LessThan]: createCallExpressionParser(
|
|
469
|
+
hasArgsCount(2, 2),
|
|
470
|
+
withArgsOfType(NumberType),
|
|
434
471
|
),
|
|
435
|
-
[Ops.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
parseArgsOfType(AnyType),
|
|
439
|
-
narrowArgsType,
|
|
472
|
+
[Ops.LessThanOrEqualTo]: createCallExpressionParser(
|
|
473
|
+
hasArgsCount(2, 2),
|
|
474
|
+
withArgsOfType(NumberType),
|
|
440
475
|
),
|
|
441
|
-
[Ops.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
parseArgsOfType(AnyType),
|
|
445
|
-
narrowArgsType,
|
|
476
|
+
[Ops.Multiply]: createCallExpressionParser(
|
|
477
|
+
hasArgsCount(2, Infinity),
|
|
478
|
+
withArgsOfReturnType,
|
|
446
479
|
),
|
|
447
|
-
[Ops.
|
|
448
|
-
(
|
|
449
|
-
|
|
450
|
-
for (let i = 0; i < parsedArgs.length; i++) {
|
|
451
|
-
outputType &= parsedArgs[i].type;
|
|
452
|
-
}
|
|
453
|
-
return outputType;
|
|
454
|
-
},
|
|
455
|
-
withArgsCount(2, Infinity),
|
|
456
|
-
parseArgsOfType(NumberType | ColorType),
|
|
457
|
-
narrowArgsType,
|
|
480
|
+
[Ops.Coalesce]: createCallExpressionParser(
|
|
481
|
+
hasArgsCount(2, Infinity),
|
|
482
|
+
withArgsOfReturnType,
|
|
458
483
|
),
|
|
459
|
-
[Ops.
|
|
460
|
-
(
|
|
461
|
-
|
|
462
|
-
for (let i = 1; i < parsedArgs.length; i += 2) {
|
|
463
|
-
type &= parsedArgs[i].type;
|
|
464
|
-
}
|
|
465
|
-
type &= parsedArgs[parsedArgs.length - 1].type;
|
|
466
|
-
return type;
|
|
467
|
-
},
|
|
468
|
-
withArgsCount(2, Infinity),
|
|
469
|
-
parseArgsOfType(AnyType),
|
|
470
|
-
narrowArgsType,
|
|
484
|
+
[Ops.Divide]: createCallExpressionParser(
|
|
485
|
+
hasArgsCount(2, 2),
|
|
486
|
+
withArgsOfType(NumberType),
|
|
471
487
|
),
|
|
472
|
-
[Ops.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
parseArgsOfType(NumberType),
|
|
488
|
+
[Ops.Add]: createCallExpressionParser(
|
|
489
|
+
hasArgsCount(2, Infinity),
|
|
490
|
+
withArgsOfType(NumberType),
|
|
476
491
|
),
|
|
477
|
-
[Ops.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
parseArgsOfType(NumberType),
|
|
492
|
+
[Ops.Subtract]: createCallExpressionParser(
|
|
493
|
+
hasArgsCount(2, 2),
|
|
494
|
+
withArgsOfType(NumberType),
|
|
481
495
|
),
|
|
482
|
-
[Ops.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
parseArgsOfType(NumberType),
|
|
496
|
+
[Ops.Clamp]: createCallExpressionParser(
|
|
497
|
+
hasArgsCount(3, 3),
|
|
498
|
+
withArgsOfType(NumberType),
|
|
486
499
|
),
|
|
487
|
-
[Ops.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
parseArgsOfType(NumberType),
|
|
500
|
+
[Ops.Mod]: createCallExpressionParser(
|
|
501
|
+
hasArgsCount(2, 2),
|
|
502
|
+
withArgsOfType(NumberType),
|
|
491
503
|
),
|
|
492
|
-
[Ops.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
parseArgsOfType(NumberType),
|
|
504
|
+
[Ops.Pow]: createCallExpressionParser(
|
|
505
|
+
hasArgsCount(2, 2),
|
|
506
|
+
withArgsOfType(NumberType),
|
|
496
507
|
),
|
|
497
|
-
[Ops.
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
parseArgsOfType(NumberType),
|
|
508
|
+
[Ops.Abs]: createCallExpressionParser(
|
|
509
|
+
hasArgsCount(1, 1),
|
|
510
|
+
withArgsOfType(NumberType),
|
|
501
511
|
),
|
|
502
|
-
[Ops.
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
parseArgsOfType(NumberType),
|
|
512
|
+
[Ops.Floor]: createCallExpressionParser(
|
|
513
|
+
hasArgsCount(1, 1),
|
|
514
|
+
withArgsOfType(NumberType),
|
|
506
515
|
),
|
|
507
|
-
[Ops.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
parseArgsOfType(NumberType),
|
|
516
|
+
[Ops.Ceil]: createCallExpressionParser(
|
|
517
|
+
hasArgsCount(1, 1),
|
|
518
|
+
withArgsOfType(NumberType),
|
|
511
519
|
),
|
|
512
|
-
[Ops.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
parseArgsOfType(NumberType),
|
|
520
|
+
[Ops.Round]: createCallExpressionParser(
|
|
521
|
+
hasArgsCount(1, 1),
|
|
522
|
+
withArgsOfType(NumberType),
|
|
516
523
|
),
|
|
517
|
-
[Ops.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
parseArgsOfType(NumberType),
|
|
524
|
+
[Ops.Sin]: createCallExpressionParser(
|
|
525
|
+
hasArgsCount(1, 1),
|
|
526
|
+
withArgsOfType(NumberType),
|
|
521
527
|
),
|
|
522
|
-
[Ops.
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
parseArgsOfType(NumberType),
|
|
528
|
+
[Ops.Cos]: createCallExpressionParser(
|
|
529
|
+
hasArgsCount(1, 1),
|
|
530
|
+
withArgsOfType(NumberType),
|
|
526
531
|
),
|
|
527
|
-
[Ops.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
parseArgsOfType(NumberType),
|
|
532
|
+
[Ops.Atan]: createCallExpressionParser(
|
|
533
|
+
hasArgsCount(1, 2),
|
|
534
|
+
withArgsOfType(NumberType),
|
|
531
535
|
),
|
|
532
|
-
[Ops.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
parseArgsOfType(NumberType),
|
|
536
|
+
[Ops.Sqrt]: createCallExpressionParser(
|
|
537
|
+
hasArgsCount(1, 1),
|
|
538
|
+
withArgsOfType(NumberType),
|
|
536
539
|
),
|
|
537
|
-
[Ops.
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
540
|
+
[Ops.Match]: createCallExpressionParser(
|
|
541
|
+
hasArgsCount(4, Infinity),
|
|
542
|
+
hasEvenArgs,
|
|
543
|
+
withMatchArgs,
|
|
541
544
|
),
|
|
542
|
-
[Ops.
|
|
543
|
-
(
|
|
544
|
-
|
|
545
|
-
for (let i = 2; i < parsedArgs.length; i += 2) {
|
|
546
|
-
type &= parsedArgs[i].type;
|
|
547
|
-
}
|
|
548
|
-
type &= parsedArgs[parsedArgs.length - 1].type;
|
|
549
|
-
return type;
|
|
550
|
-
},
|
|
551
|
-
withArgsCount(4, Infinity),
|
|
552
|
-
withEvenArgs,
|
|
553
|
-
parseMatchArgs,
|
|
545
|
+
[Ops.Between]: createCallExpressionParser(
|
|
546
|
+
hasArgsCount(3, 3),
|
|
547
|
+
withArgsOfType(NumberType),
|
|
554
548
|
),
|
|
555
|
-
[Ops.
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
549
|
+
[Ops.Interpolate]: createCallExpressionParser(
|
|
550
|
+
hasArgsCount(6, Infinity),
|
|
551
|
+
hasEvenArgs,
|
|
552
|
+
withInterpolateArgs,
|
|
559
553
|
),
|
|
560
|
-
[Ops.
|
|
561
|
-
(
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
type &= parsedArgs[i].type;
|
|
565
|
-
}
|
|
566
|
-
return type;
|
|
567
|
-
},
|
|
568
|
-
withArgsCount(6, Infinity),
|
|
569
|
-
withEvenArgs,
|
|
570
|
-
parseInterpolateArgs,
|
|
554
|
+
[Ops.Case]: createCallExpressionParser(
|
|
555
|
+
hasArgsCount(3, Infinity),
|
|
556
|
+
hasOddArgs,
|
|
557
|
+
withCaseArgs,
|
|
571
558
|
),
|
|
572
|
-
[Ops.
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
type &= parsedArgs[i].type;
|
|
577
|
-
}
|
|
578
|
-
type &= parsedArgs[parsedArgs.length - 1].type;
|
|
579
|
-
return type;
|
|
580
|
-
},
|
|
581
|
-
withArgsCount(3, Infinity),
|
|
582
|
-
withOddArgs,
|
|
583
|
-
parseCaseArgs,
|
|
559
|
+
[Ops.In]: createCallExpressionParser(hasArgsCount(2, 2), withInArgs),
|
|
560
|
+
[Ops.Number]: createCallExpressionParser(
|
|
561
|
+
hasArgsCount(1, Infinity),
|
|
562
|
+
withArgsOfType(AnyType),
|
|
584
563
|
),
|
|
585
|
-
[Ops.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
withArgsCount(1, Infinity),
|
|
589
|
-
parseArgsOfType(AnyType),
|
|
564
|
+
[Ops.String]: createCallExpressionParser(
|
|
565
|
+
hasArgsCount(1, Infinity),
|
|
566
|
+
withArgsOfType(AnyType),
|
|
590
567
|
),
|
|
591
|
-
[Ops.
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
parseArgsOfType(AnyType),
|
|
568
|
+
[Ops.Array]: createCallExpressionParser(
|
|
569
|
+
hasArgsCount(1, Infinity),
|
|
570
|
+
withArgsOfType(NumberType),
|
|
595
571
|
),
|
|
596
|
-
[Ops.
|
|
597
|
-
(
|
|
598
|
-
|
|
599
|
-
? NumberArrayType | SizeType
|
|
600
|
-
: parsedArgs.length === 3 || parsedArgs.length === 4
|
|
601
|
-
? NumberArrayType | ColorType
|
|
602
|
-
: NumberArrayType;
|
|
603
|
-
},
|
|
604
|
-
withArgsCount(1, Infinity),
|
|
605
|
-
parseArgsOfType(NumberType),
|
|
572
|
+
[Ops.Color]: createCallExpressionParser(
|
|
573
|
+
hasArgsCount(1, 4),
|
|
574
|
+
withArgsOfType(NumberType),
|
|
606
575
|
),
|
|
607
|
-
[Ops.
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
parseArgsOfType(NumberType),
|
|
576
|
+
[Ops.Band]: createCallExpressionParser(
|
|
577
|
+
hasArgsCount(1, 3),
|
|
578
|
+
withArgsOfType(NumberType),
|
|
611
579
|
),
|
|
612
|
-
[Ops.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
parseArgsOfType(NumberType),
|
|
580
|
+
[Ops.Palette]: createCallExpressionParser(
|
|
581
|
+
hasArgsCount(2, 2),
|
|
582
|
+
withPaletteArgs,
|
|
616
583
|
),
|
|
617
|
-
[Ops.
|
|
618
|
-
|
|
619
|
-
StringType,
|
|
620
|
-
withArgsCount(1, 1),
|
|
621
|
-
parseArgsOfType(BooleanType | NumberType | StringType | ColorType),
|
|
584
|
+
[Ops.ToString]: createCallExpressionParser(
|
|
585
|
+
hasArgsCount(1, 1),
|
|
586
|
+
withArgsOfType(BooleanType | NumberType | StringType | ColorType),
|
|
622
587
|
),
|
|
623
588
|
};
|
|
624
589
|
|
|
625
590
|
/**
|
|
626
|
-
* @typedef {function(Array<EncodedExpression>,
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* Fourth argument is an optional type hint
|
|
591
|
+
* @typedef {function(Array<EncodedExpression>, number, ParsingContext):Array<Expression>|void} ArgValidator
|
|
592
|
+
*
|
|
593
|
+
* An argument validator applies various checks to an encoded expression arguments and
|
|
594
|
+
* returns the parsed arguments if any. The second argument is the return type of the call expression.
|
|
631
595
|
*/
|
|
632
596
|
|
|
633
597
|
/**
|
|
634
598
|
* @type ArgValidator
|
|
635
599
|
*/
|
|
636
|
-
function withGetArgs(encoded, context) {
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
600
|
+
function withGetArgs(encoded, returnType, context) {
|
|
601
|
+
const argsCount = encoded.length - 1;
|
|
602
|
+
const args = new Array(argsCount);
|
|
603
|
+
for (let i = 0; i < argsCount; ++i) {
|
|
604
|
+
const key = encoded[i + 1];
|
|
605
|
+
switch (typeof key) {
|
|
606
|
+
case 'number': {
|
|
607
|
+
args[i] = new LiteralExpression(NumberType, key);
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
case 'string': {
|
|
611
|
+
args[i] = new LiteralExpression(StringType, key);
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
default: {
|
|
646
615
|
throw new Error(
|
|
647
|
-
|
|
616
|
+
`expected a string key or numeric array index for a get operation, got ${key}`,
|
|
648
617
|
);
|
|
649
618
|
}
|
|
650
|
-
continue;
|
|
651
619
|
}
|
|
652
|
-
if (
|
|
653
|
-
|
|
654
|
-
'Expected the attribute name of a get operation to be a string',
|
|
655
|
-
);
|
|
620
|
+
if (i === 0) {
|
|
621
|
+
context.properties.add(String(key));
|
|
656
622
|
}
|
|
657
|
-
context.properties.add(String(arg.value));
|
|
658
623
|
}
|
|
659
624
|
return args;
|
|
660
625
|
}
|
|
@@ -662,52 +627,37 @@ function withGetArgs(encoded, context) {
|
|
|
662
627
|
/**
|
|
663
628
|
* @type ArgValidator
|
|
664
629
|
*/
|
|
665
|
-
function withVarArgs(encoded,
|
|
666
|
-
const
|
|
667
|
-
if (typeof
|
|
668
|
-
throw new Error('
|
|
630
|
+
function withVarArgs(encoded, returnType, context) {
|
|
631
|
+
const name = encoded[1];
|
|
632
|
+
if (typeof name !== 'string') {
|
|
633
|
+
throw new Error('expected a string argument for var operation');
|
|
669
634
|
}
|
|
670
|
-
context.variables.add(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
context.style.variables[varName] === undefined
|
|
674
|
-
) {
|
|
675
|
-
return [new LiteralExpression(AnyType, varName)];
|
|
676
|
-
}
|
|
677
|
-
const initialValue = context.style.variables[varName];
|
|
678
|
-
const arg = /** @type {LiteralExpression} */ (parse(initialValue, context));
|
|
679
|
-
arg.value = varName;
|
|
680
|
-
if (typeHint && !overlapsType(typeHint, arg.type)) {
|
|
681
|
-
throw new Error(
|
|
682
|
-
`The variable ${varName} has type ${typeName(
|
|
683
|
-
arg.type,
|
|
684
|
-
)} but the following type was expected: ${typeName(typeHint)}`,
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
|
-
return [arg];
|
|
635
|
+
context.variables.add(name);
|
|
636
|
+
|
|
637
|
+
return [new LiteralExpression(StringType, name)];
|
|
688
638
|
}
|
|
689
639
|
|
|
690
640
|
/**
|
|
691
641
|
* @type ArgValidator
|
|
692
642
|
*/
|
|
693
|
-
function usesFeatureId(encoded, context) {
|
|
643
|
+
function usesFeatureId(encoded, returnType, context) {
|
|
694
644
|
context.featureId = true;
|
|
695
645
|
}
|
|
696
646
|
|
|
697
647
|
/**
|
|
698
648
|
* @type ArgValidator
|
|
699
649
|
*/
|
|
700
|
-
function usesGeometryType(encoded, context) {
|
|
650
|
+
function usesGeometryType(encoded, returnType, context) {
|
|
701
651
|
context.geometryType = true;
|
|
702
652
|
}
|
|
703
653
|
|
|
704
654
|
/**
|
|
705
655
|
* @type ArgValidator
|
|
706
656
|
*/
|
|
707
|
-
function withNoArgs(encoded, context) {
|
|
657
|
+
function withNoArgs(encoded, returnType, context) {
|
|
708
658
|
const operation = encoded[0];
|
|
709
659
|
if (encoded.length !== 1) {
|
|
710
|
-
throw new Error(`
|
|
660
|
+
throw new Error(`expected no arguments for ${operation} operation`);
|
|
711
661
|
}
|
|
712
662
|
return [];
|
|
713
663
|
}
|
|
@@ -717,15 +667,15 @@ function withNoArgs(encoded, context) {
|
|
|
717
667
|
* @param {number} maxArgs The maximum number of arguments.
|
|
718
668
|
* @return {ArgValidator} The argument validator
|
|
719
669
|
*/
|
|
720
|
-
function
|
|
721
|
-
return function (encoded, context) {
|
|
670
|
+
function hasArgsCount(minArgs, maxArgs) {
|
|
671
|
+
return function (encoded, returnType, context) {
|
|
722
672
|
const operation = encoded[0];
|
|
723
673
|
const argCount = encoded.length - 1;
|
|
724
674
|
if (minArgs === maxArgs) {
|
|
725
675
|
if (argCount !== minArgs) {
|
|
726
676
|
const plural = minArgs === 1 ? '' : 's';
|
|
727
677
|
throw new Error(
|
|
728
|
-
`
|
|
678
|
+
`expected ${minArgs} argument${plural} for ${operation}, got ${argCount}`,
|
|
729
679
|
);
|
|
730
680
|
}
|
|
731
681
|
} else if (argCount < minArgs || argCount > maxArgs) {
|
|
@@ -734,35 +684,41 @@ function withArgsCount(minArgs, maxArgs) {
|
|
|
734
684
|
? `${minArgs} or more`
|
|
735
685
|
: `${minArgs} to ${maxArgs}`;
|
|
736
686
|
throw new Error(
|
|
737
|
-
`
|
|
687
|
+
`expected ${range} arguments for ${operation}, got ${argCount}`,
|
|
738
688
|
);
|
|
739
689
|
}
|
|
740
690
|
};
|
|
741
691
|
}
|
|
742
692
|
|
|
693
|
+
/**
|
|
694
|
+
* @type {ArgValidator}
|
|
695
|
+
*/
|
|
696
|
+
function withArgsOfReturnType(encoded, returnType, context) {
|
|
697
|
+
const argCount = encoded.length - 1;
|
|
698
|
+
/**
|
|
699
|
+
* @type {Array<Expression>}
|
|
700
|
+
*/
|
|
701
|
+
const args = new Array(argCount);
|
|
702
|
+
for (let i = 0; i < argCount; ++i) {
|
|
703
|
+
const expression = parse(encoded[i + 1], returnType, context);
|
|
704
|
+
args[i] = expression;
|
|
705
|
+
}
|
|
706
|
+
return args;
|
|
707
|
+
}
|
|
708
|
+
|
|
743
709
|
/**
|
|
744
710
|
* @param {number} argType The argument type.
|
|
745
711
|
* @return {ArgValidator} The argument validator
|
|
746
712
|
*/
|
|
747
|
-
function
|
|
748
|
-
return function (encoded, context) {
|
|
749
|
-
const operation = encoded[0];
|
|
713
|
+
function withArgsOfType(argType) {
|
|
714
|
+
return function (encoded, returnType, context) {
|
|
750
715
|
const argCount = encoded.length - 1;
|
|
751
716
|
/**
|
|
752
717
|
* @type {Array<Expression>}
|
|
753
718
|
*/
|
|
754
719
|
const args = new Array(argCount);
|
|
755
720
|
for (let i = 0; i < argCount; ++i) {
|
|
756
|
-
const expression = parse(encoded[i + 1], context);
|
|
757
|
-
if (!overlapsType(argType, expression.type)) {
|
|
758
|
-
const gotType = typeName(argType);
|
|
759
|
-
const expectedType = typeName(expression.type);
|
|
760
|
-
throw new Error(
|
|
761
|
-
`Unexpected type for argument ${i} of ${operation} operation` +
|
|
762
|
-
`, got ${gotType} but expected ${expectedType}`,
|
|
763
|
-
);
|
|
764
|
-
}
|
|
765
|
-
expression.type &= argType;
|
|
721
|
+
const expression = parse(encoded[i + 1], argType, context);
|
|
766
722
|
args[i] = expression;
|
|
767
723
|
}
|
|
768
724
|
return args;
|
|
@@ -772,41 +728,12 @@ function parseArgsOfType(argType) {
|
|
|
772
728
|
/**
|
|
773
729
|
* @type {ArgValidator}
|
|
774
730
|
*/
|
|
775
|
-
function
|
|
776
|
-
const operation = encoded[0];
|
|
777
|
-
const argCount = encoded.length - 1;
|
|
778
|
-
|
|
779
|
-
// first pass to determine a narrowed down type
|
|
780
|
-
let sameType = AnyType;
|
|
781
|
-
for (let i = 0; i < parsedArgs.length; ++i) {
|
|
782
|
-
sameType &= parsedArgs[i].type;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
if (sameType === NoneType) {
|
|
786
|
-
throw new Error(
|
|
787
|
-
`No common type could be found for arguments of ${operation} operation`,
|
|
788
|
-
);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
// re-parse args
|
|
792
|
-
const args = new Array(argCount);
|
|
793
|
-
for (let i = 0; i < argCount; ++i) {
|
|
794
|
-
args[i] = parse(encoded[i + 1], context, sameType);
|
|
795
|
-
}
|
|
796
|
-
return args;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* @type {ArgValidator}
|
|
801
|
-
*/
|
|
802
|
-
function withOddArgs(encoded, context) {
|
|
731
|
+
function hasOddArgs(encoded, returnType, context) {
|
|
803
732
|
const operation = encoded[0];
|
|
804
733
|
const argCount = encoded.length - 1;
|
|
805
734
|
if (argCount % 2 === 0) {
|
|
806
735
|
throw new Error(
|
|
807
|
-
`
|
|
808
|
-
argCount,
|
|
809
|
-
)} instead`,
|
|
736
|
+
`expected an odd number of arguments for ${operation}, got ${argCount} instead`,
|
|
810
737
|
);
|
|
811
738
|
}
|
|
812
739
|
}
|
|
@@ -814,14 +741,12 @@ function withOddArgs(encoded, context) {
|
|
|
814
741
|
/**
|
|
815
742
|
* @type {ArgValidator}
|
|
816
743
|
*/
|
|
817
|
-
function
|
|
744
|
+
function hasEvenArgs(encoded, returnType, context) {
|
|
818
745
|
const operation = encoded[0];
|
|
819
746
|
const argCount = encoded.length - 1;
|
|
820
747
|
if (argCount % 2 === 1) {
|
|
821
748
|
throw new Error(
|
|
822
|
-
`
|
|
823
|
-
argCount,
|
|
824
|
-
)} instead`,
|
|
749
|
+
`expected an even number of arguments for operation ${operation}, got ${argCount} instead`,
|
|
825
750
|
);
|
|
826
751
|
}
|
|
827
752
|
}
|
|
@@ -829,119 +754,96 @@ function withEvenArgs(encoded, context) {
|
|
|
829
754
|
/**
|
|
830
755
|
* @type ArgValidator
|
|
831
756
|
*/
|
|
832
|
-
function
|
|
757
|
+
function withMatchArgs(encoded, returnType, context) {
|
|
833
758
|
const argsCount = encoded.length - 1;
|
|
834
759
|
|
|
835
|
-
const
|
|
836
|
-
let inputType = input.type;
|
|
837
|
-
const fallback = parse(encoded[encoded.length - 1], context, typeHint);
|
|
838
|
-
let outputType =
|
|
839
|
-
typeHint !== undefined ? typeHint & fallback.type : fallback.type;
|
|
760
|
+
const inputType = StringType | NumberType | BooleanType;
|
|
840
761
|
|
|
841
|
-
|
|
842
|
-
const args = new Array(argsCount - 2);
|
|
843
|
-
for (let i = 0; i < argsCount - 2; i += 2) {
|
|
844
|
-
const match = parse(encoded[i + 2], context);
|
|
845
|
-
const output = parse(encoded[i + 3], context, typeHint);
|
|
846
|
-
inputType &= match.type;
|
|
847
|
-
outputType &= output.type;
|
|
848
|
-
args[i] = match;
|
|
849
|
-
args[i + 1] = output;
|
|
850
|
-
}
|
|
762
|
+
const input = parse(encoded[1], inputType, context);
|
|
851
763
|
|
|
852
|
-
|
|
853
|
-
const expectedInputType = StringType | NumberType | BooleanType;
|
|
854
|
-
if (!overlapsType(expectedInputType, inputType)) {
|
|
855
|
-
throw new Error(
|
|
856
|
-
`Expected an input of type ${typeName(
|
|
857
|
-
expectedInputType,
|
|
858
|
-
)} for the interpolate operation` +
|
|
859
|
-
`, got ${typeName(inputType)} instead`,
|
|
860
|
-
);
|
|
861
|
-
}
|
|
862
|
-
inputType &= expectedInputType;
|
|
863
|
-
if (isType(outputType, NoneType)) {
|
|
864
|
-
throw new Error(
|
|
865
|
-
`Could not find a common output type for the following match operation: ` +
|
|
866
|
-
JSON.stringify(encoded),
|
|
867
|
-
);
|
|
868
|
-
}
|
|
764
|
+
const fallback = parse(encoded[encoded.length - 1], returnType, context);
|
|
869
765
|
|
|
870
|
-
|
|
766
|
+
const args = new Array(argsCount - 2);
|
|
871
767
|
for (let i = 0; i < argsCount - 2; i += 2) {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
768
|
+
try {
|
|
769
|
+
const match = parse(encoded[i + 2], input.type, context);
|
|
770
|
+
args[i] = match;
|
|
771
|
+
} catch (err) {
|
|
772
|
+
throw new Error(
|
|
773
|
+
`failed to parse argument ${i + 1} of match expression: ${err.message}`,
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
try {
|
|
777
|
+
const output = parse(encoded[i + 3], fallback.type, context);
|
|
778
|
+
args[i + 1] = output;
|
|
779
|
+
} catch (err) {
|
|
780
|
+
throw new Error(
|
|
781
|
+
`failed to parse argument ${i + 2} of match expression: ${err.message}`,
|
|
782
|
+
);
|
|
783
|
+
}
|
|
876
784
|
}
|
|
877
785
|
|
|
878
|
-
return [
|
|
879
|
-
parse(encoded[1], context, inputType),
|
|
880
|
-
...args,
|
|
881
|
-
parse(encoded[encoded.length - 1], context, outputType),
|
|
882
|
-
];
|
|
786
|
+
return [input, ...args, fallback];
|
|
883
787
|
}
|
|
884
788
|
|
|
885
789
|
/**
|
|
886
790
|
* @type ArgValidator
|
|
887
791
|
*/
|
|
888
|
-
function
|
|
792
|
+
function withInterpolateArgs(encoded, returnType, context) {
|
|
889
793
|
const interpolationType = encoded[1];
|
|
890
|
-
|
|
794
|
+
/**
|
|
795
|
+
* @type {number}
|
|
796
|
+
*/
|
|
797
|
+
let base;
|
|
891
798
|
switch (interpolationType[0]) {
|
|
892
799
|
case 'linear':
|
|
893
|
-
|
|
800
|
+
base = 1;
|
|
894
801
|
break;
|
|
895
802
|
case 'exponential':
|
|
896
|
-
|
|
897
|
-
if (typeof
|
|
803
|
+
const b = interpolationType[1];
|
|
804
|
+
if (typeof b !== 'number' || b <= 0) {
|
|
898
805
|
throw new Error(
|
|
899
|
-
`
|
|
900
|
-
`, got ${JSON.stringify(
|
|
806
|
+
`expected a number base for exponential interpolation` +
|
|
807
|
+
`, got ${JSON.stringify(b)} instead`,
|
|
901
808
|
);
|
|
902
809
|
}
|
|
810
|
+
base = b;
|
|
903
811
|
break;
|
|
904
812
|
default:
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
throw new Error(
|
|
909
|
-
`Invalid interpolation type: ${JSON.stringify(interpolationType)}`,
|
|
910
|
-
);
|
|
813
|
+
throw new Error(
|
|
814
|
+
`invalid interpolation type: ${JSON.stringify(interpolationType)}`,
|
|
815
|
+
);
|
|
911
816
|
}
|
|
912
|
-
interpolation = parse(interpolation, context);
|
|
913
817
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
818
|
+
const interpolation = new LiteralExpression(NumberType, base);
|
|
819
|
+
|
|
820
|
+
let input;
|
|
821
|
+
try {
|
|
822
|
+
input = parse(encoded[2], NumberType, context);
|
|
823
|
+
} catch (err) {
|
|
917
824
|
throw new Error(
|
|
918
|
-
`
|
|
919
|
-
`, got ${typeName(input.type)} instead`,
|
|
825
|
+
`failed to parse argument 1 in interpolate expression: ${err.message}`,
|
|
920
826
|
);
|
|
921
827
|
}
|
|
922
|
-
input = parse(encoded[2], context, NumberType); // parse again with narrower output
|
|
923
828
|
|
|
924
829
|
const args = new Array(encoded.length - 3);
|
|
925
830
|
for (let i = 0; i < args.length; i += 2) {
|
|
926
|
-
|
|
927
|
-
|
|
831
|
+
try {
|
|
832
|
+
const stop = parse(encoded[i + 3], NumberType, context);
|
|
833
|
+
args[i] = stop;
|
|
834
|
+
} catch (err) {
|
|
928
835
|
throw new Error(
|
|
929
|
-
`
|
|
930
|
-
`, got ${typeName(stop.type)} at position ${i + 2} instead`,
|
|
836
|
+
`failed to parse argument ${i + 2} for interpolate expression: ${err.message}`,
|
|
931
837
|
);
|
|
932
838
|
}
|
|
933
|
-
|
|
934
|
-
|
|
839
|
+
try {
|
|
840
|
+
const output = parse(encoded[i + 4], returnType, context);
|
|
841
|
+
args[i + 1] = output;
|
|
842
|
+
} catch (err) {
|
|
935
843
|
throw new Error(
|
|
936
|
-
`
|
|
937
|
-
`, got ${typeName(output.type)} at position ${i + 3} instead`,
|
|
844
|
+
`failed to parse argument ${i + 3} for interpolate expression: ${err.message}`,
|
|
938
845
|
);
|
|
939
846
|
}
|
|
940
|
-
// parse again with narrower types
|
|
941
|
-
stop = parse(encoded[i + 3], context, NumberType);
|
|
942
|
-
output = parse(encoded[i + 4], context, NumberType | ColorType);
|
|
943
|
-
args[i] = stop;
|
|
944
|
-
args[i + 1] = output;
|
|
945
847
|
}
|
|
946
848
|
|
|
947
849
|
return [interpolation, input, ...args];
|
|
@@ -950,119 +852,109 @@ function parseInterpolateArgs(encoded, context, parsedArgs, typeHint) {
|
|
|
950
852
|
/**
|
|
951
853
|
* @type ArgValidator
|
|
952
854
|
*/
|
|
953
|
-
function
|
|
954
|
-
const fallback = parse(encoded[encoded.length - 1],
|
|
955
|
-
let outputType =
|
|
956
|
-
typeHint !== undefined ? typeHint & fallback.type : fallback.type;
|
|
855
|
+
function withCaseArgs(encoded, returnType, context) {
|
|
856
|
+
const fallback = parse(encoded[encoded.length - 1], returnType, context);
|
|
957
857
|
|
|
958
|
-
// first parse args to figure out possible types
|
|
959
858
|
const args = new Array(encoded.length - 1);
|
|
960
859
|
for (let i = 0; i < args.length - 1; i += 2) {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
860
|
+
try {
|
|
861
|
+
const condition = parse(encoded[i + 1], BooleanType, context);
|
|
862
|
+
args[i] = condition;
|
|
863
|
+
} catch (err) {
|
|
964
864
|
throw new Error(
|
|
965
|
-
`
|
|
966
|
-
|
|
865
|
+
`failed to parse argument ${i} of case expression: ${err.message}`,
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
try {
|
|
869
|
+
const output = parse(encoded[i + 2], fallback.type, context);
|
|
870
|
+
args[i + 1] = output;
|
|
871
|
+
} catch (err) {
|
|
872
|
+
throw new Error(
|
|
873
|
+
`failed to parse argument ${i + 1} of case expression: ${err.message}`,
|
|
967
874
|
);
|
|
968
875
|
}
|
|
969
|
-
outputType &= output.type;
|
|
970
|
-
args[i] = condition;
|
|
971
|
-
args[i + 1] = output;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
if (isType(outputType, NoneType)) {
|
|
975
|
-
throw new Error(
|
|
976
|
-
`Could not find a common output type for the following case operation: ` +
|
|
977
|
-
JSON.stringify(encoded),
|
|
978
|
-
);
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
// parse again args with common output type
|
|
982
|
-
for (let i = 0; i < args.length - 1; i += 2) {
|
|
983
|
-
args[i + 1] = parse(encoded[i + 2], context, outputType);
|
|
984
876
|
}
|
|
985
|
-
args[args.length - 1] = parse(
|
|
986
|
-
encoded[encoded.length - 1],
|
|
987
|
-
context,
|
|
988
|
-
outputType,
|
|
989
|
-
);
|
|
990
877
|
|
|
878
|
+
args[args.length - 1] = fallback;
|
|
991
879
|
return args;
|
|
992
880
|
}
|
|
993
881
|
|
|
994
882
|
/**
|
|
995
883
|
* @type ArgValidator
|
|
996
884
|
*/
|
|
997
|
-
function
|
|
998
|
-
|
|
999
|
-
let haystack = /** @type {any} */ (encoded[2]);
|
|
885
|
+
function withInArgs(encoded, returnType, context) {
|
|
886
|
+
let haystack = encoded[2];
|
|
1000
887
|
if (!Array.isArray(haystack)) {
|
|
1001
888
|
throw new Error(
|
|
1002
|
-
`
|
|
889
|
+
`the second argument for the "in" operator must be an array`,
|
|
1003
890
|
);
|
|
1004
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* @type {number}
|
|
894
|
+
*/
|
|
895
|
+
let needleType;
|
|
1005
896
|
if (typeof haystack[0] === 'string') {
|
|
1006
897
|
if (haystack[0] !== 'literal') {
|
|
1007
898
|
throw new Error(
|
|
1008
|
-
`
|
|
899
|
+
`for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions`,
|
|
1009
900
|
);
|
|
1010
901
|
}
|
|
1011
902
|
if (!Array.isArray(haystack[1])) {
|
|
1012
903
|
throw new Error(
|
|
1013
|
-
`
|
|
904
|
+
`failed to parse "in" expression: the literal operator must be followed by an array`,
|
|
1014
905
|
);
|
|
1015
906
|
}
|
|
1016
907
|
haystack = haystack[1];
|
|
908
|
+
needleType = StringType;
|
|
909
|
+
} else {
|
|
910
|
+
needleType = NumberType;
|
|
1017
911
|
}
|
|
1018
912
|
|
|
1019
|
-
let needleType = StringType | NumberType;
|
|
1020
913
|
const args = new Array(haystack.length);
|
|
1021
914
|
for (let i = 0; i < args.length; i++) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
);
|
|
915
|
+
try {
|
|
916
|
+
const arg = parse(haystack[i], needleType, context);
|
|
917
|
+
args[i] = arg;
|
|
918
|
+
} catch (err) {
|
|
919
|
+
throw new Error(
|
|
920
|
+
`failed to parse haystack item ${i} for "in" expression: ${err.message}`,
|
|
921
|
+
);
|
|
922
|
+
}
|
|
1031
923
|
}
|
|
1032
924
|
|
|
1033
|
-
const needle = parse(encoded[1],
|
|
925
|
+
const needle = parse(encoded[1], needleType, context);
|
|
1034
926
|
return [needle, ...args];
|
|
1035
927
|
}
|
|
1036
928
|
|
|
1037
929
|
/**
|
|
1038
930
|
* @type ArgValidator
|
|
1039
931
|
*/
|
|
1040
|
-
function
|
|
1041
|
-
|
|
1042
|
-
|
|
932
|
+
function withPaletteArgs(encoded, returnType, context) {
|
|
933
|
+
let index;
|
|
934
|
+
try {
|
|
935
|
+
index = parse(encoded[1], NumberType, context);
|
|
936
|
+
} catch (err) {
|
|
1043
937
|
throw new Error(
|
|
1044
|
-
`
|
|
1045
|
-
index.type,
|
|
1046
|
-
)} instead`,
|
|
938
|
+
`failed to parse first argument in palette expression: ${err.message}`,
|
|
1047
939
|
);
|
|
1048
940
|
}
|
|
1049
941
|
const colors = encoded[2];
|
|
1050
942
|
if (!Array.isArray(colors)) {
|
|
1051
|
-
throw new Error('
|
|
943
|
+
throw new Error('the second argument of palette must be an array');
|
|
1052
944
|
}
|
|
1053
945
|
const parsedColors = new Array(colors.length);
|
|
1054
946
|
for (let i = 0; i < parsedColors.length; i++) {
|
|
1055
|
-
|
|
1056
|
-
|
|
947
|
+
let color;
|
|
948
|
+
try {
|
|
949
|
+
color = parse(colors[i], ColorType, context);
|
|
950
|
+
} catch (err) {
|
|
1057
951
|
throw new Error(
|
|
1058
|
-
`
|
|
952
|
+
`failed to parse color at index ${i} in palette expression: ${err.message}`,
|
|
1059
953
|
);
|
|
1060
954
|
}
|
|
1061
|
-
if (!
|
|
955
|
+
if (!(color instanceof LiteralExpression)) {
|
|
1062
956
|
throw new Error(
|
|
1063
|
-
`
|
|
1064
|
-
color.type,
|
|
1065
|
-
)} instead`,
|
|
957
|
+
`the palette color at index ${i} must be a literal value`,
|
|
1066
958
|
);
|
|
1067
959
|
}
|
|
1068
960
|
parsedColors[i] = color;
|
|
@@ -1071,59 +963,47 @@ function parsePaletteArgs(encoded, context) {
|
|
|
1071
963
|
}
|
|
1072
964
|
|
|
1073
965
|
/**
|
|
1074
|
-
* @param {
|
|
1075
|
-
* arguments
|
|
1076
|
-
* @param {Array<ArgValidator>} argValidators A chain of argument validators; the return value of the last validator
|
|
1077
|
-
* will be used as parsed arguments
|
|
966
|
+
* @param {Array<ArgValidator>} validators A chain of argument validators. The last validator is expected
|
|
967
|
+
* to return the parsed arguments.
|
|
1078
968
|
* @return {Parser} The parser.
|
|
1079
969
|
*/
|
|
1080
|
-
function
|
|
1081
|
-
return function (encoded,
|
|
970
|
+
function createCallExpressionParser(...validators) {
|
|
971
|
+
return function (encoded, returnType, context) {
|
|
1082
972
|
const operator = encoded[0];
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
let
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
)}`,
|
|
1098
|
-
);
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* @type {Array<Expression>}
|
|
976
|
+
*/
|
|
977
|
+
let args;
|
|
978
|
+
for (let i = 0; i < validators.length; i++) {
|
|
979
|
+
const parsed = validators[i](encoded, returnType, context);
|
|
980
|
+
if (i == validators.length - 1) {
|
|
981
|
+
if (!parsed) {
|
|
982
|
+
throw new Error(
|
|
983
|
+
'expected last argument validator to return the parsed args',
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
args = parsed;
|
|
1099
987
|
}
|
|
1100
|
-
actualType &= typeHint;
|
|
1101
|
-
}
|
|
1102
|
-
if (actualType === NoneType) {
|
|
1103
|
-
throw new Error(
|
|
1104
|
-
`No matching type was found for the following expression: ${JSON.stringify(
|
|
1105
|
-
encoded,
|
|
1106
|
-
)}`,
|
|
1107
|
-
);
|
|
1108
988
|
}
|
|
1109
|
-
return new CallExpression(
|
|
989
|
+
return new CallExpression(returnType, operator, ...args);
|
|
1110
990
|
};
|
|
1111
991
|
}
|
|
1112
992
|
|
|
1113
993
|
/**
|
|
1114
994
|
* @param {Array} encoded The encoded expression.
|
|
995
|
+
* @param {number} returnType The expected return type of the call expression.
|
|
1115
996
|
* @param {ParsingContext} context The parsing context.
|
|
1116
|
-
* @param {number} [typeHint] Optional type hint
|
|
1117
997
|
* @return {Expression} The parsed expression.
|
|
1118
998
|
*/
|
|
1119
|
-
function parseCallExpression(encoded,
|
|
999
|
+
function parseCallExpression(encoded, returnType, context) {
|
|
1120
1000
|
const operator = encoded[0];
|
|
1121
1001
|
|
|
1122
1002
|
const parser = parsers[operator];
|
|
1123
1003
|
if (!parser) {
|
|
1124
|
-
throw new Error(`
|
|
1004
|
+
throw new Error(`unknown operator: ${operator}`);
|
|
1125
1005
|
}
|
|
1126
|
-
return parser(encoded,
|
|
1006
|
+
return parser(encoded, returnType, context);
|
|
1127
1007
|
}
|
|
1128
1008
|
|
|
1129
1009
|
/**
|