@interopio/workspaces-api 3.5.6 → 3.5.7
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/changelog.md +3 -0
- package/dist/workspaces.es.js +151 -9
- package/dist/workspaces.es.js.map +1 -1
- package/dist/workspaces.umd.js +151 -9
- package/dist/workspaces.umd.js.map +1 -1
- package/dist/workspaces.umd.min.js +1 -1
- package/package.json +2 -2
- package/workspaces.d.ts +53 -5
package/dist/workspaces.umd.js
CHANGED
|
@@ -916,6 +916,13 @@
|
|
|
916
916
|
const isWindowInSwimlaneResultDecoder = object({
|
|
917
917
|
inWorkspace: boolean()
|
|
918
918
|
});
|
|
919
|
+
const iconDecoder = object({
|
|
920
|
+
base64Image: nonEmptyStringDecoder
|
|
921
|
+
});
|
|
922
|
+
const setIconArgumentsDecoder = object({
|
|
923
|
+
icon: iconDecoder,
|
|
924
|
+
frameId: nonEmptyStringDecoder
|
|
925
|
+
});
|
|
919
926
|
const allParentDecoder = oneOf(constant("workspace"), constant("row"), constant("column"), constant("group"));
|
|
920
927
|
const subParentDecoder = oneOf(constant("row"), constant("column"), constant("group"));
|
|
921
928
|
const frameStateDecoder = oneOf(constant("maximized"), constant("minimized"), constant("normal"));
|
|
@@ -1345,6 +1352,14 @@
|
|
|
1345
1352
|
const simpleItemConfigDecoder = object({
|
|
1346
1353
|
itemId: nonEmptyStringDecoder
|
|
1347
1354
|
});
|
|
1355
|
+
const closeOptionsDecoder = object({
|
|
1356
|
+
allowPrevent: optional(boolean()),
|
|
1357
|
+
showDialog: optional(boolean()),
|
|
1358
|
+
});
|
|
1359
|
+
const closeItemConfigDecoder = object({
|
|
1360
|
+
itemId: nonEmptyStringDecoder,
|
|
1361
|
+
closeOptions: optional(closeOptionsDecoder)
|
|
1362
|
+
});
|
|
1348
1363
|
const frameSnapshotConfigDecoder = object({
|
|
1349
1364
|
itemId: nonEmptyStringDecoder,
|
|
1350
1365
|
excludeIds: optional(boolean())
|
|
@@ -1518,6 +1533,9 @@
|
|
|
1518
1533
|
shortcut: nonEmptyStringDecoder,
|
|
1519
1534
|
frameId: nonEmptyStringDecoder
|
|
1520
1535
|
});
|
|
1536
|
+
const frameClosingDataDecoder = object({
|
|
1537
|
+
frameId: nonEmptyStringDecoder,
|
|
1538
|
+
});
|
|
1521
1539
|
const setMaximizationBoundaryAPIConfigDecoder = object({
|
|
1522
1540
|
enabled: boolean()
|
|
1523
1541
|
});
|
|
@@ -1536,6 +1554,9 @@
|
|
|
1536
1554
|
itemId: nonEmptyStringDecoder,
|
|
1537
1555
|
strategy: loadingStrategyDecoder
|
|
1538
1556
|
});
|
|
1557
|
+
const frameClosingResultDecoder = object({
|
|
1558
|
+
prevent: boolean()
|
|
1559
|
+
});
|
|
1539
1560
|
|
|
1540
1561
|
const webPlatformMethodName = "T42.Web.Platform.Control";
|
|
1541
1562
|
const webPlatformWspStreamName = "T42.Web.Platform.WSP.Stream";
|
|
@@ -1557,6 +1578,7 @@
|
|
|
1557
1578
|
};
|
|
1558
1579
|
const CLIENT_OPERATIONS = {
|
|
1559
1580
|
shortcutClicked: { name: "shortcutClicked", argsDecoder: shortcutClickedDataDecoder, resultDecoder: voidResultDecoder },
|
|
1581
|
+
frameClosing: { name: "frameClosing", argsDecoder: frameClosingDataDecoder, resultDecoder: frameClosingResultDecoder },
|
|
1560
1582
|
};
|
|
1561
1583
|
const OPERATIONS = {
|
|
1562
1584
|
ping: { name: "ping", resultDecoder: pingResultDecoder },
|
|
@@ -1578,7 +1600,7 @@
|
|
|
1578
1600
|
restoreItem: { name: "restoreItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1579
1601
|
maximizeItem: { name: "maximizeItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1580
1602
|
focusItem: { name: "focusItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1581
|
-
closeItem: { name: "closeItem", argsDecoder:
|
|
1603
|
+
closeItem: { name: "closeItem", argsDecoder: closeItemConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1582
1604
|
resizeItem: { name: "resizeItem", argsDecoder: resizeItemConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1583
1605
|
setMaximizationBoundary: { name: "setMaximizationBoundary", argsDecoder: setMaximizationBoundaryConfigDecoder, resultDecoder: voidResultDecoder },
|
|
1584
1606
|
changeFrameState: { name: "changeFrameState", argsDecoder: frameStateConfigDecoder, resultDecoder: voidResultDecoder },
|
|
@@ -1610,7 +1632,10 @@
|
|
|
1610
1632
|
getPlatformFrameId: { name: "getPlatformFrameId", resultDecoder: getPlatformFrameIdResultDecoder },
|
|
1611
1633
|
operationCheck: { name: "operationCheck", argsDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder },
|
|
1612
1634
|
setWindowDragMode: { name: "setWindowDragMode", argsDecoder: setWindowDragModeDecoder, resultDecoder: voidResultDecoder },
|
|
1613
|
-
setLoadingStrategy: { name: "setLoadingStrategy", argsDecoder: setLoadingStrategyDecoder, resultDecoder: voidResultDecoder }
|
|
1635
|
+
setLoadingStrategy: { name: "setLoadingStrategy", argsDecoder: setLoadingStrategyDecoder, resultDecoder: voidResultDecoder },
|
|
1636
|
+
getTaskbarIcon: { name: "getTaskbarIcon", resultDecoder: iconDecoder },
|
|
1637
|
+
setTaskbarIcon: { name: "setTaskbarIcon", argsDecoder: setIconArgumentsDecoder, resultDecoder: voidResultDecoder },
|
|
1638
|
+
subscribeToFrameClosing: { name: "subscribeToFrameClosing", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder }
|
|
1614
1639
|
};
|
|
1615
1640
|
|
|
1616
1641
|
class PromiseWrapper {
|
|
@@ -1768,6 +1793,35 @@
|
|
|
1768
1793
|
};
|
|
1769
1794
|
return this.transport.onInternalMethodInvoked("control", wrappedCallback);
|
|
1770
1795
|
}
|
|
1796
|
+
onOperationWithResponse(callback) {
|
|
1797
|
+
const wrappedCallback = async (payload, caller) => {
|
|
1798
|
+
const operationName = payload.operation;
|
|
1799
|
+
const operationArgs = payload.data;
|
|
1800
|
+
const operationDefinition = Object.values(CLIENT_OPERATIONS).find((operation) => operation.name === operationName);
|
|
1801
|
+
if (!operationDefinition) {
|
|
1802
|
+
throw new Error(`Cannot find definition for operation name: ${operationName}`);
|
|
1803
|
+
}
|
|
1804
|
+
if (operationDefinition.argsDecoder) {
|
|
1805
|
+
try {
|
|
1806
|
+
operationDefinition.argsDecoder.runWithException(operationArgs);
|
|
1807
|
+
}
|
|
1808
|
+
catch (error) {
|
|
1809
|
+
throw new Error(`Unexpected internal outgoing validation error: ${error.message}, for input: ${JSON.stringify(error.input)}, for operation ${operationName}`);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
const result = await callback(payload, caller);
|
|
1813
|
+
if (operationDefinition.resultDecoder) {
|
|
1814
|
+
try {
|
|
1815
|
+
operationDefinition.resultDecoder.runWithException(result);
|
|
1816
|
+
}
|
|
1817
|
+
catch (error) {
|
|
1818
|
+
throw new Error(`Unexpected internal outgoing result validation error: ${error.message}, for input: ${JSON.stringify(error.input)}, for operation ${operationName}`);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
return result;
|
|
1822
|
+
};
|
|
1823
|
+
return this.transport.onInternalMethodInvoked("control", wrappedCallback);
|
|
1824
|
+
}
|
|
1771
1825
|
checkScopeMatch(scope, receivedIds) {
|
|
1772
1826
|
if (scope.type === "global") {
|
|
1773
1827
|
return true;
|
|
@@ -1981,7 +2035,7 @@
|
|
|
1981
2035
|
registerMethod(key) {
|
|
1982
2036
|
const method = INCOMING_METHODS[key];
|
|
1983
2037
|
return this.agm.register(method.name, (args, caller) => {
|
|
1984
|
-
this.registry.execute(key, args, caller);
|
|
2038
|
+
return Promise.all(this.registry.execute(key, args, caller));
|
|
1985
2039
|
});
|
|
1986
2040
|
}
|
|
1987
2041
|
}
|
|
@@ -3434,6 +3488,21 @@
|
|
|
3434
3488
|
const myId = getData$1(this).summary.id;
|
|
3435
3489
|
return getData$1(this).controller.getFrameState(myId);
|
|
3436
3490
|
}
|
|
3491
|
+
setIcon(icon) {
|
|
3492
|
+
if (!isDesktop()) {
|
|
3493
|
+
throw new Error("frame.setIcon() is not supported in IO Connect Browser");
|
|
3494
|
+
}
|
|
3495
|
+
iconDecoder.runWithException(icon);
|
|
3496
|
+
const frameId = this.id;
|
|
3497
|
+
return getData$1(this).controller.setTaskbarIcon(icon, frameId);
|
|
3498
|
+
}
|
|
3499
|
+
getIcon() {
|
|
3500
|
+
if (!isDesktop()) {
|
|
3501
|
+
throw new Error("frame.getIcon() is not supported in IO Connect Browser");
|
|
3502
|
+
}
|
|
3503
|
+
const frameId = this.id;
|
|
3504
|
+
return getData$1(this).controller.getTaskbarIcon(frameId);
|
|
3505
|
+
}
|
|
3437
3506
|
async minimize() {
|
|
3438
3507
|
if (!isDesktop()) {
|
|
3439
3508
|
throw new Error("State operations are not supported in IO Connect Browser");
|
|
@@ -3455,9 +3524,10 @@
|
|
|
3455
3524
|
const myId = getData$1(this).summary.id;
|
|
3456
3525
|
return getData$1(this).controller.changeFrameState(myId, "normal");
|
|
3457
3526
|
}
|
|
3458
|
-
close() {
|
|
3527
|
+
close(options) {
|
|
3528
|
+
const validatedOptions = optional(closeOptionsDecoder).runWithException(options);
|
|
3459
3529
|
const myId = getData$1(this).summary.id;
|
|
3460
|
-
return getData$1(this).controller.
|
|
3530
|
+
return getData$1(this).controller.closeFrame(myId, validatedOptions);
|
|
3461
3531
|
}
|
|
3462
3532
|
snapshot() {
|
|
3463
3533
|
const myId = getData$1(this).summary.id;
|
|
@@ -3489,6 +3559,20 @@
|
|
|
3489
3559
|
}
|
|
3490
3560
|
return getData$1(this).controller.initFrame(this.id, config);
|
|
3491
3561
|
}
|
|
3562
|
+
async onClosing(callback) {
|
|
3563
|
+
if (!isDesktop()) {
|
|
3564
|
+
throw new Error("Frame closing operations are not supported in io.Connect Browser");
|
|
3565
|
+
}
|
|
3566
|
+
checkThrowCallback(callback);
|
|
3567
|
+
const wrappedCallback = async () => {
|
|
3568
|
+
let shouldPrevent = false;
|
|
3569
|
+
const preventClose = () => shouldPrevent = true;
|
|
3570
|
+
await callback({ prevent: preventClose });
|
|
3571
|
+
return { prevent: shouldPrevent };
|
|
3572
|
+
};
|
|
3573
|
+
const unsubscribe = await getData$1(this).controller.registerFrameOnClosing(this.id, wrappedCallback);
|
|
3574
|
+
return unsubscribe;
|
|
3575
|
+
}
|
|
3492
3576
|
async onClosed(callback) {
|
|
3493
3577
|
checkThrowCallback(callback);
|
|
3494
3578
|
const myId = getData$1(this).summary.id;
|
|
@@ -4174,6 +4258,12 @@
|
|
|
4174
4258
|
}
|
|
4175
4259
|
await this.bridge.send(OPERATIONS.bundleItem.name, { type, itemId });
|
|
4176
4260
|
}
|
|
4261
|
+
async getTaskbarIcon(frameId) {
|
|
4262
|
+
return await this.bridge.send(OPERATIONS.getTaskbarIcon.name, { frameId });
|
|
4263
|
+
}
|
|
4264
|
+
async setTaskbarIcon(icon, frameId) {
|
|
4265
|
+
await this.bridge.send(OPERATIONS.setTaskbarIcon.name, { icon, frameId });
|
|
4266
|
+
}
|
|
4177
4267
|
getWorkspaceContext(workspaceId) {
|
|
4178
4268
|
const contextName = `___workspace___${workspaceId}`;
|
|
4179
4269
|
return this.contexts.get(contextName);
|
|
@@ -4202,6 +4292,9 @@
|
|
|
4202
4292
|
async closeItem(itemId) {
|
|
4203
4293
|
await this.bridge.send(OPERATIONS.closeItem.name, { itemId });
|
|
4204
4294
|
}
|
|
4295
|
+
async closeFrame(itemId, closeOptions) {
|
|
4296
|
+
await this.bridge.send(OPERATIONS.closeItem.name, { itemId, closeOptions });
|
|
4297
|
+
}
|
|
4205
4298
|
async resizeItem(itemId, config) {
|
|
4206
4299
|
await this.bridge.send(OPERATIONS.resizeItem.name, Object.assign({}, { itemId }, config));
|
|
4207
4300
|
}
|
|
@@ -4400,10 +4493,18 @@
|
|
|
4400
4493
|
bridge;
|
|
4401
4494
|
base;
|
|
4402
4495
|
shortcutsController;
|
|
4403
|
-
|
|
4496
|
+
closingController;
|
|
4497
|
+
constructor(bridge, base, shortcutsController, closingController) {
|
|
4404
4498
|
this.bridge = bridge;
|
|
4405
4499
|
this.base = base;
|
|
4406
4500
|
this.shortcutsController = shortcutsController;
|
|
4501
|
+
this.closingController = closingController;
|
|
4502
|
+
}
|
|
4503
|
+
setTaskbarIcon(icon, frameId) {
|
|
4504
|
+
return this.base.setTaskbarIcon(icon, frameId);
|
|
4505
|
+
}
|
|
4506
|
+
getTaskbarIcon(frameId) {
|
|
4507
|
+
return this.base.getTaskbarIcon(frameId);
|
|
4407
4508
|
}
|
|
4408
4509
|
checkIsWindowLoaded(windowId) {
|
|
4409
4510
|
return this.base.checkIsWindowLoaded(windowId);
|
|
@@ -4606,6 +4707,9 @@
|
|
|
4606
4707
|
async closeItem(itemId) {
|
|
4607
4708
|
return await this.base.closeItem(itemId);
|
|
4608
4709
|
}
|
|
4710
|
+
async closeFrame(itemId, closeOptions) {
|
|
4711
|
+
return await this.base.closeFrame(itemId, closeOptions);
|
|
4712
|
+
}
|
|
4609
4713
|
async resizeItem(itemId, config) {
|
|
4610
4714
|
return await this.base.resizeItem(itemId, config);
|
|
4611
4715
|
}
|
|
@@ -4709,6 +4813,9 @@
|
|
|
4709
4813
|
setLoadingStrategy(workspaceId, strategy) {
|
|
4710
4814
|
return this.base.setLoadingStrategy(workspaceId, strategy);
|
|
4711
4815
|
}
|
|
4816
|
+
registerFrameOnClosing(frameId, callback) {
|
|
4817
|
+
return this.closingController.registerFrameOnClosing(frameId, callback);
|
|
4818
|
+
}
|
|
4712
4819
|
async handleCoreLocalSubscription(config, levelId) {
|
|
4713
4820
|
await this.bridge.createCoreEventSubscription();
|
|
4714
4821
|
config.scopeId = config.scopeId || levelId;
|
|
@@ -4782,7 +4889,7 @@
|
|
|
4782
4889
|
_shortcuts = CallbackFactory();
|
|
4783
4890
|
constructor(bridge) {
|
|
4784
4891
|
this.bridge = bridge;
|
|
4785
|
-
this.bridge.onOperation((payload
|
|
4892
|
+
this.bridge.onOperation((payload) => {
|
|
4786
4893
|
if (payload.operation === CLIENT_OPERATIONS.shortcutClicked.name) {
|
|
4787
4894
|
const data = payload.data;
|
|
4788
4895
|
this._shortcuts.execute(`${data.frameId}-${data.shortcut}`);
|
|
@@ -4799,6 +4906,34 @@
|
|
|
4799
4906
|
}
|
|
4800
4907
|
}
|
|
4801
4908
|
|
|
4909
|
+
class ClosingController {
|
|
4910
|
+
bridge;
|
|
4911
|
+
registry = CallbackFactory();
|
|
4912
|
+
constructor(bridge) {
|
|
4913
|
+
this.bridge = bridge;
|
|
4914
|
+
this.subscribeToFrameClosing();
|
|
4915
|
+
}
|
|
4916
|
+
async registerFrameOnClosing(frameId, callback) {
|
|
4917
|
+
await this.bridge.send(OPERATIONS.subscribeToFrameClosing.name, { itemId: frameId });
|
|
4918
|
+
return this.registry.add(frameId, callback);
|
|
4919
|
+
}
|
|
4920
|
+
subscribeToFrameClosing() {
|
|
4921
|
+
this.bridge.onOperationWithResponse(async (payload) => {
|
|
4922
|
+
if (payload.operation !== CLIENT_OPERATIONS.frameClosing.name) {
|
|
4923
|
+
return;
|
|
4924
|
+
}
|
|
4925
|
+
const data = payload.data;
|
|
4926
|
+
const frameClosingResult = await Promise.all(this.registry.execute(data.frameId));
|
|
4927
|
+
return this.aggregateFrameClosingResult(frameClosingResult);
|
|
4928
|
+
});
|
|
4929
|
+
}
|
|
4930
|
+
aggregateFrameClosingResult(results) {
|
|
4931
|
+
return {
|
|
4932
|
+
prevent: results.some((result) => result?.prevent)
|
|
4933
|
+
};
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4802
4937
|
class IoC {
|
|
4803
4938
|
agm;
|
|
4804
4939
|
windows;
|
|
@@ -4811,6 +4946,7 @@
|
|
|
4811
4946
|
_parentBaseInstance;
|
|
4812
4947
|
_baseController;
|
|
4813
4948
|
_shortcutsController;
|
|
4949
|
+
_closingController;
|
|
4814
4950
|
constructor(agm, windows, layouts, contexts) {
|
|
4815
4951
|
this.agm = agm;
|
|
4816
4952
|
this.windows = windows;
|
|
@@ -4825,7 +4961,7 @@
|
|
|
4825
4961
|
}
|
|
4826
4962
|
get controller() {
|
|
4827
4963
|
if (!this._controllerInstance) {
|
|
4828
|
-
this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController);
|
|
4964
|
+
this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController, this.closingController);
|
|
4829
4965
|
}
|
|
4830
4966
|
return this._controllerInstance;
|
|
4831
4967
|
}
|
|
@@ -4835,6 +4971,12 @@
|
|
|
4835
4971
|
}
|
|
4836
4972
|
return this._shortcutsController;
|
|
4837
4973
|
}
|
|
4974
|
+
get closingController() {
|
|
4975
|
+
if (!this._closingController) {
|
|
4976
|
+
this._closingController = new ClosingController(this.bridge);
|
|
4977
|
+
}
|
|
4978
|
+
return this._closingController;
|
|
4979
|
+
}
|
|
4838
4980
|
get bridge() {
|
|
4839
4981
|
if (!this._bridgeInstance) {
|
|
4840
4982
|
this._bridgeInstance = new Bridge(this.transport, CallbackFactory());
|
|
@@ -4968,7 +5110,7 @@
|
|
|
4968
5110
|
}
|
|
4969
5111
|
}
|
|
4970
5112
|
|
|
4971
|
-
var version = "3.5.
|
|
5113
|
+
var version = "3.5.7";
|
|
4972
5114
|
|
|
4973
5115
|
const composeAPI = (glue, ioc) => {
|
|
4974
5116
|
const controller = ioc.controller;
|