@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/models/base/base.ts
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
import { Workspace } from "../workspace";
|
|
2
|
-
import { ParentBuilder } from "../../builders/parentBuilder";
|
|
3
|
-
import { strictParentDefinitionDecoder, swimlaneWindowDefinitionDecoder, checkThrowCallback } from "../../shared/decoders";
|
|
4
|
-
import { SubParent, AllParentTypes, Child, SubParentTypes, AllParent, ContainerLockConfig } from "../../types/builders";
|
|
5
|
-
import { PrivateDataManager } from "../../shared/privateDataManager";
|
|
6
|
-
import { ParentPrivateData, WorkspacePrivateData } from "../../types/privateData";
|
|
7
|
-
import { Window } from "../../models/window";
|
|
8
|
-
import { IOConnectWorkspaces } from "../../../workspaces";
|
|
9
|
-
import { Group } from "../group";
|
|
10
|
-
import { Row } from "../row";
|
|
11
|
-
import { Column } from "../column";
|
|
12
|
-
import { ColumnSnapshotConfig, GroupSnapshotConfig, RowSnapshotConfig } from "../../types/protocol";
|
|
13
|
-
import { SubscriptionConfig } from "../../types/subscription";
|
|
14
|
-
|
|
15
|
-
interface PrivateData {
|
|
16
|
-
manager: PrivateDataManager;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const data = new WeakMap<Base, PrivateData>();
|
|
20
|
-
|
|
21
|
-
const getData = (base: Base, model: AllParentTypes): WorkspacePrivateData | ParentPrivateData => {
|
|
22
|
-
const manager = data.get(base).manager;
|
|
23
|
-
|
|
24
|
-
if (model instanceof Workspace) {
|
|
25
|
-
return manager.getWorkspaceData(model);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return data.get(base).manager.getParentData(model as SubParentTypes);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export class Base {
|
|
32
|
-
public frameId: string;
|
|
33
|
-
public workspaceId: string;
|
|
34
|
-
public positionIndex: number;
|
|
35
|
-
|
|
36
|
-
constructor(dataManager: PrivateDataManager) {
|
|
37
|
-
data.set(this, { manager: dataManager });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public getId(model: AllParentTypes): string {
|
|
41
|
-
return getData(this, model).id;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getPositionIndex(model: AllParentTypes): number {
|
|
45
|
-
return getData(this, model).config.positionIndex;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public getWorkspaceId(model: AllParentTypes): string {
|
|
49
|
-
const privateData = getData(this, model) as ParentPrivateData;
|
|
50
|
-
return privateData.config.workspaceId || privateData.workspace.id;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public getFrameId(model: AllParentTypes): string {
|
|
54
|
-
return getData(this, model).frame.id;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public getAllChildren(model: AllParentTypes, predicate?: (child: Child) => boolean): Child[] {
|
|
58
|
-
checkThrowCallback(predicate, true);
|
|
59
|
-
const children = getData(this, model).children;
|
|
60
|
-
|
|
61
|
-
if (typeof predicate === "undefined") {
|
|
62
|
-
return children;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return children.filter(predicate);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public getMyParent(model: AllParentTypes): AllParentTypes {
|
|
69
|
-
if (model instanceof Workspace) {
|
|
70
|
-
return model;
|
|
71
|
-
}
|
|
72
|
-
return (getData(this, model) as ParentPrivateData).parent;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public getMyFrame(model: AllParentTypes): IOConnectWorkspaces.Frame {
|
|
76
|
-
return getData(this, model).frame;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public getMyWorkspace(model: AllParentTypes): Workspace {
|
|
80
|
-
if (model instanceof Workspace) {
|
|
81
|
-
return model;
|
|
82
|
-
}
|
|
83
|
-
return (getData(this, model) as ParentPrivateData).workspace;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public async addWindow(model: AllParentTypes, definition: IOConnectWorkspaces.WorkspaceWindowDefinition, parentType: AllParent): Promise<IOConnectWorkspaces.WorkspaceWindow> {
|
|
87
|
-
if (!definition.appName && !definition.windowId) {
|
|
88
|
-
throw new Error("The window definition should contain either an appName or a windowId");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const validatedDefinition = swimlaneWindowDefinitionDecoder.runWithException(definition);
|
|
92
|
-
const controller = getData(this, model).controller;
|
|
93
|
-
|
|
94
|
-
const operationResult = await controller.add("window", getData(this, model).id, parentType, validatedDefinition);
|
|
95
|
-
|
|
96
|
-
if (model instanceof Workspace) {
|
|
97
|
-
await model.refreshReference();
|
|
98
|
-
return model.getWindow(w => w.elementId === operationResult.itemId);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const myWorkspace = this.getMyWorkspace(model);
|
|
102
|
-
await myWorkspace.refreshReference();
|
|
103
|
-
|
|
104
|
-
return myWorkspace.getWindow(w => w.elementId === operationResult.itemId);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public async addParent<T>(model: AllParentTypes, typeToAdd: SubParent, parentType: AllParent, definition?: IOConnectWorkspaces.BoxDefinition | ParentBuilder): Promise<T> {
|
|
108
|
-
const parentDefinition = this.transformDefinition(typeToAdd, definition);
|
|
109
|
-
const controller = getData(this, model).controller;
|
|
110
|
-
|
|
111
|
-
const newParentId = (await controller.add("container", getData(this, model).id, parentType, parentDefinition)).itemId;
|
|
112
|
-
|
|
113
|
-
if (model instanceof Workspace) {
|
|
114
|
-
await model.refreshReference();
|
|
115
|
-
return model.getBox((parent) => parent.id === newParentId) as unknown as T;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const myWorkspace = this.getMyWorkspace(model);
|
|
119
|
-
await myWorkspace.refreshReference();
|
|
120
|
-
|
|
121
|
-
return myWorkspace.getBox((parent) => parent.id === newParentId) as unknown as T;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public async removeChild(model: AllParentTypes, predicate: (child: Child) => boolean): Promise<void> {
|
|
125
|
-
checkThrowCallback(predicate);
|
|
126
|
-
const child = this.getAllChildren(model).find(predicate);
|
|
127
|
-
if (!child) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
await child.close();
|
|
132
|
-
|
|
133
|
-
if (model instanceof Workspace) {
|
|
134
|
-
|
|
135
|
-
await model.refreshReference();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
await this.getMyWorkspace(model).refreshReference();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public async maximize(model: SubParentTypes): Promise<void> {
|
|
143
|
-
const { controller, id } = getData(this, model);
|
|
144
|
-
|
|
145
|
-
await controller.maximizeItem(id);
|
|
146
|
-
|
|
147
|
-
await this.getMyWorkspace(model.parent).refreshReference();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public async restore(model: SubParentTypes): Promise<void> {
|
|
151
|
-
const { controller, id } = getData(this, model);
|
|
152
|
-
|
|
153
|
-
await controller.restoreItem(id);
|
|
154
|
-
|
|
155
|
-
await this.getMyWorkspace(model.parent).refreshReference();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public async close(model: SubParentTypes): Promise<void> {
|
|
159
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
160
|
-
|
|
161
|
-
const controller = getData(this, model).controller;
|
|
162
|
-
|
|
163
|
-
await controller.closeItem(modelData.id);
|
|
164
|
-
|
|
165
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public async lockContainer(model: SubParentTypes, config?: ContainerLockConfig): Promise<void> {
|
|
169
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
170
|
-
|
|
171
|
-
const controller = getData(this, model).controller;
|
|
172
|
-
|
|
173
|
-
await controller.lockContainer(modelData.id, model.type, config);
|
|
174
|
-
|
|
175
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
public getAllowDrop(model: SubParentTypes): boolean {
|
|
179
|
-
return getData(this, model).config.allowDrop;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public getAllowDropLeft(model: Group): boolean {
|
|
183
|
-
const privateData = getData(this, model);
|
|
184
|
-
if (privateData.type !== "group") {
|
|
185
|
-
throw new Error(`Property allowDropLeft is available only for groups and not on ${model.type} ${model.id}`);
|
|
186
|
-
}
|
|
187
|
-
return privateData.config.allowDropLeft;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public getAllowDropRight(model: Group): boolean {
|
|
191
|
-
const privateData = getData(this, model);
|
|
192
|
-
if (privateData.type !== "group") {
|
|
193
|
-
throw new Error(`Property allowDropRight is available only for groups and not on ${model.type} ${model.id}`);
|
|
194
|
-
}
|
|
195
|
-
return privateData.config.allowDropRight;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public getAllowDropTop(model: Group): boolean {
|
|
199
|
-
const privateData = getData(this, model);
|
|
200
|
-
if (privateData.type !== "group") {
|
|
201
|
-
throw new Error(`Property allowDropTop is available only for groups and not on ${model.type} ${model.id}`);
|
|
202
|
-
}
|
|
203
|
-
return privateData.config.allowDropTop;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public getAllowDropBottom(model: Group): boolean {
|
|
207
|
-
const privateData = getData(this, model);
|
|
208
|
-
if (privateData.type !== "group") {
|
|
209
|
-
throw new Error(`Property allowDropBottom is available only for groups and not on ${model.type} ${model.id}`);
|
|
210
|
-
}
|
|
211
|
-
return privateData.config.allowDropBottom;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
public getAllowDropHeader(model: Group): boolean {
|
|
215
|
-
const privateData = getData(this, model);
|
|
216
|
-
if (privateData.type !== "group") {
|
|
217
|
-
throw new Error(`Property allowDropHeader is available only for groups and not on ${model.type} ${model.id}`);
|
|
218
|
-
}
|
|
219
|
-
return privateData.config.allowDropHeader;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
public getAllowSplitters(model: Row | Column): boolean {
|
|
223
|
-
const privateData = getData(this, model);
|
|
224
|
-
|
|
225
|
-
if (privateData.type === "group") {
|
|
226
|
-
throw new Error(`Cannot get allow splitters from private data ${privateData.type}`);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return privateData.config.allowSplitters;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public getAllowExtract(model: Group): boolean {
|
|
233
|
-
const privateData = getData(this, model);
|
|
234
|
-
if (privateData.type !== "group") {
|
|
235
|
-
throw new Error(`Cannot get allow extract from private data ${privateData.type} with config ${privateData.type !== "workspace" ? privateData.config.type : ""}`);
|
|
236
|
-
}
|
|
237
|
-
return privateData.config.allowExtract;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public getAllowReorder(model: Group): boolean {
|
|
241
|
-
const privateData = getData(this, model);
|
|
242
|
-
if (privateData.type !== "group") {
|
|
243
|
-
throw new Error(`Cannot get allow extract from private data ${privateData.type} with config ${privateData.type !== "workspace" ? privateData.config.type : ""}`);
|
|
244
|
-
}
|
|
245
|
-
return privateData.config.allowReorder;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public getShowMaximizeButton(model: Group): boolean {
|
|
249
|
-
const privateData = getData(this, model);
|
|
250
|
-
if (privateData.type !== "group") {
|
|
251
|
-
throw new Error(`Cannot get show maximize button from private data${privateData.type} with config ${privateData.type !== "workspace" ? privateData.config.type : ""}`);
|
|
252
|
-
}
|
|
253
|
-
return privateData.config.showMaximizeButton;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
public getShowEjectButton(model: Group): boolean {
|
|
257
|
-
const privateData = getData(this, model);
|
|
258
|
-
if (privateData.type !== "group") {
|
|
259
|
-
throw new Error(`Cannot get show eject button from private data${privateData.type} with config ${privateData.type !== "workspace" ? privateData.config.type : ""}`);
|
|
260
|
-
}
|
|
261
|
-
return privateData.config.showEjectButton;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
public getShowAddWindowButton(model: Group): boolean {
|
|
265
|
-
const privateData = getData(this, model);
|
|
266
|
-
if (privateData.type !== "group") {
|
|
267
|
-
throw new Error(`Cannot get add window button from private data${privateData.type} with config ${privateData.type !== "workspace" ? privateData.config.type : ""}`);
|
|
268
|
-
}
|
|
269
|
-
return privateData.config.showAddWindowButton;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
public getMinWidth(model: SubParentTypes): number {
|
|
273
|
-
const privateData = getData(this, model);
|
|
274
|
-
|
|
275
|
-
return privateData.config.minWidth;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
public getMaxWidth(model: SubParentTypes): number {
|
|
279
|
-
const privateData = getData(this, model);
|
|
280
|
-
|
|
281
|
-
return privateData.config.maxWidth;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
public getMinHeight(model: SubParentTypes): number {
|
|
285
|
-
const privateData = getData(this, model);
|
|
286
|
-
|
|
287
|
-
return privateData.config.minHeight;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
public getMaxHeight(model: SubParentTypes): number {
|
|
291
|
-
const privateData = getData(this, model);
|
|
292
|
-
|
|
293
|
-
return privateData.config.maxHeight;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
public getWidthInPx(model: SubParentTypes): number {
|
|
297
|
-
const privateData = getData(this, model);
|
|
298
|
-
|
|
299
|
-
return privateData.config.widthInPx;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
public getHeightInPx(model: SubParentTypes): number {
|
|
303
|
-
const privateData = getData(this, model);
|
|
304
|
-
|
|
305
|
-
return privateData.config.heightInPx;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
public getIsPinned(model: Column | Row): boolean {
|
|
309
|
-
const privateData = getData(this, model);
|
|
310
|
-
|
|
311
|
-
return (privateData.config as RowSnapshotConfig | ColumnSnapshotConfig).isPinned;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
public getIsMaximized(model: Column | Row | Group): boolean {
|
|
315
|
-
const privateData = getData(this, model);
|
|
316
|
-
|
|
317
|
-
return (privateData.config as RowSnapshotConfig | ColumnSnapshotConfig | GroupSnapshotConfig).isMaximized;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public getMaximizationBoundary(model: Column | Row): boolean {
|
|
321
|
-
const privateData = getData(this, model);
|
|
322
|
-
|
|
323
|
-
return (privateData.config as RowSnapshotConfig | ColumnSnapshotConfig).maximizationBoundary;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
public async setHeight(model: Row, height: number): Promise<void> {
|
|
327
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
328
|
-
const { controller, id } = modelData;
|
|
329
|
-
|
|
330
|
-
await controller.resizeItem(id, {
|
|
331
|
-
height
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
public async setWidth(model: Column, width: number): Promise<void> {
|
|
338
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
339
|
-
const { controller, id } = modelData;
|
|
340
|
-
|
|
341
|
-
await controller.resizeItem(id, {
|
|
342
|
-
width
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
public async setSize(model: Group, width?: number, height?: number): Promise<void> {
|
|
349
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
350
|
-
const { controller, id } = modelData;
|
|
351
|
-
|
|
352
|
-
await controller.resizeItem(id, {
|
|
353
|
-
width,
|
|
354
|
-
height
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
public async setMaximizationBoundary(model: Row | Column, config: IOConnectWorkspaces.SetMaximizationBoundaryConfig): Promise<void> {
|
|
361
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
362
|
-
const { controller, id } = modelData;
|
|
363
|
-
|
|
364
|
-
await controller.setMaximizationBoundary(id, config);
|
|
365
|
-
|
|
366
|
-
await this.getMyWorkspace(modelData.parent).refreshReference();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
public async bundleTo(model: Group, type: "row" | "column") {
|
|
370
|
-
const modelData = getData(this, model) as ParentPrivateData;
|
|
371
|
-
const { controller, id } = modelData;
|
|
372
|
-
|
|
373
|
-
await controller.bundleItemTo(type, id);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
public async processLocalSubscription(model: SubParentTypes, subscriptionConfig: SubscriptionConfig): Promise<IOConnectWorkspaces.Unsubscribe> {
|
|
377
|
-
return getData(this, model).controller.processLocalSubscription(subscriptionConfig, this.getId(model))
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
private transformDefinition(type: "group" | "row" | "column", definition?: IOConnectWorkspaces.BoxDefinition | ParentBuilder): IOConnectWorkspaces.BoxDefinition {
|
|
381
|
-
let parentDefinition: IOConnectWorkspaces.BoxDefinition;
|
|
382
|
-
|
|
383
|
-
if (typeof definition === "undefined") {
|
|
384
|
-
parentDefinition = { type, children: [] };
|
|
385
|
-
} else if (definition instanceof ParentBuilder) {
|
|
386
|
-
parentDefinition = definition.serialize();
|
|
387
|
-
} else {
|
|
388
|
-
if (typeof definition.type === "undefined") {
|
|
389
|
-
definition.type = type;
|
|
390
|
-
}
|
|
391
|
-
parentDefinition = strictParentDefinitionDecoder.runWithException(definition);
|
|
392
|
-
parentDefinition.children = parentDefinition.children || [];
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return parentDefinition;
|
|
396
|
-
}
|
|
397
|
-
}
|
package/src/models/column.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Base } from "./base/base";
|
|
2
|
-
import { IOConnectWorkspaces } from "../../workspaces.d";
|
|
3
|
-
import { checkThrowCallback, columnLockConfigDecoder, nonNegativeNumberDecoder, setMaximizationBoundaryAPIConfigDecoder } from "../shared/decoders";
|
|
4
|
-
import { SubscriptionConfig } from "../types/subscription";
|
|
5
|
-
|
|
6
|
-
interface PrivateData {
|
|
7
|
-
base: Base;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const privateData = new WeakMap<Column, PrivateData>();
|
|
11
|
-
|
|
12
|
-
const getBase = (model: Column): Base => {
|
|
13
|
-
return privateData.get(model).base;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export class Column implements IOConnectWorkspaces.Column {
|
|
17
|
-
|
|
18
|
-
constructor(base: Base) {
|
|
19
|
-
privateData.set(this, { base });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public get type(): "column" {
|
|
23
|
-
return "column";
|
|
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, "column");
|
|
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", "column", definition);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public async addColumn(): Promise<Column> {
|
|
114
|
-
throw new Error("Adding columns as column children is not supported");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public async addRow(definition?: IOConnectWorkspaces.BoxDefinition): Promise<IOConnectWorkspaces.Row> {
|
|
118
|
-
if (definition?.type && definition.type !== "row") {
|
|
119
|
-
throw new Error(`Expected a row definition, but received ${definition.type}`);
|
|
120
|
-
}
|
|
121
|
-
return getBase(this).addParent<IOConnectWorkspaces.Row>(this, "row", "column", definition);
|
|
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.ColumnLockConfig | ((config: IOConnectWorkspaces.ColumnLockConfig) => IOConnectWorkspaces.ColumnLockConfig)): 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
|
-
|
|
151
|
-
} else {
|
|
152
|
-
lockConfigResult = config;
|
|
153
|
-
}
|
|
154
|
-
const verifiedConfig = lockConfigResult === undefined ? undefined : columnLockConfigDecoder.runWithException(lockConfigResult);
|
|
155
|
-
return getBase(this).lockContainer(this, verifiedConfig);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public async setWidth(width: number): Promise<void> {
|
|
159
|
-
nonNegativeNumberDecoder.runWithException(width);
|
|
160
|
-
return getBase(this).setWidth(this, width);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
public async onLockConfigurationChanged(callback: (config: IOConnectWorkspaces.ColumnLockConfig) => void): Promise<IOConnectWorkspaces.Unsubscribe> {
|
|
165
|
-
checkThrowCallback(callback);
|
|
166
|
-
const wrappedCallback = async (): Promise<void> => {
|
|
167
|
-
await this.workspace.refreshReference();
|
|
168
|
-
callback({
|
|
169
|
-
allowDrop: this.allowDrop,
|
|
170
|
-
allowSplitters: this.allowSplitters
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
const config: SubscriptionConfig = {
|
|
174
|
-
callback: wrappedCallback,
|
|
175
|
-
action: "lock-configuration-changed",
|
|
176
|
-
eventType: "container",
|
|
177
|
-
scope: "container"
|
|
178
|
-
};
|
|
179
|
-
const unsubscribe = await getBase(this).processLocalSubscription(this, config);
|
|
180
|
-
return unsubscribe;
|
|
181
|
-
}
|
|
182
|
-
public async setMaximizationBoundary(config: IOConnectWorkspaces.SetMaximizationBoundaryConfig): Promise<void> {
|
|
183
|
-
const validatedConfig = setMaximizationBoundaryAPIConfigDecoder.runWithException(config);
|
|
184
|
-
return getBase(this).setMaximizationBoundary(this, validatedConfig);
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
}
|