@interopio/workspaces-api 3.2.1 → 3.2.3
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/dist/workspaces.es.js +4295 -4648
- package/dist/workspaces.es.js.map +1 -1
- package/dist/workspaces.umd.js +5206 -5559
- package/dist/workspaces.umd.js.map +1 -1
- package/dist/workspaces.umd.min.js +1 -1
- package/package.json +36 -50
- package/workspaces.d.ts +8 -0
- package/rollup.config.js +0 -54
- package/src/builders/baseBuilder.ts +0 -50
- package/src/builders/parentBuilder.ts +0 -62
- package/src/builders/workspaceBuilder.ts +0 -102
- package/src/communication/bridge.ts +0 -263
- package/src/communication/constants.ts +0 -202
- package/src/communication/interop-transport.ts +0 -175
- package/src/controllers/base.ts +0 -487
- package/src/controllers/main.ts +0 -541
- package/src/controllers/shortcuts.ts +0 -28
- package/src/index.ts +0 -23
- package/src/main.ts +0 -415
- package/src/models/base/base.ts +0 -397
- package/src/models/column.ts +0 -187
- package/src/models/frame.ts +0 -368
- package/src/models/group.ts +0 -237
- package/src/models/row.ts +0 -188
- package/src/models/window.ts +0 -309
- package/src/models/workspace.ts +0 -717
- package/src/shared/decoders.ts +0 -939
- package/src/shared/ioc.ts +0 -227
- package/src/shared/privateDataManager.ts +0 -93
- package/src/shared/promisePlus.ts +0 -34
- package/src/shared/promiseWrapper.ts +0 -11
- package/src/types/builders.ts +0 -10
- package/src/types/controller.ts +0 -79
- package/src/types/glue.ts +0 -37
- package/src/types/ioc.ts +0 -33
- package/src/types/privateData.ts +0 -92
- package/src/types/protocol.ts +0 -453
- package/src/types/subscription.ts +0 -31
- package/temp.d.ts +0 -49
- package/tsconfig.json +0 -10
package/src/controllers/base.ts
DELETED
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Workspace } from "../models/workspace";
|
|
3
|
-
import { WorkspaceSnapshotResult, WorkspaceCreateConfigProtocol, FrameSummaryResult, AddItemResult, WorkspaceSummariesResult, WorkspaceSummaryResult, SimpleWindowOperationSuccessResult, FrameSnapshotResult, WorkspaceStreamData, GetPlatformFrameIdResult, OperationCheckResult } from "../types/protocol";
|
|
4
|
-
import { OPERATIONS } from "../communication/constants";
|
|
5
|
-
import { FrameCreateConfig, WorkspaceIoCCreateConfig, WindowCreateConfig, ParentCreateConfig } from "../types/ioc";
|
|
6
|
-
import { IoC } from "../shared/ioc";
|
|
7
|
-
import { Bridge } from "../communication/bridge";
|
|
8
|
-
import { GDWindow, WindowsAPI, ContextsAPI, LayoutsAPI } from "../types/glue";
|
|
9
|
-
import { IOConnectWorkspaces } from "../../workspaces";
|
|
10
|
-
import { Frame } from "../models/frame";
|
|
11
|
-
import { RefreshChildrenConfig } from "../types/privateData";
|
|
12
|
-
import { AllParentTypes, Child, ContainerLockConfig, SubParentTypes } from "../types/builders";
|
|
13
|
-
import { PrivateDataManager } from "../shared/privateDataManager";
|
|
14
|
-
import { Window } from "../models/window";
|
|
15
|
-
import { UnsubscribeFunction } from "callback-registry";
|
|
16
|
-
|
|
17
|
-
export class BaseController {
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
private readonly ioc: IoC,
|
|
21
|
-
private readonly windows: WindowsAPI,
|
|
22
|
-
private readonly contexts: ContextsAPI,
|
|
23
|
-
private readonly layouts: LayoutsAPI,
|
|
24
|
-
) { }
|
|
25
|
-
|
|
26
|
-
private get bridge(): Bridge {
|
|
27
|
-
return this.ioc.bridge;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private get privateDataManager(): PrivateDataManager {
|
|
31
|
-
return this.ioc.privateDataManager;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public checkIsWindowLoaded(windowId: string): boolean {
|
|
35
|
-
return (!!windowId) && this.windows.list().some((win) => win.id === windowId);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public async createWorkspace(createConfig: WorkspaceCreateConfigProtocol): Promise<Workspace> {
|
|
39
|
-
const snapshot = await this.bridge.send<WorkspaceSnapshotResult>(OPERATIONS.createWorkspace.name, createConfig);
|
|
40
|
-
|
|
41
|
-
const frameConfig: FrameCreateConfig = {
|
|
42
|
-
summary: snapshot.frameSummary
|
|
43
|
-
};
|
|
44
|
-
const frame = this.ioc.getModel<"frame">("frame", frameConfig);
|
|
45
|
-
|
|
46
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
47
|
-
|
|
48
|
-
return this.ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public async createEmptyFrame(definition: IOConnectWorkspaces.EmptyFrameDefinition): Promise<Frame> {
|
|
52
|
-
const frameSummary = await this.bridge.send<FrameSummaryResult>(OPERATIONS.createFrame.name, definition);
|
|
53
|
-
const frameConfig: FrameCreateConfig = {
|
|
54
|
-
summary: frameSummary
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return this.ioc.getModel<"frame">("frame", frameConfig);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public async initFrame(frameId: string, config: IOConnectWorkspaces.FrameInitializationConfig): Promise<void> {
|
|
61
|
-
await this.bridge.send<void>(OPERATIONS.initFrame.name, { frameId, ...config });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public async restoreWorkspace(name: string, options: IOConnectWorkspaces.RestoreWorkspaceConfig): Promise<Workspace> {
|
|
65
|
-
const snapshot = await this.bridge.send<WorkspaceSnapshotResult>(OPERATIONS.openWorkspace.name, { name, restoreOptions: options });
|
|
66
|
-
|
|
67
|
-
const frameSummary = await this.bridge.send<FrameSummaryResult>(OPERATIONS.getFrameSummary.name, { itemId: snapshot.config.frameId });
|
|
68
|
-
|
|
69
|
-
const frameConfig: FrameCreateConfig = {
|
|
70
|
-
summary: frameSummary
|
|
71
|
-
};
|
|
72
|
-
const frame = this.ioc.getModel<"frame">("frame", frameConfig);
|
|
73
|
-
|
|
74
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
75
|
-
|
|
76
|
-
return this.ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public async add(type: "container" | "window", parentId: string, parentType: "row" | "column" | "group" | "workspace", definition: IOConnectWorkspaces.WorkspaceWindowDefinition | IOConnectWorkspaces.BoxDefinition): Promise<AddItemResult> {
|
|
80
|
-
let operationName: string;
|
|
81
|
-
const operationArgs = { definition, parentId, parentType };
|
|
82
|
-
|
|
83
|
-
if (type === "window") {
|
|
84
|
-
operationName = OPERATIONS.addWindow.name;
|
|
85
|
-
} else if (type === "container") {
|
|
86
|
-
operationName = OPERATIONS.addContainer.name;
|
|
87
|
-
} else {
|
|
88
|
-
throw new Error(`Unrecognized add type: ${type}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return await this.bridge.send<AddItemResult>(operationName, operationArgs);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public async getFrame(windowId: string): Promise<Frame> {
|
|
95
|
-
const frameSummary = await this.bridge.send<FrameSummaryResult>(OPERATIONS.getFrameSummary.name, { itemId: windowId });
|
|
96
|
-
|
|
97
|
-
const frameConfig: FrameCreateConfig = {
|
|
98
|
-
summary: frameSummary
|
|
99
|
-
};
|
|
100
|
-
return this.ioc.getModel<"frame">("frame", frameConfig);
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public getFrames(allFrameSummaries: FrameSummaryResult[], predicate?: (frame: Frame) => boolean): Frame[] {
|
|
105
|
-
|
|
106
|
-
return allFrameSummaries.reduce<Frame[]>((frames, frameSummary) => {
|
|
107
|
-
|
|
108
|
-
const frameConfig: FrameCreateConfig = {
|
|
109
|
-
summary: frameSummary
|
|
110
|
-
};
|
|
111
|
-
const frameToCheck = this.ioc.getModel<"frame">("frame", frameConfig);
|
|
112
|
-
|
|
113
|
-
if (!predicate || predicate(frameToCheck)) {
|
|
114
|
-
frames.push(frameToCheck);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return frames;
|
|
118
|
-
}, []);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public getAllWorkspaceSummaries(...bridgeResults: WorkspaceSummariesResult[]): IOConnectWorkspaces.WorkspaceSummary[] {
|
|
122
|
-
|
|
123
|
-
const allSummaries = bridgeResults.reduce<WorkspaceSummaryResult[]>((summaries, summaryResult) => {
|
|
124
|
-
summaries.push(...summaryResult.summaries);
|
|
125
|
-
return summaries;
|
|
126
|
-
}, []);
|
|
127
|
-
|
|
128
|
-
return allSummaries.map<IOConnectWorkspaces.WorkspaceSummary>((summary) => {
|
|
129
|
-
|
|
130
|
-
return Object.assign(
|
|
131
|
-
{},
|
|
132
|
-
{ id: summary.id, width: summary.config.widthInPx, height: summary.config.heightInPx },
|
|
133
|
-
summary.config
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public handleOnSaved(callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): UnsubscribeFunction {
|
|
139
|
-
const wrappedCallback = (layout: IOConnectWorkspaces.WorkspaceLayout): void => {
|
|
140
|
-
if (layout.type !== "Workspace") {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
callback(layout);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const addedUnSub: UnsubscribeFunction = this.layouts.onAdded(wrappedCallback);
|
|
148
|
-
const changedUnSub: UnsubscribeFunction = this.layouts.onChanged(wrappedCallback);
|
|
149
|
-
|
|
150
|
-
return (): void => {
|
|
151
|
-
addedUnSub();
|
|
152
|
-
changedUnSub();
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public handleOnRemoved(callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): UnsubscribeFunction {
|
|
157
|
-
const wrappedCallback = (layout: IOConnectWorkspaces.WorkspaceLayout): void => {
|
|
158
|
-
if (layout.type !== "Workspace") {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
callback(layout);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
return this.layouts.onRemoved(wrappedCallback);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public async importLayouts(layouts: IOConnectWorkspaces.WorkspaceLayout[], mode: "replace" | "merge"): Promise<void> {
|
|
169
|
-
await this.layouts.import(layouts, mode);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public async transformStreamPayloadToWorkspace(payload: WorkspaceStreamData): Promise<Workspace> {
|
|
173
|
-
const frameConfig: FrameCreateConfig = {
|
|
174
|
-
summary: payload.frameSummary
|
|
175
|
-
};
|
|
176
|
-
const frame = this.ioc.getModel<"frame">("frame", frameConfig);
|
|
177
|
-
|
|
178
|
-
const snapshot = payload.workspaceSnapshot || (await this.bridge.send<WorkspaceSnapshotResult>(OPERATIONS.getWorkspaceSnapshot.name, { itemId: payload.workspaceSummary.id }));
|
|
179
|
-
|
|
180
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
181
|
-
|
|
182
|
-
const workspace = this.ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
183
|
-
|
|
184
|
-
return workspace;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public async fetchWorkspace(itemId: string): Promise<Workspace> {
|
|
188
|
-
|
|
189
|
-
const snapshot = await this.bridge.send<WorkspaceSnapshotResult>(OPERATIONS.getWorkspaceSnapshot.name, { itemId });
|
|
190
|
-
|
|
191
|
-
const frameConfig: FrameCreateConfig = {
|
|
192
|
-
summary: snapshot.frameSummary
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const frame = this.ioc.getModel<"frame">("frame", frameConfig);
|
|
196
|
-
|
|
197
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
198
|
-
|
|
199
|
-
return this.ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public async bundleWorkspaceTo(type: "row" | "column", workspaceId: string): Promise<void> {
|
|
204
|
-
await this.bridge.send(OPERATIONS.bundleWorkspace.name, { type, workspaceId });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public async bundleItemTo(type: "row" | "column", itemId: string): Promise<void> {
|
|
208
|
-
const isSupported = await this.isOperationSupported(OPERATIONS.bundleItem.name);
|
|
209
|
-
|
|
210
|
-
if (!isSupported) {
|
|
211
|
-
throw new Error(`Operation ${OPERATIONS.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
await this.bridge.send(OPERATIONS.bundleItem.name, { type, itemId });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public getWorkspaceContext(workspaceId: string): Promise<any> {
|
|
218
|
-
const contextName = `___workspace___${workspaceId}`;
|
|
219
|
-
return this.contexts.get(contextName);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
public setWorkspaceContext(workspaceId: string, data: any): Promise<void> {
|
|
223
|
-
const contextName = `___workspace___${workspaceId}`;
|
|
224
|
-
return this.contexts.set(contextName, data);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public updateWorkspaceContext(workspaceId: string, data: any): Promise<void> {
|
|
228
|
-
const contextName = `___workspace___${workspaceId}`;
|
|
229
|
-
return this.contexts.update(contextName, data);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public subscribeWorkspaceContextUpdated(workspaceId: string, callback: (data: any) => void): Promise<UnsubscribeFunction> {
|
|
233
|
-
const contextName = `___workspace___${workspaceId}`;
|
|
234
|
-
return this.contexts.subscribe(contextName, callback);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public async restoreItem(itemId: string): Promise<void> {
|
|
238
|
-
await this.bridge.send(OPERATIONS.restoreItem.name, { itemId });
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
public async maximizeItem(itemId: string): Promise<void> {
|
|
242
|
-
await this.bridge.send(OPERATIONS.maximizeItem.name, { itemId });
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public async focusItem(itemId: string): Promise<void> {
|
|
246
|
-
await this.bridge.send(OPERATIONS.focusItem.name, { itemId });
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
public async closeItem(itemId: string): Promise<void> {
|
|
250
|
-
await this.bridge.send(OPERATIONS.closeItem.name, { itemId });
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
public async resizeItem(itemId: string, config: IOConnectWorkspaces.ResizeConfig): Promise<void> {
|
|
254
|
-
await this.bridge.send(OPERATIONS.resizeItem.name, Object.assign({}, { itemId }, config));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public async setMaximizationBoundary(itemId: string, config: IOConnectWorkspaces.SetMaximizationBoundaryConfig): Promise<void> {
|
|
258
|
-
await this.bridge.send(OPERATIONS.setMaximizationBoundary.name, Object.assign({}, { itemId }, config));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
public async showWorkspaceLoadingAnimation(workspaceId: string): Promise<void> {
|
|
262
|
-
await this.bridge.send(OPERATIONS.showLoadingAnimation.name, { itemId: workspaceId, type: "workspace" });
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
public async hideWorkspaceLoadingAnimation(workspaceId: string): Promise<void> {
|
|
266
|
-
await this.bridge.send(OPERATIONS.hideLoadingAnimation.name, { itemId: workspaceId, type: "workspace" });
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
public async moveFrame(itemId: string, config: IOConnectWorkspaces.MoveConfig): Promise<void> {
|
|
270
|
-
await this.bridge.send(OPERATIONS.moveFrame.name, Object.assign({}, { itemId }, config));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
public getGDWindow(itemId: string): GDWindow {
|
|
274
|
-
return this.windows.list().find((gdWindow) => gdWindow.id === itemId);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public async forceLoadWindow(itemId: string): Promise<string> {
|
|
278
|
-
const controlResult = await this.bridge.send<SimpleWindowOperationSuccessResult>(OPERATIONS.forceLoadWindow.name, { itemId });
|
|
279
|
-
|
|
280
|
-
return controlResult.windowId;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
public async ejectWindow(itemId: string): Promise<SimpleWindowOperationSuccessResult> {
|
|
284
|
-
return await this.bridge.send<SimpleWindowOperationSuccessResult>(OPERATIONS.ejectWindow.name, { itemId });
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
public async moveWindowTo(itemId: string, newParentId: string): Promise<void> {
|
|
288
|
-
await this.bridge.send(OPERATIONS.moveWindowTo.name, { itemId, containerId: newParentId });
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public async getSnapshot(itemId: string, type: "workspace" | "frame"): Promise<WorkspaceSnapshotResult | FrameSnapshotResult> {
|
|
292
|
-
let result: WorkspaceSnapshotResult | FrameSnapshotResult;
|
|
293
|
-
|
|
294
|
-
if (type === "workspace") {
|
|
295
|
-
result = await this.bridge.send<WorkspaceSnapshotResult>(OPERATIONS.getWorkspaceSnapshot.name, { itemId });
|
|
296
|
-
} else if (type === "frame") {
|
|
297
|
-
result = await this.bridge.send<FrameSnapshotResult>(OPERATIONS.getFrameSnapshot.name, { itemId });
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return result;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
public async setItemTitle(itemId: string, title: string): Promise<void> {
|
|
304
|
-
await this.bridge.send(OPERATIONS.setItemTitle.name, { itemId, title });
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public refreshChildren(config: RefreshChildrenConfig): Child[] {
|
|
308
|
-
const { parent, children, existingChildren, workspace } = config;
|
|
309
|
-
if (parent instanceof Window || (parent as IOConnectWorkspaces.WorkspaceWindow).type === "window") {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const newChildren = children.map((newChildSnapshot) => {
|
|
314
|
-
let childToAdd = existingChildren.find((child) => {
|
|
315
|
-
return child.type === "window" ? child.elementId === newChildSnapshot.id : child.id === newChildSnapshot.id;
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
if (childToAdd) {
|
|
319
|
-
this.privateDataManager.remapChild(childToAdd, {
|
|
320
|
-
parent: parent as AllParentTypes,
|
|
321
|
-
children: [],
|
|
322
|
-
config: newChildSnapshot.config
|
|
323
|
-
});
|
|
324
|
-
} else {
|
|
325
|
-
let createConfig: WindowCreateConfig | ParentCreateConfig;
|
|
326
|
-
if (newChildSnapshot.type === "window") {
|
|
327
|
-
createConfig = {
|
|
328
|
-
id: newChildSnapshot.id,
|
|
329
|
-
parent: parent as AllParentTypes,
|
|
330
|
-
frame: workspace.frame,
|
|
331
|
-
workspace,
|
|
332
|
-
config: newChildSnapshot.config,
|
|
333
|
-
} as WindowCreateConfig;
|
|
334
|
-
} else {
|
|
335
|
-
createConfig = {
|
|
336
|
-
id: newChildSnapshot.id,
|
|
337
|
-
parent: parent as AllParentTypes,
|
|
338
|
-
frame: workspace.frame,
|
|
339
|
-
workspace,
|
|
340
|
-
config: newChildSnapshot.config,
|
|
341
|
-
children: []
|
|
342
|
-
} as ParentCreateConfig;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
childToAdd = this.ioc.getModel<"child">(newChildSnapshot.type, createConfig);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (newChildSnapshot.type !== "window") {
|
|
349
|
-
this.refreshChildren({
|
|
350
|
-
workspace, existingChildren,
|
|
351
|
-
children: newChildSnapshot.children,
|
|
352
|
-
parent: childToAdd
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return childToAdd;
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
if (parent instanceof Workspace) {
|
|
360
|
-
return newChildren;
|
|
361
|
-
} else {
|
|
362
|
-
this.privateDataManager.remapChild(parent as SubParentTypes, { children: newChildren });
|
|
363
|
-
return newChildren;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
public iterateFindChild(children: Child[], predicate: (child: Child) => boolean): Child {
|
|
368
|
-
let foundChild = children.find((child) => predicate(child));
|
|
369
|
-
|
|
370
|
-
if (foundChild) {
|
|
371
|
-
return foundChild;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
children.some((child) => {
|
|
375
|
-
if (child instanceof Window) {
|
|
376
|
-
return false;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
foundChild = this.iterateFindChild((child as SubParentTypes).children, predicate);
|
|
380
|
-
|
|
381
|
-
if (foundChild) {
|
|
382
|
-
return true;
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
return foundChild;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
public iterateFilterChildren(children: Child[], predicate: (child: Child) => boolean): Child[] {
|
|
390
|
-
const foundChildren = children.filter((child) => predicate(child));
|
|
391
|
-
|
|
392
|
-
const grandChildren = children.reduce<Child[]>((innerFound, child) => {
|
|
393
|
-
if (child instanceof Window) {
|
|
394
|
-
return innerFound;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
innerFound.push(...this.iterateFilterChildren((child as SubParentTypes).children, predicate));
|
|
398
|
-
|
|
399
|
-
return innerFound;
|
|
400
|
-
}, []);
|
|
401
|
-
|
|
402
|
-
foundChildren.push(...grandChildren);
|
|
403
|
-
|
|
404
|
-
return foundChildren;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
public notifyWindowAdded(windowId: string): Promise<void> {
|
|
408
|
-
return new Promise((resolve) => {
|
|
409
|
-
|
|
410
|
-
const alreadyPresent: boolean = this.windows.list().some((win) => win.id === windowId);
|
|
411
|
-
|
|
412
|
-
if (alreadyPresent) {
|
|
413
|
-
return resolve();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const unsubscribe: UnsubscribeFunction = this.windows.onWindowAdded((win) => {
|
|
417
|
-
|
|
418
|
-
if (win.id !== windowId) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (unsubscribe) {
|
|
423
|
-
unsubscribe();
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
resolve();
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
public async hibernateWorkspace(workspaceId: string): Promise<void> {
|
|
432
|
-
await this.bridge.send<void>(OPERATIONS.hibernateWorkspace.name, { workspaceId });
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
public async resumeWorkspace(workspaceId: string): Promise<void> {
|
|
436
|
-
await this.bridge.send<void>(OPERATIONS.resumeWorkspace.name, { workspaceId });
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public async lockWorkspace(workspaceId: string, config?: IOConnectWorkspaces.WorkspaceLockConfig): Promise<void> {
|
|
440
|
-
await this.bridge.send<void>(OPERATIONS.lockWorkspace.name, { workspaceId, config });
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
public async lockWindow(windowPlacementId: string, config?: IOConnectWorkspaces.WorkspaceWindowLockConfig): Promise<void> {
|
|
444
|
-
await this.bridge.send<void>(OPERATIONS.lockWindow.name, { windowPlacementId, config });
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
public async lockContainer(itemId: string, type: SubParentTypes["type"], config?: ContainerLockConfig): Promise<void> {
|
|
448
|
-
await this.bridge.send<void>(OPERATIONS.lockContainer.name, { itemId, type, config });
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
public async pinWorkspace(workspaceId: string, icon?: string): Promise<void> {
|
|
452
|
-
await this.bridge.send<void>(OPERATIONS.pinWorkspace.name, { workspaceId, icon });
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
public async unpinWorkspace(workspaceId: string): Promise<void> {
|
|
456
|
-
await this.bridge.send<void>(OPERATIONS.unpinWorkspace.name, { workspaceId });
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
public async getWorkspaceIcon(workspaceId: string): Promise<string> {
|
|
460
|
-
const result = await this.bridge.send<{ icon: string }>(OPERATIONS.getWorkspaceIcon.name, { workspaceId });
|
|
461
|
-
return result.icon;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
public setWorkspaceIcon(workspaceId: string, icon: string): Promise<void> {
|
|
465
|
-
return this.bridge.send<void>(OPERATIONS.setWorkspaceIcon.name, { workspaceId, icon });
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
public async getPlatformFrameId(): Promise<GetPlatformFrameIdResult> {
|
|
469
|
-
try {
|
|
470
|
-
const result = await this.bridge.send<GetPlatformFrameIdResult>(OPERATIONS.getPlatformFrameId.name, {});
|
|
471
|
-
|
|
472
|
-
return result;
|
|
473
|
-
} catch (error) {
|
|
474
|
-
return {}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
public async isOperationSupported(operation: string): Promise<OperationCheckResult> {
|
|
479
|
-
const desktopGlobal = (window as any).glue42gd || (window as any).iodesktop;
|
|
480
|
-
|
|
481
|
-
if (desktopGlobal) {
|
|
482
|
-
// operation check is not supported in Glue42Desktop
|
|
483
|
-
return { isSupported: true };
|
|
484
|
-
}
|
|
485
|
-
return await this.bridge.send<OperationCheckResult>(OPERATIONS.operationCheck.name, { operation });
|
|
486
|
-
}
|
|
487
|
-
}
|