@interopio/workspaces-api 3.5.5 → 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 CHANGED
@@ -1,3 +1,8 @@
1
+ 3.5.7
2
+ feat: G4 e 8073 workspace frame on closing event prevention master
3
+ feat: G4E-8009 Setting taskbar icon for workspace frame api
4
+ 3.5.6
5
+ feat: ability to embed a loading strategy within a workspaces layout upon saving
1
6
  3.5.5
2
7
  feat: setup a workspace to open only once
3
8
  3.5.4
@@ -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"));
@@ -1164,7 +1171,8 @@ const workspaceConfigResultDecoder = object({
1164
1171
  widthInPx: optional(number()),
1165
1172
  heightInPx: optional(number()),
1166
1173
  isPinned: optional(boolean()),
1167
- windowDragMode: optional(windowDragModeDecoder)
1174
+ windowDragMode: optional(windowDragModeDecoder),
1175
+ loadingStrategy: optional(loadingStrategyDecoder)
1168
1176
  });
1169
1177
  const baseChildSnapshotConfigDecoder = object({
1170
1178
  frameId: nonEmptyStringDecoder,
@@ -1338,6 +1346,14 @@ const moveConfigDecoder = object({
1338
1346
  const simpleItemConfigDecoder = object({
1339
1347
  itemId: nonEmptyStringDecoder
1340
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
+ });
1341
1357
  const frameSnapshotConfigDecoder = object({
1342
1358
  itemId: nonEmptyStringDecoder,
1343
1359
  excludeIds: optional(boolean())
@@ -1511,6 +1527,9 @@ const shortcutClickedDataDecoder = object({
1511
1527
  shortcut: nonEmptyStringDecoder,
1512
1528
  frameId: nonEmptyStringDecoder
1513
1529
  });
1530
+ const frameClosingDataDecoder = object({
1531
+ frameId: nonEmptyStringDecoder,
1532
+ });
1514
1533
  const setMaximizationBoundaryAPIConfigDecoder = object({
1515
1534
  enabled: boolean()
1516
1535
  });
@@ -1525,6 +1544,13 @@ const setWindowDragModeDecoder = object({
1525
1544
  itemId: nonEmptyStringDecoder,
1526
1545
  dragMode: windowDragModeDecoder
1527
1546
  });
1547
+ const setLoadingStrategyDecoder = object({
1548
+ itemId: nonEmptyStringDecoder,
1549
+ strategy: loadingStrategyDecoder
1550
+ });
1551
+ const frameClosingResultDecoder = object({
1552
+ prevent: boolean()
1553
+ });
1528
1554
 
1529
1555
  const webPlatformMethodName = "T42.Web.Platform.Control";
1530
1556
  const webPlatformWspStreamName = "T42.Web.Platform.WSP.Stream";
@@ -1546,6 +1572,7 @@ const STREAMS = {
1546
1572
  };
1547
1573
  const CLIENT_OPERATIONS = {
1548
1574
  shortcutClicked: { name: "shortcutClicked", argsDecoder: shortcutClickedDataDecoder, resultDecoder: voidResultDecoder },
1575
+ frameClosing: { name: "frameClosing", argsDecoder: frameClosingDataDecoder, resultDecoder: frameClosingResultDecoder },
1549
1576
  };
1550
1577
  const OPERATIONS = {
1551
1578
  ping: { name: "ping", resultDecoder: pingResultDecoder },
@@ -1567,7 +1594,7 @@ const OPERATIONS = {
1567
1594
  restoreItem: { name: "restoreItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1568
1595
  maximizeItem: { name: "maximizeItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1569
1596
  focusItem: { name: "focusItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1570
- closeItem: { name: "closeItem", argsDecoder: simpleItemConfigDecoder, resultDecoder: voidResultDecoder },
1597
+ closeItem: { name: "closeItem", argsDecoder: closeItemConfigDecoder, resultDecoder: voidResultDecoder },
1571
1598
  resizeItem: { name: "resizeItem", argsDecoder: resizeItemConfigDecoder, resultDecoder: voidResultDecoder },
1572
1599
  setMaximizationBoundary: { name: "setMaximizationBoundary", argsDecoder: setMaximizationBoundaryConfigDecoder, resultDecoder: voidResultDecoder },
1573
1600
  changeFrameState: { name: "changeFrameState", argsDecoder: frameStateConfigDecoder, resultDecoder: voidResultDecoder },
@@ -1598,7 +1625,11 @@ const OPERATIONS = {
1598
1625
  hideLoadingAnimation: { name: "hideLoadingAnimation", argsDecoder: loadingAnimationConfigDecoder, resultDecoder: voidResultDecoder },
1599
1626
  getPlatformFrameId: { name: "getPlatformFrameId", resultDecoder: getPlatformFrameIdResultDecoder },
1600
1627
  operationCheck: { name: "operationCheck", argsDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder },
1601
- setWindowDragMode: { name: "setWindowDragMode", argsDecoder: setWindowDragModeDecoder, resultDecoder: voidResultDecoder }
1628
+ setWindowDragMode: { name: "setWindowDragMode", argsDecoder: setWindowDragModeDecoder, 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 }
1602
1633
  };
1603
1634
 
1604
1635
  class PromiseWrapper {
@@ -1756,6 +1787,35 @@ class Bridge {
1756
1787
  };
1757
1788
  return this.transport.onInternalMethodInvoked("control", wrappedCallback);
1758
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
+ }
1759
1819
  checkScopeMatch(scope, receivedIds) {
1760
1820
  if (scope.type === "global") {
1761
1821
  return true;
@@ -1969,7 +2029,7 @@ class InteropTransport {
1969
2029
  registerMethod(key) {
1970
2030
  const method = INCOMING_METHODS[key];
1971
2031
  return this.agm.register(method.name, (args, caller) => {
1972
- this.registry.execute(key, args, caller);
2032
+ return Promise.all(this.registry.execute(key, args, caller));
1973
2033
  });
1974
2034
  }
1975
2035
  }
@@ -2679,6 +2739,20 @@ class Workspace {
2679
2739
  }
2680
2740
  return getData$3(this).config.windowDragMode;
2681
2741
  }
2742
+ get loadingStrategy() {
2743
+ if (!isDesktop()) {
2744
+ console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser");
2745
+ }
2746
+ return getData$3(this).config.loadingStrategy;
2747
+ }
2748
+ async setLoadingStrategy(strategy) {
2749
+ if (!isDesktop()) {
2750
+ throw new Error("Not supported in IO Connect Browser");
2751
+ }
2752
+ const controller = getData$3(this).controller;
2753
+ await controller.setLoadingStrategy(this.id, strategy);
2754
+ await this.refreshReference();
2755
+ }
2682
2756
  async removeChild(predicate) {
2683
2757
  checkThrowCallback(predicate);
2684
2758
  const child = this.children.find(predicate);
@@ -3408,6 +3482,21 @@ class Frame {
3408
3482
  const myId = getData$1(this).summary.id;
3409
3483
  return getData$1(this).controller.getFrameState(myId);
3410
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
+ }
3411
3500
  async minimize() {
3412
3501
  if (!isDesktop()) {
3413
3502
  throw new Error("State operations are not supported in IO Connect Browser");
@@ -3429,9 +3518,10 @@ class Frame {
3429
3518
  const myId = getData$1(this).summary.id;
3430
3519
  return getData$1(this).controller.changeFrameState(myId, "normal");
3431
3520
  }
3432
- close() {
3521
+ close(options) {
3522
+ const validatedOptions = optional(closeOptionsDecoder).runWithException(options);
3433
3523
  const myId = getData$1(this).summary.id;
3434
- return getData$1(this).controller.closeItem(myId);
3524
+ return getData$1(this).controller.closeFrame(myId, validatedOptions);
3435
3525
  }
3436
3526
  snapshot() {
3437
3527
  const myId = getData$1(this).summary.id;
@@ -3463,6 +3553,20 @@ class Frame {
3463
3553
  }
3464
3554
  return getData$1(this).controller.initFrame(this.id, config);
3465
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
+ }
3466
3570
  async onClosed(callback) {
3467
3571
  checkThrowCallback(callback);
3468
3572
  const myId = getData$1(this).summary.id;
@@ -4148,6 +4252,12 @@ class BaseController {
4148
4252
  }
4149
4253
  await this.bridge.send(OPERATIONS.bundleItem.name, { type, itemId });
4150
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
+ }
4151
4261
  getWorkspaceContext(workspaceId) {
4152
4262
  const contextName = `___workspace___${workspaceId}`;
4153
4263
  return this.contexts.get(contextName);
@@ -4176,6 +4286,9 @@ class BaseController {
4176
4286
  async closeItem(itemId) {
4177
4287
  await this.bridge.send(OPERATIONS.closeItem.name, { itemId });
4178
4288
  }
4289
+ async closeFrame(itemId, closeOptions) {
4290
+ await this.bridge.send(OPERATIONS.closeItem.name, { itemId, closeOptions });
4291
+ }
4179
4292
  async resizeItem(itemId, config) {
4180
4293
  await this.bridge.send(OPERATIONS.resizeItem.name, Object.assign({}, { itemId }, config));
4181
4294
  }
@@ -4358,6 +4471,10 @@ class BaseController {
4358
4471
  return {};
4359
4472
  }
4360
4473
  }
4474
+ async setLoadingStrategy(workspaceId, strategy) {
4475
+ await this.isOperationSupported(OPERATIONS.setLoadingStrategy.name);
4476
+ return this.bridge.send(OPERATIONS.setLoadingStrategy.name, { itemId: workspaceId, strategy });
4477
+ }
4361
4478
  async isOperationSupported(operation) {
4362
4479
  if (isDesktop()) {
4363
4480
  return { isSupported: true };
@@ -4370,10 +4487,18 @@ class MainController {
4370
4487
  bridge;
4371
4488
  base;
4372
4489
  shortcutsController;
4373
- constructor(bridge, base, shortcutsController) {
4490
+ closingController;
4491
+ constructor(bridge, base, shortcutsController, closingController) {
4374
4492
  this.bridge = bridge;
4375
4493
  this.base = base;
4376
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);
4377
4502
  }
4378
4503
  checkIsWindowLoaded(windowId) {
4379
4504
  return this.base.checkIsWindowLoaded(windowId);
@@ -4576,6 +4701,9 @@ class MainController {
4576
4701
  async closeItem(itemId) {
4577
4702
  return await this.base.closeItem(itemId);
4578
4703
  }
4704
+ async closeFrame(itemId, closeOptions) {
4705
+ return await this.base.closeFrame(itemId, closeOptions);
4706
+ }
4579
4707
  async resizeItem(itemId, config) {
4580
4708
  return await this.base.resizeItem(itemId, config);
4581
4709
  }
@@ -4676,6 +4804,12 @@ class MainController {
4676
4804
  getPlatformFrameId() {
4677
4805
  return this.base.getPlatformFrameId();
4678
4806
  }
4807
+ setLoadingStrategy(workspaceId, strategy) {
4808
+ return this.base.setLoadingStrategy(workspaceId, strategy);
4809
+ }
4810
+ registerFrameOnClosing(frameId, callback) {
4811
+ return this.closingController.registerFrameOnClosing(frameId, callback);
4812
+ }
4679
4813
  async handleCoreLocalSubscription(config, levelId) {
4680
4814
  await this.bridge.createCoreEventSubscription();
4681
4815
  config.scopeId = config.scopeId || levelId;
@@ -4749,7 +4883,7 @@ class ShortcutsController {
4749
4883
  _shortcuts = CallbackFactory();
4750
4884
  constructor(bridge) {
4751
4885
  this.bridge = bridge;
4752
- this.bridge.onOperation((payload, caller) => {
4886
+ this.bridge.onOperation((payload) => {
4753
4887
  if (payload.operation === CLIENT_OPERATIONS.shortcutClicked.name) {
4754
4888
  const data = payload.data;
4755
4889
  this._shortcuts.execute(`${data.frameId}-${data.shortcut}`);
@@ -4766,6 +4900,34 @@ class ShortcutsController {
4766
4900
  }
4767
4901
  }
4768
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
+
4769
4931
  class IoC {
4770
4932
  agm;
4771
4933
  windows;
@@ -4778,6 +4940,7 @@ class IoC {
4778
4940
  _parentBaseInstance;
4779
4941
  _baseController;
4780
4942
  _shortcutsController;
4943
+ _closingController;
4781
4944
  constructor(agm, windows, layouts, contexts) {
4782
4945
  this.agm = agm;
4783
4946
  this.windows = windows;
@@ -4792,7 +4955,7 @@ class IoC {
4792
4955
  }
4793
4956
  get controller() {
4794
4957
  if (!this._controllerInstance) {
4795
- this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController);
4958
+ this._controllerInstance = new MainController(this.bridge, this.baseController, this.shortcutsController, this.closingController);
4796
4959
  }
4797
4960
  return this._controllerInstance;
4798
4961
  }
@@ -4802,6 +4965,12 @@ class IoC {
4802
4965
  }
4803
4966
  return this._shortcutsController;
4804
4967
  }
4968
+ get closingController() {
4969
+ if (!this._closingController) {
4970
+ this._closingController = new ClosingController(this.bridge);
4971
+ }
4972
+ return this._closingController;
4973
+ }
4805
4974
  get bridge() {
4806
4975
  if (!this._bridgeInstance) {
4807
4976
  this._bridgeInstance = new Bridge(this.transport, CallbackFactory());
@@ -4935,7 +5104,7 @@ class IoC {
4935
5104
  }
4936
5105
  }
4937
5106
 
4938
- var version = "3.5.5";
5107
+ var version = "3.5.7";
4939
5108
 
4940
5109
  const composeAPI = (glue, ioc) => {
4941
5110
  const controller = ioc.controller;