maplibre-gl 3.0.0-pre.2 → 3.0.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.
Files changed (106) hide show
  1. package/README.md +0 -3
  2. package/build/banner.ts +2 -3
  3. package/build/generate-dist-package.js +21 -0
  4. package/build/generate-struct-arrays.ts +1 -1
  5. package/build/generate-style-code.ts +4 -0
  6. package/build/generate-style-spec.ts +3 -1
  7. package/build/rollup/bundle_prelude.js +21 -0
  8. package/build/rollup/maplibregl.js +47 -0
  9. package/build/rollup_plugins.ts +2 -1
  10. package/dist/maplibre-gl-csp-worker.js +1 -1
  11. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  12. package/dist/maplibre-gl-csp.js +1 -1
  13. package/dist/maplibre-gl-csp.js.map +1 -1
  14. package/dist/maplibre-gl-dev.js +2101 -1843
  15. package/dist/maplibre-gl-dev.js.map +1 -0
  16. package/dist/maplibre-gl.d.ts +239 -70
  17. package/dist/maplibre-gl.js +4 -4
  18. package/dist/maplibre-gl.js.map +1 -1
  19. package/dist/package.json +1 -1
  20. package/dist/style-spec/index.d.ts +9 -6
  21. package/package.json +63 -63
  22. package/src/data/feature_index.ts +1 -1
  23. package/src/index.ts +0 -22
  24. package/src/render/glyph_manager.ts +5 -0
  25. package/src/render/image_manager.ts +35 -16
  26. package/src/render/painter.ts +4 -7
  27. package/src/source/geojson_source.test.ts +21 -1
  28. package/src/source/geojson_source.ts +61 -3
  29. package/src/source/image_source.ts +3 -2
  30. package/src/source/load_tilejson.ts +2 -1
  31. package/src/source/raster_dem_tile_source.ts +3 -2
  32. package/src/source/raster_tile_source.ts +4 -6
  33. package/src/source/terrain_source_cache.test.ts +4 -5
  34. package/src/source/vector_tile_source.test.ts +1 -1
  35. package/src/source/vector_tile_source.ts +1 -4
  36. package/src/source/video_source.ts +2 -1
  37. package/src/source/worker.ts +0 -5
  38. package/src/source/worker_tile.ts +1 -1
  39. package/src/style/load_glyph_range.ts +2 -1
  40. package/src/style/load_sprite.test.ts +209 -0
  41. package/src/style/load_sprite.ts +62 -35
  42. package/src/style/properties.ts +6 -6
  43. package/src/style/style.test.ts +213 -1
  44. package/src/style/style.ts +194 -12
  45. package/src/style/style_image.ts +10 -1
  46. package/src/style/validate_style.ts +2 -0
  47. package/src/style-spec/CHANGELOG.md +4 -0
  48. package/src/style-spec/README.md +0 -8
  49. package/src/style-spec/bin/{gl-style-format → gl-style-format.js} +7 -7
  50. package/src/style-spec/bin/gl-style-migrate.js +18 -0
  51. package/src/style-spec/bin/gl-style-validate.js +45 -0
  52. package/src/style-spec/expression/types.ts +1 -1
  53. package/src/style-spec/feature_filter/feature_filter.test.ts +5 -0
  54. package/src/style-spec/package.json +4 -5
  55. package/src/style-spec/reference/v8.json +3 -3
  56. package/src/style-spec/style-spec.test.ts +2 -1
  57. package/src/style-spec/style-spec.ts +0 -2
  58. package/src/style-spec/types.g.ts +4 -2
  59. package/src/style-spec/validate/validate.ts +4 -1
  60. package/src/style-spec/validate/validate_array.ts +3 -3
  61. package/src/style-spec/validate/validate_function.ts +8 -3
  62. package/src/style-spec/validate/validate_layer.ts +5 -2
  63. package/src/style-spec/validate/validate_light.ts +4 -4
  64. package/src/style-spec/validate/validate_object.ts +3 -2
  65. package/src/style-spec/validate/validate_padding.test.ts +20 -19
  66. package/src/style-spec/validate/validate_padding.ts +2 -2
  67. package/src/style-spec/validate/validate_property.ts +3 -3
  68. package/src/style-spec/validate/validate_source.ts +9 -1
  69. package/src/style-spec/validate/validate_sprite.test.ts +75 -0
  70. package/src/style-spec/validate/validate_sprite.ts +55 -0
  71. package/src/style-spec/validate/validate_terrain.test.ts +6 -5
  72. package/src/style-spec/validate/validate_terrain.ts +3 -3
  73. package/src/style-spec/validate_style.min.ts +24 -10
  74. package/src/ui/camera.ts +1 -1
  75. package/src/ui/control/fullscreen_control.test.ts +24 -0
  76. package/src/ui/control/fullscreen_control.ts +26 -1
  77. package/src/ui/handler/scroll_zoom.test.ts +24 -0
  78. package/src/ui/handler/scroll_zoom.ts +15 -5
  79. package/src/ui/handler_manager.ts +51 -36
  80. package/src/ui/map.test.ts +24 -0
  81. package/src/ui/map.ts +116 -14
  82. package/src/util/ajax.test.ts +1 -129
  83. package/src/util/ajax.ts +3 -168
  84. package/src/util/browser.ts +7 -2
  85. package/src/util/config.ts +2 -0
  86. package/src/util/dispatcher.test.ts +35 -12
  87. package/src/util/dispatcher.ts +7 -7
  88. package/src/util/dom.ts +2 -2
  89. package/src/util/image_request.test.ts +486 -0
  90. package/src/util/image_request.ts +221 -0
  91. package/src/util/primitives.ts +1 -1
  92. package/src/util/request_manager.ts +16 -5
  93. package/src/util/style.test.ts +19 -0
  94. package/src/util/style.ts +12 -0
  95. package/src/util/test/util.ts +3 -0
  96. package/src/util/util.ts +47 -2
  97. package/build/generate-debug-index-file.ts +0 -20
  98. package/build/generate-query-test-fixtures.ts +0 -124
  99. package/postinstall.js +0 -1
  100. package/src/style-spec/bin/gl-style-composite +0 -9
  101. package/src/style-spec/bin/gl-style-migrate +0 -9
  102. package/src/style-spec/bin/gl-style-validate +0 -42
  103. package/src/style-spec/composite.test.ts +0 -107
  104. package/src/style-spec/composite.ts +0 -51
  105. package/src/util/tile_request_cache.test.ts +0 -101
  106. package/src/util/tile_request_cache.ts +0 -169
package/README.md CHANGED
@@ -8,9 +8,6 @@ It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox
8
8
 
9
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
10
 
11
- **Call for Bounties💰** If you have ideas for new features in MapLibre, you can now nominate them for the MapLibre Bounty Program at https://maplibre.org/news/2022-10-16-call-for-bounties/
12
- <br />
13
-
14
11
  ## Getting Started
15
12
 
16
13
  Include the JavaScript and CSS files in the `<head>` of your HTML file.
package/build/banner.ts CHANGED
@@ -1,4 +1,3 @@
1
- import fs from 'fs';
1
+ import packageJSON from '../package.json' assert {type: 'json'};
2
2
 
3
- const version = JSON.parse(fs.readFileSync('package.json').toString()).version;
4
- export default `/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${version}/LICENSE.txt */`;
3
+ export default `/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${packageJSON.version}/LICENSE.txt */`;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+ /// js files in this project are esm.
3
+ /// This package.json ensures that node imports from outside see them as such
4
+ // https://nodejs.org/api/packages.html#type
5
+
6
+ import { writeFile, mkdir } from "node:fs/promises"
7
+
8
+ async function ensureDist() {
9
+ const dist = new URL("../dist/", import.meta.url);
10
+ await mkdir(dist, { recursive: true })
11
+ return dist
12
+ }
13
+
14
+ await writeFile(
15
+ new URL("package.json", await ensureDist()),
16
+ JSON.stringify({
17
+ name: "@maplibre/distfiles",
18
+ type: "commonjs",
19
+ deprecated: "Please install maplibre-gl from parent directory instead",
20
+ })
21
+ )
@@ -6,7 +6,7 @@
6
6
  * - Particular, named StructArray subclasses, when fancy struct accessors are needed (e.g. CollisionBoxArray)
7
7
  */
8
8
 
9
- 'use strict'; // eslint-disable-line strict
9
+ 'use strict';
10
10
 
11
11
  import * as fs from 'fs';
12
12
  import * as util from '../src/util/util';
@@ -29,6 +29,8 @@ function nativeType(property) {
29
29
  return 'Color';
30
30
  case 'padding':
31
31
  return 'Padding';
32
+ case 'sprite':
33
+ return 'Sprite';
32
34
  case 'formatted':
33
35
  return 'Formatted';
34
36
  case 'resolvedImage':
@@ -91,6 +93,8 @@ function runtimeType(property) {
91
93
  return 'ColorType';
92
94
  case 'padding':
93
95
  return 'PaddingType';
96
+ case 'sprite':
97
+ return 'SpriteType';
94
98
  case 'formatted':
95
99
  return 'FormattedType';
96
100
  case 'Image':
@@ -122,6 +122,8 @@ export type ColorSpecification = string;
122
122
 
123
123
  export type PaddingSpecification = number | number[];
124
124
 
125
+ export type SpriteSpecification = string | {id: string; url: string}[];
126
+
125
127
  export type FormattedSpecification = string;
126
128
 
127
129
  export type ResolvedImageSpecification = string;
@@ -174,7 +176,7 @@ export type ExpressionSpecification =
174
176
  | ['in', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification]
175
177
  | ['index-of', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification] // number
176
178
  | ['length', string | ExpressionSpecification]
177
- | ['slice', string | ExpressionSpecification, number | ExpressionSpecification]
179
+ | ['slice', string | ExpressionSpecification, number | ExpressionSpecification, (number | ExpressionSpecification)?]
178
180
  // Decision
179
181
  | ['!', boolean | ExpressionSpecification] // boolean
180
182
  | ['!=', ExpressionInputType | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, CollatorExpressionSpecification?] // boolean
@@ -0,0 +1,21 @@
1
+ /* eslint-disable */
2
+
3
+ var shared, worker, maplibregl;
4
+ // define gets called three times: one for each chunk. we rely on the order
5
+ // they're imported to know which is which
6
+ function define(_, chunk) {
7
+ if (!shared) {
8
+ shared = chunk;
9
+ } else if (!worker) {
10
+ worker = chunk;
11
+ } else {
12
+ var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);'
13
+
14
+ var sharedChunk = {};
15
+ shared(sharedChunk);
16
+ maplibregl = chunk(sharedChunk);
17
+ if (typeof window !== 'undefined') {
18
+ maplibregl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,47 @@
1
+ //
2
+ // Our custom intro provides a specialized "define()" function, called by the
3
+ // AMD modules below, that sets up the worker blob URL and then executes the
4
+ // main module, storing its exported value as 'maplibregl'
5
+
6
+ // The three "chunks" imported here are produced by a first Rollup pass,
7
+ // which outputs them as AMD modules.
8
+
9
+ // Shared dependencies, i.e.:
10
+ /*
11
+ define(['exports'], function (exports) {
12
+ // Code for all common dependencies
13
+ // Each module's exports are attached attached to 'exports' (with
14
+ // names rewritten to avoid collisions, etc.)
15
+ })
16
+ */
17
+ import '../../staging/maplibregl/shared';
18
+
19
+ // Worker and its unique dependencies, i.e.:
20
+ /*
21
+ define(['./shared.js'], function (__shared__js) {
22
+ // Code for worker script and its unique dependencies.
23
+ // Expects the output of 'shared' module to be passed in as an argument,
24
+ // since all references to common deps look like, e.g.,
25
+ // __shared__js.shapeText().
26
+ });
27
+ */
28
+ // When this wrapper function is passed to our custom define() above,
29
+ // it gets stringified, together with the shared wrapper (using
30
+ // Function.toString()), and the resulting string of code is made into a
31
+ // Blob URL that gets used by the main module to create the web workers.
32
+ import '../../staging/maplibregl/worker';
33
+
34
+ // Main module and its unique dependencies
35
+ /*
36
+ define(['./shared.js'], function (__shared__js) {
37
+ // Code for main GL JS module and its unique dependencies.
38
+ // Expects the output of 'shared' module to be passed in as an argument,
39
+ // since all references to common deps look like, e.g.,
40
+ // __shared__js.shapeText().
41
+ //
42
+ // Returns the actual maplibregl (i.e. src/index.js)
43
+ });
44
+ */
45
+ import '../../staging/maplibregl/index';
46
+
47
+ export default maplibregl;
@@ -38,7 +38,8 @@ export const plugins = (production: boolean): Plugin[] => [
38
38
  // eslint-disable-next-line camelcase
39
39
  pure_getters: true,
40
40
  passes: 3
41
- }
41
+ },
42
+ sourceMap: true
42
43
  }),
43
44
  nodeResolve,
44
45
  typescript(),