@openfin/core 31.74.2 → 31.74.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.
- package/package.json +1 -1
- package/src/api/application/Instance.js +23 -5
- package/src/api/base.d.ts +3 -0
- package/src/api/base.js +7 -0
- package/src/api/events/system.d.ts +2 -2
- package/src/api/interop/fdc3/PrivateChannelProvider.js +1 -8
- package/src/api/interop/fdc3/fdc3-1.2.js +34 -1
- package/src/api/interop/fdc3/utils.js +24 -4
package/package.json
CHANGED
|
@@ -141,11 +141,29 @@ class Application extends base_1.EmitterBase {
|
|
|
141
141
|
* @tutorial Application.quit
|
|
142
142
|
*/
|
|
143
143
|
async quit(force = false) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
try {
|
|
145
|
+
await this._close(force);
|
|
146
|
+
await this.wire.sendAction('destroy-application', { force, ...this.identity });
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const acceptableErrors = [
|
|
150
|
+
'Remote connection has closed',
|
|
151
|
+
'Could not locate the requested application'
|
|
152
|
+
];
|
|
153
|
+
if (!acceptableErrors.some(msg => error.message.includes(msg))) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async _close(force = false) {
|
|
159
|
+
try {
|
|
160
|
+
await this.wire.sendAction('close-application', { force, ...this.identity });
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (!error.message.includes('Remote connection has closed')) {
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
149
167
|
}
|
|
150
168
|
close(force = false) {
|
|
151
169
|
console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
|
package/src/api/base.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export declare class EmitterBase<EmitterEvent extends BaseEvent, EmitterEventTyp
|
|
|
33
33
|
on<EventType extends EmitterEventType>(eventType: EventType, listener: EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions): Promise<this>;
|
|
34
34
|
addListener: <EventType extends EmitterEventType>(eventType: EventType, listener: OpenFin.BaseEvents.EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions) => Promise<this>;
|
|
35
35
|
once<EventType extends EmitterEventType>(eventType: EventType, listener: EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions): Promise<this>;
|
|
36
|
+
next<EventType extends EmitterEventType>(eventType: EventType, options?: OpenFin.SubscriptionOptions): Promise<Extract<EmitterEvent, {
|
|
37
|
+
type: EventType;
|
|
38
|
+
}>>;
|
|
36
39
|
prependListener<EventType extends EmitterEventType>(eventType: EventType, listener: EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions): Promise<this>;
|
|
37
40
|
prependOnceListener<EventType extends EmitterEventType>(eventType: EventType, listener: EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions): Promise<this>;
|
|
38
41
|
removeListener<EventType extends EmitterEventType>(eventType: EventType, listener: EventHandler<EmitterEvent, EventType>, options?: OpenFin.SubscriptionOptions): Promise<this>;
|
package/src/api/base.js
CHANGED
|
@@ -107,6 +107,13 @@ class EmitterBase extends Base {
|
|
|
107
107
|
});
|
|
108
108
|
return this;
|
|
109
109
|
}
|
|
110
|
+
async next(eventType, options) {
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
this.once(eventType, (event) => {
|
|
113
|
+
resolve(event);
|
|
114
|
+
}, options).catch(reject);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
110
117
|
async prependListener(eventType, listener, options) {
|
|
111
118
|
await this.registerEventListener(eventType, options, (emitter) => {
|
|
112
119
|
emitter.prependListener(eventType, listener);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as OpenFin from '../../OpenFin';
|
|
2
2
|
import { PropagatedApplicationEvent } from './application';
|
|
3
|
-
import { BaseEvent } from './base';
|
|
3
|
+
import { BaseEvent, IdentityEvent } from './base';
|
|
4
4
|
import { PropagatedViewEvent } from './view';
|
|
5
5
|
import { PropagatedWindowEvent } from './window';
|
|
6
6
|
import { AppVersionCompleteEvent, AppVersionErrorEvent, AppVersionProgressEvent, AppVersionRuntimeStatusEvent } from '../../OpenFin';
|
|
@@ -38,7 +38,7 @@ export type EventWithId<Event extends AppVersionEvent> = Event extends infer E e
|
|
|
38
38
|
appVersionId: string;
|
|
39
39
|
} : never;
|
|
40
40
|
export type AppVersionEventWithId = EventWithId<AppVersionEvent>;
|
|
41
|
-
export type ApplicationCreatedEvent =
|
|
41
|
+
export type ApplicationCreatedEvent = IdentityEvent & {
|
|
42
42
|
type: 'application-created';
|
|
43
43
|
};
|
|
44
44
|
export type DesktopIconClickedEvent = BaseEvent & {
|
|
@@ -84,16 +84,9 @@ class PrivateChannelProvider {
|
|
|
84
84
|
if (contextType) {
|
|
85
85
|
const currentHandlersList = senderClientState.handlerIdsByContextTypes.get(contextType) || [];
|
|
86
86
|
senderClientState.handlerIdsByContextTypes.set(contextType, [...currentHandlersList, handlerId]);
|
|
87
|
-
const currContext = this.contextByContextType.get(contextType);
|
|
88
|
-
if (currContext) {
|
|
89
|
-
this.provider.dispatch(senderClientIdentity, handlerId, currContext);
|
|
90
|
-
}
|
|
91
87
|
}
|
|
92
88
|
else {
|
|
93
89
|
senderClientState.globalHandler = handlerId;
|
|
94
|
-
if (this.lastContext) {
|
|
95
|
-
this.provider.dispatch(senderClientIdentity, handlerId, this.lastContext);
|
|
96
|
-
}
|
|
97
90
|
}
|
|
98
91
|
Array.from(this.clients.values()).forEach((currClientState) => {
|
|
99
92
|
if (currClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId &&
|
|
@@ -271,7 +264,7 @@ class PrivateChannelProvider {
|
|
|
271
264
|
const allClientInfo = await this.provider.getAllClientInfo();
|
|
272
265
|
return Array.from(this.clients.values()).filter((clientState) => {
|
|
273
266
|
const { uuid, name } = clientState.clientIdentity;
|
|
274
|
-
return allClientInfo.some(clientInfo => {
|
|
267
|
+
return allClientInfo.some((clientInfo) => {
|
|
275
268
|
return name === clientInfo.name && uuid === clientInfo.uuid;
|
|
276
269
|
});
|
|
277
270
|
});
|
|
@@ -4,6 +4,7 @@ const base_1 = require("../../base");
|
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const utils_2 = require("../utils");
|
|
6
6
|
const InteropClient_1 = require("../InteropClient");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
7
8
|
/**
|
|
8
9
|
* @typedef { object } Listener
|
|
9
10
|
* @summary Listener object returned by addContextListener and addIntentListener
|
|
@@ -393,7 +394,39 @@ class Fdc3Module extends base_1.Base {
|
|
|
393
394
|
return {
|
|
394
395
|
...currentContextGroupInfo,
|
|
395
396
|
type: 'system',
|
|
396
|
-
addContextListener:
|
|
397
|
+
addContextListener: (contextType, handler) => {
|
|
398
|
+
let realHandler;
|
|
399
|
+
let realType;
|
|
400
|
+
if (typeof contextType === 'function') {
|
|
401
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
402
|
+
realHandler = contextType;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
realHandler = handler;
|
|
406
|
+
if (typeof contextType === 'string') {
|
|
407
|
+
realType = contextType;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const listener = (async () => {
|
|
411
|
+
let first = true;
|
|
412
|
+
const currentContext = await this.fin.me.interop.getCurrentContext(realType);
|
|
413
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
414
|
+
if (first) {
|
|
415
|
+
first = false;
|
|
416
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// eslint-disable-next-line consistent-return
|
|
421
|
+
return realHandler(context, contextMetadata);
|
|
422
|
+
};
|
|
423
|
+
return this.fin.me.interop.addContextHandler(wrappedHandler, realType);
|
|
424
|
+
})();
|
|
425
|
+
return {
|
|
426
|
+
...listener,
|
|
427
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
428
|
+
};
|
|
429
|
+
},
|
|
397
430
|
broadcast: this.broadcast.bind(this),
|
|
398
431
|
getCurrentContext: async (contextType) => {
|
|
399
432
|
const context = await this.fin.me.interop.getCurrentContext(contextType);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const PrivateChannelClient_1 = require("./PrivateChannelClient");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
6
7
|
const getUnsupportedChannelApis = (channelType) => {
|
|
7
8
|
return {
|
|
8
9
|
addContextListener: () => {
|
|
@@ -111,14 +112,33 @@ const buildAppChannelObject = (sessionContextGroup) => {
|
|
|
111
112
|
return context === undefined ? null : context;
|
|
112
113
|
},
|
|
113
114
|
addContextListener: (contextType, handler) => {
|
|
114
|
-
let
|
|
115
|
+
let realHandler;
|
|
116
|
+
let realType;
|
|
115
117
|
if (typeof contextType === 'function') {
|
|
116
118
|
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
117
|
-
|
|
119
|
+
realHandler = contextType;
|
|
118
120
|
}
|
|
119
121
|
else {
|
|
120
|
-
|
|
122
|
+
realHandler = handler;
|
|
123
|
+
if (typeof contextType === 'string') {
|
|
124
|
+
realType = contextType;
|
|
125
|
+
}
|
|
121
126
|
}
|
|
127
|
+
const listener = (async () => {
|
|
128
|
+
let first = true;
|
|
129
|
+
const currentContext = await sessionContextGroup.getCurrentContext(realType);
|
|
130
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
131
|
+
if (first) {
|
|
132
|
+
first = false;
|
|
133
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// eslint-disable-next-line consistent-return
|
|
138
|
+
return realHandler(context, contextMetadata);
|
|
139
|
+
};
|
|
140
|
+
return sessionContextGroup.addContextHandler(wrappedHandler, realType);
|
|
141
|
+
})();
|
|
122
142
|
return {
|
|
123
143
|
...listener,
|
|
124
144
|
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
@@ -149,7 +169,7 @@ exports.isContext = isContext;
|
|
|
149
169
|
const isChannel = (channel) => {
|
|
150
170
|
if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
|
|
151
171
|
const { type, id } = channel;
|
|
152
|
-
return
|
|
172
|
+
return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
|
|
153
173
|
}
|
|
154
174
|
return false;
|
|
155
175
|
};
|