@geode/opengeodeweb-front 10.44.0-rc.6 → 10.44.0-rc.8
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/server/utils/scripts.js +34 -23
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/MissingFilesSelector.vue +30 -17
- package/app/components/ObjectSelector.vue +34 -23
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +5 -1
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +6 -2
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +49 -10
- package/app/components/Viewer/Ui.vue +6 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager_helpers/reset.ts +3 -0
- package/app/composables/project_manager_helpers/restore.ts +22 -10
- package/app/composables/project_manager_helpers/types.ts +2 -0
- package/app/composables/use_overlapping_picker.ts +23 -37
- package/app/composables/viewer_context_menu.ts +10 -0
- package/app/composables/virtual_tree_flatten.ts +66 -43
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +2 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/treeview.ts +12 -1
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/database.ts +47 -32
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
- package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +83 -39
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/edge.ts +88 -44
- package/internal/stores/data_style/model/lines/vertex.ts +88 -44
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
- package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
- package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
- package/internal/stores/hybrid_viewer/highlight.ts +70 -54
- package/internal/stores/hybrid_viewer/scene.ts +31 -25
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/package.json +1 -1
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/scripts.ts +35 -30
|
@@ -2,6 +2,7 @@ import type { ProjectSnapshot } from "@ogw_front/composables/project_manager_hel
|
|
|
2
2
|
import { importProjectToViewer } from "@ogw_front/composables/project_manager_helpers/viewer_session";
|
|
3
3
|
import { importWorkflowFromSnapshot } from "@ogw_front/utils/import_workflow";
|
|
4
4
|
import { oldestCrs } from "@ogw_front/utils/crs";
|
|
5
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
5
6
|
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
6
7
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
7
8
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
@@ -21,32 +22,43 @@ function restoreCrs(snapshot: ProjectSnapshot): void {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
async function restoreProject(snapshot: ProjectSnapshot): Promise<void> {
|
|
26
|
-
const dataStyleStore = useDataStyleStore();
|
|
27
|
-
const viewerStore = useViewerStore();
|
|
25
|
+
async function restoreData(snapshot: ProjectSnapshot): Promise<void> {
|
|
28
26
|
const dataStore = useDataStore();
|
|
29
27
|
const treeviewStore = useTreeviewStore();
|
|
30
28
|
const hybridViewerStore = useHybridViewerStore();
|
|
31
29
|
|
|
32
|
-
treeviewStore.isImporting = true;
|
|
33
|
-
|
|
34
|
-
await importProjectToViewer(viewerStore.client);
|
|
35
|
-
|
|
36
30
|
treeviewStore.importStores(snapshot.treeview);
|
|
37
31
|
if (snapshot.data !== undefined) {
|
|
38
32
|
await dataStore.importStores(snapshot.data);
|
|
39
33
|
}
|
|
40
34
|
await hybridViewerStore.initHybridViewer();
|
|
35
|
+
await importWorkflowFromSnapshot(snapshot.data?.items ?? []);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function restoreViews(snapshot: ProjectSnapshot): Promise<void> {
|
|
39
|
+
const dataStyleStore = useDataStyleStore();
|
|
40
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
41
|
+
const basemapStore = useBasemapStore();
|
|
41
42
|
|
|
42
|
-
const items = snapshot.data?.items ?? [];
|
|
43
|
-
await importWorkflowFromSnapshot(items);
|
|
44
43
|
restoreCrs(snapshot);
|
|
44
|
+
await basemapStore.importStores(snapshot.basemap);
|
|
45
45
|
await hybridViewerStore.importStores(snapshot.hybridViewer);
|
|
46
46
|
if (snapshot.dataStyle !== undefined) {
|
|
47
47
|
await dataStyleStore.importStores(snapshot.dataStyle);
|
|
48
48
|
}
|
|
49
49
|
await dataStyleStore.applyAllStylesFromState();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Loads a project snapshot into the (already reset) viewer and stores.
|
|
53
|
+
async function restoreProject(snapshot: ProjectSnapshot): Promise<void> {
|
|
54
|
+
const viewerStore = useViewerStore();
|
|
55
|
+
const treeviewStore = useTreeviewStore();
|
|
56
|
+
|
|
57
|
+
treeviewStore.isImporting = true;
|
|
58
|
+
|
|
59
|
+
await importProjectToViewer(viewerStore.client);
|
|
60
|
+
await restoreData(snapshot);
|
|
61
|
+
await restoreViews(snapshot);
|
|
50
62
|
|
|
51
63
|
treeviewStore.finalizeImportSelection();
|
|
52
64
|
treeviewStore.isImporting = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelComponentRelationRecord, NewDataItem } from "@ogw_front/stores/data";
|
|
2
|
+
import type { BasemapSnapshot } from "@ogw_front/stores/basemap";
|
|
2
3
|
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
4
|
import type { CameraSnapshot } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
4
5
|
import type { DataStyleSnapshot } from "@ogw_front/stores/data_style";
|
|
@@ -17,6 +18,7 @@ interface ProjectSnapshot {
|
|
|
17
18
|
hybridViewer?: CameraSnapshot;
|
|
18
19
|
dataStyle?: DataStyleSnapshot;
|
|
19
20
|
crs?: { projectCrs?: CRSList };
|
|
21
|
+
basemap?: BasemapSnapshot;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type { ProjectSnapshot };
|
|
@@ -2,6 +2,7 @@ import { ref } from "vue";
|
|
|
2
2
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
3
3
|
|
|
4
4
|
import { type DataItem, useDataStore } from "@ogw_front/stores/data";
|
|
5
|
+
import { computeMenuPosition } from "@ogw_front/composables/overlapping_picker_menu";
|
|
5
6
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
6
7
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
7
8
|
|
|
@@ -102,13 +103,7 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
async function
|
|
106
|
-
x,
|
|
107
|
-
y,
|
|
108
|
-
containerWidth,
|
|
109
|
-
containerHeight,
|
|
110
|
-
containerRect,
|
|
111
|
-
}: GetViewerIdParams): Promise<ViewerIdResult> {
|
|
106
|
+
async function getViewableIds(): Promise<string[]> {
|
|
112
107
|
const activeIds = new Set(dataItems.value.map((i: DataItem) => i.id));
|
|
113
108
|
const visibleStyleIds = Object.keys(dataStyleStore.styles).filter(
|
|
114
109
|
(styleId) => activeIds.has(styleId) && dataStyleStore.objectVisibility(styleId) === true,
|
|
@@ -123,15 +118,30 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
123
118
|
}
|
|
124
119
|
}),
|
|
125
120
|
);
|
|
126
|
-
|
|
121
|
+
return viewableChecks.filter((id): id is string => Boolean(id));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function showIntermediateMenu(
|
|
125
|
+
{ x, y, containerWidth, containerHeight, containerRect }: GetViewerIdParams,
|
|
126
|
+
itemCount: number,
|
|
127
|
+
): void {
|
|
128
|
+
const position = computeMenuPosition({ x, y, containerWidth, containerHeight, itemCount });
|
|
129
|
+
intermediateMenuX.value = containerRect.left + position.x;
|
|
130
|
+
intermediateMenuY.value = containerRect.top + position.y;
|
|
131
|
+
displayIntermediate.value = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function get_viewer_id(params: GetViewerIdParams): Promise<ViewerIdResult> {
|
|
135
|
+
const ids = await getViewableIds();
|
|
127
136
|
|
|
128
|
-
const result: ViewerIdResult = { id: undefined, viewer_id: undefined };
|
|
129
137
|
const schema = viewer_schemas.opengeodeweb_viewer.viewer.picked_ids;
|
|
130
|
-
const
|
|
131
|
-
|
|
138
|
+
const { array_ids, viewer_id } = await viewerStore.request({
|
|
139
|
+
schema,
|
|
140
|
+
params: { x: params.x, y: params.y, ids },
|
|
141
|
+
});
|
|
132
142
|
|
|
133
143
|
if (array_ids.length === 0) {
|
|
134
|
-
return
|
|
144
|
+
return { id: undefined, viewer_id: undefined };
|
|
135
145
|
}
|
|
136
146
|
|
|
137
147
|
const pickedList: PickedItem[] = array_ids.map((pickId) => ({ id: pickId, viewer_id }));
|
|
@@ -142,31 +152,7 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
142
152
|
|
|
143
153
|
const proposedItems = await fetchProposedItems(pickedList);
|
|
144
154
|
intermediateItems.value = proposedItems;
|
|
145
|
-
|
|
146
|
-
const yUI = containerHeight - y;
|
|
147
|
-
const MENU_WIDTH = 340;
|
|
148
|
-
const MENU_BASE_HEIGHT = 55;
|
|
149
|
-
const MENU_ITEM_HEIGHT = 48;
|
|
150
|
-
const MENU_HEIGHT = MENU_BASE_HEIGHT + proposedItems.length * MENU_ITEM_HEIGHT;
|
|
151
|
-
const CLAMP_MARGIN = 10;
|
|
152
|
-
const clampedX = Math.min(
|
|
153
|
-
Math.max(x, CLAMP_MARGIN),
|
|
154
|
-
containerWidth - MENU_WIDTH - CLAMP_MARGIN,
|
|
155
|
-
);
|
|
156
|
-
let clampedY = yUI;
|
|
157
|
-
if (yUI + MENU_HEIGHT > containerHeight - CLAMP_MARGIN) {
|
|
158
|
-
clampedY = Math.max(yUI - MENU_HEIGHT, CLAMP_MARGIN);
|
|
159
|
-
} else {
|
|
160
|
-
clampedY = Math.max(yUI, CLAMP_MARGIN);
|
|
161
|
-
}
|
|
162
|
-
clampedY = Math.min(
|
|
163
|
-
Math.max(clampedY, CLAMP_MARGIN),
|
|
164
|
-
containerHeight - MENU_HEIGHT - CLAMP_MARGIN,
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
intermediateMenuX.value = containerRect.left + clampedX;
|
|
168
|
-
intermediateMenuY.value = containerRect.top + clampedY;
|
|
169
|
-
displayIntermediate.value = true;
|
|
155
|
+
showIntermediateMenu(params, proposedItems.length);
|
|
170
156
|
|
|
171
157
|
/* eslint-disable-next-line promise/avoid-new */
|
|
172
158
|
return new Promise<ViewerIdResult>((resolve) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MenuMetaData, useMenuStore } from "@ogw_front/stores/menu";
|
|
2
2
|
import type { Ref, ShallowRef } from "vue";
|
|
3
|
+
import { BASEMAP_GROUP_ID } from "@ogw_front/utils/basemap_tree";
|
|
3
4
|
import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
4
5
|
import type { ViewerIdResult } from "@ogw_front/composables/use_overlapping_picker";
|
|
5
6
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -18,6 +19,15 @@ async function treeMenuTarget(
|
|
|
18
19
|
dataStore: ReturnType<typeof useDataStore>,
|
|
19
20
|
payload: TreeMenuPayload,
|
|
20
21
|
): Promise<MenuTarget | undefined> {
|
|
22
|
+
if (payload.context_type === "basemap") {
|
|
23
|
+
return {
|
|
24
|
+
id: payload.itemId,
|
|
25
|
+
meta_data: {
|
|
26
|
+
viewer_type: "basemap",
|
|
27
|
+
geode_object_type: payload.itemId === BASEMAP_GROUP_ID ? "Basemap" : "Map",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
21
31
|
if (payload.context_type === "geode_object_type") {
|
|
22
32
|
const [referenceId] = payload.targetIds;
|
|
23
33
|
if (referenceId === undefined) {
|
|
@@ -27,57 +27,80 @@ function matchesSearch(ctx: FlattenContext, item: TreeItem, id: unknown, search:
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
function createDisplayItem(ctx: FlattenContext, item: TreeItem, depth: number): DisplayItem {
|
|
31
|
+
const id = item[ctx.actualItemProps.value.value];
|
|
32
|
+
return {
|
|
33
|
+
raw: item,
|
|
34
|
+
id,
|
|
35
|
+
depth,
|
|
36
|
+
isOpen: ctx.openedSet.value.has(id),
|
|
37
|
+
isActive: ctx.activeSet.value.has(id),
|
|
38
|
+
isLeaf: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
const id = item[ctx.actualItemProps.value.value];
|
|
36
|
-
const children = ctx.getChildrenOf(item);
|
|
37
|
-
const hasChildren = Boolean(children && children.length > 0);
|
|
42
|
+
type FlattenChildren = (children: readonly TreeItem[]) => DisplayItem[];
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
// A branch is kept when it matches or when one of its descendants does
|
|
45
|
+
function flattenSearchedBranch(
|
|
46
|
+
entry: DisplayItem,
|
|
47
|
+
subtree: readonly DisplayItem[],
|
|
48
|
+
matches: boolean,
|
|
49
|
+
): DisplayItem[] {
|
|
50
|
+
if (subtree.length === 0 && !matches) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const branch = { ...entry, isLeaf: false };
|
|
54
|
+
if (!branch.isOpen) {
|
|
55
|
+
return [branch];
|
|
56
|
+
}
|
|
57
|
+
return [branch, ...subtree];
|
|
58
|
+
}
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
function flattenOpenBranch(
|
|
61
|
+
entry: DisplayItem,
|
|
62
|
+
children: readonly TreeItem[],
|
|
63
|
+
flattenChildren: FlattenChildren,
|
|
64
|
+
): DisplayItem[] {
|
|
65
|
+
const branch = { ...entry, isLeaf: false };
|
|
66
|
+
if (!branch.isOpen) {
|
|
67
|
+
return [branch];
|
|
68
|
+
}
|
|
69
|
+
return [branch, ...flattenChildren(children)];
|
|
70
|
+
}
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
function flattenNode(
|
|
73
|
+
ctx: FlattenContext,
|
|
74
|
+
item: TreeItem,
|
|
75
|
+
depth: number,
|
|
76
|
+
flattenChildren: FlattenChildren,
|
|
77
|
+
): DisplayItem[] {
|
|
78
|
+
const { search } = ctx.props.value;
|
|
79
|
+
const entry = createDisplayItem(ctx, item, depth);
|
|
80
|
+
const children = ctx.getChildrenOf(item) ?? [];
|
|
81
|
+
const searching = search !== undefined && search !== "";
|
|
50
82
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
depth,
|
|
55
|
-
isOpen,
|
|
56
|
-
isActive,
|
|
57
|
-
isLeaf: false,
|
|
58
|
-
});
|
|
59
|
-
if (isOpen) {
|
|
60
|
-
result.push(...subtree);
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (!matches) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
83
|
+
if (children.length === 0) {
|
|
84
|
+
if (searching && !matchesSearch(ctx, item, entry.id, search)) {
|
|
85
|
+
return [];
|
|
67
86
|
}
|
|
87
|
+
return [entry];
|
|
88
|
+
}
|
|
89
|
+
if (searching) {
|
|
90
|
+
const matches = matchesSearch(ctx, item, entry.id, search);
|
|
91
|
+
return flattenSearchedBranch(entry, flattenChildren(children), matches);
|
|
92
|
+
}
|
|
93
|
+
return flattenOpenBranch(entry, children, flattenChildren);
|
|
94
|
+
}
|
|
68
95
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
isActive,
|
|
75
|
-
isLeaf: !hasChildren,
|
|
76
|
-
});
|
|
96
|
+
function flattenTree(ctx: FlattenContext, nodes: readonly TreeItem[], depth = 0): DisplayItem[] {
|
|
97
|
+
const result: DisplayItem[] = [];
|
|
98
|
+
function flattenChildren(children: readonly TreeItem[]): DisplayItem[] {
|
|
99
|
+
return flattenTree(ctx, children, depth + 1);
|
|
100
|
+
}
|
|
77
101
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
102
|
+
for (const item of nodes) {
|
|
103
|
+
result.push(...flattenNode(ctx, item, depth, flattenChildren));
|
|
81
104
|
}
|
|
82
105
|
return result;
|
|
83
106
|
}
|
|
@@ -26,6 +26,85 @@ interface ExtensionData {
|
|
|
26
26
|
enabled: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
async function transformBlobUrl(
|
|
30
|
+
path: string,
|
|
31
|
+
transformer: ((code: string) => string) | undefined,
|
|
32
|
+
): Promise<string> {
|
|
33
|
+
if (!transformer || !path.startsWith("blob:")) {
|
|
34
|
+
return path;
|
|
35
|
+
}
|
|
36
|
+
const response = await fetch(path);
|
|
37
|
+
const code = await response.text();
|
|
38
|
+
const transformedCode = transformer(code);
|
|
39
|
+
|
|
40
|
+
const newBlob = new Blob([transformedCode], {
|
|
41
|
+
type: "application/javascript",
|
|
42
|
+
});
|
|
43
|
+
return URL.createObjectURL(newBlob);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function importExtensionModule(
|
|
47
|
+
path: string,
|
|
48
|
+
transformer: ((code: string) => string) | undefined,
|
|
49
|
+
extensionPort: string,
|
|
50
|
+
serverPort?: string,
|
|
51
|
+
): Promise<ExtensionModule> {
|
|
52
|
+
const finalURL = await transformBlobUrl(path, transformer);
|
|
53
|
+
// oxlint-disable-next-line no-inline-comments, no-unsafe-assignment
|
|
54
|
+
const extensionModule: ExtensionModule = await import(/* @vite-ignore */ finalURL);
|
|
55
|
+
const store = extensionModule.metadata.store();
|
|
56
|
+
store.$patch?.({
|
|
57
|
+
default_local_port: extensionPort,
|
|
58
|
+
...(serverPort !== undefined && { nitro_port: serverPort }),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (finalURL !== path && finalURL.startsWith("blob:")) {
|
|
62
|
+
URL.revokeObjectURL(finalURL);
|
|
63
|
+
}
|
|
64
|
+
return extensionModule;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function validateExtensionModule(
|
|
68
|
+
extensionModule: ExtensionModule,
|
|
69
|
+
api: unknown,
|
|
70
|
+
loaded: Map<string, ExtensionData>,
|
|
71
|
+
): void {
|
|
72
|
+
if (!extensionModule.metadata?.id) {
|
|
73
|
+
throw new Error("Extension must have metadata.id");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const extensionId = extensionModule.metadata.id;
|
|
77
|
+
|
|
78
|
+
if (loaded.has(extensionId)) {
|
|
79
|
+
consola.warn(`[AppStore] Extension "${extensionId}" is already loaded`);
|
|
80
|
+
throw new Error(`Extension "${extensionId}" is already loaded.`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (api === undefined) {
|
|
84
|
+
throw new Error("Extension API not initialized");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (typeof extensionModule.install !== "function") {
|
|
88
|
+
throw new TypeError("Extension must export an install function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function createExtensionData(
|
|
93
|
+
extensionModule: ExtensionModule,
|
|
94
|
+
path: string,
|
|
95
|
+
backendPath: string | undefined,
|
|
96
|
+
): ExtensionData {
|
|
97
|
+
return {
|
|
98
|
+
module: extensionModule,
|
|
99
|
+
id: extensionModule.metadata.id,
|
|
100
|
+
path,
|
|
101
|
+
backendPath,
|
|
102
|
+
loadedAt: new Date().toISOString(),
|
|
103
|
+
metadata: extensionModule.metadata,
|
|
104
|
+
enabled: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
29
108
|
// oxlint-disable-next-line max-lines-per-function, max-statements
|
|
30
109
|
export function useAppExtensions(): {
|
|
31
110
|
loadedExtensions: typeof loadedExtensions;
|
|
@@ -63,61 +142,21 @@ export function useAppExtensions(): {
|
|
|
63
142
|
backendPath?: string,
|
|
64
143
|
): Promise<ExtensionModule> {
|
|
65
144
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const newBlob = new Blob([transformedCode], {
|
|
74
|
-
type: "application/javascript",
|
|
75
|
-
});
|
|
76
|
-
finalURL = URL.createObjectURL(newBlob);
|
|
77
|
-
}
|
|
78
|
-
// oxlint-disable-next-line no-inline-comments, no-unsafe-assignment
|
|
79
|
-
const extensionModule: ExtensionModule = await import(/* @vite-ignore */ finalURL);
|
|
80
|
-
const store = extensionModule.metadata.store();
|
|
81
|
-
store.$patch?.({
|
|
82
|
-
default_local_port: extensionPort,
|
|
83
|
-
...(serverPort !== undefined && { nitro_port: serverPort }),
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
if (finalURL !== path && finalURL.startsWith("blob:")) {
|
|
87
|
-
URL.revokeObjectURL(finalURL);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (!extensionModule.metadata?.id) {
|
|
91
|
-
throw new Error("Extension must have metadata.id");
|
|
92
|
-
}
|
|
93
|
-
|
|
145
|
+
const extensionModule = await importExtensionModule(
|
|
146
|
+
path,
|
|
147
|
+
codeTransformer.value,
|
|
148
|
+
extensionPort,
|
|
149
|
+
serverPort,
|
|
150
|
+
);
|
|
151
|
+
validateExtensionModule(extensionModule, extensionAPI.value, loadedExtensions.value);
|
|
94
152
|
const extensionId = extensionModule.metadata.id;
|
|
95
153
|
|
|
96
|
-
if (loadedExtensions.value.has(extensionId)) {
|
|
97
|
-
consola.warn(`[AppStore] Extension "${extensionId}" is already loaded`);
|
|
98
|
-
throw new Error(`Extension "${extensionId}" is already loaded.`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (extensionAPI.value === undefined) {
|
|
102
|
-
throw new Error("Extension API not initialized");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (typeof extensionModule.install !== "function") {
|
|
106
|
-
throw new TypeError("Extension must export an install function");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
154
|
await extensionModule.install(extensionAPI.value, backendPath);
|
|
110
155
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
backendPath,
|
|
116
|
-
loadedAt: new Date().toISOString(),
|
|
117
|
-
metadata: extensionModule.metadata,
|
|
118
|
-
enabled: true,
|
|
119
|
-
};
|
|
120
|
-
loadedExtensions.value.set(extensionId, extensionData);
|
|
156
|
+
loadedExtensions.value.set(
|
|
157
|
+
extensionId,
|
|
158
|
+
createExtensionData(extensionModule, path, backendPath),
|
|
159
|
+
);
|
|
121
160
|
|
|
122
161
|
consola.info(`[AppStore] Extension loaded successfully: ${extensionId}`);
|
|
123
162
|
return extensionModule;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useBasemapBuilds } from "./basemap_helpers/builds.js";
|
|
2
|
+
import { useBasemapLayers } from "./basemap_helpers/layers.js";
|
|
3
|
+
import { useBasemapSettings } from "./basemap_helpers/settings.js";
|
|
4
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
5
|
+
import { useGeoreferenced } from "./basemap_helpers/georeferenced.js";
|
|
6
|
+
|
|
7
|
+
const REBUILD_DELAY_MILLISECONDS = 500;
|
|
8
|
+
|
|
9
|
+
export const useBasemapStore = defineStore("basemap", () => {
|
|
10
|
+
const { available, georeferencedIds, dataBounds, dataKey } = useGeoreferenced();
|
|
11
|
+
const layers = useBasemapLayers(georeferencedIds);
|
|
12
|
+
const { shown, maps, opacities, crop, layersParams, applyLayers, applyBasemap } = layers;
|
|
13
|
+
const { basemapId, grid, attribution, rebuild, reset } = useBasemapBuilds(layers, dataBounds);
|
|
14
|
+
const settings = useBasemapSettings(layers, basemapId, rebuild);
|
|
15
|
+
const { setMaps, setOpacity, setCrop, exportStores, importStores } = settings;
|
|
16
|
+
|
|
17
|
+
const scheduleRebuild = useDebounceFn(() => {
|
|
18
|
+
void rebuild();
|
|
19
|
+
}, REBUILD_DELAY_MILLISECONDS);
|
|
20
|
+
// Rebuilt when the georeferenced data or their extent change: data added, removed, converted,
|
|
21
|
+
// Aligned, or displayed after a project import
|
|
22
|
+
watch(dataKey, () => {
|
|
23
|
+
// A hidden basemap would be out of date once shown again: the rebuild removes it
|
|
24
|
+
if (maps.value.length > 0 || basemapId.value !== undefined) {
|
|
25
|
+
void scheduleRebuild();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
maps,
|
|
31
|
+
shown,
|
|
32
|
+
opacities,
|
|
33
|
+
crop,
|
|
34
|
+
basemapId,
|
|
35
|
+
grid,
|
|
36
|
+
attribution,
|
|
37
|
+
available,
|
|
38
|
+
setMaps,
|
|
39
|
+
setOpacity,
|
|
40
|
+
setCrop,
|
|
41
|
+
rebuild,
|
|
42
|
+
reset,
|
|
43
|
+
layersParams,
|
|
44
|
+
applyLayers,
|
|
45
|
+
applyBasemap,
|
|
46
|
+
exportStores,
|
|
47
|
+
importStores,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type { BasemapSnapshot } from "./basemap_helpers/settings.js";
|
|
52
|
+
export type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
2
|
+
import { useDetailLayers } from "./basemap_helpers/detail_layers.js";
|
|
3
|
+
import { useDetailMap } from "./basemap_helpers/detail_map.js";
|
|
4
|
+
import { useDetailRefresh } from "./basemap_helpers/detail_refresh.js";
|
|
5
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
|
+
|
|
7
|
+
// When the camera rests, the visible area of the basemap at the zoom of the screen
|
|
8
|
+
export const useBasemapDetailStore = defineStore("basemapDetail", () => {
|
|
9
|
+
const basemapStore = useBasemapStore();
|
|
10
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
11
|
+
const detail = useDetailMap();
|
|
12
|
+
const { detailId, newRefresh, forget, clear } = detail;
|
|
13
|
+
const layers = useDetailLayers(detail);
|
|
14
|
+
const { scheduleRefresh, onCameraChange } = useDetailRefresh(detail, layers);
|
|
15
|
+
|
|
16
|
+
watch(() => hybridViewerStore.camera_options, onCameraChange, { deep: true });
|
|
17
|
+
watch(
|
|
18
|
+
() => hybridViewerStore.is_moving,
|
|
19
|
+
(moving) => {
|
|
20
|
+
if (moving) {
|
|
21
|
+
// The result of a refresh started before the move is obsolete
|
|
22
|
+
newRefresh();
|
|
23
|
+
} else {
|
|
24
|
+
scheduleRefresh();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
// A new base (data changed, maps rebuilt) drops the detail, then a new one is built for it
|
|
29
|
+
// Once the camera rests
|
|
30
|
+
watch(
|
|
31
|
+
() => basemapStore.basemapId,
|
|
32
|
+
async (id) => {
|
|
33
|
+
await clear();
|
|
34
|
+
if (id !== undefined) {
|
|
35
|
+
scheduleRefresh();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
watch(() => JSON.stringify(basemapStore.layersParams()), layers.syncLayers);
|
|
40
|
+
// A detail dropped for a missing map, or built while the maps changed, is built again
|
|
41
|
+
watch(() => basemapStore.maps.join(","), scheduleRefresh);
|
|
42
|
+
|
|
43
|
+
// A new project: the viewer and the back are already cleared, nothing is requested
|
|
44
|
+
basemapStore.$onAction(({ name }) => {
|
|
45
|
+
if (name === "reset") {
|
|
46
|
+
forget();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { detailId };
|
|
51
|
+
});
|