maplibre-gl 3.5.1 → 3.5.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.
@@ -2241,6 +2241,10 @@ export declare class TileCache {
2241
2241
  */
2242
2242
  filter(filterFn: (tile: Tile) => boolean): void;
2243
2243
  }
2244
+ export type SerializedObject<S extends Serialized = any> = {
2245
+ [_: string]: S;
2246
+ };
2247
+ export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array<Serialized> | SerializedObject;
2244
2248
  export declare class ThrottledInvoker {
2245
2249
  _channel: MessageChannel;
2246
2250
  _triggered: boolean;
@@ -2249,50 +2253,6 @@ export declare class ThrottledInvoker {
2249
2253
  trigger(): void;
2250
2254
  remove(): void;
2251
2255
  }
2252
- export declare class Actor {
2253
- target: any;
2254
- parent: any;
2255
- mapId: string | null;
2256
- callbacks: {
2257
- number: any;
2258
- };
2259
- name: string;
2260
- tasks: {
2261
- number: any;
2262
- };
2263
- taskQueue: Array<number>;
2264
- cancelCallbacks: {
2265
- number: Cancelable;
2266
- };
2267
- invoker: ThrottledInvoker;
2268
- globalScope: any;
2269
- /**
2270
- * @param target - The target
2271
- * @param parent - The parent
2272
- * @param mapId - A unique identifier for the Map instance using this Actor.
2273
- */
2274
- constructor(target: any, parent: any, mapId?: string);
2275
- /**
2276
- * Sends a message from a main-thread map to a Worker or from a Worker back to
2277
- * a main-thread map instance.
2278
- *
2279
- * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.
2280
- * @param targetMapId - A particular mapId to which to send this message.
2281
- */
2282
- send(type: string, data: unknown, callback?: Function | null, targetMapId?: string | null, mustQueue?: boolean): Cancelable;
2283
- receive: (message: {
2284
- data: {
2285
- id: number;
2286
- type: string;
2287
- data: unknown;
2288
- targetMapId?: string | null;
2289
- mustQueue: boolean;
2290
- };
2291
- }) => void;
2292
- process: () => void;
2293
- processTask(id: number, task: any): void;
2294
- remove(): void;
2295
- }
2296
2256
  export type DEMEncoding = "mapbox" | "terrarium" | "custom";
2297
2257
  export declare class DEMData {
2298
2258
  uid: string;
@@ -2313,6 +2273,22 @@ export declare class DEMData {
2313
2273
  getPixels(): RGBAImage;
2314
2274
  backfillBorder(borderTile: DEMData, dx: number, dy: number): void;
2315
2275
  }
2276
+ export type TileParameters = {
2277
+ source: string;
2278
+ uid: string;
2279
+ };
2280
+ export type WorkerTileParameters = TileParameters & {
2281
+ tileID: OverscaledTileID;
2282
+ request: RequestParameters;
2283
+ zoom: number;
2284
+ maxZoom: number;
2285
+ tileSize: number;
2286
+ promoteId: PromoteIdSpecification;
2287
+ pixelRatio: number;
2288
+ showCollisionBoxes: boolean;
2289
+ collectResourceTiming?: boolean;
2290
+ returnDependencies?: boolean;
2291
+ };
2316
2292
  /**
2317
2293
  * @internal
2318
2294
  * The worker tile's result type
@@ -2335,24 +2311,127 @@ export type WorkerTileResult = {
2335
2311
  } | null;
2336
2312
  glyphPositions?: GlyphPositions | null;
2337
2313
  };
2338
- export type MessageListener = (a: {
2339
- data: any;
2340
- target: any;
2341
- }) => unknown;
2342
- export interface WorkerInterface {
2343
- addEventListener(type: "message", listener: MessageListener): void;
2344
- removeEventListener(type: "message", listener: MessageListener): void;
2345
- postMessage(message: any): void;
2346
- terminate(): void;
2314
+ export type WorkerTileCallback = (error?: Error | null, result?: WorkerTileResult | null) => void;
2315
+ /**
2316
+ * May be implemented by custom source types to provide code that can be run on
2317
+ * the WebWorkers. In addition to providing a custom
2318
+ * {@link WorkerSource#loadTile}, any other methods attached to a `WorkerSource`
2319
+ * implementation may also be targeted by the {@link Source} via
2320
+ * `dispatcher.getActor().send('source-type.methodname', params, callback)`.
2321
+ *
2322
+ * @see {@link Map#addSourceType}
2323
+ */
2324
+ export interface WorkerSource {
2325
+ availableImages: Array<string>;
2326
+ /**
2327
+ * Loads a tile from the given params and parse it into buckets ready to send
2328
+ * back to the main thread for rendering. Should call the callback with:
2329
+ * `{ buckets, featureIndex, collisionIndex, rawTileData}`.
2330
+ */
2331
+ loadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void;
2332
+ /**
2333
+ * Re-parses a tile that has already been loaded. Yields the same data as
2334
+ * {@link WorkerSource#loadTile}.
2335
+ */
2336
+ reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void;
2337
+ /**
2338
+ * Aborts loading a tile that is in progress.
2339
+ */
2340
+ abortTile(params: TileParameters, callback: WorkerTileCallback): void;
2341
+ /**
2342
+ * Removes this tile from any local caches.
2343
+ */
2344
+ removeTile(params: TileParameters, callback: WorkerTileCallback): void;
2345
+ /**
2346
+ * Tells the WorkerSource to abort in-progress tasks and release resources.
2347
+ * The foreground Source is responsible for ensuring that 'removeSource' is
2348
+ * the last message sent to the WorkerSource.
2349
+ */
2350
+ removeSource?: (params: {
2351
+ source: string;
2352
+ }, callback: WorkerTileCallback) => void;
2353
+ }
2354
+ export interface ActorTarget {
2355
+ addEventListener: typeof window.addEventListener;
2356
+ removeEventListener: typeof window.removeEventListener;
2357
+ postMessage: typeof window.postMessage;
2358
+ terminate?: () => void;
2359
+ }
2360
+ export interface WorkerSourceProvider {
2361
+ getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource;
2362
+ }
2363
+ export interface GlyphsProvider {
2364
+ getGlyphs(mapId: string, params: {
2365
+ stacks: {
2366
+ [_: string]: Array<number>;
2367
+ };
2368
+ source: string;
2369
+ tileID: OverscaledTileID;
2370
+ type: string;
2371
+ }, callback: Callback<{
2372
+ [_: string]: {
2373
+ [_: number]: StyleGlyph;
2374
+ };
2375
+ }>): any;
2376
+ }
2377
+ export type MessageType = "<response>" | "<cancel>" | "geojson.getClusterExpansionZoom" | "geojson.getClusterChildren" | "geojson.getClusterLeaves" | "geojson.loadData" | "removeSource" | "loadWorkerSource" | "loadDEMTile" | "removeDEMTile" | "removeTile" | "reloadTile" | "abortTile" | "loadTile" | "getTile" | "getGlyphs" | "getImages" | "setImages" | "syncRTLPluginState" | "setReferrer" | "setLayers" | "updateLayers";
2378
+ export type MessageData = {
2379
+ id: string;
2380
+ type: MessageType;
2381
+ data?: Serialized;
2382
+ targetMapId?: string | number | null;
2383
+ mustQueue?: boolean;
2384
+ error?: Serialized | null;
2385
+ hasCallback?: boolean;
2386
+ sourceMapId: string | number | null;
2387
+ };
2388
+ export type Message = {
2389
+ data: MessageData;
2390
+ };
2391
+ export declare class Actor {
2392
+ target: ActorTarget;
2393
+ parent: WorkerSourceProvider | GlyphsProvider;
2394
+ mapId: string | number | null;
2395
+ callbacks: {
2396
+ [x: number]: Function;
2397
+ };
2398
+ name: string;
2399
+ tasks: {
2400
+ [x: number]: MessageData;
2401
+ };
2402
+ taskQueue: Array<string>;
2403
+ cancelCallbacks: {
2404
+ [x: number]: () => void;
2405
+ };
2406
+ invoker: ThrottledInvoker;
2407
+ globalScope: ActorTarget;
2408
+ /**
2409
+ * @param target - The target
2410
+ * @param parent - The parent
2411
+ * @param mapId - A unique identifier for the Map instance using this Actor.
2412
+ */
2413
+ constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number);
2414
+ /**
2415
+ * Sends a message from a main-thread map to a Worker or from a Worker back to
2416
+ * a main-thread map instance.
2417
+ *
2418
+ * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.
2419
+ * @param targetMapId - A particular mapId to which to send this message.
2420
+ */
2421
+ send(type: MessageType, data: unknown, callback?: Function | null, targetMapId?: string | null, mustQueue?: boolean): Cancelable;
2422
+ receive: (message: Message) => void;
2423
+ process: () => void;
2424
+ processTask(id: string, task: MessageData): void;
2425
+ remove(): void;
2347
2426
  }
2348
2427
  export declare class WorkerPool {
2349
2428
  static workerCount: number;
2350
2429
  active: {
2351
2430
  [_ in number | string]: boolean;
2352
2431
  };
2353
- workers: Array<WorkerInterface>;
2432
+ workers: Array<ActorTarget>;
2354
2433
  constructor();
2355
- acquire(mapId: number | string): Array<WorkerInterface>;
2434
+ acquire(mapId: number | string): Array<ActorTarget>;
2356
2435
  release(mapId: number | string): void;
2357
2436
  isPreloaded(): boolean;
2358
2437
  numActive(): number;
@@ -2361,15 +2440,12 @@ export declare class Dispatcher {
2361
2440
  workerPool: WorkerPool;
2362
2441
  actors: Array<Actor>;
2363
2442
  currentActor: number;
2364
- id: number;
2365
- static Actor: {
2366
- new (...args: any): Actor;
2367
- };
2368
- constructor(workerPool: WorkerPool, parent: any, mapId: number);
2443
+ id: string | number;
2444
+ constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number);
2369
2445
  /**
2370
2446
  * Broadcast a message to all Workers.
2371
2447
  */
2372
- broadcast(type: string, data: unknown, cb?: (...args: any[]) => any): void;
2448
+ broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any): void;
2373
2449
  /**
2374
2450
  * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion.
2375
2451
  * @returns An actor object backed by a web worker for processing messages.
@@ -3018,7 +3094,7 @@ export type SymbolFeature = {
3018
3094
  sourceLayerIndex: number;
3019
3095
  geometry: Array<Array<Point>>;
3020
3096
  properties: any;
3021
- type: "Point" | "LineString" | "Polygon";
3097
+ type: "Unknown" | "Point" | "LineString" | "Polygon";
3022
3098
  id?: any;
3023
3099
  };
3024
3100
  export type SortKeyRange = {
@@ -4796,7 +4872,7 @@ export type BucketFeature = {
4796
4872
  sourceLayerIndex: number;
4797
4873
  geometry: Array<Array<Point>>;
4798
4874
  properties: any;
4799
- type: 1 | 2 | 3;
4875
+ type: 0 | 1 | 2 | 3;
4800
4876
  id?: any;
4801
4877
  readonly patterns: {
4802
4878
  [_: string]: {