@maptiler/sdk 4.2.0 → 5.0.0-beta.m-r.1

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 (73) hide show
  1. package/README.md +276 -30
  2. package/dist/ImageViewer/ImageViewer.d.ts +6 -8
  3. package/dist/ImageViewer/ImageViewerMarker.d.ts +9 -9
  4. package/dist/ImageViewer/monkeyPatchML.d.ts +1 -1
  5. package/dist/Map.d.ts +155 -11
  6. package/dist/Marker/Marker.d.ts +397 -0
  7. package/dist/Marker/MarkerManager.d.ts +137 -0
  8. package/dist/Marker/altitude-math.d.ts +24 -0
  9. package/dist/Marker/collision-helpers.d.ts +160 -0
  10. package/dist/Marker/index.d.ts +2 -0
  11. package/dist/Marker/marker-adaptive-colors.d.ts +35 -0
  12. package/dist/Marker/marker-animation-presets.d.ts +60 -0
  13. package/dist/Marker/marker-constants.d.ts +111 -0
  14. package/dist/Marker/marker-content-registry.d.ts +17 -0
  15. package/dist/Marker/marker-dom-utils.d.ts +66 -0
  16. package/dist/Marker/marker-icons.d.ts +31 -0
  17. package/dist/Marker/marker-state-helpers.d.ts +2 -0
  18. package/dist/Marker/marker-svg-config.d.ts +84 -0
  19. package/dist/Marker/marker-symbols.d.ts +12 -0
  20. package/dist/Marker/marker-text-fit.d.ts +20 -0
  21. package/dist/Marker/marker-transitions.d.ts +29 -0
  22. package/dist/Marker/types.d.ts +458 -0
  23. package/dist/bundler/maplibre-gl-worker.mjs +13839 -0
  24. package/dist/bundler/next-worker.mjs +16 -0
  25. package/dist/bundler/next.cjs +42 -0
  26. package/dist/bundler/next.d.ts +6 -0
  27. package/dist/bundler/next.mjs +48 -0
  28. package/dist/bundler/side-effect.d.ts +2 -0
  29. package/dist/bundler/vite-worker.mjs +11 -0
  30. package/dist/bundler/webpack-worker.mjs +11 -0
  31. package/dist/constants/defaults.d.ts +0 -1
  32. package/dist/controls/MaptilerGeolocateControl.d.ts +1 -1
  33. package/dist/controls/MaptilerLogoControl.d.ts +1 -2
  34. package/dist/controls/MaptilerNavigationControl.d.ts +3 -4
  35. package/dist/controls/Minimap.d.ts +3 -3
  36. package/dist/eslint.mjs +4 -4
  37. package/dist/index.d.ts +10 -81
  38. package/dist/mapstyle.d.ts +11 -3
  39. package/dist/maptiler-sdk.css +108 -1
  40. package/dist/maptiler-sdk.d.ts +1 -1
  41. package/dist/maptiler-sdk.mjs +16779 -14378
  42. package/dist/maptiler-sdk.mjs.map +1 -1
  43. package/dist/routing.d.ts +18 -0
  44. package/dist/tools.d.ts +6 -7
  45. package/dist/utils/defaultWorkerUrl.d.ts +17 -0
  46. package/dist/utils/object.d.ts +1 -0
  47. package/package.json +26 -8
  48. package/dist/MLAdapters/AttributionControl.d.ts +0 -5
  49. package/dist/MLAdapters/BoxZoomHandler.d.ts +0 -7
  50. package/dist/MLAdapters/CanvasSource.d.ts +0 -5
  51. package/dist/MLAdapters/CooperativeGesturesHandler.d.ts +0 -5
  52. package/dist/MLAdapters/FullscreenControl.d.ts +0 -5
  53. package/dist/MLAdapters/GeoJSONSource.d.ts +0 -5
  54. package/dist/MLAdapters/GeolocateControl.d.ts +0 -5
  55. package/dist/MLAdapters/ImageSource.d.ts +0 -5
  56. package/dist/MLAdapters/KeyboardHandler.d.ts +0 -5
  57. package/dist/MLAdapters/LogoControl.d.ts +0 -5
  58. package/dist/MLAdapters/MapMouseEvent.d.ts +0 -5
  59. package/dist/MLAdapters/MapTouchEvent.d.ts +0 -5
  60. package/dist/MLAdapters/MapWheelEvent.d.ts +0 -5
  61. package/dist/MLAdapters/Marker.d.ts +0 -5
  62. package/dist/MLAdapters/NavigationControl.d.ts +0 -5
  63. package/dist/MLAdapters/Popup.d.ts +0 -5
  64. package/dist/MLAdapters/RasterDEMTileSource.d.ts +0 -5
  65. package/dist/MLAdapters/RasterTileSource.d.ts +0 -5
  66. package/dist/MLAdapters/ScaleControl.d.ts +0 -5
  67. package/dist/MLAdapters/ScrollZoomHandler.d.ts +0 -5
  68. package/dist/MLAdapters/Style.d.ts +0 -5
  69. package/dist/MLAdapters/TerrainControl.d.ts +0 -5
  70. package/dist/MLAdapters/TwoFingersTouchPitchHandler.d.ts +0 -5
  71. package/dist/MLAdapters/VectorTileSource.d.ts +0 -5
  72. package/dist/MLAdapters/VideoSource.d.ts +0 -5
  73. package/dist/ml-types.d.ts +0 -638
@@ -0,0 +1,18 @@
1
+ import * as client from "@maptiler/client";
2
+ export type ExtraRoutingOptions = {
3
+ /**
4
+ * Specifies whether the routing request runs with a session logic.
5
+ * A "session" is started at the initialization of the SDK and finished when the browser
6
+ * page is being closed or refreshed.
7
+ * When this option is enabled, extra URL param `mtsid` is added to queries
8
+ * to the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
9
+ *
10
+ * Default: value of this option in global config (which is `true` by default).
11
+ */
12
+ session?: boolean;
13
+ };
14
+ export type RoutingOptions = client.RoutingOptions & ExtraRoutingOptions;
15
+ export declare const routing: {
16
+ directionsPost: (body: client.RoutingRequest, options?: RoutingOptions) => Promise<client.RoutingResponse>;
17
+ directionsGet: (req: client.RoutingGetRequest, options?: RoutingOptions) => Promise<client.RoutingResponse>;
18
+ };
package/dist/tools.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { default as maplibregl, RequestParameters, ResourceType, RequestTransformFunction } from 'maplibre-gl';
1
+ import { ExpressionSpecification, LayerSpecification, RequestParameters, ResourceType, RequestTransformFunction } from 'maplibre-gl';
2
2
  import { Map as MapSDK } from './Map';
3
- export declare function enableRTL(customPluginURL?: string): Promise<void>;
4
3
  export declare function bindAll(fns: Array<string>, context: any): void;
5
4
  /**
6
5
  * This function is meant to be used as transformRequest by any Map instance created.
@@ -52,7 +51,7 @@ export declare function displayWebGLContextLostWarning(map: MapSDK): void;
52
51
  * This replacement happened regardless of how deep in the object the flag is.
53
52
  * Note that it does not replace the occurences of ["get", "name"] (local names)
54
53
  */
55
- export declare function changeFirstLanguage(origExpr: maplibregl.ExpressionSpecification, replacer: maplibregl.ExpressionSpecification, localized: boolean): maplibregl.ExpressionSpecification;
54
+ export declare function changeFirstLanguage(origExpr: ExpressionSpecification, replacer: ExpressionSpecification, localized: boolean): ExpressionSpecification;
56
55
  /**
57
56
  * If `localized` is `true`, it checks for the pattern "{name:xx}" (with "xx" being a language iso string).
58
57
  * If `localized` is `false`, it check for {name}.
@@ -65,8 +64,8 @@ export declare function checkNamePattern(str: string, localized: boolean): {
65
64
  /**
66
65
  * Replaces the occurences of {name:xx} in a string by a provided object-expression to return a concat object expression
67
66
  */
68
- export declare function replaceLanguage(origLang: string, newLang: maplibregl.ExpressionSpecification, localized: boolean): maplibregl.ExpressionSpecification;
69
- export declare function addFormatElevationExpressionFromString(expression: maplibregl.ExpressionSpecification | string): maplibregl.ExpressionSpecification | string;
67
+ export declare function replaceLanguage(origLang: string, newLang: ExpressionSpecification, localized: boolean): ExpressionSpecification;
68
+ export declare function addFormatElevationExpressionFromString(expression: ExpressionSpecification | string): ExpressionSpecification | string;
70
69
  /**
71
70
  * Find languages used in string label definition.
72
71
  * The returned array contains languages such as "en", "fr" but
@@ -78,8 +77,8 @@ export declare function findLanguageStr(str: string): Array<string | null>;
78
77
  * The returned array contains languages such as "en", "fr" but
79
78
  * can also contain null that stand for the use of {name}
80
79
  */
81
- export declare function findLanguageObj(origExpr: maplibregl.ExpressionSpecification): Array<string | null>;
82
- export declare function computeLabelsLocalizationMetrics(layers: maplibregl.LayerSpecification[], map: MapSDK): {
80
+ export declare function findLanguageObj(origExpr: ExpressionSpecification): Array<string | null>;
81
+ export declare function computeLabelsLocalizationMetrics(layers: LayerSpecification[], map: MapSDK): {
83
82
  unlocalized: number;
84
83
  localized: Record<string, number>;
85
84
  };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * URL of the MapLibre worker published on the MapTiler CDN alongside the UMD bundle of this SDK version.
3
+ */
4
+ export declare function getCdnWorkerUrl(): string;
5
+ /**
6
+ * Since MapLibre v6, the worker is loaded from a separate file that bundlers generally don't emit,
7
+ * so in the ES build (npm) the SDK falls back to the worker hosted on the MapTiler CDN.
8
+ * A URL set beforehand, with `setWorkerUrl` or one of the bundler helpers
9
+ * (e.g. `@maptiler/sdk/vite-worker`), always takes precedence.
10
+ * The UMD build keeps MapLibre's default, which finds the worker next to the UMD bundle.
11
+ */
12
+ export declare function setDefaultWorkerUrl(): void;
13
+ /**
14
+ * Same as MapLibre's `prewarm`, but sets the default worker URL first,
15
+ * as the workers it starts are the ones later used by the maps.
16
+ */
17
+ export declare function prewarm(): void;
@@ -1 +1,2 @@
1
1
  export declare function orderObjectKeys<T extends Record<string, unknown>>(obj?: T): T;
2
+ export declare function omit<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/sdk",
3
- "version": "4.2.0",
3
+ "version": "5.0.0-beta.m-r.1",
4
4
  "description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
5
5
  "author": "MapTiler",
6
6
  "module": "dist/maptiler-sdk.mjs",
@@ -13,6 +13,23 @@
13
13
  "import": "./dist/maptiler-sdk.mjs",
14
14
  "types": "./dist/maptiler-sdk.d.ts"
15
15
  },
16
+ "./vite-worker": {
17
+ "types": "./dist/bundler/side-effect.d.ts",
18
+ "import": "./dist/bundler/vite-worker.mjs"
19
+ },
20
+ "./webpack-worker": {
21
+ "types": "./dist/bundler/side-effect.d.ts",
22
+ "import": "./dist/bundler/webpack-worker.mjs"
23
+ },
24
+ "./next-worker": {
25
+ "types": "./dist/bundler/side-effect.d.ts",
26
+ "import": "./dist/bundler/next-worker.mjs"
27
+ },
28
+ "./next": {
29
+ "types": "./dist/bundler/next.d.ts",
30
+ "import": "./dist/bundler/next.mjs",
31
+ "require": "./dist/bundler/next.cjs"
32
+ },
16
33
  "./dist/maptiler-sdk.css": {
17
34
  "import": "./dist/maptiler-sdk.css"
18
35
  },
@@ -44,6 +61,7 @@
44
61
  },
45
62
  "scripts": {
46
63
  "prepare": "husky",
64
+ "prepack": "npm run build",
47
65
  "doc": "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
48
66
  "ncu": "npx npm-check-updates",
49
67
  "lint": "tsc --noEmit && eslint src",
@@ -80,7 +98,7 @@
80
98
  "@types/stats.js": "^0.17.4",
81
99
  "@types/uuid": "^10.0.0",
82
100
  "@types/xmldom": "^0.1.31",
83
- "@vitest/web-worker": "^3.0.9",
101
+ "@vitest/web-worker": "^5.0.4",
84
102
  "@xmldom/xmldom": "^0.8.10",
85
103
  "concurrently": "^9.1.2",
86
104
  "eslint": "^9.21.0",
@@ -89,24 +107,24 @@
89
107
  "happy-dom": "^20.8.9",
90
108
  "husky": "^8.0.0",
91
109
  "jiti": "^2.4.2",
92
- "lint-staged": "^15.4.3",
110
+ "lint-staged": "^17.6.0",
93
111
  "prettier": "3.5.2",
94
112
  "stats.js": "^0.17.0",
95
113
  "typedoc": "^0.27.6",
96
114
  "typescript": "^5.7.3",
97
115
  "typescript-eslint": "^8.25.0",
98
116
  "vite": "^6.0.7",
99
- "vite-plugin-dts": "^4.5.0",
100
- "vitest": "^3.0.9"
117
+ "vite-plugin-dts": "^5.1.2",
118
+ "vitest": "^5.0.4"
101
119
  },
102
120
  "dependencies": {
103
- "@maplibre/maplibre-gl-style-spec": "^24.7.0",
104
- "@maptiler/client": "^3.1.0",
121
+ "@maplibre/maplibre-gl-style-spec": "^26.4.4",
122
+ "@maptiler/client": "3.2.0-rc.1",
105
123
  "eslint-plugin-compat": "^6.1.0",
106
124
  "events": "^3.3.0",
107
125
  "gl-matrix": "^3.4.4",
108
126
  "js-base64": "^3.7.7",
109
- "maplibre-gl": "5.24",
127
+ "maplibre-gl": "6.11.2",
110
128
  "uuid": "^14.0.0"
111
129
  }
112
130
  }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class AttributionControl extends maplibregl.AttributionControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,7 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class BoxZoomHandler extends maplibregl.BoxZoomHandler {
4
- constructor(map: SDKMap | MapMLGL, options: {
5
- clickTolerance: number;
6
- });
7
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class CanvasSource extends maplibregl.CanvasSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, GestureOptions, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
4
- constructor(map: SDKMap | MapMLGL, options: GestureOptions);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class FullscreenControl extends maplibregl.FullscreenControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class GeoJSONSource extends maplibregl.GeoJSONSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class GeolocateControl extends maplibregl.GeolocateControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class ImageSource extends maplibregl.ImageSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class KeyboardHandler extends maplibregl.KeyboardHandler {
4
- constructor(map: SDKMap | MapMLGL);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class LogoControl extends maplibregl.LogoControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class MapMouseEvent extends maplibregl.MapMouseEvent {
4
- constructor(type: string, map: SDKMap | MapMLGL, originalEvent: MouseEvent, data?: Record<string, unknown>);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class MapTouchEvent extends maplibregl.MapTouchEvent {
4
- constructor(type: string, map: SDKMap | MapMLGL, originalEvent: TouchEvent);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class MapWheelEvent extends maplibregl.MapWheelEvent {
4
- constructor(type: string, map: SDKMap | MapMLGL, originalEvent: WheelEvent);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class Marker extends maplibregl.Marker {
4
- addTo(map: SDKMap | MapMLGL): this;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class NavigationControl extends maplibregl.NavigationControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class Popup extends maplibregl.Popup {
4
- addTo(map: SDKMap | MapMLGL): this;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class RasterTileSource extends maplibregl.RasterTileSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class ScaleControl extends maplibregl.ScaleControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
4
- constructor(map: SDKMap | MapMLGL, triggerRenderFrame: () => void);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, StyleOptions } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class Style extends maplibregl.Style {
4
- constructor(map: SDKMap, options?: StyleOptions);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class TerrainControl extends maplibregl.TerrainControl {
4
- onAdd(map: SDKMap | MapMLGL): HTMLElement;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
4
- constructor(map: SDKMap | MapMLGL);
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class VectorTileSource extends maplibregl.VectorTileSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }
@@ -1,5 +0,0 @@
1
- import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
2
- import { Map as SDKMap } from '../Map';
3
- export declare class VideoSource extends maplibregl.VideoSource {
4
- onAdd(map: SDKMap | MapMLGL): void;
5
- }