@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
package/src/models/row.ts DELETED
@@ -1,188 +0,0 @@
1
- import { Base } from "./base/base";
2
- import { IOConnectWorkspaces } from "../../workspaces.d";
3
- import { checkThrowCallback, nonNegativeNumberDecoder, rowLockConfigDecoder, setMaximizationBoundaryAPIConfigDecoder } from "../shared/decoders";
4
- import { SubscriptionConfig } from "../types/subscription";
5
-
6
- interface PrivateData {
7
- base: Base;
8
- }
9
-
10
- const privateData = new WeakMap<Row, PrivateData>();
11
-
12
- const getBase = (model: Row): Base => {
13
- return privateData.get(model).base;
14
- };
15
-
16
- export class Row implements IOConnectWorkspaces.Row {
17
-
18
- constructor(base: Base) {
19
- privateData.set(this, { base });
20
- }
21
-
22
- public get type(): "row" {
23
- return "row";
24
- }
25
-
26
- public get id(): string {
27
- return getBase(this).getId(this);
28
- }
29
-
30
- public get frameId(): string {
31
- return getBase(this).getFrameId(this);
32
- }
33
-
34
- public get workspaceId(): string {
35
- return getBase(this).getWorkspaceId(this);
36
- }
37
-
38
- public get positionIndex(): number {
39
- return getBase(this).getPositionIndex(this);
40
- }
41
-
42
- public get children(): IOConnectWorkspaces.WorkspaceElement[] {
43
- return getBase(this).getAllChildren(this);
44
- }
45
-
46
- public get parent(): IOConnectWorkspaces.Workspace | IOConnectWorkspaces.WorkspaceBox {
47
- return getBase(this).getMyParent(this);
48
- }
49
-
50
- public get frame(): IOConnectWorkspaces.Frame {
51
- return getBase(this).getMyFrame(this);
52
- }
53
-
54
- public get workspace(): IOConnectWorkspaces.Workspace {
55
- return getBase(this).getMyWorkspace(this);
56
- }
57
-
58
- public get allowDrop(): boolean {
59
- return getBase(this).getAllowDrop(this);
60
- }
61
-
62
- public get allowSplitters(): boolean {
63
- return getBase(this).getAllowSplitters(this);
64
- }
65
-
66
- public get minWidth(): number {
67
- return getBase(this).getMinWidth(this);
68
- }
69
-
70
- public get minHeight(): number {
71
- return getBase(this).getMinHeight(this);
72
- }
73
-
74
- public get maxWidth(): number {
75
- return getBase(this).getMaxWidth(this);
76
- }
77
-
78
- public get maxHeight(): number {
79
- return getBase(this).getMaxHeight(this);
80
- }
81
-
82
- public get width(): number {
83
- return getBase(this).getWidthInPx(this);
84
- }
85
-
86
- public get height(): number {
87
- return getBase(this).getHeightInPx(this);
88
- }
89
-
90
- public get isPinned(): boolean {
91
- return getBase(this).getIsPinned(this);
92
- }
93
-
94
- public get isMaximized(): boolean {
95
- return getBase(this).getIsMaximized(this);
96
- }
97
-
98
- public get maximizationBoundary(): boolean {
99
- return getBase(this).getMaximizationBoundary(this);
100
- }
101
-
102
- public addWindow(definition: IOConnectWorkspaces.WorkspaceWindowDefinition): Promise<IOConnectWorkspaces.WorkspaceWindow> {
103
- return getBase(this).addWindow(this, definition, "row");
104
- }
105
-
106
- public async addGroup(definition?: IOConnectWorkspaces.BoxDefinition): Promise<IOConnectWorkspaces.Group> {
107
- if (definition?.type && definition.type !== "group") {
108
- throw new Error(`Expected a group definition, but received ${definition.type}`);
109
- }
110
- return getBase(this).addParent<IOConnectWorkspaces.Group>(this, "group", "row", definition);
111
- }
112
-
113
- public async addColumn(definition?: IOConnectWorkspaces.BoxDefinition): Promise<IOConnectWorkspaces.Column> {
114
- if (definition?.type && definition.type !== "column") {
115
- throw new Error(`Expected a column definition, but received ${definition.type}`);
116
- }
117
- return getBase(this).addParent<IOConnectWorkspaces.Column>(this, "column", "row", definition);
118
- }
119
-
120
- public async addRow(): Promise<Row> {
121
- throw new Error("Adding rows as row children is not supported");
122
- }
123
-
124
- public removeChild(predicate: (child: IOConnectWorkspaces.WorkspaceElement) => boolean): Promise<void> {
125
- return getBase(this).removeChild(this, predicate);
126
- }
127
-
128
- public maximize(): Promise<void> {
129
- return getBase(this).maximize(this);
130
- }
131
-
132
- public restore(): Promise<void> {
133
- return getBase(this).restore(this);
134
- }
135
-
136
- public close(): Promise<void> {
137
- return getBase(this).close(this);
138
- }
139
-
140
- public lock(config?: IOConnectWorkspaces.RowLockConfig | ((config: IOConnectWorkspaces.RowLockConfig) => IOConnectWorkspaces.RowLockConfig)): Promise<void> {
141
- let lockConfigResult = undefined;
142
-
143
- if (typeof config === "function") {
144
- const currentLockConfig = {
145
- allowDrop: this.allowDrop,
146
- allowSplitters: this.allowSplitters
147
- };
148
-
149
- lockConfigResult = config(currentLockConfig);
150
- } else {
151
- lockConfigResult = config;
152
- }
153
-
154
- const verifiedConfig = lockConfigResult === undefined ? undefined : rowLockConfigDecoder.runWithException(lockConfigResult);
155
-
156
- return getBase(this).lockContainer(this, verifiedConfig);
157
- }
158
-
159
- public async setHeight(height: number): Promise<void> {
160
- nonNegativeNumberDecoder.runWithException(height);
161
- return getBase(this).setHeight(this, height);
162
- }
163
-
164
-
165
- public async onLockConfigurationChanged(callback: (config: IOConnectWorkspaces.RowLockConfig) => void): Promise<IOConnectWorkspaces.Unsubscribe> {
166
- checkThrowCallback(callback);
167
- const wrappedCallback = async (): Promise<void> => {
168
- await this.workspace.refreshReference();
169
- callback({
170
- allowDrop: this.allowDrop,
171
- allowSplitters: this.allowSplitters
172
- });
173
- };
174
- const config: SubscriptionConfig = {
175
- callback: wrappedCallback,
176
- action: "lock-configuration-changed",
177
- eventType: "container",
178
- scope: "container"
179
- };
180
- const unsubscribe = await getBase(this).processLocalSubscription(this, config);
181
- return unsubscribe;
182
- }
183
- public async setMaximizationBoundary(config: IOConnectWorkspaces.SetMaximizationBoundaryConfig): Promise<void> {
184
- const validatedConfig = setMaximizationBoundaryAPIConfigDecoder.runWithException(config);
185
- return getBase(this).setMaximizationBoundary(this, validatedConfig);
186
- }
187
-
188
- }
@@ -1,309 +0,0 @@
1
- import { checkThrowCallback, nonEmptyStringDecoder, windowLockConfigDecoder, elementResizeConfigDecoder } from "../shared//decoders";
2
- import { SubscriptionConfig } from "../types/subscription";
3
- import { PrivateDataManager } from "../shared/privateDataManager";
4
- import { WindowPrivateData } from "../types/privateData";
5
- import { IOConnectWorkspaces } from "../../workspaces";
6
- import { GDWindow } from "../types/glue";
7
- import { Row } from "./row";
8
- import { Column } from "./column";
9
- import { Group } from "./group";
10
-
11
- interface PrivateData {
12
- manager: PrivateDataManager;
13
- }
14
-
15
- const data = new WeakMap<Window, PrivateData>();
16
-
17
- const getData = (model: Window): WindowPrivateData => {
18
- return data.get(model).manager.getWindowData(model);
19
- };
20
-
21
- export class Window implements IOConnectWorkspaces.WorkspaceWindow {
22
-
23
- constructor(dataManager: PrivateDataManager) {
24
- data.set(this, { manager: dataManager });
25
- }
26
-
27
- public get id(): string {
28
- return getData(this).config.windowId;
29
- }
30
-
31
- public get elementId(): string {
32
- return getData(this).id;
33
- }
34
-
35
- public get type(): "window" {
36
- return "window";
37
- }
38
-
39
- public get frameId(): string {
40
- return getData(this).frame.id;
41
- }
42
-
43
- public get workspaceId(): string {
44
- return getData(this).workspace.id;
45
- }
46
-
47
- public get positionIndex(): number {
48
- return getData(this).config.positionIndex;
49
- }
50
-
51
- public get isMaximized(): boolean {
52
- return getData(this).config.isMaximized;
53
- }
54
-
55
- public get isLoaded(): boolean {
56
- return getData(this).controller.checkIsWindowLoaded(this.id);
57
- }
58
-
59
- public get isSelected(): boolean {
60
- return getData(this).config.isSelected;
61
- }
62
-
63
- public get focused(): boolean {
64
- return this.getGdWindow().isFocused;
65
- }
66
-
67
- public get title(): string {
68
- return getData(this).config.title;
69
- }
70
-
71
- public get allowExtract(): boolean {
72
- return getData(this).config.allowExtract;
73
- }
74
-
75
- public get allowReorder(): boolean {
76
- return getData(this).config.allowReorder;
77
- }
78
-
79
- public get showCloseButton(): boolean {
80
- return getData(this).config.showCloseButton;
81
- }
82
-
83
- public get width(): number {
84
- return getData(this).config.widthInPx;
85
- }
86
-
87
- public get height(): number {
88
- return getData(this).config.heightInPx;
89
- }
90
-
91
- public get minWidth(): number {
92
- return getData(this).config.minWidth;
93
- }
94
-
95
- public get minHeight(): number {
96
- return getData(this).config.minHeight;
97
- }
98
-
99
- public get maxWidth(): number {
100
- return getData(this).config.maxWidth;
101
- }
102
-
103
- public get maxHeight(): number {
104
- return getData(this).config.maxHeight;
105
- }
106
-
107
- public get workspace(): IOConnectWorkspaces.Workspace {
108
- return getData(this).workspace;
109
- }
110
-
111
- public get frame(): IOConnectWorkspaces.Frame {
112
- return getData(this).frame;
113
- }
114
-
115
- public get parent(): IOConnectWorkspaces.Workspace | IOConnectWorkspaces.Row | IOConnectWorkspaces.Column | IOConnectWorkspaces.Group {
116
- return getData(this).parent;
117
- }
118
-
119
- public get appName(): string {
120
- return getData(this).config.appName;
121
- }
122
-
123
- public async forceLoad(): Promise<void> {
124
- if (this.isLoaded) {
125
- return;
126
- }
127
- const controller = getData(this).controller;
128
- const itemId = getData(this).id;
129
-
130
- const windowId = await controller.forceLoadWindow(itemId);
131
-
132
- getData(this).config.windowId = windowId;
133
-
134
- await this.workspace.refreshReference();
135
- }
136
-
137
- public async focus(): Promise<void> {
138
- const id = getData(this).id;
139
- const controller = getData(this).controller;
140
-
141
- await controller.focusItem(id);
142
-
143
- await this.workspace.refreshReference();
144
- }
145
-
146
- public async close(): Promise<void> {
147
- const id = getData(this).id;
148
- const controller = getData(this).controller;
149
-
150
- await controller.closeItem(id);
151
-
152
- await getData(this)
153
- .parent
154
- .removeChild((child) => child.id === id);
155
-
156
- await this.workspace.refreshReference();
157
- }
158
-
159
- public async setTitle(title: string): Promise<void> {
160
- nonEmptyStringDecoder.runWithException(title);
161
-
162
- const itemId = getData(this).id;
163
- const controller = getData(this).controller;
164
-
165
- await controller.setItemTitle(itemId, title);
166
-
167
- await this.workspace.refreshReference();
168
- }
169
-
170
- public async maximize(): Promise<void> {
171
- const id = getData(this).id;
172
- const controller = getData(this).controller;
173
-
174
- await controller.maximizeItem(id);
175
-
176
- await this.workspace.refreshReference();
177
- }
178
-
179
- public async restore(): Promise<void> {
180
- const id = getData(this).id;
181
- const controller = getData(this).controller;
182
-
183
- await controller.restoreItem(id);
184
-
185
- await this.workspace.refreshReference();
186
- }
187
-
188
- public async eject(): Promise<GDWindow> {
189
- if (!this.isLoaded) {
190
- throw new Error("Cannot eject this window, because it is not loaded yet");
191
- }
192
- const itemId: string = getData(this).id;
193
-
194
- const newWindowId: string = await getData(this).controller.ejectWindow(itemId);
195
-
196
- getData(this).config.windowId = newWindowId;
197
-
198
- await this.workspace.refreshReference();
199
-
200
- return this.getGdWindow();
201
- }
202
-
203
- public getGdWindow(): GDWindow {
204
- if (!this.isLoaded) {
205
- throw new Error("Cannot fetch this GD window, because the window is not yet loaded");
206
- }
207
-
208
- const myId = getData(this).config.windowId;
209
- const controller = getData(this).controller;
210
-
211
- return controller.getGDWindow(myId);
212
- }
213
-
214
- public async moveTo(parent: IOConnectWorkspaces.Row | IOConnectWorkspaces.Column | IOConnectWorkspaces.Group): Promise<void> {
215
- if (!(parent instanceof Row || parent instanceof Column || parent instanceof Group)) {
216
- throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");
217
- }
218
-
219
- const myId = getData(this).id;
220
- const controller = getData(this).controller;
221
-
222
- const foundParent = await controller.getParent((p) => p.id === parent.id);
223
-
224
- if (!foundParent) {
225
- throw new Error("Cannot move the window to the selected parent, because this parent does not exist.");
226
- }
227
-
228
- await controller.moveWindowTo(myId, parent.id);
229
-
230
- await this.workspace.refreshReference();
231
- }
232
-
233
- public async lock(config?: IOConnectWorkspaces.WorkspaceWindowLockConfig | ((config: IOConnectWorkspaces.WorkspaceWindowLockConfig) => IOConnectWorkspaces.WorkspaceWindowLockConfig)): Promise<void> {
234
- let lockConfigResult = undefined;
235
-
236
- if (typeof config === "function") {
237
- const currentLockConfig = {
238
- allowExtract: this.allowExtract,
239
- allowReorder: this.allowReorder,
240
- showCloseButton: this.showCloseButton
241
- };
242
- lockConfigResult = config(currentLockConfig);
243
- } else {
244
- lockConfigResult = config;
245
- }
246
-
247
- const verifiedConfig = lockConfigResult === undefined ? undefined : windowLockConfigDecoder.runWithException(lockConfigResult);
248
- const windowPlacementId = getData(this).id;
249
- await getData(this).controller.lockWindow(windowPlacementId, verifiedConfig);
250
- await this.workspace.refreshReference();
251
- }
252
-
253
- public async setSize(config: IOConnectWorkspaces.ElementResizeConfig): Promise<void> {
254
- const verifiedConfig = elementResizeConfigDecoder.runWithException(config);
255
-
256
- if (!verifiedConfig.width && !verifiedConfig.height) {
257
- throw new Error("Expected either width or height to be passed.");
258
- }
259
-
260
- const myId = getData(this).id;
261
- const controller = getData(this).controller;
262
-
263
- await controller.resizeItem(myId, {
264
- height: verifiedConfig.height,
265
- width: verifiedConfig.width,
266
- relative: false
267
- });
268
-
269
- await this.workspace.refreshReference();
270
- }
271
-
272
- public async onRemoved(callback: () => void): Promise<IOConnectWorkspaces.Unsubscribe> {
273
- checkThrowCallback(callback);
274
- const id = getData(this).id;
275
- const wrappedCallback = async (): Promise<void> => {
276
- await this.workspace.refreshReference();
277
- callback();
278
- };
279
- const config: SubscriptionConfig = {
280
- callback: wrappedCallback,
281
- action: "removed",
282
- eventType: "window",
283
- scope: "window"
284
- };
285
- const unsubscribe = await getData(this).controller.processLocalSubscription(config, id);
286
- return unsubscribe;
287
- }
288
-
289
- public async onLockConfigurationChanged(callback:(config:IOConnectWorkspaces.WorkspaceWindowLockConfig)=>void): Promise<IOConnectWorkspaces.Unsubscribe>{
290
- checkThrowCallback(callback);
291
- const id = getData(this).id;
292
- const wrappedCallback = async (): Promise<void> => {
293
- await this.workspace.refreshReference();
294
- callback({
295
- allowExtract: this.allowExtract,
296
- allowReorder: this.allowReorder,
297
- showCloseButton: this.showCloseButton
298
- });
299
- };
300
- const config: SubscriptionConfig = {
301
- callback: wrappedCallback,
302
- action: "lock-configuration-changed",
303
- eventType: "window",
304
- scope: "window"
305
- };
306
- const unsubscribe = await getData(this).controller.processLocalSubscription(config, id);
307
- return unsubscribe;
308
- }
309
- }