@geode/opengeodeweb-front 10.36.0-rc.2 → 10.36.0-rc.4
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/opengeodeweb_front_schemas.js +2 -1
- package/.build/server/utils/microservices.js +44 -2
- package/.build/server/utils/path.js +4 -1
- package/.build/server/utils/server_config.js +11 -1
- package/app/components/ClippingPlanes.vue +186 -38
- package/app/components/SliceCard.vue +79 -0
- package/app/composables/clipping_planes_widget_entries.ts +1 -0
- package/app/stores/app_helpers/extension.ts +5 -1
- package/app/utils/extension.ts +7 -2
- package/app/utils/import_workflow.ts +7 -1
- package/app/utils/slice.ts +24 -0
- package/internal/stores/hybrid_viewer/filters.ts +25 -0
- package/opengeodeweb_front_schemas.json +3 -0
- package/opengeodeweb_front_typed_schemas.d.ts +1 -0
- package/package.json +1 -1
- package/server/api/local/extensions/run.post.ts +46 -27
- package/server/api/local/extensions/schemas/run.json +3 -0
- package/server/utils/extension.ts +5 -0
- package/server/utils/microservices.ts +53 -2
- package/server/utils/path.ts +4 -0
- package/server/utils/server_config.ts +14 -0
|
@@ -181,7 +181,8 @@ var api = {
|
|
|
181
181
|
"name": { "type": "string" },
|
|
182
182
|
"version": { "type": "string" },
|
|
183
183
|
"frontendContent": { "type": "string" },
|
|
184
|
-
"port": { "type": "integer" }
|
|
184
|
+
"port": { "type": "integer" },
|
|
185
|
+
"serverPort": { "type": "integer" }
|
|
185
186
|
},
|
|
186
187
|
"required": [
|
|
187
188
|
"id",
|
|
@@ -9,9 +9,10 @@ import child_process from "node:child_process";
|
|
|
9
9
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" };
|
|
10
10
|
//#region server/utils/microservices.ts
|
|
11
11
|
const MILLISECONDS_PER_SECOND = 1e3;
|
|
12
|
-
const DEFAULT_TIMEOUT_SECONDS =
|
|
12
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
13
13
|
const MAX_PORT_RETRIES = 1;
|
|
14
14
|
const DEFAULT_RUN_ARGS = { projectFolderPath: "" };
|
|
15
|
+
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
15
16
|
async function runScript(execPath, execName, args, expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
|
|
16
17
|
const command = executablePath(execPath, execName);
|
|
17
18
|
consola.debug("runScript", command, args);
|
|
@@ -132,6 +133,47 @@ async function runExtension(extensionId, execName, execPath, args = DEFAULT_RUN_
|
|
|
132
133
|
}
|
|
133
134
|
throw new Error(`runExtension failed to run ${extensionId}`);
|
|
134
135
|
}
|
|
136
|
+
async function waitUntilListening(child) {
|
|
137
|
+
child.stderr.on("data", (data) => {
|
|
138
|
+
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
139
|
+
});
|
|
140
|
+
child.on("close", (code) => {
|
|
141
|
+
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
142
|
+
});
|
|
143
|
+
for await (const chunk of child.stdout) {
|
|
144
|
+
const output = String(chunk);
|
|
145
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
146
|
+
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
147
|
+
child.stdout.on("data", (data) => {
|
|
148
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
154
|
+
}
|
|
155
|
+
async function runExtensionServer(entryPath, attempts = 0) {
|
|
156
|
+
let port = void 0;
|
|
157
|
+
try {
|
|
158
|
+
port = await getAvailablePort();
|
|
159
|
+
consola.info("runExtensionServer", entryPath, port);
|
|
160
|
+
await waitUntilListening(child_process.spawn("node", [entryPath], { env: {
|
|
161
|
+
...process.env,
|
|
162
|
+
PORT: String(port)
|
|
163
|
+
} }));
|
|
164
|
+
return port;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (!isPortInUseError(error)) {
|
|
167
|
+
consola.error("runExtensionServer error", error);
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
if (attempts <= MAX_PORT_RETRIES) {
|
|
171
|
+
consola.warn("Retrying runExtensionServer on conflicting port", port);
|
|
172
|
+
return await runExtensionServer(entryPath, attempts + 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
throw new Error(`runExtensionServer failed to run ${entryPath}`);
|
|
176
|
+
}
|
|
135
177
|
function addMicroserviceMetadatas(projectFolderPath, serviceObj) {
|
|
136
178
|
const microservices = projectMicroservices(projectFolderPath);
|
|
137
179
|
let enriched = { ...serviceObj };
|
|
@@ -151,4 +193,4 @@ function addMicroserviceMetadatas(projectFolderPath, serviceObj) {
|
|
|
151
193
|
fs.writeFileSync(microservicesMetadatasPath(projectFolderPath), JSON.stringify({ microservices }, void 0, 2));
|
|
152
194
|
}
|
|
153
195
|
//#endregion
|
|
154
|
-
export { addMicroserviceMetadatas, runBack, runExtension, runViewer };
|
|
196
|
+
export { addMicroserviceMetadatas, runBack, runExtension, runExtensionServer, runViewer };
|
|
@@ -105,5 +105,8 @@ function extensionBackendPath(unzippedExtensionPath, backendExecutableName) {
|
|
|
105
105
|
consola.debug("runExtensions", { backendExecutablePath });
|
|
106
106
|
return backendExecutablePath;
|
|
107
107
|
}
|
|
108
|
+
function extensionServerEntryPath(unzippedExtensionPath, entry) {
|
|
109
|
+
return path.join(unzippedExtensionPath, entry);
|
|
110
|
+
}
|
|
108
111
|
//#endregion
|
|
109
|
-
export { createPath, executableName, executablePath, extensionBackendPath, extensionFolderPath, extensionFrontendPath, generateProjectFolderPath };
|
|
112
|
+
export { createPath, executableName, executablePath, extensionBackendPath, extensionFolderPath, extensionFrontendPath, extensionServerEntryPath, generateProjectFolderPath };
|
|
@@ -3,6 +3,7 @@ import { createServerWsRpcClient } from "./ws_client.js";
|
|
|
3
3
|
const stringStorage = /* @__PURE__ */ new Map();
|
|
4
4
|
const booleanStorage = /* @__PURE__ */ new Map();
|
|
5
5
|
const clientStorage = /* @__PURE__ */ new Map();
|
|
6
|
+
const extensionServerPorts = /* @__PURE__ */ new Map();
|
|
6
7
|
function getAppBaseUrl() {
|
|
7
8
|
const value = stringStorage.get("APP_BASE_URL");
|
|
8
9
|
if (value === void 0) throw new Error("APP_BASE_URL is not set");
|
|
@@ -47,5 +48,14 @@ async function getViewerWebSocketClient() {
|
|
|
47
48
|
if (viewerClient !== void 0 && viewerClient.isOpen()) return viewerClient;
|
|
48
49
|
return await setViewerWebSocketClient(getViewerBaseUrl());
|
|
49
50
|
}
|
|
51
|
+
function setExtensionServerPort(extensionId, port) {
|
|
52
|
+
extensionServerPorts.set(extensionId, port);
|
|
53
|
+
}
|
|
54
|
+
function getExtensionServerPort(extensionId) {
|
|
55
|
+
return extensionServerPorts.get(extensionId);
|
|
56
|
+
}
|
|
57
|
+
function getExtensionServerPorts() {
|
|
58
|
+
return extensionServerPorts;
|
|
59
|
+
}
|
|
50
60
|
//#endregion
|
|
51
|
-
export { getAppBaseUrl, getBackBaseUrl, getIsAppReady, getViewerBaseUrl, getViewerWebSocketClient, setAppBaseUrl, setBackBaseUrl, setIsAppReady, setViewerBaseUrl, setViewerWebSocketClient };
|
|
61
|
+
export { getAppBaseUrl, getBackBaseUrl, getExtensionServerPort, getExtensionServerPorts, getIsAppReady, getViewerBaseUrl, getViewerWebSocketClient, setAppBaseUrl, setBackBaseUrl, setExtensionServerPort, setIsAppReady, setViewerBaseUrl, setViewerWebSocketClient };
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DEBOUNCE_DELAY, DEFAULT_NORMALS } from "@ogw_front/utils/clipping_planes";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_SLICE_AXIS,
|
|
5
|
+
SLICE_AXES,
|
|
6
|
+
type SliceAxis,
|
|
7
|
+
areAllGrids,
|
|
8
|
+
} from "@ogw_front/utils/slice";
|
|
9
|
+
import type { ClippingPlane } from "@ogw_front/composables/clipping_planes_widget_entries";
|
|
3
10
|
import ClippingPlaneCard from "@ogw_front/components/ClippingPlaneCard.vue";
|
|
11
|
+
import SliceCard from "@ogw_front/components/SliceCard.vue";
|
|
4
12
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
5
13
|
import { useClippingPlanesWidget } from "@ogw_front/composables/clipping_planes_widget";
|
|
6
14
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -18,10 +26,23 @@ const dataStore = useDataStore();
|
|
|
18
26
|
const hybridViewerStore = useHybridViewerStore();
|
|
19
27
|
const targetAllVisible = ref<boolean>(true);
|
|
20
28
|
const selectedDatasetIds = ref<string[]>([]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
let lastItemId = 0;
|
|
30
|
+
function newItemId(): number {
|
|
31
|
+
lastItemId += 1;
|
|
32
|
+
return lastItemId;
|
|
33
|
+
}
|
|
34
|
+
const planes = ref<ClippingPlane[]>([{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }]);
|
|
24
35
|
const allItems = dataStore.refAllItems();
|
|
36
|
+
const sliceEnabled = ref<boolean>(false);
|
|
37
|
+
const slices = ref<{ id: number; axis: SliceAxis; index: number }[]>([
|
|
38
|
+
{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 },
|
|
39
|
+
]);
|
|
40
|
+
const sliceMaxIndices = ref<[number, number, number]>([0, 0, 0]);
|
|
41
|
+
const targetIds = computed<string[]>(() =>
|
|
42
|
+
targetAllVisible.value ? allItems.value.map((item) => item.id) : selectedDatasetIds.value,
|
|
43
|
+
);
|
|
44
|
+
const isAllGrid = computed<boolean>(() => areAllGrids(allItems.value, targetIds.value));
|
|
45
|
+
const isSliceActive = computed<boolean>(() => isAllGrid.value && sliceEnabled.value);
|
|
25
46
|
const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
26
47
|
allItems.value.map((item) => ({
|
|
27
48
|
title: item.name || item.id,
|
|
@@ -30,6 +51,8 @@ const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
|
30
51
|
);
|
|
31
52
|
const widgetContainer = useTemplateRef("widgetContainer");
|
|
32
53
|
let debouncedApply: ((...args: unknown[]) => void) | undefined = undefined;
|
|
54
|
+
let areSlicesApplied = false;
|
|
55
|
+
let pendingSlices: Promise<void> = Promise.resolve();
|
|
33
56
|
|
|
34
57
|
const {
|
|
35
58
|
getSceneCenter,
|
|
@@ -49,41 +72,103 @@ const {
|
|
|
49
72
|
debouncedApply: (...args: unknown[]) => debouncedApply?.(...args),
|
|
50
73
|
});
|
|
51
74
|
|
|
75
|
+
function getUntargetedIds(): string[] {
|
|
76
|
+
return allItems.value.map((item) => item.id).filter((id) => !targetIds.value.includes(id));
|
|
77
|
+
}
|
|
78
|
+
|
|
52
79
|
async function applyClippingPlanes(): Promise<void> {
|
|
53
|
-
|
|
54
|
-
if (allIds.length === 0) {
|
|
80
|
+
if (allItems.value.length === 0) {
|
|
55
81
|
return;
|
|
56
82
|
}
|
|
57
83
|
const center = getSceneCenter();
|
|
58
|
-
const
|
|
59
|
-
const untargetedIds = allIds.filter((id) => !targetIds.includes(id));
|
|
84
|
+
const untargetedIds = getUntargetedIds();
|
|
60
85
|
const planesData = planes.value.map((plane) => ({
|
|
61
86
|
origin: (plane.origin || center).map(Number),
|
|
62
87
|
normal: plane.normal.map(Number),
|
|
63
88
|
}));
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
if (targetIds.value.length > 0) {
|
|
90
|
+
await hybridViewerStore.setClippingPlanes(
|
|
91
|
+
targetIds.value,
|
|
92
|
+
isSliceActive.value ? [] : planesData,
|
|
93
|
+
);
|
|
67
94
|
}
|
|
68
95
|
if (untargetedIds.length > 0) {
|
|
69
96
|
await hybridViewerStore.setClippingPlanes(untargetedIds, []);
|
|
70
97
|
}
|
|
71
98
|
}
|
|
72
99
|
|
|
100
|
+
async function sendSlices(): Promise<void> {
|
|
101
|
+
if (!isAllGrid.value && !areSlicesApplied) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const isActive = isSliceActive.value;
|
|
105
|
+
const untargetedIds = getUntargetedIds();
|
|
106
|
+
if (targetIds.value.length > 0) {
|
|
107
|
+
const maxIndices = await hybridViewerStore.setSlice(
|
|
108
|
+
targetIds.value,
|
|
109
|
+
isActive ? slices.value.map(({ axis, index }) => ({ axis, index })) : [],
|
|
110
|
+
);
|
|
111
|
+
if (isAllGrid.value) {
|
|
112
|
+
sliceMaxIndices.value = maxIndices;
|
|
113
|
+
}
|
|
114
|
+
if (isActive) {
|
|
115
|
+
for (const slice of slices.value) {
|
|
116
|
+
slice.index = Math.min(slice.index, maxIndices[slice.axis]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (areSlicesApplied && untargetedIds.length > 0) {
|
|
121
|
+
await hybridViewerStore.setSlice(untargetedIds, []);
|
|
122
|
+
}
|
|
123
|
+
areSlicesApplied = isActive;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function queueSliceTask(task: () => Promise<void>): Promise<void> {
|
|
127
|
+
const previous = pendingSlices;
|
|
128
|
+
pendingSlices = (async (): Promise<void> => {
|
|
129
|
+
await Promise.allSettled([previous]);
|
|
130
|
+
await task();
|
|
131
|
+
})();
|
|
132
|
+
return pendingSlices;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function applySlices(): Promise<void> {
|
|
136
|
+
return queueSliceTask(sendSlices);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function applyAll(): Promise<void> {
|
|
140
|
+
await applyClippingPlanes();
|
|
141
|
+
await applySlices();
|
|
142
|
+
}
|
|
143
|
+
|
|
73
144
|
debouncedApply = useDebounceFn(() => applyClippingPlanes(), DEBOUNCE_DELAY);
|
|
145
|
+
const debouncedApplySlices = useDebounceFn(() => applySlices(), DEBOUNCE_DELAY);
|
|
74
146
|
|
|
75
147
|
function addPlane(): void {
|
|
76
148
|
// Index is always in-bounds (modulo the fixed-size list); the fallbacks only
|
|
77
149
|
// Satisfy noUncheckedIndexedAccess and are never hit at runtime.
|
|
78
150
|
const normal = DEFAULT_NORMALS[planes.value.length % DEFAULT_NORMALS.length] ??
|
|
79
151
|
DEFAULT_NORMALS[0] ?? [1, 0, 0];
|
|
80
|
-
planes.value.push({ origin: getSceneCenter(), normal });
|
|
152
|
+
planes.value.push({ id: newItemId(), origin: getSceneCenter(), normal });
|
|
81
153
|
}
|
|
82
154
|
|
|
83
155
|
function removePlane(index: number): void {
|
|
84
156
|
planes.value.splice(index, 1);
|
|
85
157
|
}
|
|
86
158
|
|
|
159
|
+
function addSlice(): void {
|
|
160
|
+
const lastSlice = slices.value.at(-1);
|
|
161
|
+
slices.value.push({
|
|
162
|
+
id: newItemId(),
|
|
163
|
+
axis: lastSlice ? SLICE_AXES[lastSlice.axis].next : DEFAULT_SLICE_AXIS,
|
|
164
|
+
index: 0,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function removeSlice(index: number): void {
|
|
169
|
+
slices.value.splice(index, 1);
|
|
170
|
+
}
|
|
171
|
+
|
|
87
172
|
function flipNormal(plane: { normal: number[] }): void {
|
|
88
173
|
plane.normal = plane.normal.map((component) => -component);
|
|
89
174
|
syncWidgets();
|
|
@@ -92,15 +177,23 @@ function flipNormal(plane: { normal: number[] }): void {
|
|
|
92
177
|
|
|
93
178
|
async function resetClippingPlanes(): Promise<void> {
|
|
94
179
|
setFromWidget(true);
|
|
95
|
-
planes.value = [{ origin: undefined, normal: [1, 0, 0] }];
|
|
180
|
+
planes.value = [{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }];
|
|
181
|
+
sliceEnabled.value = false;
|
|
182
|
+
slices.value = [{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 }];
|
|
96
183
|
updateWidgetPlacement({ isReset: true });
|
|
97
184
|
setFromWidget(false);
|
|
98
|
-
await
|
|
185
|
+
await applyAll();
|
|
99
186
|
}
|
|
100
187
|
|
|
101
188
|
async function removeClippingPlanes(): Promise<void> {
|
|
102
189
|
const allIds = allItems.value.map((item) => item.id);
|
|
103
190
|
await hybridViewerStore.setClippingPlanes(allIds, []);
|
|
191
|
+
await queueSliceTask(async () => {
|
|
192
|
+
if (areSlicesApplied) {
|
|
193
|
+
await hybridViewerStore.setSlice(allIds, []);
|
|
194
|
+
areSlicesApplied = false;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
104
197
|
}
|
|
105
198
|
|
|
106
199
|
watch(widgetContainer, (container) => {
|
|
@@ -124,7 +217,7 @@ watch(
|
|
|
124
217
|
watch(show, (visible) => {
|
|
125
218
|
if (visible) {
|
|
126
219
|
updateWidgetPlacement({ isReset: true });
|
|
127
|
-
|
|
220
|
+
applyAll();
|
|
128
221
|
}
|
|
129
222
|
});
|
|
130
223
|
|
|
@@ -133,7 +226,23 @@ watch(
|
|
|
133
226
|
() => {
|
|
134
227
|
if (show.value) {
|
|
135
228
|
updateWidgetPlacement({ isReset: true });
|
|
136
|
-
|
|
229
|
+
applyAll();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{ deep: true },
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
watch(sliceEnabled, () => {
|
|
236
|
+
if (show.value) {
|
|
237
|
+
applyAll();
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
watch(
|
|
242
|
+
slices,
|
|
243
|
+
() => {
|
|
244
|
+
if (show.value) {
|
|
245
|
+
debouncedApplySlices();
|
|
137
246
|
}
|
|
138
247
|
},
|
|
139
248
|
{ deep: true },
|
|
@@ -142,7 +251,7 @@ watch(
|
|
|
142
251
|
watch(allItems, () => {
|
|
143
252
|
if (show.value) {
|
|
144
253
|
updateWidgetPlacement({ isReset: true });
|
|
145
|
-
|
|
254
|
+
applyAll();
|
|
146
255
|
}
|
|
147
256
|
});
|
|
148
257
|
|
|
@@ -151,7 +260,7 @@ watch(
|
|
|
151
260
|
(actorCount) => {
|
|
152
261
|
if (show.value && actorCount > 0) {
|
|
153
262
|
updateWidgetPlacement({ isReset: true });
|
|
154
|
-
|
|
263
|
+
applyAll();
|
|
155
264
|
}
|
|
156
265
|
},
|
|
157
266
|
);
|
|
@@ -171,6 +280,7 @@ onBeforeUnmount(cleanupLocalWidget);
|
|
|
171
280
|
>
|
|
172
281
|
<v-card-text class="pa-3 max-panel-height overflow-y-auto">
|
|
173
282
|
<v-sheet
|
|
283
|
+
v-show="!isSliceActive"
|
|
174
284
|
ref="widgetContainer"
|
|
175
285
|
height="180"
|
|
176
286
|
color="transparent"
|
|
@@ -203,28 +313,66 @@ onBeforeUnmount(cleanupLocalWidget);
|
|
|
203
313
|
|
|
204
314
|
<v-divider class="my-2" />
|
|
205
315
|
|
|
206
|
-
<v-
|
|
207
|
-
<v-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
316
|
+
<template v-if="isAllGrid">
|
|
317
|
+
<v-switch
|
|
318
|
+
v-model="sliceEnabled"
|
|
319
|
+
data-testid="sliceSwitch"
|
|
320
|
+
label="Slice"
|
|
321
|
+
color="primary"
|
|
322
|
+
density="compact"
|
|
323
|
+
hide-details
|
|
324
|
+
class="mb-2 text-caption"
|
|
325
|
+
/>
|
|
326
|
+
<template v-if="sliceEnabled">
|
|
327
|
+
<v-row align="center" justify="space-between" no-gutters class="mb-2">
|
|
328
|
+
<v-col class="text-caption font-weight-bold">Slices ({{ slices.length }})</v-col>
|
|
329
|
+
<v-col cols="auto">
|
|
330
|
+
<v-btn
|
|
331
|
+
data-testid="addSliceButton"
|
|
332
|
+
size="x-small"
|
|
333
|
+
variant="tonal"
|
|
334
|
+
color="primary"
|
|
335
|
+
icon="mdi-plus"
|
|
336
|
+
@click="addSlice"
|
|
337
|
+
/>
|
|
338
|
+
</v-col>
|
|
339
|
+
</v-row>
|
|
340
|
+
<SliceCard
|
|
341
|
+
v-for="(slice, idx) in slices"
|
|
342
|
+
:key="slice.id"
|
|
343
|
+
:slice="slice"
|
|
344
|
+
:index="idx"
|
|
345
|
+
:max-index="sliceMaxIndices[slice.axis]"
|
|
346
|
+
@remove="removeSlice(idx)"
|
|
216
347
|
/>
|
|
217
|
-
</
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
348
|
+
</template>
|
|
349
|
+
<v-divider class="my-2" />
|
|
350
|
+
</template>
|
|
351
|
+
|
|
352
|
+
<template v-if="!isSliceActive">
|
|
353
|
+
<v-row align="center" justify="space-between" no-gutters class="mb-2">
|
|
354
|
+
<v-col class="text-caption font-weight-bold">Planes ({{ planes.length }})</v-col>
|
|
355
|
+
<v-col cols="auto">
|
|
356
|
+
<v-btn
|
|
357
|
+
data-testid="addPlaneButton"
|
|
358
|
+
size="x-small"
|
|
359
|
+
variant="tonal"
|
|
360
|
+
color="primary"
|
|
361
|
+
icon="mdi-plus"
|
|
362
|
+
@click="addPlane"
|
|
363
|
+
/>
|
|
364
|
+
</v-col>
|
|
365
|
+
</v-row>
|
|
366
|
+
|
|
367
|
+
<ClippingPlaneCard
|
|
368
|
+
v-for="(plane, idx) in planes"
|
|
369
|
+
:key="plane.id"
|
|
370
|
+
:plane="plane"
|
|
371
|
+
:index="idx"
|
|
372
|
+
@remove="removePlane(idx)"
|
|
373
|
+
@flip-normal="flipNormal(plane)"
|
|
374
|
+
/>
|
|
375
|
+
</template>
|
|
228
376
|
</v-card-text>
|
|
229
377
|
|
|
230
378
|
<template #actions>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { SLICE_AXES, type SliceAxis } from "@ogw_front/utils/slice";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
slice: { axis: SliceAxis; index: number };
|
|
6
|
+
index: number;
|
|
7
|
+
maxIndex: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { slice, index, maxIndex } = defineProps<Props>();
|
|
11
|
+
|
|
12
|
+
interface Emits {
|
|
13
|
+
remove: [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<Emits>();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<v-card data-testid="sliceCard" variant="outlined" class="pa-2 mb-3 rounded-lg border-opacity-50">
|
|
21
|
+
<v-row align="center" no-gutters class="mb-1">
|
|
22
|
+
<v-col cols="auto">
|
|
23
|
+
<v-chip size="x-small" variant="flat" color="primary" class="font-weight-bold">
|
|
24
|
+
Slice #{{ index + 1 }}
|
|
25
|
+
</v-chip>
|
|
26
|
+
</v-col>
|
|
27
|
+
<v-col class="px-2">
|
|
28
|
+
<v-slider
|
|
29
|
+
v-model="slice.index"
|
|
30
|
+
data-testid="sliceIndexSlider"
|
|
31
|
+
:min="0"
|
|
32
|
+
:max="maxIndex"
|
|
33
|
+
:step="1"
|
|
34
|
+
color="primary"
|
|
35
|
+
track-color="grey-lighten-2"
|
|
36
|
+
density="compact"
|
|
37
|
+
hide-details
|
|
38
|
+
/>
|
|
39
|
+
</v-col>
|
|
40
|
+
<v-col cols="auto">
|
|
41
|
+
<v-btn
|
|
42
|
+
data-testid="removeSliceButton"
|
|
43
|
+
icon="mdi-trash-can-outline"
|
|
44
|
+
size="x-small"
|
|
45
|
+
variant="text"
|
|
46
|
+
color="error"
|
|
47
|
+
@click="emit('remove')"
|
|
48
|
+
/>
|
|
49
|
+
</v-col>
|
|
50
|
+
</v-row>
|
|
51
|
+
|
|
52
|
+
<v-row align="center" justify="space-between" no-gutters>
|
|
53
|
+
<v-col cols="auto">
|
|
54
|
+
<v-btn-toggle
|
|
55
|
+
v-model="slice.axis"
|
|
56
|
+
data-testid="sliceAxisToggle"
|
|
57
|
+
mandatory
|
|
58
|
+
density="compact"
|
|
59
|
+
color="primary"
|
|
60
|
+
variant="outlined"
|
|
61
|
+
divided
|
|
62
|
+
>
|
|
63
|
+
<v-btn
|
|
64
|
+
v-for="axis in SLICE_AXES"
|
|
65
|
+
:key="axis.value"
|
|
66
|
+
:value="axis.value"
|
|
67
|
+
size="small"
|
|
68
|
+
class="text-caption"
|
|
69
|
+
>
|
|
70
|
+
{{ axis.title }}
|
|
71
|
+
</v-btn>
|
|
72
|
+
</v-btn-toggle>
|
|
73
|
+
</v-col>
|
|
74
|
+
<v-col cols="auto" class="text-caption text-primary font-weight-bold">
|
|
75
|
+
{{ slice.index }} / {{ maxIndex }}
|
|
76
|
+
</v-col>
|
|
77
|
+
</v-row>
|
|
78
|
+
</v-card>
|
|
79
|
+
</template>
|
|
@@ -11,6 +11,7 @@ import type vtkAbstractWidgetFactory from "@kitware/vtk.js/Widgets/Core/Abstract
|
|
|
11
11
|
import { newInstance as vtkImplicitPlaneWidget } from "@kitware/vtk.js/Widgets/Widgets3D/ImplicitPlaneWidget";
|
|
12
12
|
|
|
13
13
|
interface ClippingPlane {
|
|
14
|
+
id: number;
|
|
14
15
|
origin?: number[];
|
|
15
16
|
normal: number[];
|
|
16
17
|
}
|
|
@@ -59,6 +59,7 @@ export function useAppExtensions(): {
|
|
|
59
59
|
async function loadExtension(
|
|
60
60
|
path: string,
|
|
61
61
|
extensionPort: string,
|
|
62
|
+
serverPort?: string,
|
|
62
63
|
backendPath?: string,
|
|
63
64
|
): Promise<ExtensionModule> {
|
|
64
65
|
try {
|
|
@@ -77,7 +78,10 @@ export function useAppExtensions(): {
|
|
|
77
78
|
// oxlint-disable-next-line no-inline-comments, no-unsafe-assignment
|
|
78
79
|
const extensionModule: ExtensionModule = await import(/* @vite-ignore */ finalURL);
|
|
79
80
|
const store = extensionModule.metadata.store();
|
|
80
|
-
store.$patch?.({
|
|
81
|
+
store.$patch?.({
|
|
82
|
+
default_local_port: extensionPort,
|
|
83
|
+
...(serverPort === undefined ? {} : { nitro_port: serverPort }),
|
|
84
|
+
});
|
|
81
85
|
|
|
82
86
|
if (finalURL !== path && finalURL.startsWith("blob:")) {
|
|
83
87
|
URL.revokeObjectURL(finalURL);
|
package/app/utils/extension.ts
CHANGED
|
@@ -15,6 +15,7 @@ interface ExtensionDescriptor {
|
|
|
15
15
|
version: string;
|
|
16
16
|
frontendContent: string;
|
|
17
17
|
port: number;
|
|
18
|
+
serverPort?: number;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
interface DownloadExtensionParams {
|
|
@@ -87,12 +88,16 @@ async function registerRunningExtensions(): Promise<RegisteredExtension[]> {
|
|
|
87
88
|
const { extensionsArray } = await runExtensions();
|
|
88
89
|
return Promise.all(
|
|
89
90
|
extensionsArray.map(async (extension: ExtensionDescriptor) => {
|
|
90
|
-
const { id, name, version, frontendContent, port } = extension;
|
|
91
|
+
const { id, name, version, frontendContent, port, serverPort } = extension;
|
|
91
92
|
const blob = new Blob([frontendContent], {
|
|
92
93
|
type: "application/javascript",
|
|
93
94
|
});
|
|
94
95
|
const blobUrl = URL.createObjectURL(blob);
|
|
95
|
-
const extensionModule = await appStore.loadExtension(
|
|
96
|
+
const extensionModule = await appStore.loadExtension(
|
|
97
|
+
blobUrl,
|
|
98
|
+
String(port),
|
|
99
|
+
serverPort === undefined ? undefined : String(serverPort),
|
|
100
|
+
);
|
|
96
101
|
consola.info("[ExtensionManager] Extension loaded:", id);
|
|
97
102
|
const storeFactory = extensionModule.metadata.store;
|
|
98
103
|
const store = storeFactory();
|
|
@@ -80,6 +80,9 @@ async function importFile(filename: string, geode_object_type: string): Promise<
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async function importWorkflow(files: readonly FileToImport[]): Promise<string[]> {
|
|
83
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
84
|
+
// Files are imported concurrently and the viewer only frames the first actor to arrive, so the camera is reset once everything is loaded
|
|
85
|
+
const wasSceneEmpty = Object.keys(hybridViewerStore.hybridDb).length === 0;
|
|
83
86
|
const chunk_size = 5;
|
|
84
87
|
const chunks: FileToImport[][] = [];
|
|
85
88
|
for (let i = 0; i < files.length; i += chunk_size) {
|
|
@@ -102,7 +105,10 @@ async function importWorkflow(files: readonly FileToImport[]): Promise<string[]>
|
|
|
102
105
|
await processChunk(chunkIndex + 1);
|
|
103
106
|
}
|
|
104
107
|
await processChunk(0);
|
|
105
|
-
const
|
|
108
|
+
const isSceneFilled = Object.keys(hybridViewerStore.hybridDb).length > 0;
|
|
109
|
+
if (wasSceneEmpty && isSceneFilled) {
|
|
110
|
+
hybridViewerStore.resetCamera();
|
|
111
|
+
}
|
|
106
112
|
await hybridViewerStore.remoteRender();
|
|
107
113
|
return results;
|
|
108
114
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const GRID_TYPES = new Set([
|
|
2
|
+
"RegularGrid2D",
|
|
3
|
+
"LightRegularGrid2D",
|
|
4
|
+
"RegularGrid3D",
|
|
5
|
+
"LightRegularGrid3D",
|
|
6
|
+
]);
|
|
7
|
+
type SliceAxis = 0 | 1 | 2;
|
|
8
|
+
const SLICE_AXES = [
|
|
9
|
+
{ title: "YZ", value: 0, next: 1 },
|
|
10
|
+
{ title: "XZ", value: 1, next: 2 },
|
|
11
|
+
{ title: "XY", value: 2, next: 0 },
|
|
12
|
+
] as const satisfies readonly { title: string; value: SliceAxis; next: SliceAxis }[];
|
|
13
|
+
const DEFAULT_SLICE_AXIS: SliceAxis = 2;
|
|
14
|
+
|
|
15
|
+
function areAllGrids(items: { id: string; geode_object_type: string }[], ids: string[]): boolean {
|
|
16
|
+
const targetedItems = items.filter((item) => ids.includes(item.id));
|
|
17
|
+
return (
|
|
18
|
+
targetedItems.length > 0 &&
|
|
19
|
+
targetedItems.every((item) => GRID_TYPES.has(item.geode_object_type))
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { SLICE_AXES, DEFAULT_SLICE_AXIS, areAllGrids };
|
|
24
|
+
export type { SliceAxis };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SliceAxis } from "@ogw_front/utils/slice";
|
|
1
2
|
import { useHybridViewerCore } from "./core";
|
|
2
3
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
3
4
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
@@ -30,6 +31,25 @@ async function setShrink(ids: string[], shrink_factor: number): Promise<void> {
|
|
|
30
31
|
});
|
|
31
32
|
await remoteRender();
|
|
32
33
|
}
|
|
34
|
+
async function setSlice(
|
|
35
|
+
ids: string[],
|
|
36
|
+
slices: { axis: SliceAxis; index: number }[],
|
|
37
|
+
): Promise<[number, number, number]> {
|
|
38
|
+
const viewerStore = useViewerStore();
|
|
39
|
+
const { remoteRender } = useHybridViewerCore();
|
|
40
|
+
const schema = viewer_schemas.opengeodeweb_viewer.viewer.slice;
|
|
41
|
+
const params = {
|
|
42
|
+
ids,
|
|
43
|
+
slices,
|
|
44
|
+
};
|
|
45
|
+
const response = await viewerStore.request({
|
|
46
|
+
schema,
|
|
47
|
+
params,
|
|
48
|
+
});
|
|
49
|
+
await remoteRender();
|
|
50
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- response shape is defined by the slice schema.
|
|
51
|
+
return (response as { max_indices: [number, number, number] }).max_indices;
|
|
52
|
+
}
|
|
33
53
|
interface ThresholdAttribute {
|
|
34
54
|
name: string;
|
|
35
55
|
location: "point" | "cell";
|
|
@@ -54,11 +74,16 @@ async function setThreshold(ids: string[], attribute?: ThresholdAttribute): Prom
|
|
|
54
74
|
function useHybridViewerFilters(): {
|
|
55
75
|
setClippingPlanes: (ids: string[], planes: unknown) => Promise<void>;
|
|
56
76
|
setShrink: (ids: string[], shrink_factor: number) => Promise<void>;
|
|
77
|
+
setSlice: (
|
|
78
|
+
ids: string[],
|
|
79
|
+
slices: { axis: SliceAxis; index: number }[],
|
|
80
|
+
) => Promise<[number, number, number]>;
|
|
57
81
|
setThreshold: (ids: string[], attribute?: ThresholdAttribute) => Promise<void>;
|
|
58
82
|
} {
|
|
59
83
|
return {
|
|
60
84
|
setClippingPlanes,
|
|
61
85
|
setShrink,
|
|
86
|
+
setSlice,
|
|
62
87
|
setThreshold,
|
|
63
88
|
};
|
|
64
89
|
}
|
package/package.json
CHANGED
|
@@ -7,54 +7,73 @@ import fs from "node:fs";
|
|
|
7
7
|
import {
|
|
8
8
|
addMicroserviceMetadatas,
|
|
9
9
|
runBack,
|
|
10
|
+
runExtensionServer,
|
|
10
11
|
} from "@geode/opengeodeweb-front/server/utils/microservices.ts";
|
|
11
12
|
import {
|
|
12
13
|
extensionBackendPath,
|
|
13
14
|
extensionFolderPath,
|
|
15
|
+
extensionServerEntryPath,
|
|
14
16
|
} from "@geode/opengeodeweb-front/server/utils/path.ts";
|
|
15
17
|
import {
|
|
16
18
|
readExtensionFrontend,
|
|
17
19
|
readExtensionMetadata,
|
|
18
20
|
} from "@geode/opengeodeweb-front/server/utils/extension.ts";
|
|
19
21
|
import { extensionsConf } from "@geode/opengeodeweb-front/server/utils/app_config.ts";
|
|
22
|
+
import { setExtensionServerPort } from "@geode/opengeodeweb-front/server/utils/server_config.ts";
|
|
20
23
|
import { unzipFile } from "@geode/opengeodeweb-front/server/utils/server.ts";
|
|
21
24
|
|
|
22
25
|
import { defineTypedEventHandler } from "@geode/opengeodeweb-front/server/utils/typed_handler.ts";
|
|
23
26
|
import schemas from "@geode/opengeodeweb-front/opengeodeweb_front_typed_schemas.js";
|
|
24
27
|
|
|
28
|
+
async function runSingleExtension(
|
|
29
|
+
extensionPath: string,
|
|
30
|
+
extensionId: string,
|
|
31
|
+
projectFolderPath: string,
|
|
32
|
+
): Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
version: string;
|
|
36
|
+
frontendContent: string;
|
|
37
|
+
port: number;
|
|
38
|
+
serverPort: number | undefined;
|
|
39
|
+
}> {
|
|
40
|
+
const unzippedExtensionPath = await unzipFile(
|
|
41
|
+
extensionPath,
|
|
42
|
+
extensionFolderPath(projectFolderPath, extensionId),
|
|
43
|
+
);
|
|
44
|
+
const { id, name, version, backendExecutable, server, frontendFile } =
|
|
45
|
+
await readExtensionMetadata(unzippedExtensionPath);
|
|
46
|
+
const frontendContent = await readExtensionFrontend(unzippedExtensionPath, frontendFile, id);
|
|
47
|
+
|
|
48
|
+
fs.chmodSync(extensionBackendPath(unzippedExtensionPath, backendExecutable), "755");
|
|
49
|
+
const port = await runBack(backendExecutable, unzippedExtensionPath, {
|
|
50
|
+
projectFolderPath,
|
|
51
|
+
});
|
|
52
|
+
addMicroserviceMetadatas(projectFolderPath, {
|
|
53
|
+
type: "back",
|
|
54
|
+
name,
|
|
55
|
+
port,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const serverPort =
|
|
59
|
+
server === undefined
|
|
60
|
+
? undefined
|
|
61
|
+
: await runExtensionServer(extensionServerEntryPath(unzippedExtensionPath, server.entry));
|
|
62
|
+
if (serverPort !== undefined) {
|
|
63
|
+
setExtensionServerPort(id, serverPort);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { id, name, version, frontendContent, port, serverPort };
|
|
67
|
+
}
|
|
68
|
+
|
|
25
69
|
export default defineTypedEventHandler(
|
|
26
70
|
schemas.api.local.extensions.run,
|
|
27
71
|
async ({ projectFolderPath, projectName }) => {
|
|
28
72
|
const extensionsConfig = extensionsConf(projectName);
|
|
29
73
|
const extensionsArray = await Promise.all(
|
|
30
74
|
Object.entries(extensionsConfig).map(async ([extensionId, { path: extensionPath }]) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
extensionFolderPath(projectFolderPath, extensionId),
|
|
34
|
-
);
|
|
35
|
-
const { id, name, version, backendExecutable, frontendFile } =
|
|
36
|
-
await readExtensionMetadata(unzippedExtensionPath);
|
|
37
|
-
const frontendContent = await readExtensionFrontend(
|
|
38
|
-
unzippedExtensionPath,
|
|
39
|
-
frontendFile,
|
|
40
|
-
id,
|
|
41
|
-
);
|
|
42
|
-
fs.chmodSync(extensionBackendPath(unzippedExtensionPath, backendExecutable), "755");
|
|
43
|
-
const port = await runBack(backendExecutable, unzippedExtensionPath, {
|
|
44
|
-
projectFolderPath,
|
|
45
|
-
});
|
|
46
|
-
addMicroserviceMetadatas(projectFolderPath, {
|
|
47
|
-
type: "back",
|
|
48
|
-
name,
|
|
49
|
-
port,
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
name,
|
|
54
|
-
version,
|
|
55
|
-
frontendContent,
|
|
56
|
-
port,
|
|
57
|
-
};
|
|
75
|
+
const result = await runSingleExtension(extensionPath, extensionId, projectFolderPath);
|
|
76
|
+
return result;
|
|
58
77
|
}),
|
|
59
78
|
);
|
|
60
79
|
|
|
@@ -10,6 +10,10 @@ import { createError } from "h3";
|
|
|
10
10
|
// Local imports
|
|
11
11
|
import { extensionFrontendPath } from "@geode/opengeodeweb-front/server/utils/path.ts";
|
|
12
12
|
|
|
13
|
+
const extensionServerMetadataSchema = z.object({
|
|
14
|
+
entry: z.string(),
|
|
15
|
+
});
|
|
16
|
+
|
|
13
17
|
const extensionMetadataSchema = z
|
|
14
18
|
.object({
|
|
15
19
|
id: z.string(),
|
|
@@ -17,6 +21,7 @@ const extensionMetadataSchema = z
|
|
|
17
21
|
version: z.string(),
|
|
18
22
|
frontendFile: z.string(),
|
|
19
23
|
backendExecutable: z.string(),
|
|
24
|
+
server: extensionServerMetadataSchema.optional(),
|
|
20
25
|
})
|
|
21
26
|
.loose();
|
|
22
27
|
|
|
@@ -20,9 +20,10 @@ interface RunArgs {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const MILLISECONDS_PER_SECOND = 1000;
|
|
23
|
-
const DEFAULT_TIMEOUT_SECONDS =
|
|
23
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
24
24
|
const MAX_PORT_RETRIES = 1;
|
|
25
25
|
const DEFAULT_RUN_ARGS: RunArgs = { projectFolderPath: "" };
|
|
26
|
+
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
26
27
|
|
|
27
28
|
async function runScript(
|
|
28
29
|
execPath: string,
|
|
@@ -183,6 +184,56 @@ async function runExtension(
|
|
|
183
184
|
}
|
|
184
185
|
throw new Error(`runExtension failed to run ${extensionId}`);
|
|
185
186
|
}
|
|
187
|
+
async function waitUntilListening(
|
|
188
|
+
child: child_process.ChildProcessWithoutNullStreams,
|
|
189
|
+
): Promise<void> {
|
|
190
|
+
child.stderr.on("data", (data: Buffer) => {
|
|
191
|
+
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
192
|
+
});
|
|
193
|
+
child.on("close", (code) => {
|
|
194
|
+
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
195
|
+
});
|
|
196
|
+
// oxlint-disable-next-line typescript/no-unnecessary-condition
|
|
197
|
+
for await (const chunk of child.stdout) {
|
|
198
|
+
const output = String(chunk);
|
|
199
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
200
|
+
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
201
|
+
child.stdout.on("data", (data: Buffer) => {
|
|
202
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function runExtensionServer(entryPath: string, attempts = 0): Promise<number> {
|
|
211
|
+
let port: number | undefined = undefined;
|
|
212
|
+
try {
|
|
213
|
+
port = await getAvailablePort();
|
|
214
|
+
consola.info("runExtensionServer", entryPath, port);
|
|
215
|
+
const child = child_process.spawn("node", [entryPath], {
|
|
216
|
+
env: {
|
|
217
|
+
...process.env,
|
|
218
|
+
PORT: String(port),
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
await waitUntilListening(child);
|
|
222
|
+
return port;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (!isPortInUseError(error)) {
|
|
225
|
+
consola.error("runExtensionServer error", error);
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
if (attempts <= MAX_PORT_RETRIES) {
|
|
229
|
+
consola.warn("Retrying runExtensionServer on conflicting port", port);
|
|
230
|
+
const newPort = await runExtensionServer(entryPath, attempts + 1);
|
|
231
|
+
return newPort;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
throw new Error(`runExtensionServer failed to run ${entryPath}`);
|
|
235
|
+
}
|
|
236
|
+
|
|
186
237
|
function addMicroserviceMetadatas(projectFolderPath: string, serviceObj: Microservice): void {
|
|
187
238
|
const microservices = projectMicroservices(projectFolderPath);
|
|
188
239
|
let enriched: Microservice = { ...serviceObj };
|
|
@@ -213,4 +264,4 @@ function addMicroserviceMetadatas(projectFolderPath: string, serviceObj: Microse
|
|
|
213
264
|
);
|
|
214
265
|
}
|
|
215
266
|
|
|
216
|
-
export { addMicroserviceMetadatas, runBack, runExtension, runViewer };
|
|
267
|
+
export { addMicroserviceMetadatas, runBack, runExtension, runExtensionServer, runViewer };
|
package/server/utils/path.ts
CHANGED
|
@@ -163,11 +163,15 @@ function extensionBackendPath(
|
|
|
163
163
|
});
|
|
164
164
|
return backendExecutablePath;
|
|
165
165
|
}
|
|
166
|
+
function extensionServerEntryPath(unzippedExtensionPath: string, entry: string): string {
|
|
167
|
+
return path.join(unzippedExtensionPath, entry);
|
|
168
|
+
}
|
|
166
169
|
export {
|
|
167
170
|
createPath,
|
|
168
171
|
extensionBackendPath,
|
|
169
172
|
extensionFrontendPath,
|
|
170
173
|
extensionFolderPath,
|
|
174
|
+
extensionServerEntryPath,
|
|
171
175
|
executablePath,
|
|
172
176
|
executableName,
|
|
173
177
|
generateProjectFolderPath,
|
|
@@ -3,6 +3,7 @@ import { type ServerWsRpcClient, createServerWsRpcClient } from "./ws_client.js"
|
|
|
3
3
|
const stringStorage = new Map<string, string>();
|
|
4
4
|
const booleanStorage = new Map<string, boolean>();
|
|
5
5
|
const clientStorage = new Map<string, ServerWsRpcClient>();
|
|
6
|
+
const extensionServerPorts = new Map<string, number>();
|
|
6
7
|
|
|
7
8
|
function getAppBaseUrl(): string {
|
|
8
9
|
const value = stringStorage.get("APP_BASE_URL");
|
|
@@ -60,14 +61,27 @@ async function getViewerWebSocketClient(): Promise<ServerWsRpcClient> {
|
|
|
60
61
|
const client = await setViewerWebSocketClient(viewerBaseUrl);
|
|
61
62
|
return client;
|
|
62
63
|
}
|
|
64
|
+
function setExtensionServerPort(extensionId: string, port: number): void {
|
|
65
|
+
extensionServerPorts.set(extensionId, port);
|
|
66
|
+
}
|
|
67
|
+
function getExtensionServerPort(extensionId: string): number | undefined {
|
|
68
|
+
return extensionServerPorts.get(extensionId);
|
|
69
|
+
}
|
|
70
|
+
function getExtensionServerPorts(): ReadonlyMap<string, number> {
|
|
71
|
+
return extensionServerPorts;
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
export {
|
|
64
75
|
getAppBaseUrl,
|
|
65
76
|
getBackBaseUrl,
|
|
77
|
+
getExtensionServerPort,
|
|
78
|
+
getExtensionServerPorts,
|
|
66
79
|
getIsAppReady,
|
|
67
80
|
getViewerBaseUrl,
|
|
68
81
|
getViewerWebSocketClient,
|
|
69
82
|
setAppBaseUrl,
|
|
70
83
|
setBackBaseUrl,
|
|
84
|
+
setExtensionServerPort,
|
|
71
85
|
setIsAppReady,
|
|
72
86
|
setViewerBaseUrl,
|
|
73
87
|
setViewerWebSocketClient,
|