maplibre-gl 2.2.0-pre.1 → 2.2.0-pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -8
- package/build/generate-debug-index-file.ts +19 -0
- package/build/generate-style-code.ts +6 -1
- package/build/generate-style-spec.ts +153 -35
- package/build/rollup_plugins.ts +4 -1
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +2775 -4481
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +3942 -3280
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +70 -67
- package/src/css/maplibre-gl.css +68 -32
- package/src/css/svg/maplibregl-ctrl-terrain.svg +7 -0
- package/src/data/bucket/fill_bucket.test.ts +1 -0
- package/src/data/bucket/fill_extrusion_attributes.ts +4 -0
- package/src/data/bucket/fill_extrusion_bucket.ts +28 -4
- package/src/data/bucket/symbol_bucket.test.ts +2 -0
- package/src/data/bucket/symbol_bucket.ts +1 -1
- package/src/data/dem_data.test.ts +14 -1
- package/src/data/dem_data.ts +13 -0
- package/src/data/evaluation_feature.ts +1 -1
- package/src/data/program_configuration.ts +2 -2
- package/src/geo/transform.test.ts +90 -2
- package/src/geo/transform.ts +215 -53
- package/src/gl/vertex_buffer.ts +4 -4
- package/src/index.ts +3 -1
- package/src/render/draw_background.ts +6 -6
- package/src/render/draw_circle.ts +6 -2
- package/src/render/draw_collision_debug.ts +5 -1
- package/src/render/draw_debug.ts +6 -6
- package/src/render/draw_fill.ts +5 -2
- package/src/render/draw_fill_extrusion.ts +3 -2
- package/src/render/draw_heatmap.ts +2 -3
- package/src/render/draw_hillshade.ts +8 -7
- package/src/render/draw_line.ts +7 -5
- package/src/render/draw_raster.ts +8 -6
- package/src/render/draw_symbol.test.ts +13 -10
- package/src/render/draw_symbol.ts +23 -12
- package/src/render/draw_terrain.ts +123 -0
- package/src/render/image_atlas.ts +1 -0
- package/src/render/image_manager.ts +1 -0
- package/src/render/painter.ts +52 -14
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/hillshade_program.ts +7 -2
- package/src/render/program/line_program.ts +24 -10
- package/src/render/program/program_uniforms.ts +5 -1
- package/src/render/program/terrain_program.ts +83 -0
- package/src/render/program.ts +29 -5
- package/src/render/render_to_texture.test.ts +41 -0
- package/src/render/render_to_texture.ts +157 -0
- package/src/render/terrain.test.ts +155 -0
- package/src/render/terrain.ts +387 -0
- package/src/render/vertex_array_object.ts +21 -4
- package/src/shaders/README.md +2 -2
- package/src/shaders/_prelude.vertex.glsl +76 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/circle.fragment.glsl +2 -1
- package/src/shaders/circle.fragment.glsl.g.ts +1 -1
- package/src/shaders/circle.vertex.glsl +6 -2
- package/src/shaders/circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/collision_box.vertex.glsl +1 -1
- package/src/shaders/collision_box.vertex.glsl.g.ts +1 -1
- package/src/shaders/debug.vertex.glsl +1 -1
- package/src/shaders/debug.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion.vertex.glsl +16 -2
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +15 -2
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/line.vertex.glsl +7 -3
- package/src/shaders/line.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_gradient.vertex.glsl +7 -3
- package/src/shaders/line_gradient.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_pattern.vertex.glsl +7 -3
- package/src/shaders/line_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_sdf.vertex.glsl +7 -4
- package/src/shaders/line_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/shaders.ts +14 -2
- package/src/shaders/symbol_icon.vertex.glsl +8 -8
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_sdf.vertex.glsl +8 -5
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_text_and_icon.vertex.glsl +8 -5
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/terrain.fragment.glsl +7 -0
- package/src/shaders/terrain.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain.vertex.glsl +12 -0
- package/src/shaders/terrain.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain_coords.fragment.glsl +11 -0
- package/src/shaders/terrain_coords.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain_depth.fragment.glsl +15 -0
- package/src/shaders/terrain_depth.fragment.glsl.g.ts +2 -0
- package/src/source/geojson_worker_source.test.ts +2 -2
- package/src/source/geojson_wrapper.test.ts +1 -1
- package/src/source/image_source.test.ts +8 -8
- package/src/source/image_source.ts +1 -1
- package/src/source/load_tilejson.ts +6 -1
- package/src/source/pixels_to_tile_units.ts +1 -1
- package/src/source/raster_dem_tile_source.ts +4 -3
- package/src/source/raster_dem_tile_worker_source.ts +0 -1
- package/src/source/raster_tile_source.test.ts +1 -1
- package/src/source/source_cache.test.ts +95 -12
- package/src/source/source_cache.ts +72 -11
- package/src/source/terrain_source_cache.test.ts +104 -0
- package/src/source/terrain_source_cache.ts +205 -0
- package/src/source/tile.ts +15 -0
- package/src/source/tile_id.ts +9 -0
- package/src/source/vector_tile_source.test.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +1 -1
- package/src/source/video_source.test.ts +2 -2
- package/src/style/light.test.ts +1 -1
- package/src/style/load_sprite.ts +1 -1
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +3 -1
- package/src/style/style.test.ts +19 -3
- package/src/style/style.ts +59 -5
- package/src/style/style_layer/background_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/line_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/symbol_style_layer.ts +16 -1
- package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -3
- package/src/style/validate_style.ts +2 -0
- package/src/style-spec/CHANGELOG.md +5 -0
- package/src/style-spec/composite.test.ts +2 -0
- package/src/style-spec/composite.ts +3 -2
- package/src/style-spec/diff.test.ts +3 -3
- package/src/style-spec/empty.ts +3 -2
- package/src/style-spec/error/validation_error.ts +1 -1
- package/src/style-spec/expression/compound_expression.ts +0 -4
- package/src/style-spec/expression/definitions/assertion.ts +0 -18
- package/src/style-spec/expression/definitions/at.ts +0 -4
- package/src/style-spec/expression/definitions/case.ts +0 -6
- package/src/style-spec/expression/definitions/coalesce.ts +0 -6
- package/src/style-spec/expression/definitions/coercion.ts +13 -18
- package/src/style-spec/expression/definitions/collator.ts +0 -10
- package/src/style-spec/expression/definitions/comparison.ts +0 -6
- package/src/style-spec/expression/definitions/format.ts +0 -19
- package/src/style-spec/expression/definitions/image.ts +0 -4
- package/src/style-spec/expression/definitions/in.ts +0 -4
- package/src/style-spec/expression/definitions/index_of.ts +0 -8
- package/src/style-spec/expression/definitions/interpolate.ts +1 -25
- package/src/style-spec/expression/definitions/length.ts +0 -6
- package/src/style-spec/expression/definitions/let.ts +0 -9
- package/src/style-spec/expression/definitions/literal.ts +1 -23
- package/src/style-spec/expression/definitions/match.ts +0 -41
- package/src/style-spec/expression/definitions/number_format.ts +0 -17
- package/src/style-spec/expression/definitions/slice.ts +0 -8
- package/src/style-spec/expression/definitions/step.ts +0 -11
- package/src/style-spec/expression/definitions/var.ts +0 -4
- package/src/style-spec/expression/definitions/within.ts +0 -5
- package/src/style-spec/expression/expression.test.ts +1 -1
- package/src/style-spec/expression/expression.ts +3 -3
- package/src/style-spec/expression/index.ts +8 -2
- package/src/style-spec/expression/parsing_context.ts +2 -0
- package/src/style-spec/expression/types/formatted.ts +0 -23
- package/src/style-spec/expression/types/resolved_image.ts +0 -4
- package/src/style-spec/expression/types.ts +6 -1
- package/src/style-spec/expression/values.ts +9 -4
- package/src/style-spec/feature_filter/convert.ts +65 -65
- package/src/style-spec/feature_filter/feature_filter.test.ts +45 -4
- package/src/style-spec/feature_filter/index.ts +2 -1
- package/src/style-spec/function/index.test.ts +117 -1
- package/src/style-spec/function/index.ts +24 -12
- package/src/style-spec/migrate/expressions.ts +2 -2
- package/src/style-spec/migrate/v8.test.ts +2 -0
- package/src/style-spec/migrate/v8.ts +8 -7
- package/src/style-spec/migrate/v9.test.ts +6 -4
- package/src/style-spec/migrate/v9.ts +3 -2
- package/src/style-spec/migrate.test.ts +3 -1
- package/src/style-spec/migrate.ts +5 -4
- package/src/style-spec/package.json +1 -1
- package/src/style-spec/read_style.ts +2 -1
- package/src/style-spec/reference/latest.ts +1 -1
- package/src/style-spec/reference/v8.json +51 -6
- package/src/style-spec/style-spec.test.ts +2 -1
- package/src/style-spec/style-spec.ts +8 -0
- package/src/style-spec/types.g.ts +159 -36
- package/src/style-spec/util/extend.ts +1 -1
- package/src/style-spec/util/interpolate.test.ts +5 -0
- package/src/style-spec/util/interpolate.ts +12 -0
- package/src/style-spec/util/padding.test.ts +27 -0
- package/src/style-spec/util/padding.ts +64 -0
- package/src/style-spec/util/ref_properties.ts +2 -1
- package/src/style-spec/validate/validate.ts +5 -1
- package/src/style-spec/validate/validate_expression.ts +2 -1
- package/src/style-spec/validate/validate_function.ts +2 -2
- package/src/style-spec/validate/validate_glyphs_url.ts +1 -1
- package/src/style-spec/validate/validate_object.ts +2 -2
- package/src/style-spec/validate/validate_padding.test.ts +82 -0
- package/src/style-spec/validate/validate_padding.ts +36 -0
- package/src/style-spec/validate/validate_terrain.test.ts +46 -0
- package/src/style-spec/validate/validate_terrain.ts +41 -0
- package/src/style-spec/validate_style.min.ts +6 -3
- package/src/style-spec/validate_style.ts +5 -3
- package/src/symbol/check_max_angle.test.ts +5 -5
- package/src/symbol/collision_feature.test.ts +22 -5
- package/src/symbol/collision_feature.ts +7 -5
- package/src/symbol/collision_index.ts +28 -12
- package/src/symbol/get_anchors.test.ts +4 -4
- package/src/symbol/{mergelines.test.ts → merge_lines.test.ts} +1 -1
- package/src/symbol/{mergelines.ts → merge_lines.ts} +1 -1
- package/src/symbol/placement.ts +24 -9
- package/src/symbol/projection.ts +42 -27
- package/src/symbol/quads.test.ts +1 -1
- package/src/symbol/shaping.ts +10 -10
- package/src/symbol/symbol_layout.ts +5 -4
- package/src/symbol/symbol_style_layer.test.ts +1 -1
- package/src/symbol/transform_text.ts +3 -3
- package/src/ui/camera.test.ts +11 -11
- package/src/ui/camera.ts +2 -0
- package/src/ui/control/geolocate_control.ts +1 -1
- package/src/ui/control/terrain_control.ts +77 -0
- package/src/ui/default_locale.ts +3 -2
- package/src/ui/events.ts +15 -0
- package/src/ui/handler/cooperative_gestures.test.ts +167 -0
- package/src/ui/handler/drag_pan.test.ts +2 -1
- package/src/ui/handler/scroll_zoom.ts +7 -0
- package/src/ui/handler/touch_pan.ts +22 -2
- package/src/ui/handler/touch_zoom_rotate.ts +18 -1
- package/src/ui/handler_manager.ts +35 -5
- package/src/ui/map.test.ts +17 -17
- package/src/ui/map.ts +112 -14
- package/src/ui/map_events.test.ts +33 -32
- package/src/ui/marker.test.ts +21 -0
- package/src/ui/marker.ts +14 -0
- package/src/ui/popup.test.ts +2 -2
- package/src/util/ajax.test.ts +5 -5
- package/src/util/ajax.ts +1 -1
- package/src/util/classify_rings.test.ts +27 -27
- package/src/util/find_pole_of_inaccessibility.ts +1 -1
- package/src/util/primitives.ts +18 -15
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/smart_wrap.ts +1 -1
- package/src/util/tile_request_cache.test.ts +5 -5
- package/src/util/util.test.ts +5 -5
package/README.md
CHANGED
|
@@ -1,8 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# MapLibre GL JS
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**[MapLibre GL JS](https://maplibre.org/maplibre-gl-js-docs/api/)** is an open-source library for publishing maps on your websites. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering.
|
|
6
|
+
|
|
7
|
+
It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), before their switch to a non-OSS license in December 2020. The library is intended to be a drop-in replacement for the Mapbox’s version with additional functionality.
|
|
8
|
+
|
|
9
|
+
[](LICENSE.txt)[](https://www.npmjs.com/package/maplibre-gl)[](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml)[](https://opensource.org/licenses/BSD-3-Clause)
|
|
10
|
+
|
|
11
|
+
<br />
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
Include the JavaScript and CSS files in the <head> of your HTML file.
|
|
16
|
+
|
|
17
|
+
``` html
|
|
18
|
+
<script src='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js'></script>
|
|
19
|
+
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Include the following code in the <body> of your HTML file.
|
|
23
|
+
|
|
24
|
+
``` html
|
|
25
|
+
<div id='map' style='width: 400px; height: 300px;'></div>
|
|
26
|
+
<script>
|
|
27
|
+
var map = new maplibregl.Map({
|
|
28
|
+
container: 'map',
|
|
29
|
+
style: 'https://demotiles.maplibre.org/style.json', // stylesheet location
|
|
30
|
+
center: [-74.5, 40], // starting position [lng, lat]
|
|
31
|
+
zoom: 9 // starting zoom
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Enjoy the map!
|
|
37
|
+
|
|
38
|
+
<br />
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
Full documentation for this library [is available here](https://maplibre.org/maplibre-gl-js-docs/api/).
|
|
43
|
+
|
|
44
|
+
Check out the features through [examples](https://maplibre.org/maplibre-gl-js-docs/example/).
|
|
45
|
+
|
|
46
|
+
| Showcases | |
|
|
47
|
+
| ---- | ---- |
|
|
48
|
+
| | |
|
|
49
|
+
| | |
|
|
50
|
+
| | |
|
|
51
|
+
|
|
52
|
+
<br />
|
|
53
|
+
|
|
54
|
+
## Migrating from mapbox-gl
|
|
6
55
|
|
|
7
56
|
If you depend on mapbox-gl directly, simply replace `mapbox-gl` with `maplibre-gl` in `package.json`:
|
|
8
57
|
|
|
@@ -55,11 +104,9 @@ Want an example? Have a look at the official [MapLibre GL JS Documentation](http
|
|
|
55
104
|
|
|
56
105
|
Use MapLibre GL JS bindings for React (https://visgl.github.io/react-map-gl/docs/get-started/get-started#using-with-a-mapbox-gl-fork) and Angular (https://github.com/maplibre/ngx-maplibre-gl). Find more at [awesome-maplibre](https://github.com/maplibre/awesome-maplibre).
|
|
57
106
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
This project's initial plans are outlined in the [Roadmap](https://github.com/maplibre/maplibre-gl-js/projects/2) project. The primary goal is consistency and continued bug fixes and maintenance as we advance.
|
|
107
|
+
<br />
|
|
61
108
|
|
|
62
|
-
|
|
109
|
+
## Contribution
|
|
63
110
|
|
|
64
111
|
### Getting Involved
|
|
65
112
|
|
|
@@ -73,12 +120,30 @@ You can find the official status of the backing community and steering committee
|
|
|
73
120
|
|
|
74
121
|
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
|
|
75
122
|
|
|
76
|
-
###
|
|
123
|
+
### Roadmap
|
|
124
|
+
|
|
125
|
+
This project's initial plans are outlined in the [Roadmap](https://github.com/maplibre/maplibre-gl-js/projects/2) project. The primary goal is consistency and continued bug fixes and maintenance as we advance.
|
|
126
|
+
|
|
127
|
+
> **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
|
|
128
|
+
|
|
129
|
+
<br />
|
|
130
|
+
|
|
131
|
+
## Sponsors
|
|
132
|
+
|
|
133
|
+
We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring dontations:
|
|
134
|
+
|
|
135
|
+
[MIERUNE Inc.](https://www.mierune.co.jp/?lang=en) [@MIERUNE](https://github.com/MIERUNE), [@jawg](https://github.com/jawg), [@nekoyasan](https://github.com/nekoyasan), [@atierian](https://github.com/atierian), [@photoprism](https://github.com/photoprism), [@kaplanlior](https://github.com/kaplanlior), [@francois2metz](https://github.com/francois2metz), [@Schneider-Geo](https://github.com/Schneider-Geo), [@serghov](https://github.com/serghov), [@ambientlight](https://github.com/ambientlight), [@joschi77](https://github.com/joschi77), [@geoffhill](https://github.com/geoffhill), [@jasongode](https://github.com/jasongode)
|
|
136
|
+
|
|
137
|
+
<br />
|
|
138
|
+
|
|
139
|
+
## Thank you Mapbox 🙏🏽
|
|
77
140
|
|
|
78
141
|
We'd like to acknowledge the amazing work Mapbox has contributed to open source. The open source community is sad to part ways with them, but we simultaneously feel grateful for everything they already contributed. `mapbox-gl-js` 1.x is an open source achievement which now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽♀️.
|
|
79
142
|
|
|
80
143
|
Please keep in mind: Unauthorized backports are the biggest threat to the MapLibre project. It is unacceptable to backport code from mapbox-gl-js, which is not covered by the former BSD-3 license. If you are unsure about this issue, [please ask](https://github.com/maplibre/maplibre-gl-js/discussions)!
|
|
81
144
|
|
|
145
|
+
<br />
|
|
146
|
+
|
|
82
147
|
## License
|
|
83
148
|
|
|
84
149
|
**MapLibre GL** is licensed under the [3-Clause BSD license](./LICENSE.txt).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** This file is meant to create an index.html file to allow knowing which debug files exists */
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
const htmlFilesLinks = fs.readdirSync('test/debug-pages')
|
|
5
|
+
.filter(f => f.endsWith('.html'))
|
|
6
|
+
.map(f => ` <a href='/test/debug-pages/${f}'>${f}</a><br/>`)
|
|
7
|
+
.join('\n');
|
|
8
|
+
|
|
9
|
+
fs.writeFileSync('test/debug-pages/index.html', `
|
|
10
|
+
<html>
|
|
11
|
+
<head>
|
|
12
|
+
<title>Debug Pages</title>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<h1>Debug Pages</h1>
|
|
16
|
+
${htmlFilesLinks}
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
19
|
+
`);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
|
|
5
|
-
import spec from '../src/style-spec/reference/v8.json';
|
|
5
|
+
import spec from '../src/style-spec/reference/v8.json' assert {type: 'json'};
|
|
6
6
|
|
|
7
7
|
function camelCase(str: string): string {
|
|
8
8
|
return str.replace(/-(.)/g, (_, x) => {
|
|
@@ -27,6 +27,8 @@ function nativeType(property) {
|
|
|
27
27
|
return Object.keys(property.values).map(v => JSON.stringify(v)).join(' | ');
|
|
28
28
|
case 'color':
|
|
29
29
|
return 'Color';
|
|
30
|
+
case 'padding':
|
|
31
|
+
return 'Padding';
|
|
30
32
|
case 'formatted':
|
|
31
33
|
return 'Formatted';
|
|
32
34
|
case 'resolvedImage':
|
|
@@ -87,6 +89,8 @@ function runtimeType(property) {
|
|
|
87
89
|
return 'StringType';
|
|
88
90
|
case 'color':
|
|
89
91
|
return 'ColorType';
|
|
92
|
+
case 'padding':
|
|
93
|
+
return 'PaddingType';
|
|
90
94
|
case 'formatted':
|
|
91
95
|
return 'FormattedType';
|
|
92
96
|
case 'Image':
|
|
@@ -175,6 +179,7 @@ import {
|
|
|
175
179
|
} from '../properties';
|
|
176
180
|
|
|
177
181
|
import type Color from '../../style-spec/util/color';
|
|
182
|
+
import type Padding from '../../style-spec/util/padding';
|
|
178
183
|
|
|
179
184
|
import type Formatted from '../../style-spec/expression/types/formatted';
|
|
180
185
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as properties from '../src/style-spec/util/properties';
|
|
3
3
|
|
|
4
|
-
import spec from '../src/style-spec/reference/v8.json';
|
|
4
|
+
import spec from '../src/style-spec/reference/v8.json' assert {type: 'json'};
|
|
5
5
|
|
|
6
6
|
function unionType(values) {
|
|
7
7
|
if (Array.isArray(values)) {
|
|
@@ -48,7 +48,7 @@ function propertyType(property) {
|
|
|
48
48
|
} else if (properties.supportsZoomExpression(property)) {
|
|
49
49
|
return `PropertyValueSpecification<${baseType}>`;
|
|
50
50
|
} else if (property.expression) {
|
|
51
|
-
return '
|
|
51
|
+
return 'ExpressionSpecification';
|
|
52
52
|
} else {
|
|
53
53
|
return baseType;
|
|
54
54
|
}
|
|
@@ -120,42 +120,160 @@ fs.writeFileSync('src/style-spec/types.g.ts',
|
|
|
120
120
|
|
|
121
121
|
export type ColorSpecification = string;
|
|
122
122
|
|
|
123
|
+
export type PaddingSpecification = number | number[];
|
|
124
|
+
|
|
123
125
|
export type FormattedSpecification = string;
|
|
124
126
|
|
|
125
127
|
export type ResolvedImageSpecification = string;
|
|
126
128
|
|
|
127
129
|
export type PromoteIdSpecification = {[_: string]: string} | string;
|
|
128
130
|
|
|
129
|
-
export type
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
export type ExpressionInputType = string | number | boolean;
|
|
132
|
+
|
|
133
|
+
export type CollatorExpressionSpecification =
|
|
134
|
+
['collator', {
|
|
135
|
+
'case-sensitive'?: boolean | ExpressionSpecification,
|
|
136
|
+
'diacritic-sensitive'?: boolean | ExpressionSpecification,
|
|
137
|
+
locale?: string | ExpressionSpecification}
|
|
138
|
+
]; // collator
|
|
139
|
+
|
|
140
|
+
export type InterpolationSpecification =
|
|
141
|
+
| ['linear']
|
|
142
|
+
| ['exponential', number | ExpressionSpecification]
|
|
143
|
+
| ['cubic-bezier', number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification]
|
|
144
|
+
|
|
145
|
+
export type ExpressionSpecification =
|
|
146
|
+
// types
|
|
147
|
+
| ['array', unknown | ExpressionSpecification] // array
|
|
148
|
+
| ['array', ExpressionInputType | ExpressionSpecification, unknown | ExpressionSpecification] // array
|
|
149
|
+
| ['array', ExpressionInputType | ExpressionSpecification, number | ExpressionSpecification, unknown | ExpressionSpecification] // array
|
|
150
|
+
| ['boolean', ...(unknown | ExpressionSpecification)[], unknown | ExpressionSpecification] // boolean
|
|
151
|
+
| CollatorExpressionSpecification
|
|
152
|
+
| ['format', ...(string | ['image', ExpressionSpecification] | ExpressionSpecification | {'font-scale'?: number | ExpressionSpecification, 'text-font'?: string[] | ExpressionSpecification, 'text-color': ColorSpecification | ExpressionSpecification})[]] // string
|
|
153
|
+
| ['image', unknown | ExpressionSpecification] // image
|
|
154
|
+
| ['literal', unknown]
|
|
155
|
+
| ['number', unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] // number
|
|
156
|
+
| ['number-format', number | ExpressionSpecification, {'locale'?: string | ExpressionSpecification, 'currency'?: string | ExpressionSpecification, 'min-fraction-digits'?: number | ExpressionSpecification, 'max-fraction-digits'?: number | ExpressionSpecification}] // string
|
|
157
|
+
| ['object', unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] // object
|
|
158
|
+
| ['string', unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] // string
|
|
159
|
+
| ['to-boolean', unknown | ExpressionSpecification] // boolean
|
|
160
|
+
| ['to-color', unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] // color
|
|
161
|
+
| ['to-number', unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] // number
|
|
162
|
+
| ['to-string', unknown | ExpressionSpecification] // string
|
|
163
|
+
// feature data
|
|
164
|
+
| ['accumulated']
|
|
165
|
+
| ['feature-state', string]
|
|
166
|
+
| ['geometry-type'] // string
|
|
167
|
+
| ['id']
|
|
168
|
+
| ['line-progress'] // number
|
|
169
|
+
| ['properties'] // object
|
|
170
|
+
// lookup
|
|
171
|
+
| ['at', number | ExpressionSpecification, ExpressionSpecification]
|
|
172
|
+
| ['get', string | ExpressionSpecification, (Record<string, unknown> | ExpressionSpecification)?]
|
|
173
|
+
| ['has', string | ExpressionSpecification, (Record<string, unknown> | ExpressionSpecification)?]
|
|
174
|
+
| ['in', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification]
|
|
175
|
+
| ['index-of', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification] // number
|
|
176
|
+
| ['length', string | ExpressionSpecification]
|
|
177
|
+
| ['slice', string | ExpressionSpecification, number | ExpressionSpecification]
|
|
139
178
|
// Decision
|
|
140
|
-
| ['!',
|
|
141
|
-
| ['!=',
|
|
142
|
-
| ['<',
|
|
143
|
-
| ['<=',
|
|
144
|
-
| ['==',
|
|
145
|
-
| ['>',
|
|
146
|
-
| ['>=',
|
|
147
|
-
| [
|
|
148
|
-
| [
|
|
149
|
-
| [
|
|
150
|
-
|
|
151
|
-
| [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
| ['!', boolean | ExpressionSpecification] // boolean
|
|
180
|
+
| ['!=', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
181
|
+
| ['<', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
182
|
+
| ['<=', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
183
|
+
| ['==', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
184
|
+
| ['>', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
185
|
+
| ['>=', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
|
|
186
|
+
| ['all', ...(boolean | ExpressionSpecification)[]] // boolean
|
|
187
|
+
| ['any', ...(boolean | ExpressionSpecification)[]] // boolean
|
|
188
|
+
| ['case', boolean | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
189
|
+
...(boolean | ExpressionInputType | ExpressionSpecification)[], ExpressionInputType | ExpressionSpecification]
|
|
190
|
+
| ['coalesce', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
191
|
+
...(ExpressionInputType | ExpressionSpecification)[]]
|
|
192
|
+
| ['match', ExpressionInputType | ExpressionSpecification,
|
|
193
|
+
ExpressionInputType | ExpressionInputType[], ExpressionInputType | ExpressionSpecification,
|
|
194
|
+
...(ExpressionInputType | ExpressionInputType[] | ExpressionSpecification)[], // repeated as above
|
|
195
|
+
ExpressionInputType]
|
|
196
|
+
| ['within', unknown | ExpressionSpecification]
|
|
197
|
+
// Ramps, scales, curves
|
|
198
|
+
| ['interpolate', InterpolationSpecification,
|
|
199
|
+
number | ExpressionSpecification, number | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
200
|
+
...(number | ExpressionInputType | ExpressionSpecification)[]]
|
|
201
|
+
| ['interpolate-hcl', InterpolationSpecification,
|
|
202
|
+
number | ExpressionSpecification, number | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
203
|
+
...(number | ColorSpecification | ExpressionSpecification)[]]
|
|
204
|
+
| ['interpolate-lab', InterpolationSpecification,
|
|
205
|
+
number | ExpressionSpecification, number | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
206
|
+
...(number | ColorSpecification | ExpressionSpecification)[]]
|
|
207
|
+
| ['step', number | ExpressionSpecification, number | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
208
|
+
...(number | ExpressionInputType | ExpressionSpecification)[]]
|
|
209
|
+
// Variable binding
|
|
210
|
+
| ['let', string, ExpressionInputType | ExpressionSpecification, ...(string | ExpressionInputType | ExpressionSpecification)[]]
|
|
211
|
+
| ['var', string]
|
|
212
|
+
// String
|
|
213
|
+
| ['concat', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification,
|
|
214
|
+
...(ExpressionInputType | ExpressionSpecification)[]] // string
|
|
215
|
+
| ['downcase', string | ExpressionSpecification] // string
|
|
216
|
+
| ['is-supported-script', string | ExpressionSpecification] // boolean
|
|
217
|
+
| ['resolved-locale', CollatorExpressionSpecification] // string
|
|
218
|
+
| ['upcase', string | ExpressionSpecification] // string
|
|
219
|
+
// Color
|
|
220
|
+
| ['rgb', number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification] // color
|
|
221
|
+
| ['rgba', number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification]
|
|
222
|
+
| ['to-rgba', ColorSpecification | ExpressionSpecification]
|
|
223
|
+
// Math
|
|
224
|
+
| ['-', number | ExpressionSpecification, (number | ExpressionSpecification)?] // number
|
|
225
|
+
| ['*', number | ExpressionSpecification, number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] // number
|
|
226
|
+
| ['/', number | ExpressionSpecification, number | ExpressionSpecification] // number
|
|
227
|
+
| ['%', number | ExpressionSpecification, number | ExpressionSpecification] // number
|
|
228
|
+
| ['^', number | ExpressionSpecification, number | ExpressionSpecification] // number
|
|
229
|
+
| ['+', number | ExpressionSpecification, number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] // number
|
|
230
|
+
| ['abs', number | ExpressionSpecification] // number
|
|
231
|
+
| ['acos', number | ExpressionSpecification] // number
|
|
232
|
+
| ['asin', number | ExpressionSpecification] // number
|
|
233
|
+
| ['atan', number | ExpressionSpecification] // number
|
|
234
|
+
| ['ceil', number | ExpressionSpecification] // number
|
|
235
|
+
| ['cos', number | ExpressionSpecification] // number
|
|
236
|
+
| ['distance', Record<string, unknown> | ExpressionSpecification] // number
|
|
237
|
+
| ['ExpressionSpecification'] // number
|
|
238
|
+
| ['floor', number | ExpressionSpecification] // number
|
|
239
|
+
| ['ln', number | ExpressionSpecification] // number
|
|
240
|
+
| ['ln2'] // number
|
|
241
|
+
| ['log10', number | ExpressionSpecification] // number
|
|
242
|
+
| ['log2', number | ExpressionSpecification] // number
|
|
243
|
+
| ['max', number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] // number
|
|
244
|
+
| ['min', number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] // number
|
|
245
|
+
| ['pi'] // number
|
|
246
|
+
| ['round', number | ExpressionSpecification] // number
|
|
247
|
+
| ['sin', number | ExpressionSpecification] // number
|
|
248
|
+
| ['sqrt', number | ExpressionSpecification] // number
|
|
249
|
+
| ['tan', number | ExpressionSpecification] // number
|
|
250
|
+
// Zoom
|
|
251
|
+
| ['zoom'] // number
|
|
252
|
+
// Heatmap
|
|
253
|
+
| ['heatmap-density'] // number
|
|
254
|
+
|
|
255
|
+
export type ExpressionFilterSpecification = boolean | ExpressionSpecification
|
|
256
|
+
|
|
257
|
+
export type LegacyFilterSpecification =
|
|
258
|
+
// Existential
|
|
259
|
+
| ['has', string]
|
|
260
|
+
| ['!has', string]
|
|
261
|
+
// Comparison
|
|
262
|
+
| ['==', string, string | number | boolean]
|
|
263
|
+
| ['!=', string, string | number | boolean]
|
|
264
|
+
| ['>', string, string | number | boolean]
|
|
265
|
+
| ['>=', string, string | number | boolean]
|
|
266
|
+
| ['<', string, string | number | boolean]
|
|
267
|
+
| ['<=', string, string | number | boolean]
|
|
268
|
+
// Set membership
|
|
269
|
+
| ['in', string, ...(string | number | boolean)[]]
|
|
270
|
+
| ['!in', string, ...(string | number | boolean)[]]
|
|
271
|
+
// Combining
|
|
272
|
+
| ['all', ...LegacyFilterSpecification[]]
|
|
273
|
+
| ['any', ...LegacyFilterSpecification[]]
|
|
274
|
+
| ['none', ...LegacyFilterSpecification[]]
|
|
275
|
+
|
|
276
|
+
export type FilterSpecification = ExpressionFilterSpecification | LegacyFilterSpecification
|
|
159
277
|
|
|
160
278
|
export type TransitionSpecification = {
|
|
161
279
|
duration?: number,
|
|
@@ -179,24 +297,24 @@ export type CompositeFunctionSpecification<T> =
|
|
|
179
297
|
| { type: 'interval', stops: Array<[{zoom: number, value: number}, T]>, property: string, default?: T }
|
|
180
298
|
| { type: 'categorical', stops: Array<[{zoom: number, value: string | number | boolean}, T]>, property: string, default?: T };
|
|
181
299
|
|
|
182
|
-
export type ExpressionSpecificationArray = Array<unknown>;
|
|
183
|
-
|
|
184
300
|
export type PropertyValueSpecification<T> =
|
|
185
301
|
T
|
|
186
302
|
| CameraFunctionSpecification<T>
|
|
187
|
-
|
|
|
303
|
+
| ExpressionSpecification;
|
|
188
304
|
|
|
189
305
|
export type DataDrivenPropertyValueSpecification<T> =
|
|
190
306
|
T
|
|
191
307
|
| CameraFunctionSpecification<T>
|
|
192
308
|
| SourceFunctionSpecification<T>
|
|
193
309
|
| CompositeFunctionSpecification<T>
|
|
194
|
-
|
|
|
310
|
+
| ExpressionSpecification;
|
|
195
311
|
|
|
196
312
|
${objectDeclaration('StyleSpecification', spec.$root)}
|
|
197
313
|
|
|
198
314
|
${objectDeclaration('LightSpecification', spec.light)}
|
|
199
315
|
|
|
316
|
+
${objectDeclaration('TerrainSpecification', spec.terrain)}
|
|
317
|
+
|
|
200
318
|
${spec.source.map(key => objectDeclaration(sourceTypeName(key), spec[key])).join('\n\n')}
|
|
201
319
|
|
|
202
320
|
export type SourceSpecification =
|
package/build/rollup_plugins.ts
CHANGED
|
@@ -3,12 +3,14 @@ import typescript from '@rollup/plugin-typescript';
|
|
|
3
3
|
import resolve from '@rollup/plugin-node-resolve';
|
|
4
4
|
import replace from '@rollup/plugin-replace';
|
|
5
5
|
import commonjs from '@rollup/plugin-commonjs';
|
|
6
|
-
import unassert from 'rollup-plugin
|
|
6
|
+
import unassert from 'unassert-rollup-plugin';
|
|
7
7
|
import json from '@rollup/plugin-json';
|
|
8
8
|
import {terser} from 'rollup-plugin-terser';
|
|
9
9
|
import minifyStyleSpec from './rollup_plugin_minify_style_spec';
|
|
10
10
|
import strip from '@rollup/plugin-strip';
|
|
11
11
|
import {Plugin} from 'rollup';
|
|
12
|
+
import {importAssertionsPlugin} from 'rollup-plugin-import-assert';
|
|
13
|
+
|
|
12
14
|
// Common set of plugins/transformations shared across different rollup
|
|
13
15
|
// builds (main maplibre bundle, style-spec package, benchmarks bundle)
|
|
14
16
|
|
|
@@ -19,6 +21,7 @@ export const nodeResolve = resolve({
|
|
|
19
21
|
|
|
20
22
|
export const plugins = (production: boolean): Plugin[] => [
|
|
21
23
|
minifyStyleSpec(),
|
|
24
|
+
importAssertionsPlugin(),
|
|
22
25
|
json(),
|
|
23
26
|
// https://github.com/zaach/jison/issues/351
|
|
24
27
|
replace({
|