@interopio/workspaces-api 3.5.6 → 4.0.0

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 CHANGED
@@ -1,3 +1,8 @@
1
+ 4.0.0
2
+ feat: io.Connect Browser 4.0
3
+ 3.5.7
4
+ feat: G4 e 8073 workspace frame on closing event prevention master
5
+ feat: G4E-8009 Setting taskbar icon for workspace frame api
1
6
  3.5.6
2
7
  feat: ability to embed a loading strategy within a workspaces layout upon saving
3
8
  3.5.5
@@ -910,6 +910,13 @@ const windowDragModeDecoder = oneOf(constant("keepInside"), constant("autoEject"
910
910
  const isWindowInSwimlaneResultDecoder = object({
911
911
  inWorkspace: boolean()
912
912
  });
913
+ const iconDecoder = object({
914
+ base64Image: nonEmptyStringDecoder
915
+ });
916
+ const setIconArgumentsDecoder = object({
917
+ icon: iconDecoder,
918
+ frameId: nonEmptyStringDecoder
919
+ });
913
920
  const allParentDecoder = oneOf(constant("workspace"), constant("row"), constant("column"), constant("group"));
914
921
  const subParentDecoder = oneOf(constant("row"), constant("column"), constant("group"));
915
922
  const frameStateDecoder = oneOf(constant("maximized"), constant("minimized"), constant("normal"));
@@ -1339,6 +1346,14 @@ const moveConfigDecoder = object({
1339
1346
  const simpleItemConfigDecoder = object({
1340
1347
  itemId: nonEmptyStringDecoder
1341
1348
  });
1349
+ const closeOptionsDecoder = object({
1350
+ allowPrevent: optional(boolean()),
1351
+ showDialog: optional(boolean()),
1352
+ });
1353
+ const closeItemConfigDecoder = object({
1354
+ itemId: nonEmptyStringDecoder,
1355
+ closeOptions: optional(closeOptionsDecoder)
1356
+ });
1342
1357
  const frameSnapshotConfigDecoder = object({
1343
1358
  itemId: nonEmptyStringDecoder,
1344
1359
  excludeIds: optional(boolean())
@@ -1512,6 +1527,9 @@ const shortcutClickedDataDecoder = object({
1512
1527
  shortcut: nonEmptyStringDecoder,
1513
1528
  frameId: nonEmptyStringDecoder
1514
1529
  });
1530
+ const frameClosingDataDecoder = object({
1531
+ frameId: nonEmptyStringDecoder,
1532
+ });
1515
1533
  const setMaximizationBoundaryAPIConfigDecoder = object({
1516
1534
  enabled: boolean()
1517
1535
  });
@@ -1530,6 +1548,9 @@ const setLoadingStrategyDecoder = object({
1530
1548
  itemId: nonEmptyStringDecoder,
1531
1549
  strategy: loadingStrategyDecoder
1532
1550
  });
1551
+ const frameClosingResultDecoder = object({
1552
+ prevent: boolean()
1553
+ });
1533
1554
 
1534
1555
  const webPlatformMethodName = "T42.Web.Platform.Control";
1535
1556
  const webPlatformWspStreamName = "T42.Web.Platform.WSP.Stream";
@@ -1551,6 +1572,7 @@ const STREAMS = {
1551
1572
  };
1552
1573
  const CLIENT_OPERATIONS = {
1553
1574
  shortcutClicked: { name: "shortcutClicked", argsDecoder: shortcutClickedDataDecoder, resultDecoder: voidResultDecoder },
1575
+ frameClosing: { name: "frameClosing", argsDecoder: frameClosingDataDecoder, resultDecoder: frameClosingResultDecoder },
1554
1576
  };
1555
1577
  const OPERATIONS = {
1556
1578
  ping: { name: "ping", resultDecoder: pingResultDecoder },
@@ -1572,7 +1594,7 @@ const OPERATIONS = {
1572
1594
  restoreItem: { name: "restoreItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1573
1595
  maximizeItem: { name: "maximizeItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1574
1596
  focusItem: { name: "focusItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1575
- closeItem: { name: "closeItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1597
+ closeItem: { name: "closeItem", argsDecoder: closeItemConfigDecoder, resultDecoder: voidResultDecoder },
1576
1598
  resizeItem: { name: "resizeItem", argsDecoder: resizeItemConfigDecoder, resultDecoder: voidResultDecoder },
1577
1599
  setMaximizationBoundary: { name: "setMaximizationBoundary", argsDecoder: setMaximizationBoundaryConfigDecoder, resultDecoder: voidResultDecoder },
1578
1600
  changeFrameState: { name: "changeFrameState", argsDecoder: frameStateConfigDecoder, resultDecoder: voidResultDecoder },
@@ -1604,7 +1626,10 @@ const OPERATIONS = {
1604
1626
  getPlatformFrameId: { name: "getPlatformFrameId", resultDecoder: getPlatformFrameIdResultDecoder },
1605
1627
  operationCheck: { name: "operationCheck", argsDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder },
1606
1628
  setWindowDragMode: { name: "setWindowDragMode", argsDecoder: setWindowDragModeDecoder, resultDecoder: voidResultDecoder },
1607
- setLoadingStrategy: { name: "setLoadingStrategy", argsDecoder: setLoadingStrategyDecoder, resultDecoder: voidResultDecoder }
1629
+ setLoadingStrategy: { name: "setLoadingStrategy", argsDecoder: setLoadingStrategyDecoder, resultDecoder: voidResultDecoder },
1630
+ getTaskbarIcon: { name: "getTaskbarIcon", resultDecoder: iconDecoder },
1631
+ setTaskbarIcon: { name: "setTaskbarIcon", argsDecoder: setIconArgumentsDecoder, resultDecoder: voidResultDecoder },
1632
+ subscribeToFrameClosing: { name: "subscribeToFrameClosing", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder }
1608
1633
  };
1609
1634
 
1610
1635
  class PromiseWrapper {
@@ -1762,6 +1787,35 @@ class Bridge {
1762
1787
  };
1763
1788
  return this.transport.onInternalMethodInvoked("control", wrappedCallback);
1764
1789
  }
1790
+ onOperationWithResponse(callback) {
1791
+ const wrappedCallback = async (payload, caller) => {
1792
+ const operationName = payload.operation;
1793
+ const operationArgs = payload.data;
1794
+ const operationDefinition = Object.values(CLIENT_OPERATIONS).find((operation) => operation.name === operationName);
1795
+ if (!operationDefinition) {
1796
+ throw new Error(`Cannot find definition for operation name: ${operationName}`);
1797
+ }
1798
+ if (operationDefinition.argsDecoder) {
1799
+ try {
1800
+ operationDefinition.argsDecoder.runWithException(operationArgs);
1801
+ }
1802
+ catch (error) {
1803
+ throw new Error(`Unexpected internal outgoing validation error: ${error.message}, for input: ${JSON.stringify(error.input)}, for operation ${operationName}`);
1804
+ }
1805
+ }
1806
+ const result = await callback(payload, caller);
1807
+ if (operationDefinition.resultDecoder) {
1808
+ try {
1809
+ operationDefinition.resultDecoder.runWithException(result);
1810
+ }
1811
+ catch (error) {
1812
+ throw new Error(`Unexpected internal outgoing result validation error: ${error.message}, for input: ${JSON.stringify(error.input)}, for operation ${operationName}`);
1813
+ }
1814
+ }
1815
+ return result;
1816
+ };
1817
+ return this.transport.onInternalMethodInvoked("control", wrappedCallback);
1818
+ }
1765
1819
  checkScopeMatch(scope, receivedIds) {
1766
1820
  if (scope.type === "global") {
1767
1821
  return true;
@@ -1975,7 +2029,7 @@ class InteropTransport {
1975
2029
  registerMethod(key) {
1976
2030
  const method = INCOMING_METHODS[key];
1977
2031
  return this.agm.register(method.name, (args, caller) => {
1978
- this.registry.execute(key, args, caller);
2032
+ return Promise.all(this.registry.execute(key, args, caller));
1979
2033
  });
1980
2034
  }
1981
2035
  }
@@ -3428,6 +3482,21 @@ class Frame {
3428
3482
  const myId = getData$1(this).summary.id;
3429
3483
  return getData$1(this).controller.getFrameState(myId);
3430
3484
  }
3485
+ setIcon(icon) {
3486
+ if (!isDesktop()) {
3487
+ throw new Error("frame.setIcon() is not supported in IO Connect Browser");
3488
+ }
3489
+ iconDecoder.runWithException(icon);
3490
+ const frameId = this.id;
3491
+ return getData$1(this).controller.setTaskbarIcon(icon, frameId);
3492
+ }
3493
+ getIcon() {
3494
+ if (!isDesktop()) {
3495
+ throw new Error("frame.getIcon() is not supported in IO Connect Browser");
3496
+ }
3497
+ const frameId = this.id;
3498
+ return getData$1(this).controller.getTaskbarIcon(frameId);
3499
+ }
3431
3500
  async minimize() {
3432
3501
  if (!isDesktop()) {
3433
3502
  throw new Error("State operations are not supported in IO Connect Browser");
@@ -3449,9 +3518,10 @@ class Frame {
3449
3518
  const myId = getData$1(this).summary.id;
3450
3519
  return getData$1(this).controller.changeFrameState(myId, "normal");
3451
3520
  }
3452
- close() {
3521
+ close(options) {
3522
+ const validatedOptions = optional(closeOptionsDecoder).runWithException(options);
3453
3523
  const myId = getData$1(this).summary.id;
3454
- return getData$1(this).controller.closeItem(myId);
3524
+ return getData$1(this).controller.closeFrame(myId, validatedOptions);
3455
3525
  }
3456
3526
  snapshot() {
3457
3527
  const myId = getData$1(this).summary.id;
@@ -3483,6 +3553,20 @@ class Frame {
3483
3553
  }
3484
3554
  return getData$1(this).controller.initFrame(this.id, config);
3485
3555
  }
3556
+ async onClosing(callback) {
3557
+ if (!isDesktop()) {
3558
+ throw new Error("Frame closing operations are not supported in io.Connect Browser");
3559
+ }
3560
+ checkThrowCallback(callback);
3561
+ const wrappedCallback = async () => {
3562
+ let shouldPrevent = false;
3563
+ const preventClose = () => shouldPrevent = true;
3564
+ await callback({ prevent: preventClose });
3565
+ return { prevent: shouldPrevent };
3566
+ };
3567
+ const unsubscribe = await getData$1(this).controller.registerFrameOnClosing(this.id, wrappedCallback);
3568
+ return unsubscribe;
3569
+ }
3486
3570
  async onClosed(callback) {
3487
3571
  checkThrowCallback(callback);
3488
3572
  const myId = getData$1(this).summary.id;
@@ -4168,6 +4252,12 @@ class BaseController {
4168
4252
  }
4169
4253
  await this.bridge.send(OPERATIONS.bundleItem.name, { type, itemId });
4170
4254
  }
4255
+ async getTaskbarIcon(frameId) {
4256
+ return await this.bridge.send(OPERATIONS.getTaskbarIcon.name, { frameId });
4257
+ }
4258
+ async setTaskbarIcon(icon, frameId) {
4259
+ await this.bridge.send(OPERATIONS.setTaskbarIcon.name, { icon, frameId });
4260
+ }
4171
4261
  getWorkspaceContext(workspaceId) {
4172
4262
  const contextName = `___workspace___${workspaceId}`;
4173
4263
  return this.contexts.get(contextName);
@@ -4196,6 +4286,9 @@ class BaseController {
4196
4286
  async closeItem(itemId) {
4197
4287
  await this.bridge.send(OPERATIONS.closeItem.name, { itemId });
4198
4288
  }
4289
+ async closeFrame(itemId, closeOptions) {
4290
+ await this.bridge.send(OPERATIONS.closeItem.name, { itemId, closeOptions });
4291
+ }
4199
4292
  async resizeItem(itemId, config) {
4200
4293
  await this.bridge.send(OPERATIONS.resizeItem.name, Object.assign({}, { itemId }, config));
4201
4294
  }
@@ -4394,10 +4487,18 @@ class MainController {
4394
4487
  bridge;
4395
4488
  base;
4396
4489
  shortcutsController;
4397
- constructor(bridge, base, shortcutsController) {
4490
+ closingController;
4491
+ constructor(bridge, base, shortcutsController, closingController) {
4398
4492
  this.bridge = bridge;
4399
4493
  this.base = base;
4400
4494
  this.shortcutsController = shortcutsController;
4495
+ this.closingController = closingController;
4496
+ }
4497
+ setTaskbarIcon(icon, frameId) {
4498
+ return this.base.setTaskbarIcon(icon, frameId);
4499
+ }
4500
+ getTaskbarIcon(frameId) {
4501
+ return this.base.getTaskbarIcon(frameId);
4401
4502
  }
4402
4503
  checkIsWindowLoaded(windowId) {
4403
4504
  return this.base.checkIsWindowLoaded(windowId);
@@ -4600,6 +4701,9 @@ class MainController {
4600
4701
  async closeItem(itemId) {
4601
4702
  return await this.base.closeItem(itemId);
4602
4703
  }
4704
+ async closeFrame(itemId, closeOptions) {
4705
+ return await this.base.closeFrame(itemId, closeOptions);
4706
+ }
4603
4707
  async resizeItem(itemId, config) {
4604
4708
  return await this.base.resizeItem(itemId, config);
4605
4709
  }
@@ -4703,6 +4807,9 @@ class MainController {
4703
4807
  setLoadingStrategy(workspaceId, strategy) {
4704
4808
  return this.base.setLoadingStrategy(workspaceId, strategy);
4705
4809
  }
4810
+ registerFrameOnClosing(frameId, callback) {
4811
+ return this.closingController.registerFrameOnClosing(frameId, callback);
4812
+ }
4706
4813
  async handleCoreLocalSubscription(config, levelId) {
4707
4814
  await this.bridge.createCoreEventSubscription();
4708
4815
  config.scopeId = config.scopeId || levelId;
@@ -4776,7 +4883,7 @@ class ShortcutsController {
4776
4883
  _shortcuts = CallbackFactory();
4777
4884
  constructor(bridge) {
4778
4885
  this.bridge = bridge;
4779
- this.bridge.onOperation((payload, caller) => {
4886
+ this.bridge.onOperation((payload) => {
4780
4887
  if (payload.operation === CLIENT_OPERATIONS.shortcutClicked.name) {
4781
4888
  const data = payload.data;
4782
4889
  this._shortcuts.execute(`${data.frameId}-${data.shortcut}`);
@@ -4793,6 +4900,34 @@ class ShortcutsController {
4793
4900
  }
4794
4901
  }
4795
4902
 
4903
+ class ClosingController {
4904
+ bridge;
4905
+ registry = CallbackFactory();
4906
+ constructor(bridge) {
4907
+ this.bridge = bridge;
4908
+ this.subscribeToFrameClosing();
4909
+ }
4910
+ async registerFrameOnClosing(frameId, callback) {
4911
+ await this.bridge.send(OPERATIONS.subscribeToFrameClosing.name, { itemId: frameId });
4912
+ return this.registry.add(frameId, callback);
4913
+ }
4914
+ subscribeToFrameClosing() {
4915
+ this.bridge.onOperationWithResponse(async (payload) => {
4916
+ if (payload.operation !== CLIENT_OPERATIONS.frameClosing.name) {
4917
+ return;
4918
+ }
4919
+ const data = payload.data;
4920
+ const frameClosingResult = await Promise.all(this.registry.execute(data.frameId));
4921
+ return this.aggregateFrameClosingResult(frameClosingResult);
4922
+ });
4923
+ }
4924
+ aggregateFrameClosingResult(results) {
4925
+ return {
4926
+ prevent: results.some((result) => result?.prevent)
4927
+ };
4928
+ }
4929
+ }
4930
+
4796
4931
  class IoC {
4797
4932
  agm;
4798
4933
  windows;
@@ -4805,6 +4940,7 @@ class IoC {
4805
4940
  _parentBaseInstance;
4806
4941
  _baseController;
4807
4942
  _shortcutsController;
4943
+ _closingController;
4808
4944
  constructor(agm, windows, layouts, contexts) {
4809
4945
  this.agm = agm;
4810
4946
  this.windows = windows;
@@ -4819,7 +4955,7 @@ class IoC {
4819
4955
  }
4820
4956
  get controller() {
4821
4957
  if (!this._controllerInstance) {
4822
- this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController);
4958
+ this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController, this.closingController);
4823
4959
  }
4824
4960
  return this._controllerInstance;
4825
4961
  }
@@ -4829,6 +4965,12 @@ class IoC {
4829
4965
  }
4830
4966
  return this._shortcutsController;
4831
4967
  }
4968
+ get closingController() {
4969
+ if (!this._closingController) {
4970
+ this._closingController = new ClosingController(this.bridge);
4971
+ }
4972
+ return this._closingController;
4973
+ }
4832
4974
  get bridge() {
4833
4975
  if (!this._bridgeInstance) {
4834
4976
  this._bridgeInstance = new Bridge(this.transport, CallbackFactory());
@@ -4962,7 +5104,7 @@ class IoC {
4962
5104
  }
4963
5105
  }
4964
5106
 
4965
- var version = "3.5.6";
5107
+ var version = "4.0.0";
4966
5108
 
4967
5109
  const composeAPI = (glue, ioc) => {
4968
5110
  const controller = ioc.controller;