maplibre-gl 2.2.0-pre.3 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +73 -14
  2. package/build/generate-debug-index-file.ts +19 -0
  3. package/build/generate-style-code.ts +6 -1
  4. package/build/generate-style-spec.ts +151 -35
  5. package/build/generate-typings.ts +1 -1
  6. package/build/rollup_plugins.ts +4 -1
  7. package/dist/maplibre-gl-csp-worker.js +1 -1
  8. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  9. package/dist/maplibre-gl-csp.js +1 -1
  10. package/dist/maplibre-gl-csp.js.map +1 -1
  11. package/dist/maplibre-gl-dev.js +364 -3124
  12. package/dist/maplibre-gl.css +1 -1
  13. package/dist/maplibre-gl.d.ts +439 -151
  14. package/dist/maplibre-gl.js +4 -4
  15. package/dist/maplibre-gl.js.map +1 -1
  16. package/package.json +68 -65
  17. package/src/css/maplibre-gl.css +39 -32
  18. package/src/data/bucket/fill_bucket.test.ts +1 -0
  19. package/src/data/bucket/symbol_bucket.test.ts +2 -0
  20. package/src/data/evaluation_feature.ts +1 -1
  21. package/src/data/program_configuration.ts +2 -2
  22. package/src/geo/transform.ts +4 -4
  23. package/src/gl/vertex_buffer.ts +4 -4
  24. package/src/index.ts +1 -1
  25. package/src/render/image_atlas.ts +1 -0
  26. package/src/render/image_manager.ts +1 -0
  27. package/src/render/program/debug_program.ts +1 -1
  28. package/src/render/render_to_texture.ts +3 -0
  29. package/src/render/terrain.ts +21 -21
  30. package/src/shaders/README.md +2 -2
  31. package/src/source/geojson_worker_source.test.ts +2 -2
  32. package/src/source/geojson_wrapper.test.ts +1 -1
  33. package/src/source/image_source.test.ts +8 -8
  34. package/src/source/image_source.ts +1 -1
  35. package/src/source/raster_tile_source.test.ts +1 -1
  36. package/src/source/source_cache.test.ts +12 -12
  37. package/src/source/source_cache.ts +1 -1
  38. package/src/source/terrain_source_cache.ts +3 -3
  39. package/src/source/vector_tile_source.test.ts +1 -1
  40. package/src/source/vector_tile_worker_source.test.ts +1 -1
  41. package/src/source/video_source.test.ts +2 -2
  42. package/src/source/worker.ts +2 -4
  43. package/src/style/light.test.ts +1 -1
  44. package/src/style/style.test.ts +3 -3
  45. package/src/style/style.ts +2 -2
  46. package/src/style/style_layer/background_style_layer_properties.g.ts +1 -0
  47. package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -0
  48. package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -0
  49. package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -0
  50. package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -0
  51. package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -0
  52. package/src/style/style_layer/line_style_layer_properties.g.ts +1 -0
  53. package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -0
  54. package/src/style/style_layer/symbol_style_layer.ts +16 -1
  55. package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -3
  56. package/src/style-spec/CHANGELOG.md +5 -0
  57. package/src/style-spec/composite.test.ts +2 -0
  58. package/src/style-spec/diff.test.ts +3 -3
  59. package/src/style-spec/empty.ts +3 -2
  60. package/src/style-spec/expression/definitions/coercion.ts +13 -2
  61. package/src/style-spec/expression/definitions/interpolate.ts +1 -0
  62. package/src/style-spec/expression/expression.test.ts +1 -1
  63. package/src/style-spec/expression/expression.ts +3 -0
  64. package/src/style-spec/expression/index.ts +8 -2
  65. package/src/style-spec/expression/parsing_context.ts +2 -0
  66. package/src/style-spec/expression/types.ts +6 -1
  67. package/src/style-spec/expression/values.ts +9 -4
  68. package/src/style-spec/feature_filter/convert.ts +65 -65
  69. package/src/style-spec/feature_filter/feature_filter.test.ts +45 -4
  70. package/src/style-spec/feature_filter/index.ts +2 -1
  71. package/src/style-spec/function/index.test.ts +117 -1
  72. package/src/style-spec/function/index.ts +24 -12
  73. package/src/style-spec/migrate/expressions.ts +1 -1
  74. package/src/style-spec/migrate/v8.test.ts +2 -0
  75. package/src/style-spec/migrate/v9.test.ts +6 -4
  76. package/src/style-spec/migrate.test.ts +3 -1
  77. package/src/style-spec/package.json +1 -1
  78. package/src/style-spec/reference/latest.ts +2 -2
  79. package/src/style-spec/reference/v8.json +9 -6
  80. package/src/style-spec/style-spec.test.ts +2 -1
  81. package/src/style-spec/style-spec.ts +18 -9
  82. package/src/style-spec/types.g.ts +152 -36
  83. package/src/style-spec/util/interpolate.test.ts +5 -0
  84. package/src/style-spec/util/interpolate.ts +12 -0
  85. package/src/style-spec/util/padding.test.ts +27 -0
  86. package/src/style-spec/util/padding.ts +64 -0
  87. package/src/style-spec/validate/validate.ts +3 -1
  88. package/src/style-spec/validate/validate_padding.test.ts +82 -0
  89. package/src/style-spec/validate/validate_padding.ts +36 -0
  90. package/src/style-spec/validate_style.ts +1 -1
  91. package/src/symbol/check_max_angle.test.ts +5 -5
  92. package/src/symbol/collision_feature.test.ts +22 -5
  93. package/src/symbol/collision_feature.ts +7 -5
  94. package/src/symbol/collision_index.ts +1 -1
  95. package/src/symbol/get_anchors.test.ts +4 -4
  96. package/src/symbol/projection.ts +1 -1
  97. package/src/symbol/quads.test.ts +1 -1
  98. package/src/symbol/shaping.ts +10 -10
  99. package/src/symbol/symbol_layout.ts +5 -4
  100. package/src/symbol/symbol_style_layer.test.ts +1 -1
  101. package/src/ui/camera.test.ts +11 -11
  102. package/src/ui/control/geolocate_control.ts +1 -1
  103. package/src/ui/control/terrain_control.ts +4 -4
  104. package/src/ui/handler/cooperative_gestures.test.ts +167 -0
  105. package/src/ui/handler/drag_pan.test.ts +2 -1
  106. package/src/ui/handler/scroll_zoom.ts +7 -0
  107. package/src/ui/handler/touch_pan.ts +22 -2
  108. package/src/ui/handler/touch_zoom_rotate.ts +18 -1
  109. package/src/ui/handler_manager.ts +2 -2
  110. package/src/ui/map.test.ts +16 -16
  111. package/src/ui/map.ts +76 -8
  112. package/src/ui/map_events.test.ts +33 -32
  113. package/src/ui/popup.test.ts +2 -2
  114. package/src/util/ajax.test.ts +5 -5
  115. package/src/util/ajax.ts +1 -1
  116. package/src/util/classify_rings.test.ts +27 -27
  117. package/src/util/primitives.ts +4 -4
  118. package/src/util/resolve_tokens.test.ts +1 -1
  119. package/src/util/tile_request_cache.test.ts +5 -5
  120. package/src/util/util.test.ts +5 -5
  121. package/src/util/util.ts +2 -3
package/README.md CHANGED
@@ -1,8 +1,57 @@
1
- # MapLibre GL
1
+ ![MapLibre Logo](https://maplibre.org/img/maplibre-logo-big.svg)
2
2
 
3
- **MapLibre GL** is a community-led fork derived from [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js) before their switch to a non-OSS license.
3
+ # MapLibre GL JS
4
4
 
5
- ### Migrating from mapbox-gl
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](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=flat)](LICENSE.txt)[![Version](https://img.shields.io/npm/v/maplibre-gl?style=flat)](https://www.npmjs.com/package/maplibre-gl)[![CI](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml/badge.svg)](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml)[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](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
+ |![Display a map](https://maplibre.org/maplibre-gl-js-docs/assets/simple-map-800-22a3f5b6410f543ab214e14f68fb42ec.png) |![Third party vector tile source](https://maplibre.org/maplibre-gl-js-docs/assets/third-party-800-e047007bba338f6ec7d6cd47abfed279.png) |
49
+ |![Animate a series of images](https://maplibre.org/maplibre-gl-js-docs/assets/animate-images-800-497358611dbe047f300faeb9465aad5f.png) |![Create a heatmap layer](https://maplibre.org/maplibre-gl-js-docs/assets/heatmap-layer-800-05c0f97ddb6b1a10e84b5064564e86ff.png) |
50
+ |![3D buildings](https://maplibre.org/maplibre-gl-js-docs/assets/3d-buildings-800-bd7885f07050dbbfee7a9bb800ff5ce8.png) |![Visualize population density](https://maplibre.org/maplibre-gl-js-docs/assets/visualize-population-density-800-6c65712d9ea94eb6d2bd3348a82b9bdf.png) |
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,17 +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
- ### Sponsors
59
-
60
- We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring dontations:
61
-
62
- [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)
63
-
64
- ### Roadmap
65
-
66
- 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 />
67
108
 
68
- > **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
109
+ ## Contribution
69
110
 
70
111
  ### Getting Involved
71
112
 
@@ -79,12 +120,30 @@ You can find the official status of the backing community and steering committee
79
120
 
80
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.
81
122
 
82
- ### Thank you Mapbox 🙏🏽
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 🙏🏽
83
140
 
84
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 🙇🏽‍♀️.
85
142
 
86
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)!
87
144
 
145
+ <br />
146
+
88
147
  ## License
89
148
 
90
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 'ExpressionSpecificationArray';
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 FilterSpecificationInputType = string | number | boolean;
130
- export type FilterSpecification =
131
- // Lookup
132
- | ['at', number, (number |string)[]]
133
- | ['get', string, Record<string, unknown>?]
134
- | ['has', string, Record<string, unknown>?]
135
- | ['in', ...FilterSpecificationInputType[], FilterSpecificationInputType | FilterSpecificationInputType[]]
136
- | ['index-of', FilterSpecificationInputType, FilterSpecificationInputType | FilterSpecificationInputType[]]
137
- | ['length', string | string[]]
138
- | ['slice', string | string[], number]
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
- | ['!', FilterSpecification]
141
- | ['!=', string | FilterSpecification, FilterSpecificationInputType]
142
- | ['<', string | FilterSpecification, FilterSpecificationInputType]
143
- | ['<=', string | FilterSpecification, FilterSpecificationInputType]
144
- | ['==', string | FilterSpecification, FilterSpecificationInputType]
145
- | ['>', string | FilterSpecification, FilterSpecificationInputType]
146
- | ['>=', string | FilterSpecification, FilterSpecificationInputType]
147
- | ["all", ...FilterSpecification[], FilterSpecificationInputType]
148
- | ["any", ...FilterSpecification[], FilterSpecificationInputType]
149
- | ["case", ...FilterSpecification[], FilterSpecificationInputType]
150
- | ["coalesce", ...FilterSpecification[], FilterSpecificationInputType]
151
- | ["match", ...FilterSpecification[], FilterSpecificationInputType]
152
- | ["within", ...FilterSpecification[], FilterSpecificationInputType]
153
- // Used in convert.ts
154
- | ["!in", ...FilterSpecification[], FilterSpecificationInputType]
155
- | ["!has", ...FilterSpecification[], FilterSpecificationInputType]
156
- | ["none", ...FilterSpecification[], FilterSpecificationInputType]
157
- // Fallbak for others
158
- | Array<string | FilterSpecification>
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,19 +297,17 @@ 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
- | ExpressionSpecificationArray;
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
- | ExpressionSpecificationArray;
310
+ | ExpressionSpecification;
195
311
 
196
312
  ${objectDeclaration('StyleSpecification', spec.$root)}
197
313
 
@@ -8,7 +8,7 @@ if (!fs.existsSync('dist')) {
8
8
 
9
9
  console.log('Starting bundling types');
10
10
  const outputFile = './dist/maplibre-gl.d.ts';
11
- childProcess.execSync(`dts-bundle-generator --no-check --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`);
11
+ childProcess.execSync(`dts-bundle-generator --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`);
12
12
  let types = fs.readFileSync(outputFile, 'utf8');
13
13
  // Classes are not exported but should be since this is exported as UMD - fixing...
14
14
  types = types.replace(/declare class/g, 'export declare class');
@@ -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-unassert';
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({