@openfin/remote-adapter 36.80.25 → 37.80.3

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.
@@ -1920,7 +1920,27 @@ function requireInteropBroker () {
1920
1920
  const clientState = this.getClientState(clientIdentity);
1921
1921
  if (clientState && clientState.contextGroupId) {
1922
1922
  const { contextGroupId } = clientState;
1923
- this.setContextForGroup({ context }, contextGroupId);
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
+ });
1924
1944
  }
1925
1945
  else if (clientState) {
1926
1946
  // Client has not joined any context group behavior.
@@ -1931,36 +1951,6 @@ function requireInteropBroker () {
1931
1951
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
1932
1952
  }
1933
1953
  }
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
- }
1964
1954
  /**
1965
1955
  * Get current context for a client subscribed to a Context Group.
1966
1956
  *
@@ -6414,37 +6404,6 @@ function requireApplication () {
6414
6404
  return application;
6415
6405
  }
6416
6406
 
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
-
6448
6407
  var hasRequiredInstance$1;
6449
6408
 
6450
6409
  function requireInstance$1 () {
@@ -6460,7 +6419,6 @@ function requireInstance$1 () {
6460
6419
  const main_1 = main;
6461
6420
  const view_1 = requireView();
6462
6421
  const warnings_1 = warnings;
6463
- const promisifySubscription_1 = promisifySubscription$1;
6464
6422
  /**
6465
6423
  * A basic window that wraps a native HTML window. Provides more fine-grained
6466
6424
  * control over the window state such as the ability to minimize, maximize, restore, etc.
@@ -6476,60 +6434,79 @@ function requireInstance$1 () {
6476
6434
  constructor(wire, identity) {
6477
6435
  super(wire, identity, 'window');
6478
6436
  }
6479
- async createWindow(options) {
6437
+ /**
6438
+ * create a new window
6439
+ * @internal
6440
+ */
6441
+ createWindow(options) {
6480
6442
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
6481
6443
  // we do not want to expose this error, just continue if this analytics-only call fails
6482
6444
  });
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);
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
+ });
6533
6510
  }
6534
6511
  /**
6535
6512
  * Retrieves an array of frame info objects representing the main frame and any
@@ -6926,7 +6903,7 @@ function requireInstance$1 () {
6926
6903
  // don't expose
6927
6904
  });
6928
6905
  const opts = await this.getOptions();
6929
- if (!opts.layout && !opts.layoutSnapshot) {
6906
+ if (!opts.layout || !opts.layoutSnapshot) {
6930
6907
  throw new Error('Window does not have a Layout');
6931
6908
  }
6932
6909
  return this.fin.Platform.Layout.wrap(layoutIdentity ?? this.identity);
@@ -8230,14 +8207,9 @@ function requireInstance () {
8230
8207
  // don't expose
8231
8208
  });
8232
8209
  const layoutWindow = await this.getCurrentWindow();
8233
- let layoutWindowIdentity = layoutWindow.identity;
8234
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
8235
- if (layoutWindowIdentity.identity) {
8236
- layoutWindowIdentity = layoutWindowIdentity.identity;
8237
- }
8238
8210
  try {
8239
8211
  const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
8240
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
8212
+ const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
8241
8213
  const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
8242
8214
  return this.fin.Platform.Layout.wrap(layoutIdentity);
8243
8215
  }
@@ -8250,7 +8222,7 @@ function requireInstance () {
8250
8222
  throw e;
8251
8223
  }
8252
8224
  // fallback logic for missing endpoint
8253
- return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
8225
+ return this.fin.Platform.Layout.wrap(layoutWindow.identity);
8254
8226
  }
8255
8227
  };
8256
8228
  /**
@@ -8558,8 +8530,6 @@ class _Frame extends base_1$h.EmitterBase {
8558
8530
  * Returns a frame info object representing the window that the referenced iframe is
8559
8531
  * currently embedded in.
8560
8532
  *
8561
- * @remarks If the frame is embedded in a view, this will return an invalid stub with empty fields.
8562
- *
8563
8533
  * @example
8564
8534
  * ```js
8565
8535
  * async function getParentWindow() {
@@ -14501,12 +14471,12 @@ class Platform extends base_1$5.EmitterBase {
14501
14471
  * @experimental
14502
14472
  */
14503
14473
  async launchContentManifest(manifestUrl) {
14504
- this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
14474
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch((e) => {
14505
14475
  // don't expose
14506
14476
  });
14507
14477
  const client = await this.getClient();
14508
14478
  const manifest = await this.fetchManifest(manifestUrl);
14509
- client.dispatch('launch-into-platform', { manifest, manifestUrl });
14479
+ client.dispatch('launch-into-platform', { manifest });
14510
14480
  return this;
14511
14481
  }
14512
14482
  /**
@@ -15149,7 +15119,7 @@ class LayoutModule extends base_1$3.Base {
15149
15119
  return this.wrapSync(this.fin.me.identity);
15150
15120
  };
15151
15121
  _LayoutModule_getLayoutManagerSpy.set(this, (layoutIdentity, layoutManager) => {
15152
- const msg = '[Layout] You are using a deprecated property `layoutManager` - it will throw if you access it starting in v37.';
15122
+ const msg = '[Layout] You are using a deprecated property `layoutManager` - it will be removed in v39.';
15153
15123
  const managerProxy = new Proxy(layoutManager, {
15154
15124
  get(target, key) {
15155
15125
  console.warn(`[Layout-mgr-proxy] accessing ${key.toString()}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/remote-adapter",
3
- "version": "36.80.25",
3
+ "version": "37.80.3",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,
@@ -20,7 +20,7 @@
20
20
  "@rollup/plugin-commonjs": "25.0.2",
21
21
  "@rollup/plugin-node-resolve": "15.1.0",
22
22
  "@rollup/plugin-typescript": "11.1.1",
23
- "@types/node": "^20.14.2",
23
+ "@types/node": "^20.9.0",
24
24
  "rollup": "3.24.1",
25
25
  "typescript": "4.9.5"
26
26
  },