maplibre-gl-layers 0.19.0 → 1.1.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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +8646 -6335
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +1353 -7
  5. package/dist/index.mjs +8645 -6334
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/wasm/offloads-nosimd.wasm +0 -0
  8. package/dist/wasm/offloads-simd-mt.wasm +0 -0
  9. package/dist/wasm/offloads-simd.wasm +0 -0
  10. package/package.json +10 -9
  11. package/dist/SpriteLayer.d.ts +0 -41
  12. package/dist/config.d.ts +0 -26
  13. package/dist/const.d.ts +0 -98
  14. package/dist/default.d.ts +0 -29
  15. package/dist/gl/atlas.d.ts +0 -64
  16. package/dist/gl/hitTest.d.ts +0 -54
  17. package/dist/gl/mouseEvents.d.ts +0 -36
  18. package/dist/gl/shader.d.ts +0 -114
  19. package/dist/gl/text.d.ts +0 -17
  20. package/dist/gl/tracking.d.ts +0 -36
  21. package/dist/host/calculationHost.d.ts +0 -87
  22. package/dist/host/mapLibreProjectionHost.d.ts +0 -18
  23. package/dist/host/projectionHost.d.ts +0 -62
  24. package/dist/host/runtime.d.ts +0 -38
  25. package/dist/host/wasmCalculationHost.d.ts +0 -72
  26. package/dist/host/wasmHost.d.ts +0 -133
  27. package/dist/host/wasmProjectionHost.d.ts +0 -19
  28. package/dist/internalTypes.d.ts +0 -582
  29. package/dist/interpolation/degreeInterpolation.d.ts +0 -48
  30. package/dist/interpolation/distanceInterpolation.d.ts +0 -31
  31. package/dist/interpolation/easing.d.ts +0 -26
  32. package/dist/interpolation/interpolationChannels.d.ts +0 -59
  33. package/dist/interpolation/locationInterpolation.d.ts +0 -30
  34. package/dist/interpolation/rotationInterpolation.d.ts +0 -40
  35. package/dist/types.d.ts +0 -944
  36. package/dist/utils/color.d.ts +0 -20
  37. package/dist/utils/image.d.ts +0 -32
  38. package/dist/utils/looseQuadTree.d.ts +0 -34
  39. package/dist/utils/math.d.ts +0 -451
  40. package/dist/utils/utils.d.ts +0 -37
  41. package/dist/wasm/config.json.d.ts +0 -16
package/dist/index.d.ts CHANGED
@@ -1,15 +1,1361 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.19.0
3
+ * version: 1.1.0
4
4
  * description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/maplibre-gl-layers.git
8
- * git.commit.hash: 7bc93c11d7855dedb8d60f140af4e413252c32a7
8
+ * git.commit.hash: 6308f45aa959024297cb716990f16213b89b6bd0
9
9
  */
10
10
 
11
- export * from './types';
12
- export * from './default';
13
- export * from './utils/image';
14
- export { initializeRuntimeHost, releaseRuntimeHost, detectMultiThreadedModuleAvailability, type MultiThreadedModuleAvailability, } from './host/runtime';
15
- export * from './SpriteLayer';
11
+ import { CustomLayerInterface } from 'maplibre-gl';
12
+
13
+ /**
14
+ * Applies auto-rotation to all images within a sprite when movement exceeds the configured threshold.
15
+ * @template T Arbitrary sprite tag type.
16
+ * @param {InternalSpriteCurrentState<T>} sprite - Sprite undergoing potential rotation update.
17
+ * @param {SpriteLocation} nextLocation - Destination location used to derive bearing and distance.
18
+ * @returns {boolean} `true` when auto-rotation was applied, `false` otherwise.
19
+ */
20
+ export declare const applyAutoRotation: <T>(sprite: InternalSpriteCurrentState<T>, nextLocation: SpriteLocation, forceAutoRotation: boolean) => boolean;
21
+
22
+ /**
23
+ * Better text filtering options than default options.
24
+ */
25
+ export declare const BETTER_TEXTURE_FILTERING_OPTIONS: SpriteTextureFilteringOptions;
26
+
27
+ /**
28
+ * Creates internal sprite image state from initialization data and layer bookkeeping fields.
29
+ * @param {SpriteImageDefinitionInit} imageInit - Caller-provided image definition.
30
+ * @param {number} subLayer - Sub-layer index the image belongs to.
31
+ * @param {number} order - Ordering slot within the sub-layer.
32
+ * @param {SpriteOriginReference} originReference - Encode/Decode origin reference.
33
+ * @param {boolean} invalidated - Initially invalidate state.
34
+ * @returns {InternalSpriteImageState} Normalized internal state ready for rendering.
35
+ */
36
+ export declare const createImageStateFromInit: (imageInit: SpriteImageDefinitionInit, subLayer: number, order: number, originReference: SpriteOriginReference, invalidated: boolean, spriteAutoRotationDeg?: number) => InternalSpriteImageState;
37
+
38
+ /**
39
+ * Factory that creates the MapLibre layer interface for the sprite layer.
40
+ * Implements the CustomLayerInterface lifecycle (init -> render -> dispose), packing thousands
41
+ * of sprites into GPU buffers for efficient rendering. Supports optional scaling controls for
42
+ * billboard and surface modes.
43
+ *
44
+ * @template T Arbitrary tag type for per-sprite metadata.
45
+ * @param {SpriteLayerOptions} [options] Initial layer options such as ID or scaling settings.
46
+ * @returns {SpriteLayerInterface<T>} Interface for sprite add/update/remove operations and MapLibre hooks.
47
+ */
48
+ export declare const createSpriteLayer: <T = any>(options?: SpriteLayerOptions) => SpriteLayerInterface<T>;
49
+
50
+ /**
51
+ * Defaulted text filtering options.
52
+ */
53
+ export declare const DEFAULT_TEXTURE_FILTERING_OPTIONS: SpriteTextureFilteringOptions;
54
+
55
+ /**
56
+ * Detects SIMD and multi-threading module availability.
57
+ * @returns MultiThreadedModuleAvailability.
58
+ */
59
+ export declare const detectMultiThreadedModuleAvailability: () => MultiThreadedModuleAvailability;
60
+
61
+ /**
62
+ * Easing function type.
63
+ */
64
+ declare type EasingFunction = (progress: number) => number;
65
+
66
+ /**
67
+ * The handle value that using the instance.
68
+ */
69
+ declare type IdHandle = number;
70
+
71
+ /**
72
+ * Initialize maplibre-gl-layers runtime host.
73
+ * @param variantOrOptions Options.
74
+ * @returns Initialized calculation variant.
75
+ */
76
+ export declare const initializeRuntimeHost: (options?: SpriteLayerHostOptions) => Promise<SpriteLayerCalculationVariant>;
77
+
78
+ /**
79
+ * Current sprite mutable state view tracked internally by the layer.
80
+ */
81
+ declare interface InternalSpriteCurrentState<TTag> extends SpriteCurrentState<TTag> {
82
+ spriteId: string;
83
+ handle: IdHandle;
84
+ isEnabled: boolean;
85
+ visibilityDistanceMeters: number | undefined;
86
+ opacityMultiplier: number;
87
+ location: MutableSpriteInterpolatedValues<SpriteLocation>;
88
+ images: Map<number, Map<number, InternalSpriteImageState>>;
89
+ tag: TTag | null;
90
+ lastAutoRotationLocation: Readonly<SpriteLocation>;
91
+ currentAutoRotateDeg: number;
92
+ autoRotationInvalidated: boolean;
93
+ interpolationDirty: boolean;
94
+ cachedMercator: Readonly<SpriteMercatorCoordinate>;
95
+ cachedMercatorLng: number;
96
+ cachedMercatorLat: number;
97
+ cachedMercatorZ: number | undefined;
98
+ }
99
+
100
+ /**
101
+ * Base mutable attribute view for an image that composes a sprite.
102
+ */
103
+ declare interface InternalSpriteImageState extends SpriteImageState {
104
+ subLayer: number;
105
+ order: number;
106
+ imageId: string;
107
+ imageHandle: number;
108
+ mode: SpriteMode;
109
+ scale: number;
110
+ anchor: Readonly<SpriteAnchor>;
111
+ border: ResolvedSpriteImageLineAttribute | undefined;
112
+ borderPixelWidth: number;
113
+ leaderLine: ResolvedSpriteImageLineAttribute | undefined;
114
+ leaderLinePixelWidth: number;
115
+ rotateDeg: number;
116
+ opacity: number;
117
+ lodOpacity: number;
118
+ finalOpacity: MutableSpriteInterpolatedValues<number>;
119
+ offset: MutableSpriteImageInterpolatedOffset;
120
+ finalRotateDeg: MutableSpriteInterpolatedValues<number>;
121
+ autoRotation: boolean;
122
+ autoRotationMinDistanceMeters: number;
123
+ originLocation: Readonly<SpriteImageOriginLocation> | undefined;
124
+ originReferenceKey: SpriteOriginReferenceKey;
125
+ originRenderTargetIndex: SpriteOriginReferenceIndex;
126
+ interpolationDirty: boolean;
127
+ surfaceShaderInputs: Readonly<SurfaceShaderInputs> | undefined;
128
+ hitTestCorners: [
129
+ MutableSpriteScreenPoint,
130
+ MutableSpriteScreenPoint,
131
+ MutableSpriteScreenPoint,
132
+ MutableSpriteScreenPoint
133
+ ] | undefined;
134
+ }
135
+
136
+ /**
137
+ * Helper that loads an ImageBitmap from a URL.
138
+ * @param url Target image URL.
139
+ * @param options Optional loading options.
140
+ * @returns Promise resolving to the ImageBitmap.
141
+ * @remarks This function helps loading SVG with better manner.
142
+ */
143
+ export declare const loadImageBitmap: (url: string, options?: SpriteImageRegisterOptions) => Promise<ImageBitmap>;
144
+
145
+ /**
146
+ * SIMD and multi-threading module availability.
147
+ */
148
+ export declare interface MultiThreadedModuleAvailability {
149
+ /** Is available? */
150
+ readonly available: boolean;
151
+ /** Not available, reason text */
152
+ readonly reason?: string;
153
+ }
154
+
155
+ declare interface MutableSpriteImageInterpolatedOffset extends SpriteImageInterpolatedOffset {
156
+ offsetMeters: MutableSpriteInterpolatedValues<number>;
157
+ offsetDeg: MutableSpriteInterpolatedValues<number>;
158
+ }
159
+
160
+ /**
161
+ * Mutable counterpart to {@link SpriteInterpolatedValues}, used internally so SpriteLayer
162
+ * can reuse object references while still exposing readonly snapshots publicly.
163
+ */
164
+ declare interface MutableSpriteInterpolatedValues<TValue> extends SpriteInterpolatedValues<TValue> {
165
+ current: TValue;
166
+ from: TValue | undefined;
167
+ to: TValue | undefined;
168
+ invalidated: boolean | undefined;
169
+ interpolation: MutableSpriteInterpolation<TValue>;
170
+ }
171
+
172
+ /**
173
+ * Mutable interpolation states.
174
+ */
175
+ declare interface MutableSpriteInterpolation<TValue> {
176
+ state: SpriteInterpolationState<TValue> | null;
177
+ options: Readonly<SpriteInterpolationOptions> | null;
178
+ lastCommandValue: TValue;
179
+ baseValue: TValue | undefined;
180
+ targetValue: TValue | undefined;
181
+ }
182
+
183
+ /**
184
+ * Mutable point reused when computing hit-test corners.
185
+ */
186
+ declare interface MutableSpriteScreenPoint extends SpriteScreenPoint {
187
+ x: number;
188
+ y: number;
189
+ }
190
+
191
+ /**
192
+ * Helper that read an ImageBitmap from a blob.
193
+ * @param blob Target blob.
194
+ * @param options Optional reading options.
195
+ * @returns Promise resolving to the ImageBitmap.
196
+ * @remarks This function helps reading SVG with better manner.
197
+ */
198
+ export declare const readImageBitmap: (blob: Blob, options?: SpriteImageRegisterOptions) => Promise<ImageBitmap>;
199
+
200
+ /**
201
+ * Release maplibre-gl-layers runtime host.
202
+ * @returns
203
+ */
204
+ export declare const releaseRuntimeHost: () => void;
205
+
206
+ /** Line definition resolved for rendering. */
207
+ declare interface ResolvedSpriteImageLineAttribute extends SpriteImageLineAttributeState {
208
+ readonly rgba: RgbaColor;
209
+ }
210
+
211
+ declare type RgbaColor = readonly [number, number, number, number];
212
+
213
+ /**
214
+ * Anchor within the image.
215
+ * The sprite's base coordinate maps to this location; range is -1.0 to 1.0 relative to image size.
216
+ * x: -1.0 at left, 0.0 center, 1.0 right. y: -1.0 bottom, 0.0 center, 1.0 top.
217
+ * Values outside the range are accepted; clamp externally if needed.
218
+ */
219
+ export declare interface SpriteAnchor {
220
+ /** Horizontal offset; -1.0 left edge, 1.0 right edge. */
221
+ x: number;
222
+ /** Vertical offset; -1.0 bottom edge, 1.0 top edge. */
223
+ y: number;
224
+ }
225
+
226
+ /**
227
+ * Current runtime state of a sprite.
228
+ *
229
+ * @template TTag Tag type.
230
+ */
231
+ export declare interface SpriteCurrentState<TTag> {
232
+ /** Sprite identifier. */
233
+ readonly spriteId: string;
234
+ /** Indicates whether the sprite is enabled. */
235
+ readonly isEnabled: boolean;
236
+ /** Multiplier applied to every image opacity. */
237
+ readonly opacityMultiplier: number;
238
+ /**
239
+ * Pseudo LOD threshold for the sprite. When the camera distance exceeds this value,
240
+ * the sprite's images become invisible.
241
+ */
242
+ readonly visibilityDistanceMeters: number | undefined;
243
+ /**
244
+ * Location information including current, source, and destination coordinates.
245
+ * `from`/`to` are `undefined` when interpolation is inactive.
246
+ */
247
+ readonly location: SpriteInterpolatedValues<Readonly<SpriteLocation>>;
248
+ /** Current image states, grouped by sub-layer and order. */
249
+ readonly images: ReadonlyMap<number, ReadonlyMap<number, SpriteImageState>>;
250
+ /** Optional tag value; null indicates no tag. */
251
+ readonly tag: TTag | null;
252
+ }
253
+
254
+ /**
255
+ * Back easing definition.
256
+ */
257
+ export declare interface SpriteEasingBack {
258
+ readonly type: 'back';
259
+ /** Overshoot factor controlling how far past the target the curve goes. Defaults to 1.70158. */
260
+ overshoot?: number;
261
+ }
262
+
263
+ /**
264
+ * Bounce easing definition.
265
+ */
266
+ export declare interface SpriteEasingBounce {
267
+ readonly type: 'bounce';
268
+ /** Number of visible bounces before settling. Defaults to 3. */
269
+ bounces?: number;
270
+ /** Decay factor applied per bounce; range (0, 1]. Defaults to 0.5. */
271
+ decay?: number;
272
+ }
273
+
274
+ /**
275
+ * Cubic easing definition.
276
+ */
277
+ export declare interface SpriteEasingCubic {
278
+ readonly type: 'cubic';
279
+ /** Direction of the cubic curve. Defaults to in-out. */
280
+ mode?: 'in' | 'out' | 'in-out';
281
+ }
282
+
283
+ /**
284
+ * Ease easing definition.
285
+ */
286
+ export declare interface SpriteEasingEase {
287
+ readonly type: 'ease';
288
+ /** Power applied to the easing curve. Defaults to 3. */
289
+ power?: number;
290
+ /** Direction of the easing curve. Defaults to in-out. */
291
+ mode?: 'in' | 'out' | 'in-out';
292
+ }
293
+
294
+ /**
295
+ * Exponential easing definition.
296
+ */
297
+ export declare interface SpriteEasingExponential {
298
+ readonly type: 'exponential';
299
+ /** Growth rate used by the exponential curve. Defaults to 5. */
300
+ exponent?: number;
301
+ /** Direction of the exponential curve. Defaults to in-out. */
302
+ mode?: 'in' | 'out' | 'in-out';
303
+ }
304
+
305
+ /**
306
+ * Linear easing definition.
307
+ */
308
+ export declare interface SpriteEasingLinear {
309
+ readonly type: 'linear';
310
+ }
311
+
312
+ /**
313
+ * Union of supported easing parameters.
314
+ */
315
+ export declare type SpriteEasingParam = SpriteEasingLinear | SpriteEasingEase | SpriteEasingExponential | SpriteEasingQuadratic | SpriteEasingCubic | SpriteEasingSine | SpriteEasingBounce | SpriteEasingBack;
316
+
317
+ /**
318
+ * Quadratic easing definition.
319
+ */
320
+ export declare interface SpriteEasingQuadratic {
321
+ readonly type: 'quadratic';
322
+ /** Direction of the quadratic curve. Defaults to in-out. */
323
+ mode?: 'in' | 'out' | 'in-out';
324
+ }
325
+
326
+ /**
327
+ * Sine easing definition.
328
+ */
329
+ export declare interface SpriteEasingSine {
330
+ readonly type: 'sine';
331
+ /** Direction of the sine ease. Defaults to in-out. */
332
+ mode?: 'in' | 'out' | 'in-out';
333
+ /** Multiplier applied to the sine amplitude. Defaults to 1. */
334
+ amplitude?: number;
335
+ }
336
+
337
+ /**
338
+ * Easing types.
339
+ */
340
+ export declare type SpriteEasingType = SpriteEasingParam['type'];
341
+
342
+ /**
343
+ * Initial attributes that define a sprite image.
344
+ */
345
+ export declare interface SpriteImageDefinitionInit {
346
+ /** Image ID to render. */
347
+ imageId: string;
348
+ /** Rendering mode. Defaults to surface. */
349
+ mode?: SpriteMode;
350
+ /** Opacity multiplier. Defaults to 1.0. */
351
+ opacity?: number;
352
+ /** Real-world meters represented by one pixel. Defaults to 1.0. */
353
+ scale?: number;
354
+ /** Anchor within the image. Defaults to [0.0, 0.0]. */
355
+ anchor?: SpriteAnchor;
356
+ /** Offset distance in meters from the sprite coordinate. Defaults to 0. */
357
+ offsetMeters?: number;
358
+ /** Offset angle in degrees. Defaults to 0. */
359
+ offsetDeg?: number;
360
+ /** Optional border rendered around the image. */
361
+ border?: SpriteImageLineAttribute;
362
+ /** Optional leader line rendered toward the origin image. */
363
+ leaderLine?: SpriteImageLineAttribute;
364
+ /**
365
+ * Determines which coordinate to anchor against.
366
+ * - Omitted: use "the sprite" base coordinate.
367
+ * - Provided: use the referenced image's anchor and offset (resolving references recursively).
368
+ */
369
+ originLocation?: SpriteImageOriginLocation;
370
+ /**
371
+ * Additional rotation in degrees. Defaults to 0.
372
+ * Billboard: clockwise degrees relative to the screen with 0 deg up.
373
+ * Surface: clockwise degrees from geographic north.
374
+ */
375
+ rotateDeg?: number;
376
+ /**
377
+ * Enables auto-rotation based on movement. Defaults to true in surface mode and false in billboard mode.
378
+ */
379
+ autoRotation?: boolean;
380
+ /**
381
+ * Minimum distance in meters before auto-rotation updates. Defaults to 20; <= 0 updates immediately.
382
+ */
383
+ autoRotationMinDistanceMeters?: number;
384
+ /**
385
+ * Optional interpolation settings.
386
+ */
387
+ interpolation?: SpriteImageInterpolationOptions;
388
+ }
389
+
390
+ /**
391
+ * Helper for bulk initializing sprite images.
392
+ */
393
+ export declare interface SpriteImageDefinitionInitEntry extends SpriteImageDefinitionInit {
394
+ /** Sub-layer identifier. */
395
+ subLayer: number;
396
+ /**
397
+ * Order within the sub-layer; higher values render in front.
398
+ */
399
+ order: number;
400
+ }
401
+
402
+ /**
403
+ * Update payload for a sprite image. Properties left undefined are ignored.
404
+ */
405
+ export declare interface SpriteImageDefinitionUpdate {
406
+ /** Image ID to render. */
407
+ imageId?: string;
408
+ /** Rendering mode. */
409
+ mode?: SpriteMode;
410
+ /** Opacity multiplier. */
411
+ opacity?: number;
412
+ /** Real-world meters represented by one pixel. */
413
+ scale?: number;
414
+ /** Anchor within the image. */
415
+ anchor?: SpriteAnchor;
416
+ /** Offset distance in meters from the sprite coordinate. */
417
+ offsetMeters?: number;
418
+ /** Offset angle in degrees. */
419
+ offsetDeg?: number;
420
+ /** Border rendered around the image. Specify null to remove. */
421
+ border?: SpriteImageLineAttribute | null;
422
+ /** Leader line rendered toward the origin image. Specify null to remove. */
423
+ leaderLine?: SpriteImageLineAttribute | null;
424
+ /** Additional rotation in degrees. */
425
+ rotateDeg?: number;
426
+ /** Enables auto-rotation toward the travel direction. */
427
+ autoRotation?: boolean;
428
+ /** Minimum distance in meters before auto-rotation updates. */
429
+ autoRotationMinDistanceMeters?: number;
430
+ /** Optional interpolation settings. */
431
+ interpolation?: SpriteImageInterpolationOptions;
432
+ }
433
+
434
+ /**
435
+ * Update entry describing a sprite image modification.
436
+ */
437
+ export declare interface SpriteImageDefinitionUpdateEntry {
438
+ /** Target sub-layer that contains the image. */
439
+ subLayer: number;
440
+ /** Order slot within the sub-layer. */
441
+ order: number;
442
+ /** Update payload, or `null` to remove the image. */
443
+ image: SpriteImageDefinitionUpdate | null;
444
+ }
445
+
446
+ /**
447
+ * Offset with interpolation metadata for both distance and heading.
448
+ */
449
+ export declare interface SpriteImageInterpolatedOffset {
450
+ /** Distance from the anchor in meters. */
451
+ readonly offsetMeters: SpriteInterpolatedValues<number>;
452
+ /** Heading describing the offset direction in degrees. */
453
+ readonly offsetDeg: SpriteInterpolatedValues<number>;
454
+ }
455
+
456
+ /**
457
+ * Interpolation configuration.
458
+ */
459
+ export declare interface SpriteImageInterpolationOptions {
460
+ /** Interpolation settings for finalRotateDeg; `null` will disable interpolation. */
461
+ finalRotateDeg?: SpriteInterpolationOptions | null;
462
+ /** Interpolation settings for offset.offsetDeg; `null` will disable interpolation. */
463
+ offsetDeg?: SpriteInterpolationOptions | null;
464
+ /** Interpolation settings for offset.offsetMeters; `null` will disable interpolation. */
465
+ offsetMeters?: SpriteInterpolationOptions | null;
466
+ /** Interpolation settings for finalOpacity; `null` will disable interpolation. */
467
+ finalOpacity?: SpriteInterpolationOptions | null;
468
+ }
469
+
470
+ /**
471
+ * Line attribute.
472
+ */
473
+ export declare interface SpriteImageLineAttribute {
474
+ /** CSS color string. Defaults to red. */
475
+ color?: string;
476
+ /** Line width in meters. Defaults to 1. */
477
+ widthMeters?: number;
478
+ }
479
+
480
+ /**
481
+ * Resolved line attribute state.
482
+ */
483
+ export declare interface SpriteImageLineAttributeState {
484
+ /** CSS color string applied to the line. */
485
+ readonly color: string;
486
+ /** Line width in meters. */
487
+ readonly widthMeters: number;
488
+ }
489
+
490
+ /**
491
+ * Reference to another image's anchor for positioning.
492
+ */
493
+ export declare interface SpriteImageOriginLocation {
494
+ /**
495
+ * Sub-layer identifier.
496
+ */
497
+ subLayer: number;
498
+ /**
499
+ * Order within the sub-layer; higher values render in front.
500
+ */
501
+ order: number;
502
+ /**
503
+ * Use the referenced image's anchor-adjusted position when true. Defaults to the pre-anchor base point.
504
+ */
505
+ useResolvedAnchor?: boolean;
506
+ }
507
+
508
+ /**
509
+ * Options accepted by {@link SpriteLayerInterface.registerImage}.
510
+ */
511
+ export declare interface SpriteImageRegisterOptions {
512
+ /** Target width in CSS pixels. When only one dimension is supplied, the aspect ratio is preserved if known. */
513
+ readonly width?: number;
514
+ /** Target height in CSS pixels. When only one dimension is supplied, the aspect ratio is preserved if known. */
515
+ readonly height?: number;
516
+ /** Resampling quality used during rasterization. */
517
+ readonly resizeQuality?: ResizeQuality;
518
+ /** SVG-specific configuration. */
519
+ readonly svg?: SpriteImageSvgOptions;
520
+ }
521
+
522
+ /**
523
+ * Sprite image state evaluated at runtime.
524
+ */
525
+ export declare interface SpriteImageState {
526
+ /** Sub-layer index the image belongs to. */
527
+ readonly subLayer: number;
528
+ /** Ordering slot within the sub-layer. */
529
+ readonly order: number;
530
+ /** Identifier of the registered image or glyph. */
531
+ readonly imageId: string;
532
+ /** Rendering mode applied to the image. */
533
+ readonly mode: SpriteMode;
534
+ /** Scale factor converting pixels to meters. */
535
+ readonly scale: number;
536
+ /** Anchor coordinates resolved for the image. */
537
+ readonly anchor: Readonly<SpriteAnchor>;
538
+ /** User-specified rotation angle. */
539
+ readonly rotateDeg: number;
540
+ /** User-specified opacity. */
541
+ readonly opacity: number;
542
+ /** Offset applied relative to the anchor point. */
543
+ readonly offset: SpriteImageInterpolatedOffset;
544
+ /** Optional border rendered around the image. */
545
+ readonly border: SpriteImageLineAttributeState | undefined;
546
+ /** Optional leader line rendered toward the origin image. */
547
+ readonly leaderLine: SpriteImageLineAttributeState | undefined;
548
+ /** Indicates whether auto-rotation is active. */
549
+ readonly autoRotation: boolean;
550
+ /** Minimum travel distance before auto-rotation updates. */
551
+ readonly autoRotationMinDistanceMeters: number;
552
+ /** Rotation angle applied when rendering (includes auto-rotation). */
553
+ readonly finalRotateDeg: SpriteInterpolatedValues<number>;
554
+ /** Opacity applied when rendering (includes multipliers). */
555
+ readonly finalOpacity: SpriteInterpolatedValues<number>;
556
+ /** Optional reference to another image used for anchoring. */
557
+ readonly originLocation: Readonly<SpriteImageOriginLocation> | undefined;
558
+ }
559
+
560
+ /**
561
+ * Options used when registering SVG images.
562
+ */
563
+ export declare interface SpriteImageSvgOptions {
564
+ /** Treat the resource as SVG even when the MIME type is missing or incorrect. */
565
+ readonly assumeSvg?: boolean;
566
+ /** Enables parsing of the SVG markup to detect intrinsic sizing. Defaults to true for SVG images. */
567
+ readonly inspectSize?: boolean;
568
+ /**
569
+ * Uses the SVG viewBox dimensions as the raster size when width/height attributes are missing.
570
+ * When disabled (default), such SVGs fail to load instead of inferring a size.
571
+ */
572
+ readonly useViewBoxDimensions?: boolean;
573
+ }
574
+
575
+ /**
576
+ * Parameters required to construct a new sprite.
577
+ *
578
+ * @template TTag Tag type.
579
+ */
580
+ export declare interface SpriteInit<TTag> {
581
+ /** Whether the sprite starts enabled. Defaults to true. */
582
+ isEnabled?: boolean;
583
+ /** Initial location. */
584
+ location: SpriteLocation;
585
+ /**
586
+ * Marks the sprite as invalidated initially, causing interpolation parameters to be
587
+ * ignored until the first update drives the value again.
588
+ */
589
+ invalidate?: boolean;
590
+ /**
591
+ * Pseudo LOD threshold for the sprite. When the camera distance exceeds this value,
592
+ * all images attached to the sprite become invisible.
593
+ */
594
+ visibilityDistanceMeters?: number;
595
+ /**
596
+ * Default interpolation settings applied to initial location updates until overridden.
597
+ */
598
+ interpolation?: SpriteInterpolationOptions;
599
+ /**
600
+ * Multiplier applied to every image opacity belonging to the sprite. Defaults to 1.0.
601
+ */
602
+ opacityMultiplier?: number;
603
+ /** Array of zero or more images. */
604
+ images: SpriteImageDefinitionInitEntry[];
605
+ /** Optional tag value; null or omission means no tag. */
606
+ tag?: TTag | null;
607
+ }
608
+
609
+ /**
610
+ * Batch payload accepted by addSprites. Supports both record and array inputs.
611
+ *
612
+ * @template TTag Tag type.
613
+ */
614
+ export declare type SpriteInitCollection<TTag> = Record<string, SpriteInit<TTag>> | readonly SpriteInitEntry<TTag>[];
615
+
616
+ /**
617
+ * Entry for batch sprite creation, pairing a sprite identifier with its initial settings.
618
+ *
619
+ * @template TTag Tag type.
620
+ */
621
+ export declare interface SpriteInitEntry<TTag> extends SpriteInit<TTag> {
622
+ /** Sprite identifier. */
623
+ spriteId: string;
624
+ }
625
+
626
+ /**
627
+ * Interpolated values.
628
+ * @param TValue - Value type.
629
+ */
630
+ export declare interface SpriteInterpolatedValues<TValue> {
631
+ /** Current time value. */
632
+ readonly current: TValue;
633
+ /** Requested value. */
634
+ readonly from: TValue | undefined;
635
+ /** Will be reached value. */
636
+ readonly to: TValue | undefined;
637
+ /** Marks whether the value was invalidated due to visibility changes. */
638
+ readonly invalidated: boolean | undefined;
639
+ }
640
+
641
+ /**
642
+ * Defines interpolation modes.
643
+ */
644
+ export declare type SpriteInterpolationMode = 'feedback' | 'feedforward';
645
+
646
+ /**
647
+ * Options for interpolating values.
648
+ */
649
+ export declare interface SpriteInterpolationOptions {
650
+ /** Interpolation mode; defaults to `feedback`. */
651
+ mode?: SpriteInterpolationMode;
652
+ /** Duration in milliseconds. */
653
+ durationMs: number;
654
+ /** Easing definition. Defaults to `linear`. */
655
+ easing?: SpriteEasingParam;
656
+ }
657
+
658
+ /**
659
+ * Runtime state describing the active interpolation between two sprite locations.
660
+ * Consumers reuse the same state across ticks to avoid re-allocations while animation is running.
661
+ */
662
+ declare interface SpriteInterpolationState<TValue> {
663
+ /** Strategy used to resolve the target location (feedback or feedforward). */
664
+ readonly mode: SpriteInterpolationMode;
665
+ /** Total time allocated for the interpolation in milliseconds. */
666
+ readonly durationMs: number;
667
+ /** Easing attributes */
668
+ readonly easingParam: SpriteEasingParam;
669
+ /** Resolved easing function applied to raw progress values. */
670
+ readonly easingFunc: EasingFunction;
671
+ /** Origin sprite location cloned from the current render state. */
672
+ readonly from: TValue;
673
+ /** Destination sprite location being interpolated towards. */
674
+ readonly to: TValue;
675
+ /** */
676
+ readonly pathTarget?: TValue;
677
+ /** Epoch millisecond when the interpolation started, or -1 when uninitialized. */
678
+ startTimestamp: number;
679
+ }
680
+
681
+ /**
682
+ * Calculation variant. It is internal calculation methods.
683
+ */
684
+ export declare type SpriteLayerCalculationVariant = 'simd-mt' | 'simd' | 'nosimd' | 'disabled';
685
+
686
+ /**
687
+ * Event dispatched when a sprite is clicked or tapped.
688
+ *
689
+ * @template TTag Tag type stored on sprites.
690
+ */
691
+ export declare interface SpriteLayerClickEvent<TTag> {
692
+ /** Discriminated event type. */
693
+ readonly type: 'spriteclick';
694
+ /** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
695
+ readonly sprite: SpriteCurrentState<TTag> | undefined;
696
+ /** Sprite image that received the interaction, or `undefined` when missing. */
697
+ readonly image: SpriteImageState | undefined;
698
+ /** Screen position of the interaction. */
699
+ readonly screenPoint: SpriteScreenPoint;
700
+ /** Original DOM event. */
701
+ readonly originalEvent: MouseEvent | PointerEvent | TouchEvent;
702
+ }
703
+
704
+ /**
705
+ * Event listener callback.
706
+ *
707
+ * @template TTag Tag type stored on sprites.
708
+ * @template K Event key from {@link SpriteLayerEventMap}.
709
+ * @param {SpriteLayerEventMap<TTag>[K]} event - Event payload dispatched by SpriteLayer.
710
+ * @returns {void}
711
+ */
712
+ export declare type SpriteLayerEventListener<TTag, K extends keyof SpriteLayerEventMap<TTag>> = (event: SpriteLayerEventMap<TTag>[K]) => void;
713
+
714
+ /**
715
+ * Map of events emitted by SpriteLayer.
716
+ *
717
+ * @template TTag Tag type stored on sprites.
718
+ */
719
+ export declare interface SpriteLayerEventMap<TTag> {
720
+ /** Event fired when a sprite image is clicked. */
721
+ readonly spriteclick: SpriteLayerClickEvent<TTag>;
722
+ /** Event fired when a sprite image is hovered. */
723
+ readonly spritehover: SpriteLayerHoverEvent<TTag>;
724
+ }
725
+
726
+ /**
727
+ * SpriteLayer host options.
728
+ */
729
+ export declare interface SpriteLayerHostOptions {
730
+ /**
731
+ * Calculation variant. Default is `simd`.
732
+ * Use `simd-mt` to enable pthread/SIMD wasm when `SharedArrayBuffer` is available
733
+ * (i.e. cross-origin isolated contexts) and fall back to the other variants otherwise.
734
+ */
735
+ readonly variant?: SpriteLayerCalculationVariant;
736
+ /**
737
+ * Wasm runtime module base URL path. Default is `/wasm`
738
+ */
739
+ readonly wasmBaseUrl?: string;
740
+ }
741
+
742
+ /**
743
+ * Event dispatched when a sprite is hovered by a pointing device.
744
+ *
745
+ * @template TTag Tag type stored on sprites.
746
+ */
747
+ export declare interface SpriteLayerHoverEvent<TTag> {
748
+ /** Discriminated event type. */
749
+ readonly type: 'spritehover';
750
+ /** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
751
+ readonly sprite: SpriteCurrentState<TTag> | undefined;
752
+ /** Sprite image that received the interaction, or `undefined` when missing. */
753
+ readonly image: SpriteImageState | undefined;
754
+ /** Screen position of the interaction. */
755
+ readonly screenPoint: SpriteScreenPoint;
756
+ /** Original hover-capable DOM event. */
757
+ readonly originalEvent: MouseEvent | PointerEvent;
758
+ }
759
+
760
+ /**
761
+ * MapLibre layer interface for SpriteLayer.
762
+ * Renders large numbers of sprites and supports high-frequency updates.
763
+ *
764
+ * @template TTag Sprite tag type.
765
+ */
766
+ export declare interface SpriteLayerInterface<TTag = any> extends CustomLayerInterface {
767
+ /**
768
+ * Registers an image or glyph so it can be referenced by sprite images.
769
+ *
770
+ * @param {string} imageId - Unique image identifier.
771
+ * @param {string | ImageBitmap} image - Image source (URL or ImageBitmap) to upload.
772
+ * @param {SpriteImageRegisterOptions | undefined} options - Optional SVG handling controls.
773
+ * @returns {Promise<boolean>} Resolves to `true` when the image was registered; `false` if the ID already existed.
774
+ */
775
+ readonly registerImage: (imageId: string, image: string | ImageBitmap, options?: SpriteImageRegisterOptions) => Promise<boolean>;
776
+ /**
777
+ * Registers a text glyph texture for later use.
778
+ *
779
+ * @param {string} textGlyphId - Unique identifier for the text glyph.
780
+ * @param {string} text - Text content to render.
781
+ * @param {SpriteTextGlyphDimensions} dimensions - Glyph sizing options.
782
+ * @param {SpriteTextGlyphOptions | undefined} options - Optional styling information.
783
+ * @returns {Promise<boolean>} Resolves to `true` when the glyph was registered; `false` if the ID already existed.
784
+ */
785
+ readonly registerTextGlyph: (textGlyphId: string, text: string, dimensions: SpriteTextGlyphDimensions, options?: SpriteTextGlyphOptions) => Promise<boolean>;
786
+ /**
787
+ * Removes a previously registered image or glyph.
788
+ *
789
+ * @param {string} imageId - Identifier of the image to remove.
790
+ * @returns {boolean} `true` when the image existed and was removed.
791
+ */
792
+ readonly unregisterImage: (imageId: string) => boolean;
793
+ /**
794
+ * Removes every registered image and glyph, releasing associated GPU resources.
795
+ *
796
+ * @returns {void}
797
+ */
798
+ readonly unregisterAllImages: () => void;
799
+ /**
800
+ * Returns all currently registered image IDs.
801
+ *
802
+ * @returns {string[]} Array of registered image identifiers.
803
+ */
804
+ readonly getAllImageIds: () => string[];
805
+ /**
806
+ * Adds a sprite to the layer.
807
+ *
808
+ * @param {string} spriteId - Unique sprite identifier.
809
+ * @param {SpriteInit<TTag>} init - Initial sprite configuration.
810
+ * @returns {boolean} `true` when the sprite was inserted; `false` if the ID already existed.
811
+ */
812
+ readonly addSprite: (spriteId: string, init: SpriteInit<TTag>) => boolean;
813
+ /**
814
+ * Adds multiple sprites in one call.
815
+ *
816
+ * @param {SpriteInitCollection<TTag>} sprites - Sprite definitions keyed by ID or supplied as entries.
817
+ * @returns {number} Number of sprites that were inserted.
818
+ */
819
+ readonly addSprites: (sprites: SpriteInitCollection<TTag>) => number;
820
+ /**
821
+ * Removes a sprite.
822
+ *
823
+ * @param {string} spriteId - Identifier of the sprite to remove.
824
+ * @returns {void}
825
+ */
826
+ readonly removeSprite: (spriteId: string) => void;
827
+ /**
828
+ * Removes multiple sprites.
829
+ *
830
+ * @param {readonly string[]} spriteIds - Identifiers of the sprites to remove.
831
+ * @returns {number} Number of sprites that were removed.
832
+ */
833
+ readonly removeSprites: (spriteIds: readonly string[]) => number;
834
+ /**
835
+ * Removes all sprites.
836
+ *
837
+ * @returns {number} Number of sprites that were removed.
838
+ */
839
+ readonly removeAllSprites: () => number;
840
+ /**
841
+ * Retrieves the current state for a sprite.
842
+ *
843
+ * @param {string} spriteId - Identifier of the sprite.
844
+ * @returns {SpriteCurrentState<TTag> | undefined} Current state or `undefined` when not found.
845
+ */
846
+ readonly getSpriteState: (spriteId: string) => SpriteCurrentState<TTag> | undefined;
847
+ /**
848
+ * Returns all sprite IDs currently managed by the layer.
849
+ *
850
+ * @returns {string[]} Array of sprite identifiers.
851
+ */
852
+ readonly getAllSpriteIds: () => string[];
853
+ /**
854
+ * Attaches an image definition to a sprite.
855
+ *
856
+ * @param {string} spriteId - Target sprite identifier.
857
+ * @param {number} subLayer - Sub-layer index.
858
+ * @param {number} order - Order slot within the sub-layer.
859
+ * @param {SpriteImageDefinitionInit} imageInit - Image definition to insert.
860
+ * @returns {boolean} `true` when the image slot was empty and the definition applied.
861
+ */
862
+ readonly addSpriteImage: (spriteId: string, subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean;
863
+ /**
864
+ * Updates an image assigned to a sprite.
865
+ *
866
+ * @param {string} spriteId - Target sprite identifier.
867
+ * @param {number} subLayer - Sub-layer index containing the image.
868
+ * @param {number} order - Order slot within the sub-layer.
869
+ * @param {SpriteImageDefinitionUpdate} imageUpdate - Update payload.
870
+ * @returns {boolean} `true` when the image existed and was updated.
871
+ */
872
+ readonly updateSpriteImage: (spriteId: string, subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean;
873
+ /**
874
+ * Removes an image from a sprite.
875
+ *
876
+ * @param {string} spriteId - Target sprite identifier.
877
+ * @param {number} subLayer - Sub-layer index containing the image.
878
+ * @param {number} order - Order slot within the sub-layer.
879
+ * @returns {boolean} `true` when the image existed and was removed.
880
+ */
881
+ readonly removeSpriteImage: (spriteId: string, subLayer: number, order: number) => boolean;
882
+ /**
883
+ * Removes all images attached to the specified sprite.
884
+ *
885
+ * @param {string} spriteId - Identifier of the sprite whose images should be removed.
886
+ * @returns {number} Number of images that were removed.
887
+ */
888
+ readonly removeAllSpriteImages: (spriteId: string) => number;
889
+ /**
890
+ * Updates a sprite with the provided payload.
891
+ *
892
+ * @param {string} spriteId - Target sprite identifier.
893
+ * @param {SpriteUpdateEntry<TTag>} update - Update payload describing property changes.
894
+ * @returns {boolean} `true` when the sprite was found and updated.
895
+ */
896
+ readonly updateSprite: (spriteId: string, update: SpriteUpdateEntry<TTag>) => boolean;
897
+ /**
898
+ * Adds, updates, or removes sprites based on an arbitrary collection of source items.
899
+ *
900
+ * @param {readonly TSourceItem[]} sourceItems - Source items that describe desired sprite state.
901
+ * @param {SpriteMutateCallbacks<TTag, TSourceItem>} mutator - Callbacks responsible for creation and modification.
902
+ * @returns {number} Number of sprites that changed. Counts each `add` that returns a non-null
903
+ * initializer and each `modify` that either invoked the updater helper or returned `'remove'`.
904
+ */
905
+ readonly mutateSprites: <TSourceItem extends SpriteMutateSourceItem>(sourceItems: readonly TSourceItem[], mutator: SpriteMutateCallbacks<TTag, TSourceItem>) => number;
906
+ /**
907
+ * Iterates over each sprite and allows modifications through a callback.
908
+ *
909
+ * @param {(sprite: SpriteCurrentState<TTag>, update: SpriteUpdaterEntry<TTag>) => boolean} updater - Callback invoked for each sprite. Return `false` to stop iteration early.
910
+ * @returns {number} Number of sprites that were updated.
911
+ */
912
+ readonly updateForEach: (updater: (sprite: SpriteCurrentState<TTag>, update: SpriteUpdaterEntry<TTag>) => boolean) => number;
913
+ /**
914
+ * Controls entire interpolation Calculation.
915
+ * When `false`, interpolation halts immediately and resumes smoothly from the paused state when re-enabled.
916
+ * @param moveable - Continuous calculation for movement interpolation when value is true.
917
+ */
918
+ readonly setInterpolationCalculation: (moveable: boolean) => void;
919
+ /**
920
+ * Enables or disables hit-test.
921
+ *
922
+ * @param {boolean} detect - When false, hit testing is skipped.
923
+ */
924
+ readonly setHitTestDetection: (detect: boolean) => void;
925
+ /**
926
+ * Starts tracking a sprite so the map recenters on it every animation frame.
927
+ * When `trackRotation` is true (default), the sprite's final rotation follows the map bearing.
928
+ *
929
+ * @param {string} spriteId - Identifier of the sprite to track.
930
+ * @param {boolean} [trackRotation=true] - Whether to align the sprite's rotation to the map bearing.
931
+ * @returns {void}
932
+ */
933
+ readonly trackSprite: (spriteId: string, trackRotation?: boolean) => void;
934
+ /**
935
+ * Stops tracking any sprite previously targeted via {@link trackSprite}.
936
+ *
937
+ * @returns {void}
938
+ */
939
+ readonly untrackSprite: () => void;
940
+ /**
941
+ * Adds an event listener.
942
+ *
943
+ * @param {K} type - Event name.
944
+ * @param {SpriteLayerEventListener<TTag, K>} listener - Listener callback.
945
+ * @returns {void}
946
+ */
947
+ readonly on: <K extends keyof SpriteLayerEventMap<TTag>>(type: K, listener: SpriteLayerEventListener<TTag, K>) => void;
948
+ /**
949
+ * Removes a previously registered event listener.
950
+ *
951
+ * @param {K} type - Event name.
952
+ * @param {SpriteLayerEventListener<TTag, K>} listener - Listener callback to remove.
953
+ * @returns {void}
954
+ */
955
+ readonly off: <K extends keyof SpriteLayerEventMap<TTag>>(type: K, listener: SpriteLayerEventListener<TTag, K>) => void;
956
+ }
957
+
958
+ /**
959
+ * Options accepted when creating a SpriteLayer.
960
+ */
961
+ export declare interface SpriteLayerOptions {
962
+ /** Optional layer identifier supplied to MapLibre. */
963
+ id?: string;
964
+ /** Optional scaling controls. Default is UNLIMITED_SPRITE_SCALING_OPTIONS. */
965
+ spriteScaling?: SpriteScalingOptions;
966
+ /** Optional texture filtering configuration. */
967
+ textureFiltering?: SpriteTextureFilteringOptions;
968
+ }
969
+
970
+ /**
971
+ * Base coordinate for the sprite. All images within the sprite are positioned relative to this location.
972
+ */
973
+ export declare interface SpriteLocation {
974
+ /** Longitude in degrees. */
975
+ lng: number;
976
+ /** Latitude in degrees. */
977
+ lat: number;
978
+ /** Elevation or virtual height. Defaults to 0 and is currently unused. */
979
+ z?: number;
980
+ }
981
+
982
+ /**
983
+ * Represents a projected three dimensional position.
984
+ * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
985
+ * - the size of 1 unit is the width of the projected world instead of the "mercator meter"
986
+ * - the origin of the coordinate space is at the north-west corner instead of the middle
987
+ */
988
+ declare interface SpriteMercatorCoordinate {
989
+ readonly x: number;
990
+ readonly y: number;
991
+ readonly z: number;
992
+ }
993
+
994
+ /**
995
+ * Sprite rendering modes.
996
+ * Billboard: Image always faces the viewport, suited for HUD-style elements.
997
+ * Surface: Image lies parallel to the map surface, suited for dynamic markers on the map.
998
+ */
999
+ export declare type SpriteMode = 'billboard' | 'surface';
1000
+
1001
+ /**
1002
+ * Result flags returned by `mutateSprites` callbacks.
1003
+ * - `'notremove'`: Keep the sprite after applying any modifications.
1004
+ * - `'remove'`: Remove the sprite from the layer.
1005
+ */
1006
+ export declare type SpriteModifierResult = 'notremove' | 'remove';
1007
+
1008
+ /**
1009
+ * Callbacks invoked by `mutateSprites` for each source item.
1010
+ *
1011
+ * @template TTag Sprite tag type stored by the layer.
1012
+ * @template TSourceItem Source item type that satisfies {@link SpriteMutateSourceItem}.
1013
+ */
1014
+ export declare interface SpriteMutateCallbacks<TTag, TSourceItem extends SpriteMutateSourceItem> {
1015
+ /**
1016
+ * Invoked when the sprite ID from the source item does not yet exist.
1017
+ * Return a populated {@link SpriteInit} when the sprite should be added; return `undefined`
1018
+ * (or `null`) to skip creation.
1019
+ *
1020
+ * @param sourceItem Source item that produced the sprite ID.
1021
+ * @returns Sprite initializer to insert, or `undefined`/`null` to skip.
1022
+ */
1023
+ add: (sourceItem: TSourceItem) => SpriteInit<TTag> | null | undefined;
1024
+ /**
1025
+ * Invoked when the sprite ID already exists on the layer.
1026
+ * Use `update` to mutate sprite properties or images; return `'remove'` to delete the sprite instead.
1027
+ *
1028
+ * @param sourceItem Source item that produced the sprite ID.
1029
+ * @param sprite Current sprite state snapshot.
1030
+ * @param update Helper exposing the same operations as {@link SpriteUpdaterEntry}.
1031
+ * @returns `'remove'` to delete the sprite; otherwise `'notremove'`.
1032
+ */
1033
+ modify: (sourceItem: TSourceItem, sprite: SpriteCurrentState<TTag>, update: SpriteUpdaterEntry<TTag>) => SpriteModifierResult;
1034
+ }
1035
+
1036
+ /** Source items supplied to `mutateSprites` must expose the target sprite ID. */
1037
+ export declare interface SpriteMutateSourceItem {
1038
+ /** Identifier of the sprite targeted by the source item. */
1039
+ readonly spriteId: string;
1040
+ }
1041
+
1042
+ /**
1043
+ * Encode/Decode interface for a (subLayer, order) pair into a compact numeric key.
1044
+ * @remarks It is used for (wasm) interoperability for image identity.
1045
+ */
1046
+ declare interface SpriteOriginReference {
1047
+ /**
1048
+ * Encodes a (subLayer, order) pair into a compact numeric key.
1049
+ * @param subLayer Sub-layer identifier within the sprite.
1050
+ * @param order Order slot inside the sub-layer.
1051
+ * @returns Encoded origin reference key.
1052
+ */
1053
+ readonly encodeKey: (subLayer: number, order: number) => SpriteOriginReferenceKey;
1054
+ /**
1055
+ * Decodes an origin reference key back into the sub-layer and order pair.
1056
+ * @param key Encoded origin reference key.
1057
+ * @returns `subLayer` and `order` components; when the key is invalid, both values are set to `-1`.
1058
+ */
1059
+ readonly decodeKey: (key: SpriteOriginReferenceKey) => {
1060
+ readonly subLayer: number;
1061
+ readonly order: number;
1062
+ };
1063
+ }
1064
+
1065
+ /**
1066
+ * Index into the render target bucket pointing at the resolved origin image.
1067
+ * @remarks It is used for (wasm) interoperability for image identity.
1068
+ * When no origin is assigned or the reference could not be resolved,
1069
+ * the value will be {@link SPRITE_ORIGIN_REFERENCE_INDEX_NONE}.
1070
+ */
1071
+ declare type SpriteOriginReferenceIndex = number;
1072
+
1073
+ /**
1074
+ * Encoded pointer representing the target of an origin reference.
1075
+ * @remarks It is used for (wasm) interoperability for image identity.
1076
+ * The high bits encode the sub-layer while the low bits encode the order slot.
1077
+ */
1078
+ declare type SpriteOriginReferenceKey = number;
1079
+
1080
+ /**
1081
+ * Represents a point on anonymous-unit space.
1082
+ */
1083
+ export declare interface SpritePoint {
1084
+ /** Horizontal (X axis) coordinate. */
1085
+ readonly x: number;
1086
+ /** Vertical (Y axis) coordinate. */
1087
+ readonly y: number;
1088
+ }
1089
+
1090
+ /**
1091
+ * Options controlling distance-aware scaling.
1092
+ */
1093
+ export declare interface SpriteScalingOptions {
1094
+ /**
1095
+ * Overrides the baseline meters-per-pixel ratio.
1096
+ * We strongly recommend specifying the default value of 1, as this value affects all calculations.
1097
+ */
1098
+ metersPerPixel?: number;
1099
+ /**
1100
+ * Distance (meters) from the camera at which sprites stop growing when getting closer.
1101
+ * Set to 0 or omit to disable the near-distance clamp.
1102
+ */
1103
+ minScaleDistanceMeters?: number;
1104
+ /**
1105
+ * Distance (meters) from the camera at which sprites stop shrinking when moving away.
1106
+ * Set to 0 or omit to disable the far-distance clamp.
1107
+ */
1108
+ maxScaleDistanceMeters?: number;
1109
+ }
1110
+
1111
+ /**
1112
+ * Represents a point in screen space.
1113
+ */
1114
+ export declare type SpriteScreenPoint = SpritePoint;
1115
+
1116
+ /**
1117
+ * Border sides that can be rendered for a text glyph outline.
1118
+ */
1119
+ export declare type SpriteTextGlyphBorderSide = 'top' | 'right' | 'bottom' | 'left';
1120
+
1121
+ /**
1122
+ * Additional size options accepted by registerTextGlyph.
1123
+ */
1124
+ export declare type SpriteTextGlyphDimensions = {
1125
+ readonly lineHeightPixel: number;
1126
+ readonly maxWidthPixel?: never;
1127
+ } | {
1128
+ readonly maxWidthPixel: number;
1129
+ readonly lineHeightPixel?: never;
1130
+ };
1131
+
1132
+ /**
1133
+ * Horizontal alignment options for text glyphs.
1134
+ */
1135
+ export declare type SpriteTextGlyphHorizontalAlign = 'left' | 'center' | 'right';
1136
+
1137
+ /**
1138
+ * Text glyph appearance options.
1139
+ */
1140
+ export declare interface SpriteTextGlyphOptions {
1141
+ /** Font family name. */
1142
+ fontFamily?: string;
1143
+ /** CSS font-weight value. */
1144
+ fontWeight?: string;
1145
+ /** CSS font-style value. */
1146
+ fontStyle?: 'normal' | 'italic';
1147
+ /** Text fill color. */
1148
+ color?: string;
1149
+ /** Letter spacing in pixels. */
1150
+ letterSpacingPixel?: number;
1151
+ /** Background color applied behind the text. */
1152
+ backgroundColor?: string;
1153
+ /** Padding around the glyph. */
1154
+ paddingPixel?: SpriteTextGlyphPaddingPixel;
1155
+ /** Outline color. */
1156
+ borderColor?: string;
1157
+ /** Outline width in pixels. */
1158
+ borderWidthPixel?: number;
1159
+ /** Border sides to draw; defaults to all four sides when omitted. */
1160
+ borderSides?: readonly SpriteTextGlyphBorderSide[];
1161
+ /** Border radius in pixels. */
1162
+ borderRadiusPixel?: number;
1163
+ /** Horizontal alignment of multiline text. */
1164
+ textAlign?: SpriteTextGlyphHorizontalAlign;
1165
+ /** It is not specified normally. Preferred font size in pixels; may shrink automatically to satisfy provided dimensions. */
1166
+ fontSizePixelHint?: number;
1167
+ /** Pixel ratio used when rendering the glyph; defaults to 1 and values > 1 render at higher resolution before downscaling. */
1168
+ renderPixelRatio?: number;
1169
+ }
1170
+
1171
+ /**
1172
+ * Padding in pixels applied when rendering text glyphs.
1173
+ */
1174
+ export declare type SpriteTextGlyphPaddingPixel = number | {
1175
+ top?: number;
1176
+ right?: number;
1177
+ bottom?: number;
1178
+ left?: number;
1179
+ };
1180
+
1181
+ /**
1182
+ * Texture filtering configuration.
1183
+ */
1184
+ export declare interface SpriteTextureFilteringOptions {
1185
+ /** Minification filter to apply (defaults to `linear`). */
1186
+ minFilter?: SpriteTextureMinFilter;
1187
+ /** Magnification filter to apply (defaults to `linear`). */
1188
+ magFilter?: SpriteTextureMagFilter;
1189
+ /** Generates mipmaps during upload when true (defaults to `false`). */
1190
+ generateMipmaps?: boolean;
1191
+ /** Desired anisotropy factor (>= 1) when EXT_texture_filter_anisotropic is available. */
1192
+ maxAnisotropy?: number;
1193
+ }
1194
+
1195
+ /**
1196
+ * Allowed magnification filters for sprite textures.
1197
+ */
1198
+ export declare type SpriteTextureMagFilter = 'nearest' | 'linear';
1199
+
1200
+ /**
1201
+ * Allowed minification filters for sprite textures.
1202
+ */
1203
+ export declare type SpriteTextureMinFilter = 'nearest' | 'linear' | 'nearest-mipmap-nearest' | 'nearest-mipmap-linear' | 'linear-mipmap-nearest' | 'linear-mipmap-linear';
1204
+
1205
+ /**
1206
+ * Sprite update entry with optional image list.
1207
+ *
1208
+ * @template TTag Tag type stored on the sprite.
1209
+ */
1210
+ export declare interface SpriteUpdateEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
1211
+ /** Optional set of image updates. */
1212
+ images?: SpriteImageDefinitionUpdateEntry[];
1213
+ }
1214
+
1215
+ /**
1216
+ * Base structure for sprite updates.
1217
+ *
1218
+ * @template TTag Tag type stored on the sprite.
1219
+ */
1220
+ export declare interface SpriteUpdateEntryBase<TTag> {
1221
+ /** Optional toggle to enable or disable the sprite. */
1222
+ isEnabled?: boolean;
1223
+ /** Optional target location for the sprite. */
1224
+ location?: SpriteLocation;
1225
+ /** Optional interpolation settings; `null` disables interpolation. */
1226
+ interpolation?: SpriteInterpolationOptions | null;
1227
+ /** Optional tag value to replace the current one; `null` clears the tag. */
1228
+ tag?: TTag | null;
1229
+ /**
1230
+ * Pseudo LOD threshold for the sprite. Specify a positive finite value to enable the check,
1231
+ * `null` to clear the current threshold, or leave `undefined` to keep the existing value.
1232
+ */
1233
+ visibilityDistanceMeters?: number | null;
1234
+ /**
1235
+ * Optional multiplier applied to every image opacity. When omitted the previous multiplier is preserved.
1236
+ */
1237
+ opacityMultiplier?: number;
1238
+ }
1239
+
1240
+ /**
1241
+ * Callback-based helper for mutating sprite state.
1242
+ *
1243
+ * @template TTag Tag type stored on the sprite.
1244
+ */
1245
+ export declare interface SpriteUpdaterEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
1246
+ /**
1247
+ * Retrieves the current image layout.
1248
+ * @returns Structured image index (order sets each sub layers).
1249
+ */
1250
+ readonly getImageIndexMap: () => ReadonlyMap<number, ReadonlySet<number>>;
1251
+ /**
1252
+ * Adds an image definition.
1253
+ * @param subLayer - Sub layer index.
1254
+ * @param order - Order index.
1255
+ * @param imageInit - Image initializer.
1256
+ * @returns True if added.
1257
+ */
1258
+ readonly addImage: (subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean;
1259
+ /**
1260
+ * Applies image updates.
1261
+ * @param subLayer - Sub layer index.
1262
+ * @param order - Order index.
1263
+ * @param imageUpdate - Image updater.
1264
+ * @returns True if updated.
1265
+ */
1266
+ readonly updateImage: (subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean;
1267
+ /**
1268
+ * Removes an image slot.
1269
+ * @param subLayer - Sub layer index.
1270
+ * @param order - Order index.
1271
+ * @returns True if removed.
1272
+ */
1273
+ readonly removeImage: (subLayer: number, order: number) => boolean;
1274
+ }
1275
+
1276
+ /**
1277
+ * Standard values that fill in missing {@link SpriteScalingOptions} fields supplied by callers.
1278
+ * metersPerPixel is 1.
1279
+ */
1280
+ export declare const STANDARD_SPRITE_SCALING_OPTIONS: SpriteScalingOptions;
1281
+
1282
+ /**
1283
+ * East/north displacement for an individual surface corner.
1284
+ */
1285
+ declare interface SurfaceCorner {
1286
+ /** Eastward offset in meters relative to the base center. */
1287
+ readonly east: number;
1288
+ /** Northward offset in meters relative to the base center. */
1289
+ readonly north: number;
1290
+ }
1291
+
1292
+ /**
1293
+ * Corner model describing world displacements and resulting geographic coordinates for shader validation.
1294
+ */
1295
+ declare interface SurfaceShaderCornerState extends SpriteLocation, SurfaceCorner {
1296
+ }
1297
+
1298
+ /**
1299
+ * Aggregated inputs required to reproduce surface geometry on the GPU.
1300
+ */
1301
+ declare interface SurfaceShaderInputs {
1302
+ readonly mercatorCenter: {
1303
+ readonly x: number;
1304
+ readonly y: number;
1305
+ readonly z: number;
1306
+ };
1307
+ readonly worldToMercatorScale: Readonly<SurfaceCorner>;
1308
+ readonly halfSizeMeters: Readonly<SurfaceCorner>;
1309
+ readonly anchor: Readonly<SpriteAnchor>;
1310
+ readonly offsetMeters: Readonly<SurfaceCorner>;
1311
+ readonly sinCos: {
1312
+ readonly sin: number;
1313
+ readonly cos: number;
1314
+ };
1315
+ readonly totalRotateDeg: number;
1316
+ readonly depthBiasNdc: number;
1317
+ readonly centerDisplacement: Readonly<SurfaceCorner>;
1318
+ readonly baseLngLat: Readonly<SpriteLocation>;
1319
+ readonly displacedCenter: Readonly<SpriteLocation>;
1320
+ readonly scaleAdjustment: number;
1321
+ readonly corners: readonly Readonly<SurfaceShaderCornerState>[];
1322
+ clipCenter: {
1323
+ readonly x: number;
1324
+ readonly y: number;
1325
+ readonly z: number;
1326
+ readonly w: number;
1327
+ };
1328
+ clipBasisEast: {
1329
+ readonly x: number;
1330
+ readonly y: number;
1331
+ readonly z: number;
1332
+ readonly w: number;
1333
+ };
1334
+ clipBasisNorth: {
1335
+ readonly x: number;
1336
+ readonly y: number;
1337
+ readonly z: number;
1338
+ readonly w: number;
1339
+ };
1340
+ clipCorners: ReadonlyArray<{
1341
+ readonly x: number;
1342
+ readonly y: number;
1343
+ readonly z: number;
1344
+ readonly w: number;
1345
+ }>;
1346
+ }
1347
+
1348
+ export declare class SvgSizeResolutionError extends Error implements Error {
1349
+ readonly code: SvgSizeResolutionErrorCode;
1350
+ constructor(message: string, code: SvgSizeResolutionErrorCode);
1351
+ }
1352
+
1353
+ export declare type SvgSizeResolutionErrorCode = 'size-missing' | 'viewbox-disabled' | 'invalid-dimensions';
1354
+
1355
+ /**
1356
+ * Unlimited (default) values that fill in missing {@link SpriteScalingOptions} fields supplied by callers.
1357
+ * metersPerPixel is 1.
1358
+ */
1359
+ export declare const UNLIMITED_SPRITE_SCALING_OPTIONS: SpriteScalingOptions;
1360
+
1361
+ export { }