update v2 to latest

This commit is contained in:
licui
2018-10-26 15:40:51 -04:00
parent 2bf22171c7
commit be48833bf9
23 changed files with 545 additions and 123 deletions
+42 -24
View File
@@ -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.<Application>}
* @tutorial Application.wrap
* @static
*/
wrap(identity: Identity): Promise<Application>;
/**
* 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.<Application>}
* @tutorial Application.create
* @static
*/
create(appOptions: any): Promise<Application>;
/**
* Returns an Application object that represents the current application
* Asynchronously returns an Application object that represents the current application
* @return {Promise.<Application>}
* @tutorial Application.getCurrent
* @static
*/
getCurrent(): Promise<Application>;
/**
* 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.<Application>}
* @tutorial Application.createFromManifest
* @static
*/
createFromManifest(manifestUrl: string): Promise<Application>;
}
@@ -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<ApplicationEvents> {
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<ConfigInterface>;
/**
* Returns the current zoom level of the application.
* @return {Promise.<number>}
* @tutorial Application.getZoomLevel
*/
getZoomLevel(): Promise<number>;
/**
* 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<void>;
/**
* 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.<void>}
* @tutorial Application.setZoomLevel
*/
setZoomLevel(level: number): Promise<void>;
/**
* @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<ApplicationInfo>;
}
export interface Application {
on(type: 'closed', listener: (data: Reply<'application', 'closed'>) => void): Promise<void>;
on(type: 'initialized', listener: (data: Reply<'application', 'initialized'>) => void): Promise<void>;
on(type: 'connected', listener: (data: Reply<'application', 'connected'>) => void): Promise<void>;
on(type: 'crashed', listener: (data: Reply<'application', 'crashed'>) => void): Promise<void>;
on(type: 'error', listener: (data: Reply<'application', 'error'>) => void): Promise<void>;
on(type: 'not-responding', listener: (data: Reply<'application', 'not-responding'>) => void): Promise<void>;
on(type: 'out-of-memory', listener: (data: Reply<'application', 'out-of-memory'>) => void): Promise<void>;
on(type: 'responding', listener: (data: Reply<'application', 'responding'>) => void): Promise<void>;
on(type: 'started', listener: (data: Reply<'application', 'started'>) => void): Promise<void>;
on(type: 'run-requested', listener: (data: Reply<'application', 'run-requested'>) => void): Promise<void>;
on(type: 'window-navigation-rejected', listener: (data: NavigationRejectedReply) => void): Promise<void>;
on(type: 'window-created', listener: (data: Reply<'application', 'window-created'>) => void): Promise<void>;
on(type: 'window-closed', listener: (data: Reply<'application', 'window-closed'>) => void): Promise<void>;
on(type: 'tray-icon-clicked', listener: (data: TrayIconClickReply) => void): Promise<void>;
on(type: 'removeListener', listener: (eventType: string) => void): Promise<void>;
on(type: 'newListener', listener: (eventType: string) => void): Promise<void>;
}
+24 -21
View File
@@ -1,10 +1,11 @@
/// <reference types="node" />
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<EventTypes extends BaseEventMap> extends Base {
private emitterAccessor;
protected identity: Identity;
protected emitter: EventEmitter;
listeners: (event: string | symbol) => Function[];
constructor(wire: Transport, emitterAccessor: EmitterAccessor);
eventNames: () => (string | symbol)[];
emit: <E extends string | symbol | Extract<keyof EventTypes, string>>(eventName: E, payload: E extends Extract<keyof EventTypes, string> ? 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<any>) => boolean;
protected registerEventListener: (listener: RuntimeEvent) => Promise<void | Message<void>>;
protected deregisterEventListener: (listener: RuntimeEvent) => Promise<void | Message<void>>;
on(eventType: string, listener: (...args: any[]) => void): Promise<void>;
addListener: (eventType: string, listener: (...args: any[]) => void) => Promise<void>;
once(eventType: string, listener: (...args: any[]) => void): Promise<void>;
prependListener(eventType: string, listener: (...args: any[]) => void): Promise<void>;
prependOnceListener(eventType: string, listener: (...args: any[]) => void): Promise<void>;
removeListener(eventType: string, listener: (...args: any[]) => void): Promise<void>;
protected deregisterAllListeners: (eventType: string | symbol) => Promise<void | Message<void>>;
removeAllListeners(eventType?: string): Promise<void>;
protected registerEventListener: (eventType: string | symbol | Extract<keyof EventTypes, string>, options?: SubOptions) => Promise<EventEmitter>;
protected deregisterEventListener: (eventType: string | symbol | Extract<keyof EventTypes, string>, options?: SubOptions) => Promise<void | EventEmitter>;
on<E extends Extract<keyof EventTypes, string> | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise<this>;
addListener: <E extends string | symbol | Extract<keyof EventTypes, string>>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions) => Promise<this>;
once<E extends Extract<keyof EventTypes, string> | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise<this>;
prependListener<E extends Extract<keyof EventTypes, string> | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise<this>;
prependOnceListener<E extends Extract<keyof EventTypes, string> | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise<this>;
removeListener<E extends Extract<keyof EventTypes, string> | string | symbol>(eventType: E, listener: (payload: E extends keyof EventTypes ? EventTypes[E] : any, ...args: any[]) => void, options?: SubOptions): Promise<this>;
protected deregisterAllListeners: (eventType: string | symbol | Extract<keyof EventTypes, string>) => Promise<void | EventEmitter>;
removeAllListeners(eventType?: Extract<keyof EventTypes, string> | string | symbol): Promise<this>;
}
export declare class Reply<TOPIC extends string, TYPE extends string | void> implements Identity {
topic: TOPIC;
@@ -41,3 +43,4 @@ export declare class Reply<TOPIC extends string, TYPE extends string | void> imp
uuid: string;
name?: string;
}
export {};
+56
View File
@@ -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<Topic, Type> extends ApplicationEvent<Topic, Type> {
userAppConfigArgs: any;
}
export interface TrayIconClicked<Topic, Type> extends ApplicationEvent<Topic, Type> {
button: 0 | 1 | 2;
x: number;
y: number;
monitorInfo: any;
}
export interface ApplicationEventMapping<Topic = string, Type = string> extends BaseEventMap {
'closed': ApplicationEvent<Topic, Type>;
'connected': ApplicationEvent<Topic, Type>;
'crashed': CrashedEvent & ApplicationEvent<Topic, Type>;
'initialized': ApplicationEvent<Topic, Type>;
'manifest-changed': ApplicationEvent<Topic, Type>;
'not-responding': ApplicationEvent<Topic, Type>;
'responding': ApplicationEvent<Topic, Type>;
'run-requested': RunRequestedEvent<Topic, Type>;
'started': ApplicationEvent<Topic, Type>;
'tray-icon-clicked': TrayIconClicked<Topic, Type>;
'window-alert-requested': WindowAlertRequestedEvent<Topic, Type>;
'window-auth-requested': WindowAuthRequestedEvent<Topic, Type>;
'window-created': WindowEvent<Topic, Type>;
'window-end-load': WindowEndLoadEvent<Topic, Type>;
'window-not-responding': WindowEvent<Topic, Type>;
'window-responding': WindowEvent<Topic, Type>;
'window-show-requested': WindowEvent<Topic, Type>;
'window-start-load': WindowEvent<Topic, Type>;
}
export interface PropagatedApplicationEventMapping<Topic = string, Type = string> {
'application-closed': ApplicationEvent<Topic, Type>;
'application-connected': ApplicationEvent<Topic, Type>;
'application-crashed': CrashedEvent & ApplicationEvent<Topic, Type>;
'application-initialized': ApplicationEvent<Topic, Type>;
'application-manifest-changed': ApplicationEvent<Topic, Type>;
'application-not-responding': ApplicationEvent<Topic, Type>;
'application-responding': ApplicationEvent<Topic, Type>;
'application-started': ApplicationEvent<Topic, Type>;
'application-tray-icon-clicked': TrayIconClicked<Topic, Type>;
'window-created': WindowEvent<Topic, Type>;
'window-end-load': WindowEndLoadEvent<Topic, Type>;
'window-not-responding': WindowEvent<Topic, Type>;
'window-responding': WindowEvent<Topic, Type>;
'window-start-load': WindowEvent<Topic, Type>;
}
export declare type ApplicationEvents = PropagatedWindowEvents<'application'> & {
[Type in keyof ApplicationEventMapping]: ApplicationEventMapping<'application', Type>[Type];
};
export declare type PropagatedApplicationEvents<Topic> = {
[Type in keyof PropagatedApplicationEventMapping]: PropagatedApplicationEventMapping<Topic, Type>[Type];
};
+18
View File
@@ -0,0 +1,18 @@
import { FrameEvent } from './frame';
export declare type RuntimeEvent<Topic = string, Type = string> = Topic extends 'window' ? WindowEvent<Topic, Type> : Topic extends 'frame' ? FrameEvent<Type> : Topic extends 'application' ? ApplicationEvent<Topic, Type> : BaseEvent<Topic, Type>;
export interface BaseEvent<Topic, Type> {
topic: Topic;
type: Type;
}
export interface ApplicationEvent<Topic, Type> extends BaseEvent<Topic, Type> {
uuid: string;
}
export interface WindowEvent<Topic, Type> extends ApplicationEvent<Topic, Type> {
name: string;
}
export declare function getTopic(e: RuntimeEvent<any>): string;
export interface BaseEventMap {
[name: string]: any;
'newListener': string;
'listenerRemoved': string;
}
+10
View File
@@ -0,0 +1,10 @@
import { BaseEventMap, ApplicationEvent } from './base';
export interface ChannelEvent<Type> extends ApplicationEvent<'channel', Type> {
channelName: string;
channelId: string;
name?: string;
}
export interface ChannelEvents extends BaseEventMap {
'connected': ChannelEvent<'connected'>;
'disconnected': ChannelEvent<'disconnected'>;
}
+15
View File
@@ -0,0 +1,15 @@
/// <reference types="node" />
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[];
+5
View File
@@ -0,0 +1,5 @@
import { Message } from '../../transport/transport';
import { EmitterMap } from './emitterMap';
export declare class EventAggregator extends EmitterMap {
dispatchEvent: (message: Message<any>) => boolean;
}
+5
View File
@@ -0,0 +1,5 @@
import { RuntimeEvent, BaseEventMap } from './base';
export interface ExternalApplicationEvents extends BaseEventMap {
connected: RuntimeEvent<'externalapplication', 'connected'>;
disconnected: RuntimeEvent<'externalapplication', 'disconnected'>;
}
+9
View File
@@ -0,0 +1,9 @@
import { BaseEventMap, WindowEvent } from './base';
export interface FrameEvent<Type> extends WindowEvent<'frame', Type> {
entityType: 'iframe';
frameName: string;
}
export interface FrameEvents extends BaseEventMap {
connected: FrameEvent<'connected'>;
disconnected: FrameEvent<'disconnected'>;
}
+11
View File
@@ -0,0 +1,11 @@
import { RuntimeEvent, BaseEventMap } from './base';
import { Identity } from '../../identity';
import { nonHotkeyEvents } from '../global-hotkey';
export interface GlobalHotkeyEvent<Type> extends RuntimeEvent<'global-hotkey', Type> {
identity: Identity;
hotkey: string;
}
export interface GlobalHotkeyEvents extends BaseEventMap {
[nonHotkeyEvents.REGISTERED]: GlobalHotkeyEvent<nonHotkeyEvents.REGISTERED>;
[nonHotkeyEvents.UNREGISTERED]: GlobalHotkeyEvent<nonHotkeyEvents.UNREGISTERED>;
}
+8
View File
@@ -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'>;
}
+22
View File
@@ -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<Topic, Type> extends BaseEvent<Topic, Type> {
elapsedTime: number;
isIdle: boolean;
}
export declare type MonitorEvent<Topic, Type> = MonitorInfo & BaseEvent<Topic, Type>;
export interface SessionChangedEvent<Topic, Type> extends BaseEvent<Topic, Type> {
reason: 'lock' | 'unlock' | 'remote-connect' | 'remote-disconnect' | 'unknown';
}
export interface SystemEventMapping<Topic = string, Type = string> extends BaseEventMap {
'application-created': ApplicationEvent<Topic, Type>;
'desktop-icon-clicked': ApplicationEvent<Topic, Type>;
'idle-state-changed': IdleEvent<Topic, Type>;
'monitor-info-changed': MonitorEvent<Topic, Type>;
'session-changed': SessionChangedEvent<Topic, Type>;
}
export declare type SystemEvents = PropagatedWindowEvents<'system'> & PropagatedApplicationEvents<'system'> & {
[Type in keyof SystemEventMapping]: SystemEventMapping<'system', Type>[Type];
};
+176
View File
@@ -0,0 +1,176 @@
import { CrashedEvent } from './application';
import { WindowEvent, BaseEventMap } from './base';
export declare type SpecificWindowEvent<Type> = WindowEvent<'window', Type>;
export interface WindowAlertRequestedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
message: string;
url: string;
}
export interface WindowAuthRequestedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
authInfo: {
host: string;
isProxy: boolean;
port: number;
realm: string;
scheme: string;
};
}
export interface WindowEndLoadEvent<Topic, Type> extends WindowEvent<Topic, Type> {
documentName: string;
isMain: boolean;
}
export interface WindowNavigationRejectedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
sourceName: string;
url: string;
}
export interface WindowReloadedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
url: string;
}
export interface WindowExternalProcessExitedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
processUuid: string;
exitCode: number;
}
export interface WindowExternalProcessStartedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
processUuid: string;
}
export interface WindowHiddenEvent<Topic, Type> extends WindowEvent<Topic, Type> {
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<Topic, Type> extends WindowEvent<Topic, Type> {
preloadScripts: (PreloadScriptInfoRunning & any)[];
}
export interface WindowPreloadScriptsStateChangedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
preloadScripts: (PreloadScriptInfoRunning & any)[];
}
export interface WindowPreloadScriptsStateChangedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
preloadScripts: (PreloadScriptInfo & any)[];
}
export interface WindowResourceLoadFailedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
errorCode: number;
errorDescription: string;
validatedURL: string;
isMainFrame: boolean;
}
export interface WindowResourceResponseReceivedEvent<Topic, Type> extends WindowEvent<Topic, Type> {
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<Topic, Type> extends WindowEvent<Topic, Type> {
height: number;
left: number;
top: number;
width: number;
windowState: 'minimized' | 'normal' | 'maximized';
}
export interface WindowBoundsChange<Topic, Type> extends WindowEvent<Topic, Type> {
changeType: 0 | 1 | 2;
deferred: boolean;
height: number;
left: number;
top: number;
width: number;
}
export interface WindowGroupChanged<Topic, Type> extends WindowEvent<Topic, Type> {
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<Topic = string, Type = string> extends BaseEventMap {
'auth-requested': WindowAuthRequestedEvent<Topic, Type>;
'begin-user-bounds-changing': WindowBeginBoundsChangingEvent<Topic, Type>;
'blurred': WindowEvent<Topic, Type>;
'bounds-changed': WindowBoundsChange<Topic, Type>;
'bounds-changing': WindowBoundsChange<Topic, Type>;
'close-requested': WindowEvent<Topic, Type>;
'closed': WindowEvent<Topic, Type>;
'closing': WindowEvent<Topic, Type>;
'crashed': CrashedEvent & WindowEvent<Topic, Type>;
'disabled-frame-bounds-changed': WindowBoundsChange<Topic, Type>;
'disabled-frame-bounds-changing': WindowBoundsChange<Topic, Type>;
'embedded': WindowEvent<Topic, Type>;
'end-user-bounds-changing': WindowBeginBoundsChangingEvent<Topic, Type>;
'external-process-exited': WindowExternalProcessExitedEvent<Topic, Type>;
'external-process-started': WindowExternalProcessStartedEvent<Topic, Type>;
'focused': WindowEvent<Topic, Type>;
'frame-disabled': WindowEvent<Topic, Type>;
'frame-enabled': WindowEvent<Topic, Type>;
'group-changed': WindowGroupChanged<Topic, Type>;
'hidden': WindowHiddenEvent<Topic, Type>;
'initialized': WindowEvent<Topic, Type>;
'maximized': WindowEvent<Topic, Type>;
'minimized': WindowEvent<Topic, Type>;
'navigation-rejected': WindowNavigationRejectedEvent<Topic, Type>;
'preload-scripts-state-changed': WindowPreloadScriptsStateChangeEvent<Topic, Type>;
'preload-scripts-state-changing': WindowPreloadScriptsStateChangeEvent<Topic, Type>;
'resource-load-failed': WindowResourceLoadFailedEvent<Topic, Type>;
'resource-response-received': WindowResourceResponseReceivedEvent<Topic, Type>;
'reloaded': WindowReloadedEvent<Topic, Type>;
'restored': WindowEvent<Topic, Type>;
'show-requested': WindowEvent<Topic, Type>;
'shown': WindowEvent<Topic, Type>;
}
export interface PropagatedWindowEventMapping<Topic = string, Type = string> extends BaseEventMap {
'window-begin-user-bounds-changing': WindowBeginBoundsChangingEvent<Topic, Type>;
'window-blurred': WindowEvent<Topic, Type>;
'window-bounds-changed': WindowBoundsChange<Topic, Type>;
'window-bounds-changing': WindowBoundsChange<Topic, Type>;
'window-closed': WindowEvent<Topic, Type>;
'window-closing': WindowEvent<Topic, Type>;
'window-crashed': CrashedEvent & WindowEvent<Topic, Type>;
'window-disabled-frame-bounds-changed': WindowBoundsChange<Topic, Type>;
'window-disabled-frame-bounds-changing': WindowBoundsChange<Topic, Type>;
'window-embedded': WindowEvent<Topic, Type>;
'window-end-user-bounds-changing': WindowBeginBoundsChangingEvent<Topic, Type>;
'window-external-process-exited': WindowExternalProcessExitedEvent<Topic, Type>;
'window-external-process-started': WindowExternalProcessStartedEvent<Topic, Type>;
'window-focused': WindowEvent<Topic, Type>;
'window-frame-disabled': WindowEvent<Topic, Type>;
'window-frame-enabled': WindowEvent<Topic, Type>;
'window-group-changed': WindowGroupChanged<Topic, Type>;
'window-hidden': WindowHiddenEvent<Topic, Type>;
'window-initialized': WindowEvent<Topic, Type>;
'window-maximized': WindowEvent<Topic, Type>;
'window-minimized': WindowEvent<Topic, Type>;
'window-navigation-rejected': WindowNavigationRejectedEvent<Topic, Type>;
'window-preload-scripts-state-changed': WindowPreloadScriptsStateChangeEvent<Topic, Type>;
'window-preload-scripts-state-changing': WindowPreloadScriptsStateChangedEvent<Topic, Type>;
'window-resource-load-failed': WindowResourceLoadFailedEvent<Topic, Type>;
'window-resource-response-received': WindowResourceResponseReceivedEvent<Topic, Type>;
'window-reloaded': WindowReloadedEvent<Topic, Type>;
'window-restored': WindowEvent<Topic, Type>;
'window-shown': WindowEvent<Topic, Type>;
}
export declare type WindowEvents = {
[Type in keyof WindowEventMapping]: WindowEventMapping<'window', Type>[Type];
};
export declare type PropagatedWindowEvents<Topic> = {
[Type in keyof PropagatedWindowEventMapping]: PropagatedWindowEventMapping<Topic, Type>[Type];
};
@@ -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.<ExternalApplication>}
* @tutorial ExternalApplication.wrap
* @static
*/
wrap(uuid: string): Promise<ExternalApplication>;
/**
* 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<ExternalApplicationEvents> {
identity: Identity;
constructor(wire: Transport, identity: Identity);
/**
@@ -28,9 +42,3 @@ export declare class ExternalApplication extends EmitterBase {
*/
getInfo(): Promise<ExternalApplicationInfo>;
}
export interface ExternalApplication {
on(type: 'connected', listener: (data: Reply<'externalapplication', 'connected'>) => void): Promise<void>;
on(type: 'disconnected', listener: (data: Reply<'externalapplication', 'disconnected'>) => void): Promise<void>;
on(type: 'removeListener', listener: (eventType: string) => void): Promise<void>;
on(type: 'newListener', listener: (eventType: string) => void): Promise<void>;
}
+28 -10
View File
@@ -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<FrameEvents> {
identity: Identity;
constructor(wire: Transport, identity: Identity);
/**
@@ -45,7 +67,3 @@ export declare class _Frame extends EmitterBase {
*/
getParentWindow(): Promise<FrameInfo>;
}
export interface _Frame {
on(type: 'connected', listener: (eventType: string) => void): Promise<void>;
on(type: 'disconnected', listener: (eventType: string) => void): Promise<void>;
}
+6 -1
View File
@@ -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<GlobalHotkeyEvents> {
constructor(wire: Transport);
/**
* Registers a global hotkey with the operating system.
+10 -11
View File
@@ -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<any> {
senderIdentity: Identity;
ackToSender: any;
providerIdentity: Identity;
providerIdentity: ProviderIdentity;
connectAction: boolean;
}
export declare class Channel extends EmitterBase {
export declare class Channel extends EmitterBase<ChannelEvents> {
private channelMap;
constructor(wire: Transport);
getAllChannels(): Promise<ProviderIdentity[]>;
onChannelConnect(listener: Function): Promise<void>;
onChannelDisconnect(listener: Function): Promise<void>;
connect(options: Options): Promise<ChannelClient>;
create(channelName?: string): Promise<ChannelProvider>;
onmessage: (msg: Message<ChannelMessage>) => boolean;
onChannelConnect(listener: (...args: any[]) => void): Promise<void>;
onChannelDisconnect(listener: (...args: any[]) => void): Promise<void>;
connect(channelName: string, options?: ConnectOptions): Promise<ChannelClient>;
create(channelName: string): Promise<ChannelProvider>;
onmessage: (msg: ChannelMessage) => boolean;
private processChannelMessage;
private processChannelConnection;
}
+6 -4
View File
@@ -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<any>;
processConnection(senderId: ProviderIdentity, payload: any): Promise<any>;
dispatch(to: Identity, action: string, payload: any): Promise<any>;
processConnection(senderId: Identity, payload: any): Promise<any>;
publish(action: string, payload: any): Promise<any>[];
onConnection(listener: ConnectionListener): void;
onDisconnection(listener: ConnectionListener): void;
}
+2 -3
View File
@@ -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<NotificationEvents> {
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;
+8 -8
View File
@@ -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<SystemEvents> {
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<CrashReporterOption>;
/**
* 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.<string>}
* @tutorial System.getDeviceId
*/
getDeviceId(): Promise<string>;
/**
* 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<string>;
/**
* Returns a unique identifier (UUID) provided by the machine.
* @return {Promise.<string>}
* @tutorial System.getMachineId
*/
getMachineId(): Promise<string>;
/**
* Returns the minimum (inclusive) logging level that is currently being written to the log.
* @return {Promise.<LogLevel>}
+46 -29
View File
@@ -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.<Window>}
* @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<WindowEvents> {
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<Bounds>;
/**
* Returns the native JavaScript "window" object for the window.
* @return {Promise.<any>}
* @tutorial Window.getNativeWindow
*/
getNativeWindow(): Promise<any>;
/**
* Gives focus to the window.
* @return {Promise.<void>}
@@ -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.<string>}
* @tutorial Window.getSnapshot
*/
getSnapshot(): Promise<string>;
getSnapshot(area?: Area): Promise<string>;
/**
* Gets the current state ("minimized", "maximized", or "restored") of the window.
* @return {Promise.<string>}
@@ -747,13 +774,3 @@ export declare class _Window extends EmitterBase {
*/
stopNavigation(): Promise<void>;
}
export interface _Window {
on(type: 'focused', listener: Function): Promise<void>;
on(type: 'initialized', listener: Function): Promise<void>;
on(type: 'bounds-changed', listener: (data: BoundsChangedReply) => void): Promise<void>;
on(type: 'hidden', listener: Function): Promise<void>;
on(type: 'removeListener', listener: (eventType: string | symbol) => void): Promise<void>;
on(type: 'newListener', listener: (eventType: string | symbol) => void): Promise<void>;
on(type: 'closed', listener: (eventType: CloseEventShape) => void): Promise<void>;
on(type: 'fire-constructor-callback', listener: Function): Promise<void>;
}
+18 -1
View File
@@ -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<number, {
@@ -10,12 +12,13 @@ declare class Transport extends EventEmitter {
reject: Function;
}>;
protected uncorrelatedListener: Function;
protected messageHandlers: MessageHandler[];
me: Identity;
protected wire: Wire;
environment: Environment;
topicRefMap: Map<string, number>;
sendRaw: Wire['send'];
eventAggregator: EventAggregator;
protected messageHandlers: MessageHandler[];
constructor(wireType: WireConstructor, environment: Environment);
connectSync: (config: ConnectConfig) => any;
connect(config: InternalConnectConfig): Promise<string>;
@@ -38,6 +41,20 @@ export declare class Message<T> {
payload: T;
correlationId?: number;
}
export declare class EventMessage implements Message<RuntimeEvent> {
action: 'process-desktop-event';
payload: RuntimeEvent;
}
export declare class NotificationEventMessage implements Message<NotificationEvent> {
action: 'process-notification-event';
payload: NotificationEvent;
}
export interface NotificationEvent {
payload: {
notificationId: string;
};
type: string | symbol;
}
export declare class Payload {
success: boolean;
data: any;
+3 -2
View File
@@ -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 <https://github.com/chrisbarker>
// Ricardo de Pena <https://github.com/rdepena>
// Roma <https://github.com/whyn07m3>
// Li Cui <https://github.com/licui3936>
// 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
/**