@openfin/core 30.73.20 → 30.73.22

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/OpenFin.d.ts +75 -27
  3. package/src/OpenFin.js +2 -0
  4. package/src/api/events/system.d.ts +18 -3
  5. package/src/api/events/typedEventEmitter.d.ts +13 -0
  6. package/{fdc3.js → src/api/events/typedEventEmitter.js} +0 -0
  7. package/src/api/frame/Instance.d.ts +2 -1
  8. package/src/api/global-hotkey/index.d.ts +2 -1
  9. package/src/api/interop/InteropBroker.d.ts +6 -5
  10. package/src/api/interop/fdc3/PrivateChannelClient.d.ts +8 -8
  11. package/src/api/interop/fdc3/fdc3-1.2.d.ts +14 -15
  12. package/src/api/interop/fdc3/fdc3-2.0.d.ts +23 -23
  13. package/src/api/interop/fdc3/fdc3-2.0.js +9 -9
  14. package/src/api/interop/fdc3/fdc3.d.ts +13 -0
  15. package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +53 -0
  16. package/src/api/interop/fdc3/shapes/fdc3v1.js +4 -0
  17. package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +75 -0
  18. package/src/api/interop/fdc3/shapes/fdc3v2.js +2 -0
  19. package/src/api/interop/fdc3/utils.d.ts +7 -6
  20. package/src/api/interop/fdc3/utils.js +2 -2
  21. package/src/api/platform/Instance.d.ts +14 -1
  22. package/src/api/platform/Instance.js +15 -0
  23. package/src/api/platform/layout/utils/bounds-observer.d.ts +1 -1
  24. package/src/api/platform/layout/utils/bounds-observer.js +2 -2
  25. package/src/api/system/index.d.ts +15 -483
  26. package/src/api/system/index.js +51 -471
  27. package/src/api/view/Instance.d.ts +11 -2
  28. package/src/api/view/Instance.js +16 -0
  29. package/src/api/window/Instance.d.ts +2 -1
  30. package/src/fdc3.d.ts +3 -0
  31. package/src/mock.d.ts +1 -1
  32. package/src/shapes/protocol.d.ts +3 -1
  33. package/fdc3.ts +0 -264
@@ -181,7 +181,7 @@ class Fdc3Module2 extends base_1.Base {
181
181
  * Find all the available instances for a particular application.
182
182
  * @param { AppIdentifier } app
183
183
  * @returns { Promise<Array<AppIdentifier>> }
184
- * @tutorial fdc3v2.findInstances
184
+ * @tutorial findInstances
185
185
  */
186
186
  async findInstances(app) {
187
187
  this.wire.sendAction('fdc3-find-instances').catch((e) => {
@@ -199,7 +199,7 @@ class Fdc3Module2 extends base_1.Base {
199
199
  * Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
200
200
  * @param { AppIdentifier } app
201
201
  * @returns { Promise<AppMetadata(2)> }
202
- * @tutorial fdc3v2.getAppMetadata
202
+ * @tutorial getAppMetadata
203
203
  */
204
204
  async getAppMetadata(app) {
205
205
  this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
@@ -277,7 +277,7 @@ class Fdc3Module2 extends base_1.Base {
277
277
  * @param { Context } context
278
278
  * @param { string } [resultType] The type of result returned for any intent specified during resolution.
279
279
  * @returns { Promise<Array<AppIntent(2)>> }
280
- * @tutorial fdc3v2.findIntentsByContext
280
+ * @tutorial findIntentsByContext
281
281
  */
282
282
  async findIntentsByContext(context, resultType) {
283
283
  this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
@@ -298,7 +298,7 @@ class Fdc3Module2 extends base_1.Base {
298
298
  * @param { Context } context Context associated with the Intent
299
299
  * @param { AppIdentifier | TargetApp } [app]
300
300
  * @returns { Promise<IntentResolution(2)> }
301
- * @tutorial fdc3v2.raiseIntent
301
+ * @tutorial raiseIntent
302
302
  */
303
303
  async raiseIntent(intent, context, app) {
304
304
  this.wire.sendAction('fdc3-raise-intent').catch((e) => {
@@ -317,7 +317,7 @@ class Fdc3Module2 extends base_1.Base {
317
317
  * @param { Context } context Context associated with the Intent
318
318
  * @param { AppIdentifier | TargetApp } [app]
319
319
  * @returns { Promise<IntentResolution(2)> }
320
- * @tutorial fdc3v2.raiseIntentForContext
320
+ * @tutorial raiseIntentForContext
321
321
  */
322
322
  async raiseIntentForContext(context, app) {
323
323
  // TODO: We have to do the same thing we do for raiseIntent here as well.
@@ -385,7 +385,7 @@ class Fdc3Module2 extends base_1.Base {
385
385
  /**
386
386
  * Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
387
387
  * @returns { Promise<PrivateChannel> }
388
- * @tutorial fdc3v2.createPrivateChannel
388
+ * @tutorial createPrivateChannel
389
389
  */
390
390
  async createPrivateChannel() {
391
391
  const channelId = (0, utils_1.generateId)();
@@ -398,7 +398,7 @@ class Fdc3Module2 extends base_1.Base {
398
398
  /**
399
399
  * Retrieves a list of the User Channels available for the app to join.
400
400
  * @returns { Promise<Channel[]>}
401
- * @tutorial fdc3v2.getUserChannels
401
+ * @tutorial getUserChannels
402
402
  */
403
403
  async getUserChannels() {
404
404
  const channels = await this.fin.me.interop.getContextGroups();
@@ -422,7 +422,7 @@ class Fdc3Module2 extends base_1.Base {
422
422
  * Join an app to a specified User channel.
423
423
  * @param { string } channelId Channel name
424
424
  * @returns { Promise<void> }
425
- * @tutorial fdc3v2.joinUserChannel
425
+ * @tutorial joinUserChannel
426
426
  */
427
427
  async joinUserChannel(channelId) {
428
428
  return this.fdc3Module.joinChannel(channelId);
@@ -457,7 +457,7 @@ class Fdc3Module2 extends base_1.Base {
457
457
  * Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
458
458
  * fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
459
459
  * @returns { Promise<ImplementationMetadata(2)> }
460
- * @tutorial fdc3v2.getInfo
460
+ * @tutorial getInfo
461
461
  */
462
462
  async getInfo() {
463
463
  return InteropClient_1.InteropClient.ferryFdc3Call(this.fin.me.interop, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
@@ -0,0 +1,13 @@
1
+ import Fdc3Module from './fdc3-1.2';
2
+ import Fdc3Module2 from './fdc3-2.0';
3
+ import type Transport from '../../../transport/transport';
4
+ declare global {
5
+ interface Window {
6
+ fdc3: Fdc3Module | Fdc3Module2;
7
+ }
8
+ }
9
+ declare type Fdc3Versions = '1.2' | '2.0';
10
+ export declare const versionMap: Record<Fdc3Versions, typeof Fdc3Module | typeof Fdc3Module2>;
11
+ export declare function registerFdc3Shim(version: string, transport: Transport): void;
12
+ export declare function getFdc3(transport: Transport, version?: Fdc3Versions): Fdc3Module | Fdc3Module2;
13
+ export {};
@@ -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,4 @@
1
+ "use strict";
2
+ /* eslint-disable import/no-extraneous-dependencies */
3
+ /* eslint-disable no-restricted-imports */
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,75 @@
1
+ import * as OpenFin from '../../../../OpenFin';
2
+ import { Channel as ChannelV1, SystemChannel } from './fdc3v1';
3
+ import type { Listener } from 'fdc3v2/src/api/Listener';
4
+ import type { AppIntent } from 'fdc3v2/src/api/AppIntent';
5
+ import type { ImplementationMetadata } from 'fdc3v2/src/api/ImplementationMetadata';
6
+ import type { ContextMetadata } from 'fdc3v2/src/api/ContextMetadata';
7
+ import type { AppIdentifier } from 'fdc3v2/src/api/AppIdentifier';
8
+ import type { AppMetadata } from 'fdc3v2/src/api/AppMetadata';
9
+ import type { DisplayMetadata } from 'fdc3v2/src/api/DisplayMetadata';
10
+ export type { Listener } from 'fdc3v2/src/api/Listener';
11
+ export type { AppIntent } from 'fdc3v2/src/api/AppIntent';
12
+ export type { ImplementationMetadata } from 'fdc3v2/src/api/ImplementationMetadata';
13
+ export type { ContextMetadata } from 'fdc3v2/src/api/ContextMetadata';
14
+ export type { AppIdentifier } from 'fdc3v2/src/api/AppIdentifier';
15
+ export type { AppMetadata } from 'fdc3v2/src/api/AppMetadata';
16
+ export type { DisplayMetadata } from 'fdc3v2/src/api/DisplayMetadata';
17
+ export declare type ContextHandler = (context: Context, metadata?: ContextMetadata) => void;
18
+ export declare type IntentHandler = (context: Context, metadata?: ContextMetadata) => Promise<IntentResult> | void;
19
+ export declare type IntentResult = Context | Channel | PrivateChannel;
20
+ export interface Context {
21
+ id?: {
22
+ [key: string]: string;
23
+ };
24
+ name?: string;
25
+ type: string;
26
+ contextMetadata?: ContextMetadata;
27
+ metadata?: any;
28
+ }
29
+ export interface Intent {
30
+ name: string;
31
+ context: Context;
32
+ metadata: OpenFin.IntentMetadata;
33
+ }
34
+ export interface IntentResolution {
35
+ source: AppIdentifier;
36
+ intent: string;
37
+ version?: string;
38
+ getResult(): Promise<IntentResult>;
39
+ }
40
+ export interface Channel {
41
+ readonly id: string;
42
+ readonly type: 'user' | 'app' | 'private';
43
+ readonly displayMetadata?: DisplayMetadata;
44
+ broadcast(context: Context): Promise<void>;
45
+ getCurrentContext(contextType?: string): Promise<Context | null>;
46
+ addContextListener(contextType: string | null, handler: ContextHandler): Listener & Promise<Listener>;
47
+ }
48
+ export declare type PrivateChannel = Omit<Channel, 'addContextListener'> & {
49
+ addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
50
+ onAddContextListener(handler: (contextType?: string) => void): Listener;
51
+ onUnsubscribe(handler: (contextType?: string) => void): Listener;
52
+ onDisconnect(handler: () => void): Listener;
53
+ disconnect(): void;
54
+ };
55
+ export interface DesktopAgent {
56
+ open(app: AppIdentifier, context?: Context): Promise<AppIdentifier>;
57
+ findIntent(intent: string, context?: Context, resultType?: string): Promise<AppIntent>;
58
+ findIntentsByContext(context: Context, resultType?: string): Promise<Array<AppIntent>>;
59
+ findInstances(app: AppIdentifier): Promise<Array<AppIdentifier>>;
60
+ broadcast(context: Context): Promise<void>;
61
+ raiseIntent(intent: string, context: Context, app?: AppIdentifier): Promise<IntentResolution>;
62
+ raiseIntentForContext(context: Context, app?: AppIdentifier): Promise<IntentResolution>;
63
+ addIntentListener(intent: string, handler: IntentHandler): Promise<Listener>;
64
+ addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
65
+ getUserChannels(): Promise<Array<SystemChannel>>;
66
+ joinUserChannel(channelId: string): Promise<void>;
67
+ getOrCreateChannel(channelId: string): Promise<ChannelV1>;
68
+ createPrivateChannel(): Promise<PrivateChannel>;
69
+ getCurrentChannel(): Promise<ChannelV1 | null>;
70
+ leaveCurrentChannel(): Promise<void>;
71
+ getInfo(): Promise<ImplementationMetadata>;
72
+ getAppMetadata(app: AppIdentifier): Promise<AppMetadata>;
73
+ getSystemChannels(): Promise<Array<SystemChannel>>;
74
+ joinChannel(channelId: string): Promise<void>;
75
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,11 @@
1
- import { FDC3, FDC3v2 } from '../../../../fdc3';
1
+ import { TargetApp } from './shapes/fdc3v1';
2
+ import { AppIdentifier, IntentResolution, Channel, PrivateChannel, Context } from './shapes/fdc3v2';
2
3
  import * as OpenFin from '../../../OpenFin';
3
4
  import { PrivateChannelClient } from './PrivateChannelClient';
4
5
  interface UnsupportedChannelApis {
5
6
  addContextListener(): Error;
6
7
  broadcast(): Error;
7
- getCurrentChannel(): Error;
8
+ getCurrentContext(): Error;
8
9
  }
9
10
  export declare const getUnsupportedChannelApis: (channelType?: string) => UnsupportedChannelApis;
10
11
  export declare class UnsupportedChannelApiError extends Error {
@@ -20,8 +21,8 @@ export declare enum ResultError {
20
21
  */
21
22
  IntentHandlerRejected = "IntentHandlerRejected"
22
23
  }
23
- export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) => FDC3v2.PrivateChannel;
24
- export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) => FDC3.Channel;
25
- export declare const connectPrivateChannel: (channelId: string) => Promise<FDC3v2.PrivateChannel>;
26
- export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp, intent?: string) => Promise<FDC3v2.IntentResolution>;
24
+ export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) => PrivateChannel;
25
+ export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) => Channel;
26
+ export declare const connectPrivateChannel: (channelId: string) => Promise<PrivateChannel>;
27
+ export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context: Context, app?: AppIdentifier | TargetApp, intent?: string) => Promise<IntentResolution>;
27
28
  export {};
@@ -11,8 +11,8 @@ const getUnsupportedChannelApis = (channelType) => {
11
11
  broadcast: () => {
12
12
  throw new UnsupportedChannelApiError('Channel.broadcast', channelType);
13
13
  },
14
- getCurrentChannel: () => {
15
- throw new UnsupportedChannelApiError('Channel.getCurrentChannel', channelType);
14
+ getCurrentContext: () => {
15
+ throw new UnsupportedChannelApiError('Channel.getCurrentContext', channelType);
16
16
  }
17
17
  };
18
18
  };
@@ -4,7 +4,7 @@ import { EmitterBase } from '../base';
4
4
  import { Channel } from '../interappbus/channel/index';
5
5
  import ChannelClient from '../interappbus/channel/client';
6
6
  import { LayoutModule } from './layout';
7
- import PlatformEvents = OpenFin.PlatformEvents;
7
+ declare type PlatformEvents = OpenFin.PlatformEvents;
8
8
  /** Manages the life cycle of windows and views in the application.
9
9
  *
10
10
  * Enables taking snapshots of itself and applying them to restore a previous configuration
@@ -65,6 +65,18 @@ export declare class Platform extends EmitterBase<PlatformEvents> {
65
65
  * @tutorial Platform.getSnapshot
66
66
  */
67
67
  getSnapshot(): Promise<OpenFin.Snapshot>;
68
+ /**
69
+ * Returns a snapshot of a single view's options in its current state.
70
+ *
71
+ * Can be used to restore a view to a previous state.
72
+ *
73
+ * NOTE: this method is meant for advanced usage only, it is not recommended to manage the state of individual views.
74
+ *
75
+ * @param { Identity } viewIdentity View identity
76
+ * @returns { Promise<ViewState> }
77
+ * @tutorial Platform.getViewSnapshot
78
+ */
79
+ getViewSnapshot(viewIdentity: OpenFin.Identity): Promise<OpenFin.ViewState>;
68
80
  /**
69
81
  * Adds a snapshot to a running Platform.
70
82
  * Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
@@ -133,3 +145,4 @@ export declare class Platform extends EmitterBase<PlatformEvents> {
133
145
  skipBeforeUnload: boolean;
134
146
  }): Promise<void>;
135
147
  }
148
+ export {};
@@ -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());