@interopio/workspaces-api 4.6.0 → 5.0.0-next.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,9 +1,16 @@
1
+ ## 5.0.0-next.0
1
2
 
2
- ## 4.6.0
3
+ ### Major Changes
4
+
5
+ - b7b1ac5: chore: bump all packages to v5.0.0
6
+
7
+ ### Minor Changes
8
+
9
+ - c5e2cfa: feat: G4E-10611 Workspace layout can now have appRestrictions for showing apps in add application popup and for allowing apps to be dropped
3
10
 
4
11
  ### Patch Changes
5
12
 
6
- - Cascade patch bump for internal dependents
13
+ - 04c50d6: feature: Added support for IDs in layouts and general support for layout sharing
7
14
 
8
15
  ## 4.5.0
9
16
 
@@ -924,6 +924,19 @@ const allParentDecoder = oneOf(constant("workspace"), constant("row"), constant(
924
924
  const subParentDecoder = oneOf(constant("row"), constant("column"), constant("group"));
925
925
  const frameStateDecoder = oneOf(constant("maximized"), constant("minimized"), constant("normal"));
926
926
  const loadingAnimationTypeDecoder = oneOf(constant("workspace"));
927
+ const appRestrictionRuleDecoder = object({
928
+ allowInApplicationPopup: optional(boolean()),
929
+ allowDrop: optional(boolean())
930
+ });
931
+ const appRestrictionEntryDecoder = object({
932
+ appName: nonEmptyStringDecoder,
933
+ allowInApplicationPopup: optional(boolean()),
934
+ allowDrop: optional(boolean())
935
+ });
936
+ const appRestrictionsDecoder = object({
937
+ apps: optional(array(appRestrictionEntryDecoder)),
938
+ default: optional(appRestrictionRuleDecoder)
939
+ });
927
940
  const checkThrowCallback = (callback, allowUndefined) => {
928
941
  const argumentType = typeof callback;
929
942
  if (allowUndefined && argumentType !== "function" && argumentType !== "undefined") {
@@ -939,6 +952,9 @@ const workspaceBuilderCreateConfigDecoder = optional(object({
939
952
  const deleteLayoutConfigDecoder = object({
940
953
  name: nonEmptyStringDecoder
941
954
  });
955
+ const deleteLayoutByIdConfigDecoder = object({
956
+ layoutId: nonEmptyStringDecoder
957
+ });
942
958
  const windowDefinitionConfigDecoder = object({
943
959
  minWidth: optional(number()),
944
960
  maxWidth: optional(number()),
@@ -1045,7 +1061,13 @@ const restoreWorkspaceConfigDecoder = optional(object({
1045
1061
  isPinned: optional(boolean()),
1046
1062
  isSelected: optional(boolean()),
1047
1063
  positionIndex: optional(nonNegativeNumberDecoder),
1048
- allowSystemHibernation: optional(boolean())
1064
+ allowSystemHibernation: optional(boolean()),
1065
+ }));
1066
+ const restoreWorkspaceByIdConfigDecoder = intersection(restoreWorkspaceConfigDecoder, object({
1067
+ layoutId: nonEmptyStringDecoder,
1068
+ }));
1069
+ const openWorkspaceByIdConfigDecoder = intersection(restoreWorkspaceConfigDecoder, object({
1070
+ layoutId: nonEmptyStringDecoder,
1049
1071
  }));
1050
1072
  const openWorkspaceConfigDecoder = object({
1051
1073
  name: nonEmptyStringDecoder,
@@ -1081,7 +1103,8 @@ const workspaceDefinitionDecoder = object({
1081
1103
  isPinned: optional(boolean()),
1082
1104
  isSelected: optional(boolean()),
1083
1105
  positionIndex: optional(nonNegativeNumberDecoder),
1084
- windowDragMode: optional(windowDragModeDecoder)
1106
+ windowDragMode: optional(windowDragModeDecoder),
1107
+ appRestrictions: optional(appRestrictionsDecoder)
1085
1108
  })),
1086
1109
  frame: optional(object({
1087
1110
  activate: optional(boolean()),
@@ -1097,6 +1120,10 @@ const restoreWorkspaceDefinitionDecoder = object({
1097
1120
  name: nonEmptyStringDecoder,
1098
1121
  restoreOptions: optional(restoreWorkspaceConfigDecoder)
1099
1122
  });
1123
+ const restoreWorkspaceByIdDefinitionDecoder = object({
1124
+ id: nonEmptyStringDecoder,
1125
+ restoreOptions: optional(restoreWorkspaceConfigDecoder)
1126
+ });
1100
1127
  const emptyFrameDefinitionDecoder = optional(object({
1101
1128
  applicationName: optional(string()),
1102
1129
  frameConfig: optional(newFrameConfigDecoder),
@@ -1104,11 +1131,11 @@ const emptyFrameDefinitionDecoder = optional(object({
1104
1131
  layoutComponentId: optional(nonEmptyStringDecoder)
1105
1132
  }));
1106
1133
  const frameInitConfigDecoder = object({
1107
- workspaces: array(oneOf(optional(workspaceDefinitionDecoder), optional(restoreWorkspaceDefinitionDecoder)))
1134
+ workspaces: array(oneOf(optional(workspaceDefinitionDecoder), optional(restoreWorkspaceDefinitionDecoder), optional(restoreWorkspaceByIdDefinitionDecoder)))
1108
1135
  });
1109
1136
  const frameInitProtocolConfigDecoder = object({
1110
1137
  frameId: nonEmptyStringDecoder,
1111
- workspaces: array(oneOf(workspaceDefinitionDecoder, restoreWorkspaceDefinitionDecoder))
1138
+ workspaces: array(oneOf(workspaceDefinitionDecoder, restoreWorkspaceDefinitionDecoder, restoreWorkspaceByIdDefinitionDecoder))
1112
1139
  });
1113
1140
  const builderConfigDecoder = object({
1114
1141
  type: allParentDecoder,
@@ -1149,6 +1176,7 @@ const workspaceConfigResultDecoder = object({
1149
1176
  title: nonEmptyStringDecoder,
1150
1177
  positionIndex: nonNegativeNumberDecoder,
1151
1178
  name: nonEmptyStringDecoder,
1179
+ layoutId: optional(nonEmptyStringDecoder),
1152
1180
  layoutName: optional(nonEmptyStringDecoder),
1153
1181
  isHibernated: optional(boolean()),
1154
1182
  isSelected: optional(boolean()),
@@ -1176,7 +1204,8 @@ const workspaceConfigResultDecoder = object({
1176
1204
  heightInPx: optional(number()),
1177
1205
  isPinned: optional(boolean()),
1178
1206
  windowDragMode: optional(windowDragModeDecoder),
1179
- loadingStrategy: optional(loadingStrategyDecoder)
1207
+ loadingStrategy: optional(loadingStrategyDecoder),
1208
+ appRestrictions: optional(appRestrictionsDecoder)
1180
1209
  });
1181
1210
  const baseChildSnapshotConfigDecoder = object({
1182
1211
  frameId: nonEmptyStringDecoder,
@@ -1261,6 +1290,7 @@ const rowLayoutItemDecoder = object({
1261
1290
  children: array(oneOf(columnLayoutItemDecoder, groupLayoutItemDecoder, windowLayoutItemDecoder, lazy(() => rowLayoutItemDecoder)))
1262
1291
  });
1263
1292
  const workspaceLayoutDecoder = object({
1293
+ id: optional(nonEmptyStringDecoder),
1264
1294
  name: nonEmptyStringDecoder,
1265
1295
  type: constant("Workspace"),
1266
1296
  metadata: optional(anyJson()),
@@ -1307,6 +1337,7 @@ const frameSnapshotResultDecoder = object({
1307
1337
  workspaces: array(workspaceSnapshotResultDecoder)
1308
1338
  });
1309
1339
  const layoutSummaryDecoder = object({
1340
+ id: optional(nonEmptyStringDecoder),
1310
1341
  name: nonEmptyStringDecoder,
1311
1342
  applicationName: optional(string())
1312
1343
  });
@@ -1435,6 +1466,16 @@ const windowStreamDataDecoder = object({
1435
1466
  })
1436
1467
  });
1437
1468
  const workspaceLayoutSaveConfigDecoder = object({
1469
+ id: optional(nonEmptyStringDecoder),
1470
+ name: nonEmptyStringDecoder,
1471
+ workspaceId: nonEmptyStringDecoder,
1472
+ saveContext: optional(boolean()),
1473
+ allowMultiple: optional(boolean()),
1474
+ metadata: optional(object()),
1475
+ saveWindowContexts: optional(boolean())
1476
+ });
1477
+ const workspaceLayoutSaveByIdConfigDecoder = object({
1478
+ id: optional(nonEmptyStringDecoder),
1438
1479
  name: nonEmptyStringDecoder,
1439
1480
  workspaceId: nonEmptyStringDecoder,
1440
1481
  saveContext: optional(boolean()),
@@ -1671,9 +1712,12 @@ const OPERATIONS = {
1671
1712
  getAllWorkspacesSummaries: { name: "getAllWorkspacesSummaries", resultDecoder: workspaceSummariesResultDecoder },
1672
1713
  getWorkspaceSnapshot: { name: "getWorkspaceSnapshot", resultDecoder: workspaceSnapshotResultDecoder, argsDecoder: simpleItemConfigDecoder },
1673
1714
  getAllLayoutsSummaries: { name: "getAllLayoutsSummaries", resultDecoder: layoutSummariesDecoder },
1715
+ openWorkspaceById: { name: "openWorkspaceById", argsDecoder: openWorkspaceByIdConfigDecoder, resultDecoder: workspaceSnapshotResultDecoder },
1674
1716
  openWorkspace: { name: "openWorkspace", argsDecoder: openWorkspaceConfigDecoder, resultDecoder: workspaceSnapshotResultDecoder },
1675
1717
  deleteLayout: { name: "deleteLayout", resultDecoder: voidResultDecoder, argsDecoder: deleteLayoutConfigDecoder },
1718
+ deleteLayoutById: { name: "deleteLayoutById", resultDecoder: voidResultDecoder, argsDecoder: deleteLayoutByIdConfigDecoder },
1676
1719
  saveLayout: { name: "saveLayout", resultDecoder: workspaceLayoutDecoder, argsDecoder: workspaceLayoutSaveConfigDecoder },
1720
+ saveLayoutById: { name: "saveLayoutById", resultDecoder: workspaceLayoutDecoder, argsDecoder: workspaceLayoutSaveByIdConfigDecoder },
1677
1721
  importLayout: { name: "importLayout", resultDecoder: voidResultDecoder, argsDecoder: workspacesImportLayoutDecoder },
1678
1722
  importLayouts: { name: "importLayouts", resultDecoder: voidResultDecoder, argsDecoder: workspacesImportLayoutsDecoder },
1679
1723
  exportAllLayouts: { name: "exportAllLayouts", resultDecoder: exportedLayoutsResultDecoder },
@@ -2741,6 +2785,9 @@ class Workspace {
2741
2785
  get title() {
2742
2786
  return getData$3(this).config.title;
2743
2787
  }
2788
+ get layoutId() {
2789
+ return getData$3(this).config.layoutId;
2790
+ }
2744
2791
  get layoutName() {
2745
2792
  return getData$3(this).config.layoutName;
2746
2793
  }
@@ -2783,6 +2830,9 @@ class Workspace {
2783
2830
  get allowWindowReorder() {
2784
2831
  return getData$3(this).config.allowWindowReorder;
2785
2832
  }
2833
+ get appRestrictions() {
2834
+ return getData$3(this).config.appRestrictions;
2835
+ }
2786
2836
  get showCloseButton() {
2787
2837
  return getData$3(this).config.showCloseButton;
2788
2838
  }
@@ -4297,11 +4347,13 @@ class BaseController {
4297
4347
  windows;
4298
4348
  contexts;
4299
4349
  layouts;
4300
- constructor(ioc, windows, contexts, layouts) {
4350
+ layoutsV2;
4351
+ constructor(ioc, windows, contexts, layouts, layoutsV2) {
4301
4352
  this.ioc = ioc;
4302
4353
  this.windows = windows;
4303
4354
  this.contexts = contexts;
4304
4355
  this.layouts = layouts;
4356
+ this.layoutsV2 = layoutsV2;
4305
4357
  }
4306
4358
  get bridge() {
4307
4359
  return this.ioc.bridge;
@@ -4331,6 +4383,16 @@ class BaseController {
4331
4383
  async initFrame(frameId, config) {
4332
4384
  await this.bridge.send(OPERATIONS.initFrame.name, { frameId, ...config });
4333
4385
  }
4386
+ async restoreWorkspaceById(options) {
4387
+ const snapshot = await this.bridge.send(OPERATIONS.openWorkspaceById.name, { ...options });
4388
+ const frameSummary = await this.bridge.send(OPERATIONS.getFrameSummary.name, { itemId: snapshot.config.frameId });
4389
+ const frameConfig = {
4390
+ summary: frameSummary
4391
+ };
4392
+ const frame = this.ioc.getModel("frame", frameConfig);
4393
+ const workspaceConfig = { frame, snapshot };
4394
+ return this.ioc.getModel("workspace", workspaceConfig);
4395
+ }
4334
4396
  async restoreWorkspace(name, options) {
4335
4397
  const snapshot = await this.bridge.send(OPERATIONS.openWorkspace.name, { name, restoreOptions: options });
4336
4398
  const frameSummary = await this.bridge.send(OPERATIONS.getFrameSummary.name, { itemId: snapshot.config.frameId });
@@ -4383,13 +4445,20 @@ class BaseController {
4383
4445
  return Object.assign({}, { id: summary.id, width: summary.config.widthInPx, height: summary.config.heightInPx }, summary.config);
4384
4446
  });
4385
4447
  }
4386
- handleOnSaved(callback) {
4448
+ async handleOnSaved(callback) {
4387
4449
  const wrappedCallback = (layout) => {
4388
4450
  if (layout.type !== "Workspace") {
4389
4451
  return;
4390
4452
  }
4391
4453
  callback(layout);
4392
4454
  };
4455
+ if (this.layoutsV2) {
4456
+ const [addedUnSub, changedUnSub] = await Promise.all([this.layoutsV2.onAdded(wrappedCallback), this.layoutsV2.onChanged(wrappedCallback)]);
4457
+ return () => {
4458
+ addedUnSub();
4459
+ changedUnSub();
4460
+ };
4461
+ }
4393
4462
  const addedUnSub = this.layouts.onAdded(wrappedCallback);
4394
4463
  const changedUnSub = this.layouts.onChanged(wrappedCallback);
4395
4464
  return () => {
@@ -4397,13 +4466,16 @@ class BaseController {
4397
4466
  changedUnSub();
4398
4467
  };
4399
4468
  }
4400
- handleOnRemoved(callback) {
4469
+ async handleOnRemoved(callback) {
4401
4470
  const wrappedCallback = (layout) => {
4402
4471
  if (layout.type !== "Workspace") {
4403
4472
  return;
4404
4473
  }
4405
4474
  callback(layout);
4406
4475
  };
4476
+ if (this.layoutsV2) {
4477
+ return this.layoutsV2.onRemoved(wrappedCallback);
4478
+ }
4407
4479
  return this.layouts.onRemoved(wrappedCallback);
4408
4480
  }
4409
4481
  async importLayouts(layouts, mode) {
@@ -4727,6 +4799,21 @@ class MainController {
4727
4799
  async initFrame(frameId, config) {
4728
4800
  return this.base.initFrame(frameId, config);
4729
4801
  }
4802
+ async restoreWorkspaceById(options) {
4803
+ const allLayouts = await this.getLayoutSummaries();
4804
+ const layoutExists = allLayouts.some((summary) => summary.id === options.layoutId);
4805
+ if (!layoutExists) {
4806
+ throw new Error(`This layout: ${options.layoutId} cannot be restored, because it doesn't exist.`);
4807
+ }
4808
+ if (options?.frameId) {
4809
+ const allFrameSummaries = await this.bridge.send(OPERATIONS.getAllFramesSummaries.name);
4810
+ const foundMatchingFrame = allFrameSummaries.summaries.some((summary) => summary.id === options.frameId);
4811
+ if (!foundMatchingFrame) {
4812
+ throw new Error(`Cannot reuse the frame with id: ${options.frameId}, because there is no frame with that ID found`);
4813
+ }
4814
+ }
4815
+ return await this.base.restoreWorkspaceById(options);
4816
+ }
4730
4817
  async restoreWorkspace(name, options) {
4731
4818
  const allLayouts = await this.getLayoutSummaries();
4732
4819
  const layoutExists = allLayouts.some((summary) => summary.name === name);
@@ -4845,6 +4932,9 @@ class MainController {
4845
4932
  async deleteLayout(name) {
4846
4933
  await this.bridge.send(OPERATIONS.deleteLayout.name, { name });
4847
4934
  }
4935
+ async deleteLayoutById(layoutId) {
4936
+ await this.bridge.send(OPERATIONS.deleteLayoutById.name, { layoutId });
4937
+ }
4848
4938
  async exportLayout(predicate) {
4849
4939
  const allLayoutsResult = await this.bridge.send(OPERATIONS.exportAllLayouts.name);
4850
4940
  return allLayoutsResult.layouts.reduce((matchingLayouts, layout) => {
@@ -4857,6 +4947,9 @@ class MainController {
4857
4947
  async saveLayout(config) {
4858
4948
  return await this.bridge.send(OPERATIONS.saveLayout.name, config);
4859
4949
  }
4950
+ async saveLayoutById(config) {
4951
+ return await this.bridge.send(OPERATIONS.saveLayoutById.name, config);
4952
+ }
4860
4953
  async importLayouts(layouts, mode) {
4861
4954
  if (isDesktop()) {
4862
4955
  try {
@@ -4869,10 +4962,10 @@ class MainController {
4869
4962
  }
4870
4963
  await this.base.importLayouts(layouts, mode);
4871
4964
  }
4872
- handleOnSaved(callback) {
4965
+ async handleOnSaved(callback) {
4873
4966
  return this.base.handleOnSaved(callback);
4874
4967
  }
4875
- handleOnRemoved(callback) {
4968
+ async handleOnRemoved(callback) {
4876
4969
  return this.base.handleOnRemoved(callback);
4877
4970
  }
4878
4971
  async bundleWorkspaceTo(type, workspaceId) {
@@ -5193,6 +5286,7 @@ class IoC {
5193
5286
  windows;
5194
5287
  layouts;
5195
5288
  contexts;
5289
+ layoutsV2;
5196
5290
  _controllerInstance;
5197
5291
  _bridgeInstance;
5198
5292
  _transportInstance;
@@ -5201,15 +5295,16 @@ class IoC {
5201
5295
  _baseController;
5202
5296
  _shortcutsController;
5203
5297
  _closingController;
5204
- constructor(agm, windows, layouts, contexts) {
5298
+ constructor(agm, windows, layouts, contexts, layoutsV2) {
5205
5299
  this.agm = agm;
5206
5300
  this.windows = windows;
5207
5301
  this.layouts = layouts;
5208
5302
  this.contexts = contexts;
5303
+ this.layoutsV2 = layoutsV2;
5209
5304
  }
5210
5305
  get baseController() {
5211
5306
  if (!this._baseController) {
5212
- this._baseController = new BaseController(this, this.windows, this.contexts, this.layouts);
5307
+ this._baseController = new BaseController(this, this.windows, this.contexts, this.layouts, this.layoutsV2);
5213
5308
  }
5214
5309
  return this._baseController;
5215
5310
  }
@@ -5364,7 +5459,7 @@ class IoC {
5364
5459
  }
5365
5460
  }
5366
5461
 
5367
- var version = "4.6.0";
5462
+ var version = "5.0.0-next.0";
5368
5463
 
5369
5464
  const composeAPI = (glue, ioc) => {
5370
5465
  const controller = ioc.controller;
@@ -5432,6 +5527,10 @@ const composeAPI = (glue, ioc) => {
5432
5527
  checkThrowCallback(predicate);
5433
5528
  return controller.getParent(predicate);
5434
5529
  };
5530
+ const restoreWorkspaceById = async (options) => {
5531
+ const validatedOptions = restoreWorkspaceByIdConfigDecoder.runWithException(options);
5532
+ return controller.restoreWorkspaceById(validatedOptions);
5533
+ };
5435
5534
  const restoreWorkspace = async (name, options) => {
5436
5535
  nonEmptyStringDecoder.runWithException(name);
5437
5536
  const validatedOptions = restoreWorkspaceConfigDecoder.runWithException(options);
@@ -5454,6 +5553,10 @@ const composeAPI = (glue, ioc) => {
5454
5553
  nonEmptyStringDecoder.runWithException(name);
5455
5554
  return controller.deleteLayout(name);
5456
5555
  },
5556
+ deleteById: async (layoutId) => {
5557
+ nonEmptyStringDecoder.runWithException(layoutId);
5558
+ return controller.deleteLayoutById(layoutId);
5559
+ },
5457
5560
  export: async (predicate) => {
5458
5561
  checkThrowCallback(predicate, true);
5459
5562
  return controller.exportLayout(predicate);
@@ -5469,6 +5572,10 @@ const composeAPI = (glue, ioc) => {
5469
5572
  const verifiedConfig = workspaceLayoutSaveConfigDecoder.runWithException(config);
5470
5573
  return controller.saveLayout(verifiedConfig);
5471
5574
  },
5575
+ saveById: async (config) => {
5576
+ const verifiedConfig = workspaceLayoutSaveByIdConfigDecoder.runWithException(config);
5577
+ return controller.saveLayoutById(verifiedConfig);
5578
+ },
5472
5579
  onSaved: async (callback) => {
5473
5580
  checkThrowCallback(callback);
5474
5581
  return controller.handleOnSaved(callback);
@@ -5688,6 +5795,7 @@ const composeAPI = (glue, ioc) => {
5688
5795
  getWindow,
5689
5796
  getBox: getParent,
5690
5797
  restoreWorkspace,
5798
+ restoreWorkspaceById,
5691
5799
  createWorkspace,
5692
5800
  createEmptyFrame,
5693
5801
  waitForFrame,
@@ -5711,7 +5819,7 @@ const composeAPI = (glue, ioc) => {
5711
5819
  };
5712
5820
 
5713
5821
  const factoryFunction = async (io) => {
5714
- const ioc = new IoC(io.agm, io.windows, io.layouts, io.contexts);
5822
+ const ioc = new IoC(io.agm, io.windows, io.layouts, io.contexts, io.layouts.v2);
5715
5823
  const actualWindowId = io.interop.instance.windowId;
5716
5824
  await ioc.initiate(actualWindowId);
5717
5825
  io.workspaces = composeAPI(io, ioc);