Update to latest v2 api (#36834)

Change customeData type to any
This commit is contained in:
Li Cui 2019-07-11 18:49:05 -04:00 committed by Armando Aguirre
parent e669d7bd5f
commit 657fe5e753
11 changed files with 105 additions and 37 deletions

View File

@ -20,7 +20,7 @@ export interface ApplicationOption {
contentNavigation?: object;
contextMenu?: boolean;
cornerRounding?: object;
customData?: string;
customData?: any;
customRequestHeaders?: Array<CustomRequestHeaders>;
defaultCentered?: boolean;
defaultHeight?: number;

View File

@ -0,0 +1,42 @@
import { WebContents } from '../webcontents/webcontents';
import { BaseEventMap } from '../events/base';
import Transport from '../../transport/transport';
import { Identity } from '../../identity';
import { Base } from '../base';
interface AutoResizeOptions {
/**
* If true, the view's width will grow and shrink together with the window. false
* by default.
*/
width: boolean;
/**
* If true, the view's height will grow and shrink together with the window. false
* by default.
*/
height: boolean;
}
export interface BrowserViewOptions {
autoResize?: AutoResizeOptions;
}
export interface BrowserViewCreationOptions extends BrowserViewOptions {
name: string;
url: string;
target: Identity;
bounds?: {
x: number;
y: number;
width: number;
height: number;
};
}
export declare class BrowserViewModule extends Base {
create(options: BrowserViewCreationOptions): Promise<BrowserView>;
wrapSync(identity: Identity): BrowserView;
}
export declare class BrowserView extends WebContents<BaseEventMap> {
identity: Identity;
constructor(wire: Transport, identity: Identity);
setBounds: (bounds: any) => Promise<void>;
getInfo: () => Promise<any>;
}
export {};

View File

@ -1,4 +1,3 @@
import { Identity } from '../../identity';
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> : Topic extends 'external-window' ? ApplicationEvent<Topic, Type> : BaseEvent<Topic, Type>;
export interface BaseEvent<Topic, Type> {
@ -11,8 +10,6 @@ export interface ApplicationEvent<Topic, Type> extends BaseEvent<Topic, Type> {
export interface WindowEvent<Topic, Type> extends ApplicationEvent<Topic, Type> {
name: string;
}
export interface ExternalWindowEvent<Topic, Type> extends BaseEvent<Topic, Type>, Identity {
}
export declare function getTopic(e: RuntimeEvent<any>): string;
export interface BaseEventMap {
[name: string]: any;

View File

@ -1,24 +1,7 @@
import { ExternalWindowEvent, BaseEventMap } from './base';
export interface ExternalWindowEventMapping<Topic = string, Type = string> extends BaseEventMap {
'begin-user-bounds-changing': ExternalWindowEvent<Topic, Type>;
'blurred': ExternalWindowEvent<Topic, Type>;
'bounds-changed': ExternalWindowEvent<Topic, Type>;
'bounds-changing': ExternalWindowEvent<Topic, Type>;
'closed': ExternalWindowEvent<Topic, Type>;
'closing': ExternalWindowEvent<Topic, Type>;
'disabled-movement-bounds-changed': ExternalWindowEvent<Topic, Type>;
'disabled-movement-bounds-changing': ExternalWindowEvent<Topic, Type>;
'end-user-bounds-changing': ExternalWindowEvent<Topic, Type>;
'focused': ExternalWindowEvent<Topic, Type>;
'group-changed': ExternalWindowEvent<Topic, Type>;
'hidden': ExternalWindowEvent<Topic, Type>;
'maximized': ExternalWindowEvent<Topic, Type>;
'minimized': ExternalWindowEvent<Topic, Type>;
'restored': ExternalWindowEvent<Topic, Type>;
'shown': ExternalWindowEvent<Topic, Type>;
'user-movement-disabled': ExternalWindowEvent<Topic, Type>;
'user-movement-enabled': ExternalWindowEvent<Topic, Type>;
}
import { BaseEventMap } from './base';
import { WindowEventMapping } from './window';
declare type ExternalWindowEventMapping<Topic = string, Type = string> = BaseEventMap & Pick<WindowEventMapping, 'begin-user-bounds-changing' | 'blurred' | 'bounds-changed' | 'bounds-changing' | 'closed' | 'closing' | 'disabled-movement-bounds-changed' | 'disabled-movement-bounds-changing' | 'end-user-bounds-changing' | 'focused' | 'group-changed' | 'hidden' | 'maximized' | 'minimized' | 'restored' | 'shown' | 'user-movement-disabled' | 'user-movement-enabled'>;
export declare type ExternalWindowEvents = {
[Type in keyof ExternalWindowEventMapping]: ExternalWindowEventMapping<'external-window', Type>[Type];
};
export {};

View File

@ -83,6 +83,13 @@ export interface WindowBeginBoundsChangingEvent<Topic, Type> extends WindowEvent
width: number;
windowState: 'minimized' | 'normal' | 'maximized';
}
export interface WindowEndBoundsChangingEvent<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;
@ -120,7 +127,7 @@ export interface WindowEventMapping<Topic = string, Type = string> extends BaseE
'disabled-movement-bounds-changed': WindowBoundsChange<Topic, Type>;
'disabled-movement-bounds-changing': WindowBoundsChange<Topic, Type>;
'embedded': WindowEvent<Topic, Type>;
'end-user-bounds-changing': WindowBeginBoundsChangingEvent<Topic, Type>;
'end-user-bounds-changing': WindowEndBoundsChangingEvent<Topic, Type>;
'external-process-exited': WindowExternalProcessExitedEvent<Topic, Type>;
'external-process-started': WindowExternalProcessStartedEvent<Topic, Type>;
'focused': WindowEvent<Topic, Type>;

View File

@ -15,6 +15,7 @@ export default class ExternalWindowModule extends Base {
* @return {Promise.<ExternalWindow>}
* @static
* @experimental
* @tutorial Window.wrap
*/
wrap(identity: Identity): Promise<ExternalWindow>;
/**
@ -28,14 +29,21 @@ export default class ExternalWindowModule extends Base {
* @return {ExternalWindow}
* @static
* @experimental
* @tutorial Window.wrapSync
*/
wrapSync(identity: Identity): ExternalWindow;
}
/**
* @classdesc An ExternalWindow object representing an adopted native window
* on the system. Allows the developer to call actions on external windows as
* well as listen to external window events.
* @classdesc An ExternalWindow is an OpenFin object representing a window that belongs to a non-openfin application.<br>
* While External Windows don't have the complete functionality of an OpenFin Window object,
* they can be used to tap into any application that is currently running in the OS.<br>
* External Windows are useful for grouping, moving and resizing non-openfin applications
* as well as listening to events that are dispatched by these applications.<br>
* They are also compatible with OpenFin's Layouts service to facilitate
* a complete positional control over all running applications.<br>
* External Windows has the ability to listen for <a href="tutorial-ExternalWindow.EventEmitter.html"> external window specific events</a>.
* @class
* @alias ExternalWindow
* @hideconstructor
*/
export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
@ -45,12 +53,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* Brings the external window to the front of the window stack.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.bringToFront
*/
bringToFront(): Promise<void>;
/**
* Closes the external window.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.close
*/
close(): Promise<void>;
/**
@ -58,6 +68,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* when using the window's frame.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.disableUserMovement
*/
disableUserMovement(): Promise<void>;
/**
@ -65,12 +76,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* when using the window's frame.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.enableUserMovement
*/
enableUserMovement(): Promise<void>;
/**
* Flashes the external windows frame and taskbar icon until stopFlashing is called.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.flash
*/
flash(): Promise<void>;
/**
@ -78,12 +91,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @return {Promise.<void>}
* @emits ExternalWindow#focused
* @experimental
* @tutorial Window.focus
*/
focus(): Promise<void>;
/**
* Gets the current bounds (top, left, etc.) of the external window.
* @return {Promise.<Bounds>}
* @experimental
* @tutorial Window.getBounds
*/
getBounds(): Promise<Bounds>;
/**
@ -92,18 +107,21 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* is returned.
* @return {Promise.<Array<ExternalWindow|_Window>>}
* @experimental
* @tutorial Window.getGroup
*/
getGroup(): Promise<Array<ExternalWindow | _Window>>;
/**
* Gets an information object for the window.
* @return {Promise.<any>}
* @experimental
* @tutorial Window.getInfo
*/
getInfo(): Promise<any>;
/**
* Gets an external window's options.
* @return {Promise.<any>}
* @experimental
* @tutorial Window.getOptions
*/
getOptions(): Promise<any>;
/**
@ -111,18 +129,21 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* the external window.
* @return {Promise.<string>}
* @experimental
* @tutorial Window.getState
*/
getState(): Promise<string>;
/**
* Hides the external window.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.hide
*/
hide(): Promise<void>;
/**
* Determines if the external window is currently showing.
* @return {Promise.<boolean>}
* @experimental
* @tutorial Window.isShowing
*/
isShowing(): Promise<boolean>;
/**
@ -130,6 +151,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param { _Window | ExternalWindow } target The window whose group is to be joined
* @return {Promise.<void>}
* @experimental
* @tutorial Window.joinGroup
*/
joinGroup(target: ExternalWindow | _Window): Promise<void>;
/**
@ -137,12 +159,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* independently of those in the group.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.leaveGroup
*/
leaveGroup(): Promise<void>;
/**
* Maximizes the external window.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.maximize
*/
maximize(): Promise<void>;
/**
@ -150,12 +174,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param { _Window | ExternalWindow } target The window whose group is to be merged with
* @return {Promise.<void>}
* @experimental
* @tutorial Window.mergeGroups
*/
mergeGroups(target: ExternalWindow | _Window): Promise<void>;
/**
* Minimizes the external window.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.minimize
*/
minimize(): Promise<void>;
/**
@ -164,6 +190,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param { number } deltaTop The change in the top position of the window
* @return {Promise.<void>}
* @experimental
* @tutorial Window.moveBy
*/
moveBy(deltaLeft: number, deltaTop: number): Promise<void>;
/**
@ -172,6 +199,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param { number } top The top position of the window
* @return {Promise.<void>}
* @experimental
* @tutorial Window.moveTo
*/
moveTo(left: number, top: number): Promise<void>;
/**
@ -183,6 +211,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* If undefined, the default is "top-left".
* @return {Promise.<void>}
* @experimental
* @tutorial Window.resizeBy
*/
resizeBy(deltaWidth: number, deltaHeight: number, anchor: AnchorType): Promise<void>;
/**
@ -194,12 +223,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* If undefined, the default is "top-left".
* @return {Promise.<void>}
* @experimental
* @tutorial Window.resizeTo
*/
resizeTo(width: number, height: number, anchor: AnchorType): Promise<void>;
/**
* Restores the external window to its normal state (i.e. unminimized, unmaximized).
* @return {Promise.<void>}
* @experimental
* @tutorial Window.restore
*/
restore(): Promise<void>;
/**
@ -207,6 +238,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* give it focus.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.setAsForeground
*/
setAsForeground(): Promise<void>;
/**
@ -214,12 +246,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @property { Bounds } bounds
* @return {Promise.<void>}
* @experimental
* @tutorial Window.setBounds
*/
setBounds(bounds: Bounds): Promise<void>;
/**
* Shows the external window if it is hidden.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.show
*/
show(): Promise<void>;
/**
@ -230,12 +264,14 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param { number } top The top position of the window
* @return {Promise.<void>}
* @experimental
* @tutorial Window.showAt
*/
showAt(left: number, top: number): Promise<void>;
/**
* Stops the taskbar icon from flashing.
* @return {Promise.<void>}
* @experimental
* @tutorial Window.stopFlashing
*/
stopFlashing(): Promise<void>;
/**
@ -243,6 +279,7 @@ export declare class ExternalWindow extends EmitterBase<ExternalWindowEvents> {
* @param {*} options Changes an external window's options
* @return {Promise.<void>}
* @experimental
* @tutorial Window.updateOptions
*/
updateOptions(options: any): Promise<void>;
}

View File

@ -12,6 +12,7 @@ import ExternalWindow from './external-window/external-window';
import _FrameModule from './frame/frame';
import GlobalHotkey from './global-hotkey';
import { Identity } from '../identity';
import { BrowserViewModule } from './browserview/browserview';
export default class Fin extends EventEmitter {
private wire;
System: System;
@ -24,6 +25,7 @@ export default class Fin extends EventEmitter {
ExternalWindow: ExternalWindow;
Frame: _FrameModule;
GlobalHotkey: GlobalHotkey;
BrowserView: BrowserViewModule;
readonly me: Identity;
constructor(wire: Transport);
}

View File

@ -3,7 +3,7 @@ import { Identity } from '../../identity';
import { Application } from '../application/application';
import Transport from '../../transport/transport';
import { WindowEvents } from '../events/window';
import { AnchorType, Transition, TransitionOptions, Bounds } from '../../shapes';
import { AnchorType, Bounds, Transition, TransitionOptions } from '../../shapes';
import { WindowOption } from './windowOption';
import { EntityType } from '../frame/frame';
import { ExternalWindow } from '../external-window/external-window';
@ -181,7 +181,7 @@ interface WindowMovementOptions {
* @property {number} [cornerRounding.height=0] The height in pixels.
* @property {number} [cornerRounding.width=0] The width in pixels.
*
* @property {string} [customData=""] - _Updatable._
* @property {any} [customData=""] - _Updatable._
* A field that the user can attach serializable data to to be ferried around with the window options.
* _When omitted, the default value of this property is the empty string (`""`)._
*
@ -795,8 +795,8 @@ export declare class _Window extends WebContents<WindowEvents> {
updateOptions(options: any): Promise<void>;
/**
* Provides credentials to authentication requests
* @param { string } userName userName to provide to the authentication challange
* @param { string } password password to provide to the authentication challange
* @param { string } userName userName to provide to the authentication challenge
* @param { string } password password to provide to the authentication challenge
* @return {Promise.<void>}
* @tutorial Window.authenticate
*/

View File

@ -13,7 +13,7 @@ export interface WindowOption {
contextMenu?: boolean;
contextMenuSettings?: ContextMenuSettings;
cornerRounding?: object;
customData?: string;
customData?: any;
customRequestHeaders?: Array<CustomRequestHeaders>;
defaultCentered?: boolean;
defaultHeight?: number;

View File

@ -31,12 +31,12 @@ export interface Bounds {
right?: number;
bottom?: number;
}
export declare interface RGB {
export interface RGB {
red: number;
blue: number;
green: number;
}
export declare interface ContextMenuSettings {
export interface ContextMenuSettings {
enable?: boolean;
devtools?: boolean;
reload?: boolean;

View File

@ -8,7 +8,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
// based on v12.69.43.1
// based on v12.69.43.15
// see https://openfin.co/support/technical-faq/#what-do-the-numbers-in-the-runtime-version-mean
/**