vease 1.59.0-rc.9 → 1.59.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.
- package/.build/tests/e2e/utils/clipping_planes_interaction.js +8 -1
- package/.build/tests/e2e/utils/fixtures.js +1 -4
- package/.build/tests/e2e/utils/viewer_canvas.js +5 -1
- package/.build/tests/e2e/utils/viewer_interaction.js +2 -2
- package/package.json +7 -7
- package/tests/e2e/utils/clipping_planes_interaction.ts +14 -0
- package/tests/e2e/utils/fixtures.ts +0 -4
- package/tests/e2e/utils/viewer_canvas.ts +8 -0
- package/tests/e2e/utils/viewer_interaction.ts +1 -0
- package/vease_schemas.json +68 -0
- package/vease_typed_schemas.d.ts +26 -0
- package/.build/tests/e2e/utils/basemap_tile_server.js +0 -42
- package/.build/tests/e2e/utils/basemap_tiles/route.png +0 -0
- package/.build/tests/e2e/utils/basemap_tiles/tile.png +0 -0
- package/tests/e2e/utils/basemap_tile_server.ts +0 -56
- package/tests/e2e/utils/basemap_tiles/route.png +0 -0
- package/tests/e2e/utils/basemap_tiles/tile.png +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { waitForActionSettled } from "./wait_for_action_settled.js";
|
|
2
2
|
//#region tests/e2e/utils/clipping_planes_interaction.ts
|
|
3
|
+
const OPACITY_SLIDER_STEP = .05;
|
|
3
4
|
async function toggleClippingPlanes(window) {
|
|
4
5
|
await window.getByTestId("clippingPlanesButton").click();
|
|
5
6
|
await waitForActionSettled(window);
|
|
@@ -26,6 +27,12 @@ async function setPlaneNormal(window, planeIndex, normal) {
|
|
|
26
27
|
}
|
|
27
28
|
await waitForActionSettled(window);
|
|
28
29
|
}
|
|
30
|
+
async function setPlaneOpacity(window, planeIndex, opacity) {
|
|
31
|
+
await window.getByTestId("planeCard").nth(planeIndex).getByTestId("planeOpacitySlider").getByRole("slider").focus();
|
|
32
|
+
await window.keyboard.press("Home");
|
|
33
|
+
for (let step = 0; step < Math.round(opacity / OPACITY_SLIDER_STEP); step += 1) await window.keyboard.press("ArrowRight");
|
|
34
|
+
await waitForActionSettled(window);
|
|
35
|
+
}
|
|
29
36
|
async function addClippingPlane(window) {
|
|
30
37
|
await window.getByTestId("addPlaneButton").click();
|
|
31
38
|
await waitForActionSettled(window);
|
|
@@ -69,4 +76,4 @@ async function setSliceIndex(window, index, sliceIndex = 0) {
|
|
|
69
76
|
await waitForActionSettled(window);
|
|
70
77
|
}
|
|
71
78
|
//#endregion
|
|
72
|
-
export { addClippingPlane, addSlice, invertPlaneNormal, removeClippingPlanes, resetClippingPlanes, selectClippingDatasets, setPlaneNormal, setPlaneOrigin, setSliceAxis, setSliceIndex, toggleClippingPlanes, toggleSlice, toggleTargetAllVisible };
|
|
79
|
+
export { addClippingPlane, addSlice, invertPlaneNormal, removeClippingPlanes, resetClippingPlanes, selectClippingDatasets, setPlaneNormal, setPlaneOpacity, setPlaneOrigin, setSliceAxis, setSliceIndex, toggleClippingPlanes, toggleSlice, toggleTargetAllVisible };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { waitForActionSettled } from "./wait_for_action_settled.js";
|
|
2
|
-
import { startTileServer } from "./basemap_tile_server.js";
|
|
3
2
|
import { navigateToApp } from "./navigate.js";
|
|
4
3
|
import { expect, test as test$1 } from "@playwright/test";
|
|
5
4
|
import { consola } from "consola";
|
|
6
5
|
import fs from "node:fs";
|
|
7
|
-
import os from "node:os";
|
|
8
6
|
import path from "node:path";
|
|
7
|
+
import os from "node:os";
|
|
9
8
|
//#region tests/e2e/utils/fixtures.ts
|
|
10
9
|
const MILLISECONDS_PER_SECOND = 1e3;
|
|
11
10
|
const test = test$1.extend({
|
|
@@ -24,7 +23,6 @@ const test = test$1.extend({
|
|
|
24
23
|
const configPath = fs.mkdtempSync(path.join(os.tmpdir(), `vease-e2e-worker${workerInfo.parallelIndex}-`));
|
|
25
24
|
process.env.XDG_CONFIG_HOME = configPath;
|
|
26
25
|
process.env.APPDATA = configPath;
|
|
27
|
-
const tileServer = await startTileServer();
|
|
28
26
|
async function launchBrowser() {
|
|
29
27
|
return await playwright[browserName].launch({
|
|
30
28
|
...launchOptions,
|
|
@@ -45,7 +43,6 @@ const test = test$1.extend({
|
|
|
45
43
|
};
|
|
46
44
|
await use(app);
|
|
47
45
|
await app.cleanup();
|
|
48
|
-
await tileServer.stop();
|
|
49
46
|
fs.rmSync(configPath, {
|
|
50
47
|
recursive: true,
|
|
51
48
|
force: true
|
|
@@ -18,6 +18,10 @@ async function viewerContextMenu(window, x, y) {
|
|
|
18
18
|
});
|
|
19
19
|
await waitForActionSettled(window);
|
|
20
20
|
}
|
|
21
|
+
const SCENE_CLICK_MARGIN = 20;
|
|
22
|
+
async function sceneContextMenu(window) {
|
|
23
|
+
await viewerContextMenu(window, (await getHybridViewerCanvasBoundingBox(getHybridViewerCanvas(window))).width - SCENE_CLICK_MARGIN, SCENE_CLICK_MARGIN);
|
|
24
|
+
}
|
|
21
25
|
async function dragElement(window, locator, { startX: fromX, startY: fromY, targetX, targetY, deltaX = 0, deltaY = 0 } = {}) {
|
|
22
26
|
const box = await locator.boundingBox();
|
|
23
27
|
if (!box) throw new Error("Could not get bounding box of the element to drag.");
|
|
@@ -76,4 +80,4 @@ async function viewerQuickColormap(window, x, y) {
|
|
|
76
80
|
await waitForActionSettled(window);
|
|
77
81
|
}
|
|
78
82
|
//#endregion
|
|
79
|
-
export { dragContextMenu, dragElement, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap };
|
|
83
|
+
export { dragContextMenu, dragElement, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, sceneContextMenu, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterActionWait } from "./constants.js";
|
|
2
2
|
import { waitForActionSettled } from "./wait_for_action_settled.js";
|
|
3
3
|
import { closeFeedbackSnackbar, moveMouseOutOfTheWay } from "./app_interaction.js";
|
|
4
|
-
import { dragContextMenu, dragElement, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap } from "./viewer_canvas.js";
|
|
4
|
+
import { dragContextMenu, dragElement, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, sceneContextMenu, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap } from "./viewer_canvas.js";
|
|
5
5
|
import { ensureFeatureVisible, ensureMenuOpen, openStyleMenu, resetMenuScroll, setCellsVisibility, setEdgesVisibility, setEdgesWidth, setPointsSize, setPointsVisibility, setPolygonsVisibility, setPolyhedraVisibility, setVisibilityGeneric } from "./viewer_menu.js";
|
|
6
6
|
//#region tests/e2e/utils/viewer_interaction.ts
|
|
7
7
|
function noopCleanup() {}
|
|
@@ -84,4 +84,4 @@ async function findOverlappingObjectsPicker(window) {
|
|
|
84
84
|
if (!found) throw new Error("Could not find overlapping objects picker anywhere! The test data might not be loaded or the picker is broken.");
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
|
-
export { afterActionWait, closeFeedbackSnackbar, dragContextMenu, dragElement, ensureFeatureVisible, ensureMenuOpen, findOverlappingObjectsPicker, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, moveMouseOutOfTheWay, noopCleanup, openStyleMenu, resetMenuScroll, setCellsVisibility, setEdgesVisibility, setEdgesWidth, setPointsSize, setPointsVisibility, setPolygonsVisibility, setPolyhedraVisibility, setVisibilityGeneric, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap };
|
|
87
|
+
export { afterActionWait, closeFeedbackSnackbar, dragContextMenu, dragElement, ensureFeatureVisible, ensureMenuOpen, findOverlappingObjectsPicker, getHybridViewerCanvas, getHybridViewerCanvasBoundingBox, getQuickColormapPicker, hoverViewer, moveMouseOutOfTheWay, noopCleanup, openStyleMenu, resetMenuScroll, sceneContextMenu, setCellsVisibility, setEdgesVisibility, setEdgesWidth, setPointsSize, setPointsVisibility, setPolygonsVisibility, setPolyhedraVisibility, setVisibilityGeneric, stabilizeHoverTooltip, toggleInfoCard, viewerContextMenu, viewerQuickColormap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vease",
|
|
3
|
-
"version": "1.59.0
|
|
3
|
+
"version": "1.59.0",
|
|
4
4
|
"description": "Desktop and cloud software for data visualization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Desktop",
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"@ai-sdk/vue": "4.0.93",
|
|
91
91
|
"@fontsource/michroma": "5.2.6",
|
|
92
92
|
"@fontsource/roboto": "5.2.10",
|
|
93
|
-
"@geode/cloud-api": "
|
|
94
|
-
"@geode/opengeodeweb-back": "
|
|
95
|
-
"@geode/opengeodeweb-front": "
|
|
96
|
-
"@geode/opengeodeweb-viewer": "
|
|
97
|
-
"@geode/vease-back": "
|
|
98
|
-
"@geode/vease-viewer": "
|
|
93
|
+
"@geode/cloud-api": "latest",
|
|
94
|
+
"@geode/opengeodeweb-back": "latest",
|
|
95
|
+
"@geode/opengeodeweb-front": "latest",
|
|
96
|
+
"@geode/opengeodeweb-viewer": "latest",
|
|
97
|
+
"@geode/vease-back": "latest",
|
|
98
|
+
"@geode/vease-viewer": "latest",
|
|
99
99
|
"@nuxtjs/mcp-toolkit": "0.18.1",
|
|
100
100
|
"ai": "7.0.93",
|
|
101
101
|
"bowser": "2.14.1",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Page } from "@playwright/test";
|
|
2
2
|
import { waitForActionSettled } from "./wait_for_action_settled";
|
|
3
3
|
|
|
4
|
+
const OPACITY_SLIDER_STEP = 0.05;
|
|
5
|
+
|
|
4
6
|
async function toggleClippingPlanes(window: Page): Promise<void> {
|
|
5
7
|
await window.getByTestId("clippingPlanesButton").click();
|
|
6
8
|
await waitForActionSettled(window);
|
|
@@ -33,6 +35,17 @@ async function setPlaneNormal(window: Page, planeIndex: number, normal: number[]
|
|
|
33
35
|
await waitForActionSettled(window);
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
async function setPlaneOpacity(window: Page, planeIndex: number, opacity: number): Promise<void> {
|
|
39
|
+
const card = window.getByTestId("planeCard").nth(planeIndex);
|
|
40
|
+
await card.getByTestId("planeOpacitySlider").getByRole("slider").focus();
|
|
41
|
+
await window.keyboard.press("Home");
|
|
42
|
+
for (let step = 0; step < Math.round(opacity / OPACITY_SLIDER_STEP); step += 1) {
|
|
43
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
44
|
+
await window.keyboard.press("ArrowRight");
|
|
45
|
+
}
|
|
46
|
+
await waitForActionSettled(window);
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
async function addClippingPlane(window: Page): Promise<void> {
|
|
37
50
|
await window.getByTestId("addPlaneButton").click();
|
|
38
51
|
await waitForActionSettled(window);
|
|
@@ -94,6 +107,7 @@ export {
|
|
|
94
107
|
invertPlaneNormal,
|
|
95
108
|
setPlaneOrigin,
|
|
96
109
|
setPlaneNormal,
|
|
110
|
+
setPlaneOpacity,
|
|
97
111
|
addClippingPlane,
|
|
98
112
|
removeClippingPlanes,
|
|
99
113
|
resetClippingPlanes,
|
|
@@ -12,7 +12,6 @@ import { consola } from "consola";
|
|
|
12
12
|
|
|
13
13
|
// Local imports
|
|
14
14
|
import { navigateToApp } from "./navigate";
|
|
15
|
-
import { startTileServer } from "./basemap_tile_server";
|
|
16
15
|
import { waitForActionSettled } from "./wait_for_action_settled";
|
|
17
16
|
|
|
18
17
|
const MILLISECONDS_PER_SECOND = 1000;
|
|
@@ -69,8 +68,6 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
|
|
|
69
68
|
);
|
|
70
69
|
process.env.XDG_CONFIG_HOME = configPath;
|
|
71
70
|
process.env.APPDATA = configPath;
|
|
72
|
-
// Before the app starts: any spec giving the project a CRS builds a basemap, from local tiles
|
|
73
|
-
const tileServer = await startTileServer();
|
|
74
71
|
// Launched on demand instead of using the browser fixture, which would start (and require installing) a browser in DESKTOP mode too
|
|
75
72
|
async function launchBrowser(): Promise<Browser> {
|
|
76
73
|
const browser = await playwright[browserName].launch({
|
|
@@ -93,7 +90,6 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
|
|
|
93
90
|
};
|
|
94
91
|
await use(app);
|
|
95
92
|
await app.cleanup();
|
|
96
|
-
await tileServer.stop();
|
|
97
93
|
fs.rmSync(configPath, { recursive: true, force: true });
|
|
98
94
|
},
|
|
99
95
|
{ scope: "worker" },
|
|
@@ -27,6 +27,13 @@ async function viewerContextMenu(window: Page, x: number, y: number): Promise<vo
|
|
|
27
27
|
await waitForActionSettled(window);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const SCENE_CLICK_MARGIN = 20;
|
|
31
|
+
|
|
32
|
+
async function sceneContextMenu(window: Page): Promise<void> {
|
|
33
|
+
const box = await getHybridViewerCanvasBoundingBox(getHybridViewerCanvas(window));
|
|
34
|
+
await viewerContextMenu(window, box.width - SCENE_CLICK_MARGIN, SCENE_CLICK_MARGIN);
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
interface DragOptions {
|
|
31
38
|
startX?: number;
|
|
32
39
|
startY?: number;
|
|
@@ -121,6 +128,7 @@ export {
|
|
|
121
128
|
getHybridViewerCanvasBoundingBox,
|
|
122
129
|
getQuickColormapPicker,
|
|
123
130
|
hoverViewer,
|
|
131
|
+
sceneContextMenu,
|
|
124
132
|
stabilizeHoverTooltip,
|
|
125
133
|
toggleInfoCard,
|
|
126
134
|
viewerContextMenu,
|
package/vease_schemas.json
CHANGED
|
@@ -596,6 +596,74 @@
|
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
},
|
|
599
|
+
"horizon_stack": {
|
|
600
|
+
"info": {
|
|
601
|
+
"$id": "api/controller/horizon_stack/info",
|
|
602
|
+
"route": "/info",
|
|
603
|
+
"methods": ["GET"],
|
|
604
|
+
"type": "object",
|
|
605
|
+
"properties": {
|
|
606
|
+
"id": {
|
|
607
|
+
"type": "string",
|
|
608
|
+
"minLength": 32,
|
|
609
|
+
"maxLength": 32
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
"required": ["id"],
|
|
613
|
+
"additionalProperties": false,
|
|
614
|
+
"response": {
|
|
615
|
+
"type": "object",
|
|
616
|
+
"properties": {
|
|
617
|
+
"statusCode": {
|
|
618
|
+
"type": "integer"
|
|
619
|
+
},
|
|
620
|
+
"response": {}
|
|
621
|
+
},
|
|
622
|
+
"required": ["statusCode", "response"],
|
|
623
|
+
"additionalProperties": false
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
"create": {
|
|
627
|
+
"$id": "api/controller/horizon_stack/create",
|
|
628
|
+
"route": "/create",
|
|
629
|
+
"methods": ["POST"],
|
|
630
|
+
"type": "object",
|
|
631
|
+
"properties": {
|
|
632
|
+
"name": {
|
|
633
|
+
"type": "string",
|
|
634
|
+
"minLength": 1
|
|
635
|
+
},
|
|
636
|
+
"horizons": {
|
|
637
|
+
"type": "array",
|
|
638
|
+
"items": {
|
|
639
|
+
"type": "string",
|
|
640
|
+
"minLength": 1
|
|
641
|
+
},
|
|
642
|
+
"minItems": 1,
|
|
643
|
+
"uniqueItems": true
|
|
644
|
+
},
|
|
645
|
+
"unit_names": {
|
|
646
|
+
"type": "array",
|
|
647
|
+
"items": {
|
|
648
|
+
"type": "string"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
"required": ["name", "horizons"],
|
|
653
|
+
"additionalProperties": false,
|
|
654
|
+
"response": {
|
|
655
|
+
"type": "object",
|
|
656
|
+
"properties": {
|
|
657
|
+
"statusCode": {
|
|
658
|
+
"type": "integer"
|
|
659
|
+
},
|
|
660
|
+
"response": {}
|
|
661
|
+
},
|
|
662
|
+
"required": ["statusCode", "response"],
|
|
663
|
+
"additionalProperties": false
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
},
|
|
599
667
|
"colormaps": {
|
|
600
668
|
"$id": "api/controller/colormaps",
|
|
601
669
|
"route": "/colormaps",
|
package/vease_typed_schemas.d.ts
CHANGED
|
@@ -196,6 +196,26 @@ export interface ControllerFilterClipResponse {
|
|
|
196
196
|
statusCode: number;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
export interface ControllerHorizonStackInfoParams {
|
|
200
|
+
id: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface ControllerHorizonStackInfoResponse {
|
|
204
|
+
response: any;
|
|
205
|
+
statusCode: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface ControllerHorizonStackCreateParams {
|
|
209
|
+
horizons: string[];
|
|
210
|
+
name: string;
|
|
211
|
+
unit_names?: string[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface ControllerHorizonStackCreateResponse {
|
|
215
|
+
response: any;
|
|
216
|
+
statusCode: number;
|
|
217
|
+
}
|
|
218
|
+
|
|
199
219
|
export interface ControllerColormapsParams {}
|
|
200
220
|
|
|
201
221
|
export interface ControllerColormapsResponse {
|
|
@@ -962,6 +982,12 @@ export interface Schemas {
|
|
|
962
982
|
readonly clip: (typeof json)["api"]["controller"]["filter"]["clip"] &
|
|
963
983
|
TypedSchema<ControllerFilterClipParams, ControllerFilterClipResponse>;
|
|
964
984
|
};
|
|
985
|
+
readonly horizon_stack: {
|
|
986
|
+
readonly info: (typeof json)["api"]["controller"]["horizon_stack"]["info"] &
|
|
987
|
+
TypedSchema<ControllerHorizonStackInfoParams, ControllerHorizonStackInfoResponse>;
|
|
988
|
+
readonly create: (typeof json)["api"]["controller"]["horizon_stack"]["create"] &
|
|
989
|
+
TypedSchema<ControllerHorizonStackCreateParams, ControllerHorizonStackCreateResponse>;
|
|
990
|
+
};
|
|
965
991
|
readonly colormaps: (typeof json)["api"]["controller"]["colormaps"] &
|
|
966
992
|
TypedSchema<ControllerColormapsParams, ControllerColormapsResponse>;
|
|
967
993
|
readonly style: {
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import http from "node:http";
|
|
3
|
-
import { once } from "node:events";
|
|
4
|
-
import os from "node:os";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
//#region tests/e2e/utils/basemap_tile_server.ts
|
|
7
|
-
const ROUTE_PATH = "/ign_roads/";
|
|
8
|
-
const HTTP_OK = 200;
|
|
9
|
-
const TILES_FOLDER = path.join(import.meta.dirname, "basemap_tiles");
|
|
10
|
-
async function startTileServer() {
|
|
11
|
-
const tile = fs.readFileSync(path.join(TILES_FOLDER, "tile.png"));
|
|
12
|
-
const routeTile = fs.readFileSync(path.join(TILES_FOLDER, "route.png"));
|
|
13
|
-
const server = http.createServer((request, response) => {
|
|
14
|
-
const body = (request.url ?? "").toLowerCase().startsWith(ROUTE_PATH) ? routeTile : tile;
|
|
15
|
-
response.writeHead(HTTP_OK, {
|
|
16
|
-
"Content-Type": "image/png",
|
|
17
|
-
"Content-Length": body.length
|
|
18
|
-
});
|
|
19
|
-
response.end(body);
|
|
20
|
-
});
|
|
21
|
-
server.listen(0, "127.0.0.1");
|
|
22
|
-
await once(server, "listening");
|
|
23
|
-
const address = server.address();
|
|
24
|
-
if (typeof address !== "object" || address === null) throw new Error("Tile server has no TCP address");
|
|
25
|
-
const { port } = address;
|
|
26
|
-
const cacheFolder = fs.mkdtempSync(path.join(os.tmpdir(), "vease-e2e-basemap-cache-"));
|
|
27
|
-
process.env.BASEMAP_TILE_URL = `http://127.0.0.1:${port}/{source}/{z}/{x}/{y}.png`;
|
|
28
|
-
process.env.BASEMAP_CACHE_FOLDER = cacheFolder;
|
|
29
|
-
return { stop: async () => {
|
|
30
|
-
delete process.env.BASEMAP_TILE_URL;
|
|
31
|
-
delete process.env.BASEMAP_CACHE_FOLDER;
|
|
32
|
-
server.closeAllConnections();
|
|
33
|
-
server.close();
|
|
34
|
-
await once(server, "close");
|
|
35
|
-
fs.rmSync(cacheFolder, {
|
|
36
|
-
recursive: true,
|
|
37
|
-
force: true
|
|
38
|
-
});
|
|
39
|
-
} };
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
export { startTileServer };
|
|
Binary file
|
|
Binary file
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Node imports
|
|
2
|
-
import type { AddressInfo } from "node:net";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import http from "node:http";
|
|
5
|
-
import { once } from "node:events";
|
|
6
|
-
import os from "node:os";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
|
|
9
|
-
// The first served routes source wins: the IGN roads, transparent, stand for every routes source
|
|
10
|
-
const ROUTE_PATH = "/ign_roads/";
|
|
11
|
-
const HTTP_OK = 200;
|
|
12
|
-
// Next to this file in the sources and in the build: the package ships the utils only
|
|
13
|
-
const TILES_FOLDER = path.join(import.meta.dirname, "basemap_tiles");
|
|
14
|
-
|
|
15
|
-
interface TileServer {
|
|
16
|
-
stop: () => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Serves the checkerboard tile for any /{source}/{z}/{x}/{y}.png request, a red diagonal for the roads:
|
|
20
|
-
// The tests never reach EOX, the IGN or OpenStreetMap. The env variables are inherited by the app
|
|
21
|
-
// (Nitro server or Electron process), then by vease-back, so they must be set before the app starts
|
|
22
|
-
async function startTileServer(): Promise<TileServer> {
|
|
23
|
-
const tile = fs.readFileSync(path.join(TILES_FOLDER, "tile.png"));
|
|
24
|
-
const routeTile = fs.readFileSync(path.join(TILES_FOLDER, "route.png"));
|
|
25
|
-
const server = http.createServer((request, response) => {
|
|
26
|
-
// Transparent roads: stacked on the satellite map, they must not hide it
|
|
27
|
-
const isRoute = (request.url ?? "").toLowerCase().startsWith(ROUTE_PATH);
|
|
28
|
-
const body = isRoute ? routeTile : tile;
|
|
29
|
-
response.writeHead(HTTP_OK, { "Content-Type": "image/png", "Content-Length": body.length });
|
|
30
|
-
response.end(body);
|
|
31
|
-
});
|
|
32
|
-
server.listen(0, "127.0.0.1");
|
|
33
|
-
await once(server, "listening");
|
|
34
|
-
const address = server.address();
|
|
35
|
-
if (typeof address !== "object" || address === null) {
|
|
36
|
-
throw new Error("Tile server has no TCP address");
|
|
37
|
-
}
|
|
38
|
-
const { port }: AddressInfo = address;
|
|
39
|
-
const cacheFolder = fs.mkdtempSync(path.join(os.tmpdir(), "vease-e2e-basemap-cache-"));
|
|
40
|
-
// One template for every source: the back fills {source} with the source key
|
|
41
|
-
process.env.BASEMAP_TILE_URL = `http://127.0.0.1:${port}/{source}/{z}/{x}/{y}.png`;
|
|
42
|
-
process.env.BASEMAP_CACHE_FOLDER = cacheFolder;
|
|
43
|
-
return {
|
|
44
|
-
stop: async (): Promise<void> => {
|
|
45
|
-
delete process.env.BASEMAP_TILE_URL;
|
|
46
|
-
delete process.env.BASEMAP_CACHE_FOLDER;
|
|
47
|
-
server.closeAllConnections();
|
|
48
|
-
server.close();
|
|
49
|
-
await once(server, "close");
|
|
50
|
-
fs.rmSync(cacheFolder, { recursive: true, force: true });
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type { TileServer };
|
|
56
|
-
export { startTileServer };
|
|
Binary file
|
|
Binary file
|