openfin-adapter
Advanced tools
Comparing version 18.55.1 to 18.55.2
{ | ||
"name": "openfin-adapter", | ||
"version": "18.55.1", | ||
"version": "18.55.2", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./src/main.js", |
@@ -17,2 +17,3 @@ import { Base } from '../base'; | ||
* Creates a new Notification. | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @param { object } options | ||
@@ -19,0 +20,0 @@ * @return {_Notification} |
@@ -21,2 +21,3 @@ "use strict"; | ||
* Creates a new Notification. | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @param { object } options | ||
@@ -28,2 +29,4 @@ * @return {_Notification} | ||
create(options) { | ||
// eslint-disable-next-line no-console | ||
console.warn('fin.Notification has been deprecated. Please migrate to the Notifications API: https://developers.openfin.co/docs/notifications-api'); | ||
const noteOptions = new shapes_1.NotificationOptions(options, this.me, this.genNoteId()); | ||
@@ -30,0 +33,0 @@ return new Instance_1._Notification(this.wire, noteOptions); |
@@ -6,2 +6,5 @@ import { EmitterBase } from '../base'; | ||
/** | ||
* @deprecated fin.Notification has been deprecated and replaced with the | ||
* [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @classdesc A Notification object represents a window on OpenFin Runtime which | ||
@@ -28,2 +31,3 @@ * is shown briefly to the user on the bottom-right corner of the primary monitor. | ||
* Invoked when the notification is shown | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @return {Promise.<void>} | ||
@@ -35,2 +39,3 @@ * @tutorial Notification.show | ||
* Sends a message to the notification. | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @param { any } message The message to be sent to the notification. | ||
@@ -46,2 +51,3 @@ * Can be either a primitive data type (string, number, or boolean) | ||
* Closes the notification | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @return {Promise.<void>} | ||
@@ -48,0 +54,0 @@ * @tutorial Notification.close |
@@ -7,2 +7,5 @@ "use strict"; | ||
/** | ||
* @deprecated fin.Notification has been deprecated and replaced with the | ||
* [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @classdesc A Notification object represents a window on OpenFin Runtime which | ||
@@ -42,2 +45,3 @@ * is shown briefly to the user on the bottom-right corner of the primary monitor. | ||
* Invoked when the notification is shown | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @return {Promise.<void>} | ||
@@ -47,2 +51,4 @@ * @tutorial Notification.show | ||
async show() { | ||
// eslint-disable-next-line no-console | ||
console.warn('fin.Notification has been deprecated. Please migrate to the Notifications API: https://developers.openfin.co/docs/notifications-api'); | ||
if (!this.url) { | ||
@@ -65,2 +71,3 @@ throw new Error('Notifications require a url'); | ||
* Sends a message to the notification. | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @param { any } message The message to be sent to the notification. | ||
@@ -74,2 +81,4 @@ * Can be either a primitive data type (string, number, or boolean) | ||
async sendMessage(message) { | ||
// eslint-disable-next-line no-console | ||
console.warn('fin.Notification has been deprecated. Please migrate to the Notifications API: https://developers.openfin.co/docs/notifications-api'); | ||
await this.wire.sendAction('send-action-to-notifications-center', { | ||
@@ -87,2 +96,3 @@ action: 'send-notification-message', | ||
* Closes the notification | ||
* @deprecated Please migrate to the [Notifications API]{@link https://developers.openfin.co/docs/notifications-api}. | ||
* @return {Promise.<void>} | ||
@@ -92,2 +102,4 @@ * @tutorial Notification.close | ||
async close() { | ||
// eslint-disable-next-line no-console | ||
console.warn('fin.Notification has been deprecated. Please migrate to the Notifications API: https://developers.openfin.co/docs/notifications-api'); | ||
await this.wire.sendAction('send-action-to-notifications-center', { | ||
@@ -94,0 +106,0 @@ action: 'close-notification', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable no-console */ | ||
/* eslint-disable class-methods-use-this, no-undef */ | ||
@@ -47,3 +48,4 @@ /* global localStorage */ | ||
'parent', | ||
'target' | ||
'target', | ||
'updateStateIfExists' | ||
]; | ||
@@ -239,6 +241,12 @@ // Remove internal/non used values | ||
// ************* UTILS ************** | ||
const windowExists = async (winName) => { | ||
const application = fin.Application.getCurrentSync(); | ||
const childWindows = await application.getChildWindows(); | ||
return childWindows.some((win) => win.identity.name === winName); | ||
const createOrWrapView = async (convertedOpts, target) => { | ||
const allViews = await app.getViews(); | ||
let view = allViews.find((v) => v.identity.name === convertedOpts.name); | ||
if (!view) { | ||
view = await fin.View.create({ ...convertedOpts, target }); | ||
if (!fin.__internal_.childViews) { | ||
view.navigate(convertedOpts.url); | ||
} | ||
} | ||
return view; | ||
}; | ||
@@ -275,42 +283,11 @@ // MAKE ME REAL OR KILL ME | ||
// const closeWindow = identity => fin.Window.wrapSync(identity).close(); | ||
const resolveWhenLayoutReady = (win) => new Promise((res) => win.on('layout-ready', () => res())); | ||
const resolveWhenLayoutReady = (win) => new Promise((res) => win.on('layout-ready', () => res(win))); | ||
async function openSnapshot(snapshot) { | ||
const currentWindowNames = (await fin.Application.getCurrentSync().getChildWindows()).map((win) => win.identity.name); | ||
const creationPromises = snapshot.windows.map(async (windowOptions) => { | ||
const { uuid } = fin.me; | ||
const win = fin.Window.wrapSync({ uuid, name: windowOptions.name }); | ||
const resolveCondition = windowOptions.layout ? resolveWhenLayoutReady(win) : undefined; | ||
if (currentWindowNames.includes(windowOptions.name)) { | ||
if (windowOptions.layout) { | ||
await platformProvider.replaceLayout({ opts: windowOptions, target: win.identity }, fin.me.identity); | ||
} | ||
platformProvider.setWindowContext({ | ||
target: win.identity, | ||
entityType: EntityType_1.default.WINDOW, | ||
context: windowOptions.customContext | ||
}, fin.me.identity); | ||
if (windowOptions.state === 'minimized') { | ||
win.minimize(); | ||
} | ||
else if (windowOptions.state === 'maximized') { | ||
win.maximize(); | ||
} | ||
const x = windowOptions.x || windowOptions.defaultLeft; | ||
const y = windowOptions.y || windowOptions.defaultTop; | ||
const width = windowOptions.width || windowOptions.defaultWidth; | ||
const height = windowOptions.height || windowOptions.defaultHeight; | ||
if (width && height) { | ||
win.resizeTo(width, height, 'top-left'); | ||
} | ||
if (x && y) { | ||
win.moveTo(x, y); | ||
} | ||
return resolveCondition; | ||
if (windowOptions.updateStateIfExists === undefined) { | ||
windowOptions.updateStateIfExists = true; | ||
} | ||
const pooledViewMap = await view_pool_1.getPooledViewObject(); | ||
if (windowOptions.layout) { | ||
windowOptions.layout.content = (await mapLayoutContentItems(windowOptions.layout.content, async (contentItem) => modifyContentItemName(contentItem, !pooledViewMap[contentItem.componentState.name]))); | ||
} | ||
await platformProvider.createWindow(windowOptions, fin.me.identity); | ||
return resolveCondition; | ||
return platformProvider | ||
.createWindow(windowOptions, fin.me.identity) | ||
.catch((e) => console.error(e)); | ||
}); | ||
@@ -389,11 +366,64 @@ await Promise.all(creationPromises); | ||
const { reason = Platform_1.WindowCreationReason.APICall, ...windowOptions } = options; | ||
const currentWindowNames = (await app.getChildWindows()).map((win) => win.identity.name); | ||
const { uuid } = fin.me; | ||
if (windowOptions.name && currentWindowNames.includes(windowOptions.name)) { | ||
if (!windowOptions.updateStateIfExists) { | ||
throw new Error(`Trying to create a Window in ${uuid} Platform with name already in use - ${windowOptions.name}`); | ||
} | ||
const win = fin.Window.wrapSync({ uuid, name: windowOptions.name }); | ||
const resolveCondition = windowOptions.layout ? resolveWhenLayoutReady(win) : win; | ||
if (windowOptions.layout) { | ||
platformProvider.replaceLayout({ opts: windowOptions, target: win.identity }, fin.me.identity); | ||
} | ||
platformProvider.setWindowContext({ | ||
target: win.identity, | ||
entityType: EntityType_1.default.WINDOW, | ||
context: windowOptions.customContext | ||
}, fin.me.identity); | ||
if (windowOptions.state === 'minimized') { | ||
win.minimize(); | ||
} | ||
else if (windowOptions.state === 'maximized') { | ||
win.maximize(); | ||
} | ||
const x = windowOptions.x || windowOptions.defaultLeft; | ||
const y = windowOptions.y || windowOptions.defaultTop; | ||
const width = windowOptions.width || windowOptions.defaultWidth; | ||
const height = windowOptions.height || windowOptions.defaultHeight; | ||
if (width && height) { | ||
win.resizeTo(width, height, 'top-left'); | ||
} | ||
if (x && y) { | ||
win.moveTo(x, y); | ||
} | ||
return resolveCondition; | ||
} | ||
const pooledViewMap = await view_pool_1.getPooledViewObject(); | ||
if (windowOptions.layout) { | ||
windowOptions.layout.content = await mapLayoutContentItems(windowOptions.layout.content, async (contentItem) => modifyContentItemName(contentItem, !pooledViewMap[contentItem.componentState.name] && | ||
reason !== Platform_1.WindowCreationReason.Tearout && | ||
// In the CreateViewWithoutTarget case, we have already generated a name for the view. | ||
// Generating a new one will mess up listeners created as part of view creation. | ||
reason !== Platform_1.WindowCreationReason.CreateViewWithoutTarget)); | ||
const convertedOpts = await convertWindowOptions(windowOptions); | ||
if (convertedOpts.layout) { | ||
convertedOpts.layout.content = await mapLayoutContentItems(convertedOpts.layout.content, async (contentItem) => { | ||
const newOpts = modifyContentItemName(contentItem, | ||
// The name does not need to be generated for a tearout or if it matches a pooled view (i.e. use existing view) | ||
!pooledViewMap[contentItem.componentState.name] && | ||
reason !== Platform_1.WindowCreationReason.Tearout && | ||
// In the CreateViewWithoutTarget case, we have already generated a name for the view. | ||
// Generating a new one will mess up listeners created as part of view creation. | ||
reason !== Platform_1.WindowCreationReason.CreateViewWithoutTarget); | ||
return newOpts; | ||
}); | ||
const win = fin.Window.wrapSync({ uuid, name: convertedOpts.name }); | ||
const layoutResolved = resolveWhenLayoutReady(win); | ||
fin.Window.create(convertedOpts); | ||
// using this `map` function just to iterate recursively over the content and dropping return value on floor | ||
mapLayoutContentItems(convertedOpts.layout.content, async (contentItem) => { | ||
// create the view attached to the provider, later to be stolen by the window | ||
this.createView({ | ||
opts: contentItem.componentState, | ||
target: fin.me.identity | ||
}, callerIdentity || fin.me.identity); | ||
return contentItem; | ||
}); | ||
return layoutResolved; | ||
} | ||
return fin.Window.create(await convertWindowOptions(windowOptions)); | ||
return fin.Window.create(convertedOpts); | ||
} | ||
@@ -453,3 +483,5 @@ /** | ||
const client = provider.connections.find((c) => c.name === win.identity.name); | ||
const layoutPromise = provider.dispatch(client, 'get-frame-snapshot'); | ||
const layoutPromise = client | ||
? provider.dispatch(client, 'get-frame-snapshot') | ||
: Promise.resolve(); | ||
const [bounds, state, winOptions, layout, { url, title }] = await Promise.all([ | ||
@@ -608,3 +640,3 @@ windowBoundsPromise, | ||
/** | ||
* Creates a new view and attaches it to a specified target window. | ||
* Creates a new view and attaches it to a specified target window, or creates a new window for it if no target window is provided. | ||
* @param { CreateViewPayload } payload Creation options for the new view. | ||
@@ -619,18 +651,12 @@ * @param { Identity } callerIdentity Identity of the entity that called | ||
const { uuid } = fin.me.identity; | ||
const convertedOpts = await convertViewOptions(opts); | ||
if (target) { | ||
// will move from another layout window if already exists | ||
// will create or attach the BV but we should document just create | ||
const viewOptions = await convertViewOptions(opts); | ||
const viewPromise = createOrWrapView(convertedOpts, target); | ||
if (target.name === fin.me.name) { | ||
return fin.View.create({ ...viewOptions, target }).then((view) => { | ||
// With the flag views have loaded the initial url | ||
if (!fin.__internal_.childViews) { | ||
view.navigate(viewOptions.url); | ||
} | ||
return view; | ||
}); | ||
// this is likely a "pooled" or "detached" view | ||
return viewPromise; | ||
} | ||
return provider.dispatch(target, 'add-view', viewOptions); | ||
return provider.dispatch(target, 'add-view', convertedOpts); | ||
} | ||
const layout = utils_1.generateLayoutContent(opts); | ||
const layout = utils_1.generateLayoutContent(convertedOpts); | ||
const options = { | ||
@@ -642,6 +668,6 @@ uuid, | ||
return new Promise((res) => { | ||
const view = fin.View.wrapSync({ uuid, name: opts.name }); | ||
// View could already exist, target-changed fires on creation so will capture either case | ||
view.once('target-changed', () => res(view)); | ||
this.createWindow(options, fin.me.identity); | ||
const wrappedView = fin.View.wrapSync({ uuid, name: convertedOpts.name }); | ||
wrappedView.once('target-changed', () => res(wrappedView)); | ||
this.createWindow(options, callerIdentity || fin.me.identity); | ||
}); | ||
@@ -665,10 +691,23 @@ } | ||
const newOptions = { ...opts, layout: modifiedLayout }; | ||
if (!newOptions.layout.content) { | ||
throw new Error(`Layout has incorrect shape, needs content property: ${JSON.stringify(newOptions.layout)}.`); | ||
} | ||
// we only want to generate a random name if: (1) the view has no name (2) the view has a generated name | ||
// AND (3) doesn't exist in the current window or in the view pool | ||
const windowViews = await fin.Window.wrapSync(target).getCurrentViews(); | ||
const pooledViews = await fin.Window.getCurrentSync().getCurrentViews(); | ||
const ofWin = fin.Window.wrapSync(target); | ||
const windowViews = await ofWin.getCurrentViews(); | ||
const pooledViews = await ofWin.getCurrentViews(); | ||
const viewNamesMap = [...windowViews, ...pooledViews].reduce((carry, view) => ({ ...carry, [view.identity.name]: true }), {}); | ||
const modifiedRootContentItem = await mapLayoutContentItems(newOptions.layout.content, async (contentItem) => modifyContentItemName(contentItem, !viewNamesMap[contentItem.componentState.name])); | ||
const modifiedRootContentItem = await mapLayoutContentItems(newOptions.layout.content, async (contentItem) => { | ||
if (!viewNamesMap[contentItem.componentState.name]) { | ||
const newContentItem = modifyContentItemName(contentItem, true); | ||
this.createView({ opts: newContentItem.componentState, target }, callerIdentity || fin.me.identity); | ||
return newContentItem; | ||
} | ||
return modifyContentItemName(contentItem, false); | ||
}); | ||
newOptions.layout.content = modifiedRootContentItem; | ||
return provider.dispatch(target, 'replace-layout', newOptions); | ||
const layoutReady = resolveWhenLayoutReady(ofWin); | ||
await provider.dispatch(target, 'replace-layout', newOptions); | ||
await layoutReady; | ||
} | ||
@@ -818,3 +857,2 @@ /** | ||
provider.onError((action, error, identity) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Error on action ${action} sent by ${JSON.stringify(identity)}: ${JSON.stringify(errors_1.errorToPOJO(error))}`); | ||
@@ -821,0 +859,0 @@ throw error; |
@@ -34,2 +34,5 @@ "use strict"; | ||
const app = this.fin.Application.getCurrentSync(); | ||
const attachView = () => this.ofView.attach(this.windowIdentity); | ||
const boundAttachView = attachView.bind(this); | ||
this.ofView.once('created', boundAttachView); | ||
const allViews = await app.getViews(); | ||
@@ -39,13 +42,7 @@ const view = allViews.find((v) => v.identity.name === this.ofView.identity.name); | ||
// this will move an existing view to this window | ||
this.ofView.removeListener('created', boundAttachView); | ||
await this.ofView.attach(this.windowIdentity); | ||
} | ||
else { | ||
await this.fin.View.create(this.options); | ||
// With the flag views have loaded the initial url | ||
if (!this.fin.__internal_.childViews) { | ||
this.ofView.navigate(this.options.url); | ||
} | ||
} | ||
} | ||
} | ||
exports.ResizableView = ResizableView; |
@@ -221,2 +221,5 @@ "use strict"; | ||
updatedTitle = state.title || url.hostname || state.url || state.name; | ||
if (updatedTitle === null || updatedTitle === void 0 ? void 0 : updatedTitle.includes('internal-generated')) { | ||
updatedTitle = url.hostname || state.url || state.name; | ||
} | ||
} | ||
@@ -223,0 +226,0 @@ container.setTitle(updatedTitle); |
@@ -276,2 +276,6 @@ import { EmitterBase } from '../base'; | ||
* @typedef { object } EntityProcessDetails | ||
* @property { string } uuid The uuid for the entity | ||
* @property { string } name The name for the entity | ||
* @property { string } url URL associated with the entity | ||
* @property { string } entityType Type for the entity: window or view | ||
* @property { number } cpuUsage The percentage of total CPU usage | ||
@@ -288,7 +292,22 @@ * @property { number } nonPagedPoolUsage The current nonpaged pool usage in bytes | ||
* @property { number } pid The native process identifier | ||
* @property { string } uuid The uuid for the entity | ||
* @property { string } name The name for the entity | ||
* @property { string } entityType Type for the entity | ||
* @property { Array<FrameProcessDetails> } frames Array of process info for each iframe corresponeding to the entity | ||
*/ | ||
/** | ||
* FrameProcessDetails interface | ||
* @typedef { object } FrameProcessDetails | ||
* @property { string } url Current URL associated with the process | ||
* @property { string } entityType Type for the frame | ||
* @property { number } cpuUsage The percentage of total CPU usage | ||
* @property { number } nonPagedPoolUsage The current nonpaged pool usage in bytes | ||
* @property { number } pageFaultCount The number of page faults | ||
* @property { number } pagedPoolUsage The current paged pool usage in bytes | ||
* @property { number } pagefileUsage The total amount of memory in bytes that the memory manager has committed | ||
* @property { number } peakNonPagedPoolUsage The peak nonpaged pool usage in bytes | ||
* @property { number } peakPagedPoolUsage The peak paged pool usage in bytes | ||
* @property { number } peakPagefileUsage The peak value in bytes of pagefileUsage during the lifetime of this process | ||
* @property { number } peakWorkingSetSize The peak working set size in bytes | ||
* @property { number } workingSetSize The current working set size (both shared and private data) in bytes | ||
* @property { number } pid The native process identifier | ||
*/ | ||
/** | ||
* ProcessDetails interface | ||
@@ -780,3 +799,3 @@ * @typedef { object } ProcessDetails | ||
/** | ||
* Opens the passed URL in the default web browser. | ||
* Opens the passed URL in the default web browser. It only supports http(s) and fin(s) protocols. | ||
* @param { string } url The URL to open | ||
@@ -783,0 +802,0 @@ * @return {Promise.<void>} |
@@ -253,2 +253,6 @@ "use strict"; | ||
* @typedef { object } EntityProcessDetails | ||
* @property { string } uuid The uuid for the entity | ||
* @property { string } name The name for the entity | ||
* @property { string } url URL associated with the entity | ||
* @property { string } entityType Type for the entity: window or view | ||
* @property { number } cpuUsage The percentage of total CPU usage | ||
@@ -265,7 +269,22 @@ * @property { number } nonPagedPoolUsage The current nonpaged pool usage in bytes | ||
* @property { number } pid The native process identifier | ||
* @property { string } uuid The uuid for the entity | ||
* @property { string } name The name for the entity | ||
* @property { string } entityType Type for the entity | ||
* @property { Array<FrameProcessDetails> } frames Array of process info for each iframe corresponeding to the entity | ||
*/ | ||
/** | ||
* FrameProcessDetails interface | ||
* @typedef { object } FrameProcessDetails | ||
* @property { string } url Current URL associated with the process | ||
* @property { string } entityType Type for the frame | ||
* @property { number } cpuUsage The percentage of total CPU usage | ||
* @property { number } nonPagedPoolUsage The current nonpaged pool usage in bytes | ||
* @property { number } pageFaultCount The number of page faults | ||
* @property { number } pagedPoolUsage The current paged pool usage in bytes | ||
* @property { number } pagefileUsage The total amount of memory in bytes that the memory manager has committed | ||
* @property { number } peakNonPagedPoolUsage The peak nonpaged pool usage in bytes | ||
* @property { number } peakPagedPoolUsage The peak paged pool usage in bytes | ||
* @property { number } peakPagefileUsage The peak value in bytes of pagefileUsage during the lifetime of this process | ||
* @property { number } peakWorkingSetSize The peak working set size in bytes | ||
* @property { number } workingSetSize The current working set size (both shared and private data) in bytes | ||
* @property { number } pid The native process identifier | ||
*/ | ||
/** | ||
* ProcessDetails interface | ||
@@ -897,3 +916,3 @@ * @typedef { object } ProcessDetails | ||
/** | ||
* Opens the passed URL in the default web browser. | ||
* Opens the passed URL in the default web browser. It only supports http(s) and fin(s) protocols. | ||
* @param { string } url The URL to open | ||
@@ -900,0 +919,0 @@ * @return {Promise.<void>} |
@@ -26,2 +26,3 @@ import { DownloadPreloadOption } from '../system/download-preload'; | ||
frame?: boolean; | ||
height?: Readonly<number>; | ||
hideOnClose?: boolean; | ||
@@ -53,2 +54,5 @@ hotkeys?: Hotkey[]; | ||
waitForPageLoad?: boolean; | ||
width?: Readonly<number>; | ||
x?: Readonly<number>; | ||
y?: Readonly<number>; | ||
} | ||
@@ -55,0 +59,0 @@ export interface CustomRequestHeaders { |
@@ -22,2 +22,3 @@ import type { ApplicationOption } from '../api/application/applicationOption'; | ||
export interface PlatformWindowCreationOptions extends Partial<WindowOption> { | ||
updateStateIfExists?: boolean; | ||
reason?: WindowCreationReason; | ||
@@ -24,0 +25,0 @@ } |
@@ -14,6 +14,10 @@ export interface ProcessDetails { | ||
} | ||
export interface EntityProcessDetails extends ProcessDetails { | ||
export interface FrameProcessDetails extends ProcessDetails { | ||
url: string; | ||
entityType: string; | ||
} | ||
export interface EntityProcessDetails extends FrameProcessDetails { | ||
name: string; | ||
entityType: string; | ||
uuid: string; | ||
iframes: Array<FrameProcessDetails>; | ||
} | ||
@@ -20,0 +24,0 @@ export interface AppProcessInfo { |
@@ -9,2 +9,3 @@ /// <reference types="node" /> | ||
import EntityType from '../shapes/EntityType'; | ||
import { ProtocolMap } from '../shapes/protocol'; | ||
export declare type MessageHandler = (data: any) => boolean; | ||
@@ -31,2 +32,5 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmitter { | ||
READY_STATE: typeof READY_STATE; | ||
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): Promise<Message<{ | ||
data: ProtocolMap[T]['response']; | ||
} & ProtocolMap[T]['specialResponse']>>; | ||
ferryAction(origData: any): Promise<Message<any>>; | ||
@@ -39,7 +43,2 @@ registerMessageHandler(handler: MessageHandler): void; | ||
export default Transport; | ||
interface Transport { | ||
sendAction(action: 'request-external-authorization', payload: {}, uncorrelated: true): Promise<Message<AuthorizationPayload>>; | ||
sendAction(action: string, payload: {}, uncorrelated: boolean): Promise<Message<Payload>>; | ||
topicRefMap: Map<string, number>; | ||
} | ||
export interface Message<T> { | ||
@@ -46,0 +45,0 @@ action: string; |
@@ -110,3 +110,5 @@ "use strict"; | ||
} | ||
sendAction(action, payload = {}, uncorrelated = false) { | ||
sendAction(action, payload = {}, uncorrelated = false | ||
// specialResponse type is only used for 'requestAuthorization' | ||
) { | ||
return new Promise((resolve, reject) => { | ||
@@ -113,0 +115,0 @@ const id = this.environment.getNextMessageId(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3983754
270
18110