@openfin/core 45.100.114 → 45.100.115

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.js CHANGED
@@ -2518,6 +2518,47 @@ class Application extends EmitterBase {
2518
2518
  constructor(wire, identity) {
2519
2519
  super(wire, 'application', identity.uuid);
2520
2520
  this.identity = identity;
2521
+ /**
2522
+ * @experimental
2523
+ * Retrieves a performance snapshot for all Windows, Views and Frames in the Application.
2524
+ *
2525
+ * By default, all custom marks and measures are collected, along with navigation/paint entries
2526
+ * and resource timing (`resources` defaults to `true`). Pass `include` to restrict custom
2527
+ * marks/measures to matching names (string substring or RegExp). Pass `browser: true` to also
2528
+ * include hereio internal runtime metrics.
2529
+ *
2530
+ * See also [MDN | Performance Mark API](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)
2531
+ *
2532
+ * Note - only currently running WebContents will be captured, and performance entries can only be
2533
+ * captured for the current navigation of each.
2534
+ */
2535
+ this.getPerformanceStats = async (options = {}) => {
2536
+ /**
2537
+ * Returns a filter object compatible with JSON.stringify (regexs stringify to `{}`).
2538
+ * @param include Array of strings or regexps.
2539
+ */
2540
+ const getSerializableFilterObject = (include) => {
2541
+ return include.map((filter) => {
2542
+ if (filter instanceof RegExp) {
2543
+ return {
2544
+ type: 'regex',
2545
+ expression: filter.source,
2546
+ flags: filter.flags
2547
+ };
2548
+ }
2549
+ return filter;
2550
+ });
2551
+ };
2552
+ const { include, resources = true, browser = false } = options;
2553
+ const result = await this.wire.sendAction('get-application-performance-stats', {
2554
+ ...this.identity,
2555
+ // Omit `include` when unspecified so the runtime collects all custom marks/measures.
2556
+ ...(include !== undefined ? { include: getSerializableFilterObject(include) } : {}),
2557
+ resources,
2558
+ browser
2559
+ });
2560
+ return result.payload.data;
2561
+ };
2521
2562
  this.window = new _Window(this.wire, {
2522
2563
  uuid: this.identity.uuid,
2523
2564
  name: this.identity.uuid
@@ -13085,6 +13126,45 @@ class PrivateChannelProvider {
13085
13126
  }
13086
13127
  }
13087
13128
 
13129
+ /**
13130
+ * The default FDC3 user channels advertised by the Interop Broker.
13131
+ */
13132
+ const defaultColorChannels = {
13133
+ 'fdc3.channel.1': { name: 'Channel 1', color: 'red', glyph: '1' },
13134
+ 'fdc3.channel.2': { name: 'Channel 2', color: 'orange', glyph: '2' },
13135
+ 'fdc3.channel.3': { name: 'Channel 3', color: 'yellow', glyph: '3' },
13136
+ 'fdc3.channel.4': { name: 'Channel 4', color: 'green', glyph: '4' },
13137
+ 'fdc3.channel.5': { name: 'Channel 5', color: 'cyan', glyph: '5' },
13138
+ 'fdc3.channel.6': { name: 'Channel 6', color: 'blue', glyph: '6' },
13139
+ 'fdc3.channel.7': { name: 'Channel 7', color: 'magenta', glyph: '7' },
13140
+ 'fdc3.channel.8': { name: 'Channel 8', color: 'purple', glyph: '8' }
13141
+ };
13142
+ const legacyColorChannelIds = {
13143
+ red: 'fdc3.channel.1',
13144
+ orange: 'fdc3.channel.2',
13145
+ yellow: 'fdc3.channel.3',
13146
+ green: 'fdc3.channel.4',
13147
+ teal: 'fdc3.channel.5',
13148
+ blue: 'fdc3.channel.6',
13149
+ pink: 'fdc3.channel.7',
13150
+ // Legacy indigo (workspace) and purple (core) intentionally converge on the same FDC3 purple channel.
13151
+ indigo: 'fdc3.channel.8',
13152
+ purple: 'fdc3.channel.8'
13153
+ };
13154
+ /**
13155
+ * Converts a legacy color-named channel ID to its canonical FDC3 user-channel ID.
13156
+ * The removed legacy gray channel resolves to no channel.
13157
+ */
13158
+ function normalizeColorChannelId(colorChannelId) {
13159
+ if (colorChannelId === 'gray') {
13160
+ return undefined;
13161
+ }
13162
+ if (Object.prototype.hasOwnProperty.call(legacyColorChannelIds, colorChannelId)) {
13163
+ return legacyColorChannelIds[colorChannelId];
13164
+ }
13165
+ return colorChannelId;
13166
+ }
13167
+
13088
13168
  var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13089
13169
  if (kind === "m") throw new TypeError("Private method is not writable");
13090
13170
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -13097,50 +13177,7 @@ var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) |
13097
13177
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13098
13178
  };
13099
13179
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
13100
- const defaultContextGroups = [
13101
- {
13102
- id: 'green',
13103
- displayMetadata: {
13104
- color: '#00CC88',
13105
- name: 'green'
13106
- }
13107
- },
13108
- {
13109
- id: 'purple',
13110
- displayMetadata: {
13111
- color: '#8C61FF',
13112
- name: 'purple'
13113
- }
13114
- },
13115
- {
13116
- id: 'orange',
13117
- displayMetadata: {
13118
- color: '#FF8C4C',
13119
- name: 'orange'
13120
- }
13121
- },
13122
- {
13123
- id: 'red',
13124
- displayMetadata: {
13125
- color: '#FF5E60',
13126
- name: 'red'
13127
- }
13128
- },
13129
- {
13130
- id: 'pink',
13131
- displayMetadata: {
13132
- color: '#FF8FB8',
13133
- name: 'pink'
13134
- }
13135
- },
13136
- {
13137
- id: 'yellow',
13138
- displayMetadata: {
13139
- color: '#E9FF8F',
13140
- name: 'yellow'
13141
- }
13142
- }
13143
- ];
13180
+ const defaultContextGroups = Object.entries(defaultColorChannels).map(([id, displayMetadata]) => ({ id, displayMetadata }));
13144
13181
  /**
13145
13182
  * {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
13146
13183
  *
@@ -13170,17 +13207,19 @@ const defaultContextGroups = [
13170
13207
  * "interopBrokerConfiguration": {
13171
13208
  * "contextGroups": [
13172
13209
  * {
13173
- * "id": "green",
13210
+ * "id": "fdc3.channel.4",
13174
13211
  * "displayMetadata": {
13175
- * "color": "#00CC88",
13176
- * "name": "green"
13212
+ * "color": "green",
13213
+ * "name": "Channel 4",
13214
+ * "glyph": "4"
13177
13215
  * }
13178
13216
  * },
13179
13217
  * {
13180
- * "id": "purple",
13218
+ * "id": "fdc3.channel.8",
13181
13219
  * "displayMetadata": {
13182
- * "color": "#8C61FF",
13183
- * "name": "purple"
13220
+ * "color": "purple",
13221
+ * "name": "Channel 8",
13222
+ * "glyph": "8"
13184
13223
  * }
13185
13224
  * },
13186
13225
  * ]
@@ -13343,9 +13382,13 @@ class InteropBroker extends Base {
13343
13382
  this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
13344
13383
  // don't expose, analytics-only call
13345
13384
  });
13346
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
13385
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13386
+ if (normalizedContextGroupId === undefined) {
13387
+ return;
13388
+ }
13389
+ const contextGroupState = this.contextGroupsById.get(normalizedContextGroupId);
13347
13390
  if (!contextGroupState) {
13348
- throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
13391
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${normalizedContextGroupId}.`);
13349
13392
  }
13350
13393
  const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13351
13394
  if (contextIntegrityCheckResult.isValid === false) {
@@ -13353,8 +13396,8 @@ class InteropBroker extends Base {
13353
13396
  }
13354
13397
  const broadcastedContextType = context.type;
13355
13398
  contextGroupState.set(broadcastedContextType, context);
13356
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
13357
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13399
+ this.lastContextMap.set(normalizedContextGroupId, broadcastedContextType);
13400
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId);
13358
13401
  clientsInSameContextGroup.forEach((client) => {
13359
13402
  for (const [, handlerInfo] of client.contextHandlers) {
13360
13403
  if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
@@ -13400,10 +13443,20 @@ class InteropBroker extends Base {
13400
13443
  * @param joinContextGroupOptions - Id of the Context Group and identity of the entity to join to the group.
13401
13444
  * @param senderIdentity - Identity of the client sender.
13402
13445
  */
13403
- async joinContextGroup({ contextGroupId, target }, senderIdentity) {
13446
+ async joinContextGroup({ contextGroupId: requestedContextGroupId, target }, senderIdentity) {
13404
13447
  this.wire.sendAction('interop-broker-join-context-group').catch((e) => {
13405
13448
  // don't expose, analytics-only call
13406
13449
  });
13450
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13451
+ if (contextGroupId === undefined) {
13452
+ if (target) {
13453
+ await this.removeFromContextGroup({ target }, senderIdentity);
13454
+ }
13455
+ else {
13456
+ await this.removeClientFromContextGroup(senderIdentity);
13457
+ }
13458
+ return;
13459
+ }
13407
13460
  if (this.sessionContextGroupMap.has(contextGroupId)) {
13408
13461
  throw new Error(BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);
13409
13462
  }
@@ -13445,10 +13498,15 @@ class InteropBroker extends Base {
13445
13498
  * @param addClientToContextGroupOptions - Contains the contextGroupId
13446
13499
  * @param clientIdentity - Identity of the client sender.
13447
13500
  */
13448
- async addClientToContextGroup({ contextGroupId }, clientIdentity) {
13501
+ async addClientToContextGroup({ contextGroupId: requestedContextGroupId }, clientIdentity) {
13449
13502
  this.wire.sendAction('interop-broker-add-client-to-context-group').catch((e) => {
13450
13503
  // don't expose, analytics-only call
13451
13504
  });
13505
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13506
+ if (contextGroupId === undefined) {
13507
+ await this.removeClientFromContextGroup(clientIdentity);
13508
+ return;
13509
+ }
13452
13510
  const clientSubscriptionState = this.getClientState(clientIdentity);
13453
13511
  if (!clientSubscriptionState) {
13454
13512
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
@@ -13547,6 +13605,9 @@ class InteropBroker extends Base {
13547
13605
  clientState.contextGroupId = undefined;
13548
13606
  }
13549
13607
  await this.setCurrentContextGroupInClientOptions(clientIdentity, null);
13608
+ if (previousContextGroupId === undefined) {
13609
+ return;
13610
+ }
13550
13611
  // All settled will suppress uncaught exceptions. We don't want to await this because it could
13551
13612
  // result in the operation hanging.
13552
13613
  Promise.allSettled(this.channel.publish('client-changed-context-group', {
@@ -13584,7 +13645,11 @@ class InteropBroker extends Base {
13584
13645
  this.wire.sendAction('interop-broker-get-info-for-context-group').catch((e) => {
13585
13646
  // don't expose, analytics-only call
13586
13647
  });
13587
- return this.getContextGroups().find((contextGroup) => contextGroup.id === contextGroupId);
13648
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13649
+ if (normalizedContextGroupId === undefined) {
13650
+ return undefined;
13651
+ }
13652
+ return this.getContextGroups().find((contextGroup) => contextGroup.id === normalizedContextGroupId);
13588
13653
  }
13589
13654
  // Used by platform windows to get all clients for a context group.
13590
13655
  /**
@@ -13600,8 +13665,12 @@ class InteropBroker extends Base {
13600
13665
  this.wire.sendAction('interop-broker-get-all-clients-in-context-group').catch((e) => {
13601
13666
  // don't expose, analytics-only call
13602
13667
  });
13668
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13669
+ if (normalizedContextGroupId === undefined) {
13670
+ return [];
13671
+ }
13603
13672
  const clientsInContextGroup = Array.from(this.interopClients.values())
13604
- .filter((connectedClient) => connectedClient.contextGroupId === contextGroupId)
13673
+ .filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId)
13605
13674
  .map((subscriptionState) => {
13606
13675
  return subscriptionState.clientIdentity;
13607
13676
  });
@@ -14048,8 +14117,9 @@ class InteropBroker extends Base {
14048
14117
  }
14049
14118
  // Used to restore interop broker state in snapshots.
14050
14119
  applySnapshot(snapshot, options) {
14051
- const contextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
14052
- if (contextGroupStates) {
14120
+ const incomingContextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
14121
+ if (incomingContextGroupStates) {
14122
+ const contextGroupStates = this.normalizeContextGroupStates(incomingContextGroupStates);
14053
14123
  if (!options?.closeExistingWindows) {
14054
14124
  this.updateExistingClients(contextGroupStates);
14055
14125
  }
@@ -14194,6 +14264,23 @@ class InteropBroker extends Base {
14194
14264
  });
14195
14265
  return newObject;
14196
14266
  }
14267
+ normalizeContextGroupStates(incomingContextGroupStates) {
14268
+ const normalizedContextGroupStates = {};
14269
+ for (const [contextGroupId, contexts] of Object.entries(incomingContextGroupStates)) {
14270
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
14271
+ if (normalizedContextGroupId !== undefined) {
14272
+ normalizedContextGroupStates[normalizedContextGroupId] = {
14273
+ ...normalizedContextGroupStates[normalizedContextGroupId],
14274
+ ...contexts
14275
+ };
14276
+ }
14277
+ }
14278
+ return normalizedContextGroupStates;
14279
+ }
14280
+ normalizeContextGroupId(contextGroupId) {
14281
+ const usesDefaultColorChannels = Object.keys(defaultColorChannels).every((defaultContextGroupId) => this.contextGroupsById.has(defaultContextGroupId));
14282
+ return usesDefaultColorChannels ? normalizeColorChannelId(contextGroupId) : contextGroupId;
14283
+ }
14197
14284
  // Util to check a client identity.
14198
14285
  static hasEndpointId(target) {
14199
14286
  return target.endpointId !== undefined;
@@ -14257,8 +14344,14 @@ class InteropBroker extends Base {
14257
14344
  clientIdentity
14258
14345
  };
14259
14346
  // Only allow the client to join a contextGroup that actually exists.
14260
- if (payload?.currentContextGroup && this.contextGroupsById.has(payload.currentContextGroup)) {
14261
- clientSubscriptionState.contextGroupId = payload?.currentContextGroup;
14347
+ const currentContextGroup = payload?.currentContextGroup
14348
+ ? this.normalizeContextGroupId(payload.currentContextGroup)
14349
+ : undefined;
14350
+ if (currentContextGroup && this.contextGroupsById.has(currentContextGroup)) {
14351
+ clientSubscriptionState.contextGroupId = currentContextGroup;
14352
+ if (currentContextGroup !== payload.currentContextGroup) {
14353
+ await this.setCurrentContextGroupInClientOptions(clientIdentity, currentContextGroup);
14354
+ }
14262
14355
  }
14263
14356
  this.interopClients.set(clientIdentity.endpointId, clientSubscriptionState);
14264
14357
  });
@@ -14828,7 +14921,7 @@ class InteropClient extends Base {
14828
14921
  *
14829
14922
  * getLastFocusedView()
14830
14923
  * .then(lastFocusedViewIdentity => {
14831
- * joinViewToContextGroup('red', lastFocusedViewIdentity)
14924
+ * joinViewToContextGroup('fdc3.channel.1', lastFocusedViewIdentity)
14832
14925
  * })
14833
14926
  * ```
14834
14927
  */
@@ -14878,7 +14971,7 @@ class InteropClient extends Base {
14878
14971
  *
14879
14972
  * @example
14880
14973
  * ```js
14881
- * fin.me.interop.getAllClientsInContextGroup('red')
14974
+ * fin.me.interop.getAllClientsInContextGroup('fdc3.channel.1')
14882
14975
  * .then(clientsInContextGroup => {
14883
14976
  * console.log(clientsInContextGroup)
14884
14977
  * })
@@ -14902,7 +14995,7 @@ class InteropClient extends Base {
14902
14995
  *
14903
14996
  * @example
14904
14997
  * ```js
14905
- * fin.me.interop.getInfoForContextGroup('red')
14998
+ * fin.me.interop.getInfoForContextGroup('fdc3.channel.1')
14906
14999
  * .then(contextGroupInfo => {
14907
15000
  * console.log(contextGroupInfo.displayMetadata.name)
14908
15001
  * console.log(contextGroupInfo.displayMetadata.color)
@@ -14991,12 +15084,12 @@ class InteropClient extends Base {
14991
15084
  *
14992
15085
  * @example
14993
15086
  * ```js
14994
- * await fin.me.interop.joinContextGroup('yellow');
15087
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
14995
15088
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
14996
15089
  * const currentContext = await fin.me.interop.getCurrentContext();
14997
15090
  *
14998
15091
  * // with a specific context
14999
- * await fin.me.interop.joinContextGroup('yellow');
15092
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
15000
15093
  * await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
15001
15094
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
15002
15095
  * const currentContext = await fin.me.interop.getCurrentContext('country');
@@ -15658,15 +15751,18 @@ class FDC3ModuleBase {
15658
15751
  async joinChannel(channelId) {
15659
15752
  this.wire.recordAnalytic('fdc3-join-channel');
15660
15753
  try {
15754
+ const contextGroup = await this.client.getInfoForContextGroup(channelId);
15755
+ if (!contextGroup) {
15756
+ console.error(`No User Channel was found with the ID "${channelId}". If this is an App Channel, use getOrCreateChannel instead.`);
15757
+ throw new Error(ChannelError.NoChannelFound);
15758
+ }
15661
15759
  return await this.client.joinContextGroup(channelId);
15662
15760
  }
15663
15761
  catch (error) {
15664
- if (error.message === BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
15665
- 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.');
15666
- }
15667
- else {
15668
- console.error(error.message);
15762
+ if (error.message === ChannelError.NoChannelFound) {
15763
+ throw new Error(ChannelError.NoChannelFound);
15669
15764
  }
15765
+ console.error(error.message);
15670
15766
  if (error.message.startsWith('Attempting to join a context group that does not exist')) {
15671
15767
  throw new Error(ChannelError.NoChannelFound);
15672
15768
  }
@@ -16346,7 +16442,7 @@ class InteropModule extends Base {
16346
16442
  * @example
16347
16443
  * ```js
16348
16444
  * const interopConfig = {
16349
- * currentContextGroup: 'green'
16445
+ * currentContextGroup: 'fdc3.channel.4'
16350
16446
  * }
16351
16447
  *
16352
16448
  * const interopBroker = await fin.Interop.init('openfin');
@@ -17353,4 +17449,6 @@ const fin$1 = ((typeof window !== 'undefined' && window?.fin) ||
17353
17449
 
17354
17450
  exports.OpenFin = OpenFin;
17355
17451
  exports.default = OpenFin;
17452
+ exports.defaultColorChannels = defaultColorChannels;
17356
17453
  exports.fin = fin$1;
17454
+ exports.normalizeColorChannelId = normalizeColorChannelId;