@openfin/remote-adapter 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.
@@ -7245,6 +7245,15 @@ declare class InteropBroker extends Base {
7245
7245
  setContext({ context }: {
7246
7246
  context: OpenFin.Context;
7247
7247
  }, clientIdentity: OpenFin.ClientIdentity): void;
7248
+ /**
7249
+ * Sets a context for the context group.
7250
+ * @param setContextOptions - New context to set.
7251
+ * @param contextGroupId - Context group id.
7252
+ *
7253
+ */
7254
+ setContextForGroup({ context }: {
7255
+ context: OpenFin.Context;
7256
+ }, contextGroupId: string): void;
7248
7257
  /**
7249
7258
  * Get current context for a client subscribed to a Context Group.
7250
7259
  *
@@ -12499,6 +12508,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12499
12508
  'interop-broker-remove-client-from-context-group': VoidCall;
12500
12509
  'interop-broker-remove-from-context-group': VoidCall;
12501
12510
  'interop-broker-set-context': VoidCall;
12511
+ 'interop-broker-set-context-for-group': VoidCall;
12502
12512
  'query-permission-for-current-context': {
12503
12513
  request: {
12504
12514
  apiName: string;
@@ -17492,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17492
17502
  */
17493
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17494
17504
  /* Excluded from this release type: __constructor */
17495
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17496
17506
  /**
17497
17507
  * Retrieves an array of frame info objects representing the main frame and any
17498
17508
  * iframes that are currently on the page.
@@ -7245,6 +7245,15 @@ declare class InteropBroker extends Base {
7245
7245
  setContext({ context }: {
7246
7246
  context: OpenFin.Context;
7247
7247
  }, clientIdentity: OpenFin.ClientIdentity): void;
7248
+ /**
7249
+ * Sets a context for the context group.
7250
+ * @param setContextOptions - New context to set.
7251
+ * @param contextGroupId - Context group id.
7252
+ *
7253
+ */
7254
+ setContextForGroup({ context }: {
7255
+ context: OpenFin.Context;
7256
+ }, contextGroupId: string): void;
7248
7257
  /**
7249
7258
  * Get current context for a client subscribed to a Context Group.
7250
7259
  *
@@ -12499,6 +12508,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12499
12508
  'interop-broker-remove-client-from-context-group': VoidCall;
12500
12509
  'interop-broker-remove-from-context-group': VoidCall;
12501
12510
  'interop-broker-set-context': VoidCall;
12511
+ 'interop-broker-set-context-for-group': VoidCall;
12502
12512
  'query-permission-for-current-context': {
12503
12513
  request: {
12504
12514
  apiName: string;
@@ -17492,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17492
17502
  */
17493
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17494
17504
  /* Excluded from this release type: __constructor */
17495
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17496
17506
  /**
17497
17507
  * Retrieves an array of frame info objects representing the main frame and any
17498
17508
  * iframes that are currently on the page.
@@ -7245,6 +7245,15 @@ declare class InteropBroker extends Base {
7245
7245
  setContext({ context }: {
7246
7246
  context: OpenFin.Context;
7247
7247
  }, clientIdentity: OpenFin.ClientIdentity): void;
7248
+ /**
7249
+ * Sets a context for the context group.
7250
+ * @param setContextOptions - New context to set.
7251
+ * @param contextGroupId - Context group id.
7252
+ *
7253
+ */
7254
+ setContextForGroup({ context }: {
7255
+ context: OpenFin.Context;
7256
+ }, contextGroupId: string): void;
7248
7257
  /**
7249
7258
  * Get current context for a client subscribed to a Context Group.
7250
7259
  *
@@ -12499,6 +12508,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12499
12508
  'interop-broker-remove-client-from-context-group': VoidCall;
12500
12509
  'interop-broker-remove-from-context-group': VoidCall;
12501
12510
  'interop-broker-set-context': VoidCall;
12511
+ 'interop-broker-set-context-for-group': VoidCall;
12502
12512
  'query-permission-for-current-context': {
12503
12513
  request: {
12504
12514
  apiName: string;
@@ -17492,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17492
17502
  */
17493
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17494
17504
  /* Excluded from this release type: __constructor */
17495
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17496
17506
  /**
17497
17507
  * Retrieves an array of frame info objects representing the main frame and any
17498
17508
  * iframes that are currently on the page.
@@ -7350,6 +7350,15 @@ declare class InteropBroker extends Base {
7350
7350
  setContext({ context }: {
7351
7351
  context: OpenFin.Context;
7352
7352
  }, clientIdentity: OpenFin.ClientIdentity): void;
7353
+ /**
7354
+ * Sets a context for the context group.
7355
+ * @param setContextOptions - New context to set.
7356
+ * @param contextGroupId - Context group id.
7357
+ *
7358
+ */
7359
+ setContextForGroup({ context }: {
7360
+ context: OpenFin.Context;
7361
+ }, contextGroupId: string): void;
7353
7362
  /**
7354
7363
  * Get current context for a client subscribed to a Context Group.
7355
7364
  *
@@ -12888,6 +12897,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12888
12897
  'interop-broker-remove-client-from-context-group': VoidCall;
12889
12898
  'interop-broker-remove-from-context-group': VoidCall;
12890
12899
  'interop-broker-set-context': VoidCall;
12900
+ 'interop-broker-set-context-for-group': VoidCall;
12891
12901
  'query-permission-for-current-context': {
12892
12902
  request: {
12893
12903
  apiName: string;
@@ -17934,10 +17944,6 @@ declare class _Window extends WebContents<OpenFin.WindowEvent> {
17934
17944
  * @internal
17935
17945
  */
17936
17946
  constructor(wire: Transport, identity: OpenFin.Identity);
17937
- /**
17938
- * create a new window
17939
- * @internal
17940
- */
17941
17947
  createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17942
17948
  /**
17943
17949
  * Retrieves an array of frame info objects representing the main frame and any
@@ -1920,27 +1920,7 @@ function requireInteropBroker () {
1920
1920
  const clientState = this.getClientState(clientIdentity);
1921
1921
  if (clientState && clientState.contextGroupId) {
1922
1922
  const { contextGroupId } = clientState;
1923
- if (!this.contextGroupsById.has(contextGroupId)) {
1924
- // Theoretically not possible.
1925
- throw new Error(`Client has a context group that isn't in the context group mapping: ${contextGroupId}.`);
1926
- }
1927
- const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
1928
- if (contextIntegrityCheckResult.isValid === false) {
1929
- throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
1930
- }
1931
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1932
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
1933
- const broadcastedContextType = context.type;
1934
- contextGroupState.set(broadcastedContextType, context);
1935
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
1936
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
1937
- clientsInSameContextGroup.forEach((client) => {
1938
- for (const [, handlerInfo] of client.contextHandlers) {
1939
- if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
1940
- this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
1941
- }
1942
- }
1943
- });
1923
+ this.setContextForGroup({ context }, contextGroupId);
1944
1924
  }
1945
1925
  else if (clientState) {
1946
1926
  // Client has not joined any context group behavior.
@@ -1951,6 +1931,36 @@ function requireInteropBroker () {
1951
1931
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
1952
1932
  }
1953
1933
  }
1934
+ /**
1935
+ * Sets a context for the context group.
1936
+ * @param setContextOptions - New context to set.
1937
+ * @param contextGroupId - Context group id.
1938
+ *
1939
+ */
1940
+ setContextForGroup({ context }, contextGroupId) {
1941
+ this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
1942
+ // don't expose, analytics-only call
1943
+ });
1944
+ const contextGroupState = this.contextGroupsById.get(contextGroupId);
1945
+ if (!contextGroupState) {
1946
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
1947
+ }
1948
+ const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
1949
+ if (contextIntegrityCheckResult.isValid === false) {
1950
+ throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
1951
+ }
1952
+ const broadcastedContextType = context.type;
1953
+ contextGroupState.set(broadcastedContextType, context);
1954
+ this.lastContextMap.set(contextGroupId, broadcastedContextType);
1955
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
1956
+ clientsInSameContextGroup.forEach((client) => {
1957
+ for (const [, handlerInfo] of client.contextHandlers) {
1958
+ if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
1959
+ this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
1960
+ }
1961
+ }
1962
+ });
1963
+ }
1954
1964
  /**
1955
1965
  * Get current context for a client subscribed to a Context Group.
1956
1966
  *
@@ -6404,6 +6414,37 @@ function requireApplication () {
6404
6414
  return application;
6405
6415
  }
6406
6416
 
6417
+ var promisifySubscription$1 = {};
6418
+
6419
+ Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
6420
+ promisifySubscription$1.promisifySubscription = void 0;
6421
+ const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
6422
+ let resolve;
6423
+ let reject;
6424
+ let timer;
6425
+ const valuePromise = new Promise((y, n) => {
6426
+ resolve = y;
6427
+ reject = n;
6428
+ });
6429
+ const listener = (e) => {
6430
+ if (predicate(e)) {
6431
+ clearTimeout(timer);
6432
+ resolve(e);
6433
+ }
6434
+ };
6435
+ await emitter.on(eventName, listener);
6436
+ if (timeout) {
6437
+ timer = setTimeout(() => reject(new Error('event timed out')), timeout);
6438
+ }
6439
+ valuePromise.finally(() => {
6440
+ emitter.removeListener(eventName, listener).catch(() => null);
6441
+ });
6442
+ return {
6443
+ getValue: () => valuePromise
6444
+ };
6445
+ };
6446
+ promisifySubscription$1.promisifySubscription = promisifySubscription;
6447
+
6407
6448
  var hasRequiredInstance$1;
6408
6449
 
6409
6450
  function requireInstance$1 () {
@@ -6419,6 +6460,7 @@ function requireInstance$1 () {
6419
6460
  const main_1 = main;
6420
6461
  const view_1 = requireView();
6421
6462
  const warnings_1 = warnings;
6463
+ const promisifySubscription_1 = promisifySubscription$1;
6422
6464
  /**
6423
6465
  * A basic window that wraps a native HTML window. Provides more fine-grained
6424
6466
  * control over the window state such as the ability to minimize, maximize, restore, etc.
@@ -6434,79 +6476,60 @@ function requireInstance$1 () {
6434
6476
  constructor(wire, identity) {
6435
6477
  super(wire, identity, 'window');
6436
6478
  }
6437
- /**
6438
- * create a new window
6439
- * @internal
6440
- */
6441
- createWindow(options) {
6479
+ async createWindow(options) {
6442
6480
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
6443
6481
  // we do not want to expose this error, just continue if this analytics-only call fails
6444
6482
  });
6445
- return new Promise((resolve, reject) => {
6446
- const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
6447
- // need to call pageResponse, otherwise when a child window is created, page is not loaded
6448
- const pageResponse = new Promise((resolve) => {
6449
- // TODO: fix typing (internal)
6450
- // @ts-expect-error
6451
- this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
6452
- let cbPayload;
6453
- const { success } = response;
6454
- const responseData = response.data;
6455
- const { message } = responseData;
6456
- if (success) {
6457
- cbPayload = {
6458
- httpResponseCode: responseData.httpResponseCode,
6459
- apiInjected: responseData.apiInjected
6460
- };
6461
- }
6462
- else {
6463
- cbPayload = {
6464
- message: responseData.message,
6465
- networkErrorCode: responseData.networkErrorCode,
6466
- stack: responseData.stack
6467
- };
6468
- }
6469
- this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
6470
- resolve({
6471
- message,
6472
- cbPayload,
6473
- success
6474
- });
6475
- });
6476
- });
6477
- // set defaults:
6478
- if (options.waitForPageLoad === undefined) {
6479
- options.waitForPageLoad = false;
6480
- }
6481
- if (options.autoShow === undefined) {
6482
- options.autoShow = true;
6483
- }
6484
- (0, warnings_1.handleDeprecatedWarnings)(options);
6485
- const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
6486
- Promise.all([pageResponse, windowCreation])
6487
- .then((resolvedArr) => {
6488
- const pageResolve = resolvedArr[0];
6489
- if (pageResolve.success) {
6490
- resolve(this);
6491
- }
6492
- else {
6493
- reject(pageResolve);
6494
- }
6495
- try {
6496
- // this is to enforce a 5.0 contract that the child's main function
6497
- // will not fire before the parent's success callback on creation.
6498
- // if the child window is not accessible (CORS) this contract does
6499
- // not hold.
6500
- const webWindow = this.getWebWindow();
6501
- webWindow.fin.__internal_.openerSuccessCBCalled();
6502
- }
6503
- catch (e) {
6504
- // common for main windows, we do not want to expose this error. here just to have a debug target.
6505
- // console.error(e);
6506
- }
6507
- })
6508
- .catch(reject);
6509
- });
6483
+ const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
6484
+ const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
6485
+ // set defaults:
6486
+ if (options.waitForPageLoad === undefined) {
6487
+ options.waitForPageLoad = false;
6488
+ }
6489
+ if (options.autoShow === undefined) {
6490
+ options.autoShow = true;
6491
+ }
6492
+ (0, warnings_1.handleDeprecatedWarnings)(options);
6493
+ const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
6494
+ const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
6495
+ let cbPayload;
6496
+ const { success } = response;
6497
+ const responseData = response.data;
6498
+ const { message } = responseData;
6499
+ if (success) {
6500
+ cbPayload = {
6501
+ httpResponseCode: responseData.httpResponseCode,
6502
+ apiInjected: responseData.apiInjected
6503
+ };
6504
+ }
6505
+ else {
6506
+ cbPayload = {
6507
+ message: responseData.message,
6508
+ networkErrorCode: responseData.networkErrorCode,
6509
+ stack: responseData.stack
6510
+ };
6511
+ }
6512
+ const pageResolve = {
6513
+ message,
6514
+ cbPayload,
6515
+ success
6516
+ };
6517
+ try {
6518
+ // this is to enforce a 5.0 contract that the child's main function
6519
+ // will not fire before the parent's success callback on creation.
6520
+ // if the child window is not accessible (CORS) this contract does
6521
+ // not hold.
6522
+ const webWindow = this.getWebWindow();
6523
+ webWindow.fin.__internal_.openerSuccessCBCalled();
6524
+ }
6525
+ catch (e) {
6526
+ // common for main windows, we do not want to expose this error. here just to have a debug target.
6527
+ // console.error(e);
6528
+ }
6529
+ if (pageResolve.success) {
6530
+ return this;
6531
+ }
6532
+ return Promise.reject(pageResolve);
6510
6533
  }
6511
6534
  /**
6512
6535
  * Retrieves an array of frame info objects representing the main frame and any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/remote-adapter",
3
- "version": "36.80.7",
3
+ "version": "36.80.9",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,