@acalcutt/maplibre-gl-native-test 5.0.2-pre.7 → 5.2.1-pre.2

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 CHANGED
@@ -50,6 +50,9 @@ To contribute to MapLibre GL Native, see [`CONTRIBUTING.md`](CONTRIBUTING.md) an
50
50
 
51
51
  Join the `#maplibre-native` Slack channel at OSMUS. Get an invite at https://slack.openstreetmap.us/
52
52
 
53
+ ### Bounties 💰
54
+
55
+ Thanks to our sponsors, we are able to award bounties to developers making contributions toward certain [bounty directions](https://github.com/maplibre/maplibre/issues?q=is%3Aissue+is%3Aopen+label%3A%22bounty+direction%22). To get started doing bounties, refer to the [step-by-step bounties guide](https://maplibre.org/roadmap/step-by-step-bounties-guide/).
53
56
 
54
57
  ## Sponsors
55
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acalcutt/maplibre-gl-native-test",
3
- "version": "5.0.2-pre.7",
3
+ "version": "5.2.1-pre.2",
4
4
  "description": "Renders map tiles with Maplibre GL",
5
5
  "keywords": [
6
6
  "maplibre",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@acalcutt/node-pre-gyp": "^1.0.11",
25
25
  "@acalcutt/node-pre-gyp-github": "1.4.8",
26
- "minimatch": "^7.0.0",
26
+ "minimatch": "^7.2.0",
27
27
  "npm-run-all": "^4.0.2"
28
28
  },
29
29
  "devDependencies": {
@@ -10,6 +10,7 @@ Binaries are available and downloaded during install for the following platforms
10
10
  - Operating systems:
11
11
  - Ubuntu 20.04 (amd64/arm64)
12
12
  - macOS 12 (amd64/arm64)
13
+ - Windows (amd64)
13
14
  - Node.js 14, 16, 18
14
15
 
15
16
  Run:
@@ -172,6 +173,8 @@ var map = new mbgl.Map({
172
173
  response.data = body;
173
174
 
174
175
  callback(null, response);
176
+ } else if (res.statusCode == 204) {
177
+ callback();
175
178
  } else {
176
179
  callback(new Error(JSON.parse(body).message));
177
180
  }
@@ -35,7 +35,7 @@ declare module '@maplibre/maplibre-gl-native' {
35
35
  /**
36
36
  * Will be used during a `Map.render` call to request all necessary map resources (tiles, fonts...)
37
37
  */
38
- request: (
38
+ request?: (
39
39
  request: { url: string; kind: ResourceKind },
40
40
  callback: (error?: Error, response?: RequestResponse) => void,
41
41
  ) => void;
@@ -60,6 +60,8 @@ declare module '@maplibre/maplibre-gl-native' {
60
60
  */
61
61
  type RenderOptions = {
62
62
  /**
63
+ * Zoom level
64
+ *
63
65
  * @default 0
64
66
  */
65
67
  zoom?: number;
@@ -109,21 +111,116 @@ declare module '@maplibre/maplibre-gl-native' {
109
111
  * A `Map` instance is used to render images from map views
110
112
  */
111
113
  class Map {
112
- constructor(mapOptions: MapOptions);
114
+ constructor(mapOptions?: MapOptions);
113
115
 
116
+ /**
117
+ * Load a style into a map
118
+ */
114
119
  load: (style: any) => void;
115
120
 
116
121
  /**
117
- * Render a specific map view to an image with previously loaded map styles
122
+ * Render a specific map view to an image with previously loaded map styles with render options.
118
123
  */
119
- render: (
120
- renderOptions: RenderOptions,
121
- callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void,
122
- ) => void;
124
+ render(renderOptions: RenderOptions, callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void): void;
125
+
126
+ /**
127
+ * Render a specific map view to an image with previously loaded map styles without render options.
128
+ */
129
+ render(callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void): void;
123
130
 
124
131
  /**
125
132
  * Call to permanently dispose the internal map resources, instance can't be used for further render calls
126
133
  */
127
134
  release: () => void;
135
+
136
+ /**
137
+ * Add source to map's style
138
+ */
139
+ addSource: (sourceId: string, source: object) => void;
140
+
141
+ /**
142
+ * Remove source from map's style
143
+ */
144
+ removeSource: (sourceId: string) => void;
145
+
146
+ /**
147
+ * Add layer to map's style
148
+ */
149
+ addLayer: (layer: object, beforeId?: string) => void;
150
+
151
+ /**
152
+ * Remove layer from map's style
153
+ */
154
+ removeLayer: (layerId: string) => void;
155
+
156
+ /**
157
+ * Add image to map's style
158
+ */
159
+ addImage: (imageId: string, image: any) => void;
160
+
161
+ /**
162
+ * Remove image from map's style
163
+ */
164
+ removeImage: (imageId: string) => void;
165
+
166
+ /**
167
+ * Set the extent of the zoom for a specified layer
168
+ */
169
+ setLayerZoomRange: (layerId: string, minZoom: number, maxZoom: number) => void;
170
+
171
+ /**
172
+ * Set the value for a layer's property
173
+ */
174
+ setLayoutProperty: (layerId: string, name: string, value: string) => void;
175
+
176
+ /**
177
+ * Set filter for specified style layer
178
+ */
179
+ setFilter: (layerId: string, filter: [] | null | undefined) => void;
180
+
181
+ /**
182
+ * Set size of the tile
183
+ */
184
+ setSize: (size: [number, number]) => void;
185
+
186
+ /**
187
+ * Set the center of the map
188
+ */
189
+ setCenter: (center: [number, number]) => void;
190
+
191
+ /**
192
+ * Set zoom of the map
193
+ */
194
+ setZoom: (zoom: number) => void;
195
+
196
+ /**
197
+ * Set bearing (rotation) of map
198
+ */
199
+ setBearing: (bearing: number) => void;
200
+
201
+ /**
202
+ * Set pitch (tilt angle) of map
203
+ */
204
+ setPitch: (pitch: number) => void;
205
+
206
+ /**
207
+ * Set light value of map
208
+ */
209
+ setLight: (light: any) => void;
210
+
211
+ /**
212
+ * Set axonometric view of map
213
+ */
214
+ setAxonometric: (state: boolean) => void;
215
+
216
+ /**
217
+ * Set X skew of map
218
+ */
219
+ setXSkew: (x: number) => void;
220
+
221
+ /**
222
+ * Set Y skew of map
223
+ */
224
+ setYSkew: (y: number) => void;
128
225
  }
129
226
  }
@@ -6,43 +6,49 @@ var mbgl = require('../../lib/node-v' + process.versions.modules + '/mbgl');
6
6
  var constructor = mbgl.Map.prototype.constructor;
7
7
 
8
8
  var Map = function(options) {
9
- if (!(options instanceof Object)) {
9
+ if (options && !(options instanceof Object)) {
10
10
  throw TypeError("Requires an options object as first argument");
11
11
  }
12
12
 
13
- if (!options.hasOwnProperty('request') || !(options.request instanceof Function)) {
14
- throw TypeError("Options object must have a 'request' method");
13
+ if (options && options.hasOwnProperty('request') && !(options.request instanceof Function)) {
14
+ throw TypeError("Options object 'request' property must be a function");
15
15
  }
16
16
 
17
- var request = options.request;
18
-
19
- return new constructor(Object.assign(options, {
20
- request: function(req) {
21
- // Protect against `request` implementations that call the callback synchronously,
22
- // call it multiple times, or throw exceptions.
23
- // http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
24
-
25
- var responded = false;
26
- var callback = function() {
27
- var args = arguments;
28
- if (!responded) {
29
- responded = true;
30
- process.nextTick(function() {
31
- req.respond.apply(req, args);
32
- });
33
- } else {
34
- console.warn('request function responded multiple times; it should call the callback only once');
17
+ if (options && options.request) {
18
+ var request = options.request;
19
+
20
+ return new constructor(Object.assign(options, {
21
+ request: function(req) {
22
+ // Protect against `request` implementations that call the callback synchronously,
23
+ // call it multiple times, or throw exceptions.
24
+ // http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
25
+
26
+ var responded = false;
27
+ var callback = function() {
28
+ var args = arguments;
29
+ if (!responded) {
30
+ responded = true;
31
+ process.nextTick(function() {
32
+ req.respond.apply(req, args);
33
+ });
34
+ } else {
35
+ console.warn('request function responded multiple times; it should call the callback only once');
36
+ }
37
+ };
38
+
39
+ try {
40
+ request(req, callback);
41
+ } catch (e) {
42
+ console.warn('request function threw an exception; it should call the callback with an error instead');
43
+ callback(e);
35
44
  }
36
- };
37
-
38
- try {
39
- request(req, callback);
40
- } catch (e) {
41
- console.warn('request function threw an exception; it should call the callback with an error instead');
42
- callback(e);
43
45
  }
44
- }
45
- }));
46
+ }));
47
+ } else if (options) {
48
+ return new constructor(options);
49
+ } else {
50
+ return new constructor();
51
+ }
46
52
  };
47
53
 
48
54
  Map.prototype = mbgl.Map.prototype;