import type * as OpenFin from '../../OpenFin'; import { Transport } from '../../transport/transport'; import { WebContents } from '../webcontents/main'; type UpdatableViewOptions = OpenFin.UpdatableViewOptions; type ViewEvent = OpenFin.ViewEvent; /** * @PORTED * @typedef {object} View~options * @summary View creation options. * @desc This is the options object required by {@link View.create View.create}. * * Note that `name` and `target` are the only required properties — albeit the `url` property is usually provided as well * (defaults to `"about:blank"` when omitted). * * @property {object} [experimental] * Configurations for API injection. * * @property {boolean} [experimental.childWindows] Configure if the runtime should enable child windows for views. * * @property {object} [accelerator] * Enable keyboard shortcuts for devtools, zoom, reload, and reload ignoring cache. * * @property {boolean} [accelerator.devtools=false] * If `true`, enables the devtools keyboard shortcut:
* `Ctrl` + `Shift` + `I` _(Toggles Devtools)_ * * @property {boolean} [accelerator.reload=false] * If `true`, enables the reload keyboard shortcuts:
* `Ctrl` + `R` _(Windows)_
* `F5` _(Windows)_
* `Command` + `R` _(Mac)_ * * @property {boolean} [accelerator.reloadIgnoringCache=false] * If `true`, enables the reload-from-source keyboard shortcuts:
* `Ctrl` + `Shift` + `R` _(Windows)_
* `Shift` + `F5` _(Windows)_
* `Command` + `Shift` + `R` _(Mac)_ * * @property {boolean} [accelerator.zoom=false] * If `true`, enables the zoom keyboard shortcuts:
* `Ctrl` + `+` _(Zoom In)_
* `Ctrl` + `Shift` + `+` _(Zoom In)_
* `Ctrl` + `NumPad+` _(Zoom In)_
* `Ctrl` + `-` _(Zoom Out)_
* `Ctrl` + `Shift` + `-` _(Zoom Out)_
* `Ctrl` + `NumPad-` _(Zoom Out)_
* `Ctrl` + `Scroll` _(Zoom In & Out)_
* `Ctrl` + `0` _(Restore to 100%)_ * * @property {object} [api] * Configurations for API injection. * * @property {object} [api.iframe] Configure if the the API should be injected into iframes based on domain. * * @property {boolean} [api.iframe.crossOriginInjection=false] Controls if the `fin` API object is present for cross origin iframes. * @property {boolean} [api.iframe.sameOriginInjection=true] Controls if the `fin` API object is present for same origin iframes. * * @property {string} [autoplayPolicy="no-user-gesture-required"] * Autoplay policy to apply to content in the window, can be * `no-user-gesture-required`, `user-gesture-required`, * `document-user-activation-required`. Defaults to `no-user-gesture-required`. * * @property {object} [autoResize] AutoResize options * * @property {object} [bounds] initial bounds given relative to the window. * * @property {string} [backgroundColor="#FFF"] - _Updatable._ * The view’s _backfill_ color as a hexadecimal value. Not to be confused with the content background color * (`document.body.style.backgroundColor`), * this color briefly fills a view’s (a) content area before its content is loaded as well as (b) newly exposed * areas when growing a window. Setting * this value to the anticipated content background color can help improve user experience. * Default is white. * * @property {object} [contentNavigation] * Restrict navigation to URLs that match a whitelisted pattern. * In the lack of a whitelist, navigation to URLs that match a blacklisted pattern would be prohibited. * See [here](https://developer.chrome.com/extensions/match_patterns) for more details. * @property {string[]} [contentNavigation.whitelist=[]] List of whitelisted URLs. * @property {string[]} [contentNavigation.blacklist=[]] List of blacklisted URLs. * * @property {object} [contentRedirect] * Restrict redirects to URLs that match a whitelisted pattern. * In the lack of a whitelist, redirects to URLs that match a blacklisted pattern would be prohibited. * See [here](https://developer.chrome.com/extensions/match_patterns) for more details. * @property {string[]} [contentRedirect.whitelist=[]] List of whitelisted URLs. * @property {string[]} [contentRedirect.blacklist=[]] List of blacklisted URLs. * * @property {object} [contextMenuSettings] - _Updatable._ * Deprecated - superseded by {@link contextMenuOptions}, which offers a larger feature-set and cleaner syntax. * Configure the context menu when right-clicking on a view. * @property {boolean} [contextMenuSettings.enable=true] Should the context menu display on right click. * @property {boolean} [contextMenuSettings.devtools=true] Should the context menu contain a button for opening devtools. * @property {boolean} [contextMenuSettings.reload=true] Should the context menu contain a button for reloading the page. * * @property {object} [contextMenuOptions] - _Updatable._ * Configure the context menu when right-clicking on a view. Supported menu items: * 'separator' * 'cut' * 'copy' * 'paste' * 'spellCheck' * 'inspect' * 'reload' * 'navigateForward' * 'navigateBack' * 'print' * @property {boolean} [contextMenuOptions.enabled = true] Should the context menu display on right click. * @property {string[]} [contextMenuOptions.template=[]] List of context menu items to display on right-click. * * @property {any} [customData=""] - _Updatable._ * A field that the user can attach serializable data to be ferried around with the view options. * _When omitted, the default value of this property is the empty string (`""`)._ * * @property {any} [customContext=""] - _Updatable._ * A field that the user can use to attach serializable data that will be saved when {@link Platform#getSnapshot Platform.getSnapshot} * is called. * When omitted, the default value of this property is the empty string (`""`). * As opposed to customData, this is meant for frequent updates and sharing with other contexts. [Example]{@tutorial customContext} * * @property {object[]} [hotkeys=[]] - _Updatable._ * Defines the list of hotkeys that will be emitted as a `hotkey` event on the view. For usage example see [example]{@tutorial hotkeys}. * Within Platform, OpenFin also implements a set of pre-defined actions called * [keyboard commands]{@link https://developers.openfin.co/docs/platform-api#section-5-3-using-keyboard-commands} * that can be assigned to a specific hotkey in the platform manifest. * @property {string} hotkeys.keys The key combination of the hotkey, i.e. "Ctrl+T" * @property {boolean} [hotkeys.preventDefault=false] preventDefault will prevent the page keydown/keyup events from being emitted. * * @property {boolean} [isClosable=true] **Platforms Only.** If false, the view will be persistent and can't be closed through * either UI or `Platform.closeView`. Note that the view will still be closed if the host window is closed or * if the view isn't part of the new layout when running `Layout.replace`. * * @property {string} name * The name of the view. * * @property {boolean} [detachOnClose=false] - _Updatable._ * Platforms Only. If true, will hide and detach the View from the window for later use instead of closing, * allowing the state of the View to be saved and the View to be immediately shown in a new Layout. * * @property {string} [manifestUrl] **Platforms Only.** Url to a manifest that contains View Options. Properties other than manifestUrl can still be used * but the properties in the manifest will take precedence if there is any collision. * * @property {preloadScript[]} [preloadScripts] - _Inheritable_ * A list of scripts that are eval'ed before other scripts in the page. When omitted, _inherits_ * from the parent application. * * @property {boolean} [preventDragOut=false] **Platforms Only.** If true, the tab of the view can't be dragged out of its host window. * * @property {string} [processAffinity=] * A string to attempt to group renderers together. Will only be used if pages are on the same origin. * * @property {boolean} [spellCheck=false] * Enable spell check in input text fields for the view. * * @property {Identity} [target] * The identity of the window this view should be attached to. * * @property {string} [url="about:blank"] * The URL of the view. * * @property {string} [uuid=] * The `uuid` of the application, unique within the set of all `Application`s running in OpenFin Runtime. * If omitted, defaults to the `uuid` of the application spawning the view. * If given, must match the `uuid` of the application spawning the view. * In other words, the application's `uuid` is the only acceptable value, but is the default, so there's * really no need to provide it. */ /** * @classdesc A View can be used to embed additional web content into a Window. * It is like a child window, except it is positioned relative to its owning window. * It has the ability to listen for View-specific events. * * By default, a View will try to share the same renderer process as other Views owned by its parent Application. * To change that behavior, see the processAffinity {@link View~options view option}. * * A View's lifecycle is tied to its owning window and can be re-attached to a different window at any point during its lifecycle. * @class * @alias View * @hideconstructor */ export declare class View extends WebContents { #private; identity: OpenFin.Identity; constructor(wire: Transport, identity: OpenFin.Identity); /** * Gets a base64 encoded image of the view or a part of it. * @function capturePage * @param { CapturePageOptions } [options] Options for the capturePage call. * @memberOf View * @instance * @return {Promise.} * @tutorial View.capturePage */ /** * Executes Javascript on the view, restricted to contents you own or contents owned by * applications you have created. * @param { string } code JavaScript code to be executed on the view. * @function executeJavaScript * @memberOf View * @instance * @return {Promise.} * @tutorial View.executeJavaScript */ /** * Focuses the view * @return {Promise.} * @function focus * @memberof View * @emits focused * @instance * @tutorial View.focus * @experimental */ focus({ emitSynthFocused }?: { emitSynthFocused: boolean; }): Promise; /** * Returns the zoom level of the view. * @function getZoomLevel * @memberOf View * @instance * @return {Promise.} * @tutorial View.getZoomLevel */ /** * Sets the zoom level of the view. * @param { number } level The zoom level * @function setZoomLevel * @memberOf View * @instance * @return {Promise.} * @tutorial View.setZoomLevel */ /** * Find and highlight text on a page. * @param { string } searchTerm Term to find in page * @param { FindInPageOptions } options Search options * @function findInPage * @memberOf View * @instance * @return {Promise.} * @tutorial View.findInPage */ /** * Stops any findInPage call with the provided action. * @param {string} action * Action to execute when stopping a find in page:
* "clearSelection" - Clear the selection.
* "keepSelection" - Translate the selection into a normal selection.
* "activateSelection" - Focus and click the selection node.
* @function stopFindInPage * @memberOf View * @instance * @return {Promise.} * @tutorial View.stopFindInPage */ /** * Navigates the view to a specified URL. The url must contain the protocol prefix such as http:// or https://. * @param { string } url - The URL to navigate the view to. * @return {Promise.} * @function navigate * @memberof View * @instance * @tutorial View.navigate * @experimental */ /** * Navigates the view back one page. * @function navigateBack * @memberOf View * @instance * @return {Promise.} * @tutorial View.navigateBack */ /** * Navigates the view forward one page. * @function navigateForward * @memberOf View * @instance * @return {Promise.} * @tutorial View.navigateForward */ /** * Stops any current navigation the view is performing. * @function stopNavigation * @memberOf View * @instance * @return {Promise.} * @tutorial View.stopNavigation */ /** * Reloads the view current page * @function reload * @memberOf View * @instance * @return {Promise.} * @tutorial View.reload */ /** * Prints the view's web page * @param { PrintOptions } [options] Printer Options * @function print * @memberOf View * @instance * @return {Promise.} * @tutorial View.print */ /** * Returns an array with all system printers * @deprecated use System.getPrinters instead * @function getPrinters * @memberOf View * @instance * @return { Promise.Array. } * @tutorial View.getPrinters */ /** * Shows the Chromium Developer Tools * @function showDeveloperTools * @memberOf View * @instance * @return {Promise.} * @tutorial View.showDeveloperTools */ /** * Retrieves the process information associated with a view. * @function getProcessInfo * @memberOf View * @instance * @return {Promise.} * @tutorial View.getProcessInfo */ /** * Retrieves information on all Shared Workers. * @function getSharedWorkers * @memberOf View * @instance * @return {Promise.Array.} * @tutorial View.getSharedWorkers */ /** * Opens the developer tools for the shared worker context. * @function inspectSharedWorker * @memberOf View * @instance * @return {Promise.} * @tutorial View.inspectSharedWorker */ /** * Inspects the shared worker based on its ID. * @param { string } workerId - The id of the shared worker. * @function inspectSharedWorkerById * @memberOf View * @instance * @return {Promise.} * @tutorial View.inspectSharedWorkerById */ /** * Opens the developer tools for the service worker context. * @function inspectServiceWorker * @memberOf View * @instance * @return {Promise.} * @tutorial View.inspectServiceWorker */ /** * Shows a popup window. If the window this view is currently attached to has a popup open, closes it. * @function showPopupWindow * @memberOf View * @instance * @param {PopupOptions} options * @return {Promise} * @tutorial View.showPopupWindow */ /** * Attaches the current view to a the given window identity. * Identity must be the identity of a window in the same application. * This detaches the view from its current window, and sets the view to be destroyed when its new window closes. * @param target {Identity} * @return {Promise.} * @tutorial View.attach * @experimental */ attach: (target: OpenFin.Identity) => Promise; /** * Destroys the current view * @return {Promise.} * @tutorial View.destroy * @experimental */ destroy: () => Promise; /** * Shows the current view if it is currently hidden. * @return {Promise.} * @tutorial View.show * @experimental */ show: () => Promise; /** * Hides the current view if it is currently visible. * @return {Promise.} * @tutorial View.hide * @experimental */ hide: () => Promise; /** * Sets the bounds (top, left, width, height) of the view relative to its window. * @param bounds {ViewBounds} * @return {Promise.} * @tutorial View.setBounds * @experimental */ setBounds: (bounds: OpenFin.Bounds) => Promise; /** * Gets the bounds (top, left, width, height) of the view relative to its window. * @return {Promise.} * @tutorial View.getBounds * @experimental */ getBounds: () => Promise; /** * Gets the View's info. * @return {Promise.} * @tutorial View.getInfo * @experimental */ getInfo: () => Promise; /** * Retrieves the layout for the window the view is attached to. * @return {Promise.} * @tutorial View.getParentLayout * @experimental */ getParentLayout: () => Promise; /** * Gets the View's options. * @return {Promise} * @tutorial View.getOptions * @experimental */ getOptions: () => Promise; /** * Updates the view's options. * @param { Partial } options * @return {Promise.} * @tutorial View.updateOptions * @experimental */ updateOptions: (options: UpdatableViewOptions) => Promise; /** * Retrieves the window the view is currently attached to. * @return {Promise.<_Window>} * @experimental */ getCurrentWindow: () => Promise; /** * Retrieves the current {@link TabStack} of the view if it belongs to one. * @return {Promise} The {@link TabStack} this view belongs to. * @throws if this view does not belong to a TabStack or if the window has been destroyed. */ getCurrentStack: () => Promise; /** * Triggers the before-unload handler for the View, if one is set. Returns `true` if the handler is trying to prevent the View from unloading, and `false` if it isn't. * Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false. * @returns {Promise} * @tutorial View.triggerBeforeUnload * @experimental */ triggerBeforeUnload: () => Promise; /** * **NOTE**: Internal use only. * Attaches this view to an HTML element in the current context. The view will resize responsively when the element bounds change. * * **Known issue**: View.bindToElement does not track position changes, if the element has fixed px width and height values it is possible for the view to not update responsively. * * **Known issue**: When View.bindToElement is used on a element that takes up the entire page in a platform window, the bound view will not respond responsively when the window is resized to be smaller. * * @param {HTMLElement} element - HTML element to attach the view to. * @return {Function} - Cleanup function that will disconnect the element resize observer. * @internal * @experimental * @tutorial View.bindToElement */ bindToElement: (element: HTMLElement) => Promise<() => void>; } export {};