@interopio/workspaces-api 3.2.2 → 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 +1 -1
- package/dist/workspaces.umd.js +1 -1
- package/dist/workspaces.umd.min.js +1 -1
- package/package.json +3 -3
- 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 -940
- 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/main.ts
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { IoC } from "./shared/ioc";
|
|
3
|
-
import { checkThrowCallback, nonEmptyStringDecoder, workspaceLayoutDecoder, workspaceDefinitionDecoder, workspaceBuilderCreateConfigDecoder, builderConfigDecoder, restoreWorkspaceConfigDecoder, workspaceLayoutSaveConfigDecoder, emptyFrameDefinitionDecoder } from "./shared/decoders";
|
|
4
|
-
import { FrameStreamData, WorkspaceStreamData, WorkspaceSnapshotResult, WindowStreamData } from "./types/protocol";
|
|
5
|
-
import { FrameCreateConfig, WorkspaceIoCCreateConfig } from "./types/ioc";
|
|
6
|
-
import { IOConnectWorkspaces } from "./../workspaces";
|
|
7
|
-
import { WorkspacesController } from "./types/controller";
|
|
8
|
-
import { version } from "../package.json";
|
|
9
|
-
import { API } from "../temp";
|
|
10
|
-
|
|
11
|
-
export const composeAPI = (glue: any, ioc: IoC): API => {
|
|
12
|
-
|
|
13
|
-
const controller: WorkspacesController = ioc.controller;
|
|
14
|
-
|
|
15
|
-
const inWorkspace = (): Promise<boolean> => {
|
|
16
|
-
const myId: string = glue.windows.my().id;
|
|
17
|
-
|
|
18
|
-
if (!myId) {
|
|
19
|
-
throw new Error("Cannot get my frame, because my id is undefined.");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return controller.checkIsInSwimlane(myId);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getBuilder = (config: IOConnectWorkspaces.BuilderConfig): IOConnectWorkspaces.WorkspaceBuilder | IOConnectWorkspaces.BoxBuilder => {
|
|
26
|
-
const validatedConfig = builderConfigDecoder.runWithException(config);
|
|
27
|
-
|
|
28
|
-
return ioc.getBuilder(validatedConfig);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const getMyFrame = async (): Promise<IOConnectWorkspaces.Frame> => {
|
|
32
|
-
const windowId: string = glue.windows.my().id;
|
|
33
|
-
|
|
34
|
-
if (!windowId) {
|
|
35
|
-
throw new Error("Cannot get my frame, because my id is undefined.");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const isInSwimlane = await controller.checkIsInSwimlane(windowId);
|
|
39
|
-
|
|
40
|
-
if (!isInSwimlane) {
|
|
41
|
-
throw new Error("Cannot fetch your frame, because this window is not in a workspace");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return controller.getFrame({ windowId });
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const getFrame = async (predicate: (frame: IOConnectWorkspaces.Frame) => boolean): Promise<IOConnectWorkspaces.Frame> => {
|
|
48
|
-
checkThrowCallback(predicate);
|
|
49
|
-
|
|
50
|
-
return controller.getFrame({ predicate });
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getAllFrames = async (predicate?: (frame: IOConnectWorkspaces.Frame) => boolean): Promise<IOConnectWorkspaces.Frame[]> => {
|
|
54
|
-
checkThrowCallback(predicate, true);
|
|
55
|
-
|
|
56
|
-
return controller.getFrames(predicate);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getAllWorkspacesSummaries = (): Promise<IOConnectWorkspaces.WorkspaceSummary[]> => {
|
|
60
|
-
return controller.getAllWorkspaceSummaries();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const getMyWorkspace = async (): Promise<IOConnectWorkspaces.Workspace> => {
|
|
64
|
-
const myId: string = glue.windows.my().id;
|
|
65
|
-
|
|
66
|
-
if (!myId) {
|
|
67
|
-
throw new Error("Cannot get my workspace, because my id is undefined.");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const isInSwimlane = await controller.checkIsInSwimlane(myId);
|
|
71
|
-
|
|
72
|
-
if (!isInSwimlane) {
|
|
73
|
-
throw new Error("Cannot fetch your workspace, because this window is not in a workspace");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return await controller.getWorkspaceByWindowId(myId);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const getWorkspace = async (predicate: (workspace: IOConnectWorkspaces.Workspace) => boolean): Promise<IOConnectWorkspaces.Workspace> => {
|
|
80
|
-
checkThrowCallback(predicate);
|
|
81
|
-
return (await controller.getWorkspaces(predicate))[0];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const getWorkspaceById = async (workspaceId: string): Promise<IOConnectWorkspaces.Workspace> => {
|
|
85
|
-
nonEmptyStringDecoder.runWithException(workspaceId);
|
|
86
|
-
|
|
87
|
-
return controller.getWorkspaceById(workspaceId);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const getAllWorkspaces = (predicate?: (workspace: IOConnectWorkspaces.Workspace) => boolean): Promise<IOConnectWorkspaces.Workspace[]> => {
|
|
91
|
-
checkThrowCallback(predicate, true);
|
|
92
|
-
return controller.getWorkspaces(predicate);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const getWindow = async (predicate: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => boolean): Promise<IOConnectWorkspaces.WorkspaceWindow> => {
|
|
96
|
-
checkThrowCallback(predicate);
|
|
97
|
-
return controller.getWindow(predicate);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const getParent = async (predicate: (parent: IOConnectWorkspaces.WorkspaceBox) => boolean): Promise<IOConnectWorkspaces.WorkspaceBox> => {
|
|
101
|
-
checkThrowCallback(predicate);
|
|
102
|
-
return controller.getParent(predicate);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const restoreWorkspace = async (name: string, options?: IOConnectWorkspaces.RestoreWorkspaceConfig): Promise<IOConnectWorkspaces.Workspace> => {
|
|
106
|
-
nonEmptyStringDecoder.runWithException(name);
|
|
107
|
-
const validatedOptions = restoreWorkspaceConfigDecoder.runWithException(options);
|
|
108
|
-
return controller.restoreWorkspace(name, validatedOptions);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const createWorkspace = async (definition: IOConnectWorkspaces.WorkspaceDefinition, saveConfig?: IOConnectWorkspaces.WorkspaceCreateConfig): Promise<IOConnectWorkspaces.Workspace> => {
|
|
112
|
-
const validatedDefinition = workspaceDefinitionDecoder.runWithException(definition);
|
|
113
|
-
const validatedConfig = workspaceBuilderCreateConfigDecoder.runWithException(saveConfig);
|
|
114
|
-
|
|
115
|
-
return controller.createWorkspace(validatedDefinition, validatedConfig);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const createEmptyFrame = async (definition?: IOConnectWorkspaces.EmptyFrameDefinition): Promise<IOConnectWorkspaces.Frame> => {
|
|
119
|
-
const validatedDefinition = emptyFrameDefinitionDecoder.runWithException(definition);
|
|
120
|
-
|
|
121
|
-
return controller.createEmptyFrame(validatedDefinition ?? {});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const layouts = {
|
|
125
|
-
getSummaries: (): Promise<IOConnectWorkspaces.WorkspaceLayoutSummary[]> => {
|
|
126
|
-
return controller.getLayoutSummaries();
|
|
127
|
-
},
|
|
128
|
-
delete: async (name: string): Promise<void> => {
|
|
129
|
-
nonEmptyStringDecoder.runWithException(name);
|
|
130
|
-
return controller.deleteLayout(name);
|
|
131
|
-
},
|
|
132
|
-
export: async (predicate?: (layout: IOConnectWorkspaces.WorkspaceLayout) => boolean): Promise<IOConnectWorkspaces.WorkspaceLayout[]> => {
|
|
133
|
-
checkThrowCallback(predicate, true);
|
|
134
|
-
return controller.exportLayout(predicate);
|
|
135
|
-
},
|
|
136
|
-
import: async (layouts: IOConnectWorkspaces.WorkspaceLayout[], mode: "replace" | "merge" = "replace"): Promise<void> => {
|
|
137
|
-
|
|
138
|
-
if (!Array.isArray(layouts)) {
|
|
139
|
-
throw new Error(`The provided layouts argument is not an array: ${JSON.stringify(layouts)}`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
layouts.forEach((layout) => workspaceLayoutDecoder.runWithException(layout));
|
|
143
|
-
return controller.importLayouts(layouts, mode);
|
|
144
|
-
},
|
|
145
|
-
save: async (config: IOConnectWorkspaces.WorkspaceLayoutSaveConfig): Promise<IOConnectWorkspaces.WorkspaceLayout> => {
|
|
146
|
-
const verifiedConfig = workspaceLayoutSaveConfigDecoder.runWithException(config);
|
|
147
|
-
return controller.saveLayout(verifiedConfig);
|
|
148
|
-
},
|
|
149
|
-
onSaved: async (callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
150
|
-
checkThrowCallback(callback);
|
|
151
|
-
|
|
152
|
-
return controller.handleOnSaved(callback);
|
|
153
|
-
},
|
|
154
|
-
onRemoved: async (callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
155
|
-
checkThrowCallback(callback);
|
|
156
|
-
|
|
157
|
-
return controller.handleOnRemoved(callback);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const onFrameOpened = async (callback: (frame: IOConnectWorkspaces.Frame) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
162
|
-
checkThrowCallback(callback);
|
|
163
|
-
|
|
164
|
-
const wrappedCallback = (payload: FrameStreamData): void => {
|
|
165
|
-
const frameConfig: FrameCreateConfig = {
|
|
166
|
-
summary: payload.frameSummary
|
|
167
|
-
};
|
|
168
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
169
|
-
callback(frame);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "frame", "opened");
|
|
173
|
-
return unsubscribe;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const onFrameClosed = async (callback: (closed: IOConnectWorkspaces.FrameClosedData) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
177
|
-
checkThrowCallback(callback);
|
|
178
|
-
const wrappedCallback = (payload: FrameStreamData): void => {
|
|
179
|
-
callback({ frameId: payload.frameSummary.id, frameBounds: payload.frameBounds });
|
|
180
|
-
};
|
|
181
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "frame", "closed");
|
|
182
|
-
return unsubscribe;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const onWorkspaceOpened = async (callback: (workspace: IOConnectWorkspaces.Workspace) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
186
|
-
|
|
187
|
-
checkThrowCallback(callback);
|
|
188
|
-
const wrappedCallback = async (payload: WorkspaceStreamData): Promise<void> => {
|
|
189
|
-
const workspace = await controller.transformStreamPayloadToWorkspace(payload);
|
|
190
|
-
|
|
191
|
-
callback(workspace);
|
|
192
|
-
};
|
|
193
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "workspace", "opened");
|
|
194
|
-
return unsubscribe;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const onWorkspaceClosed = async (callback: (closed: IOConnectWorkspaces.WorkspaceClosedData) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
198
|
-
checkThrowCallback(callback);
|
|
199
|
-
|
|
200
|
-
const wrappedCallback = (payload: WorkspaceStreamData): void => {
|
|
201
|
-
callback({ frameId: payload.frameSummary.id, workspaceId: payload.workspaceSummary.id, frameBounds: payload.frameBounds });
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "workspace", "closed");
|
|
205
|
-
return unsubscribe;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const onWorkspaceHibernated = async (callback: (workspace: IOConnectWorkspaces.Workspace) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
209
|
-
checkThrowCallback(callback);
|
|
210
|
-
|
|
211
|
-
const wrappedCallback = async (payload: WorkspaceStreamData): Promise<void> => {
|
|
212
|
-
const workspace = await controller.transformStreamPayloadToWorkspace(payload);
|
|
213
|
-
|
|
214
|
-
callback(workspace);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "workspace", "hibernated");
|
|
218
|
-
return unsubscribe;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const onWorkspaceResumed = async (callback: (workspace: IOConnectWorkspaces.Workspace) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
222
|
-
checkThrowCallback(callback);
|
|
223
|
-
|
|
224
|
-
const wrappedCallback = async (payload: WorkspaceStreamData): Promise<void> => {
|
|
225
|
-
const workspace = await controller.transformStreamPayloadToWorkspace(payload);
|
|
226
|
-
|
|
227
|
-
callback(workspace);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "workspace", "resumed");
|
|
231
|
-
return unsubscribe;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const onWindowAdded = async (callback: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
235
|
-
checkThrowCallback(callback);
|
|
236
|
-
const wrappedCallback = async (payload: WindowStreamData): Promise<void> => {
|
|
237
|
-
const snapshot = (await controller.getSnapshot(payload.windowSummary.config.workspaceId, "workspace")) as WorkspaceSnapshotResult;
|
|
238
|
-
|
|
239
|
-
const frameConfig: FrameCreateConfig = {
|
|
240
|
-
summary: snapshot.frameSummary
|
|
241
|
-
};
|
|
242
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
243
|
-
|
|
244
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
245
|
-
|
|
246
|
-
const workspace = ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
247
|
-
|
|
248
|
-
const windowParent = workspace.getBox((parent) => parent.id === payload.windowSummary.parentId);
|
|
249
|
-
const foundWindow = windowParent.children.find((child) => child.type === "window" && child.elementId === payload.windowSummary.itemId);
|
|
250
|
-
|
|
251
|
-
callback(foundWindow as IOConnectWorkspaces.WorkspaceWindow);
|
|
252
|
-
};
|
|
253
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "added");
|
|
254
|
-
return unsubscribe;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
const onWindowLoaded = async (callback: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
258
|
-
checkThrowCallback(callback);
|
|
259
|
-
const wrappedCallback = async (payload: WindowStreamData): Promise<void> => {
|
|
260
|
-
const snapshot = (await controller.getSnapshot(payload.windowSummary.config.workspaceId, "workspace")) as WorkspaceSnapshotResult;
|
|
261
|
-
|
|
262
|
-
const frameConfig: FrameCreateConfig = {
|
|
263
|
-
summary: snapshot.frameSummary
|
|
264
|
-
};
|
|
265
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
266
|
-
|
|
267
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
268
|
-
|
|
269
|
-
const workspace = ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
270
|
-
|
|
271
|
-
const foundWindow = workspace.getWindow((win) => win.id && win.id === payload.windowSummary.config.windowId);
|
|
272
|
-
|
|
273
|
-
callback(foundWindow);
|
|
274
|
-
};
|
|
275
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "loaded");
|
|
276
|
-
return unsubscribe;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const onWindowRemoved = async (callback: (removed: { windowId: string; workspaceId: string; frameId: string }) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
280
|
-
checkThrowCallback(callback);
|
|
281
|
-
const wrappedCallback = (payload: WindowStreamData): void => {
|
|
282
|
-
const { windowId, workspaceId, frameId } = payload.windowSummary.config;
|
|
283
|
-
callback({ windowId, workspaceId, frameId });
|
|
284
|
-
};
|
|
285
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "removed");
|
|
286
|
-
return unsubscribe;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const onWindowMaximized = async (callback: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
290
|
-
checkThrowCallback(callback);
|
|
291
|
-
const wrappedCallback = async (payload: WindowStreamData): Promise<void> => {
|
|
292
|
-
const snapshot = (await controller.getSnapshot(payload.windowSummary.config.workspaceId, "workspace")) as WorkspaceSnapshotResult;
|
|
293
|
-
|
|
294
|
-
const frameConfig: FrameCreateConfig = {
|
|
295
|
-
summary: snapshot.frameSummary
|
|
296
|
-
};
|
|
297
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
298
|
-
|
|
299
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
300
|
-
|
|
301
|
-
const workspace = ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
302
|
-
|
|
303
|
-
const windowParent = workspace.getBox((parent) => parent.id === payload.windowSummary.parentId);
|
|
304
|
-
const foundWindow = windowParent.children.find((child) => child.type === "window" && child.elementId === payload.windowSummary.itemId);
|
|
305
|
-
|
|
306
|
-
callback(foundWindow as IOConnectWorkspaces.WorkspaceWindow);
|
|
307
|
-
};
|
|
308
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "maximized");
|
|
309
|
-
return unsubscribe;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
const onWindowRestored = async (callback: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
313
|
-
checkThrowCallback(callback);
|
|
314
|
-
const wrappedCallback = async (payload: WindowStreamData): Promise<void> => {
|
|
315
|
-
const snapshot = (await controller.getSnapshot(payload.windowSummary.config.workspaceId, "workspace")) as WorkspaceSnapshotResult;
|
|
316
|
-
|
|
317
|
-
const frameConfig: FrameCreateConfig = {
|
|
318
|
-
summary: snapshot.frameSummary
|
|
319
|
-
};
|
|
320
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
321
|
-
|
|
322
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
323
|
-
|
|
324
|
-
const workspace = ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
325
|
-
|
|
326
|
-
const windowParent = workspace.getBox((parent) => parent.id === payload.windowSummary.parentId);
|
|
327
|
-
const foundWindow = windowParent.children.find((child) => child.type === "window" && child.elementId === payload.windowSummary.itemId);
|
|
328
|
-
|
|
329
|
-
callback(foundWindow as IOConnectWorkspaces.WorkspaceWindow);
|
|
330
|
-
};
|
|
331
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "restored");
|
|
332
|
-
return unsubscribe;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const onWindowSelected = async (callback: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => void): Promise<IOConnectWorkspaces.Unsubscribe> => {
|
|
337
|
-
checkThrowCallback(callback);
|
|
338
|
-
const wrappedCallback = async (payload: WindowStreamData): Promise<void> => {
|
|
339
|
-
const snapshot = (await controller.getSnapshot(payload.windowSummary.config.workspaceId, "workspace")) as WorkspaceSnapshotResult;
|
|
340
|
-
|
|
341
|
-
const frameConfig: FrameCreateConfig = {
|
|
342
|
-
summary: snapshot.frameSummary
|
|
343
|
-
};
|
|
344
|
-
const frame = ioc.getModel<"frame">("frame", frameConfig);
|
|
345
|
-
|
|
346
|
-
const workspaceConfig: WorkspaceIoCCreateConfig = { frame, snapshot };
|
|
347
|
-
|
|
348
|
-
const workspace = ioc.getModel<"workspace">("workspace", workspaceConfig);
|
|
349
|
-
|
|
350
|
-
const windowParent = workspace.getBox((parent) => parent.id === payload.windowSummary.parentId);
|
|
351
|
-
const foundWindow = windowParent.children.find((child) => child.type === "window" && child.elementId === payload.windowSummary.itemId);
|
|
352
|
-
|
|
353
|
-
callback(foundWindow as IOConnectWorkspaces.WorkspaceWindow);
|
|
354
|
-
};
|
|
355
|
-
const unsubscribe = await controller.processGlobalSubscription(wrappedCallback, "window", "selected");
|
|
356
|
-
return unsubscribe;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
const waitForFrame = async (id: string): Promise<IOConnectWorkspaces.Frame> => {
|
|
360
|
-
nonEmptyStringDecoder.runWithException(id);
|
|
361
|
-
return new Promise<IOConnectWorkspaces.Frame>((res, rej) => {
|
|
362
|
-
let unsub: IOConnectWorkspaces.Unsubscribe = () => {
|
|
363
|
-
// do nothing
|
|
364
|
-
};
|
|
365
|
-
onFrameOpened((f) => {
|
|
366
|
-
if (f.id === id) {
|
|
367
|
-
res(f);
|
|
368
|
-
unsub();
|
|
369
|
-
}
|
|
370
|
-
}).then((u) => {
|
|
371
|
-
unsub = u;
|
|
372
|
-
return getAllFrames();
|
|
373
|
-
}).then((frames) => {
|
|
374
|
-
const myFrame = frames.find((f) => f.id === id);
|
|
375
|
-
if (myFrame) {
|
|
376
|
-
res(myFrame);
|
|
377
|
-
unsub();
|
|
378
|
-
}
|
|
379
|
-
}).catch(rej);
|
|
380
|
-
});
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
return {
|
|
384
|
-
inWorkspace,
|
|
385
|
-
getBuilder,
|
|
386
|
-
getMyFrame,
|
|
387
|
-
getFrame,
|
|
388
|
-
getAllFrames,
|
|
389
|
-
getAllWorkspacesSummaries,
|
|
390
|
-
getMyWorkspace,
|
|
391
|
-
getWorkspace,
|
|
392
|
-
getWorkspaceById,
|
|
393
|
-
getAllWorkspaces,
|
|
394
|
-
getWindow,
|
|
395
|
-
getBox: getParent,
|
|
396
|
-
restoreWorkspace,
|
|
397
|
-
createWorkspace,
|
|
398
|
-
createEmptyFrame,
|
|
399
|
-
waitForFrame,
|
|
400
|
-
layouts,
|
|
401
|
-
onFrameOpened,
|
|
402
|
-
onFrameClosed,
|
|
403
|
-
onWorkspaceOpened,
|
|
404
|
-
onWorkspaceClosed,
|
|
405
|
-
onWorkspaceHibernated,
|
|
406
|
-
onWorkspaceResumed,
|
|
407
|
-
onWindowAdded,
|
|
408
|
-
onWindowLoaded,
|
|
409
|
-
onWindowRemoved,
|
|
410
|
-
onWindowMaximized,
|
|
411
|
-
onWindowRestored,
|
|
412
|
-
onWindowSelected,
|
|
413
|
-
version
|
|
414
|
-
};
|
|
415
|
-
};
|