@maptiler/sdk 3.4.0-rc1 → 3.4.0-rc3

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 (74) hide show
  1. package/dist/maptiler-sdk.d.ts +2 -0
  2. package/dist/maptiler-sdk.mjs +11601 -0
  3. package/dist/maptiler-sdk.mjs.map +1 -0
  4. package/dist/playwright.config.d.ts +9 -0
  5. package/dist/src/ColorRamp.d.ts +359 -0
  6. package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
  7. package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
  8. package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
  9. package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
  10. package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
  11. package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
  12. package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
  13. package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
  14. package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
  15. package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
  16. package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
  17. package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
  18. package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
  19. package/dist/src/MLAdapters/Marker.d.ts +5 -0
  20. package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
  21. package/dist/src/MLAdapters/Popup.d.ts +5 -0
  22. package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
  23. package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
  24. package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
  25. package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
  26. package/dist/src/MLAdapters/Style.d.ts +5 -0
  27. package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
  28. package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
  29. package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
  30. package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
  31. package/dist/src/Map.d.ts +405 -0
  32. package/dist/src/Point.d.ts +177 -0
  33. package/dist/src/Telemetry.d.ts +40 -0
  34. package/dist/src/caching.d.ts +4 -0
  35. package/dist/src/config.d.ts +85 -0
  36. package/dist/src/constants/defaults.d.ts +15 -0
  37. package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
  38. package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
  39. package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
  40. package/dist/src/controls/MaptilerProjectionControl.d.ts +14 -0
  41. package/dist/src/controls/MaptilerTerrainControl.d.ts +16 -0
  42. package/dist/src/controls/Minimap.d.ts +57 -0
  43. package/dist/src/controls/index.d.ts +6 -0
  44. package/dist/src/converters/index.d.ts +1 -0
  45. package/dist/src/converters/xml.d.ts +54 -0
  46. package/dist/src/custom-layers/AnimatedRouteLayer.d.ts +291 -0
  47. package/dist/src/helpers/index.d.ts +3 -0
  48. package/dist/src/helpers/screenshot.d.ts +18 -0
  49. package/dist/src/helpers/stylehelper.d.ts +28 -0
  50. package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
  51. package/dist/src/index.d.ts +88 -0
  52. package/dist/src/language.d.ts +107 -0
  53. package/dist/src/mapstyle.d.ts +17 -0
  54. package/dist/src/tools.d.ts +84 -0
  55. package/dist/src/types.d.ts +1 -0
  56. package/dist/src/utils/MaptilerAnimation/AnimationManager.d.ts +41 -0
  57. package/dist/src/utils/MaptilerAnimation/MaptilerAnimation.d.ts +238 -0
  58. package/dist/src/utils/MaptilerAnimation/animation-helpers.d.ts +182 -0
  59. package/dist/src/utils/MaptilerAnimation/easing.d.ts +3 -0
  60. package/dist/src/utils/MaptilerAnimation/index.d.ts +7 -0
  61. package/dist/src/utils/MaptilerAnimation/types.d.ts +57 -0
  62. package/dist/src/utils/array.d.ts +1 -0
  63. package/dist/src/utils/dom.d.ts +2 -0
  64. package/dist/src/utils/index.d.ts +4 -0
  65. package/dist/vite.config-e2e.d.ts +2 -0
  66. package/dist/vite.config-test.d.ts +2 -0
  67. package/dist/vite.config-umd.d.ts +2 -0
  68. package/dist/vitest-setup-tests.d.ts +1 -0
  69. package/eslint.config.mjs +71 -0
  70. package/package.json +3 -3
  71. package/tsconfig.json +3 -2
  72. package/tsconfig.tsbuildinfo +1 -0
  73. package/vite.config-es.ts +1 -0
  74. package/vite.config-umd.ts +17 -7
@@ -0,0 +1,107 @@
1
+ import { LanguageInfo } from '@maptiler/client';
2
+ declare const Language: {
3
+ readonly ALBANIAN: LanguageInfo;
4
+ readonly AMHARIC: LanguageInfo;
5
+ readonly ARABIC: LanguageInfo;
6
+ readonly ARMENIAN: LanguageInfo;
7
+ readonly AZERBAIJANI: LanguageInfo;
8
+ readonly BASQUE: LanguageInfo;
9
+ readonly BELARUSIAN: LanguageInfo;
10
+ readonly BENGALI: LanguageInfo;
11
+ readonly BOSNIAN: LanguageInfo;
12
+ readonly BRETON: LanguageInfo;
13
+ readonly BULGARIAN: LanguageInfo;
14
+ readonly CATALAN: LanguageInfo;
15
+ readonly CHINESE: LanguageInfo;
16
+ readonly TRADITIONAL_CHINESE: LanguageInfo;
17
+ readonly SIMPLIFIED_CHINESE: LanguageInfo;
18
+ readonly CORSICAN: LanguageInfo;
19
+ readonly CROATIAN: LanguageInfo;
20
+ readonly CZECH: LanguageInfo;
21
+ readonly DANISH: LanguageInfo;
22
+ readonly DUTCH: LanguageInfo;
23
+ readonly GERMAN: LanguageInfo;
24
+ readonly GREEK: LanguageInfo;
25
+ readonly ENGLISH: LanguageInfo;
26
+ readonly ESPERANTO: LanguageInfo;
27
+ readonly ESTONIAN: LanguageInfo;
28
+ readonly FINNISH: LanguageInfo;
29
+ readonly FRENCH: LanguageInfo;
30
+ readonly FRISIAN: LanguageInfo;
31
+ readonly GEORGIAN: LanguageInfo;
32
+ readonly HEBREW: LanguageInfo;
33
+ readonly HINDI: LanguageInfo;
34
+ readonly HUNGARIAN: LanguageInfo;
35
+ readonly ICELANDIC: LanguageInfo;
36
+ readonly INDONESIAN: LanguageInfo;
37
+ readonly IRISH: LanguageInfo;
38
+ readonly ITALIAN: LanguageInfo;
39
+ readonly JAPANESE: LanguageInfo;
40
+ readonly JAPANESE_HIRAGANA: LanguageInfo;
41
+ readonly JAPANESE_2018: LanguageInfo;
42
+ readonly JAPANESE_KANA: LanguageInfo;
43
+ readonly JAPANESE_LATIN: LanguageInfo;
44
+ readonly KANNADA: LanguageInfo;
45
+ readonly KAZAKH: LanguageInfo;
46
+ readonly KOREAN: LanguageInfo;
47
+ readonly KOREAN_LATIN: LanguageInfo;
48
+ readonly KURDISH: LanguageInfo;
49
+ readonly CLASSICAL_LATIN: LanguageInfo;
50
+ readonly LATVIAN: LanguageInfo;
51
+ readonly LITHUANIAN: LanguageInfo;
52
+ readonly LUXEMBOURGISH: LanguageInfo;
53
+ readonly MACEDONIAN: LanguageInfo;
54
+ readonly MALAYALAM: LanguageInfo;
55
+ readonly MALTESE: LanguageInfo;
56
+ readonly NORWEGIAN: LanguageInfo;
57
+ readonly OCCITAN: LanguageInfo;
58
+ readonly PERSIAN: LanguageInfo;
59
+ readonly POLISH: LanguageInfo;
60
+ readonly PORTUGUESE: LanguageInfo;
61
+ readonly PUNJABI: LanguageInfo;
62
+ readonly WESTERN_PUNJABI: LanguageInfo;
63
+ readonly ROMANIAN: LanguageInfo;
64
+ readonly ROMANSH: LanguageInfo;
65
+ readonly RUSSIAN: LanguageInfo;
66
+ readonly SERBIAN_CYRILLIC: LanguageInfo;
67
+ readonly SERBIAN_LATIN: LanguageInfo;
68
+ readonly SCOTTISH_GAELIC: LanguageInfo;
69
+ readonly SLOVAK: LanguageInfo;
70
+ readonly SLOVENE: LanguageInfo;
71
+ readonly SPANISH: LanguageInfo;
72
+ readonly SWEDISH: LanguageInfo;
73
+ readonly TAMIL: LanguageInfo;
74
+ readonly TELUGU: LanguageInfo;
75
+ readonly THAI: LanguageInfo;
76
+ readonly TURKISH: LanguageInfo;
77
+ readonly UKRAINIAN: LanguageInfo;
78
+ readonly VIETNAMESE: LanguageInfo;
79
+ readonly WELSH: LanguageInfo;
80
+ readonly AUTO: LanguageInfo;
81
+ readonly LATIN: LanguageInfo;
82
+ readonly NON_LATIN: LanguageInfo;
83
+ readonly LOCAL: LanguageInfo;
84
+ /**
85
+ * Language mode to display labels in both the local language and the language of the visitor's device, concatenated.
86
+ * Note that if those two languages are the same, labels won't be duplicated.
87
+ */
88
+ readonly VISITOR: LanguageInfo;
89
+ /**
90
+ * Language mode to display labels in both the local language and English, concatenated.
91
+ * Note that if those two languages are the same, labels won't be duplicated.
92
+ */
93
+ readonly VISITOR_ENGLISH: LanguageInfo;
94
+ /**
95
+ * Language mode to display labels in a language enforced in the style.
96
+ */
97
+ readonly STYLE: LanguageInfo;
98
+ /**
99
+ * Language mode to display labels in a language enforced in the style. The language cannot be further modified.
100
+ */
101
+ readonly STYLE_LOCK: LanguageInfo;
102
+ };
103
+ /**
104
+ * Get the browser language
105
+ */
106
+ export declare function getBrowserLanguage(): LanguageInfo;
107
+ export { Language, type LanguageInfo };
@@ -0,0 +1,17 @@
1
+ import { ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
2
+ export declare function styleToStyle(style: string | ReferenceMapStyle | MapStyleVariant | maplibregl.StyleSpecification | null | undefined): {
3
+ style: string | maplibregl.StyleSpecification;
4
+ requiresUrlMonitoring: boolean;
5
+ isFallback: boolean;
6
+ };
7
+ /**
8
+ * makes sure a URL is absolute
9
+ */
10
+ export declare function urlToAbsoluteUrl(url: string): string;
11
+ type StyleValidationReport = {
12
+ isValidJSON: boolean;
13
+ isValidStyle: boolean;
14
+ styleObject: maplibregl.StyleSpecification | null;
15
+ };
16
+ export declare function convertToStyleSpecificationString(str: string): StyleValidationReport;
17
+ export {};
@@ -0,0 +1,84 @@
1
+ import { default as maplibregl, RequestParameters, ResourceType, RequestTransformFunction } from 'maplibre-gl';
2
+ import { Map as MapSDK } from './Map';
3
+ export declare function enableRTL(): void;
4
+ export declare function bindAll(fns: Array<string>, context: any): void;
5
+ /**
6
+ * This function is meant to be used as transformRequest by any Map instance created.
7
+ * It adds the session ID as well as the MapTiler Cloud key from the config to all the requests
8
+ * performed on MapTiler Cloud servers.
9
+ */
10
+ export declare function maptilerCloudTransformRequest(url: string, resourceType?: ResourceType): RequestParameters;
11
+ /**
12
+ * This combines a user-defined tranformRequest function (optionnal)
13
+ * with the MapTiler Cloud-specific one: maptilerCloudTransformRequest
14
+ */
15
+ export declare function combineTransformRequest(userDefinedRTF?: RequestTransformFunction | null): RequestTransformFunction;
16
+ /**
17
+ * Generate a random string. Handy to create random IDs
18
+ */
19
+ export declare function generateRandomString(): string;
20
+ /**
21
+ * Check if a given string is in a uuid format
22
+ */
23
+ export declare function isUUID(s: string): boolean;
24
+ /**
25
+ * Attempt a JSON parse of a string but does not throw if the string is not valid JSON, returns `null` instead.
26
+ */
27
+ export declare function jsonParseNoThrow<T>(doc: string): T | null;
28
+ /**
29
+ * Simple function to check if an object is a GeoJSON
30
+ */
31
+ export declare function isValidGeoJSON<T>(obj: T & {
32
+ type: string;
33
+ }): boolean;
34
+ /**
35
+ * This function tests if WebGL2 is supported. Since it can be for a different reasons that WebGL2 is
36
+ * not supported but we do not have an action to take based on the reason, this function return null
37
+ * if there is no error (WebGL is supported), or returns a string with the error message if WebGL2 is
38
+ * not supported.
39
+ */
40
+ export declare function getWebGLSupportError(): string | null;
41
+ /**
42
+ * Display an error message in the Map div if WebGL2 is not supported
43
+ */
44
+ export declare function displayNoWebGlWarning(container: HTMLElement | string): void;
45
+ /**
46
+ * Display a warning message in the Map div if the WebGL context was lost
47
+ */
48
+ export declare function displayWebGLContextLostWarning(map: MapSDK): void;
49
+ /**
50
+ * In a text-field style property (as an object, not a string) the languages that are specified as
51
+ * ["get", "name:XX"] are replaced by the proved replacer (also an object).
52
+ * This replacement happened regardless of how deep in the object the flag is.
53
+ * Note that it does not replace the occurences of ["get", "name"] (local names)
54
+ */
55
+ export declare function changeFirstLanguage(origExpr: maplibregl.ExpressionSpecification, replacer: maplibregl.ExpressionSpecification, localized: boolean): maplibregl.ExpressionSpecification;
56
+ /**
57
+ * If `localized` is `true`, it checks for the pattern "{name:xx}" (with "xx" being a language iso string).
58
+ * If `localized` is `false`, it check for {name}.
59
+ * In a exact way or is a loose way (such as "foo {name:xx}" or "foo {name} bar")
60
+ */
61
+ export declare function checkNamePattern(str: string, localized: boolean): {
62
+ contains: boolean;
63
+ exactMatch: boolean;
64
+ };
65
+ /**
66
+ * Replaces the occurences of {name:xx} in a string by a provided object-expression to return a concat object expression
67
+ */
68
+ export declare function replaceLanguage(origLang: string, newLang: maplibregl.ExpressionSpecification, localized: boolean): maplibregl.ExpressionSpecification;
69
+ /**
70
+ * Find languages used in string label definition.
71
+ * The returned array contains languages such as "en", "fr" but
72
+ * can also contain null that stand for the use of {name}
73
+ */
74
+ export declare function findLanguageStr(str: string): Array<string | null>;
75
+ /**
76
+ * Find languages used in object label definition.
77
+ * The returned array contains languages such as "en", "fr" but
78
+ * can also contain null that stand for the use of {name}
79
+ */
80
+ export declare function findLanguageObj(origExpr: maplibregl.ExpressionSpecification): Array<string | null>;
81
+ export declare function computeLabelsLocalizationMetrics(layers: maplibregl.LayerSpecification[], map: MapSDK): {
82
+ unlocalized: number;
83
+ localized: Record<string, number>;
84
+ };
@@ -0,0 +1 @@
1
+ export type Unit = "imperial" | "metric" | "nautical";
@@ -0,0 +1,41 @@
1
+ import { default as MaptilerAnimation } from './MaptilerAnimation';
2
+ /**
3
+ * Manager for handling animation lifecycle and updates.
4
+ *
5
+ * The AnimationManager provides a centralized system for registering and
6
+ * coordinating multiple animations. To avoid individual calls to request animation frame
7
+ * for each animation, it maintains an animation loop
8
+ *
9
+ * This is not a class as it never needs to be instantiated,
10
+ * it's just a singeton object.
11
+ *
12
+ * It's not called directly but used within the MaptilerAnimation class.
13
+ */
14
+ declare const AnimationManager: {
15
+ animations: MaptilerAnimation[];
16
+ running: boolean;
17
+ /**
18
+ * Adds an animation to the manager. If this is the first animation added,
19
+ * it starts the animation loop.
20
+ *
21
+ * @param {MaptilerAnimation} animation - The animation to add.
22
+ */
23
+ add(animation: MaptilerAnimation): void;
24
+ /**
25
+ * Removes an animation from the manager. If there are no more animations,
26
+ * it stops the animation loop.
27
+ *
28
+ * @param {MaptilerAnimation} animation - The animation to remove.
29
+ */
30
+ remove(animation: MaptilerAnimation): void;
31
+ /**
32
+ * Stops the animation loop.
33
+ */
34
+ stop(): void;
35
+ /**
36
+ * Starts the animation loop. This function is called recursively using
37
+ * requestAnimationFrame to ensure smooth updates.
38
+ */
39
+ start(): void;
40
+ };
41
+ export default AnimationManager;
@@ -0,0 +1,238 @@
1
+ import { AnimationEventCallback, AnimationEventTypes, EasingFunctionName, Keyframe } from './types';
2
+ /**
3
+ * Configuration options for creating an animation.
4
+ *
5
+ * @interface MaptilerAnimationOptions
6
+ * @property {Keyframe[]} keyframes - The keyframes that define the animation states at various points in time.
7
+ * @property {number} duration - The total duration of the animation in milliseconds.
8
+ * @property {number} iterations - The number of times the animation should repeat. Use 0 for no repeat, or Infinity for an infinite loop.
9
+ * @property {delay} [delay] - Optional. The delay before the animation starts, in milliseconds. Defaults to 0 if not specified.
10
+ * @property {boolean} [manualMode] - Optional. If true, the animation will not be automatically managed by the animation manager
11
+ * and must be updated manually by calling update(). Defaults to false if not specified.
12
+ */
13
+ export interface MaptilerAnimationOptions {
14
+ keyframes: Keyframe[];
15
+ duration: number;
16
+ iterations: number;
17
+ manualMode?: boolean;
18
+ delay?: number;
19
+ }
20
+ /**
21
+ * A keyframe in the animation sequence where null or undefined values
22
+ * are interpolated to fill in the gaps between keyframes.
23
+ *
24
+ * @extends Keyframe
25
+ * @property {Record<string, number>} props - The properties to be animated at this keyframe.
26
+ * @property {EasingFunctionName} easing - The easing function to use for this keyframe.
27
+ * @property {string} id - A unique identifier for this keyframe.
28
+ */
29
+ export type InterpolatedKeyFrame = Keyframe & {
30
+ props: Record<string, number>;
31
+ easing: EasingFunctionName;
32
+ id: string;
33
+ };
34
+ /**
35
+ * Animation controller for keyframe-based animation sequences.
36
+ *
37
+ * MaptilerAnimation handles interpolation between keyframes, timing control,
38
+ * and event dispatching during animation playback.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const animation = new MaptilerAnimation({
43
+ * keyframes: [
44
+ * { delta: 0, props: { x: 0, y: 0 } },
45
+ * { delta: 0.5, props: { x: 50, y: 20 } },
46
+ * { delta: 1, props: { x: 100, y: 0 } }
47
+ * ],
48
+ * duration: 1000, // milliseconds
49
+ * iterations: 2
50
+ * });
51
+ *
52
+ * animation.addEventListener(AnimationEventTypes.TimeUpdate, (event) => {
53
+ * // Use interpolated property values to update something
54
+ * console.log(event.props);
55
+ * });
56
+ *
57
+ * animation.play();
58
+ * ```
59
+ *
60
+ * @remarks
61
+ * The animation supports various playback controls (play, pause, stop, reset),
62
+ * time manipulation, and an event system for tracking animation progress.
63
+ * Properties missing in keyframes will be automatically interpolated.
64
+ *
65
+ * Animation events include play, pause, stop, timeupdate, iteration, and more.
66
+ *
67
+ * When not using manualMode, animations are automatically added to the AnimationManager.
68
+ */
69
+ export default class MaptilerAnimation {
70
+ private playing;
71
+ /**
72
+ * Indicates if the animation is currently playing
73
+ * @returns {boolean} - true if the animation is playing, false otherwise
74
+ */
75
+ get isPlaying(): boolean;
76
+ /**
77
+ * The number of times to repeat the animation
78
+ * 0 is no repeat, Infinity is infinite repeat
79
+ */
80
+ private iterations;
81
+ private currentIteration;
82
+ /** An array of keyframes animations to interpolate between */
83
+ private keyframes;
84
+ /** The current keyframe id */
85
+ private currentKeyframe?;
86
+ /**The duration of the animation in milliseconds (when playbackRate === 1) */
87
+ readonly duration: number;
88
+ /**
89
+ * The duration of the animation affected by the playback rate
90
+ * if playback rate is 2, the effective duration is double
91
+ */
92
+ private effectiveDuration;
93
+ /** the rate at which the animation is playing */
94
+ private playbackRate;
95
+ /** the current time in milliseconds */
96
+ private currentTime;
97
+ /** 0 start of the animation, 1 end of the animation */
98
+ private currentDelta;
99
+ /** The time at which the animation started */
100
+ private animationStartTime;
101
+ /** The time at which the last frame was rendered */
102
+ private lastFrameAt;
103
+ /** The delay before the animation starts */
104
+ private delay;
105
+ /** The timeout ID for the delay before the animation starts */
106
+ private delayTimeoutID?;
107
+ /** The listeners added for each event */
108
+ private listeners;
109
+ /** The props from the previous frame */
110
+ private previousProps;
111
+ constructor({ keyframes, duration, iterations, manualMode, delay }: MaptilerAnimationOptions);
112
+ /**
113
+ * Starts or resumes the animation
114
+ * @returns This animation instance for method chaining
115
+ * @event AnimationEventTypes.Play
116
+ */
117
+ play(): this;
118
+ /**
119
+ * Pauses the animation
120
+ * @returns This animation instance for method chaining
121
+ * @event AnimationEventTypes.Pause
122
+ */
123
+ pause(): this;
124
+ /**
125
+ * Stops the animation and resets to initial state
126
+ * @returns This animation instance for method chaining
127
+ * @event AnimationEventTypes.Stop
128
+ */
129
+ stop(silent?: boolean): this;
130
+ /**
131
+ * Resets the animation to its initial state without stopping
132
+ * @returns This animation instance for method chaining
133
+ * @event AnimationEventTypes.Reset
134
+ */
135
+ reset(manual?: boolean): this;
136
+ /**
137
+ * Updates the animation state if playing, this is used by the AnimationManager
138
+ * to update all animations in the loop
139
+ * @returns This animation instance for method chaining
140
+ */
141
+ updateInternal(): this;
142
+ /**
143
+ * Updates the animation state, interpolating between keyframes
144
+ * and emitting events as necessary
145
+ * @event AnimationEventTypes.TimeUpdate
146
+ * @event AnimationEventTypes.Keyframe
147
+ * @event AnimationEventTypes.Iteration
148
+ * @event AnimationEventTypes.AnimationEnd
149
+ * @returns This animation instance for method chaining
150
+ */
151
+ update(manual?: boolean, ignoreIteration?: boolean): this;
152
+ /**
153
+ * Gets the current and next keyframes at a specific time
154
+ * @param time - The time position to query
155
+ * @returns Object containing current and next keyframes, which may be null
156
+ */
157
+ getCurrentAndNextKeyFramesAtTime(time: number): {
158
+ current: InterpolatedKeyFrame | null;
159
+ next: InterpolatedKeyFrame | null;
160
+ };
161
+ /**
162
+ * Gets the current and next keyframes at a specific delta value
163
+ * @param delta - The delta value to query
164
+ * @returns Object containing current and next keyframes, which may be null
165
+ */
166
+ getCurrentAndNextKeyFramesAtDelta(delta: number): {
167
+ current: InterpolatedKeyFrame | null;
168
+ next: InterpolatedKeyFrame | null;
169
+ };
170
+ /**
171
+ * Gets the current time position of the animation
172
+ * @returns The current time in milliseconds
173
+ */
174
+ getCurrentTime(): number;
175
+ /**
176
+ * Sets the current time position of the animation
177
+ * @param time - The time to set in milliseconds
178
+ * @returns This animation instance for method chaining
179
+ * @throws Error if time is greater than the duration
180
+ * @event AnimationEventTypes.Scrub
181
+ */
182
+ setCurrentTime(time: number): this;
183
+ /**
184
+ * Gets the current delta value of the animation
185
+ * @returns The current delta value (normalized progress between 0 and 1)
186
+ */
187
+ getCurrentDelta(): number;
188
+ /**
189
+ * Sets the current delta value of the animation
190
+ * @param delta - The delta value to set (normalized progress between 0 and 1)
191
+ * @returns This animation instance for method chaining
192
+ * @throws Error if delta is greater than 1
193
+ * @event AnimationEventTypes.Scrub
194
+ */
195
+ setCurrentDelta(delta: number): this;
196
+ /**
197
+ * Sets the playback rate of the animation
198
+ * @param rate - The playback rate (1.0 is normal speed)
199
+ * @returns This animation instance for method chaining
200
+ * @event AnimationEventTypes.PlaybackRateChange
201
+ */
202
+ setPlaybackRate(rate: number): this;
203
+ /**
204
+ * Gets the current playback rate
205
+ * @returns The current playback rate
206
+ */
207
+ getPlaybackRate(): number;
208
+ /**
209
+ * Adds an event listener to the animation
210
+ * @param type - The type of event to listen for
211
+ * @param callback - The callback function to execute when the event occurs
212
+ * @returns This animation instance for method chaining
213
+ */
214
+ addEventListener(type: AnimationEventTypes, callback: AnimationEventCallback): this;
215
+ /**
216
+ * Removes an event listener from the animation
217
+ * @param type - The type of event to remove
218
+ * @param callback - The callback function to remove
219
+ * @returns This animation instance for method chaining
220
+ */
221
+ removeEventListener(type: AnimationEventTypes, callback: AnimationEventCallback): this;
222
+ /**
223
+ * Emits an event to all listeners of a specific type
224
+ * @param event - The type of event to emit
225
+ * @param keyframe - The keyframe that triggered the event
226
+ * @param props - The interpolated properties at the current delta
227
+ */
228
+ emitEvent(event: AnimationEventTypes, keyframe?: Keyframe | null, nextKeyframe?: Keyframe | null, props?: Record<string, number>, previousProps?: Record<string, number>): void;
229
+ /**
230
+ * Creates a clone of this animation
231
+ * @returns A new animation instance with the same properties as this one
232
+ */
233
+ clone(): MaptilerAnimation;
234
+ /**
235
+ * Destroys the animation instance, removing all event listeners and stopping playback
236
+ */
237
+ destroy(): void;
238
+ }
@@ -0,0 +1,182 @@
1
+ import { Feature, LineString, MultiLineString, MultiPoint, Polygon } from 'geojson';
2
+ import { EasingFunctionName, Keyframe, NumericArrayWithNull } from './types';
3
+ /**
4
+ * Performs simple linear interpolation between two numbers.
5
+ *
6
+ * @param a - The start value
7
+ * @param b - The end value
8
+ * @param alpha - The interpolation factor (typically between 0 and 1):
9
+ * 0 returns a, 1 returns b, and values in between return a proportional mix
10
+ * @returns The interpolated value between a and b
11
+ */
12
+ export declare function lerp(a: number, b: number, alpha: number): number;
13
+ /**
14
+ * Interpolates an array of numbers, replacing null values with interpolated values.
15
+ *
16
+ * `null` is treated as an empty value where an interpolation is needed.
17
+ *
18
+ * @param {NumericArrayWithNull} numericArray - The array of numbers to interpolate, which may contain null values
19
+ * @returns A new array with null values replaced by interpolated values
20
+ */
21
+ export declare function lerpArrayValues(numericArray: NumericArrayWithNull): number[];
22
+ /**
23
+ * Looks ahead in an array for the next entry that is not null.
24
+ *
25
+ * @param arr - The array to search through
26
+ * @param currentIndex - The index to start searching from
27
+ * @returns [index, value] A tuple containing the index of the next entry and its value, or null if not found
28
+ */
29
+ export declare function findNextEntryAndIndexWithValue(arr: NumericArrayWithNull, currentIndex: number): (number | null)[];
30
+ /**
31
+ * Looks back in an array for the previous entry that is not null.
32
+ *
33
+ * @param arr - The array to search through
34
+ * @param currentIndex - The index to start searching from
35
+ * @returns [index, value] A tuple containing the index of the previous entry and its value, or null if not found
36
+ */
37
+ export declare function findPreviousEntryAndIndexWithValue(arr: NumericArrayWithNull, currentIndex: number): (number | null)[];
38
+ /**
39
+ * Options for parsing GeoJSON data into animation keyframes.
40
+ *
41
+ * @interface IparseGeoJSONToKeyframesOptions
42
+ * @property {EasingFunctionName} [defaultEasing] - The default easing function to apply to the animation.
43
+ * @property {Object|false} [pathSmoothing] - Configuration for path smoothing, or false to disable smoothing.
44
+ * @property {number} [pathSmoothing.resolution] - The resolution used for path smoothing, higher values produce more detailed paths.
45
+ * @property {number} [pathSmoothing.epsilon] - Optional tolerance parameter for path simplification.
46
+ */
47
+ export interface IparseGeoJSONToKeyframesOptions {
48
+ defaultEasing?: EasingFunctionName;
49
+ pathSmoothing?: {
50
+ resolution: number;
51
+ epsilon?: number;
52
+ } | false;
53
+ }
54
+ /**
55
+ * Represents geometry types that can be animated using keyframes.
56
+ *
57
+ * This type includes geometries like MultiPoint, LineString, MultiLineString, and Polygon
58
+ * which can be interpolated or transformed over time in animations.
59
+ */
60
+ export type KeyframeableGeometry = MultiPoint | LineString | MultiLineString | Polygon;
61
+ /**
62
+ * Represents a GeoJSON Feature that can be animated with keyframes.
63
+ * Extends the standard GeoJSON Feature with animation-specific properties.
64
+ *
65
+ * @typedef {Object} KeyframeableGeoJSONFeature
66
+ * @extends {Feature<KeyframeableGeometry>}
67
+ * @property {Object} properties - Contains both standard GeoJSON properties (as number arrays) and animation controls
68
+ * @property {EasingFunctionName[]} [properties.@easing] - Easing functions to apply to property animations
69
+ * @property {number[]} [properties.@delta] - Delta values for animation calculations
70
+ * @property {number} [properties.@duration] - Duration of the animation in milliseconds
71
+ * @property {number} [properties.@delay] - Delay before animation starts in milliseconds
72
+ * @property {number} [properties.@iterations] - Number of times the animation should repeat
73
+ * @property {boolean} [properties.@autoplay] - Whether the animation should start automatically
74
+ */
75
+ export type KeyframeableGeoJSONFeature = Feature<KeyframeableGeometry> & {
76
+ properties: Record<string, number[]> & {
77
+ "@easing"?: EasingFunctionName[];
78
+ "@delta"?: number[];
79
+ "@duration"?: number;
80
+ "@delay"?: number;
81
+ "@iterations"?: number;
82
+ "@autoplay"?: boolean;
83
+ altitude?: (number | null)[];
84
+ };
85
+ };
86
+ /**
87
+ * Converts a GeoJSON feature into an array of animation keyframes.
88
+ *
89
+ * Parses a GeoJSON feature with reserved properties to create animation keyframes.
90
+ * It extracts coordinates from the geometry and uses properties prefixed with '@' as animation
91
+ * control parameters (easing functions, delta values). Non-reserved properties are preserved
92
+ * and passed to the keyframe objects as props that will be interpolated
93
+ *
94
+ * @param {KeyframeableGeoJSONFeature} feature - The GeoJSON feature to convert to keyframes
95
+ * @param {IparseGeoJSONToKeyframesOptions} options - Configuration options
96
+ *
97
+ * @returns Array of keyframe objects that can be used for animation
98
+ *
99
+ * @throws {Error} When no geometry is found in the feature
100
+ * @throws {Error} When the geometry type is not supported
101
+ */
102
+ export declare function parseGeoJSONFeatureToKeyframes(feature: KeyframeableGeoJSONFeature, options?: IparseGeoJSONToKeyframesOptions): Keyframe[];
103
+ /**
104
+ *
105
+ * "Stretches" an array of numbers to a new length, filling in null values for the new indices.
106
+ *
107
+ * @param source the array to stretch
108
+ * @param targetLength the length to stretch to
109
+ * @returns {number[]} the stretched array with null values
110
+ */
111
+ export declare function stretchNumericalArray(source: number[], targetLength: number): (number | null)[];
112
+ /**
113
+ * Generates an array of keyframes from coordinates, deltas, easings, and other properties provided by the geoJSON feature.
114
+ * Assumes that the coordinates are in the format [longitude, latitude, altitude?]. If altitude is not provided, it defaults to 0.
115
+ *
116
+ * @param coordinates - Array of coordinate points, where each point is an array of [longitude, latitude, altitude?]
117
+ * @param deltas - Array of time deltas between keyframes
118
+ * @param easings - Array of easing function names to apply to each keyframe transition
119
+ * @param properties - Optional additional properties as key-value pairs, where each value is an array
120
+ * of numbers corresponding to each keyframe
121
+ *
122
+ * @returns An array of Keyframe objects, each containing coordinate props, delta, and easing information
123
+ *
124
+ * @throws Error if the arrays for coordinates, deltas, easings, and any property values don't have matching lengths
125
+ *
126
+ * @example
127
+ * const keyframes = getKeyframes(
128
+ * [[0, 0, 10], [10, 10, 20]], // coordinates
129
+ * [1000, 2000], // deltas (in milliseconds)
130
+ * [EasingFunctionName.Linear, EasingFunctionName.ElasticIn], // easings
131
+ * { zoom: [10, 15] } // additional properties
132
+ * );
133
+ */
134
+ export declare function getKeyframes(coordinates: number[][], deltas: number[], easings: EasingFunctionName[], properties?: Record<string, number[]>): Keyframe[];
135
+ /**
136
+ * Creates a smoothed path using cubic Bezier curves from an array of coordinates.
137
+ *
138
+ * This function takes a series of points and creates a smooth path by generating cubic
139
+ * Bezier curves between them. It uses the Catmull-Rom method to automatically calculate
140
+ * control points for each curve segment. If the path has fewer than 4 points, the original
141
+ * path is returned unchanged.
142
+ *
143
+ * @param inputPath - Array of [x, y] coordinates that define the original path
144
+ * @param outputResolution - Controls how many points are generated along each segment
145
+ * (higher values create smoother curves with more points)
146
+ * @param simplificationThreshold - Optional threshold for simplifying the input path before
147
+ * creating the curves.
148
+ * @returns An array of [x, y] coordinates representing the smoothed path
149
+ */
150
+ export declare function createBezierPathFromCoordinates(inputPath: [number, number][], outputResolution?: number, simplificationThreshold?: number): [number, number][];
151
+ /**
152
+ * Calculates the average distance between points in an array of coordinates.
153
+ *
154
+ * This function computes the average distance between consecutive points in the array.
155
+ * It uses the LngLat class from MapLibre to calculate distances based on geographical coordinates.
156
+ *
157
+ * @param arr - An array of coordinate pairs [longitude, latitude]
158
+ * @returns The average distance between points in the array
159
+ */
160
+ export declare function getAverageDistance(arr: [number, number][]): number;
161
+ /**
162
+ * Simplfies a path by removing points that are too close together.
163
+ *
164
+ * This function first resamples the path based on the average distance between points,
165
+ * then filters out points that are closer than the specified distance from the last included point.
166
+ * The first and last points of the original path are always preserved.
167
+ *
168
+ * @param points - An array of coordinate pairs [longitude, latitude]
169
+ * @param distance - The minimum distance between points in the simplified path
170
+ * @returns A new array containing a simplified version of the input path
171
+ */
172
+ export declare function simplifyPath(points: [number, number][], distance: number): [number, number][];
173
+ /**
174
+ * Resamples a geographic path to have points spaced at approximately equal distances.
175
+ * If the original path has fewer than 2 points, it is returned unchanged.
176
+ *
177
+ * @param path - An array of coordinate pairs [longitude, latitude] representing the path to resample
178
+ * @param spacing - The desired spacing between points in the resampled path (in the same unit as used by the distanceTo method), defaults to 10
179
+ * @returns A new array of coordinate pairs representing the resampled path with approximately equal spacing between points
180
+ *
181
+ */
182
+ export declare function resamplePath(path: [number, number][], spacing?: number): [number, number][];
@@ -0,0 +1,3 @@
1
+ import { EasingFunctionName } from './types';
2
+ declare const EasingFunctions: Record<EasingFunctionName, (K: number) => number>;
3
+ export default EasingFunctions;