@openfin/core 29.73.3 → 29.73.5
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/OpenFin.d.ts +79 -1
- package/package.json +1 -1
- package/src/OpenFin.d.ts +1452 -0
- package/src/OpenFin.js +4 -0
- package/src/api/events/system.d.ts +18 -3
- package/src/api/events/typedEventEmitter.d.ts +13 -0
- package/src/api/events/typedEventEmitter.js +2 -0
- package/src/api/interop/Factory.js +1 -1
- package/src/api/interop/InteropBroker.d.ts +36 -5
- package/src/api/interop/InteropBroker.js +56 -8
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +8 -7
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +14 -13
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +24 -21
- package/src/api/interop/fdc3/fdc3-2.0.js +11 -18
- package/src/api/interop/fdc3/fdc3.d.ts +13 -0
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +53 -0
- package/src/api/interop/fdc3/shapes/fdc3v1.js +4 -0
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +74 -0
- package/src/api/interop/fdc3/shapes/fdc3v2.js +2 -0
- package/src/api/interop/fdc3/utils.d.ts +7 -5
- package/src/api/interop/fdc3/utils.js +2 -2
- package/src/api/interop/utils.d.ts +1 -0
- package/src/api/interop/utils.js +9 -1
- package/src/api/platform/Instance.d.ts +12 -0
- package/src/api/platform/Instance.js +15 -0
- package/src/api/platform/layout/utils/bounds-observer.d.ts +1 -1
- package/src/api/platform/layout/utils/bounds-observer.js +2 -2
- package/src/api/system/index.d.ts +1 -470
- package/src/api/system/index.js +52 -472
- package/src/api/view/Instance.d.ts +8 -0
- package/src/api/view/Instance.js +16 -0
- package/src/fdc3.d.ts +3 -0
- package/src/shapes/protocol.d.ts +3 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DisplayMetadata } from 'fdc3v1/src/api/DisplayMetadata';
|
|
2
|
+
import type { Listener } from 'fdc3v1/src/api/Listener';
|
|
3
|
+
import type { AppMetadata } from 'fdc3v1/src/api/AppMetadata';
|
|
4
|
+
import type { AppIntent } from 'fdc3v1/src/api/AppIntent';
|
|
5
|
+
import type { ImplementationMetadata } from 'fdc3v1/src/api/ImplementationMetadata';
|
|
6
|
+
export type { DisplayMetadata } from 'fdc3v1/src/api/DisplayMetadata';
|
|
7
|
+
export type { Listener } from 'fdc3v1/src/api/Listener';
|
|
8
|
+
export type { AppMetadata } from 'fdc3v1/src/api/AppMetadata';
|
|
9
|
+
export type { AppIntent } from 'fdc3v1/src/api/AppIntent';
|
|
10
|
+
export type { ImplementationMetadata } from 'fdc3v1/src/api/ImplementationMetadata';
|
|
11
|
+
export declare type ContextHandler = (context: Context) => void;
|
|
12
|
+
export declare type TargetApp = string | AppMetadata;
|
|
13
|
+
export interface Context {
|
|
14
|
+
id?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
name?: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}
|
|
20
|
+
export interface IntentResolution {
|
|
21
|
+
source: TargetApp;
|
|
22
|
+
data?: object;
|
|
23
|
+
version: string;
|
|
24
|
+
}
|
|
25
|
+
export interface Channel {
|
|
26
|
+
id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
displayMetadata?: DisplayMetadata;
|
|
29
|
+
broadcast(context: Context): void;
|
|
30
|
+
getCurrentContext(contextType?: string): Promise<Context | null>;
|
|
31
|
+
addContextListener(contextType: string | null, handler: ContextHandler): Listener & Promise<Listener>;
|
|
32
|
+
}
|
|
33
|
+
export declare type SystemChannel = Omit<Channel, 'addContextListener' | 'broadcast' | 'getCurrentContext'> & {
|
|
34
|
+
addContextListener(): Error;
|
|
35
|
+
broadcast(): Error;
|
|
36
|
+
getCurrentContext(): Error;
|
|
37
|
+
};
|
|
38
|
+
export interface DesktopAgent {
|
|
39
|
+
open(app: TargetApp, context?: Context): Promise<void>;
|
|
40
|
+
findIntent(intent: string, context?: Context): Promise<AppIntent>;
|
|
41
|
+
findIntentsByContext(context: Context): Promise<Array<AppIntent>>;
|
|
42
|
+
broadcast(context: Context): void;
|
|
43
|
+
raiseIntent(intent: string, context: Context, app?: TargetApp): Promise<IntentResolution>;
|
|
44
|
+
raiseIntentForContext(context: Context, app?: TargetApp): Promise<IntentResolution>;
|
|
45
|
+
addIntentListener(intent: string, handler: ContextHandler): Listener;
|
|
46
|
+
joinChannel(channelId: string): Promise<void>;
|
|
47
|
+
leaveCurrentChannel(): Promise<void>;
|
|
48
|
+
getInfo(): ImplementationMetadata;
|
|
49
|
+
addContextListener(contextType: string | null, handler: ContextHandler): Listener & Promise<Listener>;
|
|
50
|
+
getOrCreateChannel(channelId: string): Promise<Channel>;
|
|
51
|
+
getSystemChannels(): Promise<SystemChannel[]>;
|
|
52
|
+
getCurrentChannel(): Promise<Channel | null>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Channel as ChannelV1, SystemChannel } from './fdc3v1';
|
|
2
|
+
import type { Listener } from 'fdc3v2/src/api/Listener';
|
|
3
|
+
import type { AppIntent } from 'fdc3v2/src/api/AppIntent';
|
|
4
|
+
import type { ImplementationMetadata } from 'fdc3v2/src/api/ImplementationMetadata';
|
|
5
|
+
import type { ContextMetadata } from 'fdc3v2/src/api/ContextMetadata';
|
|
6
|
+
import type { AppIdentifier } from 'fdc3v2/src/api/AppIdentifier';
|
|
7
|
+
import type { AppMetadata } from 'fdc3v2/src/api/AppMetadata';
|
|
8
|
+
import type { DisplayMetadata } from 'fdc3v2/src/api/DisplayMetadata';
|
|
9
|
+
export type { Listener } from 'fdc3v2/src/api/Listener';
|
|
10
|
+
export type { AppIntent } from 'fdc3v2/src/api/AppIntent';
|
|
11
|
+
export type { ImplementationMetadata } from 'fdc3v2/src/api/ImplementationMetadata';
|
|
12
|
+
export type { ContextMetadata } from 'fdc3v2/src/api/ContextMetadata';
|
|
13
|
+
export type { AppIdentifier } from 'fdc3v2/src/api/AppIdentifier';
|
|
14
|
+
export type { AppMetadata } from 'fdc3v2/src/api/AppMetadata';
|
|
15
|
+
export type { DisplayMetadata } from 'fdc3v2/src/api/DisplayMetadata';
|
|
16
|
+
export declare type ContextHandler = (context: Context, metadata?: ContextMetadata) => void;
|
|
17
|
+
export declare type IntentHandler = (context: Context, metadata?: ContextMetadata) => Promise<IntentResult> | void;
|
|
18
|
+
export declare type IntentResult = Context | Channel | PrivateChannel;
|
|
19
|
+
export interface Context {
|
|
20
|
+
id?: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
name?: string;
|
|
24
|
+
type: string;
|
|
25
|
+
contextMetadata?: ContextMetadata;
|
|
26
|
+
metadata?: any;
|
|
27
|
+
}
|
|
28
|
+
export interface Intent {
|
|
29
|
+
name: string;
|
|
30
|
+
context: Context;
|
|
31
|
+
metadata: OpenFin.IntentMetadata;
|
|
32
|
+
}
|
|
33
|
+
export interface IntentResolution {
|
|
34
|
+
source: AppIdentifier;
|
|
35
|
+
intent: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
getResult(): Promise<IntentResult>;
|
|
38
|
+
}
|
|
39
|
+
export interface Channel {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly type: 'user' | 'app' | 'private';
|
|
42
|
+
readonly displayMetadata?: DisplayMetadata;
|
|
43
|
+
broadcast(context: Context): Promise<void>;
|
|
44
|
+
getCurrentContext(contextType?: string): Promise<Context | null>;
|
|
45
|
+
addContextListener(contextType: string | null, handler: ContextHandler): Listener & Promise<Listener>;
|
|
46
|
+
}
|
|
47
|
+
export declare type PrivateChannel = Omit<Channel, 'addContextListener'> & {
|
|
48
|
+
addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
|
|
49
|
+
onAddContextListener(handler: (contextType?: string) => void): Listener;
|
|
50
|
+
onUnsubscribe(handler: (contextType?: string) => void): Listener;
|
|
51
|
+
onDisconnect(handler: () => void): Listener;
|
|
52
|
+
disconnect(): void;
|
|
53
|
+
};
|
|
54
|
+
export interface DesktopAgent {
|
|
55
|
+
open(app: AppIdentifier, context?: Context): Promise<AppIdentifier>;
|
|
56
|
+
findIntent(intent: string, context?: Context, resultType?: string): Promise<AppIntent>;
|
|
57
|
+
findIntentsByContext(context: Context, resultType?: string): Promise<Array<AppIntent>>;
|
|
58
|
+
findInstances(app: AppIdentifier): Promise<Array<AppIdentifier>>;
|
|
59
|
+
broadcast(context: Context): Promise<void>;
|
|
60
|
+
raiseIntent(intent: string, context: Context, app?: AppIdentifier): Promise<IntentResolution>;
|
|
61
|
+
raiseIntentForContext(context: Context, app?: AppIdentifier): Promise<IntentResolution>;
|
|
62
|
+
addIntentListener(intent: string, handler: IntentHandler): Promise<Listener>;
|
|
63
|
+
addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
|
|
64
|
+
getUserChannels(): Promise<Array<SystemChannel>>;
|
|
65
|
+
joinUserChannel(channelId: string): Promise<void>;
|
|
66
|
+
getOrCreateChannel(channelId: string): Promise<ChannelV1>;
|
|
67
|
+
createPrivateChannel(): Promise<PrivateChannel>;
|
|
68
|
+
getCurrentChannel(): Promise<ChannelV1 | null>;
|
|
69
|
+
leaveCurrentChannel(): Promise<void>;
|
|
70
|
+
getInfo(): Promise<ImplementationMetadata>;
|
|
71
|
+
getAppMetadata(app: AppIdentifier): Promise<AppMetadata>;
|
|
72
|
+
getSystemChannels(): Promise<Array<SystemChannel>>;
|
|
73
|
+
joinChannel(channelId: string): Promise<void>;
|
|
74
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { TargetApp } from './shapes/fdc3v1';
|
|
2
|
+
import { AppIdentifier, IntentResolution, Channel, PrivateChannel, Context } from './shapes/fdc3v2';
|
|
1
3
|
import { PrivateChannelClient } from './PrivateChannelClient';
|
|
2
4
|
interface UnsupportedChannelApis {
|
|
3
5
|
addContextListener(): Error;
|
|
4
6
|
broadcast(): Error;
|
|
5
|
-
|
|
7
|
+
getCurrentContext(): Error;
|
|
6
8
|
}
|
|
7
9
|
export declare const getUnsupportedChannelApis: (channelType?: string) => UnsupportedChannelApis;
|
|
8
10
|
export declare class UnsupportedChannelApiError extends Error {
|
|
@@ -18,8 +20,8 @@ export declare enum ResultError {
|
|
|
18
20
|
*/
|
|
19
21
|
IntentHandlerRejected = "IntentHandlerRejected"
|
|
20
22
|
}
|
|
21
|
-
export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) =>
|
|
22
|
-
export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) =>
|
|
23
|
-
export declare const connectPrivateChannel: (channelId: string) => Promise<
|
|
24
|
-
export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context:
|
|
23
|
+
export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) => PrivateChannel;
|
|
24
|
+
export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) => Channel;
|
|
25
|
+
export declare const connectPrivateChannel: (channelId: string) => Promise<PrivateChannel>;
|
|
26
|
+
export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context: Context, app?: AppIdentifier | TargetApp, intent?: string) => Promise<IntentResolution>;
|
|
25
27
|
export {};
|
|
@@ -11,8 +11,8 @@ const getUnsupportedChannelApis = (channelType) => {
|
|
|
11
11
|
broadcast: () => {
|
|
12
12
|
throw new UnsupportedChannelApiError('Channel.broadcast', channelType);
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
throw new UnsupportedChannelApiError('Channel.
|
|
14
|
+
getCurrentContext: () => {
|
|
15
|
+
throw new UnsupportedChannelApiError('Channel.getCurrentContext', channelType);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
};
|
|
@@ -15,3 +15,4 @@ export declare const BROKER_ERRORS: {
|
|
|
15
15
|
fdc3GetInfo: string;
|
|
16
16
|
};
|
|
17
17
|
export declare const wrapIntentHandler: (handler: OpenFin.IntentHandler, handlerId: string) => (intent: OpenFin.Intent) => Promise<void>;
|
|
18
|
+
export declare const generateDefaultLoggingOptions: () => OpenFin.InteropLoggingOptions;
|
package/src/api/interop/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
3
|
+
exports.generateDefaultLoggingOptions = exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
4
4
|
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
5
5
|
exports.generateId = generateId;
|
|
6
6
|
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
@@ -59,3 +59,11 @@ const wrapIntentHandler = (handler, handlerId) => {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
exports.wrapIntentHandler = wrapIntentHandler;
|
|
62
|
+
const generateDefaultLoggingOptions = () => {
|
|
63
|
+
const loggingActions = ['beforeAction', 'afterAction'];
|
|
64
|
+
const options = loggingActions.reduce((accumulator, loggingOption) => {
|
|
65
|
+
return { ...accumulator, [loggingOption]: { enabled: true } };
|
|
66
|
+
}, {});
|
|
67
|
+
return options;
|
|
68
|
+
};
|
|
69
|
+
exports.generateDefaultLoggingOptions = generateDefaultLoggingOptions;
|
|
@@ -64,6 +64,18 @@ export declare class Platform extends EmitterBase<PlatformEvents> {
|
|
|
64
64
|
* @tutorial Platform.getSnapshot
|
|
65
65
|
*/
|
|
66
66
|
getSnapshot(): Promise<OpenFin.Snapshot>;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a snapshot of a single view's options in its current state.
|
|
69
|
+
*
|
|
70
|
+
* Can be used to restore a view to a previous state.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: this method is meant for advanced usage only, it is not recommended to manage the state of individual views.
|
|
73
|
+
*
|
|
74
|
+
* @param { Identity } viewIdentity View identity
|
|
75
|
+
* @returns { Promise<ViewState> }
|
|
76
|
+
* @tutorial Platform.getViewSnapshot
|
|
77
|
+
*/
|
|
78
|
+
getViewSnapshot(viewIdentity: OpenFin.Identity): Promise<OpenFin.ViewState>;
|
|
67
79
|
/**
|
|
68
80
|
* Adds a snapshot to a running Platform.
|
|
69
81
|
* Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
|
|
@@ -173,6 +173,21 @@ class Platform extends base_1.EmitterBase {
|
|
|
173
173
|
const client = await this.getClient();
|
|
174
174
|
return client.dispatch('get-snapshot');
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns a snapshot of a single view's options in its current state.
|
|
178
|
+
*
|
|
179
|
+
* Can be used to restore a view to a previous state.
|
|
180
|
+
*
|
|
181
|
+
* NOTE: this method is meant for advanced usage only, it is not recommended to manage the state of individual views.
|
|
182
|
+
*
|
|
183
|
+
* @param { Identity } viewIdentity View identity
|
|
184
|
+
* @returns { Promise<ViewState> }
|
|
185
|
+
* @tutorial Platform.getViewSnapshot
|
|
186
|
+
*/
|
|
187
|
+
async getViewSnapshot(viewIdentity) {
|
|
188
|
+
const client = await this.getClient();
|
|
189
|
+
return client.dispatch('get-view-snapshot', { viewIdentity });
|
|
190
|
+
}
|
|
176
191
|
/**
|
|
177
192
|
* Adds a snapshot to a running Platform.
|
|
178
193
|
* Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
|
|
@@ -16,4 +16,4 @@ export declare const isDomRectEqual: (a: DOMRect, b: DOMRect) => boolean;
|
|
|
16
16
|
* @returns Function which disposes the observers when invoked.
|
|
17
17
|
* @ignore
|
|
18
18
|
*/
|
|
19
|
-
export declare const observeBounds: (element: Element, onChange: (bounds: DOMRect) => void) => () => void;
|
|
19
|
+
export declare const observeBounds: (element: Element, onChange: (bounds: DOMRect) => Promise<void> | void) => (() => void);
|
|
@@ -32,11 +32,11 @@ exports.isDomRectEqual = isDomRectEqual;
|
|
|
32
32
|
*/
|
|
33
33
|
const observeBounds = (element, onChange) => {
|
|
34
34
|
let lastBounds;
|
|
35
|
-
const checkBounds = () => {
|
|
35
|
+
const checkBounds = async () => {
|
|
36
36
|
const currentBounds = element.getBoundingClientRect();
|
|
37
37
|
if (!lastBounds || !(0, exports.isDomRectEqual)(lastBounds, currentBounds)) {
|
|
38
38
|
lastBounds = currentBounds;
|
|
39
|
-
onChange(element.getBoundingClientRect());
|
|
39
|
+
await onChange(element.getBoundingClientRect());
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
const resizeObserver = new ResizeObserver(() => checkBounds());
|