diff --git a/types/openfin/_v2/api/application/application.d.ts b/types/openfin/_v2/api/application/application.d.ts index 616501834d..b5797aa7ad 100644 --- a/types/openfin/_v2/api/application/application.d.ts +++ b/types/openfin/_v2/api/application/application.d.ts @@ -1,10 +1,11 @@ -import { EmitterBase, Base, Reply, RuntimeEvent } from '../base'; +import { EmitterBase, Base, Reply } from '../base'; import { Identity } from '../../identity'; import { _Window } from '../window/window'; import { Point } from '../system/point'; import { MonitorInfo } from '../system/monitor'; import Transport from '../../transport/transport'; import Bounds from '../window/bounds'; +import { ApplicationEvents } from '../events/application'; export interface TrayIconClickReply extends Point, Reply<'application', 'tray-icon-clicked'> { button: number; monitorInfo: MonitorInfo; @@ -32,32 +33,54 @@ export interface TrayInfo { x: number; y: number; } +/** + * @lends Application + */ export default class ApplicationModule extends Base { /** - * Returns an Application object that represents an existing application. - * @param { Identity } indentity + * Asynchronously returns an Application object that represents an existing application. + * @param { Identity } identity * @return {Promise.} * @tutorial Application.wrap + * @static */ wrap(identity: Identity): Promise; + /** + * Synchronously returns an Application object that represents an existing application. + * @param { Identity } identity + * @return {Application} + * @tutorial Application.wrapSync + * @static + */ + wrapSync(identity: Identity): Application; /** * Creates a new Application. * @param {*} appOptions * @return {Promise.} * @tutorial Application.create + * @static */ create(appOptions: any): Promise; /** - * Returns an Application object that represents the current application + * Asynchronously returns an Application object that represents the current application * @return {Promise.} * @tutorial Application.getCurrent + * @static */ getCurrent(): Promise; + /** + * Synchronously returns an Application object that represents the current application + * @return {Application} + * @tutorial Application.getCurrentSync + * @static + */ + getCurrentSync(): Application; /** * Retrieves application's manifest and returns a wrapped application. * @param {string} manifestUrl - The URL of app's manifest. * @return {Promise.} * @tutorial Application.createFromManifest + * @static */ createFromManifest(manifestUrl: string): Promise; } @@ -66,12 +89,11 @@ export default class ApplicationModule extends Base { * execute, show/close an application as well as listen to application events. * @class */ -export declare class Application extends EmitterBase { +export declare class Application extends EmitterBase { identity: Identity; _manifestUrl?: string; private window; constructor(wire: Transport, identity: Identity); - protected runtimeEventComparator: (listener: RuntimeEvent) => boolean; private windowListFromIdentityList; /** * Determines if the application is currently running. @@ -120,6 +142,12 @@ export declare class Application extends EmitterBase { * @tutorial Application.getShortcuts */ getShortcuts(): Promise; + /** + * Returns the current zoom level of the application. + * @return {Promise.} + * @tutorial Application.getZoomLevel + */ + getZoomLevel(): Promise; /** * Returns an instance of the main Window of the application * @return {Promise.<_Window>} @@ -175,6 +203,14 @@ export declare class Application extends EmitterBase { * @tutorial Application.setShortcuts */ setShortcuts(config: ConfigInterface): Promise; + /** + * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20% + * larger or smaller to default limits of 300% and 50% of original size, respectively. + * @param { number } level The zoom level + * @return {Promise.} + * @tutorial Application.setZoomLevel + */ + setZoomLevel(level: number): Promise; /** * @summary Retrieves information about the system tray. * @desc The only information currently returned is the position and dimensions. @@ -203,21 +239,3 @@ export declare class Application extends EmitterBase { */ getInfo(): Promise; } -export interface Application { - on(type: 'closed', listener: (data: Reply<'application', 'closed'>) => void): Promise; - on(type: 'initialized', listener: (data: Reply<'application', 'initialized'>) => void): Promise; - on(type: 'connected', listener: (data: Reply<'application', 'connected'>) => void): Promise; - on(type: 'crashed', listener: (data: Reply<'application', 'crashed'>) => void): Promise; - on(type: 'error', listener: (data: Reply<'application', 'error'>) => void): Promise; - on(type: 'not-responding', listener: (data: Reply<'application', 'not-responding'>) => void): Promise; - on(type: 'out-of-memory', listener: (data: Reply<'application', 'out-of-memory'>) => void): Promise; - on(type: 'responding', listener: (data: Reply<'application', 'responding'>) => void): Promise; - on(type: 'started', listener: (data: Reply<'application', 'started'>) => void): Promise; - on(type: 'run-requested', listener: (data: Reply<'application', 'run-requested'>) => void): Promise; - on(type: 'window-navigation-rejected', listener: (data: NavigationRejectedReply) => void): Promise; - on(type: 'window-created', listener: (data: Reply<'application', 'window-created'>) => void): Promise; - on(type: 'window-closed', listener: (data: Reply<'application', 'window-closed'>) => void): Promise; - on(type: 'tray-icon-clicked', listener: (data: TrayIconClickReply) => void): Promise; - on(type: 'removeListener', listener: (eventType: string) => void): Promise; - on(type: 'newListener', listener: (eventType: string) => void): Promise; -} diff --git a/types/openfin/_v2/api/base.d.ts b/types/openfin/_v2/api/base.d.ts index 1f17e1f24f..5cbb8658a7 100644 --- a/types/openfin/_v2/api/base.d.ts +++ b/types/openfin/_v2/api/base.d.ts @@ -1,10 +1,11 @@ /// -import Transport, { Message } from '../transport/transport'; +import Transport from '../transport/transport'; import { Identity } from '../identity'; import { EventEmitter } from 'events'; -export interface RuntimeEvent extends Identity { - topic: string; - type: string | symbol; +import { EmitterAccessor } from './events/emitterMap'; +import { BaseEventMap } from './events/base'; +interface SubOptions { + timestamp?: number; } export declare class Base { wire: Transport; @@ -14,26 +15,27 @@ export declare class Base { readonly me: Identity; protected isNodeEnvironment: () => boolean; protected isOpenFinEnvironment: () => boolean; - protected runtimeEventComparator: (listener: RuntimeEvent) => boolean; } -export declare class EmitterBase extends Base { +export declare class EmitterBase extends Base { + private emitterAccessor; protected identity: Identity; - protected emitter: EventEmitter; - listeners: (event: string | symbol) => Function[]; + constructor(wire: Transport, emitterAccessor: EmitterAccessor); + eventNames: () => (string | symbol)[]; + emit: >(eventName: E, payload: E extends Extract ? EventTypes[E] : any, ...args: any[]) => boolean; + private hasEmitter; + private getEmitter; + listeners: (type: string | symbol) => Function[]; listenerCount: (type: string | symbol) => number; - constructor(wire: Transport); - emit: (eventName: string | symbol, ...args: any[]) => void; - protected onmessage: (message: Message) => boolean; - protected registerEventListener: (listener: RuntimeEvent) => Promise>; - protected deregisterEventListener: (listener: RuntimeEvent) => Promise>; - on(eventType: string, listener: (...args: any[]) => void): Promise; - addListener: (eventType: string, listener: (...args: any[]) => void) => Promise; - once(eventType: string, listener: (...args: any[]) => void): Promise; - prependListener(eventType: string, listener: (...args: any[]) => void): Promise; - prependOnceListener(eventType: string, listener: (...args: any[]) => void): Promise; - removeListener(eventType: string, listener: (...args: any[]) => void): Promise; - protected deregisterAllListeners: (eventType: string | symbol) => Promise>; - removeAllListeners(eventType?: string): Promise; + protected registerEventListener: (eventType: string | symbol | Extract, options?: SubOptions) => Promise; + protected deregisterEventListener: (eventType: string | symbol | Extract, options?: SubOptions) => Promise; + on | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise; + addListener: >(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions) => Promise; + once | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise; + prependListener | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise; + prependOnceListener | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise; + removeListener | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise; + protected deregisterAllListeners: (eventType: string | symbol | Extract) => Promise; + removeAllListeners(eventType?: Extract | string | symbol): Promise; } export declare class Reply implements Identity { topic: TOPIC; @@ -41,3 +43,4 @@ export declare class Reply imp uuid: string; name?: string; } +export {}; diff --git a/types/openfin/_v2/api/events/application.d.ts b/types/openfin/_v2/api/events/application.d.ts new file mode 100644 index 0000000000..444d358cbd --- /dev/null +++ b/types/openfin/_v2/api/events/application.d.ts @@ -0,0 +1,56 @@ +import { WindowEvent, BaseEventMap, ApplicationEvent } from './base'; +import { WindowAlertRequestedEvent, WindowAuthRequestedEvent, WindowEndLoadEvent, PropagatedWindowEvents } from './window'; +export interface CrashedEvent { + reason: 'normal-termination' | 'abnormal-termination' | 'killed' | 'crashed' | 'still-running' | 'launch-failed' | 'out-of-memory'; +} +export interface RunRequestedEvent extends ApplicationEvent { + userAppConfigArgs: any; +} +export interface TrayIconClicked extends ApplicationEvent { + button: 0 | 1 | 2; + x: number; + y: number; + monitorInfo: any; +} +export interface ApplicationEventMapping extends BaseEventMap { + 'closed': ApplicationEvent; + 'connected': ApplicationEvent; + 'crashed': CrashedEvent & ApplicationEvent; + 'initialized': ApplicationEvent; + 'manifest-changed': ApplicationEvent; + 'not-responding': ApplicationEvent; + 'responding': ApplicationEvent; + 'run-requested': RunRequestedEvent; + 'started': ApplicationEvent; + 'tray-icon-clicked': TrayIconClicked; + 'window-alert-requested': WindowAlertRequestedEvent; + 'window-auth-requested': WindowAuthRequestedEvent; + 'window-created': WindowEvent; + 'window-end-load': WindowEndLoadEvent; + 'window-not-responding': WindowEvent; + 'window-responding': WindowEvent; + 'window-show-requested': WindowEvent; + 'window-start-load': WindowEvent; +} +export interface PropagatedApplicationEventMapping { + 'application-closed': ApplicationEvent; + 'application-connected': ApplicationEvent; + 'application-crashed': CrashedEvent & ApplicationEvent; + 'application-initialized': ApplicationEvent; + 'application-manifest-changed': ApplicationEvent; + 'application-not-responding': ApplicationEvent; + 'application-responding': ApplicationEvent; + 'application-started': ApplicationEvent; + 'application-tray-icon-clicked': TrayIconClicked; + 'window-created': WindowEvent; + 'window-end-load': WindowEndLoadEvent; + 'window-not-responding': WindowEvent; + 'window-responding': WindowEvent; + 'window-start-load': WindowEvent; +} +export declare type ApplicationEvents = PropagatedWindowEvents<'application'> & { + [Type in keyof ApplicationEventMapping]: ApplicationEventMapping<'application', Type>[Type]; +}; +export declare type PropagatedApplicationEvents = { + [Type in keyof PropagatedApplicationEventMapping]: PropagatedApplicationEventMapping[Type]; +}; diff --git a/types/openfin/_v2/api/events/base.d.ts b/types/openfin/_v2/api/events/base.d.ts new file mode 100644 index 0000000000..700f82679b --- /dev/null +++ b/types/openfin/_v2/api/events/base.d.ts @@ -0,0 +1,18 @@ +import { FrameEvent } from './frame'; +export declare type RuntimeEvent = Topic extends 'window' ? WindowEvent : Topic extends 'frame' ? FrameEvent : Topic extends 'application' ? ApplicationEvent : BaseEvent; +export interface BaseEvent { + topic: Topic; + type: Type; +} +export interface ApplicationEvent extends BaseEvent { + uuid: string; +} +export interface WindowEvent extends ApplicationEvent { + name: string; +} +export declare function getTopic(e: RuntimeEvent): string; +export interface BaseEventMap { + [name: string]: any; + 'newListener': string; + 'listenerRemoved': string; +} diff --git a/types/openfin/_v2/api/events/channel.d.ts b/types/openfin/_v2/api/events/channel.d.ts new file mode 100644 index 0000000000..3c448071cb --- /dev/null +++ b/types/openfin/_v2/api/events/channel.d.ts @@ -0,0 +1,10 @@ +import { BaseEventMap, ApplicationEvent } from './base'; +export interface ChannelEvent extends ApplicationEvent<'channel', Type> { + channelName: string; + channelId: string; + name?: string; +} +export interface ChannelEvents extends BaseEventMap { + 'connected': ChannelEvent<'connected'>; + 'disconnected': ChannelEvent<'disconnected'>; +} diff --git a/types/openfin/_v2/api/events/emitterMap.d.ts b/types/openfin/_v2/api/events/emitterMap.d.ts new file mode 100644 index 0000000000..aa3fb498e8 --- /dev/null +++ b/types/openfin/_v2/api/events/emitterMap.d.ts @@ -0,0 +1,15 @@ +/// +import { EventEmitter } from 'events'; +export declare class EmitterMap { + private storage; + constructor(); + private hashKeys; + get(keys: EmitterAccessor): EventEmitter; + has(keys: EmitterAccessor): boolean; + delete(keys: EmitterAccessor): boolean; +} +export declare type SystemEmitterAccessor = ['system']; +export declare type ApplicationEmitterAccessor = ['application', string]; +export declare type WindowEmitterAccessor = ['window', string, string]; +export declare type HotkeyEmitterAccessor = ['global-hotkey']; +export declare type EmitterAccessor = SystemEmitterAccessor | ApplicationEmitterAccessor | WindowEmitterAccessor | HotkeyEmitterAccessor | string[]; diff --git a/types/openfin/_v2/api/events/eventAggregator.d.ts b/types/openfin/_v2/api/events/eventAggregator.d.ts new file mode 100644 index 0000000000..ac7b7ca1b2 --- /dev/null +++ b/types/openfin/_v2/api/events/eventAggregator.d.ts @@ -0,0 +1,5 @@ +import { Message } from '../../transport/transport'; +import { EmitterMap } from './emitterMap'; +export declare class EventAggregator extends EmitterMap { + dispatchEvent: (message: Message) => boolean; +} diff --git a/types/openfin/_v2/api/events/externalApplication.d.ts b/types/openfin/_v2/api/events/externalApplication.d.ts new file mode 100644 index 0000000000..f7cd85f45d --- /dev/null +++ b/types/openfin/_v2/api/events/externalApplication.d.ts @@ -0,0 +1,5 @@ +import { RuntimeEvent, BaseEventMap } from './base'; +export interface ExternalApplicationEvents extends BaseEventMap { + connected: RuntimeEvent<'externalapplication', 'connected'>; + disconnected: RuntimeEvent<'externalapplication', 'disconnected'>; +} diff --git a/types/openfin/_v2/api/events/frame.d.ts b/types/openfin/_v2/api/events/frame.d.ts new file mode 100644 index 0000000000..c31933e557 --- /dev/null +++ b/types/openfin/_v2/api/events/frame.d.ts @@ -0,0 +1,9 @@ +import { BaseEventMap, WindowEvent } from './base'; +export interface FrameEvent extends WindowEvent<'frame', Type> { + entityType: 'iframe'; + frameName: string; +} +export interface FrameEvents extends BaseEventMap { + connected: FrameEvent<'connected'>; + disconnected: FrameEvent<'disconnected'>; +} diff --git a/types/openfin/_v2/api/events/globalHotkey.d.ts b/types/openfin/_v2/api/events/globalHotkey.d.ts new file mode 100644 index 0000000000..561baba446 --- /dev/null +++ b/types/openfin/_v2/api/events/globalHotkey.d.ts @@ -0,0 +1,11 @@ +import { RuntimeEvent, BaseEventMap } from './base'; +import { Identity } from '../../identity'; +import { nonHotkeyEvents } from '../global-hotkey'; +export interface GlobalHotkeyEvent extends RuntimeEvent<'global-hotkey', Type> { + identity: Identity; + hotkey: string; +} +export interface GlobalHotkeyEvents extends BaseEventMap { + [nonHotkeyEvents.REGISTERED]: GlobalHotkeyEvent; + [nonHotkeyEvents.UNREGISTERED]: GlobalHotkeyEvent; +} diff --git a/types/openfin/_v2/api/events/notifications.d.ts b/types/openfin/_v2/api/events/notifications.d.ts new file mode 100644 index 0000000000..a269817222 --- /dev/null +++ b/types/openfin/_v2/api/events/notifications.d.ts @@ -0,0 +1,8 @@ +import { RuntimeEvent, BaseEventMap } from './base'; +export interface NotificationEvents extends BaseEventMap { + show: RuntimeEvent<'notification', 'show'>; + close: RuntimeEvent<'notification', 'close'>; + error: RuntimeEvent<'notification', 'error'>; + click: RuntimeEvent<'notification', 'click'>; + message: RuntimeEvent<'notification', 'message'>; +} diff --git a/types/openfin/_v2/api/events/system.d.ts b/types/openfin/_v2/api/events/system.d.ts new file mode 100644 index 0000000000..20285a8862 --- /dev/null +++ b/types/openfin/_v2/api/events/system.d.ts @@ -0,0 +1,22 @@ +import { BaseEvent, ApplicationEvent, BaseEventMap } from './base'; +import { MonitorInfo } from '../system/monitor'; +import { PropagatedWindowEvents } from './window'; +import { PropagatedApplicationEvents } from './application'; +export interface IdleEvent extends BaseEvent { + elapsedTime: number; + isIdle: boolean; +} +export declare type MonitorEvent = MonitorInfo & BaseEvent; +export interface SessionChangedEvent extends BaseEvent { + reason: 'lock' | 'unlock' | 'remote-connect' | 'remote-disconnect' | 'unknown'; +} +export interface SystemEventMapping extends BaseEventMap { + 'application-created': ApplicationEvent; + 'desktop-icon-clicked': ApplicationEvent; + 'idle-state-changed': IdleEvent; + 'monitor-info-changed': MonitorEvent; + 'session-changed': SessionChangedEvent; +} +export declare type SystemEvents = PropagatedWindowEvents<'system'> & PropagatedApplicationEvents<'system'> & { + [Type in keyof SystemEventMapping]: SystemEventMapping<'system', Type>[Type]; +}; diff --git a/types/openfin/_v2/api/events/window.d.ts b/types/openfin/_v2/api/events/window.d.ts new file mode 100644 index 0000000000..85d4d553f0 --- /dev/null +++ b/types/openfin/_v2/api/events/window.d.ts @@ -0,0 +1,176 @@ +import { CrashedEvent } from './application'; +import { WindowEvent, BaseEventMap } from './base'; +export declare type SpecificWindowEvent = WindowEvent<'window', Type>; +export interface WindowAlertRequestedEvent extends WindowEvent { + message: string; + url: string; +} +export interface WindowAuthRequestedEvent extends WindowEvent { + authInfo: { + host: string; + isProxy: boolean; + port: number; + realm: string; + scheme: string; + }; +} +export interface WindowEndLoadEvent extends WindowEvent { + documentName: string; + isMain: boolean; +} +export interface WindowNavigationRejectedEvent extends WindowEvent { + sourceName: string; + url: string; +} +export interface WindowReloadedEvent extends WindowEvent { + url: string; +} +export interface WindowExternalProcessExitedEvent extends WindowEvent { + processUuid: string; + exitCode: number; +} +export interface WindowExternalProcessStartedEvent extends WindowEvent { + processUuid: string; +} +export interface WindowHiddenEvent extends WindowEvent { + reason: 'closing' | 'hide' | 'hide-on-close'; +} +export interface PreloadScriptInfoRunning { + state: 'load-started' | // started loading preload script + 'load-failed' | // preload script failed to load + 'load-succeeded' | // preload script is loaded and ready to be eval'ed + 'failed' | // preload script failed to eval + 'succeeded'; +} +export interface PreloadScriptInfo { + state: 'load-failed' | // preload script failed to load + 'failed' | // preload script failed to eval + 'succeeded'; +} +export interface WindowPreloadScriptsStateChangeEvent extends WindowEvent { + preloadScripts: (PreloadScriptInfoRunning & any)[]; +} +export interface WindowPreloadScriptsStateChangedEvent extends WindowEvent { + preloadScripts: (PreloadScriptInfoRunning & any)[]; +} +export interface WindowPreloadScriptsStateChangedEvent extends WindowEvent { + preloadScripts: (PreloadScriptInfo & any)[]; +} +export interface WindowResourceLoadFailedEvent extends WindowEvent { + errorCode: number; + errorDescription: string; + validatedURL: string; + isMainFrame: boolean; +} +export interface WindowResourceResponseReceivedEvent extends WindowEvent { + status: boolean; + newUrl: string; + originalUrl: string; + httpResponseCode: number; + requestMethod: string; + referrer: string; + headers: any; + resourceType: 'mainFrame' | 'subFrame' | 'styleSheet' | 'script' | 'image' | 'object' | 'xhr' | 'other'; +} +export interface WindowBeginBoundsChangingEvent extends WindowEvent { + height: number; + left: number; + top: number; + width: number; + windowState: 'minimized' | 'normal' | 'maximized'; +} +export interface WindowBoundsChange extends WindowEvent { + changeType: 0 | 1 | 2; + deferred: boolean; + height: number; + left: number; + top: number; + width: number; +} +export interface WindowGroupChanged extends WindowEvent { + memberOf: 'source' | 'target' | 'nothing'; + reason: 'leave' | 'join' | 'merge' | 'disband'; + sourceGroup: { + appUuid: string; + windowName: string; + }[]; + sourceWindowAppUuid: string; + sourceWindowName: string; + targetGroup: { + appUuid: string; + windowName: string; + }[]; + targetWindowAppUuid: string; + targetWindowName: string; +} +export interface WindowEventMapping extends BaseEventMap { + 'auth-requested': WindowAuthRequestedEvent; + 'begin-user-bounds-changing': WindowBeginBoundsChangingEvent; + 'blurred': WindowEvent; + 'bounds-changed': WindowBoundsChange; + 'bounds-changing': WindowBoundsChange; + 'close-requested': WindowEvent; + 'closed': WindowEvent; + 'closing': WindowEvent; + 'crashed': CrashedEvent & WindowEvent; + 'disabled-frame-bounds-changed': WindowBoundsChange; + 'disabled-frame-bounds-changing': WindowBoundsChange; + 'embedded': WindowEvent; + 'end-user-bounds-changing': WindowBeginBoundsChangingEvent; + 'external-process-exited': WindowExternalProcessExitedEvent; + 'external-process-started': WindowExternalProcessStartedEvent; + 'focused': WindowEvent; + 'frame-disabled': WindowEvent; + 'frame-enabled': WindowEvent; + 'group-changed': WindowGroupChanged; + 'hidden': WindowHiddenEvent; + 'initialized': WindowEvent; + 'maximized': WindowEvent; + 'minimized': WindowEvent; + 'navigation-rejected': WindowNavigationRejectedEvent; + 'preload-scripts-state-changed': WindowPreloadScriptsStateChangeEvent; + 'preload-scripts-state-changing': WindowPreloadScriptsStateChangeEvent; + 'resource-load-failed': WindowResourceLoadFailedEvent; + 'resource-response-received': WindowResourceResponseReceivedEvent; + 'reloaded': WindowReloadedEvent; + 'restored': WindowEvent; + 'show-requested': WindowEvent; + 'shown': WindowEvent; +} +export interface PropagatedWindowEventMapping extends BaseEventMap { + 'window-begin-user-bounds-changing': WindowBeginBoundsChangingEvent; + 'window-blurred': WindowEvent; + 'window-bounds-changed': WindowBoundsChange; + 'window-bounds-changing': WindowBoundsChange; + 'window-closed': WindowEvent; + 'window-closing': WindowEvent; + 'window-crashed': CrashedEvent & WindowEvent; + 'window-disabled-frame-bounds-changed': WindowBoundsChange; + 'window-disabled-frame-bounds-changing': WindowBoundsChange; + 'window-embedded': WindowEvent; + 'window-end-user-bounds-changing': WindowBeginBoundsChangingEvent; + 'window-external-process-exited': WindowExternalProcessExitedEvent; + 'window-external-process-started': WindowExternalProcessStartedEvent; + 'window-focused': WindowEvent; + 'window-frame-disabled': WindowEvent; + 'window-frame-enabled': WindowEvent; + 'window-group-changed': WindowGroupChanged; + 'window-hidden': WindowHiddenEvent; + 'window-initialized': WindowEvent; + 'window-maximized': WindowEvent; + 'window-minimized': WindowEvent; + 'window-navigation-rejected': WindowNavigationRejectedEvent; + 'window-preload-scripts-state-changed': WindowPreloadScriptsStateChangeEvent; + 'window-preload-scripts-state-changing': WindowPreloadScriptsStateChangedEvent; + 'window-resource-load-failed': WindowResourceLoadFailedEvent; + 'window-resource-response-received': WindowResourceResponseReceivedEvent; + 'window-reloaded': WindowReloadedEvent; + 'window-restored': WindowEvent; + 'window-shown': WindowEvent; +} +export declare type WindowEvents = { + [Type in keyof WindowEventMapping]: WindowEventMapping<'window', Type>[Type]; +}; +export declare type PropagatedWindowEvents = { + [Type in keyof PropagatedWindowEventMapping]: PropagatedWindowEventMapping[Type]; +}; diff --git a/types/openfin/_v2/api/external-application/external-application.d.ts b/types/openfin/_v2/api/external-application/external-application.d.ts index 2d1f46e0f3..a4f44851e9 100644 --- a/types/openfin/_v2/api/external-application/external-application.d.ts +++ b/types/openfin/_v2/api/external-application/external-application.d.ts @@ -1,16 +1,30 @@ -import { Base, EmitterBase, Reply } from '../base'; +import { Base, EmitterBase } from '../base'; import { Identity } from '../../identity'; import Transport from '../../transport/transport'; +import { ExternalApplicationEvents } from '../events/externalApplication'; export interface ExternalApplicationInfo { parent: Identity; } +/** + * @lends ExternalApplication + */ export default class ExternalApplicationModule extends Base { /** - * Returns an External Application object that represents an existing external application. + * Asynchronously returns an External Application object that represents an existing external application. * @param {string} uuid The UUID of the external application to be wrapped * @return {Promise.} + * @tutorial ExternalApplication.wrap + * @static */ wrap(uuid: string): Promise; + /** + * Synchronously returns an External Application object that represents an existing external application. + * @param {string} uuid The UUID of the external application to be wrapped + * @return {ExternalApplication} + * @tutorial ExternalApplication.wrapSync + * @static + */ + wrapSync(uuid: string): ExternalApplication; } /** * @classdesc An ExternalApplication object representing an application. Allows @@ -18,7 +32,7 @@ export default class ExternalApplicationModule extends Base { * well as listen to application events. * @class */ -export declare class ExternalApplication extends EmitterBase { +export declare class ExternalApplication extends EmitterBase { identity: Identity; constructor(wire: Transport, identity: Identity); /** @@ -28,9 +42,3 @@ export declare class ExternalApplication extends EmitterBase { */ getInfo(): Promise; } -export interface ExternalApplication { - on(type: 'connected', listener: (data: Reply<'externalapplication', 'connected'>) => void): Promise; - on(type: 'disconnected', listener: (data: Reply<'externalapplication', 'disconnected'>) => void): Promise; - on(type: 'removeListener', listener: (eventType: string) => void): Promise; - on(type: 'newListener', listener: (eventType: string) => void): Promise; -} diff --git a/types/openfin/_v2/api/frame/frame.d.ts b/types/openfin/_v2/api/frame/frame.d.ts index 4a5ab971de..8795ae190b 100644 --- a/types/openfin/_v2/api/frame/frame.d.ts +++ b/types/openfin/_v2/api/frame/frame.d.ts @@ -1,6 +1,7 @@ import { Base, EmitterBase } from '../base'; import { Identity } from '../../identity'; import Transport from '../../transport/transport'; +import { FrameEvents } from '../events/frame'; export declare type EntityType = 'window' | 'iframe' | 'external connection' | 'unknown'; export interface FrameInfo { uuid: string; @@ -8,19 +9,40 @@ export interface FrameInfo { entityType: EntityType; parent: Identity; } +/** + * @lends Frame + */ export default class _FrameModule extends Base { /** - * Gets a reference to the specified frame. The frame does not have to exist - * @param {string} uuid - uuid of the frame you want to wrap - * @param {string} name - name of the frame you want to wrap + * Asynchronously returns a reference to the specified frame. The frame does not have to exist + * @param {Identity} identity - the identity of the frame you want to wrap * @return {Promise.<_Frame>} + * @tutorial Frame.wrap + * @static */ - wrap(uuid: string, name: string): Promise<_Frame>; + wrap(identity: Identity): Promise<_Frame>; /** - * Get a reference to the current frame + * Synchronously returns a reference to the specified frame. The frame does not have to exist + * @param {Identity} identity - the identity of the frame you want to wrap + * @return {_Frame} + * @tutorial Frame.wrapSync + * @static + */ + wrapSync(identity: Identity): _Frame; + /** + * Asynchronously returns a reference to the current frame * @return {Promise.<_Frame>} + * @tutorial Frame.getCurrent + * @static */ getCurrent(): Promise<_Frame>; + /** + * Synchronously returns a reference to the current frame + * @return {_Frame} + * @tutorial Frame.getCurrentSync + * @static + */ + getCurrentSync(): _Frame; } /** * @classdesc Represents a way to interact with `iframes`. Facilitates discovery of current context @@ -28,7 +50,7 @@ export default class _FrameModule extends Base { * @class * @alias Frame */ -export declare class _Frame extends EmitterBase { +export declare class _Frame extends EmitterBase { identity: Identity; constructor(wire: Transport, identity: Identity); /** @@ -45,7 +67,3 @@ export declare class _Frame extends EmitterBase { */ getParentWindow(): Promise; } -export interface _Frame { - on(type: 'connected', listener: (eventType: string) => void): Promise; - on(type: 'disconnected', listener: (eventType: string) => void): Promise; -} diff --git a/types/openfin/_v2/api/global-hotkey/index.d.ts b/types/openfin/_v2/api/global-hotkey/index.d.ts index 148ddff7e9..7aa08d6f20 100644 --- a/types/openfin/_v2/api/global-hotkey/index.d.ts +++ b/types/openfin/_v2/api/global-hotkey/index.d.ts @@ -1,10 +1,15 @@ import { EmitterBase } from '../base'; import Transport from '../../transport/transport'; +import { GlobalHotkeyEvents } from '../events/globalHotkey'; +export declare const enum nonHotkeyEvents { + REGISTERED = "registered", + UNREGISTERED = "unregistered" +} /** * The GlobalHotkey module can register/unregister a global hotkeys. * @namespace */ -export default class GlobalHotkey extends EmitterBase { +export default class GlobalHotkey extends EmitterBase { constructor(wire: Transport); /** * Registers a global hotkey with the operating system. diff --git a/types/openfin/_v2/api/interappbus/channel/index.d.ts b/types/openfin/_v2/api/interappbus/channel/index.d.ts index 1297d2c5ea..2b2d963932 100644 --- a/types/openfin/_v2/api/interappbus/channel/index.d.ts +++ b/types/openfin/_v2/api/interappbus/channel/index.d.ts @@ -4,30 +4,29 @@ import { ChannelProvider } from './provider'; import { EmitterBase } from '../../base'; import Transport, { Message, Payload } from '../../../transport/transport'; import { ProviderIdentity } from './channel'; -export interface Options { +import { ChannelEvents } from '../../events/channel'; +export interface ConnectOptions { wait?: boolean; - uuid: string; - name?: string; payload?: any; } export interface ChannelPayload { payload: Payload; } -export interface ChannelMessage { +export interface ChannelMessage extends Message { senderIdentity: Identity; ackToSender: any; - providerIdentity: Identity; + providerIdentity: ProviderIdentity; connectAction: boolean; } -export declare class Channel extends EmitterBase { +export declare class Channel extends EmitterBase { private channelMap; constructor(wire: Transport); getAllChannels(): Promise; - onChannelConnect(listener: Function): Promise; - onChannelDisconnect(listener: Function): Promise; - connect(options: Options): Promise; - create(channelName?: string): Promise; - onmessage: (msg: Message) => boolean; + onChannelConnect(listener: (...args: any[]) => void): Promise; + onChannelDisconnect(listener: (...args: any[]) => void): Promise; + connect(channelName: string, options?: ConnectOptions): Promise; + create(channelName: string): Promise; + onmessage: (msg: ChannelMessage) => boolean; private processChannelMessage; private processChannelConnection; } diff --git a/types/openfin/_v2/api/interappbus/channel/provider.d.ts b/types/openfin/_v2/api/interappbus/channel/provider.d.ts index a869928ac2..4b978c2781 100644 --- a/types/openfin/_v2/api/interappbus/channel/provider.d.ts +++ b/types/openfin/_v2/api/interappbus/channel/provider.d.ts @@ -1,13 +1,15 @@ import { ChannelBase, ProviderIdentity } from './channel'; import Transport from '../../../transport/transport'; -export declare type ConnectionListener = (adapterIdentity: ProviderIdentity, connectionMessage?: any) => any; +import { Identity } from '../../../main'; +export declare type ConnectionListener = (identity: Identity, connectionMessage?: any) => any; export declare class ChannelProvider extends ChannelBase { private connectListener; private disconnectListener; - connections: ProviderIdentity[]; + connections: Identity[]; constructor(providerIdentity: ProviderIdentity, send: Transport['sendAction']); - dispatch(to: ProviderIdentity, action: string, payload: any): Promise; - processConnection(senderId: ProviderIdentity, payload: any): Promise; + dispatch(to: Identity, action: string, payload: any): Promise; + processConnection(senderId: Identity, payload: any): Promise; publish(action: string, payload: any): Promise[]; onConnection(listener: ConnectionListener): void; + onDisconnection(listener: ConnectionListener): void; } diff --git a/types/openfin/_v2/api/notification/notification.d.ts b/types/openfin/_v2/api/notification/notification.d.ts index 8deec180ba..9a6bee7076 100644 --- a/types/openfin/_v2/api/notification/notification.d.ts +++ b/types/openfin/_v2/api/notification/notification.d.ts @@ -1,6 +1,7 @@ import { Base, EmitterBase } from '../base'; import { Identity } from '../../identity'; import Transport from '../../transport/transport'; +import { NotificationEvents } from '../events/notifications'; export declare class NotificationOptions { url: string; message: string; @@ -22,14 +23,12 @@ export interface NotificationCallback { * @class * @alias Notification */ -export declare class _Notification extends EmitterBase { +export declare class _Notification extends EmitterBase { private listenerList; private unhookAllListeners; - private buildLocalPayload; protected options: NotificationOptions; protected generalListener: (msg: any) => void; protected notificationId: number; - protected onmessage: (message: any) => boolean; constructor(wire: Transport, options: NotificationOptions); url: string; timeout: number | string; diff --git a/types/openfin/_v2/api/system/system.d.ts b/types/openfin/_v2/api/system/system.d.ts index 8c0bc7d3b6..31ed091619 100644 --- a/types/openfin/_v2/api/system/system.d.ts +++ b/types/openfin/_v2/api/system/system.d.ts @@ -19,6 +19,7 @@ import { RegistryInfo } from './registry-info'; import { DownloadPreloadOption, DownloadPreloadInfo } from './download-preload'; import { ClearCacheOption } from './clearCacheOption'; import { CrashReporterOption } from './crashReporterOption'; +import { SystemEvents } from '../events/system'; /** * AppAssetInfo interface * @typedef { Object } AppAssetInfo @@ -164,7 +165,7 @@ import { CrashReporterOption } from './crashReporterOption'; * clearing the cache and exiting the runtime. * @namespace */ -export default class System extends EmitterBase { +export default class System extends EmitterBase { constructor(wire: Transport); /** * Returns the version of the runtime. The version contains the major, minor, @@ -224,13 +225,6 @@ export default class System extends EmitterBase { * @tutorial System.getCrashReporterState */ getCrashReporterState(): Promise; - /** - * Returns a unique identifier (UUID) for the machine (SHA256 hash of the system's MAC address). - * This call will return the same value on subsequent calls on the same machine(host). - * The values will be different on different machines, and should be considered globally unique. - * @return {Promise.} - * @tutorial System.getDeviceId - */ getDeviceId(): Promise; /** * Start the crash reporter for the browser process if not already running. @@ -275,6 +269,12 @@ export default class System extends EmitterBase { * @tutorial System.getLog */ getLog(options: GetLogRequestType): Promise; + /** + * Returns a unique identifier (UUID) provided by the machine. + * @return {Promise.} + * @tutorial System.getMachineId + */ + getMachineId(): Promise; /** * Returns the minimum (inclusive) logging level that is currently being written to the log. * @return {Promise.} diff --git a/types/openfin/_v2/api/window/window.d.ts b/types/openfin/_v2/api/window/window.d.ts index 8d597a6446..ff89a89051 100644 --- a/types/openfin/_v2/api/window/window.d.ts +++ b/types/openfin/_v2/api/window/window.d.ts @@ -1,32 +1,52 @@ -import { Base, EmitterBase, RuntimeEvent } from '../base'; +import { Base, EmitterBase } from '../base'; import { Identity } from '../../identity'; import Bounds from './bounds'; -import BoundsChangedReply from './bounds-changed'; import { Transition, TransitionOptions } from './transition'; import { Application } from '../application/application'; import Transport from '../../transport/transport'; +import { WindowEvents } from '../events/window'; +/** + * @lends Window + */ export default class _WindowModule extends Base { - private instance; /** - * Returns a Window object that represents an existing window. - * @param { Identity } indentity + * Asynchronously returns a Window object that represents an existing window. + * @param { Identity } identity * @return {Promise.<_Window>} * @tutorial Window.wrap + * @static */ wrap(identity: Identity): Promise<_Window>; + /** + * Synchronously returns a Window object that represents an existing window. + * @param { Identity } identity + * @return {_Window} + * @tutorial Window.wrapSync + * @static + */ + wrapSync(identity: Identity): _Window; /** * Creates a new Window. * @param { * } options - Window creation options * @return {Promise.<_Window>} * @tutorial Window.create + * @static */ create(options: any): Promise<_Window>; /** - * Returns a Window object that represents the current window - * @return {Promise.} - * @tutorial window.getCurrent + * Asynchronously returns a Window object that represents the current window + * @return {Promise.<_Window>} + * @tutorial Window.getCurrent + * @static */ getCurrent(): Promise<_Window>; + /** + * Synchronously returns a Window object that represents the current window + * @return {_Window} + * @tutorial Window.getCurrentSync + * @static + */ + getCurrentSync(): _Window; } export interface CloseEventShape { name: string; @@ -47,6 +67,19 @@ export interface FrameInfo { entityType: string; parent?: Identity; } +export interface Area { + height: number; + width: number; + x: number; + y: number; +} +/** + * @typedef { Object } Area + * @property { number } height Area's height + * @property { number } width Area's width + * @property { number } x X coordinate of area's starting point + * @property { number } y Y coordinate of area's starting point + */ /** * @typedef {object} Transition * @property {Opacity} opacity - The Opacity transition @@ -98,7 +131,7 @@ this animation onto the end of the animation queue. * @class * @alias Window */ -export declare class _Window extends EmitterBase { +export declare class _Window extends EmitterBase { identity: Identity; /** * Raised when a window within this application requires credentials from the user. @@ -425,10 +458,8 @@ export declare class _Window extends EmitterBase { * @property {string} state - The preload script state: "load-failed", "failed", "succeeded" */ - private nativeWindow; constructor(wire: Transport, identity: Identity); createWindow(options: any): Promise<_Window>; - protected runtimeEventComparator: (listener: RuntimeEvent) => boolean; private windowListFromNameList; /** * Retrieves an array of frame info objects representing the main frame and any @@ -443,12 +474,6 @@ export declare class _Window extends EmitterBase { * @tutorial Window.getBounds */ getBounds(): Promise; - /** - * Returns the native JavaScript "window" object for the window. - * @return {Promise.} - * @tutorial Window.getNativeWindow - */ - getNativeWindow(): Promise; /** * Gives focus to the window. * @return {Promise.} @@ -561,11 +586,13 @@ export declare class _Window extends EmitterBase { */ getParentWindow(): Promise<_Window>; /** - * Gets a base64 encoded PNG snapshot of the window. + * Gets a base64 encoded PNG snapshot of the window or just part a of it. + * @param { Area } [area] The area of the window to be captured. + * Omitting it will capture the whole visible window. * @return {Promise.} * @tutorial Window.getSnapshot */ - getSnapshot(): Promise; + getSnapshot(area?: Area): Promise; /** * Gets the current state ("minimized", "maximized", or "restored") of the window. * @return {Promise.} @@ -747,13 +774,3 @@ export declare class _Window extends EmitterBase { */ stopNavigation(): Promise; } -export interface _Window { - on(type: 'focused', listener: Function): Promise; - on(type: 'initialized', listener: Function): Promise; - on(type: 'bounds-changed', listener: (data: BoundsChangedReply) => void): Promise; - on(type: 'hidden', listener: Function): Promise; - on(type: 'removeListener', listener: (eventType: string | symbol) => void): Promise; - on(type: 'newListener', listener: (eventType: string | symbol) => void): Promise; - on(type: 'closed', listener: (eventType: CloseEventShape) => void): Promise; - on(type: 'fire-constructor-callback', listener: Function): Promise; -} diff --git a/types/openfin/_v2/transport/transport.d.ts b/types/openfin/_v2/transport/transport.d.ts index fb7b967240..519562de95 100644 --- a/types/openfin/_v2/transport/transport.d.ts +++ b/types/openfin/_v2/transport/transport.d.ts @@ -3,6 +3,8 @@ import { Wire, WireConstructor, READY_STATE, ExistingConnectConfig, ConnectConfi import { Identity } from '../identity'; import { EventEmitter } from 'events'; import { Environment } from '../environment/environment'; +import { RuntimeEvent } from '../api/events/base'; +import { EventAggregator } from '../api/events/eventAggregator'; export declare type MessageHandler = (data: any) => boolean; declare class Transport extends EventEmitter { protected wireListeners: Map; protected uncorrelatedListener: Function; - protected messageHandlers: MessageHandler[]; me: Identity; protected wire: Wire; environment: Environment; topicRefMap: Map; sendRaw: Wire['send']; + eventAggregator: EventAggregator; + protected messageHandlers: MessageHandler[]; constructor(wireType: WireConstructor, environment: Environment); connectSync: (config: ConnectConfig) => any; connect(config: InternalConnectConfig): Promise; @@ -38,6 +41,20 @@ export declare class Message { payload: T; correlationId?: number; } +export declare class EventMessage implements Message { + action: 'process-desktop-event'; + payload: RuntimeEvent; +} +export declare class NotificationEventMessage implements Message { + action: 'process-notification-event'; + payload: NotificationEvent; +} +export interface NotificationEvent { + payload: { + notificationId: string; + }; + type: string | symbol; +} export declare class Payload { success: boolean; data: any; diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts index fe34f0b630..a901fecdc9 100644 --- a/types/openfin/index.d.ts +++ b/types/openfin/index.d.ts @@ -1,12 +1,13 @@ -// Type definitions for OpenFin API 34.0 +// Type definitions for OpenFin API 37.0 // Project: https://openfin.co/ // Definitions by: Chris Barker // Ricardo de Pena // Roma +// Li Cui // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 -// based on v9.61.34.22 +// based on v9.61.37.14 // see https://openfin.co/support/technical-faq/#what-do-the-numbers-in-the-runtime-version-mean /**