@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.
Files changed (40) hide show
  1. package/dist/workspaces.es.js +4295 -4648
  2. package/dist/workspaces.es.js.map +1 -1
  3. package/dist/workspaces.umd.js +5206 -5559
  4. package/dist/workspaces.umd.js.map +1 -1
  5. package/dist/workspaces.umd.min.js +1 -1
  6. package/package.json +36 -50
  7. package/workspaces.d.ts +8 -0
  8. package/rollup.config.js +0 -54
  9. package/src/builders/baseBuilder.ts +0 -50
  10. package/src/builders/parentBuilder.ts +0 -62
  11. package/src/builders/workspaceBuilder.ts +0 -102
  12. package/src/communication/bridge.ts +0 -263
  13. package/src/communication/constants.ts +0 -202
  14. package/src/communication/interop-transport.ts +0 -175
  15. package/src/controllers/base.ts +0 -487
  16. package/src/controllers/main.ts +0 -541
  17. package/src/controllers/shortcuts.ts +0 -28
  18. package/src/index.ts +0 -23
  19. package/src/main.ts +0 -415
  20. package/src/models/base/base.ts +0 -397
  21. package/src/models/column.ts +0 -187
  22. package/src/models/frame.ts +0 -368
  23. package/src/models/group.ts +0 -237
  24. package/src/models/row.ts +0 -188
  25. package/src/models/window.ts +0 -309
  26. package/src/models/workspace.ts +0 -717
  27. package/src/shared/decoders.ts +0 -939
  28. package/src/shared/ioc.ts +0 -227
  29. package/src/shared/privateDataManager.ts +0 -93
  30. package/src/shared/promisePlus.ts +0 -34
  31. package/src/shared/promiseWrapper.ts +0 -11
  32. package/src/types/builders.ts +0 -10
  33. package/src/types/controller.ts +0 -79
  34. package/src/types/glue.ts +0 -37
  35. package/src/types/ioc.ts +0 -33
  36. package/src/types/privateData.ts +0 -92
  37. package/src/types/protocol.ts +0 -453
  38. package/src/types/subscription.ts +0 -31
  39. package/temp.d.ts +0 -49
  40. package/tsconfig.json +0 -10
@@ -1,541 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Bridge } from "../communication/bridge";
3
- import { IsWindowInSwimlaneResult, WorkspaceCreateConfigProtocol, WorkspaceSnapshotResult, FrameSummariesResult, WorkspaceSummariesResult, LayoutSummariesResult, ExportedLayoutsResult, FrameSnapshotResult, AddItemResult, WindowStreamData, FrameStateResult, FrameBoundsResult, WorkspaceStreamData } from "../types/protocol";
4
- import { OPERATIONS } from "../communication/constants";
5
- import { SubscriptionConfig, WorkspaceEventType, WorkspaceEventAction } from "../types/subscription";
6
- import { Workspace } from "../models/workspace";
7
- import { Frame } from "../models/frame";
8
- import { Child, ContainerLockConfig, SubParentTypes } from "../types/builders";
9
- import { RefreshChildrenConfig } from "../types/privateData";
10
- import { IOConnectWorkspaces } from "../../workspaces";
11
- import { WorkspacesController } from "../types/controller";
12
- import { GDWindow } from "../types/glue";
13
- import { BaseController } from "./base";
14
- import { UnsubscribeFunction } from "callback-registry";
15
- import { ShortcutsController } from "./shortcuts";
16
-
17
- export class MainController implements WorkspacesController {
18
-
19
- constructor(
20
- private readonly bridge: Bridge,
21
- private readonly base: BaseController,
22
- private readonly shortcutsController: ShortcutsController
23
- ) { }
24
-
25
- public checkIsWindowLoaded(windowId: string): boolean {
26
- return this.base.checkIsWindowLoaded(windowId);
27
- }
28
-
29
- public async checkIsInSwimlane(windowId: string): Promise<boolean> {
30
-
31
- const controlResult = await this.bridge.send<IsWindowInSwimlaneResult>(OPERATIONS.isWindowInWorkspace.name, { itemId: windowId });
32
-
33
- return controlResult.inWorkspace;
34
- }
35
-
36
- public async createWorkspace(definition: IOConnectWorkspaces.WorkspaceDefinition, saveConfig?: IOConnectWorkspaces.WorkspaceCreateConfig): Promise<Workspace> {
37
- const createConfig: WorkspaceCreateConfigProtocol = Object.assign({}, definition, { saveConfig });
38
-
39
- return await this.base.createWorkspace(createConfig);
40
- }
41
-
42
- public async createEmptyFrame(definition: IOConnectWorkspaces.EmptyFrameDefinition): Promise<Frame> {
43
- return await this.base.createEmptyFrame(definition);
44
- }
45
-
46
- public async initFrame(frameId: string, config: IOConnectWorkspaces.FrameInitializationConfig): Promise<void> {
47
- return this.base.initFrame(frameId, config);
48
- }
49
-
50
- public async restoreWorkspace(name: string, options?: IOConnectWorkspaces.RestoreWorkspaceConfig): Promise<Workspace> {
51
- const allLayouts = await this.getLayoutSummaries();
52
-
53
- const layoutExists = allLayouts.some((summary) => summary.name === name);
54
-
55
- if (!layoutExists) {
56
- throw new Error(`This layout: ${name} cannot be restored, because it doesn't exist.`);
57
- }
58
-
59
- if (options?.frameId) {
60
- const allFrameSummaries = await this.bridge.send<FrameSummariesResult>(OPERATIONS.getAllFramesSummaries.name);
61
-
62
- const foundMatchingFrame = allFrameSummaries.summaries.some((summary) => summary.id === options.frameId);
63
-
64
- if (!foundMatchingFrame) {
65
- throw new Error(`Cannot reuse the frame with id: ${options.frameId}, because there is no frame with that ID found`);
66
- }
67
- }
68
-
69
- return await this.base.restoreWorkspace(name, options);
70
- }
71
-
72
- public async add(type: "container" | "window", parentId: string, parentType: "row" | "column" | "group" | "workspace", definition: IOConnectWorkspaces.WorkspaceWindowDefinition | IOConnectWorkspaces.BoxDefinition): Promise<AddItemResult> {
73
- return await this.base.add(type, parentId, parentType, definition);
74
- }
75
-
76
- public processLocalSubscription(config: SubscriptionConfig, levelId: string): Promise<IOConnectWorkspaces.Unsubscribe> {
77
- const desktopGlobal = (window as any).glue42gd || (window as any).iodesktop;
78
-
79
- return desktopGlobal ?
80
- this.handleEnterpriseLocalSubscription(config, levelId) :
81
- this.handleCoreLocalSubscription(config, levelId);
82
- }
83
-
84
- public processGlobalSubscription(callback: (callbackData: unknown) => void | Promise<void>, eventType: WorkspaceEventType, action: WorkspaceEventAction): Promise<IOConnectWorkspaces.Unsubscribe> {
85
- const desktopGlobal = (window as any).glue42gd || (window as any).iodesktop;
86
-
87
- return desktopGlobal ?
88
- this.handleEnterpriseGlobalSubscription(callback, eventType, action) :
89
- this.handleCoreGlobalSubscription(callback, eventType, action);
90
- }
91
-
92
- public async getFrame(selector: { windowId?: string; predicate?: (frame: Frame) => boolean }): Promise<Frame> {
93
-
94
- if (selector.windowId) {
95
- return await this.base.getFrame(selector.windowId);
96
- }
97
-
98
- if (selector.predicate) {
99
- return (await this.getFrames(selector.predicate))[0];
100
- }
101
-
102
- throw new Error(`The provided selector is not valid: ${JSON.stringify(selector)}`);
103
- }
104
-
105
- public async getFrames(predicate?: (frame: Frame) => boolean): Promise<Frame[]> {
106
-
107
- const allFrameSummaries = await this.bridge.send<FrameSummariesResult>(OPERATIONS.getAllFramesSummaries.name);
108
-
109
- return this.base.getFrames(allFrameSummaries.summaries, predicate);
110
- }
111
-
112
- public getWorkspaceById(workspaceId: string): Promise<Workspace> {
113
- return this.base.fetchWorkspace(workspaceId);
114
- }
115
-
116
- public async getWorkspaceByWindowId(itemId: string): Promise<Workspace> {
117
- const desktopGlobal = (window as any).glue42gd || (window as any).iodesktop;
118
-
119
- if (!desktopGlobal) {
120
- // workspace-ui-core doesn't accept an itemId for getWorkspaceSnapshot, but GD does and getWorkspaceSnapshot is significantly faster
121
- return (await this.getWorkspaces((wsp) => !!wsp.getWindow((w) => w.id === itemId)))[0];
122
- }
123
- return this.base.fetchWorkspace(itemId);
124
- }
125
-
126
- public transformStreamPayloadToWorkspace(payload: WorkspaceStreamData): Promise<Workspace> {
127
- return this.base.transformStreamPayloadToWorkspace(payload);
128
- }
129
-
130
- public async getWorkspace(predicate: (workspace: Workspace) => boolean): Promise<Workspace> {
131
- let foundWorkspace: Workspace;
132
-
133
- await this.iterateWorkspaces((wsp, end) => {
134
- if (predicate(wsp)) {
135
- foundWorkspace = wsp;
136
- end();
137
- }
138
- });
139
-
140
- return foundWorkspace;
141
- }
142
-
143
- public async getWorkspaces(predicate?: (workspace: Workspace) => boolean): Promise<Workspace[]> {
144
- const matchingWorkspaces: Workspace[] = [] as Workspace[];
145
-
146
- await this.iterateWorkspaces((wsp) => {
147
- if (!predicate || predicate(wsp)) {
148
- matchingWorkspaces.push(wsp);
149
- }
150
- });
151
-
152
- return matchingWorkspaces;
153
- }
154
-
155
- public async getWorkspacesByFrameId(frameId: string): Promise<Workspace[]> {
156
- const workspaceSummaries = await this.getAllWorkspaceSummaries();
157
- const summariesForFrame = workspaceSummaries.filter((s) => s.frameId === frameId);
158
-
159
- const workspacesForFrame = await Promise.all(summariesForFrame.map((summary) => {
160
- return this.base.fetchWorkspace(summary.id);
161
- }));
162
-
163
- return workspacesForFrame;
164
- }
165
-
166
- public async getAllWorkspaceSummaries(): Promise<IOConnectWorkspaces.WorkspaceSummary[]> {
167
-
168
- const allSummariesResult = await this.bridge.send<WorkspaceSummariesResult>(OPERATIONS.getAllWorkspacesSummaries.name, {});
169
-
170
- return this.base.getAllWorkspaceSummaries(allSummariesResult);
171
- }
172
-
173
- public async getWindow(predicate: (swimlaneWindow: IOConnectWorkspaces.WorkspaceWindow) => boolean): Promise<IOConnectWorkspaces.WorkspaceWindow> {
174
- let resultWindow: IOConnectWorkspaces.WorkspaceWindow;
175
-
176
- await this.iterateWorkspaces((wsp, end) => {
177
- const foundWindow = wsp.getWindow(predicate);
178
-
179
- if (foundWindow) {
180
- resultWindow = foundWindow;
181
- end();
182
- }
183
- });
184
-
185
- return resultWindow;
186
- }
187
-
188
- public async getParent(predicate: (parent: IOConnectWorkspaces.WorkspaceBox) => boolean): Promise<IOConnectWorkspaces.WorkspaceBox> {
189
- let resultParent: IOConnectWorkspaces.WorkspaceBox;
190
-
191
- await this.iterateWorkspaces((wsp, end) => {
192
-
193
- const foundParent = wsp.getBox(predicate);
194
-
195
- if (foundParent) {
196
- resultParent = foundParent;
197
- end();
198
- }
199
- });
200
-
201
- return resultParent;
202
- }
203
-
204
- public async getLayoutSummaries(): Promise<IOConnectWorkspaces.WorkspaceLayoutSummary[]> {
205
- const allLayouts = await this.bridge.send<LayoutSummariesResult>(OPERATIONS.getAllLayoutsSummaries.name);
206
- return allLayouts.summaries;
207
- }
208
-
209
- public async deleteLayout(name: string): Promise<void> {
210
- await this.bridge.send(OPERATIONS.deleteLayout.name, { name });
211
- }
212
-
213
- public async exportLayout(predicate?: (layout: IOConnectWorkspaces.WorkspaceLayout) => boolean): Promise<IOConnectWorkspaces.WorkspaceLayout[]> {
214
- const allLayoutsResult = await this.bridge.send<ExportedLayoutsResult>(OPERATIONS.exportAllLayouts.name);
215
- return allLayoutsResult.layouts.reduce<IOConnectWorkspaces.WorkspaceLayout[]>((matchingLayouts, layout) => {
216
-
217
- if (!predicate || predicate(layout)) {
218
- matchingLayouts.push(layout);
219
- }
220
-
221
- return matchingLayouts;
222
- }, []);
223
- }
224
-
225
- public async saveLayout(config: IOConnectWorkspaces.WorkspaceLayoutSaveConfig): Promise<IOConnectWorkspaces.WorkspaceLayout> {
226
- return await this.bridge.send(OPERATIONS.saveLayout.name, config);
227
- }
228
-
229
- public async importLayouts(layouts: IOConnectWorkspaces.WorkspaceLayout[], mode: "replace" | "merge"): Promise<void> {
230
- const desktopGlobal = (window as any).glue42gd || (window as any).iodesktop;
231
-
232
- if (desktopGlobal) {
233
- try {
234
- // ensuring backwards compatibility
235
- await this.bridge.send(OPERATIONS.importLayouts.name, { layouts, mode });
236
- } catch (error) {
237
- // this is a soft-reversal to handle an import issue with GD
238
- await Promise.all(layouts.map((layout) => this.bridge.send(OPERATIONS.importLayout.name, { layout, mode })));
239
- }
240
- return;
241
- }
242
-
243
- await this.base.importLayouts(layouts, mode);
244
- }
245
-
246
- public handleOnSaved(callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): UnsubscribeFunction {
247
- return this.base.handleOnSaved(callback);
248
- }
249
-
250
- public handleOnRemoved(callback: (layout: IOConnectWorkspaces.WorkspaceLayout) => void): UnsubscribeFunction {
251
- return this.base.handleOnRemoved(callback);
252
- }
253
-
254
- public async bundleWorkspaceTo(type: "row" | "column", workspaceId: string): Promise<void> {
255
- return await this.base.bundleWorkspaceTo(type, workspaceId);
256
- }
257
-
258
- public async bundleItemTo(type: "row" | "column", id: string): Promise<void> {
259
- return await this.base.bundleItemTo(type, id);
260
- }
261
-
262
- public getWorkspaceContext(workspaceId: string): Promise<any> {
263
- return this.base.getWorkspaceContext(workspaceId);
264
- }
265
-
266
- public setWorkspaceContext(workspaceId: string, data: any): Promise<void> {
267
- return this.base.setWorkspaceContext(workspaceId, data);
268
- }
269
-
270
- public updateWorkspaceContext(workspaceId: string, data: any): Promise<void> {
271
- return this.base.updateWorkspaceContext(workspaceId, data);
272
- }
273
-
274
- public subscribeWorkspaceContextUpdated(workspaceId: string, callback: (data: any) => void): Promise<import("callback-registry").UnsubscribeFunction> {
275
- return this.base.subscribeWorkspaceContextUpdated(workspaceId, callback);
276
- }
277
-
278
- public async restoreItem(itemId: string): Promise<void> {
279
- return await this.base.restoreItem(itemId);
280
- }
281
-
282
- public async maximizeItem(itemId: string): Promise<void> {
283
- return await this.base.maximizeItem(itemId);
284
- }
285
-
286
- public async focusItem(itemId: string): Promise<void> {
287
- return await this.base.focusItem(itemId);
288
- }
289
-
290
- public async changeFrameState(frameId: string, state: IOConnectWorkspaces.FrameState): Promise<void> {
291
- await this.bridge.send<void>(OPERATIONS.changeFrameState.name, { frameId, requestedState: state });
292
- }
293
-
294
- public async getFrameBounds(frameId: string): Promise<IOConnectWorkspaces.FrameBounds> {
295
- const frameResult = await this.bridge.send<FrameBoundsResult>(OPERATIONS.getFrameBounds.name, { itemId: frameId });
296
- return frameResult.bounds;
297
- }
298
-
299
- public async getFrameState(frameId: string): Promise<IOConnectWorkspaces.FrameState> {
300
- const frameResult = await this.bridge.send<FrameStateResult>(OPERATIONS.getFrameState.name, { itemId: frameId });
301
- return frameResult.state;
302
- }
303
-
304
- public async closeItem(itemId: string): Promise<void> {
305
- return await this.base.closeItem(itemId);
306
- }
307
-
308
- public async resizeItem(itemId: string, config: IOConnectWorkspaces.ResizeConfig): Promise<void> {
309
- return await this.base.resizeItem(itemId, config);
310
- }
311
-
312
- public async setMaximizationBoundary(itemId: string, config: IOConnectWorkspaces.SetMaximizationBoundaryConfig): Promise<void> {
313
- return await this.base.setMaximizationBoundary(itemId, config);
314
- }
315
-
316
- public async showWorkspaceLoadingAnimation(workspaceId: string): Promise<void> {
317
- return await this.base.showWorkspaceLoadingAnimation(workspaceId);
318
- }
319
-
320
- public async hideWorkspaceLoadingAnimation(workspaceId: string): Promise<void> {
321
- return await this.base.hideWorkspaceLoadingAnimation(workspaceId);
322
- }
323
-
324
- public async moveFrame(itemId: string, config: IOConnectWorkspaces.MoveConfig): Promise<void> {
325
- return await this.base.moveFrame(itemId, config);
326
- }
327
-
328
- public getGDWindow(itemId: string): GDWindow {
329
- return this.base.getGDWindow(itemId);
330
- }
331
-
332
- public async forceLoadWindow(itemId: string): Promise<string> {
333
- const windowId = await this.base.forceLoadWindow(itemId);
334
-
335
- await this.base.notifyWindowAdded(windowId);
336
-
337
- return windowId;
338
- }
339
-
340
- public async ejectWindow(itemId: string): Promise<string> {
341
- const windowId: string = (await this.base.ejectWindow(itemId)).windowId;
342
-
343
- await this.base.notifyWindowAdded(windowId);
344
-
345
- return windowId;
346
- }
347
-
348
- public async moveWindowTo(itemId: string, newParentId: string): Promise<void> {
349
- return await this.base.moveWindowTo(itemId, newParentId);
350
- }
351
-
352
- public async getSnapshot(itemId: string, type: "workspace"): Promise<WorkspaceSnapshotResult>
353
- public async getSnapshot(itemId: string, type: "frame"): Promise<FrameSnapshotResult>
354
- public async getSnapshot(itemId: string, type: "workspace" | "frame"): Promise<WorkspaceSnapshotResult | FrameSnapshotResult> {
355
- return await this.base.getSnapshot(itemId, type);
356
- }
357
-
358
- public async setItemTitle(itemId: string, title: string): Promise<void> {
359
- return await this.base.setItemTitle(itemId, title);
360
- }
361
-
362
- public flatChildren(children: Child[]): Child[] {
363
- return children.reduce<Child[]>((soFar, child) => {
364
-
365
- soFar.push(child);
366
-
367
- if (child.type !== "window") {
368
- soFar.push(...this.flatChildren(child.children));
369
- }
370
-
371
- return soFar;
372
- }, []);
373
- }
374
-
375
- public refreshChildren(config: RefreshChildrenConfig): Child[] {
376
- return this.base.refreshChildren(config);
377
- }
378
-
379
- public iterateFindChild(children: Child[], predicate: (child: Child) => boolean): Child {
380
- return this.base.iterateFindChild(children, predicate);
381
- }
382
-
383
- public iterateFilterChildren(children: Child[], predicate: (child: Child) => boolean): Child[] {
384
- return this.base.iterateFilterChildren(children, predicate);
385
- }
386
-
387
- public hibernateWorkspace(workspaceId: string): Promise<void> {
388
- return this.base.hibernateWorkspace(workspaceId);
389
- }
390
-
391
- public resumeWorkspace(workspaceId: string): Promise<void> {
392
- return this.base.resumeWorkspace(workspaceId);
393
- }
394
-
395
- public lockWorkspace(workspaceId: string, config?: IOConnectWorkspaces.WorkspaceLockConfig): Promise<void> {
396
- return this.base.lockWorkspace(workspaceId, config);
397
- }
398
-
399
- public lockWindow(windowPlacementId: string, config?: IOConnectWorkspaces.WorkspaceWindowLockConfig): Promise<void> {
400
- return this.base.lockWindow(windowPlacementId, config);
401
- }
402
-
403
- public lockContainer(itemId: string, type: SubParentTypes["type"], config?: ContainerLockConfig): Promise<void> {
404
- return this.base.lockContainer(itemId, type, config);
405
- }
406
-
407
- public pinWorkspace(workspaceId: string, icon?: string): Promise<void> {
408
- return this.base.pinWorkspace(workspaceId, icon);
409
- }
410
-
411
- public unpinWorkspace(workspaceId: string): Promise<void> {
412
- return this.base.unpinWorkspace(workspaceId);
413
- }
414
-
415
- public getWorkspaceIcon(workspaceId: string): Promise<string> {
416
- return this.base.getWorkspaceIcon(workspaceId);
417
- }
418
-
419
- public setWorkspaceIcon(workspaceId: string, icon: string): Promise<void> {
420
- return this.base.setWorkspaceIcon(workspaceId, icon);
421
- }
422
-
423
- public async getFrameConstraints(frameId: string): Promise<IOConnectWorkspaces.FrameConstraints> {
424
- const frameSnapshot = await this.getSnapshot(frameId, "frame");
425
-
426
- return {
427
- minWidth: frameSnapshot.config.minWidth,
428
- maxWidth: frameSnapshot.config.maxWidth,
429
- minHeight: frameSnapshot.config.minHeight,
430
- maxHeight: frameSnapshot.config.maxHeight,
431
- };
432
- }
433
-
434
- public registerShortcut(shortcut: string, frameId: string, callback: () => void): Promise<UnsubscribeFunction> {
435
- return this.shortcutsController.registerShortcut(shortcut, frameId, callback);
436
- }
437
-
438
- public getPlatformFrameId(): Promise<{id?: string}> {
439
- return this.base.getPlatformFrameId();
440
- }
441
-
442
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
443
- private async handleCoreLocalSubscription(config: SubscriptionConfig, levelId: string): Promise<IOConnectWorkspaces.Unsubscribe> {
444
- await this.bridge.createCoreEventSubscription();
445
-
446
- config.scopeId = config.scopeId || levelId;
447
-
448
- if (config.eventType === "window" && config.action === "loaded") {
449
- const originalCB = config.callback;
450
-
451
- const wrappedCB = async (callbackData: WindowStreamData): Promise<void> => {
452
-
453
- await this.base.notifyWindowAdded(callbackData.windowSummary.config.windowId);
454
-
455
- originalCB(callbackData);
456
- };
457
-
458
- config.callback = wrappedCB;
459
- }
460
-
461
- return this.bridge.handleCoreSubscription(config);
462
- }
463
-
464
- private handleEnterpriseLocalSubscription(config: SubscriptionConfig, levelId: string): Promise<IOConnectWorkspaces.Unsubscribe> {
465
- config.scopeId = config.scopeId || levelId;
466
-
467
- if (config.eventType === "window" && config.action === "loaded") {
468
- const originalCB = config.callback;
469
-
470
- const wrappedCB = async (callbackData: WindowStreamData): Promise<void> => {
471
- await this.base.notifyWindowAdded(callbackData.windowSummary.config.windowId);
472
- originalCB(callbackData);
473
- };
474
-
475
- config.callback = wrappedCB;
476
- }
477
-
478
- return this.bridge.subscribe(config);
479
- }
480
-
481
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
482
- private async handleCoreGlobalSubscription(callback: (callbackData: unknown) => void | Promise<void>, eventType: WorkspaceEventType, action: WorkspaceEventAction): Promise<IOConnectWorkspaces.Unsubscribe> {
483
- await this.bridge.createCoreEventSubscription();
484
-
485
- const config: SubscriptionConfig = {
486
- eventType, callback, action,
487
- scope: "global",
488
- };
489
-
490
- if (eventType === "window" && action === "loaded") {
491
- const wrappedCB = async (callbackData: WindowStreamData): Promise<void> => {
492
-
493
- await this.base.notifyWindowAdded(callbackData.windowSummary.config.windowId);
494
-
495
- callback(callbackData);
496
- };
497
-
498
- config.callback = wrappedCB;
499
- }
500
-
501
- return this.bridge.handleCoreSubscription(config);
502
- }
503
-
504
- private handleEnterpriseGlobalSubscription(callback: (callbackData: unknown) => void | Promise<void>, eventType: WorkspaceEventType, action: WorkspaceEventAction): Promise<IOConnectWorkspaces.Unsubscribe> {
505
- const config: SubscriptionConfig = {
506
- eventType, callback, action,
507
- scope: "global",
508
- };
509
-
510
- if (eventType === "window" && action === "loaded") {
511
- const wrappedCB = async (callbackData: WindowStreamData): Promise<void> => {
512
-
513
- await this.base.notifyWindowAdded(callbackData.windowSummary.config.windowId);
514
-
515
- callback(callbackData);
516
- };
517
-
518
- config.callback = wrappedCB;
519
- }
520
-
521
- return this.bridge.subscribe(config);
522
- }
523
-
524
- private async iterateWorkspaces(callback: (workspace: Workspace, end: () => void) => void): Promise<void> {
525
- let ended = false;
526
-
527
- const end = (): void => { ended = true; };
528
-
529
- const workspaceSummaries = await this.getAllWorkspaceSummaries();
530
-
531
- for (const summary of workspaceSummaries) {
532
- if (ended) {
533
- return;
534
- }
535
-
536
- const wsp = await this.base.fetchWorkspace(summary.id);
537
-
538
- callback(wsp, end);
539
- }
540
- }
541
- }
@@ -1,28 +0,0 @@
1
- import { UnsubscribeFunction } from "callback-registry";
2
- import { Bridge } from "../communication/bridge";
3
- import { CLIENT_OPERATIONS, OPERATIONS } from "../communication/constants";
4
- import CallbackRegistry from "callback-registry";
5
-
6
-
7
- export class ShortcutsController {
8
- private _shortcuts = CallbackRegistry();
9
- constructor(
10
- private readonly bridge: Bridge,
11
- ) {
12
- this.bridge.onOperation((payload, caller) => {
13
- if (payload.operation === CLIENT_OPERATIONS.shortcutClicked.name) {
14
- const data = payload.data;
15
- this._shortcuts.execute(`${data.frameId}-${data.shortcut}`);
16
- }
17
- })
18
- }
19
-
20
- public async registerShortcut(shortcut: string, frameId: string, callback: () => void): Promise<UnsubscribeFunction> {
21
- await this.bridge.send<void>(OPERATIONS.registerShortcut.name, { shortcut, frameId });
22
- const un = this._shortcuts.add(`${frameId}-${shortcut}`, callback);
23
- return () => {
24
- un();
25
- this.bridge.send<void>(OPERATIONS.unregisterShortcut.name, { shortcut, frameId });
26
- }
27
- }
28
- }
package/src/index.ts DELETED
@@ -1,23 +0,0 @@
1
- import { IoC } from "./shared/ioc";
2
- import { composeAPI } from "./main";
3
- import { WorkspacesFactoryFunction } from "../workspaces";
4
-
5
- /* eslint-disable @typescript-eslint/no-explicit-any */
6
- const factoryFunction: WorkspacesFactoryFunction = async (io: any): Promise<void> => {
7
-
8
- const ioc = new IoC(io.agm, io.windows, io.layouts, io.contexts);
9
-
10
- const actualWindowId = io.interop.instance.windowId;
11
-
12
- await ioc.initiate(actualWindowId);
13
-
14
- io.workspaces = composeAPI(io, ioc);
15
- };
16
-
17
- // attach to window object
18
- if (typeof window !== "undefined") {
19
- /* eslint-disable @typescript-eslint/no-explicit-any */
20
- (window as any).IOWorkspaces = factoryFunction;
21
- }
22
-
23
- export default factoryFunction;