@interopio/browser 3.4.6 → 3.4.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.
@@ -2033,7 +2033,7 @@
2033
2033
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
2034
2034
  const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
2035
2035
  const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"), constant$1("prefs"));
2036
- const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1("windowHello"), constant$1("windowAdded"), constant$1("windowRemoved"), constant$1("getBounds"), constant$1("getFrameBounds"), constant$1("getUrl"), constant$1("moveResize"), constant$1("focus"), constant$1("close"), constant$1("getTitle"), constant$1("setTitle"), constant$1("focusChange"), constant$1("getChannel"));
2036
+ const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1("windowHello"), constant$1("windowAdded"), constant$1("windowRemoved"), constant$1("getBounds"), constant$1("getFrameBounds"), constant$1("getUrl"), constant$1("moveResize"), constant$1("focus"), constant$1("close"), constant$1("getTitle"), constant$1("setTitle"), constant$1("focusChange"), constant$1("getChannel"), constant$1("notifyChannelsChanged"));
2037
2037
  const appManagerOperationTypesDecoder = oneOf$1(constant$1("appHello"), constant$1("appDirectoryStateChange"), constant$1("instanceStarted"), constant$1("instanceStopped"), constant$1("applicationStart"), constant$1("instanceStop"), constant$1("clear"));
2038
2038
  const layoutsOperationTypesDecoder = oneOf$1(constant$1("layoutAdded"), constant$1("layoutChanged"), constant$1("layoutRemoved"), constant$1("layoutRenamed"), constant$1("get"), constant$1("getAll"), constant$1("export"), constant$1("import"), constant$1("remove"), constant$1("rename"), constant$1("clientSaveRequest"), constant$1("getGlobalPermissionState"), constant$1("checkGlobalActivated"), constant$1("requestGlobalPermission"), constant$1("getDefaultGlobal"), constant$1("setDefaultGlobal"), constant$1("clearDefaultGlobal"), constant$1("updateMetadata"));
2039
2039
  const notificationsOperationTypesDecoder = oneOf$1(constant$1("raiseNotification"), constant$1("requestPermission"), constant$1("notificationShow"), constant$1("notificationClick"), constant$1("getPermission"), constant$1("list"), constant$1("notificationRaised"), constant$1("notificationClosed"), constant$1("click"), constant$1("clear"), constant$1("clearAll"), constant$1("configure"), constant$1("getConfiguration"), constant$1("configurationChanged"), constant$1("setState"), constant$1("clearOld"), constant$1("activeCountChange"), constant$1("stateChange"));
@@ -2123,12 +2123,28 @@
2123
2123
  id: nonEmptyStringDecoder,
2124
2124
  applicationName: nonEmptyStringDecoder
2125
2125
  });
2126
+ const iframePermissionsPolicyConfigDecoder = object$1({
2127
+ flags: string$1()
2128
+ });
2129
+ const workspacesSandboxDecoder = object$1({
2130
+ flags: string$1()
2131
+ });
2132
+ const requestChannelSelectorConfigDecoder = object$1({
2133
+ windowId: nonEmptyStringDecoder,
2134
+ channelsNames: array$1(nonEmptyStringDecoder)
2135
+ });
2136
+ const channelSelectorDecoder = object$1({
2137
+ enabled: boolean$1(),
2138
+ });
2126
2139
  const applicationDetailsDecoder = object$1({
2127
2140
  url: nonEmptyStringDecoder,
2128
2141
  top: optional$1(number$1()),
2129
2142
  left: optional$1(number$1()),
2130
2143
  width: optional$1(nonNegativeNumberDecoder),
2131
- height: optional$1(nonNegativeNumberDecoder)
2144
+ height: optional$1(nonNegativeNumberDecoder),
2145
+ workspacesSandbox: optional$1(workspacesSandboxDecoder),
2146
+ channelSelector: optional$1(channelSelectorDecoder),
2147
+ iframePermissionsPolicy: optional$1(iframePermissionsPolicyConfigDecoder)
2132
2148
  });
2133
2149
  const intentDefinitionDecoder = object$1({
2134
2150
  name: nonEmptyStringDecoder,
@@ -2491,6 +2507,10 @@
2491
2507
  name: optional$1(nonEmptyStringDecoder),
2492
2508
  fdc3: optional$1(boolean$1())
2493
2509
  })));
2510
+ const leaveChannelsConfig = object$1({
2511
+ windowId: optionalNonEmptyStringDecoder,
2512
+ channel: optionalNonEmptyStringDecoder
2513
+ });
2494
2514
  const fdc3ContextDecoder = anyJson$1().where((value) => typeof value.type === "string", "Expected a valid FDC3 Context with compulsory 'type' field");
2495
2515
  const interopActionSettingsDecoder = object$1({
2496
2516
  method: nonEmptyStringDecoder,
@@ -2707,7 +2727,7 @@
2707
2727
  const getWindowIdsOnChannelResultDecoder = object$1({
2708
2728
  windowIds: array$1(nonEmptyStringDecoder)
2709
2729
  });
2710
- const channelsOperationTypesDecoder = oneOf$1(constant$1("addChannel"), constant$1("getMyChannel"), constant$1("getWindowIdsOnChannel"), constant$1("getWindowIdsWithChannels"), constant$1("joinChannel"), constant$1("restrict"), constant$1("getRestrictions"), constant$1("restrictAll"));
2730
+ const channelsOperationTypesDecoder = oneOf$1(constant$1("addChannel"), constant$1("getMyChannel"), constant$1("getWindowIdsOnChannel"), constant$1("getWindowIdsWithChannels"), constant$1("joinChannel"), constant$1("restrict"), constant$1("getRestrictions"), constant$1("restrictAll"), constant$1("notifyChannelsChanged"), constant$1("leaveChannel"));
2711
2731
  const getMyChanelResultDecoder = object$1({
2712
2732
  channel: optional$1(nonEmptyStringDecoder)
2713
2733
  });
@@ -2742,6 +2762,14 @@
2742
2762
  channel: nonEmptyStringDecoder,
2743
2763
  windowId: nonEmptyStringDecoder
2744
2764
  });
2765
+ const leaveChannelDataDecoder = object$1({
2766
+ windowId: nonEmptyStringDecoder,
2767
+ channelName: optional$1(nonEmptyStringDecoder)
2768
+ });
2769
+ const channelsChangedDataDecoder = object$1({
2770
+ windowId: nonEmptyStringDecoder,
2771
+ channelNames: array$1(nonEmptyStringDecoder)
2772
+ });
2745
2773
  const windowChannelResultDecoder = object$1({
2746
2774
  channel: optional$1(nonEmptyStringDecoder),
2747
2775
  });
@@ -2792,6 +2820,7 @@
2792
2820
  setTitle: { name: "setTitle", dataDecoder: windowTitleConfigDecoder },
2793
2821
  focusChange: { name: "focusChange", dataDecoder: focusEventDataDecoder },
2794
2822
  getChannel: { name: "getChannel", dataDecoder: simpleWindowDecoder, resultDecoder: windowChannelResultDecoder },
2823
+ notifyChannelsChanged: { name: "notifyChannelsChanged", dataDecoder: channelsChangedDataDecoder }
2795
2824
  };
2796
2825
 
2797
2826
  function getDefaultExportFromCjs$1 (x) {
@@ -2947,6 +2976,9 @@
2947
2976
  this.me.isFocused = hasFocus;
2948
2977
  this.registry.execute("focus-change", this.me);
2949
2978
  }
2979
+ processChannelsChangedEvent(channelNames) {
2980
+ this.registry.execute("channels-changed", channelNames);
2981
+ }
2950
2982
  async toApi() {
2951
2983
  this.ctxUnsubscribe = await this._bridge.contextLib.subscribe(this.myCtxKey, (data) => this.registry.execute("context-updated", data));
2952
2984
  this.me = {
@@ -2968,6 +3000,7 @@
2968
3000
  onContextUpdated: this.onContextUpdated.bind(this),
2969
3001
  onFocusChanged: this.onFocusChanged.bind(this),
2970
3002
  getChannel: this.getChannel.bind(this),
3003
+ onChannelsChanged: this.onChannelsChanged.bind(this),
2971
3004
  };
2972
3005
  return this.me;
2973
3006
  }
@@ -3072,9 +3105,12 @@
3072
3105
  const result = await this._bridge.send("windows", operations$9.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
3073
3106
  return result.channel;
3074
3107
  }
3108
+ onChannelsChanged(callback) {
3109
+ return this.registry.add("channels-changed", callback);
3110
+ }
3075
3111
  }
3076
3112
 
3077
- const systemOperations = {
3113
+ const commonOperations = {
3078
3114
  operationCheck: { name: "operationCheck", dataDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder },
3079
3115
  getWorkspaceWindowFrameBounds: { name: "getWorkspaceWindowFrameBounds", resultDecoder: workspaceFrameBoundsResultDecoder, dataDecoder: simpleItemIdDecoder }
3080
3116
  };
@@ -3087,7 +3123,7 @@
3087
3123
  return;
3088
3124
  }
3089
3125
  promiseActive = false;
3090
- const message = timeoutMessage || `Promise timeout hit: ${timeoutMilliseconds}`;
3126
+ const message = timeoutMessage;
3091
3127
  reject(message);
3092
3128
  }, timeoutMilliseconds);
3093
3129
  promise()
@@ -3218,6 +3254,7 @@
3218
3254
  operations$9.moveResize.execute = this.handleMoveResize.bind(this);
3219
3255
  operations$9.setTitle.execute = this.handleSetTitle.bind(this);
3220
3256
  operations$9.getChannel.execute = this.handleGetChannel.bind(this);
3257
+ operations$9.notifyChannelsChanged.execute = this.handleChannelsChanged.bind(this);
3221
3258
  }
3222
3259
  my() {
3223
3260
  return Object.assign({}, this.me);
@@ -3351,7 +3388,7 @@
3351
3388
  return;
3352
3389
  }
3353
3390
  try {
3354
- await this.bridge.send("windows", systemOperations.operationCheck, { operation: "focusChange" });
3391
+ await this.bridge.send("windows", commonOperations.operationCheck, { operation: "focusChange" });
3355
3392
  }
3356
3393
  catch (error) {
3357
3394
  this.logger.warn("The platform of this client is outdated and does not support focus tracking, disabling focus events for this client.");
@@ -3407,6 +3444,10 @@
3407
3444
  ...(channel ? { channel } : {}),
3408
3445
  };
3409
3446
  }
3447
+ async handleChannelsChanged(data) {
3448
+ const windowProjection = this.allWindowProjections.find((projection) => projection.id === data.windowId);
3449
+ windowProjection?.model.processChannelsChangedEvent(data.channelNames);
3450
+ }
3410
3451
  }
3411
3452
 
3412
3453
  const GlueWebPlatformControlName = "T42.Web.Platform.Control";
@@ -3499,7 +3540,7 @@
3499
3540
  }
3500
3541
  async checkOperationSupported(domain, operation) {
3501
3542
  try {
3502
- const result = await this.send(domain, systemOperations.operationCheck, { operation: operation.name });
3543
+ const result = await this.send(domain, commonOperations.operationCheck, { operation: operation.name });
3503
3544
  return result;
3504
3545
  }
3505
3546
  catch (error) {
@@ -4547,7 +4588,7 @@
4547
4588
  }
4548
4589
  async isRaiseOperationSupported() {
4549
4590
  try {
4550
- const { isSupported } = await this.bridge.send("intents", systemOperations.operationCheck, { operation: "raise" });
4591
+ const { isSupported } = await this.bridge.send("intents", commonOperations.operationCheck, { operation: "raise" });
4551
4592
  return {
4552
4593
  supported: isSupported,
4553
4594
  reason: isSupported ? "" : "The platform of this client is outdated and does not support \"raise\" operation"
@@ -4781,7 +4822,10 @@
4781
4822
  joinChannel: { name: "joinChannel", dataDecoder: joinChannelDataDecoder },
4782
4823
  restrict: { name: "restrict", dataDecoder: restrictionConfigDataDecoder },
4783
4824
  getRestrictions: { name: "getRestrictions", dataDecoder: getRestrictionsDataDecoder, resultDecoder: restrictionsDecoder },
4784
- restrictAll: { name: "restrictAll", dataDecoder: restrictAllDataDecoder }
4825
+ restrictAll: { name: "restrictAll", dataDecoder: restrictAllDataDecoder },
4826
+ notifyChannelsChanged: { name: "notifyChannelsChanged", dataDecoder: channelsChangedDataDecoder },
4827
+ leaveChannel: { name: "leaveChannel", dataDecoder: leaveChannelDataDecoder },
4828
+ requestChannelSelector: { name: "requestChannelSelector", dataDecoder: requestChannelSelectorConfigDecoder }
4785
4829
  };
4786
4830
 
4787
4831
  class ChannelsController {
@@ -4802,6 +4846,7 @@
4802
4846
  addOperationsExecutors() {
4803
4847
  operations$4.getMyChannel.execute = this.handleGetMyChannel.bind(this);
4804
4848
  operations$4.joinChannel.execute = this.handleJoinChannel.bind(this);
4849
+ operations$4.leaveChannel.execute = this.handleLeaveChannel.bind(this);
4805
4850
  operations$4.restrict.execute = ({ config }) => this.restrict(config);
4806
4851
  operations$4.getRestrictions.execute = ({ windowId }) => this.getRestrictions(windowId);
4807
4852
  operations$4.restrictAll.execute = ({ restrictions }) => this.restrictAll(restrictions);
@@ -4818,6 +4863,14 @@
4818
4863
  const api = this.toApi();
4819
4864
  coreGlue.channels = api;
4820
4865
  }
4866
+ async postStart(io, ioc) {
4867
+ try {
4868
+ await this.requestChannelSelector(io.appManager.myInstance);
4869
+ }
4870
+ catch (error) {
4871
+ this.logger.warn(`Failed to display channel selector: ${extractErrorMsg(error)}`);
4872
+ }
4873
+ }
4821
4874
  async handleBridgeMessage(args) {
4822
4875
  const operationName = runDecoderWithIOError(channelsOperationTypesDecoder, args.operation);
4823
4876
  const operation = operations$4[operationName];
@@ -4859,8 +4912,17 @@
4859
4912
  onChanged(callback) {
4860
4913
  return this.changed(callback);
4861
4914
  }
4862
- async leave() {
4863
- await this.switchToChannel();
4915
+ async leave(config = {}) {
4916
+ runDecoderWithIOError(leaveChannelsConfig, config);
4917
+ if (!config.windowId || config.windowId === this.windowsController.my().id) {
4918
+ await this.switchToChannel();
4919
+ return;
4920
+ }
4921
+ const leaveData = { windowId: config.windowId, channelName: config.channel };
4922
+ await this.bridge.send("channels", operations$4.leaveChannel, leaveData, undefined, { includeOperationCheck: true });
4923
+ }
4924
+ handleLeaveChannel(data) {
4925
+ return this.leave({ channel: data.channelName });
4864
4926
  }
4865
4927
  toApi() {
4866
4928
  const api = {
@@ -4913,6 +4975,17 @@
4913
4975
  }
4914
4976
  this.registry.execute(this.ChangedKey, name);
4915
4977
  this.sessionController.setWindowData({ currentName: name }, "channels");
4978
+ const windowId = this.windowsController.my().id;
4979
+ if (!windowId) {
4980
+ return;
4981
+ }
4982
+ const channelNames = this.currentChannelName ? [this.currentChannelName] : [];
4983
+ try {
4984
+ await this.bridge.send("channels", operations$4.notifyChannelsChanged, { channelNames: channelNames, windowId }, undefined, { includeOperationCheck: true });
4985
+ }
4986
+ catch (error) {
4987
+ this.logger.warn(`Failed to notify channel changed: ${extractErrorMsg(error)}`);
4988
+ }
4916
4989
  }
4917
4990
  async updateData(name, data) {
4918
4991
  const contextName = this.createContextName(name);
@@ -5281,6 +5354,25 @@
5281
5354
  const fdc3Data = { type: searchedType, ...context.data[`fdc3_${latestFdc3TypeEncoded}`] };
5282
5355
  callback({ fdc3: fdc3Data }, context, updaterId);
5283
5356
  }
5357
+ async requestChannelSelector(myInstance) {
5358
+ if (!myInstance) {
5359
+ return;
5360
+ }
5361
+ const myApplicationData = myInstance.application;
5362
+ const myAppDetails = myApplicationData.userProperties?.details;
5363
+ if (!myAppDetails) {
5364
+ return;
5365
+ }
5366
+ if (!myAppDetails?.channelSelector?.enabled) {
5367
+ return;
5368
+ }
5369
+ const { channels: channelsStorageData } = this.sessionController.getWindowData();
5370
+ const channelName = channelsStorageData?.currentName;
5371
+ const windowId = myInstance.id;
5372
+ const channelsNames = channelName ? [channelName] : [];
5373
+ const requestChannelSelectorConfig = { windowId, channelsNames };
5374
+ await this.bridge.send("channels", operations$4.requestChannelSelector, requestChannelSelectorConfig, undefined, { includeOperationCheck: true });
5375
+ }
5284
5376
  }
5285
5377
 
5286
5378
  const operations$3 = {
@@ -5875,8 +5967,8 @@
5875
5967
  }
5876
5968
  async tryGetWorkspaceBasedBounds() {
5877
5969
  try {
5878
- await this.bridge.send("workspaces", systemOperations.operationCheck, { operation: "getWorkspaceWindowFrameBounds" });
5879
- const bridgeResponse = await this.bridge.send("workspaces", systemOperations.getWorkspaceWindowFrameBounds, { itemId: this.windowsController.my().id });
5970
+ await this.bridge.send("workspaces", commonOperations.operationCheck, { operation: "getWorkspaceWindowFrameBounds" });
5971
+ const bridgeResponse = await this.bridge.send("workspaces", commonOperations.getWorkspaceWindowFrameBounds, { itemId: this.windowsController.my().id });
5880
5972
  const myWorkspaceBounds = bridgeResponse.bounds;
5881
5973
  this.logger.trace(`Opening the resolver UI relative to my workspace frame window bounds: ${JSON.stringify(myWorkspaceBounds)}`);
5882
5974
  return myWorkspaceBounds;
@@ -6378,7 +6470,7 @@
6378
6470
  }
6379
6471
  }
6380
6472
 
6381
- var version$1 = "3.4.6";
6473
+ var version$1 = "3.4.7";
6382
6474
 
6383
6475
  const createFactoryFunction = (coreFactoryFunction) => {
6384
6476
  let cachedApiPromise;
@@ -6399,6 +6491,7 @@
6399
6491
  logger.trace("all libraries were started");
6400
6492
  ioc.eventsDispatcher.start(glue);
6401
6493
  logger.trace("start event dispatched, glue is ready, returning it");
6494
+ await Promise.all(Object.values(ioc.controllers).map((controller) => controller.postStart ? controller.postStart(glue, ioc) : Promise.resolve()));
6402
6495
  return glue;
6403
6496
  }
6404
6497
  catch (error) {
@@ -9761,10 +9854,6 @@
9761
9854
  function arrayReduce(array, iteratee, accumulator, initAccum) {
9762
9855
  var index = -1,
9763
9856
  length = array ? array.length : 0;
9764
-
9765
- if (initAccum && length) {
9766
- accumulator = array[++index];
9767
- }
9768
9857
  while (++index < length) {
9769
9858
  accumulator = iteratee(accumulator, array[index], index, array);
9770
9859
  }
@@ -10350,7 +10439,7 @@
10350
10439
  skipIndexes = !!length;
10351
10440
 
10352
10441
  for (var key in value) {
10353
- if ((inherited || hasOwnProperty.call(value, key)) &&
10442
+ if ((hasOwnProperty.call(value, key)) &&
10354
10443
  !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
10355
10444
  result.push(key);
10356
10445
  }
@@ -10703,9 +10792,7 @@
10703
10792
  while (++index < length) {
10704
10793
  var key = props[index];
10705
10794
 
10706
- var newValue = customizer
10707
- ? customizer(object[key], source[key], key, object, source)
10708
- : undefined;
10795
+ var newValue = undefined;
10709
10796
 
10710
10797
  assignValue(object, key, newValue === undefined ? source[key] : newValue);
10711
10798
  }