@openfin/remote-adapter 36.80.8 → 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.
@@ -17502,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17502
17502
  */
17503
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17504
17504
  /* Excluded from this release type: __constructor */
17505
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17506
17506
  /**
17507
17507
  * Retrieves an array of frame info objects representing the main frame and any
17508
17508
  * iframes that are currently on the page.
@@ -17502,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17502
17502
  */
17503
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17504
17504
  /* Excluded from this release type: __constructor */
17505
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17506
17506
  /**
17507
17507
  * Retrieves an array of frame info objects representing the main frame and any
17508
17508
  * iframes that are currently on the page.
@@ -17502,7 +17502,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17502
17502
  */
17503
17503
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17504
17504
  /* Excluded from this release type: __constructor */
17505
- /* Excluded from this release type: createWindow */
17505
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17506
17506
  /**
17507
17507
  * Retrieves an array of frame info objects representing the main frame and any
17508
17508
  * iframes that are currently on the page.
@@ -17944,10 +17944,6 @@ declare class _Window extends WebContents<OpenFin.WindowEvent> {
17944
17944
  * @internal
17945
17945
  */
17946
17946
  constructor(wire: Transport, identity: OpenFin.Identity);
17947
- /**
17948
- * create a new window
17949
- * @internal
17950
- */
17951
17947
  createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17952
17948
  /**
17953
17949
  * Retrieves an array of frame info objects representing the main frame and any
@@ -6414,6 +6414,37 @@ function requireApplication () {
6414
6414
  return application;
6415
6415
  }
6416
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
+
6417
6448
  var hasRequiredInstance$1;
6418
6449
 
6419
6450
  function requireInstance$1 () {
@@ -6429,6 +6460,7 @@ function requireInstance$1 () {
6429
6460
  const main_1 = main;
6430
6461
  const view_1 = requireView();
6431
6462
  const warnings_1 = warnings;
6463
+ const promisifySubscription_1 = promisifySubscription$1;
6432
6464
  /**
6433
6465
  * A basic window that wraps a native HTML window. Provides more fine-grained
6434
6466
  * control over the window state such as the ability to minimize, maximize, restore, etc.
@@ -6444,79 +6476,60 @@ function requireInstance$1 () {
6444
6476
  constructor(wire, identity) {
6445
6477
  super(wire, identity, 'window');
6446
6478
  }
6447
- /**
6448
- * create a new window
6449
- * @internal
6450
- */
6451
- createWindow(options) {
6479
+ async createWindow(options) {
6452
6480
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
6453
6481
  // we do not want to expose this error, just continue if this analytics-only call fails
6454
6482
  });
6455
- return new Promise((resolve, reject) => {
6456
- const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
6457
- // need to call pageResponse, otherwise when a child window is created, page is not loaded
6458
- const pageResponse = new Promise((resolve) => {
6459
- // TODO: fix typing (internal)
6460
- // @ts-expect-error
6461
- this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
6462
- let cbPayload;
6463
- const { success } = response;
6464
- const responseData = response.data;
6465
- const { message } = responseData;
6466
- if (success) {
6467
- cbPayload = {
6468
- httpResponseCode: responseData.httpResponseCode,
6469
- apiInjected: responseData.apiInjected
6470
- };
6471
- }
6472
- else {
6473
- cbPayload = {
6474
- message: responseData.message,
6475
- networkErrorCode: responseData.networkErrorCode,
6476
- stack: responseData.stack
6477
- };
6478
- }
6479
- this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
6480
- resolve({
6481
- message,
6482
- cbPayload,
6483
- success
6484
- });
6485
- });
6486
- });
6487
- // set defaults:
6488
- if (options.waitForPageLoad === undefined) {
6489
- options.waitForPageLoad = false;
6490
- }
6491
- if (options.autoShow === undefined) {
6492
- options.autoShow = true;
6493
- }
6494
- (0, warnings_1.handleDeprecatedWarnings)(options);
6495
- const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
6496
- Promise.all([pageResponse, windowCreation])
6497
- .then((resolvedArr) => {
6498
- const pageResolve = resolvedArr[0];
6499
- if (pageResolve.success) {
6500
- resolve(this);
6501
- }
6502
- else {
6503
- reject(pageResolve);
6504
- }
6505
- try {
6506
- // this is to enforce a 5.0 contract that the child's main function
6507
- // will not fire before the parent's success callback on creation.
6508
- // if the child window is not accessible (CORS) this contract does
6509
- // not hold.
6510
- const webWindow = this.getWebWindow();
6511
- webWindow.fin.__internal_.openerSuccessCBCalled();
6512
- }
6513
- catch (e) {
6514
- // common for main windows, we do not want to expose this error. here just to have a debug target.
6515
- // console.error(e);
6516
- }
6517
- })
6518
- .catch(reject);
6519
- });
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);
6520
6533
  }
6521
6534
  /**
6522
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.8",
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,