@interopio/browser-platform 3.0.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/browser.platform.d.ts +455 -0
- package/changelog.md +69 -0
- package/dist/browser.platform.es.js +46074 -0
- package/dist/browser.platform.es.js.map +1 -0
- package/dist/browser.platform.umd.js +46082 -0
- package/dist/browser.platform.umd.js.map +1 -0
- package/license.md +21 -0
- package/package.json +78 -0
- package/readme.md +9 -0
- package/rollup.config.js +45 -0
- package/src/common/constants.ts +46 -0
- package/src/common/defaultConfig.ts +56 -0
- package/src/common/gateway.d.ts +32 -0
- package/src/common/types.ts +222 -0
- package/src/connection/gateway.ts +132 -0
- package/src/connection/no-gateway.ts +1 -0
- package/src/connection/portsBridge.ts +441 -0
- package/src/connection/preferred.ts +247 -0
- package/src/controllers/domains.ts +156 -0
- package/src/controllers/glue.ts +604 -0
- package/src/controllers/interception.ts +53 -0
- package/src/controllers/license.ts +50 -0
- package/src/controllers/main.ts +256 -0
- package/src/controllers/plugins.ts +121 -0
- package/src/controllers/serviceWorker.ts +193 -0
- package/src/controllers/state.ts +84 -0
- package/src/controllers/system.ts +99 -0
- package/src/controllers/transactions.ts +80 -0
- package/src/factory.ts +40 -0
- package/src/fallbacks/browser.ts +47 -0
- package/src/fallbacks/dekstop.ts +21 -0
- package/src/index.ts +18 -0
- package/src/libs/applications/appStore/directory.ts +235 -0
- package/src/libs/applications/appStore/remoteWatcher.ts +112 -0
- package/src/libs/applications/controller.ts +469 -0
- package/src/libs/applications/decoders.ts +98 -0
- package/src/libs/applications/defaults.ts +6 -0
- package/src/libs/applications/types.ts +98 -0
- package/src/libs/channels/controller.ts +109 -0
- package/src/libs/channels/decoders.ts +19 -0
- package/src/libs/extension/controller.ts +120 -0
- package/src/libs/extension/decoders.ts +18 -0
- package/src/libs/extension/types.ts +11 -0
- package/src/libs/intents/constants.ts +9 -0
- package/src/libs/intents/controller.ts +500 -0
- package/src/libs/intents/decoders.ts +96 -0
- package/src/libs/intents/resolverHelper.ts +264 -0
- package/src/libs/intents/types.ts +119 -0
- package/src/libs/layouts/constants.ts +3 -0
- package/src/libs/layouts/controller.ts +476 -0
- package/src/libs/layouts/decoders.ts +132 -0
- package/src/libs/layouts/global/builder.ts +400 -0
- package/src/libs/layouts/global/resetter.ts +116 -0
- package/src/libs/layouts/global/restorer.ts +217 -0
- package/src/libs/layouts/global/validator.ts +169 -0
- package/src/libs/layouts/idbStore.ts +63 -0
- package/src/libs/layouts/types.ts +133 -0
- package/src/libs/manager/controller.ts +175 -0
- package/src/libs/manager/decoders.ts +6 -0
- package/src/libs/manager/defaults.ts +5 -0
- package/src/libs/manager/identity.ts +92 -0
- package/src/libs/manager/session.ts +195 -0
- package/src/libs/manager/types.ts +51 -0
- package/src/libs/notifications/controller.ts +447 -0
- package/src/libs/notifications/decoders.ts +166 -0
- package/src/libs/notifications/types.ts +49 -0
- package/src/libs/notifications/utils.ts +7 -0
- package/src/libs/search/controller.ts +232 -0
- package/src/libs/search/decoders.ts +6 -0
- package/src/libs/search/repositories/applications.ts +62 -0
- package/src/libs/search/repositories/layouts.ts +48 -0
- package/src/libs/search/repositories/workspaces.ts +47 -0
- package/src/libs/search/types.ts +9 -0
- package/src/libs/themes/constants.ts +9 -0
- package/src/libs/themes/controller.ts +153 -0
- package/src/libs/themes/decoders.ts +28 -0
- package/src/libs/themes/types.ts +28 -0
- package/src/libs/windows/controller.ts +498 -0
- package/src/libs/windows/decoders.ts +64 -0
- package/src/libs/windows/types.ts +59 -0
- package/src/libs/workspaces/controller.ts +922 -0
- package/src/libs/workspaces/decoders.ts +868 -0
- package/src/libs/workspaces/defaultConfig.ts +11 -0
- package/src/libs/workspaces/frames.ts +239 -0
- package/src/libs/workspaces/hibernationWatcher.ts +231 -0
- package/src/libs/workspaces/types.ts +506 -0
- package/src/platform.ts +156 -0
- package/src/shared/decoders.ts +479 -0
- package/src/shared/fetchTimeout.ts +25 -0
- package/src/shared/ioc.ts +580 -0
- package/src/shared/logger.ts +19 -0
- package/src/shared/promisePlus.ts +62 -0
- package/src/shared/sequelizer.ts +48 -0
- package/src/shared/utils.ts +86 -0
- package/src/storage/local.ts +111 -0
- package/src/storage/session.ts +436 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import { IOConnectBrowser } from "@interopio/browser";
|
|
4
|
+
import { IOConnectWorkspaces } from "@interopio/workspaces-api";
|
|
5
|
+
import { BridgeOperation, FocusEventData, InternalPlatformConfig, LibController, OperationCheckConfig, OperationCheckResult } from "../../common/types";
|
|
6
|
+
import { addContainerConfigDecoder, addItemResultDecoder, addWindowConfigDecoder, bundleItemConfigDecoder, bundleWorkspaceConfigDecoder, deleteLayoutConfigDecoder, exportedLayoutsResultDecoder, frameBoundsResultDecoder, frameHelloDecoder, frameInitProtocolConfigDecoder, frameSnapshotConfigDecoder, frameSnapshotResultDecoder, frameStateConfigDecoder, frameStateResultDecoder, frameSummariesResultDecoder, frameSummaryDecoder, frameSummaryResultDecoder, getFrameSummaryConfigDecoder, getWorkspacesLayoutsConfigDecoder, getWorkspacesLayoutsResponseDecoder, getWorkspaceWindowsOnLayoutSaveContextConfigDecoder, getWorkspaceWindowsOnLayoutSaveContextResult, isWindowInSwimlaneResultDecoder, layoutSummariesDecoder, lockContainerDecoder, lockWindowDecoder, lockWorkspaceDecoder, moveFrameConfigDecoder, moveWindowConfigDecoder, openWorkspaceConfigDecoder, pinWorkspaceDecoder, resizeItemConfigDecoder, setItemTitleConfigDecoder, setMaximizationBoundaryConfigDecoder, setWorkspaceIconDecoder, simpleItemConfigDecoder, simpleWindowOperationSuccessResultDecoder, voidResultDecoder, workspaceCreateConfigDecoder, workspaceIconDecoder, workspaceLayoutDecoder, workspaceLayoutSaveConfigDecoder, workspaceSelectorDecoder, workspacesLayoutImportConfigDecoder, workspaceSnapshotResultDecoder, workspacesOperationDecoder, workspaceSummariesResultDecoder } from "./decoders";
|
|
7
|
+
import { FramesController } from "./frames";
|
|
8
|
+
import { AddContainerConfig, AddItemResult, AddWindowConfig, BundleItemConfig, BundleWorkspaceConfig, DeleteLayoutConfig, ExportedLayoutsResult, FrameBoundsResult, FrameHello, FrameInitializationConfigProtocol, FrameQueryConfig, FrameSessionData, FrameSnapshotConfig, FrameSnapshotResult, FrameStateConfig, FrameStateResult, FrameSummariesResult, FrameSummaryResult, GetFrameSummaryConfig, GetWorkspacesLayoutsConfig, GetWorkspacesLayoutsResponse, GetWorkspaceWindowsOnLayoutSaveContextConfig, GetWorkspaceWindowsOnLayoutSaveContextResult, IsWindowInSwimlaneResult, LayoutSummariesResult, LayoutSummary, LockContainerConfig, LockWindowConfig, LockWorkspaceConfig, MoveFrameConfig, MoveWindowConfig, OpenWorkspaceConfig, PinWorkspaceConfig, ResizeItemConfig, SetItemTitleConfig, SetMaximizationBoundaryConfig, SetWorkspaceIconConfig, SimpleItemConfig, SimpleWindowOperationSuccessResult, WorkspaceCreateConfigProtocol, WorkspaceEventPayload, WorkspaceIconResult, WorkspaceSelector, WorkspacesLayoutImportConfig, WorkspaceSnapshotResult, WorkspacesOperationsTypes, WorkspaceStreamData, WorkspaceSummariesResult, WorkspaceSummaryResult, WorkspaceWindowOnSaveData } from "./types";
|
|
9
|
+
import logger from "../../shared/logger";
|
|
10
|
+
import { IOConnectBrowserPlatform } from "../../../browser.platform";
|
|
11
|
+
import { GlueController } from "../../controllers/glue";
|
|
12
|
+
import { IoC } from "../../shared/ioc";
|
|
13
|
+
import { FrameWindowBoundsResult, SimpleWindowCommand, WindowMoveResizeConfig } from "../windows/types";
|
|
14
|
+
import { WindowsStateController } from "../../controllers/state";
|
|
15
|
+
import { WorkspaceHibernationWatcher } from "./hibernationWatcher";
|
|
16
|
+
import { focusEventDataDecoder, operationCheckConfigDecoder, operationCheckResultDecoder, workspacesConfigDecoder } from "../../shared/decoders";
|
|
17
|
+
import deepMerge from "deepmerge";
|
|
18
|
+
import { defaultLoadingConfig } from "./defaultConfig";
|
|
19
|
+
import { PromiseWrap } from "../../shared/promisePlus";
|
|
20
|
+
import { RawWindowsLayoutDataRequestConfig, SaveRequestClientResponse } from "../layouts/types";
|
|
21
|
+
|
|
22
|
+
export class WorkspacesController implements LibController {
|
|
23
|
+
private started = false;
|
|
24
|
+
private settings!: IOConnectBrowserPlatform.Workspaces.Config;
|
|
25
|
+
|
|
26
|
+
private operations: { [key in WorkspacesOperationsTypes]: BridgeOperation } = {
|
|
27
|
+
frameHello: { name: "frameHello", dataDecoder: frameHelloDecoder, execute: this.handleFrameHello.bind(this) },
|
|
28
|
+
isWindowInWorkspace: { name: "isWindowInWorkspace", dataDecoder: simpleItemConfigDecoder, resultDecoder: isWindowInSwimlaneResultDecoder, execute: this.isWindowInWorkspace.bind(this) },
|
|
29
|
+
createWorkspace: { name: "createWorkspace", dataDecoder: workspaceCreateConfigDecoder, resultDecoder: workspaceSnapshotResultDecoder, execute: this.createWorkspace.bind(this) },
|
|
30
|
+
createFrame: { name: "createFrame", resultDecoder: frameSummaryResultDecoder, execute: this.createFrame.bind(this) },
|
|
31
|
+
initFrame: { name: "initFrame", resultDecoder: voidResultDecoder, execute: this.initFrame.bind(this) },
|
|
32
|
+
getAllFramesSummaries: { name: "getAllFramesSummaries", resultDecoder: frameSummariesResultDecoder, execute: this.getAllFramesSummaries.bind(this) },
|
|
33
|
+
getFrameSummary: { name: "getFrameSummary", dataDecoder: getFrameSummaryConfigDecoder, resultDecoder: frameSummaryDecoder, execute: this.getFrameSummary.bind(this) },
|
|
34
|
+
getAllWorkspacesSummaries: { name: "getAllWorkspacesSummaries", resultDecoder: workspaceSummariesResultDecoder, execute: this.getAllWorkspacesSummaries.bind(this) },
|
|
35
|
+
getWorkspaceSnapshot: { name: "getWorkspaceSnapshot", dataDecoder: simpleItemConfigDecoder, resultDecoder: workspaceSnapshotResultDecoder, execute: this.getWorkspaceSnapshot.bind(this) },
|
|
36
|
+
getAllLayoutsSummaries: { name: "getAllLayoutsSummaries", resultDecoder: layoutSummariesDecoder, execute: this.getAllLayoutsSummaries.bind(this) },
|
|
37
|
+
openWorkspace: { name: "openWorkspace", dataDecoder: openWorkspaceConfigDecoder, resultDecoder: workspaceSnapshotResultDecoder, execute: this.openWorkspace.bind(this) },
|
|
38
|
+
deleteLayout: { name: "deleteLayout", dataDecoder: deleteLayoutConfigDecoder, resultDecoder: voidResultDecoder, execute: this.deleteLayout.bind(this) },
|
|
39
|
+
saveLayout: { name: "saveLayout", dataDecoder: workspaceLayoutSaveConfigDecoder, resultDecoder: workspaceLayoutDecoder, execute: this.saveLayout.bind(this) },
|
|
40
|
+
importLayout: { name: "importLayout", dataDecoder: workspacesLayoutImportConfigDecoder, resultDecoder: voidResultDecoder, execute: this.importLayout.bind(this) },
|
|
41
|
+
exportAllLayouts: { name: "exportAllLayouts", resultDecoder: exportedLayoutsResultDecoder, execute: this.exportAllLayouts.bind(this) },
|
|
42
|
+
restoreItem: { name: "restoreItem", dataDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.restoreItem.bind(this) },
|
|
43
|
+
maximizeItem: { name: "maximizeItem", dataDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.maximizeItem.bind(this) },
|
|
44
|
+
focusItem: { name: "focusItem", dataDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.focusItem.bind(this) },
|
|
45
|
+
closeItem: { name: "closeItem", dataDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.closeItem.bind(this) },
|
|
46
|
+
resizeItem: { name: "resizeItem", dataDecoder: resizeItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.resizeItem.bind(this) },
|
|
47
|
+
changeFrameState: { name: "changeFrameState", dataDecoder: frameStateConfigDecoder, resultDecoder: voidResultDecoder, execute: this.changeFrameState.bind(this) },
|
|
48
|
+
getFrameState: { name: "getFrameState", dataDecoder: simpleItemConfigDecoder, resultDecoder: frameStateResultDecoder, execute: this.getFrameState.bind(this) },
|
|
49
|
+
getFrameBounds: { name: "getFrameBounds", dataDecoder: simpleItemConfigDecoder, resultDecoder: frameBoundsResultDecoder, execute: this.getFrameBounds.bind(this) },
|
|
50
|
+
moveFrame: { name: "moveFrame", dataDecoder: moveFrameConfigDecoder, resultDecoder: voidResultDecoder, execute: this.moveFrame.bind(this) },
|
|
51
|
+
getFrameSnapshot: { name: "getFrameSnapshot", dataDecoder: frameSnapshotConfigDecoder, resultDecoder: frameSnapshotResultDecoder, execute: this.getFrameSnapshot.bind(this) },
|
|
52
|
+
forceLoadWindow: { name: "forceLoadWindow", dataDecoder: simpleItemConfigDecoder, resultDecoder: simpleWindowOperationSuccessResultDecoder, execute: this.forceLoadWindow.bind(this) },
|
|
53
|
+
ejectWindow: { name: "ejectWindow", dataDecoder: simpleItemConfigDecoder, resultDecoder: simpleWindowOperationSuccessResultDecoder, execute: this.ejectWindow.bind(this) },
|
|
54
|
+
setItemTitle: { name: "setItemTitle", dataDecoder: setItemTitleConfigDecoder, resultDecoder: voidResultDecoder, execute: this.setItemTitle.bind(this) },
|
|
55
|
+
moveWindowTo: { name: "moveWindowTo", dataDecoder: moveWindowConfigDecoder, resultDecoder: voidResultDecoder, execute: this.moveWindowTo.bind(this) },
|
|
56
|
+
addWindow: { name: "addWindow", dataDecoder: addWindowConfigDecoder, resultDecoder: addItemResultDecoder, execute: this.addWindow.bind(this) },
|
|
57
|
+
addContainer: { name: "addContainer", dataDecoder: addContainerConfigDecoder, resultDecoder: addItemResultDecoder, execute: this.addContainer.bind(this) },
|
|
58
|
+
bundleWorkspace: { name: "bundleWorkspace", dataDecoder: bundleWorkspaceConfigDecoder, resultDecoder: voidResultDecoder, execute: this.bundleWorkspace.bind(this) },
|
|
59
|
+
bundleItem: { name: "bundleItem", dataDecoder: bundleItemConfigDecoder, resultDecoder: voidResultDecoder, execute: this.bundleItem.bind(this) },
|
|
60
|
+
hibernateWorkspace: { name: "hibernateWorkspace", dataDecoder: workspaceSelectorDecoder, resultDecoder: voidResultDecoder, execute: this.hibernateWorkspace.bind(this) },
|
|
61
|
+
resumeWorkspace: { name: "resumeWorkspace", dataDecoder: workspaceSelectorDecoder, resultDecoder: voidResultDecoder, execute: this.resumeWorkspace.bind(this) },
|
|
62
|
+
getWorkspacesConfig: { name: "getWorkspacesConfig", resultDecoder: workspacesConfigDecoder, execute: this.getWorkspacesConfiguration.bind(this) },
|
|
63
|
+
lockWorkspace: { name: "lockWorkspace", dataDecoder: lockWorkspaceDecoder, resultDecoder: voidResultDecoder, execute: this.lockWorkspace.bind(this) },
|
|
64
|
+
lockWindow: { name: "lockWindow", dataDecoder: lockWindowDecoder, resultDecoder: voidResultDecoder, execute: this.lockWindow.bind(this) },
|
|
65
|
+
lockContainer: { name: "lockContainer", dataDecoder: lockContainerDecoder, resultDecoder: voidResultDecoder, execute: this.lockContainer.bind(this) },
|
|
66
|
+
pinWorkspace: { name: "pinWorkspace", dataDecoder: pinWorkspaceDecoder, resultDecoder: voidResultDecoder, execute: this.pinWorkspace.bind(this) },
|
|
67
|
+
unpinWorkspace: { name: "unpinWorkspace", dataDecoder: workspaceSelectorDecoder, resultDecoder: voidResultDecoder, execute: this.unpinWorkspace.bind(this) },
|
|
68
|
+
getWorkspaceIcon: { name: "getWorkspaceIcon", dataDecoder: workspaceSelectorDecoder, resultDecoder: workspaceIconDecoder, execute: this.getWorkspaceIcon.bind(this) },
|
|
69
|
+
setWorkspaceIcon: { name: "setWorkspaceIcon", dataDecoder: setWorkspaceIconDecoder, resultDecoder: voidResultDecoder, execute: this.setWorkspaceIcon.bind(this) },
|
|
70
|
+
checkStarted: { name: "checkStarted", execute: this.handleCheckStarted.bind(this) },
|
|
71
|
+
getPlatformFrameId: { name: "getPlatformFrameId", execute: this.handleGetPlatformFrameId.bind(this) },
|
|
72
|
+
getWorkspacesLayouts: { name: "getWorkspacesLayouts", dataDecoder: getWorkspacesLayoutsConfigDecoder, resultDecoder: getWorkspacesLayoutsResponseDecoder, execute: this.handleGetWorkspacesLayouts.bind(this) },
|
|
73
|
+
getWorkspaceWindowsOnLayoutSaveContext: { name: "getWorkspaceWindowsOnLayoutSaveContext", dataDecoder: getWorkspaceWindowsOnLayoutSaveContextConfigDecoder, resultDecoder: getWorkspaceWindowsOnLayoutSaveContextResult, execute: this.handleGetWorkspaceWindowsOnLayoutSaveContext.bind(this) },
|
|
74
|
+
setMaximizationBoundary: { name: "setMaximizationBoundary", dataDecoder: setMaximizationBoundaryConfigDecoder, resultDecoder: voidResultDecoder, execute: this.handleSetMaximizationBoundary.bind(this) },
|
|
75
|
+
operationCheck: { name: "operationCheck", dataDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder, execute: this.handleOperationCheck.bind(this) },
|
|
76
|
+
getWorkspaceWindowFrameBounds: { name: "getWorkspaceWindowFrameBounds", resultDecoder: frameBoundsResultDecoder, dataDecoder: simpleItemConfigDecoder, execute: this.getWorkspaceWindowFrameBounds.bind(this) },
|
|
77
|
+
focusChange: { name: "focusChange", dataDecoder: focusEventDataDecoder, execute: this.handleFocusEvent.bind(this) }
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
constructor(
|
|
81
|
+
private readonly framesController: FramesController,
|
|
82
|
+
private readonly glueController: GlueController,
|
|
83
|
+
private readonly stateController: WindowsStateController,
|
|
84
|
+
private readonly hibernationWatcher: WorkspaceHibernationWatcher,
|
|
85
|
+
private readonly ioc: IoC
|
|
86
|
+
) {}
|
|
87
|
+
|
|
88
|
+
public handlePlatformShutdown(): void {
|
|
89
|
+
this.started = false;
|
|
90
|
+
this.hibernationWatcher.stop();
|
|
91
|
+
this.framesController.stop();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public async start(config: InternalPlatformConfig): Promise<void> {
|
|
95
|
+
if (!config.workspaces) {
|
|
96
|
+
this.started = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.settings = this.applyDefaults(config.workspaces);
|
|
101
|
+
|
|
102
|
+
if (this.settings.hibernation) {
|
|
103
|
+
this.hibernationWatcher.start(this, this.settings.hibernation);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
await Promise.all([
|
|
107
|
+
this.glueController.createWorkspacesStream(),
|
|
108
|
+
this.glueController.createWorkspacesEventsReceiver(this.bridgeWorkspaceEvent.bind(this))
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
await this.framesController.start(config.workspaces, config.windows.defaultWindowOpenBounds, this.operations.getFrameSummary);
|
|
112
|
+
|
|
113
|
+
this.stateController.onWindowDisappeared((windowId) => this.framesController.handleFrameDisappeared(windowId));
|
|
114
|
+
|
|
115
|
+
this.started = true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private get logger(): IOConnectBrowser.Logger.API | undefined {
|
|
119
|
+
return logger.get("workspaces.controller");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public async handleControl(args: any): Promise<any> {
|
|
123
|
+
if (!this.started) {
|
|
124
|
+
throw new Error("Cannot handle this workspaces control message, because the controller has not been started");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const workspacesData = args.data;
|
|
128
|
+
|
|
129
|
+
const commandId = args.commandId;
|
|
130
|
+
|
|
131
|
+
const operationValidation = workspacesOperationDecoder.run(args.operation);
|
|
132
|
+
|
|
133
|
+
if (!operationValidation.ok) {
|
|
134
|
+
throw new Error(`This workspace request cannot be completed, because the operation name did not pass validation: ${JSON.stringify(operationValidation.error)}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const operationName: WorkspacesOperationsTypes = operationValidation.result;
|
|
138
|
+
|
|
139
|
+
const incomingValidation = this.operations[operationName].dataDecoder?.run(workspacesData);
|
|
140
|
+
|
|
141
|
+
if (incomingValidation && !incomingValidation.ok) {
|
|
142
|
+
throw new Error(`Workspace request for ${operationName} rejected, because the provided arguments did not pass the validation: ${JSON.stringify(incomingValidation.error)}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.logger?.debug(`[${commandId}] ${operationName} command is valid with data: ${JSON.stringify(workspacesData)}`);
|
|
146
|
+
|
|
147
|
+
const result = await this.operations[operationName].execute(workspacesData, commandId);
|
|
148
|
+
|
|
149
|
+
const resultValidation = this.operations[operationName].resultDecoder?.run(result);
|
|
150
|
+
|
|
151
|
+
if (resultValidation && !resultValidation.ok) {
|
|
152
|
+
throw new Error(`Workspace request for ${operationName} could not be completed, because the operation result did not pass the validation: ${JSON.stringify(resultValidation.error)}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.logger?.trace(`[${commandId}] ${operationName} command was executed successfully`);
|
|
156
|
+
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public handleClientUnloaded(windowId: string, win: Window): void {
|
|
161
|
+
this.logger?.trace(`handling unloading of ${windowId}`);
|
|
162
|
+
|
|
163
|
+
if (!win || win.closed) {
|
|
164
|
+
this.logger?.trace(`${windowId} detected as closed, checking if frame and processing close`);
|
|
165
|
+
this.framesController.handleFrameDisappeared(windowId);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public bridgeWorkspaceEvent(data: WorkspaceEventPayload): void {
|
|
170
|
+
this.glueController.pushWorkspacesMessage(data);
|
|
171
|
+
|
|
172
|
+
if (data.action === "closed" && data.type === "workspace") {
|
|
173
|
+
this.glueController.clearContext((data as any).payload.workspaceSummary.id as string, "workspace");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (this.settings.hibernation) {
|
|
177
|
+
this.hibernationWatcher.notifyEvent(data);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public async closeItem(config: SimpleItemConfig, commandId: string): Promise<void> {
|
|
183
|
+
this.logger?.trace(`[${commandId}] handling closeItem request with config ${JSON.stringify(config)}`);
|
|
184
|
+
|
|
185
|
+
const frameToFocus = this.framesController.getAll().find((frame) => frame.windowId === config.itemId);
|
|
186
|
+
|
|
187
|
+
if (frameToFocus) {
|
|
188
|
+
this.logger?.trace(`[${commandId}] this is targeted at a frame, closing the frame`);
|
|
189
|
+
|
|
190
|
+
window.open(undefined, frameToFocus.windowId)?.close();
|
|
191
|
+
|
|
192
|
+
this.logger?.trace(`[${commandId}] the frame window is closed`);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
197
|
+
|
|
198
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
199
|
+
|
|
200
|
+
await this.glueController.callFrame<SimpleItemConfig, void>(this.operations.closeItem, config, frame.windowId);
|
|
201
|
+
|
|
202
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public async setItemTitle(config: SetItemTitleConfig, commandId: string): Promise<void> {
|
|
206
|
+
this.logger?.trace(`[${commandId}] handling setItemTitle request with config ${JSON.stringify(config)}`);
|
|
207
|
+
|
|
208
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
209
|
+
|
|
210
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
211
|
+
|
|
212
|
+
await this.glueController.callFrame<SetItemTitleConfig, void>(this.operations.setItemTitle, config, frame.windowId);
|
|
213
|
+
|
|
214
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public async hibernateWorkspace(config: WorkspaceSelector, commandId: string): Promise<void> {
|
|
218
|
+
this.logger?.trace(`[${commandId}] handling hibernateWorkspace request with config ${JSON.stringify(config)}`);
|
|
219
|
+
|
|
220
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
221
|
+
|
|
222
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
223
|
+
|
|
224
|
+
await this.glueController.preserveAllWorkspaceWindowsContext(config.workspaceId);
|
|
225
|
+
|
|
226
|
+
await this.glueController.callFrame<WorkspaceSelector, void>(this.operations.hibernateWorkspace, config, frame.windowId);
|
|
227
|
+
|
|
228
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public async getWorkspacesConfiguration(config: unknown, commandId: string): Promise<IOConnectBrowserPlatform.Workspaces.Config> {
|
|
232
|
+
this.logger?.trace(`[${commandId}] handling getWorkspacesConfiguration request`);
|
|
233
|
+
|
|
234
|
+
return this.settings;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public async getWorkspaceWindowFrameBounds(config: SimpleItemConfig, commandId: string): Promise<FrameBoundsResult> {
|
|
238
|
+
this.logger?.trace(`[${commandId}] handling getWorkspaceWindowFrameBounds request with config ${JSON.stringify(config)}`);
|
|
239
|
+
|
|
240
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.itemId });
|
|
241
|
+
|
|
242
|
+
const frameWindowBounds = await this.glueController.callWindow<SimpleWindowCommand, FrameWindowBoundsResult>("windows", this.ioc.windowsController.getFrameBoundsOperation, { windowId: frame.windowId }, { windowId: frame.windowId });
|
|
243
|
+
|
|
244
|
+
this.logger?.trace(`[${commandId}] getWorkspaceWindowFrameBounds completed`);
|
|
245
|
+
|
|
246
|
+
return { bounds: frameWindowBounds.bounds };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public async getAllFramesSummaries(config: unknown, commandId: string): Promise<FrameSummariesResult> {
|
|
250
|
+
this.logger?.trace(`[${commandId}] handling getAllFramesSummaries request`);
|
|
251
|
+
|
|
252
|
+
if (!this.started) {
|
|
253
|
+
return { summaries: [] };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const allFrames = await this.framesController.getAll();
|
|
257
|
+
|
|
258
|
+
this.logger?.trace(`[${commandId}] sending getFrameSummary to all known frames: ${allFrames.join(", ")}`);
|
|
259
|
+
|
|
260
|
+
const summaries = await Promise.all(allFrames.map((frame) => this.glueController.callFrame<GetFrameSummaryConfig, FrameSummaryResult>(
|
|
261
|
+
this.operations.getFrameSummary, { itemId: frame.windowId }, frame.windowId
|
|
262
|
+
)));
|
|
263
|
+
|
|
264
|
+
const verifiedSummaries = summaries.filter((sum) => sum.id !== "none");
|
|
265
|
+
|
|
266
|
+
this.logger?.trace(`[${commandId}] all frames responded, returning to caller`);
|
|
267
|
+
|
|
268
|
+
return { summaries: verifiedSummaries };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private async handleOperationCheck(config: OperationCheckConfig): Promise<OperationCheckResult> {
|
|
272
|
+
const operations = Object.keys(this.operations);
|
|
273
|
+
|
|
274
|
+
const isSupported = operations.some((operation) => operation.toLowerCase() === config.operation.toLowerCase());
|
|
275
|
+
|
|
276
|
+
return { isSupported };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private async handleFrameHello(config: FrameHello, commandId: string): Promise<void> {
|
|
280
|
+
this.logger?.trace(`[${commandId}] handling handleFrameHello command with config: ${JSON.stringify(config)}`);
|
|
281
|
+
|
|
282
|
+
if (config.windowId) {
|
|
283
|
+
this.framesController.processNewHello(config.windowId);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private async isWindowInWorkspace(config: SimpleItemConfig, commandId: string): Promise<IsWindowInSwimlaneResult> {
|
|
288
|
+
this.logger?.trace(`[${commandId}] handling isWindowInWorkspace command with config: ${JSON.stringify(config)}`);
|
|
289
|
+
|
|
290
|
+
const allFrames = this.framesController.getAll();
|
|
291
|
+
|
|
292
|
+
this.logger?.trace(`[${commandId}] sending isWindowInWorkspace to all known frames: ${JSON.stringify(allFrames.join(", "))}`);
|
|
293
|
+
|
|
294
|
+
const result = await Promise.all(allFrames.map((frame) => this.glueController.callFrame<SimpleItemConfig, IsWindowInSwimlaneResult>(
|
|
295
|
+
this.operations.isWindowInWorkspace, config, frame.windowId
|
|
296
|
+
)));
|
|
297
|
+
|
|
298
|
+
const inWorkspace = result.some((res) => res.inWorkspace);
|
|
299
|
+
|
|
300
|
+
this.logger?.trace(`[${commandId}] all frames responded, returning ${inWorkspace} to the caller`);
|
|
301
|
+
|
|
302
|
+
return { inWorkspace };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private async createWorkspace(config: WorkspaceCreateConfigProtocol, commandId: string): Promise<WorkspaceSnapshotResult> {
|
|
306
|
+
this.logger?.trace(`[${commandId}] handling createWorkspace command`);
|
|
307
|
+
|
|
308
|
+
const frameInstanceConfig = {
|
|
309
|
+
frameId: config.frame?.reuseFrameId,
|
|
310
|
+
newFrame: config.frame?.newFrame,
|
|
311
|
+
itemId: config.config?.reuseWorkspaceId
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const frame = await this.framesController.getFrameInstance(frameInstanceConfig);
|
|
315
|
+
|
|
316
|
+
this.logger?.trace(`[${commandId}] calling frame: ${frame.windowId}, based on selection config: ${JSON.stringify(frameInstanceConfig)}`);
|
|
317
|
+
|
|
318
|
+
const result = await this.glueController.callFrame<WorkspaceCreateConfigProtocol, WorkspaceSnapshotResult>(this.operations.createWorkspace, config, frame.windowId);
|
|
319
|
+
|
|
320
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded with a valid snapshot, returning to caller`);
|
|
321
|
+
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private async createFrame(config: IOConnectWorkspaces.EmptyFrameDefinition, commandId: string): Promise<FrameSummaryResult> {
|
|
326
|
+
this.logger?.trace(`[${commandId}] handling createFrame command`);
|
|
327
|
+
|
|
328
|
+
const frame = await this.framesController.openFrame(config.frameConfig, config.layoutComponentId);
|
|
329
|
+
|
|
330
|
+
this.logger?.trace(`[${commandId}] calling frame: ${frame.windowId}}`);
|
|
331
|
+
const result = await this.glueController.callFrame<IOConnectWorkspaces.EmptyFrameDefinition, FrameSummaryResult>(this.operations.createFrame, config, frame.windowId);
|
|
332
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded returning to caller`);
|
|
333
|
+
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private async initFrame(config: FrameInitializationConfigProtocol, commandId: string): Promise<void> {
|
|
338
|
+
this.logger?.trace(`[${commandId}] handling initFrame command`);
|
|
339
|
+
|
|
340
|
+
const frameInstanceConfig = {
|
|
341
|
+
frameId: config.frameId
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const frame = await this.framesController.getFrameInstance(frameInstanceConfig);
|
|
345
|
+
|
|
346
|
+
this.logger?.trace(`[${commandId}] calling frame: ${frame.windowId}, based on selection config: ${JSON.stringify(frameInstanceConfig)}`);
|
|
347
|
+
|
|
348
|
+
await this.glueController.callFrame<FrameInitializationConfigProtocol, void>(this.operations.initFrame, config, frame.windowId);
|
|
349
|
+
|
|
350
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded returning to caller`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private async getFrameSummary(config: GetFrameSummaryConfig, commandId: string): Promise<FrameSummaryResult> {
|
|
354
|
+
this.logger?.trace(`[${commandId}] handling getFrameSummary request for config: ${JSON.stringify(config)}`);
|
|
355
|
+
|
|
356
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
357
|
+
|
|
358
|
+
this.logger?.trace(`[${commandId}] forwarding getFrameSummary to frame ${frame.windowId}`);
|
|
359
|
+
|
|
360
|
+
const summary = await this.glueController.callFrame<GetFrameSummaryConfig, FrameSummaryResult>(this.operations.getFrameSummary, config, frame.windowId);
|
|
361
|
+
|
|
362
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded with a valid summary, returning to caller`);
|
|
363
|
+
|
|
364
|
+
return summary;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
public async getAllWorkspacesSummaries(config: unknown, commandId: string): Promise<WorkspaceSummariesResult> {
|
|
368
|
+
this.logger?.trace(`[${commandId}] handling getAllWorkspacesSummaries request`);
|
|
369
|
+
|
|
370
|
+
const allFrames = this.framesController.getAll();
|
|
371
|
+
|
|
372
|
+
this.logger?.trace(`[${commandId}] sending getAllWorkspacesSummaries to all known frames: ${allFrames.join(", ")}`);
|
|
373
|
+
|
|
374
|
+
const results = await Promise.all(allFrames.map((frame) => this.glueController.callFrame<object, WorkspaceSummariesResult>(
|
|
375
|
+
this.operations.getAllWorkspacesSummaries, {}, frame.windowId
|
|
376
|
+
)));
|
|
377
|
+
|
|
378
|
+
const summaries = results.reduce<WorkspaceSummaryResult[]>((soFar, result) => {
|
|
379
|
+
|
|
380
|
+
soFar.push(...result.summaries);
|
|
381
|
+
|
|
382
|
+
return soFar;
|
|
383
|
+
}, []);
|
|
384
|
+
|
|
385
|
+
this.logger?.trace(`[${commandId}] all frames responded, results were aggregated, returning to caller`);
|
|
386
|
+
|
|
387
|
+
return { summaries };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public async getWorkspaceSnapshot(config: SimpleItemConfig, commandId: string): Promise<WorkspaceSnapshotResult> {
|
|
391
|
+
this.logger?.trace(`[${commandId}] handling getWorkspaceSnapshot for config: ${JSON.stringify(config)}`);
|
|
392
|
+
|
|
393
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
394
|
+
|
|
395
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
396
|
+
|
|
397
|
+
const result = await this.glueController.callFrame<SimpleItemConfig, WorkspaceSnapshotResult>(this.operations.getWorkspaceSnapshot, config, frame.windowId);
|
|
398
|
+
|
|
399
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded with a valid snapshot, retuning to caller`);
|
|
400
|
+
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
public async handleCheckStarted(config: unknown, commandId: string): Promise<{ started: boolean }> {
|
|
405
|
+
this.logger?.trace(`[${commandId}] handling handleCheckStarted request`);
|
|
406
|
+
|
|
407
|
+
this.logger?.trace(`[${commandId}] the controller has been started, responding to caller`);
|
|
408
|
+
|
|
409
|
+
return { started: true };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
public async handleGetPlatformFrameId(config: unknown, commandId: string): Promise<{ id?: string }> {
|
|
413
|
+
this.logger?.trace(`[${commandId}] handling GetPlatformFrameId request`);
|
|
414
|
+
|
|
415
|
+
const platformFrameData = this.framesController.getPlatformFrameSessionData();
|
|
416
|
+
|
|
417
|
+
this.logger?.trace(`[${commandId}] GetPlatformFrameId completed, responding to caller`);
|
|
418
|
+
|
|
419
|
+
return { id: platformFrameData?.windowId };
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
public async getFrameSessionData(config: { frameId: string }, commandId: string): Promise<FrameSessionData | undefined> {
|
|
423
|
+
this.logger?.trace(`[${commandId}] handling getFrameSessionData request`);
|
|
424
|
+
|
|
425
|
+
const data = this.framesController.getFrameConfig(config.frameId);
|
|
426
|
+
|
|
427
|
+
this.logger?.trace(`[${commandId}] getFrameSessionData completed, responding to caller`);
|
|
428
|
+
|
|
429
|
+
return data;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
public async handleGetWorkspacesLayouts(config: GetWorkspacesLayoutsConfig, commandId: string): Promise<GetWorkspacesLayoutsResponse> {
|
|
433
|
+
this.logger?.trace(`[${commandId}] handling handleGetWorkspacesLayouts request for frame: ${config.frameId} for layout: ${config.layoutName} of type: ${config.layoutType}`);
|
|
434
|
+
|
|
435
|
+
const response = await this.glueController.callFrame<GetWorkspacesLayoutsConfig, GetWorkspacesLayoutsResponse>(this.operations.getWorkspacesLayouts, config, config.frameId);
|
|
436
|
+
|
|
437
|
+
this.logger?.trace(`[${commandId}] handleGetWorkspacesLayouts request completed for frame: ${config.frameId} for layout: ${config.layoutName} of type: ${config.layoutType}`);
|
|
438
|
+
|
|
439
|
+
return response;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
public async getFrameBounds(config: SimpleItemConfig, commandId: string): Promise<FrameBoundsResult> {
|
|
443
|
+
this.logger?.trace(`[${commandId}] handling getFrameBounds request with config ${JSON.stringify(config)}`);
|
|
444
|
+
|
|
445
|
+
const frame = await this.framesController.getFrameInstance({ frameId: config.itemId });
|
|
446
|
+
|
|
447
|
+
const frameWindowBounds = await this.glueController.callWindow<SimpleWindowCommand, FrameWindowBoundsResult>("windows", this.ioc.windowsController.getFrameBoundsOperation, { windowId: frame.windowId }, { windowId: frame.windowId });
|
|
448
|
+
|
|
449
|
+
this.logger?.trace(`[${commandId}] getFrameBounds completed`);
|
|
450
|
+
|
|
451
|
+
return { bounds: frameWindowBounds.bounds };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
private async getAllLayoutsSummaries(config: unknown, commandId: string): Promise<LayoutSummariesResult> {
|
|
455
|
+
this.logger?.trace(`[${commandId}] handling getAllLayoutsSummaries command`);
|
|
456
|
+
|
|
457
|
+
const all = await this.ioc.layoutsController.handleGetAll({ type: "Workspace" }, commandId);
|
|
458
|
+
|
|
459
|
+
const summaries = all.summaries.map<LayoutSummary>((summary) => ({ name: summary.name }));
|
|
460
|
+
|
|
461
|
+
this.logger?.trace(`[${commandId}] all layouts retrieved and mapped, returning to caller`);
|
|
462
|
+
|
|
463
|
+
return { summaries };
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private async openWorkspace(config: OpenWorkspaceConfig, commandId: string): Promise<WorkspaceSnapshotResult> {
|
|
467
|
+
this.logger?.trace(`[${commandId}] handling openWorkspace command for name: ${config.name}`);
|
|
468
|
+
|
|
469
|
+
const frameQueryConfig = {
|
|
470
|
+
frameId: config.restoreOptions?.frameId,
|
|
471
|
+
newFrame: config.restoreOptions?.newFrame,
|
|
472
|
+
itemId: config.restoreOptions?.reuseWorkspaceId
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const frame = await this.framesController.getFrameInstance(frameQueryConfig);
|
|
476
|
+
|
|
477
|
+
const result = await this.glueController.callFrame<OpenWorkspaceConfig, WorkspaceSnapshotResult>(this.operations.openWorkspace, config, frame.windowId);
|
|
478
|
+
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
private async deleteLayout(config: DeleteLayoutConfig, commandId: string): Promise<void> {
|
|
483
|
+
this.logger?.trace(`[${commandId}] handling deleteLayout request for name: ${config.name}`);
|
|
484
|
+
|
|
485
|
+
await this.ioc.layoutsController.handleRemove({ name: config.name, type: "Workspace" }, commandId);
|
|
486
|
+
|
|
487
|
+
this.logger?.trace(`[${commandId}] layouts reported this layout as deleted, responding to caller`);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
private async saveLayout(config: IOConnectWorkspaces.WorkspaceLayoutSaveConfig, commandId: string): Promise<IOConnectWorkspaces.WorkspaceLayout> {
|
|
491
|
+
this.logger?.trace(`[${commandId}] handling saveLayout request for workspace ${config.workspaceId} and name ${config.name}`);
|
|
492
|
+
|
|
493
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
494
|
+
|
|
495
|
+
this.logger?.trace(`[${commandId}] forwarding request to frame ${frame.windowId}`);
|
|
496
|
+
|
|
497
|
+
const result = await this.glueController.callFrame<IOConnectWorkspaces.WorkspaceLayoutSaveConfig, IOConnectWorkspaces.WorkspaceLayout>(
|
|
498
|
+
this.operations.saveLayout, config, frame.windowId
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} responded with a valid layout, returning to caller`);
|
|
502
|
+
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
private async importLayout(config: WorkspacesLayoutImportConfig, commandId: string): Promise<void> {
|
|
507
|
+
this.logger?.trace(`[${commandId}] handling importLayout command for layout ${config.layout.name}`);
|
|
508
|
+
|
|
509
|
+
await this.ioc.layoutsController.handleImport({ layouts: [config.layout], mode: config.mode }, commandId);
|
|
510
|
+
|
|
511
|
+
this.logger?.trace(`[${commandId}] the layouts controller successfully imported the layout, responding to caller`);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
private async exportAllLayouts(config: unknown, commandId: string): Promise<ExportedLayoutsResult> {
|
|
515
|
+
this.logger?.trace(`[${commandId}] handling exportAllLayouts request`);
|
|
516
|
+
|
|
517
|
+
const result = await this.ioc.layoutsController.handleExport({ type: "Workspace" }, commandId);
|
|
518
|
+
|
|
519
|
+
return result as ExportedLayoutsResult;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
private async restoreItem(config: SimpleItemConfig, commandId: string): Promise<void> {
|
|
523
|
+
this.logger?.trace(`[${commandId}] handling restoreItem request with config ${JSON.stringify(config)}`);
|
|
524
|
+
|
|
525
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
526
|
+
|
|
527
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
528
|
+
|
|
529
|
+
await this.glueController.callFrame<SimpleItemConfig, void>(this.operations.restoreItem, config, frame.windowId);
|
|
530
|
+
|
|
531
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
private async maximizeItem(config: SimpleItemConfig, commandId: string): Promise<void> {
|
|
535
|
+
this.logger?.trace(`[${commandId}] handling maximizeItem request with config ${JSON.stringify(config)}`);
|
|
536
|
+
|
|
537
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
538
|
+
|
|
539
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
540
|
+
|
|
541
|
+
await this.glueController.callFrame<SimpleItemConfig, void>(this.operations.maximizeItem, config, frame.windowId);
|
|
542
|
+
|
|
543
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
private async focusItem(config: SimpleItemConfig, commandId: string): Promise<void> {
|
|
547
|
+
this.logger?.trace(`[${commandId}] handling focusItem request with config ${JSON.stringify(config)}`);
|
|
548
|
+
|
|
549
|
+
const frameToFocus = this.framesController.getAll().find((frame) => frame.windowId === config.itemId);
|
|
550
|
+
|
|
551
|
+
if (frameToFocus) {
|
|
552
|
+
this.logger?.trace(`[${commandId}] this is targeted at a frame, focusing the frame`);
|
|
553
|
+
window.open(undefined, frameToFocus.windowId);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
558
|
+
|
|
559
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
560
|
+
|
|
561
|
+
await this.glueController.callFrame<SimpleItemConfig, void>(this.operations.focusItem, config, frame.windowId);
|
|
562
|
+
|
|
563
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
private async resizeItem(config: ResizeItemConfig, commandId: string): Promise<void> {
|
|
567
|
+
this.logger?.trace(`[${commandId}] handling resizeItem request with config ${JSON.stringify(config)}`);
|
|
568
|
+
|
|
569
|
+
const targetedFrame = this.framesController.getAll().find((fr) => fr.windowId === config.itemId);
|
|
570
|
+
|
|
571
|
+
if (targetedFrame) {
|
|
572
|
+
this.logger?.trace(`[${commandId}] detected targeted item is frame, building window resize config`);
|
|
573
|
+
|
|
574
|
+
const resizeConfig: WindowMoveResizeConfig = {
|
|
575
|
+
windowId: config.itemId,
|
|
576
|
+
width: config.width,
|
|
577
|
+
height: config.height,
|
|
578
|
+
relative: config.relative
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
await this.glueController.callWindow<WindowMoveResizeConfig, void>("windows", this.ioc.windowsController.moveResizeOperation, resizeConfig, { windowId: targetedFrame.windowId });
|
|
582
|
+
|
|
583
|
+
this.logger?.trace(`[${commandId}] window resize responded with success, returning to caller`);
|
|
584
|
+
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
589
|
+
|
|
590
|
+
this.logger?.trace(`[${commandId}] targeted item is not a frame, it is located in frame ${frame.windowId}`);
|
|
591
|
+
|
|
592
|
+
await this.glueController.callFrame<ResizeItemConfig, void>(this.operations.resizeItem, config, frame.windowId);
|
|
593
|
+
|
|
594
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
private async getFrameSnapshot(config: FrameSnapshotConfig, commandId: string): Promise<FrameSnapshotResult> {
|
|
598
|
+
this.logger?.trace(`[${commandId}] handling getFrameSnapshot request with config ${JSON.stringify(config)}`);
|
|
599
|
+
|
|
600
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
601
|
+
|
|
602
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
603
|
+
|
|
604
|
+
const result = await this.glueController.callFrame<FrameSnapshotConfig, FrameSnapshotResult>(this.operations.getFrameSnapshot, config, frame.windowId);
|
|
605
|
+
|
|
606
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
607
|
+
|
|
608
|
+
return result;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private async forceLoadWindow(config: SimpleItemConfig, commandId: string): Promise<SimpleWindowOperationSuccessResult> {
|
|
612
|
+
this.logger?.trace(`[${commandId}] handling forceLoadWindow request with config ${JSON.stringify(config)}`);
|
|
613
|
+
|
|
614
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
615
|
+
|
|
616
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
617
|
+
|
|
618
|
+
const result = await this.glueController.callFrame<SimpleItemConfig, SimpleWindowOperationSuccessResult>(this.operations.forceLoadWindow, config, frame.windowId);
|
|
619
|
+
|
|
620
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
621
|
+
|
|
622
|
+
return result;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
private async ejectWindow(config: SimpleItemConfig, commandId: string): Promise<SimpleWindowOperationSuccessResult> {
|
|
626
|
+
this.logger?.trace(`[${commandId}] handling ejectWindow request with config ${JSON.stringify(config)}`);
|
|
627
|
+
|
|
628
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
629
|
+
|
|
630
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
631
|
+
|
|
632
|
+
const result = await this.glueController.callFrame<SimpleItemConfig, SimpleWindowOperationSuccessResult>(this.operations.ejectWindow, config, frame.windowId);
|
|
633
|
+
|
|
634
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
635
|
+
|
|
636
|
+
return result;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
private async moveWindowTo(config: MoveWindowConfig, commandId: string): Promise<void> {
|
|
640
|
+
this.logger?.trace(`[${commandId}] handling moveWindowTo request with config ${JSON.stringify(config)}`);
|
|
641
|
+
|
|
642
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
643
|
+
|
|
644
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
645
|
+
|
|
646
|
+
await this.glueController.callFrame<MoveWindowConfig, void>(this.operations.moveWindowTo, config, frame.windowId);
|
|
647
|
+
|
|
648
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
private async addWindow(config: AddWindowConfig, commandId: string): Promise<AddItemResult> {
|
|
652
|
+
this.logger?.trace(`[${commandId}] handling addWindow request with config ${JSON.stringify(config)}`);
|
|
653
|
+
|
|
654
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.parentId });
|
|
655
|
+
|
|
656
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
657
|
+
|
|
658
|
+
const result = await this.glueController.callFrame<AddWindowConfig, AddItemResult>(this.operations.addWindow, config, frame.windowId);
|
|
659
|
+
|
|
660
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal: ${JSON.stringify(result)}, responding to caller`);
|
|
661
|
+
|
|
662
|
+
return result;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
private async addContainer(config: AddContainerConfig, commandId: string): Promise<AddItemResult> {
|
|
666
|
+
this.logger?.trace(`[${commandId}] handling addContainer request with config ${JSON.stringify(config)}`);
|
|
667
|
+
|
|
668
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.parentId });
|
|
669
|
+
|
|
670
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
671
|
+
|
|
672
|
+
const result = await this.glueController.callFrame<AddContainerConfig, AddItemResult>(this.operations.addContainer, config, frame.windowId);
|
|
673
|
+
|
|
674
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal: ${JSON.stringify(result)}, responding to caller`);
|
|
675
|
+
|
|
676
|
+
return result;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
private async bundleWorkspace(config: BundleWorkspaceConfig, commandId: string): Promise<void> {
|
|
680
|
+
this.logger?.trace(`[${commandId}] handling bundleWorkspace request with config ${JSON.stringify(config)}`);
|
|
681
|
+
|
|
682
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
683
|
+
|
|
684
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
685
|
+
|
|
686
|
+
await this.glueController.callFrame<BundleWorkspaceConfig, void>(this.operations.bundleWorkspace, config, frame.windowId);
|
|
687
|
+
|
|
688
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
private async bundleItem(config: BundleItemConfig, commandId: string): Promise<void> {
|
|
692
|
+
this.logger?.trace(`[${commandId}] handling bundleItem request with config ${JSON.stringify(config)}`);
|
|
693
|
+
|
|
694
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.itemId });
|
|
695
|
+
|
|
696
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
697
|
+
|
|
698
|
+
await this.glueController.callFrame<BundleItemConfig, void>(this.operations.bundleItem, config, frame.windowId);
|
|
699
|
+
|
|
700
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
private async resumeWorkspace(config: WorkspaceSelector, commandId: string): Promise<void> {
|
|
704
|
+
this.logger?.trace(`[${commandId}] handling resumeWorkspace request with config ${JSON.stringify(config)}`);
|
|
705
|
+
|
|
706
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
707
|
+
|
|
708
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
709
|
+
|
|
710
|
+
await this.glueController.callFrame<WorkspaceSelector, void>(this.operations.resumeWorkspace, config, frame.windowId);
|
|
711
|
+
|
|
712
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
private async lockWorkspace(config: LockWorkspaceConfig, commandId: string): Promise<void> {
|
|
716
|
+
this.logger?.trace(`[${commandId}] handling lockWorkspace request with config ${JSON.stringify(config)}`);
|
|
717
|
+
|
|
718
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
719
|
+
|
|
720
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
721
|
+
|
|
722
|
+
await this.glueController.callFrame<LockWorkspaceConfig, void>(this.operations.lockWorkspace, config, frame.windowId);
|
|
723
|
+
|
|
724
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
private async lockContainer(config: LockContainerConfig, commandId: string): Promise<void> {
|
|
728
|
+
this.logger?.trace(`[${commandId}] handling lockContainer request with config ${JSON.stringify(config)}`);
|
|
729
|
+
|
|
730
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.itemId });
|
|
731
|
+
|
|
732
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
733
|
+
|
|
734
|
+
await this.glueController.callFrame<LockContainerConfig, void>(this.operations.lockContainer, config, frame.windowId);
|
|
735
|
+
|
|
736
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
private async lockWindow(config: LockWindowConfig, commandId: string): Promise<void> {
|
|
740
|
+
this.logger?.trace(`[${commandId}] handling lockWindow request with config ${JSON.stringify(config)}`);
|
|
741
|
+
|
|
742
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.windowPlacementId });
|
|
743
|
+
|
|
744
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
745
|
+
|
|
746
|
+
await this.glueController.callFrame<LockWindowConfig, void>(this.operations.lockWindow, config, frame.windowId);
|
|
747
|
+
|
|
748
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
private async pinWorkspace(config: PinWorkspaceConfig, commandId: string): Promise<void> {
|
|
752
|
+
this.logger?.trace(`[${commandId}] handling pinWorkspace request with config ${JSON.stringify(config)}`);
|
|
753
|
+
|
|
754
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
755
|
+
|
|
756
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
757
|
+
|
|
758
|
+
await this.glueController.callFrame<PinWorkspaceConfig, void>(this.operations.pinWorkspace, config, frame.windowId);
|
|
759
|
+
|
|
760
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
private async unpinWorkspace(config: WorkspaceSelector, commandId: string): Promise<void> {
|
|
764
|
+
this.logger?.trace(`[${commandId}] handling unpinWorkspace request with config ${JSON.stringify(config)}`);
|
|
765
|
+
|
|
766
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
767
|
+
|
|
768
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
769
|
+
|
|
770
|
+
await this.glueController.callFrame<WorkspaceSelector, void>(this.operations.unpinWorkspace, config, frame.windowId);
|
|
771
|
+
|
|
772
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
private async getWorkspaceIcon(config: WorkspaceSelector, commandId: string): Promise<WorkspaceIconResult> {
|
|
776
|
+
this.logger?.trace(`[${commandId}] handling getWorkspaceIcon request with config ${JSON.stringify(config)}`);
|
|
777
|
+
|
|
778
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
779
|
+
|
|
780
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
781
|
+
|
|
782
|
+
const result = await this.glueController.callFrame<WorkspaceSelector, WorkspaceIconResult>(this.operations.getWorkspaceIcon, config, frame.windowId);
|
|
783
|
+
|
|
784
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
785
|
+
|
|
786
|
+
return result;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
private async setWorkspaceIcon(config: SetWorkspaceIconConfig, commandId: string): Promise<void> {
|
|
790
|
+
this.logger?.trace(`[${commandId}] handling setWorkspaceIcon request with config ${JSON.stringify(config)}`);
|
|
791
|
+
|
|
792
|
+
const frame = await this.framesController.getFrameInstance({ itemId: config.workspaceId });
|
|
793
|
+
|
|
794
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
795
|
+
|
|
796
|
+
await this.glueController.callFrame<SetWorkspaceIconConfig, void>(this.operations.setWorkspaceIcon, config, frame.windowId);
|
|
797
|
+
|
|
798
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
private async handleGetWorkspaceWindowsOnLayoutSaveContext(config: GetWorkspaceWindowsOnLayoutSaveContextConfig, commandId: string): Promise<GetWorkspaceWindowsOnLayoutSaveContextResult> {
|
|
802
|
+
this.logger?.trace(`[${commandId}] handling GetWorkspaceWindowsOnLayoutSaveContext request with config: ${JSON.stringify(config)}`);
|
|
803
|
+
|
|
804
|
+
const windowsOnSaveData = await Promise.all(config.windowIds.map<Promise<WorkspaceWindowOnSaveData>>(async (windowId) => {
|
|
805
|
+
return {
|
|
806
|
+
windowId,
|
|
807
|
+
windowContext: await this.getWorkspaceWindowOnLayoutSaveData(windowId, config)
|
|
808
|
+
};
|
|
809
|
+
}));
|
|
810
|
+
|
|
811
|
+
this.logger?.trace(`[${commandId}] operation GetWorkspaceWindowsOnLayoutSaveContext completed responding`);
|
|
812
|
+
|
|
813
|
+
return { windowsOnSaveData };
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
private async handleSetMaximizationBoundary(config: SetMaximizationBoundaryConfig, commandId: string): Promise<void> {
|
|
817
|
+
this.logger?.trace(`[${commandId}] handling setMaximizationBoundary request with config ${JSON.stringify(config)}`);
|
|
818
|
+
|
|
819
|
+
const frame = await this.framesController.getFrameInstance(config);
|
|
820
|
+
|
|
821
|
+
this.logger?.trace(`[${commandId}] targeting frame ${frame.windowId}`);
|
|
822
|
+
|
|
823
|
+
await this.glueController.callFrame<SetMaximizationBoundaryConfig, void>(this.operations.setMaximizationBoundary, config, frame.windowId);
|
|
824
|
+
|
|
825
|
+
this.logger?.trace(`[${commandId}] frame ${frame.windowId} gave a success signal, responding to caller`);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
private async changeFrameState(config: FrameStateConfig, commandId: string): Promise<void> {
|
|
829
|
+
throw new Error("Frame states are not supported in Glue42 Core");
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
private async getFrameState(config: SimpleItemConfig, commandId: string): Promise<FrameStateResult> {
|
|
833
|
+
throw new Error("Frame states are not supported in Glue42 Core");
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
private async handleFocusEvent(data: FocusEventData, commandId: string): Promise<void> {
|
|
837
|
+
this.logger?.trace(`[${commandId}] handling focus event from frame id: ${data.windowId} and hasFocus: ${data.hasFocus}`);
|
|
838
|
+
|
|
839
|
+
try {
|
|
840
|
+
await this.framesController.getFrameInstance({ frameId: data.windowId });
|
|
841
|
+
} catch (error) {
|
|
842
|
+
this.logger?.trace(`[${commandId}] ignoring focus event for unrecognized frame with id: ${data.windowId}`);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
const eventPayload: WorkspaceEventPayload = {
|
|
847
|
+
type: "frame",
|
|
848
|
+
action: "focus",
|
|
849
|
+
payload: {
|
|
850
|
+
frameSummary: {
|
|
851
|
+
id: data.windowId,
|
|
852
|
+
isFocused: data.hasFocus
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
this.bridgeWorkspaceEvent(eventPayload);
|
|
858
|
+
|
|
859
|
+
this.logger?.trace(`[${commandId}] focus event from frame id: ${data.windowId} and hasFocus: ${data.hasFocus} handled`);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
private async moveFrame(config: MoveFrameConfig, commandId: string): Promise<void> {
|
|
863
|
+
this.logger?.trace(`[${commandId}] handling moveFrame command with config: ${JSON.stringify(config)}`);
|
|
864
|
+
|
|
865
|
+
const frame = await this.framesController.getFrameInstance({ frameId: config.itemId });
|
|
866
|
+
|
|
867
|
+
const moveConfig: WindowMoveResizeConfig = {
|
|
868
|
+
windowId: config.itemId,
|
|
869
|
+
top: config.top,
|
|
870
|
+
left: config.left,
|
|
871
|
+
relative: config.relative
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
await this.glueController.callWindow<WindowMoveResizeConfig, void>("windows", this.ioc.windowsController.moveResizeOperation, moveConfig, { windowId: frame.windowId });
|
|
875
|
+
|
|
876
|
+
this.logger?.trace(`[${commandId}] frame with id ${frame.windowId} was successfully moved, responding to caller`);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
private applyDefaults(config: IOConnectBrowserPlatform.Workspaces.Config): IOConnectBrowserPlatform.Workspaces.Config {
|
|
880
|
+
const providedHibernationConfig = config?.hibernation || {};
|
|
881
|
+
const providedLoadingConfig = config?.loadingStrategy || {};
|
|
882
|
+
|
|
883
|
+
const loadingConfig = deepMerge<IOConnectBrowserPlatform.Workspaces.LoadingConfig>(defaultLoadingConfig, providedLoadingConfig as IOConnectBrowserPlatform.Workspaces.LoadingConfig);
|
|
884
|
+
|
|
885
|
+
return {
|
|
886
|
+
...config,
|
|
887
|
+
loadingStrategy: loadingConfig,
|
|
888
|
+
hibernation: providedHibernationConfig
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
private async getWorkspaceWindowOnLayoutSaveData(windowId: string, requestConfig: RawWindowsLayoutDataRequestConfig): Promise<any> {
|
|
893
|
+
|
|
894
|
+
// TODO: move all of this in the layouts controller
|
|
895
|
+
const nonGlueWindows = this.ioc.sessionController.getAllNonGlue();
|
|
896
|
+
|
|
897
|
+
if (nonGlueWindows.some((nonGlueWindow) => nonGlueWindow.windowId === windowId)) {
|
|
898
|
+
return {};
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
const workspaceWindow = this.ioc.sessionController.getWorkspaceClientById(windowId);
|
|
902
|
+
|
|
903
|
+
if (!workspaceWindow) {
|
|
904
|
+
throw new Error(`Cannot ask window: ${windowId} for on layout save request, because it is not a known workspace window`);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const timeoutMessage = `Cannot fetch the on layout save context from: ${windowId}, because of timeout`;
|
|
908
|
+
|
|
909
|
+
// the response will be undefined when communicating with an older Glue Web client which cannot service this message
|
|
910
|
+
const saveRequestResponse = await PromiseWrap<SaveRequestClientResponse>(async () => {
|
|
911
|
+
try {
|
|
912
|
+
const clientResponse = await this.glueController.callWindow<RawWindowsLayoutDataRequestConfig, SaveRequestClientResponse>("layouts", { name: "clientSaveRequest", execute: async () => {} }, requestConfig, { windowId });
|
|
913
|
+
return clientResponse;
|
|
914
|
+
} catch (error) {
|
|
915
|
+
return {};
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
}, 15000, timeoutMessage);
|
|
919
|
+
|
|
920
|
+
return saveRequestResponse?.windowContext ?? {};
|
|
921
|
+
}
|
|
922
|
+
}
|