@openfin/node-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.
@@ -7210,6 +7210,15 @@ declare class InteropBroker extends Base {
7210
7210
  setContext({ context }: {
7211
7211
  context: OpenFin.Context;
7212
7212
  }, clientIdentity: OpenFin.ClientIdentity): void;
7213
+ /**
7214
+ * Sets a context for the context group.
7215
+ * @param setContextOptions - New context to set.
7216
+ * @param contextGroupId - Context group id.
7217
+ *
7218
+ */
7219
+ setContextForGroup({ context }: {
7220
+ context: OpenFin.Context;
7221
+ }, contextGroupId: string): void;
7213
7222
  /**
7214
7223
  * Get current context for a client subscribed to a Context Group.
7215
7224
  *
@@ -12467,6 +12476,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12467
12476
  'interop-broker-remove-client-from-context-group': VoidCall;
12468
12477
  'interop-broker-remove-from-context-group': VoidCall;
12469
12478
  'interop-broker-set-context': VoidCall;
12479
+ 'interop-broker-set-context-for-group': VoidCall;
12470
12480
  'query-permission-for-current-context': {
12471
12481
  request: {
12472
12482
  apiName: string;
@@ -17460,7 +17470,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17460
17470
  */
17461
17471
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17462
17472
  /* Excluded from this release type: __constructor */
17463
- /* Excluded from this release type: createWindow */
17473
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17464
17474
  /**
17465
17475
  * Retrieves an array of frame info objects representing the main frame and any
17466
17476
  * iframes that are currently on the page.
@@ -7210,6 +7210,15 @@ declare class InteropBroker extends Base {
7210
7210
  setContext({ context }: {
7211
7211
  context: OpenFin.Context;
7212
7212
  }, clientIdentity: OpenFin.ClientIdentity): void;
7213
+ /**
7214
+ * Sets a context for the context group.
7215
+ * @param setContextOptions - New context to set.
7216
+ * @param contextGroupId - Context group id.
7217
+ *
7218
+ */
7219
+ setContextForGroup({ context }: {
7220
+ context: OpenFin.Context;
7221
+ }, contextGroupId: string): void;
7213
7222
  /**
7214
7223
  * Get current context for a client subscribed to a Context Group.
7215
7224
  *
@@ -12467,6 +12476,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12467
12476
  'interop-broker-remove-client-from-context-group': VoidCall;
12468
12477
  'interop-broker-remove-from-context-group': VoidCall;
12469
12478
  'interop-broker-set-context': VoidCall;
12479
+ 'interop-broker-set-context-for-group': VoidCall;
12470
12480
  'query-permission-for-current-context': {
12471
12481
  request: {
12472
12482
  apiName: string;
@@ -17460,7 +17470,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17460
17470
  */
17461
17471
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17462
17472
  /* Excluded from this release type: __constructor */
17463
- /* Excluded from this release type: createWindow */
17473
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17464
17474
  /**
17465
17475
  * Retrieves an array of frame info objects representing the main frame and any
17466
17476
  * iframes that are currently on the page.
@@ -7210,6 +7210,15 @@ declare class InteropBroker extends Base {
7210
7210
  setContext({ context }: {
7211
7211
  context: OpenFin.Context;
7212
7212
  }, clientIdentity: OpenFin.ClientIdentity): void;
7213
+ /**
7214
+ * Sets a context for the context group.
7215
+ * @param setContextOptions - New context to set.
7216
+ * @param contextGroupId - Context group id.
7217
+ *
7218
+ */
7219
+ setContextForGroup({ context }: {
7220
+ context: OpenFin.Context;
7221
+ }, contextGroupId: string): void;
7213
7222
  /**
7214
7223
  * Get current context for a client subscribed to a Context Group.
7215
7224
  *
@@ -12467,6 +12476,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12467
12476
  'interop-broker-remove-client-from-context-group': VoidCall;
12468
12477
  'interop-broker-remove-from-context-group': VoidCall;
12469
12478
  'interop-broker-set-context': VoidCall;
12479
+ 'interop-broker-set-context-for-group': VoidCall;
12470
12480
  'query-permission-for-current-context': {
12471
12481
  request: {
12472
12482
  apiName: string;
@@ -17460,7 +17470,7 @@ declare type WillResizeEvent = WillMoveOrResizeEvent & {
17460
17470
  */
17461
17471
  declare class _Window extends WebContents<OpenFin.WindowEvent> {
17462
17472
  /* Excluded from this release type: __constructor */
17463
- /* Excluded from this release type: createWindow */
17473
+ createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17464
17474
  /**
17465
17475
  * Retrieves an array of frame info objects representing the main frame and any
17466
17476
  * iframes that are currently on the page.
@@ -7337,6 +7337,15 @@ declare class InteropBroker extends Base {
7337
7337
  setContext({ context }: {
7338
7338
  context: OpenFin.Context;
7339
7339
  }, clientIdentity: OpenFin.ClientIdentity): void;
7340
+ /**
7341
+ * Sets a context for the context group.
7342
+ * @param setContextOptions - New context to set.
7343
+ * @param contextGroupId - Context group id.
7344
+ *
7345
+ */
7346
+ setContextForGroup({ context }: {
7347
+ context: OpenFin.Context;
7348
+ }, contextGroupId: string): void;
7340
7349
  /**
7341
7350
  * Get current context for a client subscribed to a Context Group.
7342
7351
  *
@@ -12878,6 +12887,7 @@ declare interface ProtocolMap extends ProtocolMapBase {
12878
12887
  'interop-broker-remove-client-from-context-group': VoidCall;
12879
12888
  'interop-broker-remove-from-context-group': VoidCall;
12880
12889
  'interop-broker-set-context': VoidCall;
12890
+ 'interop-broker-set-context-for-group': VoidCall;
12881
12891
  'query-permission-for-current-context': {
12882
12892
  request: {
12883
12893
  apiName: string;
@@ -17924,10 +17934,6 @@ declare class _Window extends WebContents<OpenFin.WindowEvent> {
17924
17934
  * @internal
17925
17935
  */
17926
17936
  constructor(wire: Transport, identity: OpenFin.Identity);
17927
- /**
17928
- * create a new window
17929
- * @internal
17930
- */
17931
17937
  createWindow(options: OpenFin.WindowCreationOptions): Promise<OpenFin.Window>;
17932
17938
  /**
17933
17939
  * Retrieves an array of frame info objects representing the main frame and any
@@ -4122,6 +4122,37 @@ function requireApplication () {
4122
4122
  return application$1;
4123
4123
  }
4124
4124
 
4125
+ var promisifySubscription$1 = {};
4126
+
4127
+ Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
4128
+ promisifySubscription$1.promisifySubscription = void 0;
4129
+ const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
4130
+ let resolve;
4131
+ let reject;
4132
+ let timer;
4133
+ const valuePromise = new Promise((y, n) => {
4134
+ resolve = y;
4135
+ reject = n;
4136
+ });
4137
+ const listener = (e) => {
4138
+ if (predicate(e)) {
4139
+ clearTimeout(timer);
4140
+ resolve(e);
4141
+ }
4142
+ };
4143
+ await emitter.on(eventName, listener);
4144
+ if (timeout) {
4145
+ timer = setTimeout(() => reject(new Error('event timed out')), timeout);
4146
+ }
4147
+ valuePromise.finally(() => {
4148
+ emitter.removeListener(eventName, listener).catch(() => null);
4149
+ });
4150
+ return {
4151
+ getValue: () => valuePromise
4152
+ };
4153
+ };
4154
+ promisifySubscription$1.promisifySubscription = promisifySubscription;
4155
+
4125
4156
  var hasRequiredInstance;
4126
4157
 
4127
4158
  function requireInstance () {
@@ -4137,6 +4168,7 @@ function requireInstance () {
4137
4168
  const main_1 = main;
4138
4169
  const view_1 = requireView();
4139
4170
  const warnings_1 = warnings;
4171
+ const promisifySubscription_1 = promisifySubscription$1;
4140
4172
  /**
4141
4173
  * A basic window that wraps a native HTML window. Provides more fine-grained
4142
4174
  * control over the window state such as the ability to minimize, maximize, restore, etc.
@@ -4152,79 +4184,60 @@ function requireInstance () {
4152
4184
  constructor(wire, identity) {
4153
4185
  super(wire, identity, 'window');
4154
4186
  }
4155
- /**
4156
- * create a new window
4157
- * @internal
4158
- */
4159
- createWindow(options) {
4187
+ async createWindow(options) {
4160
4188
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
4161
4189
  // we do not want to expose this error, just continue if this analytics-only call fails
4162
4190
  });
4163
- return new Promise((resolve, reject) => {
4164
- const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
4165
- // need to call pageResponse, otherwise when a child window is created, page is not loaded
4166
- const pageResponse = new Promise((resolve) => {
4167
- // TODO: fix typing (internal)
4168
- // @ts-expect-error
4169
- this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
4170
- let cbPayload;
4171
- const { success } = response;
4172
- const responseData = response.data;
4173
- const { message } = responseData;
4174
- if (success) {
4175
- cbPayload = {
4176
- httpResponseCode: responseData.httpResponseCode,
4177
- apiInjected: responseData.apiInjected
4178
- };
4179
- }
4180
- else {
4181
- cbPayload = {
4182
- message: responseData.message,
4183
- networkErrorCode: responseData.networkErrorCode,
4184
- stack: responseData.stack
4185
- };
4186
- }
4187
- this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
4188
- resolve({
4189
- message,
4190
- cbPayload,
4191
- success
4192
- });
4193
- });
4194
- });
4195
- // set defaults:
4196
- if (options.waitForPageLoad === undefined) {
4197
- options.waitForPageLoad = false;
4198
- }
4199
- if (options.autoShow === undefined) {
4200
- options.autoShow = true;
4201
- }
4202
- (0, warnings_1.handleDeprecatedWarnings)(options);
4203
- const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
4204
- Promise.all([pageResponse, windowCreation])
4205
- .then((resolvedArr) => {
4206
- const pageResolve = resolvedArr[0];
4207
- if (pageResolve.success) {
4208
- resolve(this);
4209
- }
4210
- else {
4211
- reject(pageResolve);
4212
- }
4213
- try {
4214
- // this is to enforce a 5.0 contract that the child's main function
4215
- // will not fire before the parent's success callback on creation.
4216
- // if the child window is not accessible (CORS) this contract does
4217
- // not hold.
4218
- const webWindow = this.getWebWindow();
4219
- webWindow.fin.__internal_.openerSuccessCBCalled();
4220
- }
4221
- catch (e) {
4222
- // common for main windows, we do not want to expose this error. here just to have a debug target.
4223
- // console.error(e);
4224
- }
4225
- })
4226
- .catch(reject);
4227
- });
4191
+ const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
4192
+ const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
4193
+ // set defaults:
4194
+ if (options.waitForPageLoad === undefined) {
4195
+ options.waitForPageLoad = false;
4196
+ }
4197
+ if (options.autoShow === undefined) {
4198
+ options.autoShow = true;
4199
+ }
4200
+ (0, warnings_1.handleDeprecatedWarnings)(options);
4201
+ const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
4202
+ const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
4203
+ let cbPayload;
4204
+ const { success } = response;
4205
+ const responseData = response.data;
4206
+ const { message } = responseData;
4207
+ if (success) {
4208
+ cbPayload = {
4209
+ httpResponseCode: responseData.httpResponseCode,
4210
+ apiInjected: responseData.apiInjected
4211
+ };
4212
+ }
4213
+ else {
4214
+ cbPayload = {
4215
+ message: responseData.message,
4216
+ networkErrorCode: responseData.networkErrorCode,
4217
+ stack: responseData.stack
4218
+ };
4219
+ }
4220
+ const pageResolve = {
4221
+ message,
4222
+ cbPayload,
4223
+ success
4224
+ };
4225
+ try {
4226
+ // this is to enforce a 5.0 contract that the child's main function
4227
+ // will not fire before the parent's success callback on creation.
4228
+ // if the child window is not accessible (CORS) this contract does
4229
+ // not hold.
4230
+ const webWindow = this.getWebWindow();
4231
+ webWindow.fin.__internal_.openerSuccessCBCalled();
4232
+ }
4233
+ catch (e) {
4234
+ // common for main windows, we do not want to expose this error. here just to have a debug target.
4235
+ // console.error(e);
4236
+ }
4237
+ if (pageResolve.success) {
4238
+ return this;
4239
+ }
4240
+ return Promise.reject(pageResolve);
4228
4241
  }
4229
4242
  /**
4230
4243
  * Retrieves an array of frame info objects representing the main frame and any
@@ -13165,27 +13178,7 @@ function requireInteropBroker () {
13165
13178
  const clientState = this.getClientState(clientIdentity);
13166
13179
  if (clientState && clientState.contextGroupId) {
13167
13180
  const { contextGroupId } = clientState;
13168
- if (!this.contextGroupsById.has(contextGroupId)) {
13169
- // Theoretically not possible.
13170
- throw new Error(`Client has a context group that isn't in the context group mapping: ${contextGroupId}.`);
13171
- }
13172
- const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13173
- if (contextIntegrityCheckResult.isValid === false) {
13174
- throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
13175
- }
13176
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13177
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
13178
- const broadcastedContextType = context.type;
13179
- contextGroupState.set(broadcastedContextType, context);
13180
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
13181
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13182
- clientsInSameContextGroup.forEach((client) => {
13183
- for (const [, handlerInfo] of client.contextHandlers) {
13184
- if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
13185
- this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
13186
- }
13187
- }
13188
- });
13181
+ this.setContextForGroup({ context }, contextGroupId);
13189
13182
  }
13190
13183
  else if (clientState) {
13191
13184
  // Client has not joined any context group behavior.
@@ -13196,6 +13189,36 @@ function requireInteropBroker () {
13196
13189
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
13197
13190
  }
13198
13191
  }
13192
+ /**
13193
+ * Sets a context for the context group.
13194
+ * @param setContextOptions - New context to set.
13195
+ * @param contextGroupId - Context group id.
13196
+ *
13197
+ */
13198
+ setContextForGroup({ context }, contextGroupId) {
13199
+ this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
13200
+ // don't expose, analytics-only call
13201
+ });
13202
+ const contextGroupState = this.contextGroupsById.get(contextGroupId);
13203
+ if (!contextGroupState) {
13204
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
13205
+ }
13206
+ const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13207
+ if (contextIntegrityCheckResult.isValid === false) {
13208
+ throw new Error(`Failed to set Context - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
13209
+ }
13210
+ const broadcastedContextType = context.type;
13211
+ contextGroupState.set(broadcastedContextType, context);
13212
+ this.lastContextMap.set(contextGroupId, broadcastedContextType);
13213
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13214
+ clientsInSameContextGroup.forEach((client) => {
13215
+ for (const [, handlerInfo] of client.contextHandlers) {
13216
+ if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
13217
+ this.invokeContextHandler(client.clientIdentity, handlerInfo.handlerId, context);
13218
+ }
13219
+ }
13220
+ });
13221
+ }
13199
13222
  /**
13200
13223
  * Get current context for a client subscribed to a Context Group.
13201
13224
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/node-adapter",
3
- "version": "36.80.7",
3
+ "version": "36.80.9",
4
4
  "description": "See README.md",
5
5
  "main": "out/node-adapter.js",
6
6
  "types": "out/node-adapter.d.ts",