@openfin/core 46.100.65 → 46.100.67

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/out/stub.mjs CHANGED
@@ -13080,6 +13080,45 @@ class PrivateChannelProvider {
13080
13080
  }
13081
13081
  }
13082
13082
 
13083
+ /**
13084
+ * The default FDC3 user channels advertised by the Interop Broker.
13085
+ */
13086
+ const defaultColorChannels = {
13087
+ 'fdc3.channel.1': { name: 'Channel 1', color: 'red', glyph: '1' },
13088
+ 'fdc3.channel.2': { name: 'Channel 2', color: 'orange', glyph: '2' },
13089
+ 'fdc3.channel.3': { name: 'Channel 3', color: 'yellow', glyph: '3' },
13090
+ 'fdc3.channel.4': { name: 'Channel 4', color: 'green', glyph: '4' },
13091
+ 'fdc3.channel.5': { name: 'Channel 5', color: 'cyan', glyph: '5' },
13092
+ 'fdc3.channel.6': { name: 'Channel 6', color: 'blue', glyph: '6' },
13093
+ 'fdc3.channel.7': { name: 'Channel 7', color: 'magenta', glyph: '7' },
13094
+ 'fdc3.channel.8': { name: 'Channel 8', color: 'purple', glyph: '8' }
13095
+ };
13096
+ const legacyColorChannelIds = {
13097
+ red: 'fdc3.channel.1',
13098
+ orange: 'fdc3.channel.2',
13099
+ yellow: 'fdc3.channel.3',
13100
+ green: 'fdc3.channel.4',
13101
+ teal: 'fdc3.channel.5',
13102
+ blue: 'fdc3.channel.6',
13103
+ pink: 'fdc3.channel.7',
13104
+ // Legacy indigo (workspace) and purple (core) intentionally converge on the same FDC3 purple channel.
13105
+ indigo: 'fdc3.channel.8',
13106
+ purple: 'fdc3.channel.8'
13107
+ };
13108
+ /**
13109
+ * Converts a legacy color-named channel ID to its canonical FDC3 user-channel ID.
13110
+ * The removed legacy gray channel resolves to no channel.
13111
+ */
13112
+ function normalizeColorChannelId(colorChannelId) {
13113
+ if (colorChannelId === 'gray') {
13114
+ return undefined;
13115
+ }
13116
+ if (Object.prototype.hasOwnProperty.call(legacyColorChannelIds, colorChannelId)) {
13117
+ return legacyColorChannelIds[colorChannelId];
13118
+ }
13119
+ return colorChannelId;
13120
+ }
13121
+
13083
13122
  var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13084
13123
  if (kind === "m") throw new TypeError("Private method is not writable");
13085
13124
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -13092,50 +13131,7 @@ var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) |
13092
13131
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13093
13132
  };
13094
13133
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
13095
- const defaultContextGroups = [
13096
- {
13097
- id: 'green',
13098
- displayMetadata: {
13099
- color: '#00CC88',
13100
- name: 'green'
13101
- }
13102
- },
13103
- {
13104
- id: 'purple',
13105
- displayMetadata: {
13106
- color: '#8C61FF',
13107
- name: 'purple'
13108
- }
13109
- },
13110
- {
13111
- id: 'orange',
13112
- displayMetadata: {
13113
- color: '#FF8C4C',
13114
- name: 'orange'
13115
- }
13116
- },
13117
- {
13118
- id: 'red',
13119
- displayMetadata: {
13120
- color: '#FF5E60',
13121
- name: 'red'
13122
- }
13123
- },
13124
- {
13125
- id: 'pink',
13126
- displayMetadata: {
13127
- color: '#FF8FB8',
13128
- name: 'pink'
13129
- }
13130
- },
13131
- {
13132
- id: 'yellow',
13133
- displayMetadata: {
13134
- color: '#E9FF8F',
13135
- name: 'yellow'
13136
- }
13137
- }
13138
- ];
13134
+ const defaultContextGroups = Object.entries(defaultColorChannels).map(([id, displayMetadata]) => ({ id, displayMetadata }));
13139
13135
  /**
13140
13136
  * {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
13141
13137
  *
@@ -13165,17 +13161,19 @@ const defaultContextGroups = [
13165
13161
  * "interopBrokerConfiguration": {
13166
13162
  * "contextGroups": [
13167
13163
  * {
13168
- * "id": "green",
13164
+ * "id": "fdc3.channel.4",
13169
13165
  * "displayMetadata": {
13170
- * "color": "#00CC88",
13171
- * "name": "green"
13166
+ * "color": "green",
13167
+ * "name": "Channel 4",
13168
+ * "glyph": "4"
13172
13169
  * }
13173
13170
  * },
13174
13171
  * {
13175
- * "id": "purple",
13172
+ * "id": "fdc3.channel.8",
13176
13173
  * "displayMetadata": {
13177
- * "color": "#8C61FF",
13178
- * "name": "purple"
13174
+ * "color": "purple",
13175
+ * "name": "Channel 8",
13176
+ * "glyph": "8"
13179
13177
  * }
13180
13178
  * },
13181
13179
  * ]
@@ -13338,9 +13336,13 @@ class InteropBroker extends Base {
13338
13336
  this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
13339
13337
  // don't expose, analytics-only call
13340
13338
  });
13341
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
13339
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13340
+ if (normalizedContextGroupId === undefined) {
13341
+ return;
13342
+ }
13343
+ const contextGroupState = this.contextGroupsById.get(normalizedContextGroupId);
13342
13344
  if (!contextGroupState) {
13343
- throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
13345
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${normalizedContextGroupId}.`);
13344
13346
  }
13345
13347
  const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13346
13348
  if (contextIntegrityCheckResult.isValid === false) {
@@ -13348,8 +13350,8 @@ class InteropBroker extends Base {
13348
13350
  }
13349
13351
  const broadcastedContextType = context.type;
13350
13352
  contextGroupState.set(broadcastedContextType, context);
13351
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
13352
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13353
+ this.lastContextMap.set(normalizedContextGroupId, broadcastedContextType);
13354
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId);
13353
13355
  clientsInSameContextGroup.forEach((client) => {
13354
13356
  for (const [, handlerInfo] of client.contextHandlers) {
13355
13357
  if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
@@ -13395,10 +13397,20 @@ class InteropBroker extends Base {
13395
13397
  * @param joinContextGroupOptions - Id of the Context Group and identity of the entity to join to the group.
13396
13398
  * @param senderIdentity - Identity of the client sender.
13397
13399
  */
13398
- async joinContextGroup({ contextGroupId, target }, senderIdentity) {
13400
+ async joinContextGroup({ contextGroupId: requestedContextGroupId, target }, senderIdentity) {
13399
13401
  this.wire.sendAction('interop-broker-join-context-group').catch((e) => {
13400
13402
  // don't expose, analytics-only call
13401
13403
  });
13404
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13405
+ if (contextGroupId === undefined) {
13406
+ if (target) {
13407
+ await this.removeFromContextGroup({ target }, senderIdentity);
13408
+ }
13409
+ else {
13410
+ await this.removeClientFromContextGroup(senderIdentity);
13411
+ }
13412
+ return;
13413
+ }
13402
13414
  if (this.sessionContextGroupMap.has(contextGroupId)) {
13403
13415
  throw new Error(BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);
13404
13416
  }
@@ -13440,10 +13452,15 @@ class InteropBroker extends Base {
13440
13452
  * @param addClientToContextGroupOptions - Contains the contextGroupId
13441
13453
  * @param clientIdentity - Identity of the client sender.
13442
13454
  */
13443
- async addClientToContextGroup({ contextGroupId }, clientIdentity) {
13455
+ async addClientToContextGroup({ contextGroupId: requestedContextGroupId }, clientIdentity) {
13444
13456
  this.wire.sendAction('interop-broker-add-client-to-context-group').catch((e) => {
13445
13457
  // don't expose, analytics-only call
13446
13458
  });
13459
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13460
+ if (contextGroupId === undefined) {
13461
+ await this.removeClientFromContextGroup(clientIdentity);
13462
+ return;
13463
+ }
13447
13464
  const clientSubscriptionState = this.getClientState(clientIdentity);
13448
13465
  if (!clientSubscriptionState) {
13449
13466
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
@@ -13542,6 +13559,9 @@ class InteropBroker extends Base {
13542
13559
  clientState.contextGroupId = undefined;
13543
13560
  }
13544
13561
  await this.setCurrentContextGroupInClientOptions(clientIdentity, null);
13562
+ if (previousContextGroupId === undefined) {
13563
+ return;
13564
+ }
13545
13565
  // All settled will suppress uncaught exceptions. We don't want to await this because it could
13546
13566
  // result in the operation hanging.
13547
13567
  Promise.allSettled(this.channel.publish('client-changed-context-group', {
@@ -13579,7 +13599,11 @@ class InteropBroker extends Base {
13579
13599
  this.wire.sendAction('interop-broker-get-info-for-context-group').catch((e) => {
13580
13600
  // don't expose, analytics-only call
13581
13601
  });
13582
- return this.getContextGroups().find((contextGroup) => contextGroup.id === contextGroupId);
13602
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13603
+ if (normalizedContextGroupId === undefined) {
13604
+ return undefined;
13605
+ }
13606
+ return this.getContextGroups().find((contextGroup) => contextGroup.id === normalizedContextGroupId);
13583
13607
  }
13584
13608
  // Used by platform windows to get all clients for a context group.
13585
13609
  /**
@@ -13595,8 +13619,12 @@ class InteropBroker extends Base {
13595
13619
  this.wire.sendAction('interop-broker-get-all-clients-in-context-group').catch((e) => {
13596
13620
  // don't expose, analytics-only call
13597
13621
  });
13622
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13623
+ if (normalizedContextGroupId === undefined) {
13624
+ return [];
13625
+ }
13598
13626
  const clientsInContextGroup = Array.from(this.interopClients.values())
13599
- .filter((connectedClient) => connectedClient.contextGroupId === contextGroupId)
13627
+ .filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId)
13600
13628
  .map((subscriptionState) => {
13601
13629
  return subscriptionState.clientIdentity;
13602
13630
  });
@@ -14043,8 +14071,9 @@ class InteropBroker extends Base {
14043
14071
  }
14044
14072
  // Used to restore interop broker state in snapshots.
14045
14073
  applySnapshot(snapshot, options) {
14046
- const contextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
14047
- if (contextGroupStates) {
14074
+ const incomingContextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
14075
+ if (incomingContextGroupStates) {
14076
+ const contextGroupStates = this.normalizeContextGroupStates(incomingContextGroupStates);
14048
14077
  if (!options?.closeExistingWindows) {
14049
14078
  this.updateExistingClients(contextGroupStates);
14050
14079
  }
@@ -14189,6 +14218,23 @@ class InteropBroker extends Base {
14189
14218
  });
14190
14219
  return newObject;
14191
14220
  }
14221
+ normalizeContextGroupStates(incomingContextGroupStates) {
14222
+ const normalizedContextGroupStates = {};
14223
+ for (const [contextGroupId, contexts] of Object.entries(incomingContextGroupStates)) {
14224
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
14225
+ if (normalizedContextGroupId !== undefined) {
14226
+ normalizedContextGroupStates[normalizedContextGroupId] = {
14227
+ ...normalizedContextGroupStates[normalizedContextGroupId],
14228
+ ...contexts
14229
+ };
14230
+ }
14231
+ }
14232
+ return normalizedContextGroupStates;
14233
+ }
14234
+ normalizeContextGroupId(contextGroupId) {
14235
+ const usesDefaultColorChannels = Object.keys(defaultColorChannels).every((defaultContextGroupId) => this.contextGroupsById.has(defaultContextGroupId));
14236
+ return usesDefaultColorChannels ? normalizeColorChannelId(contextGroupId) : contextGroupId;
14237
+ }
14192
14238
  // Util to check a client identity.
14193
14239
  static hasEndpointId(target) {
14194
14240
  return target.endpointId !== undefined;
@@ -14252,8 +14298,14 @@ class InteropBroker extends Base {
14252
14298
  clientIdentity
14253
14299
  };
14254
14300
  // Only allow the client to join a contextGroup that actually exists.
14255
- if (payload?.currentContextGroup && this.contextGroupsById.has(payload.currentContextGroup)) {
14256
- clientSubscriptionState.contextGroupId = payload?.currentContextGroup;
14301
+ const currentContextGroup = payload?.currentContextGroup
14302
+ ? this.normalizeContextGroupId(payload.currentContextGroup)
14303
+ : undefined;
14304
+ if (currentContextGroup && this.contextGroupsById.has(currentContextGroup)) {
14305
+ clientSubscriptionState.contextGroupId = currentContextGroup;
14306
+ if (currentContextGroup !== payload.currentContextGroup) {
14307
+ await this.setCurrentContextGroupInClientOptions(clientIdentity, currentContextGroup);
14308
+ }
14257
14309
  }
14258
14310
  this.interopClients.set(clientIdentity.endpointId, clientSubscriptionState);
14259
14311
  });
@@ -14823,7 +14875,7 @@ class InteropClient extends Base {
14823
14875
  *
14824
14876
  * getLastFocusedView()
14825
14877
  * .then(lastFocusedViewIdentity => {
14826
- * joinViewToContextGroup('red', lastFocusedViewIdentity)
14878
+ * joinViewToContextGroup('fdc3.channel.1', lastFocusedViewIdentity)
14827
14879
  * })
14828
14880
  * ```
14829
14881
  */
@@ -14873,7 +14925,7 @@ class InteropClient extends Base {
14873
14925
  *
14874
14926
  * @example
14875
14927
  * ```js
14876
- * fin.me.interop.getAllClientsInContextGroup('red')
14928
+ * fin.me.interop.getAllClientsInContextGroup('fdc3.channel.1')
14877
14929
  * .then(clientsInContextGroup => {
14878
14930
  * console.log(clientsInContextGroup)
14879
14931
  * })
@@ -14897,7 +14949,7 @@ class InteropClient extends Base {
14897
14949
  *
14898
14950
  * @example
14899
14951
  * ```js
14900
- * fin.me.interop.getInfoForContextGroup('red')
14952
+ * fin.me.interop.getInfoForContextGroup('fdc3.channel.1')
14901
14953
  * .then(contextGroupInfo => {
14902
14954
  * console.log(contextGroupInfo.displayMetadata.name)
14903
14955
  * console.log(contextGroupInfo.displayMetadata.color)
@@ -14986,12 +15038,12 @@ class InteropClient extends Base {
14986
15038
  *
14987
15039
  * @example
14988
15040
  * ```js
14989
- * await fin.me.interop.joinContextGroup('yellow');
15041
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
14990
15042
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
14991
15043
  * const currentContext = await fin.me.interop.getCurrentContext();
14992
15044
  *
14993
15045
  * // with a specific context
14994
- * await fin.me.interop.joinContextGroup('yellow');
15046
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
14995
15047
  * await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
14996
15048
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
14997
15049
  * const currentContext = await fin.me.interop.getCurrentContext('country');
@@ -15653,15 +15705,18 @@ class FDC3ModuleBase {
15653
15705
  async joinChannel(channelId) {
15654
15706
  this.wire.recordAnalytic('fdc3-join-channel');
15655
15707
  try {
15708
+ const contextGroup = await this.client.getInfoForContextGroup(channelId);
15709
+ if (!contextGroup) {
15710
+ console.error(`No User Channel was found with the ID "${channelId}". If this is an App Channel, use getOrCreateChannel instead.`);
15711
+ throw new Error(ChannelError.NoChannelFound);
15712
+ }
15656
15713
  return await this.client.joinContextGroup(channelId);
15657
15714
  }
15658
15715
  catch (error) {
15659
- if (error.message === BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
15660
- console.error('The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel.');
15661
- }
15662
- else {
15663
- console.error(error.message);
15716
+ if (error.message === ChannelError.NoChannelFound) {
15717
+ throw new Error(ChannelError.NoChannelFound);
15664
15718
  }
15719
+ console.error(error.message);
15665
15720
  if (error.message.startsWith('Attempting to join a context group that does not exist')) {
15666
15721
  throw new Error(ChannelError.NoChannelFound);
15667
15722
  }
@@ -16341,7 +16396,7 @@ class InteropModule extends Base {
16341
16396
  * @example
16342
16397
  * ```js
16343
16398
  * const interopConfig = {
16344
- * currentContextGroup: 'green'
16399
+ * currentContextGroup: 'fdc3.channel.4'
16345
16400
  * }
16346
16401
  *
16347
16402
  * const interopBroker = await fin.Interop.init('openfin');
@@ -17346,4 +17401,4 @@ const fin$1 = ((typeof window !== 'undefined' && window?.fin) ||
17346
17401
  return new Fin(transport);
17347
17402
  })());
17348
17403
 
17349
- export { OpenFin, OpenFin as default, fin$1 as fin };
17404
+ export { OpenFin, OpenFin as default, defaultColorChannels, fin$1 as fin, normalizeColorChannelId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "46.100.65",
3
+ "version": "46.100.67",
4
4
  "description": "The core renderer entry point of OpenFin",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "out/stub.js",