@maptiler/sdk 3.10.2 → 3.11.0-rc.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.
- package/README.md +233 -66
- package/dist/eslint.mjs +8 -0
- package/dist/maptiler-sdk.mjs +3512 -2464
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/ImageViewer/ImageViewer.d.ts +2 -2
- package/dist/src/Map.d.ts +42 -2
- package/dist/src/MaptilerAnimation/AnimationManager.d.ts +41 -0
- package/dist/src/MaptilerAnimation/MaptilerAnimation.d.ts +238 -0
- package/dist/src/MaptilerAnimation/animation-helpers.d.ts +183 -0
- package/dist/src/MaptilerAnimation/easing.d.ts +3 -0
- package/dist/src/MaptilerAnimation/index.d.ts +7 -0
- package/dist/src/MaptilerAnimation/types.d.ts +26 -0
- package/dist/src/custom-layers/AnimatedRouteLayer/AnimatedRouteLayer.d.ts +293 -0
- package/dist/src/custom-layers/AnimatedRouteLayer/index.d.ts +1 -0
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/array.d.ts +1 -0
- package/dist/src/utils/json.d.ts +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/e2e/global.d.ts +14 -1
- package/e2e/public/animated-route.geojson +82 -0
- package/e2e/public/animatedRouteLayer.html +24 -0
- package/e2e/public/haloSpace.html +25 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-0-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-1-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-10-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-11-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-12-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-13-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-14-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-15-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-16-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-17-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-18-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-19-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-2-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-3-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-4-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-5-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-6-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-7-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-8-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-9-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-catalogue-style-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-no-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-remote-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-catalogue-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-catalogue-style-config-space-undefined-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-constructor-undefined-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-catalogue-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-true-no-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-chromium.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/tests/AnimatedRouteLayer.test.ts +45 -0
- package/e2e/tests/consts.ts +0 -0
- package/e2e/tests/expected-results/animatedRouteLayer-1.json +202 -0
- package/e2e/tests/haloSpace.test.ts +809 -0
- package/e2e/tests/helpers/fetchGeojson.ts +21 -0
- package/e2e/tests/helpers/getMapInstanceForFixture.ts +87 -0
- package/e2e/tests/helpers/injectGlobalVariables.ts +13 -0
- package/e2e/tests/helpers/loadFixtureAndGetMapHandle.ts +46 -36
- package/e2e/tests/mocks/maptiler-style-space-halo-invalid.json +38 -0
- package/e2e/tests/mocks/maptiler-style-space-halo.json +41 -0
- package/e2e/tests/mocks/maptiler-style.json +1 -0
- package/e2e/tests/rtlTextPlugin.test.ts +3 -12
- package/e2e/tsconfig.json +1 -1
- package/eslint.config.mjs +8 -0
- package/package.json +11 -4
- package/playwright.config.ts +7 -2
- package/tsconfig.json +1 -1
- package/vitest-setup-tests.ts +16 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/rtlTextPlugin-active-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/rtlTextPlugin-disabled-chromium-linux.png +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyframeableGeoJSONFeature } from "../../../src";
|
|
2
|
+
|
|
3
|
+
type GeoJSON = {
|
|
4
|
+
type: "FeatureCollection";
|
|
5
|
+
features: KeyframeableGeoJSONFeature[];
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default async function fetchGeoJSON(assetUrl: string): Promise<GeoJSON> {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(assetUrl);
|
|
11
|
+
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new Error(`Failed to fetch GeoJSON: ${response.statusText}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const geojson = await response.json();
|
|
17
|
+
return geojson as GeoJSON;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw e;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Page, expect } from "@playwright/test";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { injectGlobalVariables } from "./injectGlobalVariables";
|
|
4
|
+
|
|
5
|
+
interface IgetMapInstanceForFixture {
|
|
6
|
+
fixture: string;
|
|
7
|
+
page: Page;
|
|
8
|
+
mockStyle?: boolean;
|
|
9
|
+
mockTiles?: boolean;
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default async function getMapInstanceForFixture({ fixture, page, mockStyle = true, mockTiles = true, debug = false, timeout = 10000 }: IgetMapInstanceForFixture) {
|
|
15
|
+
await injectGlobalVariables(page);
|
|
16
|
+
await page.addInitScript((plt) => {
|
|
17
|
+
window.__pageLoadTimeout = plt;
|
|
18
|
+
}, timeout);
|
|
19
|
+
|
|
20
|
+
if (mockStyle) {
|
|
21
|
+
// mock style response
|
|
22
|
+
await page.route("https://api.maptiler.com/maps/*/*.json*", async (route) => {
|
|
23
|
+
if (debug) console.info(`ℹ️ Style intercepted at ${route.request().url()}`);
|
|
24
|
+
await route.fulfill({
|
|
25
|
+
status: 200,
|
|
26
|
+
contentType: "application/json",
|
|
27
|
+
path: path.resolve(import.meta.dirname, "../mocks/maptiler-style.json"),
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (mockTiles) {
|
|
33
|
+
// mocks the tile response always returning the mock tile
|
|
34
|
+
await page.route("https://api.maptiler.com/tiles/*/*/*/*.jpg?key=*&*", (route) => {
|
|
35
|
+
if (debug) console.info(`ℹ️ Tile intercepted at ${route.request().url()}`);
|
|
36
|
+
return route.fulfill({
|
|
37
|
+
status: 200,
|
|
38
|
+
contentType: "image/png",
|
|
39
|
+
path: path.resolve(import.meta.dirname, "../mocks/tile.png"),
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
page.on("console", (msg) => {
|
|
45
|
+
console.log("FIXTURE LOG:", msg.text());
|
|
46
|
+
if (debug) {
|
|
47
|
+
console.log("DEBUG FIXTURE LOG:", msg.location(), msg.text());
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
page.addListener("requestfinished", async (request) => {
|
|
52
|
+
const response = await request.response();
|
|
53
|
+
if (response && response.status() >= 400) {
|
|
54
|
+
console.error(`\n\nFailed to load ${request.url()}\n status: ${response.status()}\n\n`);
|
|
55
|
+
expect(response.status()).toBeLessThan(400);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await page.goto(`http://localhost:5173/${fixture}.html`, {
|
|
60
|
+
waitUntil: "domcontentloaded",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const map = await page.evaluateHandle(() => {
|
|
65
|
+
return Promise.race([
|
|
66
|
+
new Promise(async (resolve) => {
|
|
67
|
+
console.log("Window.__map", window.__map);
|
|
68
|
+
window.__map.on("idle", () => {;
|
|
69
|
+
resolve(window.__map);
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
new Promise((_, reject) => {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
reject(new Error("Map did not load in time"));
|
|
75
|
+
}, window.__pageLoadTimeout);
|
|
76
|
+
}),
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
map,
|
|
82
|
+
};
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error(e);
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
import packagejson from "../../../package.json" assert { type: "json" };
|
|
3
|
+
|
|
4
|
+
export async function injectGlobalVariables(page: Page) {
|
|
5
|
+
console.log("injecting global variables");
|
|
6
|
+
await page.addInitScript(
|
|
7
|
+
({ version, nodeEnv }) => {
|
|
8
|
+
window.__MT_SDK_VERSION__ = version;
|
|
9
|
+
window.__MT_NODE_ENV__ = nodeEnv;
|
|
10
|
+
},
|
|
11
|
+
{ version: packagejson.version, nodeEnv: process.env.NODE_ENV },
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { Map } from "../../../src/index";
|
|
2
2
|
import { JSHandle, Page, expect } from "@playwright/test";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { injectGlobalVariables } from "./injectGlobalVariables";
|
|
4
5
|
|
|
5
|
-
interface
|
|
6
|
+
export interface LoadFixtureAndGetMapHandleOptions {
|
|
6
7
|
fixture: string;
|
|
7
8
|
page: Page;
|
|
8
|
-
mockStyle?: boolean;
|
|
9
|
-
mockTiles?: boolean;
|
|
9
|
+
mockStyle?: boolean | string;
|
|
10
|
+
mockTiles?: boolean | string;
|
|
10
11
|
debug?: boolean;
|
|
11
12
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
12
13
|
queryParams?: Record<string, string>;
|
|
14
|
+
lazy?: boolean;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export default async function loadFixtureAndGetMapHandle({
|
|
@@ -20,15 +22,18 @@ export default async function loadFixtureAndGetMapHandle({
|
|
|
20
22
|
debug = false,
|
|
21
23
|
waitUntil = "load",
|
|
22
24
|
queryParams,
|
|
23
|
-
|
|
25
|
+
lazy = false,
|
|
26
|
+
}: LoadFixtureAndGetMapHandleOptions): Promise<{ mapHandle: JSHandle<Map | null> | null }> {
|
|
27
|
+
await injectGlobalVariables(page);
|
|
24
28
|
if (mockStyle) {
|
|
25
29
|
// mock style response
|
|
26
30
|
await page.route("https://api.maptiler.com/maps/*/*.json*", async (route) => {
|
|
27
31
|
if (debug) console.info(`ℹ️ Style intercepted at ${route.request().url()}`);
|
|
32
|
+
const mockFileName = typeof mockStyle === "string" ? mockStyle : "maptiler-style.json";
|
|
28
33
|
await route.fulfill({
|
|
29
34
|
status: 200,
|
|
30
35
|
contentType: "application/json",
|
|
31
|
-
path: path.resolve(import.meta.dirname,
|
|
36
|
+
path: path.resolve(import.meta.dirname, `../mocks/${mockFileName}`),
|
|
32
37
|
});
|
|
33
38
|
});
|
|
34
39
|
}
|
|
@@ -46,7 +51,6 @@ export default async function loadFixtureAndGetMapHandle({
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
page.on("console", (msg) => {
|
|
49
|
-
console.log("FIXTURE LOG:", msg.text());
|
|
50
54
|
if (debug) {
|
|
51
55
|
console.log("DEBUG FIXTURE LOG:", msg.location(), msg.text());
|
|
52
56
|
}
|
|
@@ -64,36 +68,42 @@ export default async function loadFixtureAndGetMapHandle({
|
|
|
64
68
|
waitUntil,
|
|
65
69
|
});
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
if (!lazy) {
|
|
72
|
+
try {
|
|
73
|
+
const mapHandle = await page.evaluateHandle<Map | null>(() => {
|
|
74
|
+
return Promise.race<Map | null>([
|
|
75
|
+
new Promise<Map | null>(async (resolve) => {
|
|
76
|
+
try {
|
|
77
|
+
window.__map.on("idle", () => {
|
|
78
|
+
resolve(window.__map as Map);
|
|
79
|
+
});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error("Error getting map instance", e);
|
|
82
|
+
resolve(null);
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
new Promise<Map | null>((resolve) => {
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
console.error("Map did not load in time");
|
|
88
|
+
resolve(null);
|
|
89
|
+
}, 10000);
|
|
90
|
+
}),
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
return {
|
|
95
|
+
mapHandle,
|
|
96
|
+
};
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.error(e);
|
|
99
|
+
const nullMap = await page.evaluateHandle(() => null);
|
|
100
|
+
return {
|
|
101
|
+
mapHandle: nullMap as JSHandle<Map | null>,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
98
104
|
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
mapHandle: null,
|
|
108
|
+
};
|
|
99
109
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 8,
|
|
3
|
+
"sources": {
|
|
4
|
+
"raster": {
|
|
5
|
+
"type": "raster",
|
|
6
|
+
"tiles": [
|
|
7
|
+
"https://api.maptiler.com/tiles/satellite/{z}/{x}/{y}.jpg?key=DOESNT_MATTER"
|
|
8
|
+
],
|
|
9
|
+
"tileSize": 256
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"layers": [
|
|
13
|
+
{
|
|
14
|
+
"id": "raster",
|
|
15
|
+
"type": "raster",
|
|
16
|
+
"source": "raster",
|
|
17
|
+
"minzoom": 0,
|
|
18
|
+
"maxzoom": 22
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"projection": { "type": "globe" },
|
|
22
|
+
"metadata": {
|
|
23
|
+
"maptiler": {
|
|
24
|
+
"version": "1.0.0",
|
|
25
|
+
"attribution": "© MapTiler © OpenStreetMap contributors",
|
|
26
|
+
"halo": {
|
|
27
|
+
"scale": "letter",
|
|
28
|
+
"stops": {
|
|
29
|
+
"is": "an object"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"space": {
|
|
33
|
+
"color": [1234,1234],
|
|
34
|
+
"preset": 3
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 8,
|
|
3
|
+
"sources": {
|
|
4
|
+
"raster": {
|
|
5
|
+
"type": "raster",
|
|
6
|
+
"tiles": [
|
|
7
|
+
"https://api.maptiler.com/tiles/satellite/{z}/{x}/{y}.jpg?key=DOESNT_MATTER"
|
|
8
|
+
],
|
|
9
|
+
"tileSize": 256
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"layers": [
|
|
13
|
+
{
|
|
14
|
+
"id": "raster",
|
|
15
|
+
"type": "raster",
|
|
16
|
+
"source": "raster",
|
|
17
|
+
"minzoom": 0,
|
|
18
|
+
"maxzoom": 22
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"projection": { "type": "globe" },
|
|
22
|
+
"metadata": {
|
|
23
|
+
"maptiler": {
|
|
24
|
+
"version": "1.0.0",
|
|
25
|
+
"attribution": "© MapTiler © OpenStreetMap contributors",
|
|
26
|
+
"halo": {
|
|
27
|
+
"scale": 1.5,
|
|
28
|
+
"stops": [
|
|
29
|
+
[0.2, "transparent"],
|
|
30
|
+
[0.2, "red"],
|
|
31
|
+
[0.4, "red"],
|
|
32
|
+
[0.4, "transparent"]
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"space": {
|
|
36
|
+
"color": "green",
|
|
37
|
+
"preset": "space"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { expect, test } from "@playwright/test";
|
|
2
|
-
import path from "path";
|
|
3
2
|
import loadFixtureAndGetMapHandle from "./helpers/loadFixtureAndGetMapHandle";
|
|
4
3
|
|
|
5
4
|
test("Renders RTL text correctly when RTL plugin is enabled and incorrectly when disabled", async ({ page }) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
await
|
|
9
|
-
status: 200,
|
|
10
|
-
contentType: "application/json",
|
|
11
|
-
path: path.resolve(import.meta.dirname, "./mocks/rtl-tiles-json.json"),
|
|
12
|
-
});
|
|
5
|
+
await page.exposeFunction("notifyScreenshotStateReady", async (data: Record<string, TTestTransferData>) => {
|
|
6
|
+
const screenshotname = data.disabled ? "rtlTextPlugin-disabled.png" : "rtlTextPlugin-enabled.png";
|
|
7
|
+
await expect(page).toHaveScreenshot(screenshotname);
|
|
13
8
|
});
|
|
14
9
|
|
|
15
10
|
await loadFixtureAndGetMapHandle({
|
|
@@ -19,13 +14,9 @@ test("Renders RTL text correctly when RTL plugin is enabled and incorrectly when
|
|
|
19
14
|
|
|
20
15
|
expect(await page.title()).toBe("MapTiler E2E RTL Text Plugin");
|
|
21
16
|
|
|
22
|
-
await expect(page).toHaveScreenshot("rtlTextPlugin-active.png");
|
|
23
|
-
|
|
24
17
|
await loadFixtureAndGetMapHandle({
|
|
25
18
|
fixture: "rtlTextPlugin",
|
|
26
19
|
page,
|
|
27
20
|
queryParams: { "disable-rtl": "true" },
|
|
28
21
|
});
|
|
29
|
-
|
|
30
|
-
await expect(page).toHaveScreenshot("rtlTextPlugin-disabled.png");
|
|
31
22
|
});
|
package/e2e/tsconfig.json
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import tseslint from "typescript-eslint";
|
|
4
4
|
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
+
import eslintPluginCompat from "eslint-plugin-compat";
|
|
5
6
|
|
|
6
7
|
export default tseslint.config(
|
|
7
8
|
// https://typescript-eslint.io/getting-started/typed-linting/
|
|
@@ -11,6 +12,7 @@ export default tseslint.config(
|
|
|
11
12
|
{
|
|
12
13
|
// forked from https://www.npmjs.com/package/eslint-plugin-restrict-imports
|
|
13
14
|
plugins: {
|
|
15
|
+
compat: eslintPluginCompat,
|
|
14
16
|
import: {
|
|
15
17
|
rules: {
|
|
16
18
|
"default-imports-only": {
|
|
@@ -67,7 +69,12 @@ export default tseslint.config(
|
|
|
67
69
|
},
|
|
68
70
|
},
|
|
69
71
|
},
|
|
72
|
+
settings: {
|
|
73
|
+
// eslint-plugin-compat polyfill
|
|
74
|
+
polyfills: ["requestIdleCallback"],
|
|
75
|
+
},
|
|
70
76
|
rules: {
|
|
77
|
+
"compat/compat": "error",
|
|
71
78
|
"import/default-imports-only": [
|
|
72
79
|
"error",
|
|
73
80
|
{
|
|
@@ -127,6 +134,7 @@ export default tseslint.config(
|
|
|
127
134
|
"@typescript-eslint/related-getter-setter-pairs": "off",
|
|
128
135
|
"@typescript-eslint/unbound-method": "warn",
|
|
129
136
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "warn",
|
|
137
|
+
"@typescript-eslint/unified-signatures": ["error", { ignoreOverloadsWithDifferentJSDoc: true }],
|
|
130
138
|
},
|
|
131
139
|
},
|
|
132
140
|
//
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0-rc.1",
|
|
4
4
|
"description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
|
|
5
5
|
"author": "MapTiler",
|
|
6
6
|
"module": "dist/maptiler-sdk.mjs",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"import": "./dist/maptiler-sdk.css"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
+
"browserslist": [
|
|
24
|
+
"defaults",
|
|
25
|
+
"not op_mini all"
|
|
26
|
+
],
|
|
23
27
|
"keywords": [
|
|
24
28
|
"maptiler",
|
|
25
29
|
"map",
|
|
@@ -65,6 +69,7 @@
|
|
|
65
69
|
"devDependencies": {
|
|
66
70
|
"@canvas/image-data": "^1.0.0",
|
|
67
71
|
"@eslint/js": "^9.21.0",
|
|
72
|
+
"@maptiler/3d": "^3.1.0",
|
|
68
73
|
"@playwright/test": "^1.51.0",
|
|
69
74
|
"@types/color-convert": "^2.0.4",
|
|
70
75
|
"@types/color-name": "^2.0.0",
|
|
@@ -92,12 +97,14 @@
|
|
|
92
97
|
"vitest": "^3.0.9"
|
|
93
98
|
},
|
|
94
99
|
"dependencies": {
|
|
95
|
-
"@maplibre/maplibre-gl-style-spec": "~24.
|
|
96
|
-
"@maptiler/client": "
|
|
100
|
+
"@maplibre/maplibre-gl-style-spec": "~24.4.1",
|
|
101
|
+
"@maptiler/client": "2.7.0-rc.1",
|
|
102
|
+
"eslint-plugin-compat": "^6.1.0",
|
|
97
103
|
"events": "^3.3.0",
|
|
98
104
|
"gl-matrix": "^3.4.4",
|
|
99
105
|
"js-base64": "^3.7.7",
|
|
100
|
-
"maplibre-gl": "~5.
|
|
106
|
+
"maplibre-gl": "~5.16.0",
|
|
107
|
+
"requestidlecallback-polyfill": "^1.0.2",
|
|
101
108
|
"uuid": "^11.0.5"
|
|
102
109
|
}
|
|
103
110
|
}
|
package/playwright.config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
-
|
|
2
|
+
import packagejson from './package.json' assert { type: 'json' };
|
|
3
3
|
/**
|
|
4
4
|
* Read environment variables from file.
|
|
5
5
|
* https://github.com/motdotla/dotenv
|
|
@@ -33,8 +33,13 @@ export default defineConfig({
|
|
|
33
33
|
|
|
34
34
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
35
35
|
trace: 'on-first-retry',
|
|
36
|
+
launchOptions: {
|
|
37
|
+
env: {
|
|
38
|
+
__MT_SDK_VERSION__: packagejson.version,
|
|
39
|
+
__MT_NODE_ENV__: process.env.NODE_ENV,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
36
42
|
},
|
|
37
|
-
|
|
38
43
|
snapshotDir: './e2e/snapshots',
|
|
39
44
|
/* Configure projects for major browsers */
|
|
40
45
|
projects: [
|
package/tsconfig.json
CHANGED
package/vitest-setup-tests.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import { expect } from "vitest";
|
|
1
2
|
import ImageData from "@canvas/image-data";
|
|
2
3
|
// @ts-expect-error: Global type missing
|
|
3
4
|
global.ImageData = ImageData;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// this is to prevent tests failing because of floating point differences
|
|
8
|
+
// between different CI and local
|
|
9
|
+
expect.addSnapshotSerializer({
|
|
10
|
+
serialize(val, config, indentation, depth, refs, printer) {
|
|
11
|
+
if (typeof val === 'number') {
|
|
12
|
+
return val.toFixed(10)
|
|
13
|
+
}
|
|
14
|
+
return printer(val, config, indentation, depth, refs)
|
|
15
|
+
},
|
|
16
|
+
test(val) {
|
|
17
|
+
return typeof val === 'number'
|
|
18
|
+
},
|
|
19
|
+
})
|