/** * Sometimes a context parameter is passed to an operation in order to provide the operation * with information about the app making the request. Instances of this class provides this * information. */ export interface AppContext { extension: AppInstance; } /** * This class provides information about an instance of an add-on. */ export interface AppInstance { addon_key: string; id: string; key: string; options: AppOptions; } /** * This class represents options passed to an instance of an add-on. */ export interface AppOptions { autoresize: boolean; widthinpx: boolean; hostFrameOffset: number; _contextualOperations: ContextualOperations; } /** * This class identifies operations associated with an instance of an add-on. */ export interface ContextualOperations { resize(width: string, height: string): void; sizeToParent(): void; /** * This method hides the inline dialog that the add-on identified by this context is * being displayed in. */ hideInlineDialog(): void; } export class DefaultAppContext implements AppContext { extension: AppInstance; constructor(extension: AppInstance) { this.extension = extension; } } export class DefaultAppInstance implements AppInstance { addon_key: string; id: string; key: string; options: AppOptions; constructor( appKey: string, id: string, key: string, options: AppOptions) { this.addon_key = appKey; this.id = id; this.key = key; this.options = options; } } export class DefaultAppOptions implements AppOptions { autoresize: boolean; widthinpx: boolean; hostFrameOffset: number; _contextualOperations: ContextualOperations; constructor( autoresize: boolean, widthinpx: boolean, hostFrameOffset: number, _contextualOperations: ContextualOperations) { this.autoresize = autoresize; this.widthinpx = widthinpx; this.hostFrameOffset = hostFrameOffset; this._contextualOperations = _contextualOperations; } }