@openfin/core 36.80.7 → 36.80.9

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.
@@ -7202,6 +7202,15 @@ declare class InteropBroker extends Base {
7202
7202
  setContext({ context }: {
7203
7203
  context: OpenFin_2.Context;
7204
7204
  }, clientIdentity: OpenFin_2.ClientIdentity): void;
7205
+ /**
7206
+ * Sets a context for the context group.
7207
+ * @param setContextOptions - New context to set.
7208
+ * @param contextGroupId - Context group id.
7209
+ *
7210
+ */
7211
+ setContextForGroup({ context }: {
7212
+ context: OpenFin_2.Context;
7213
+ }, contextGroupId: string): void;
7205
7214
  /**
7206
7215
  * Get current context for a client subscribed to a Context Group.
7207
7216
  *
@@ -12457,6 +12466,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12457
12466
  'interop-broker-remove-client-from-context-group': VoidCall;
12458
12467
  'interop-broker-remove-from-context-group': VoidCall;
12459
12468
  'interop-broker-set-context': VoidCall;
12469
+ 'interop-broker-set-context-for-group': VoidCall;
12460
12470
  'query-permission-for-current-context': {
12461
12471
  request: {
12462
12472
  apiName: string;
@@ -17450,7 +17460,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17450
17460
  */
17451
17461
  declare class _Window extends WebContents<OpenFin_2.WindowEvent> {
17452
17462
  /* Excluded from this release type: __constructor */
17453
- /* Excluded from this release type: createWindow */
17463
+ createWindow(options: OpenFin_2.WindowCreationOptions): Promise<OpenFin_2.Window>;
17454
17464
  /**
17455
17465
  * Retrieves an array of frame info objects representing the main frame and any
17456
17466
  * iframes that are currently on the page.
@@ -7202,6 +7202,15 @@ declare class InteropBroker extends Base {
7202
7202
  setContext({ context }: {
7203
7203
  context: OpenFin_2.Context;
7204
7204
  }, clientIdentity: OpenFin_2.ClientIdentity): void;
7205
+ /**
7206
+ * Sets a context for the context group.
7207
+ * @param setContextOptions - New context to set.
7208
+ * @param contextGroupId - Context group id.
7209
+ *
7210
+ */
7211
+ setContextForGroup({ context }: {
7212
+ context: OpenFin_2.Context;
7213
+ }, contextGroupId: string): void;
7205
7214
  /**
7206
7215
  * Get current context for a client subscribed to a Context Group.
7207
7216
  *
@@ -12457,6 +12466,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12457
12466
  'interop-broker-remove-client-from-context-group': VoidCall;
12458
12467
  'interop-broker-remove-from-context-group': VoidCall;
12459
12468
  'interop-broker-set-context': VoidCall;
12469
+ 'interop-broker-set-context-for-group': VoidCall;
12460
12470
  'query-permission-for-current-context': {
12461
12471
  request: {
12462
12472
  apiName: string;
@@ -17450,7 +17460,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17450
17460
  */
17451
17461
  declare class _Window extends WebContents<OpenFin_2.WindowEvent> {
17452
17462
  /* Excluded from this release type: __constructor */
17453
- /* Excluded from this release type: createWindow */
17463
+ createWindow(options: OpenFin_2.WindowCreationOptions): Promise<OpenFin_2.Window>;
17454
17464
  /**
17455
17465
  * Retrieves an array of frame info objects representing the main frame and any
17456
17466
  * iframes that are currently on the page.
@@ -7202,6 +7202,15 @@ declare class InteropBroker extends Base {
7202
7202
  setContext({ context }: {
7203
7203
  context: OpenFin_2.Context;
7204
7204
  }, clientIdentity: OpenFin_2.ClientIdentity): void;
7205
+ /**
7206
+ * Sets a context for the context group.
7207
+ * @param setContextOptions - New context to set.
7208
+ * @param contextGroupId - Context group id.
7209
+ *
7210
+ */
7211
+ setContextForGroup({ context }: {
7212
+ context: OpenFin_2.Context;
7213
+ }, contextGroupId: string): void;
7205
7214
  /**
7206
7215
  * Get current context for a client subscribed to a Context Group.
7207
7216
  *
@@ -12457,6 +12466,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12457
12466
  'interop-broker-remove-client-from-context-group': VoidCall;
12458
12467
  'interop-broker-remove-from-context-group': VoidCall;
12459
12468
  'interop-broker-set-context': VoidCall;
12469
+ 'interop-broker-set-context-for-group': VoidCall;
12460
12470
  'query-permission-for-current-context': {
12461
12471
  request: {
12462
12472
  apiName: string;
@@ -17450,7 +17460,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17450
17460
  */
17451
17461
  declare class _Window extends WebContents<OpenFin_2.WindowEvent> {
17452
17462
  /* Excluded from this release type: __constructor */
17453
- /* Excluded from this release type: createWindow */
17463
+ createWindow(options: OpenFin_2.WindowCreationOptions): Promise<OpenFin_2.Window>;
17454
17464
  /**
17455
17465
  * Retrieves an array of frame info objects representing the main frame and any
17456
17466
  * iframes that are currently on the page.
package/out/mock.d.ts CHANGED
@@ -7307,6 +7307,15 @@ declare class InteropBroker extends Base {
7307
7307
  setContext({ context }: {
7308
7308
  context: OpenFin_2.Context;
7309
7309
  }, clientIdentity: OpenFin_2.ClientIdentity): void;
7310
+ /**
7311
+ * Sets a context for the context group.
7312
+ * @param setContextOptions - New context to set.
7313
+ * @param contextGroupId - Context group id.
7314
+ *
7315
+ */
7316
+ setContextForGroup({ context }: {
7317
+ context: OpenFin_2.Context;
7318
+ }, contextGroupId: string): void;
7310
7319
  /**
7311
7320
  * Get current context for a client subscribed to a Context Group.
7312
7321
  *
@@ -12846,6 +12855,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12846
12855
  'interop-broker-remove-client-from-context-group': VoidCall;
12847
12856
  'interop-broker-remove-from-context-group': VoidCall;
12848
12857
  'interop-broker-set-context': VoidCall;
12858
+ 'interop-broker-set-context-for-group': VoidCall;
12849
12859
  'query-permission-for-current-context': {
12850
12860
  request: {
12851
12861
  apiName: string;
@@ -17892,10 +17902,6 @@ declare class _Window extends WebContents<OpenFin_2.WindowEvent> {
17892
17902
  * @internal
17893
17903
  */
17894
17904
  constructor(wire: Transport, identity: OpenFin_2.Identity);
17895
- /**
17896
- * create a new window
17897
- * @internal
17898
- */
17899
17905
  createWindow(options: OpenFin_2.WindowCreationOptions): Promise<OpenFin_2.Window>;
17900
17906
  /**
17901
17907
  * Retrieves an array of frame info objects representing the main frame and any
package/out/mock.js CHANGED
@@ -4349,6 +4349,37 @@ function requireApplication () {
4349
4349
  return application;
4350
4350
  }
4351
4351
 
4352
+ var promisifySubscription$1 = {};
4353
+
4354
+ Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
4355
+ promisifySubscription$1.promisifySubscription = void 0;
4356
+ const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
4357
+ let resolve;
4358
+ let reject;
4359
+ let timer;
4360
+ const valuePromise = new Promise((y, n) => {
4361
+ resolve = y;
4362
+ reject = n;
4363
+ });
4364
+ const listener = (e) => {
4365
+ if (predicate(e)) {
4366
+ clearTimeout(timer);
4367
+ resolve(e);
4368
+ }
4369
+ };
4370
+ await emitter.on(eventName, listener);
4371
+ if (timeout) {
4372
+ timer = setTimeout(() => reject(new Error('event timed out')), timeout);
4373
+ }
4374
+ valuePromise.finally(() => {
4375
+ emitter.removeListener(eventName, listener).catch(() => null);
4376
+ });
4377
+ return {
4378
+ getValue: () => valuePromise
4379
+ };
4380
+ };
4381
+ promisifySubscription$1.promisifySubscription = promisifySubscription;
4382
+
4352
4383
  var hasRequiredInstance;
4353
4384
 
4354
4385
  function requireInstance () {
@@ -4364,6 +4395,7 @@ function requireInstance () {
4364
4395
  const main_1 = main;
4365
4396
  const view_1 = requireView();
4366
4397
  const warnings_1 = warnings;
4398
+ const promisifySubscription_1 = promisifySubscription$1;
4367
4399
  /**
4368
4400
  * A basic window that wraps a native HTML window. Provides more fine-grained
4369
4401
  * control over the window state such as the ability to minimize, maximize, restore, etc.
@@ -4379,79 +4411,60 @@ function requireInstance () {
4379
4411
  constructor(wire, identity) {
4380
4412
  super(wire, identity, 'window');
4381
4413
  }
4382
- /**
4383
- * create a new window
4384
- * @internal
4385
- */
4386
- createWindow(options) {
4414
+ async createWindow(options) {
4387
4415
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
4388
4416
  // we do not want to expose this error, just continue if this analytics-only call fails
4389
4417
  });
4390
- return new Promise((resolve, reject) => {
4391
- const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
4392
- // need to call pageResponse, otherwise when a child window is created, page is not loaded
4393
- const pageResponse = new Promise((resolve) => {
4394
- // TODO: fix typing (internal)
4395
- // @ts-expect-error
4396
- this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
4397
- let cbPayload;
4398
- const { success } = response;
4399
- const responseData = response.data;
4400
- const { message } = responseData;
4401
- if (success) {
4402
- cbPayload = {
4403
- httpResponseCode: responseData.httpResponseCode,
4404
- apiInjected: responseData.apiInjected
4405
- };
4406
- }
4407
- else {
4408
- cbPayload = {
4409
- message: responseData.message,
4410
- networkErrorCode: responseData.networkErrorCode,
4411
- stack: responseData.stack
4412
- };
4413
- }
4414
- this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
4415
- resolve({
4416
- message,
4417
- cbPayload,
4418
- success
4419
- });
4420
- });
4421
- });
4422
- // set defaults:
4423
- if (options.waitForPageLoad === undefined) {
4424
- options.waitForPageLoad = false;
4425
- }
4426
- if (options.autoShow === undefined) {
4427
- options.autoShow = true;
4428
- }
4429
- (0, warnings_1.handleDeprecatedWarnings)(options);
4430
- const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
4431
- Promise.all([pageResponse, windowCreation])
4432
- .then((resolvedArr) => {
4433
- const pageResolve = resolvedArr[0];
4434
- if (pageResolve.success) {
4435
- resolve(this);
4436
- }
4437
- else {
4438
- reject(pageResolve);
4439
- }
4440
- try {
4441
- // this is to enforce a 5.0 contract that the child's main function
4442
- // will not fire before the parent's success callback on creation.
4443
- // if the child window is not accessible (CORS) this contract does
4444
- // not hold.
4445
- const webWindow = this.getWebWindow();
4446
- webWindow.fin.__internal_.openerSuccessCBCalled();
4447
- }
4448
- catch (e) {
4449
- // common for main windows, we do not want to expose this error. here just to have a debug target.
4450
- // console.error(e);
4451
- }
4452
- })
4453
- .catch(reject);
4454
- });
4418
+ const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
4419
+ const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
4420
+ // set defaults:
4421
+ if (options.waitForPageLoad === undefined) {
4422
+ options.waitForPageLoad = false;
4423
+ }
4424
+ if (options.autoShow === undefined) {
4425
+ options.autoShow = true;
4426
+ }
4427
+ (0, warnings_1.handleDeprecatedWarnings)(options);
4428
+ const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
4429
+ const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
4430
+ let cbPayload;
4431
+ const { success } = response;
4432
+ const responseData = response.data;
4433
+ const { message } = responseData;
4434
+ if (success) {
4435
+ cbPayload = {
4436
+ httpResponseCode: responseData.httpResponseCode,
4437
+ apiInjected: responseData.apiInjected
4438
+ };
4439
+ }
4440
+ else {
4441
+ cbPayload = {
4442
+ message: responseData.message,
4443
+ networkErrorCode: responseData.networkErrorCode,
4444
+ stack: responseData.stack
4445
+ };
4446
+ }
4447
+ const pageResolve = {
4448
+ message,
4449
+ cbPayload,
4450
+ success
4451
+ };
4452
+ try {
4453
+ // this is to enforce a 5.0 contract that the child's main function
4454
+ // will not fire before the parent's success callback on creation.
4455
+ // if the child window is not accessible (CORS) this contract does
4456
+ // not hold.
4457
+ const webWindow = this.getWebWindow();
4458
+ webWindow.fin.__internal_.openerSuccessCBCalled();
4459
+ }
4460
+ catch (e) {
4461
+ // common for main windows, we do not want to expose this error. here just to have a debug target.
4462
+ // console.error(e);
4463
+ }
4464
+ if (pageResolve.success) {
4465
+ return this;
4466
+ }
4467
+ return Promise.reject(pageResolve);
4455
4468
  }
4456
4469
  /**
4457
4470
  * Retrieves an array of frame info objects representing the main frame and any
@@ -13392,27 +13405,7 @@ function requireInteropBroker () {
13392
13405
  const clientState = this.getClientState(clientIdentity);
13393
13406
  if (clientState && clientState.contextGroupId) {
13394
13407
  const { contextGroupId } = clientState;
13395
- if (!this.contextGroupsById.has(contextGroupId)) {
13396
- // Theoretically not possible.
13397
- throw new Error(`Client has a context group that isn't in the context group mapping: ${contextGroupId}.`);
13398
- }
13399
- const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13400
- if (contextIntegrityCheckResult.isValid === false) {
13401
- throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
13402
- }
13403
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13404
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
13405
- const broadcastedContextType = context.type;
13406
- contextGroupState.set(broadcastedContextType, context);
13407
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
13408
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13409
- clientsInSameContextGroup.forEach((client) => {
13410
- for (const [, handlerInfo] of client.contextHandlers) {
13411
- if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
13412
- this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
13413
- }
13414
- }
13415
- });
13408
+ this.setContextForGroup({ context }, contextGroupId);
13416
13409
  }
13417
13410
  else if (clientState) {
13418
13411
  // Client has not joined any context group behavior.
@@ -13423,6 +13416,36 @@ function requireInteropBroker () {
13423
13416
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
13424
13417
  }
13425
13418
  }
13419
+ /**
13420
+ * Sets a context for the context group.
13421
+ * @param setContextOptions - New context to set.
13422
+ * @param contextGroupId - Context group id.
13423
+ *
13424
+ */
13425
+ setContextForGroup({ context }, contextGroupId) {
13426
+ this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
13427
+ // don't expose, analytics-only call
13428
+ });
13429
+ const contextGroupState = this.contextGroupsById.get(contextGroupId);
13430
+ if (!contextGroupState) {
13431
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
13432
+ }
13433
+ const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13434
+ if (contextIntegrityCheckResult.isValid === false) {
13435
+ throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
13436
+ }
13437
+ const broadcastedContextType = context.type;
13438
+ contextGroupState.set(broadcastedContextType, context);
13439
+ this.lastContextMap.set(contextGroupId, broadcastedContextType);
13440
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13441
+ clientsInSameContextGroup.forEach((client) => {
13442
+ for (const [, handlerInfo] of client.contextHandlers) {
13443
+ if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
13444
+ this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
13445
+ }
13446
+ }
13447
+ });
13448
+ }
13426
13449
  /**
13427
13450
  * Get current context for a client subscribed to a Context Group.
13428
13451
  *
@@ -16027,7 +16050,7 @@ class MockEnvironment {
16027
16050
  throw new Error(me_1.environmentUnsupportedMessage);
16028
16051
  }
16029
16052
  getNextMessageId() {
16030
- throw new Error(me_1.environmentUnsupportedMessage);
16053
+ return `mock-message-id-${Math.random()}`;
16031
16054
  }
16032
16055
  getRandomId() {
16033
16056
  throw new Error(me_1.environmentUnsupportedMessage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "36.80.7",
3
+ "version": "36.80.9",
4
4
  "description": "The core renderer entry point of OpenFin",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "out/mock.js",