maplibre-gl 3.2.0 → 3.2.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/build/generate-docs.ts +1 -1
- package/build/generate-struct-arrays.ts +3 -2
- 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 +351 -281
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +254 -181
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +30 -30
- package/src/data/array_types.g.ts +32 -10
- package/src/data/bucket/circle_bucket.ts +1 -0
- package/src/data/bucket/line_bucket.ts +1 -0
- package/src/data/bucket/symbol_bucket.ts +1 -0
- package/src/data/feature_index.ts +1 -0
- package/src/data/program_configuration.ts +1 -0
- package/src/data/segment.ts +2 -0
- package/src/geo/transform.test.ts +9 -16
- package/src/geo/transform.ts +11 -32
- package/src/gl/context.ts +1 -0
- package/src/gl/framebuffer.ts +1 -0
- package/src/gl/index_buffer.ts +1 -0
- package/src/gl/render_pool.ts +2 -1
- package/src/gl/vertex_buffer.ts +1 -0
- package/src/render/draw_fill.test.ts +1 -1
- package/src/render/draw_symbol.test.ts +3 -3
- package/src/render/image_atlas.ts +1 -0
- package/src/render/line_atlas.ts +1 -0
- package/src/render/painter.ts +1 -1
- package/src/render/program.ts +1 -1
- package/src/render/render_to_texture.ts +31 -14
- package/src/render/terrain.test.ts +17 -0
- package/src/render/terrain.ts +34 -2
- package/src/render/texture.ts +1 -0
- package/src/render/uniform_binding.ts +2 -0
- package/src/render/vertex_array_object.ts +1 -0
- package/src/shaders/symbol_sdf.fragment.glsl +9 -3
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
- package/src/source/canvas_source.ts +1 -3
- package/src/source/geojson_source.ts +1 -3
- package/src/source/image_source.ts +2 -4
- package/src/source/raster_dem_tile_source.test.ts +14 -0
- package/src/source/raster_dem_tile_source.ts +0 -11
- package/src/source/raster_tile_source.test.ts +13 -0
- package/src/source/source_cache.ts +1 -0
- package/src/source/source_state.ts +1 -0
- package/src/source/terrain_source_cache.ts +1 -0
- package/src/source/tile.ts +1 -0
- package/src/source/tile_cache.ts +1 -1
- package/src/source/tile_id.ts +1 -0
- package/src/source/vector_tile_worker_source.test.ts +116 -67
- package/src/source/vector_tile_worker_source.ts +30 -16
- package/src/source/worker_source.ts +1 -0
- package/src/source/worker_tile.test.ts +143 -0
- package/src/source/worker_tile.ts +26 -7
- package/src/style/evaluation_parameters.ts +1 -0
- package/src/style/properties.ts +14 -0
- package/src/style/style.ts +1 -0
- package/src/style/style_glyph.ts +1 -0
- package/src/symbol/collision_index.ts +1 -0
- package/src/symbol/grid_index.ts +1 -0
- package/src/ui/camera.test.ts +12 -9
- package/src/ui/camera.ts +77 -95
- package/src/ui/handler/box_zoom.ts +1 -3
- package/src/ui/handler/click_zoom.ts +1 -3
- package/src/ui/handler/keyboard.ts +1 -3
- package/src/ui/handler/scroll_zoom.ts +1 -3
- package/src/ui/handler/shim/dblclick_zoom.ts +1 -3
- package/src/ui/handler/shim/drag_pan.ts +1 -3
- package/src/ui/handler/shim/drag_rotate.ts +1 -3
- package/src/ui/handler/shim/two_fingers_touch.ts +1 -3
- package/src/ui/handler/transform-provider.ts +1 -0
- package/src/ui/handler/two_fingers_touch.ts +1 -3
- package/src/ui/handler_manager.ts +2 -2
- package/src/ui/hash.ts +1 -2
- package/src/ui/map.test.ts +17 -12
- package/src/ui/map.ts +132 -44
- package/src/ui/map_events.test.ts +76 -0
- package/src/ui/marker.test.ts +1 -1
- package/src/util/ajax.test.ts +33 -0
- package/src/util/ajax.ts +5 -0
- package/src/util/image.ts +1 -0
- package/src/util/image_request.ts +2 -2
- package/src/util/performance.ts +1 -2
- package/src/util/struct_array.ts +5 -1
- package/src/util/test/mock_fetch.ts +51 -0
package/src/util/ajax.test.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from './ajax';
|
|
8
8
|
|
|
9
9
|
import {fakeServer, FakeServer} from 'nise';
|
|
10
|
+
import {destroyFetchMock, FetchMock, RequestMock, setupFetchMock} from './test/mock_fetch';
|
|
10
11
|
|
|
11
12
|
function readAsText(blob) {
|
|
12
13
|
return new Promise((resolve, reject) => {
|
|
@@ -141,4 +142,36 @@ describe('ajax', () => {
|
|
|
141
142
|
// edge case
|
|
142
143
|
expect(sameOrigin('://foo')).toBe(true);
|
|
143
144
|
});
|
|
145
|
+
|
|
146
|
+
describe('requests parameters', () => {
|
|
147
|
+
let fetch: FetchMock;
|
|
148
|
+
|
|
149
|
+
beforeEach(() => {
|
|
150
|
+
fetch = setupFetchMock();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
afterEach(() => {
|
|
154
|
+
destroyFetchMock();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('should be provided to fetch API in getArrayBuffer function', (done) => {
|
|
158
|
+
getArrayBuffer({url: 'http://example.com/test-params.json', cache: 'force-cache', headers: {'Authorization': 'Bearer 123'}}, () => {
|
|
159
|
+
expect(fetch).toHaveBeenCalledTimes(1);
|
|
160
|
+
expect(fetch).toHaveBeenCalledWith(expect.objectContaining({url: 'http://example.com/test-params.json', method: 'GET', cache: 'force-cache'}));
|
|
161
|
+
expect((fetch.mock.calls[0][0] as RequestMock).headers.get('Authorization')).toBe('Bearer 123');
|
|
162
|
+
|
|
163
|
+
done();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('should be provided to fetch API in getJSON function', (done) => {
|
|
168
|
+
getJSON({url: 'http://example.com/test-params.json', cache: 'force-cache', headers: {'Authorization': 'Bearer 123'}}, () => {
|
|
169
|
+
expect(fetch).toHaveBeenCalledTimes(1);
|
|
170
|
+
expect(fetch).toHaveBeenCalledWith(expect.objectContaining({url: 'http://example.com/test-params.json', method: 'GET', cache: 'force-cache'}));
|
|
171
|
+
expect((fetch.mock.calls[0][0] as RequestMock).headers.get('Authorization')).toBe('Bearer 123');
|
|
172
|
+
|
|
173
|
+
done();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
144
177
|
});
|
package/src/util/ajax.ts
CHANGED
|
@@ -49,6 +49,10 @@ export type RequestParameters = {
|
|
|
49
49
|
* If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.
|
|
50
50
|
*/
|
|
51
51
|
collectResourceTiming?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)
|
|
54
|
+
*/
|
|
55
|
+
cache?: RequestCache;
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
/**
|
|
@@ -123,6 +127,7 @@ function makeFetchRequest(requestParameters: RequestParameters, callback: Respon
|
|
|
123
127
|
body: requestParameters.body,
|
|
124
128
|
credentials: requestParameters.credentials,
|
|
125
129
|
headers: requestParameters.headers,
|
|
130
|
+
cache: requestParameters.cache,
|
|
126
131
|
referrer: getReferrer(),
|
|
127
132
|
signal: controller.signal
|
|
128
133
|
});
|
package/src/util/image.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {Cancelable} from '../types/cancelable';
|
|
|
2
2
|
import {RequestParameters, ExpiryData, makeRequest, sameOrigin, getProtocolAction} from './ajax';
|
|
3
3
|
import type {Callback} from '../types/callback';
|
|
4
4
|
|
|
5
|
-
import {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker} from './util';
|
|
5
|
+
import {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker, isImageBitmap} from './util';
|
|
6
6
|
import {webpSupported} from './webp_supported';
|
|
7
7
|
import {config} from './config';
|
|
8
8
|
|
|
@@ -202,7 +202,7 @@ export namespace ImageRequest {
|
|
|
202
202
|
expires?: string | null): void => {
|
|
203
203
|
if (err) {
|
|
204
204
|
callback(err);
|
|
205
|
-
} else if (data instanceof HTMLImageElement || data
|
|
205
|
+
} else if (data instanceof HTMLImageElement || isImageBitmap(data)) {
|
|
206
206
|
// User using addProtocol can directly return HTMLImageElement/ImageBitmap type
|
|
207
207
|
// If HtmlImageElement is used to get image then response type will be HTMLImageElement
|
|
208
208
|
callback(null, data);
|
package/src/util/performance.ts
CHANGED
package/src/util/struct_array.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type {Transferable} from '../types/transferable';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* @internal
|
|
6
7
|
* A view type size
|
|
7
8
|
*/
|
|
8
9
|
const viewTypes = {
|
|
@@ -16,11 +17,12 @@ const viewTypes = {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/**
|
|
20
|
+
* @internal
|
|
19
21
|
* A view type size
|
|
20
22
|
*/
|
|
21
23
|
export type ViewType = keyof typeof viewTypes;
|
|
22
24
|
|
|
23
|
-
/** */
|
|
25
|
+
/** @internal */
|
|
24
26
|
class Struct {
|
|
25
27
|
_pos1: number;
|
|
26
28
|
_pos2: number;
|
|
@@ -48,6 +50,7 @@ const DEFAULT_CAPACITY = 128;
|
|
|
48
50
|
const RESIZE_MULTIPLIER = 5;
|
|
49
51
|
|
|
50
52
|
/**
|
|
53
|
+
* @internal
|
|
51
54
|
* A struct array memeber
|
|
52
55
|
*/
|
|
53
56
|
export type StructArrayMember = {
|
|
@@ -72,6 +75,7 @@ export type SerializedStructArray = {
|
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
/**
|
|
78
|
+
* @internal
|
|
75
79
|
* `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`
|
|
76
80
|
* making it behave like an array of typed structs.
|
|
77
81
|
*
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class RequestMock implements Partial<Request> {
|
|
2
|
+
public readonly cache: RequestCache;
|
|
3
|
+
public readonly headers: Headers = new Headers();
|
|
4
|
+
public readonly method?: string;
|
|
5
|
+
public readonly url?: string;
|
|
6
|
+
|
|
7
|
+
public get signal(): AbortSignal {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
constructor(input: RequestInfo | URL, init?: RequestInit) {
|
|
12
|
+
this.cache = typeof input === 'object' && 'cache' in input ? input.cache : init.cache;
|
|
13
|
+
this.method = typeof input === 'object' && 'method' in input ? input.method : init.method;
|
|
14
|
+
this.url = typeof input === 'object' && 'url' in input ? input.url : input.toString();
|
|
15
|
+
this.headers = typeof input === 'object' && 'headers' in input ? new Headers(input.headers) : new Headers(init.headers || {});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class AbortControllerMock {
|
|
20
|
+
public signal: AbortSignal;
|
|
21
|
+
|
|
22
|
+
public abort(): void {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type FetchMock = jest.Mock<Promise<Response>, [input: RequestInfo | URL, init?: RequestInit], any>;
|
|
26
|
+
|
|
27
|
+
let _AbortController: typeof AbortController;
|
|
28
|
+
let _Request: typeof Request;
|
|
29
|
+
let _fetch: typeof fetch;
|
|
30
|
+
|
|
31
|
+
export function destroyFetchMock(): void {
|
|
32
|
+
global.AbortController = _AbortController ?? global.AbortController;
|
|
33
|
+
global.Request = _Request ?? global.Request;
|
|
34
|
+
global.fetch = _fetch ?? global.fetch;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function setupFetchMock(): FetchMock {
|
|
38
|
+
_AbortController = _AbortController ?? global.AbortController;
|
|
39
|
+
_Request = _Request ?? global.Request;
|
|
40
|
+
_fetch = _fetch ?? global.fetch;
|
|
41
|
+
|
|
42
|
+
const fetchMock = jest.fn(async (_input: RequestInfo | URL, _init?: RequestInit): Promise<Response> => {
|
|
43
|
+
return <Response>{};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
global.AbortController = AbortControllerMock;
|
|
47
|
+
global.Request = RequestMock as unknown as typeof Request;
|
|
48
|
+
global.fetch = fetchMock;
|
|
49
|
+
|
|
50
|
+
return fetchMock;
|
|
51
|
+
}
|