maplibre-gl 2.0.0-pre.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +10 -6
  2. package/README.md +10 -1
  3. package/build/generate-style-spec.ts +29 -9
  4. package/build/glsl_to_js.js +12 -0
  5. package/build/post-ts-build.js +2 -11
  6. package/build/release-notes.js +6 -5
  7. package/build/rollup_plugins.js +24 -2
  8. package/dist/maplibre-gl.d.ts +2934 -2851
  9. package/dist/maplibre-gl.js +3 -3
  10. package/dist/maplibre-gl.js.map +1 -1
  11. package/package.json +15 -12
  12. package/src/geo/lng_lat.ts +2 -2
  13. package/src/index.ts +7 -7
  14. package/src/render/glyph_manager.ts +1 -1
  15. package/src/source/geojson_source.test.ts +353 -0
  16. package/src/source/geojson_source.ts +34 -47
  17. package/src/source/geojson_worker_source.test.ts +277 -0
  18. package/src/source/image_source.ts +4 -4
  19. package/src/source/raster_dem_tile_source.test.ts +152 -0
  20. package/src/source/raster_dem_tile_worker_source.test.ts +38 -0
  21. package/src/source/raster_tile_source.test.ts +141 -0
  22. package/src/source/source.ts +1 -1
  23. package/src/source/source_cache.test.ts +1594 -0
  24. package/src/source/vector_tile_source.test.ts +7 -19
  25. package/src/source/vector_tile_source.ts +4 -4
  26. package/src/source/video_source.test.ts +64 -0
  27. package/src/source/video_source.ts +1 -1
  28. package/src/source/worker_tile.test.ts +101 -0
  29. package/src/style/load_glyph_range.test.ts +45 -0
  30. package/src/style/style.test.ts +2119 -0
  31. package/src/style/style.ts +2 -2
  32. package/src/style-spec/CHANGELOG.md +6 -0
  33. package/src/style-spec/feature_filter/convert.ts +11 -11
  34. package/src/style-spec/feature_filter/feature_filter.test.ts +4 -4
  35. package/src/style-spec/format.ts +2 -2
  36. package/src/style-spec/migrate/v8.test.ts +507 -0
  37. package/src/style-spec/migrate/v9.test.ts +76 -0
  38. package/src/style-spec/package.json +1 -1
  39. package/src/style-spec/reference/v8.json +11 -11
  40. package/src/style-spec/types.ts +29 -9
  41. package/src/style-spec/validate_style.min.ts +1 -1
  42. package/src/symbol/collision_index.ts +12 -6
  43. package/src/symbol/grid_index.test.ts +4 -4
  44. package/src/symbol/grid_index.ts +113 -69
  45. package/src/symbol/placement.ts +29 -24
  46. package/src/symbol/shaping.test.ts +1 -1
  47. package/src/symbol/symbol_layout.ts +26 -19
  48. package/src/ui/camera.test.ts +1883 -0
  49. package/src/ui/camera.ts +1 -2
  50. package/src/ui/control/attribution_control.test.ts +178 -102
  51. package/src/ui/control/attribution_control.ts +18 -18
  52. package/src/ui/control/control.ts +1 -1
  53. package/src/ui/events.ts +14 -5
  54. package/src/ui/handler/dblclick_zoom.test.ts +181 -0
  55. package/src/ui/handler/drag_pan.test.ts +488 -0
  56. package/src/ui/handler/drag_rotate.test.ts +861 -0
  57. package/src/ui/handler/keyboard.test.ts +237 -0
  58. package/src/ui/handler/map_event.test.ts +96 -0
  59. package/src/ui/handler/mouse_rotate.test.ts +64 -0
  60. package/src/ui/handler/scroll_zoom.test.ts +275 -0
  61. package/src/ui/handler/touch_zoom_rotate.test.ts +285 -0
  62. package/src/ui/map/requestRenderFrame.test.ts +41 -0
  63. package/src/ui/map.test.ts +2063 -0
  64. package/src/ui/map.ts +97 -102
  65. package/src/ui/map_events.test.ts +617 -0
  66. package/src/ui/marker.test.ts +774 -0
  67. package/src/ui/marker.ts +1 -1
  68. package/src/ui/popup.test.ts +739 -0
  69. package/src/ui/popup.ts +2 -2
  70. package/src/util/actor.test.ts +73 -0
  71. package/src/util/ajax.ts +10 -6
  72. package/src/util/browser.test.ts +1 -1
  73. package/src/util/dispatcher.test.ts +54 -0
  74. package/src/util/evented.ts +1 -1
  75. package/src/util/test/util.ts +27 -4
  76. package/src/util/tile_request_cache.test.ts +101 -0
  77. package/src/util/util.test.ts +309 -0
  78. package/src/util/web_worker_transfer.test.ts +80 -0
package/CHANGELOG.md CHANGED
@@ -15,25 +15,25 @@
15
15
  - Migrated the production code to typescript
16
16
  - ** Breaking Change ** removed `version` from the public API
17
17
  - ** Breaking Change ** stopped supporting IE (internet explorer)
18
- - ** Breaking Change ** removed all code related to `accessToken` and mapbox specific urls, including telemetry etc. Please do not use mapbox servers with this library.
19
- - ** Breaking Change ** removed `baseApiUrl` as it was used only for mapbox related urls
18
+ - ** Breaking Change ** removed all code related to `accessToken` and Mapbox specific urls starting with `mapbox://`. Telemetry and tracking code was removed.
19
+ - ** Breaking Change ** removed `baseApiUrl` as it was used only for Mapbox related urls
20
20
  - ** Breaking Change ** typescript typings have changed:
21
- - `Style` => `StypeSpecification`
21
+ - `Style` => `StyleSpecification`
22
22
  - `AnyLayer` => `LayerSpecification`
23
23
  - `AnySourceData` => `SourceSpecification`
24
24
  - `MapboxEvent` => `MapLibreEvent`
25
25
  - `MapboxOptions` => `MapOptions`
26
26
  - `MapBoxZoomEvent` => `MapLibreZoomEvent`
27
27
  - `*SourceRaw` + `*SourceOptions` => `*SourceSpecification`
28
- - `*Source` (source implementation definition) were removed
29
- - `*Layer` => `*LayerSpecification`
28
+ - `*Source` (source implementation definition) were removed
29
+ - `*Layer` => `*LayerSpecification`
30
30
  - `*Paint` => `*LayerSpecification['paint']`
31
31
  - `*Layout` => `*LayerSpecification['layout']`
32
32
  - `MapboxGeoJSONFeature` => `GeoJSONFeature`
33
33
  - Added `redraw` function to map (#206)
34
34
  - Improve attribution controls accessibility. See [#359](https://github.com/maplibre/maplibre-gl-js/issues/359)
35
35
  - Allow maxPitch value up to 85, use values greater than 60 at your own risk (#574)
36
- - *...Add new stuff here...*
36
+ - `getImage` uses createImageBitmap when supported (#650)
37
37
 
38
38
  ### 🐞 Bug fixes
39
39
 
@@ -42,6 +42,10 @@
42
42
  - Fix type check for non dom environment. (#334)
43
43
  - Fix precision problem in patterns when overzoomed in OpenGL ES devices.
44
44
  - Fix padding-top of the popup to improve readability of popup text (#354).
45
+ - Fix GeoJSONSource#loaded sometimes returning true while there are still pending loads (#669)
46
+ - Fix MapDataEvent#isSourceLoaded being true in GeoJSONSource "dataloading" event handlers (#694)
47
+ - Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (#726)
48
+ - Fix nested expressions types definition [#757](https://github.com/maplibre/maplibre-gl-js/pull/757)
45
49
 
46
50
  ## 1.15.2
47
51
 
package/README.md CHANGED
@@ -17,6 +17,15 @@ Use
17
17
 
18
18
  if it is important to you that the behaviour is similar to `mapbox-gl` version 1.x.
19
19
 
20
+ If you are OK with changes that integrate non-backward compatible features, install `maplibre-gl` version 2:
21
+
22
+ ```diff
23
+ "dependencies": {
24
+ - "mapbox-gl": "^1.13.0"
25
+ + "maplibre-gl": ">=2.0.0"
26
+ }
27
+ ```
28
+
20
29
  And replace `mapboxgl` with `maplibregl` in your JavaScript and optionally in your HTML/CSS code:
21
30
 
22
31
  > MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more informations please see [MapLibre GL is on unpkg.com](./docs/README-unpkg.md#maplibre-gl-on-unpkgcom).
@@ -66,7 +75,7 @@ If you depend on a free software alternative to `mapbox-gl-js`, please consider
66
75
 
67
76
  ### Thank you Mapbox 🙏🏽
68
77
 
69
- 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 achievment which now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽‍♀️.
78
+ 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 🙇🏽‍♀️.
70
79
 
71
80
  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)!
72
81
 
@@ -125,16 +125,36 @@ export type ResolvedImageSpecification = string;
125
125
 
126
126
  export type PromoteIdSpecification = {[_: string]: string} | string;
127
127
 
128
+ export type FilterSpecificationInputType = string | number | boolean;
128
129
  export type FilterSpecification =
129
- ['has', string]
130
- | ['!has', string]
131
- | ['==', string, string | number | boolean]
132
- | ['!=', string, string | number | boolean]
133
- | ['>', string, string | number | boolean]
134
- | ['>=', string, string | number | boolean]
135
- | ['<', string, string | number | boolean]
136
- | ['<=', string, string | number | boolean]
137
- | Array<string | FilterSpecification>; // Can't type in, !in, all, any, none -- https://github.com/facebook/flow/issues/2443
130
+ // Lookup
131
+ | ['at', number, (number |string)[]]
132
+ | ['get', string, Record<string, unknown>?]
133
+ | ['has', string, Record<string, unknown>?]
134
+ | ['in', ...FilterSpecificationInputType[], FilterSpecificationInputType | FilterSpecificationInputType[]]
135
+ | ['index-of', FilterSpecificationInputType, FilterSpecificationInputType | FilterSpecificationInputType[]]
136
+ | ['length', string | string[]]
137
+ | ['slice', string | string[], number]
138
+ // Decision
139
+ | ['!', FilterSpecification]
140
+ | ['!=', string | FilterSpecification, FilterSpecificationInputType]
141
+ | ['<', string | FilterSpecification, FilterSpecificationInputType]
142
+ | ['<=', string | FilterSpecification, FilterSpecificationInputType]
143
+ | ['==', string | FilterSpecification, FilterSpecificationInputType]
144
+ | ['>', string | FilterSpecification, FilterSpecificationInputType]
145
+ | ['>=', string | FilterSpecification, FilterSpecificationInputType]
146
+ | ["all", ...FilterSpecification[], FilterSpecificationInputType]
147
+ | ["any", ...FilterSpecification[], FilterSpecificationInputType]
148
+ | ["case", ...FilterSpecification[], FilterSpecificationInputType]
149
+ | ["coalesce", ...FilterSpecification[], FilterSpecificationInputType]
150
+ | ["match", ...FilterSpecification[], FilterSpecificationInputType]
151
+ | ["within", ...FilterSpecification[], FilterSpecificationInputType]
152
+ // Used in convert.ts
153
+ | ["!in", ...FilterSpecification[], FilterSpecificationInputType]
154
+ | ["!has", ...FilterSpecification[], FilterSpecificationInputType]
155
+ | ["none", ...FilterSpecification[], FilterSpecificationInputType]
156
+ // Fallbak for others
157
+ | Array<string | FilterSpecification>
138
158
 
139
159
  export type TransitionSpecification = {
140
160
  duration?: number,
@@ -0,0 +1,12 @@
1
+ export default function glsl_to_js(code, minify) {
2
+ if (minify) {
3
+ code = code.trim() // strip whitespace at the start/end
4
+ .replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
5
+ .replace(/\n+/g, '\n') // collapse multi line breaks
6
+ .replace(/\n\s+/g, '\n') // strip identation
7
+ .replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
8
+ .replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
9
+
10
+ }
11
+ return `export default ${JSON.stringify(code)};`;
12
+ }
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import glob from 'glob';
3
3
  import child_process from 'child_process';
4
+ import glsl_to_js from './glsl_to_js.js';
4
5
 
5
6
  let args = process.argv.slice(2);
6
7
  let outputBaseDir = args[0];
@@ -19,17 +20,7 @@ console.log(`Copying glsl files to ${outputBaseDir}, minify: ${minify}`);
19
20
  glob("./src/**/*.glsl", null, (err, files) => {
20
21
  for (let file of files) {
21
22
  let code = fs.readFileSync(file, 'utf8');
22
-
23
- if (minify) {
24
- code = code.trim() // strip whitespace at the start/end
25
- .replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
26
- .replace(/\n+/g, '\n') // collapse multi line breaks
27
- .replace(/\n\s+/g, '\n') // strip identation
28
- .replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
29
- .replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
30
-
31
- }
32
- let content = `export default ${JSON.stringify(code)};`
23
+ let content = glsl_to_js(code, minify);
33
24
  let fileName = outputBaseDir + '/' + file.split('/').splice(-1) + ".js";
34
25
  fs.writeFileSync(fileName, content);
35
26
  }
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const fs = require('fs');
4
- const execSync = require('child_process').execSync;
5
- const ejs = require('ejs');
6
- const _ = require('lodash');
7
- const semver = require('semver');
3
+ import * as fs from 'fs';
4
+ import {execSync} from 'child_process';
5
+ import * as ejs from 'ejs';
6
+ import _ from 'lodash';
7
+ import semver from 'semver';
8
8
 
9
9
  const changelogPath = 'CHANGELOG.md';
10
10
  const changelog = fs.readFileSync(changelogPath, 'utf8');
@@ -36,6 +36,7 @@ let previousVersion = semver.maxSatisfying(gitTags, "<" + currentVersion, { incl
36
36
  const regex = /^## (\d+\.\d+\.\d+).*?\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms;
37
37
 
38
38
  let releaseNotes = [];
39
+ let match;
39
40
  // eslint-disable-next-line no-cond-assign
40
41
  while (match = regex.exec(changelog)) {
41
42
  releaseNotes.push({
@@ -1,4 +1,5 @@
1
1
 
2
+ import typescript from '@rollup/plugin-typescript';
2
3
  import resolve from '@rollup/plugin-node-resolve';
3
4
  import replace from '@rollup/plugin-replace';
4
5
  import commonjs from '@rollup/plugin-commonjs';
@@ -6,12 +7,14 @@ import unassert from 'rollup-plugin-unassert';
6
7
  import json from '@rollup/plugin-json';
7
8
  import {terser} from 'rollup-plugin-terser';
8
9
  import minifyStyleSpec from './rollup_plugin_minify_style_spec.js';
10
+ import {createFilter} from 'rollup-pluginutils';
9
11
  import strip from '@rollup/plugin-strip';
12
+ import glsl_to_js from './glsl_to_js.js';
10
13
 
11
14
  // Common set of plugins/transformations shared across different rollup
12
15
  // builds (main maplibre bundle, style-spec package, benchmarks bundle)
13
16
 
14
- export const plugins = (minified, production) => [
17
+ export const plugins = (minified, production, watch) => [
15
18
  minifyStyleSpec(),
16
19
  json(),
17
20
  // https://github.com/zaach/jison/issues/351
@@ -26,20 +29,39 @@ export const plugins = (minified, production) => [
26
29
  sourceMap: true,
27
30
  functions: ['PerformanceUtils.*', 'Debug.*']
28
31
  }) : false,
32
+ glsl('**/*.glsl', production),
29
33
  minified ? terser({
30
34
  compress: {
31
35
  pure_getters: true,
32
36
  passes: 3
33
37
  }
34
38
  }) : false,
35
- production ? unassert() : false,
39
+ production ? unassert({
40
+ include: ['**/*'], // by default, unassert only includes .js files
41
+ }) : false,
36
42
  resolve({
37
43
  browser: true,
38
44
  preferBuiltins: false
39
45
  }),
46
+ watch ? typescript() : false,
40
47
  commonjs({
41
48
  // global keyword handling causes Webpack compatibility issues, so we disabled it:
42
49
  // https://github.com/mapbox/mapbox-gl-js/pull/6956
43
50
  ignoreGlobal: true
44
51
  })
45
52
  ].filter(Boolean);
53
+
54
+ // Using this instead of rollup-plugin-string to add minification
55
+ function glsl(include, minify) {
56
+ const filter = createFilter(include);
57
+ return {
58
+ name: 'glsl',
59
+ transform(code, id) {
60
+ if (!filter(id)) return;
61
+ return {
62
+ code: glsl_to_js(code, minify),
63
+ map: {mappings: ''}
64
+ };
65
+ }
66
+ };
67
+ }