+
View
+
+ Type in the field below and try close the View or Window. A dialog will pop up indicating that this
+ view may have unsaved changes.
+
+
+
+
+
diff --git a/dev/john/update-logging-example/use-platform-warn-before-closing-dialog/js/dialog.bundle.js b/dev/john/update-logging-example/use-platform-warn-before-closing-dialog/js/dialog.bundle.js
new file mode 100644
index 00000000..9a5e321b
--- /dev/null
+++ b/dev/john/update-logging-example/use-platform-warn-before-closing-dialog/js/dialog.bundle.js
@@ -0,0 +1,22620 @@
+/******/ (() => { // webpackBootstrap
+/******/ var __webpack_modules__ = ({
+
+/***/ "../../../node_modules/@openfin/core/out/mock.js":
+/*!*******************************************************!*\
+ !*** ../../../node_modules/@openfin/core/out/mock.js ***!
+ \*******************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+
+var require$$0 = __webpack_require__(/*! events */ "../../../node_modules/events/events.js");
+var require$$0$1 = __webpack_require__(/*! lodash/cloneDeep */ "../../../node_modules/lodash/cloneDeep.js");
+var require$$3 = __webpack_require__(/*! lodash/isEqual */ "../../../node_modules/lodash/isEqual.js");
+
+function _mergeNamespaces(n, m) {
+ m.forEach(function (e) {
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
+ if (k !== 'default' && !(k in n)) {
+ var d = Object.getOwnPropertyDescriptor(e, k);
+ Object.defineProperty(n, k, d.get ? d : {
+ enumerable: true,
+ get: function () { return e[k]; }
+ });
+ }
+ });
+ });
+ return Object.freeze(n);
+}
+
+var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
+
+function getDefaultExportFromCjs (x) {
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
+}
+
+var OpenFin$2 = {};
+
+var events = {};
+
+var application$1 = {};
+
+/**
+ * Namespace for events that can be emitted by an {@link OpenFin.Application}. Includes events
+ * re-propagated from the {@link OpenFin.Window} (and, transitively, {@link OpenFin.View}) level, prefixed with `window-` (and also, if applicable, `view-`).
+ * For example, a view's "attached" event will fire as 'window-view-attached' at the application level.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * This namespace contains only payload shapes for events that are unique to `Application`. Events that propagate to `Application` from
+ * child {@link OpenFin.Window windows} and {@link OpenFin.View views} are defined in the {@link OpenFin.WindowEvents} and
+ * {@link OpenFin.ViewEvents} namespaces. For a list of valid string keys for *all* application events, see {@link Application.on Application.on}.
+ *
+ * {@link ApplicationSourcedEvent Application-sourced events} (i.e. those that have not propagated from {@link OpenFin.ViewEvents Views}
+ * or {@link OpenFin.WindowEvents Windows} re-propagate to {@link OpenFin.SystemEvents System} with their type string prefixed with `application-`.
+ * {@link ApplicationWindowEvent Application events that are tied to Windows but do not propagate from them}
+ * are propagated to `System` without any type string prefixing.
+ *
+ * "Requested" events (e.g. {@link RunRequestedEvent}) do not propagate.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(application$1, "__esModule", { value: true });
+
+var base$1 = {};
+
+/**
+ * Namespace for shared event payloads and utility types common to all event emitters.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(base$1, "__esModule", { value: true });
+
+var externalApplication$1 = {};
+
+/**
+ * Namespace for events that can be transmitted by an {@link OpenFin.ExternalApplication}.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * For a list of valid string keys for external application events, see {@link ExternalApplication.on ExternalApplication.on}.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(externalApplication$1, "__esModule", { value: true });
+
+var frame$1 = {};
+
+Object.defineProperty(frame$1, "__esModule", { value: true });
+
+var globalHotkey$1 = {};
+
+/**
+ *
+ * Namespace for events that can be transmitted by {@link GlobalHotkey.GlobalHotkey}.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * For a list of valid string keys for global hotkey events, see {@link GlobalHotkey.GlobalHotkey.on GlobalHotkey.on}.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(globalHotkey$1, "__esModule", { value: true });
+
+var platform$1 = {};
+
+/**
+ *
+ * Namespace for events that can emitted by a {@link OpenFin.Platform}.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * The Platform `EventEmitter` is a superset of the {@link OpenFin.Application} `EventEmitter`,
+ * meaning it can listen to all {@link OpenFin.ApplicationEvents Application events} in addition to the
+ * Platform-specific events listed here. For a list of valid string keys for *all* platform events, see
+ * {@link Platform.on Platform.on}.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(platform$1, "__esModule", { value: true });
+
+var system$1 = {};
+
+/**
+ * Namespace for runtime-wide OpenFin events emitted by {@link System.System}. Includes events
+ * re-propagated from {@link OpenFin.Application}, {@link OpenFin.Window}, and {@link OpenFin.View} (prefixed with `application-`, `window-`, and `view-`). All
+ * event propagations are visible at the System level. Propagated events from WebContents (windows, views, frames) to the Application level will *not*
+ * transitively re-propagate to the System level, because they are already visible at the system level and contain the identity
+ * of the application. For example, an application's "closed" event will fire as 'application-closed' at the system level. A view's 'shown' event
+ * will be visible as 'view-shown' at the system level, but *not* as `application-window-view-shown`.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * This namespace contains only payload shapes for events that are unique to `System`. Events that propagate to `System` from
+ * child {@link OpenFin.Application applications}, {@link OpenFin.Window windows}, and {@link OpenFin.View views} are defined in the
+ * {@link OpenFin.ApplicationEvents}, {@link OpenFin.WindowEvents}, and {@link OpenFin.ViewEvents} namespaces. For a list of valid string keys for *all*
+ * system events, see {@link System.on System.on}.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(system$1, "__esModule", { value: true });
+
+var view$1 = {};
+
+/**
+ * Namespace for events that can be emitted by a {@link OpenFin.View}.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * This namespace contains only payload shapes for events that are unique to `View`. Events that are shared between all `WebContents`
+ * (i.e. {@link OpenFin.Window}, {@link OpenFin.View}) are defined in {@link OpenFin.WebContentsEvents}. For a list
+ * of valid string keys for *all* View events, see {@link View.on View.on}.
+ *
+ * View events propagate to their parent {@link OpenFin.WindowEvents Window}, {@link OpenFin.ApplicationEvents Application},
+ * and {@link OpenFin.SystemEvents System} with an added `viewIdentity` property and their event types prefixed with `'view-'`.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(view$1, "__esModule", { value: true });
+
+var webcontents = {};
+
+/**
+ * Namespace for events shared by all OpenFin WebContents elements (i.e. {@link OpenFin.Window},
+ * {@link OpenFin.View}).
+ *
+ * WebContents events will re-emit on parent entities - e.g., a propagating event in a view will also be emitted on the view's
+ * parent window, and propagating events in a window will also be emitted on the window's parent {@link OpenFin.Application}.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(webcontents, "__esModule", { value: true });
+
+var window$2 = {};
+
+/**
+ * Namespace for events that can be emitted by a {@link OpenFin.Window}.
+ *
+ * Event payloads are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ * Events gain metadata as they propagate, which is *not* present on the explicit payload interfaces. To refer to the full type
+ * of an event as it would be raised on this emitter, use {@link Payload}.
+ *
+ * This namespace contains only payload shapes for events that are unique to `Window`. Events that are shared between all `WebContents`
+ * (i.e. {@link OpenFin.Window}, {@link OpenFin.View}) are defined in {@link OpenFin.WebContentsEvents}. Events that
+ * propagate from `View` are defined in {@link OpenFin.ViewEvents}. For a list of valid string keys for *all* Window events, see
+ * {@link Window.on Window.on}
+ *
+ * {@link OpenFin.WindowEvents.WindowSourcedEvent Window-sourced events} (i.e. those that are not propagated from a
+ * {@link OpenFin.ViewEvents View}) propagate to their parent {@link OpenFin.ApplicationEvents Application} and
+ * {@link OpenFin.SystemEvents System} with their event types prefixed with `'window-'`).
+ *
+ * "Requested" events (e.g. {@link AuthRequestedEvent}) do not propagate to `System. The {@link OpenFin.WindowEvents.WindowCloseRequestedEvent}
+ * does not propagate at all.
+ *
+ * @packageDocumentation
+ */
+Object.defineProperty(window$2, "__esModule", { value: true });
+
+/**
+ * Namespace for OpenFin event types. Each entity that emits OpenFin events has its own sub-namespace. Event payloads
+ * themselves are documented as interfaces, while algebraic helper types and derived types are documented as type aliases.
+ *
+ * #### Event emitters
+ *
+ * The following entities emit OpenFin events, and have corresponding sub-namespaces:
+ *
+ * * {@link OpenFin.Application}: {@link OpenFin.ApplicationEvents}
+ * * {@link OpenFin.ExternalApplication}: {@link OpenFin.ExternalApplicationEvents}
+ * * {@link OpenFin.Frame}: {@link OpenFin.FrameEvents}
+ * * {@link OpenFin.GlobalHotkey}: {@link OpenFin.GlobalHotkeyEvents}
+ * * {@link OpenFin.Platform}: {@link OpenFin.PlatformEvents}
+ * * {@link OpenFin.System}: {@link OpenFin.SystemEvents}
+ * * {@link OpenFin.View}: {@link OpenFin.ViewEvents}
+ * * {@link OpenFin.Window}: {@link OpenFin.WindowEvents}
+ *
+ * These `EventEmitter` entities share a common set of methods for interacting with the OpenFin event bus, which can be
+ * seen on the individual documentation pages for each entity type.
+ *
+ * Registering event handlers is an asynchronous operation. It is important to ensure that the returned Promises are awaited to reduce the
+ * risk of race conditions.
+ *
+ * When the `EventEmitter` receives an event from the browser process and emits on the renderer, all of the functions attached to that
+ * specific event are called synchronously. Any values returned by the called listeners are ignored and will be discarded. If the window document
+ * is destroyed by page navigation or reload, its registered event listeners will be removed.
+ *
+ * We recommend using Arrow Functions for event listeners to ensure the this scope is consistent with the original function context.
+ *
+ * Events re-propagate from smaller/more-local scopes to larger/more-global scopes. For example, an event emitted on a specific
+ * view will propagate to the window in which the view is embedded, and then to the application in which the window is running, and
+ * finally to the OpenFin runtime itself at the "system" level. For details on propagation semantics, see the namespace for
+ * the propagating (or propagated-to) entity.
+ *
+ * If you need the payload type for a specific type of event (especially propagated events), use the emitting topic's `Payload` generic
+ * (e.g. {@link WindowEvents.Payload}) with the event's `type` string. For example, the payload of
+ * a {@link ViewEvents.CreatedEvent} after it has propagated to its parent {@link WindowEvents Window} can be found with
+ * `WindowEvents.Payload<'view-created'>`.
+ *
+ * @packageDocumentation
+ */
+var __createBinding$1 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault$1 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar$1 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$1(result, mod, k);
+ __setModuleDefault$1(result, mod);
+ return result;
+};
+Object.defineProperty(events, "__esModule", { value: true });
+events.WindowEvents = events.WebContentsEvents = events.ViewEvents = events.SystemEvents = events.PlatformEvents = events.GlobalHotkeyEvents = events.FrameEvents = events.ExternalApplicationEvents = events.BaseEvents = events.ApplicationEvents = void 0;
+const ApplicationEvents = __importStar$1(application$1);
+events.ApplicationEvents = ApplicationEvents;
+const BaseEvents = __importStar$1(base$1);
+events.BaseEvents = BaseEvents;
+const ExternalApplicationEvents = __importStar$1(externalApplication$1);
+events.ExternalApplicationEvents = ExternalApplicationEvents;
+const FrameEvents = __importStar$1(frame$1);
+events.FrameEvents = FrameEvents;
+const GlobalHotkeyEvents = __importStar$1(globalHotkey$1);
+events.GlobalHotkeyEvents = GlobalHotkeyEvents;
+const PlatformEvents = __importStar$1(platform$1);
+events.PlatformEvents = PlatformEvents;
+const SystemEvents = __importStar$1(system$1);
+events.SystemEvents = SystemEvents;
+const ViewEvents = __importStar$1(view$1);
+events.ViewEvents = ViewEvents;
+const WebContentsEvents = __importStar$1(webcontents);
+events.WebContentsEvents = WebContentsEvents;
+const WindowEvents = __importStar$1(window$2);
+events.WindowEvents = WindowEvents;
+
+(function (exports) {
+ /**
+ * Top-level namespace for types referenced by the OpenFin API. Contains:
+ *
+ * * The type of the global `fin` entry point ({@link FinApi})
+ * * Classes that act as static namespaces returned from the `fin` global (e.g. {@link ApplicationModule}, accessible via `fin.Application`)
+ * * Instance classes that are returned from API calls (e.g. {@link Application}, accessible via `fin.Application.getCurrentSync()`)
+ * * Parameter shapes for API methods (e.g. {@link ApplicationOptions}, used in `fin.Application.start()`)
+ * * Event namespaces and payload union types (e.g. {@link ApplicationEvents} and {@link ApplicationEvent})
+ *
+ * @packageDocumentation
+ */
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+ }) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+ }));
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+ };
+ Object.defineProperty(exports, "__esModule", { value: true });
+ // Deprecated shim to preserve v30 namespace names
+ __exportStar(events, exports);
+} (OpenFin$2));
+
+var OpenFin = /*@__PURE__*/getDefaultExportFromCjs(OpenFin$2);
+
+var OpenFin$1 = /*#__PURE__*/_mergeNamespaces({
+ __proto__: null,
+ default: OpenFin
+}, [OpenFin$2]);
+
+var fin$2 = {};
+
+var system = {};
+
+var base = {};
+
+var promises = {};
+
+Object.defineProperty(promises, "__esModule", { value: true });
+promises.promiseMapSerial = promises.serial = promises.promiseMap = promises.promisify = void 0;
+function promisify(func) {
+ return (...args) => new Promise((resolve, reject) => {
+ func(...args, (err, val) => (err ? reject(err) : resolve(val)));
+ });
+}
+promises.promisify = promisify;
+async function promiseMap(arr, asyncF) {
+ return Promise.all(arr.map(asyncF));
+}
+promises.promiseMap = promiseMap;
+async function serial(arr) {
+ const ret = [];
+ for (const func of arr) {
+ // eslint-disable-next-line no-await-in-loop
+ const next = await func();
+ ret.push(next);
+ }
+ return ret;
+}
+promises.serial = serial;
+async function promiseMapSerial(arr, func) {
+ return serial(arr.map((value, index, array) => () => func(value, index, array)));
+}
+promises.promiseMapSerial = promiseMapSerial;
+
+var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
+ if (kind === "m") throw new TypeError("Private method is not writable");
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
+};
+var __classPrivateFieldGet$e = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
+};
+var _EmitterBase_emitterAccessor;
+Object.defineProperty(base, "__esModule", { value: true });
+base.Reply = base.EmitterBase = base.Base = void 0;
+const promises_1 = promises;
+class Base {
+ /**
+ * @internal
+ */
+ constructor(wire) {
+ /**
+ * @internal
+ * @deprecated
+ */
+ this.isNodeEnvironment = () => {
+ return this.wire.environment.type === 'node';
+ };
+ /**
+ * @internal
+ * @deprecated
+ */
+ this.isOpenFinEnvironment = () => {
+ return this.wire.environment.type === 'openfin';
+ };
+ /**
+ * @internal
+ * @deprecated
+ */
+ this.isBrowserEnvironment = () => {
+ return this.wire.environment.type === 'other';
+ };
+ this.wire = wire;
+ }
+ get fin() {
+ return this.wire.getFin();
+ }
+ /**
+ * Provides access to the OpenFin representation of the current code context (usually a document
+ * such as a {@link OpenFin.View} or {@link OpenFin.Window}), as well as to the current `Interop` context.
+ *
+ * Useful for debugging in the devtools console, where this will intelligently type itself based
+ * on the context in which the devtools panel was opened.
+ */
+ get me() {
+ return this.wire.me;
+ }
+}
+base.Base = Base;
+/**
+ * An entity that emits OpenFin events.
+ *
+ * @remarks Event-binding methods are asynchronous as they must cross process boundaries
+ * and setup the listener in the browser process. When the `EventEmitter` receives an event from the browser process
+ * and emits on the renderer, all of the functions attached to that specific event are called synchronously. Any values
+ * returned by the called listeners are ignored and will be discarded. If the execution context of the window is destroyed
+ * by page navigation or reload, any events that have been setup in that context will be destroyed.
+ *
+ * It is important to keep in mind that when an ordinary listener function is called, the standard `this` keyword is intentionally
+ * set to reference the `EventEmitter` instance to which the listener is attached. It is possible to use ES6 Arrow Functions as
+ * listeners, however, when doing so, the `this` keyword will no longer reference the `EventEmitter` instance.
+ *
+ * Events re-propagate from smaller/more-local scopes to larger/more-global scopes. For example, an event emitted on a specific
+ * view will propagate to the window in which the view is embedded, and then to the application in which the window is running, and
+ * finally to the OpenFin runtime itself at the "system" level. Re-propagated events are prefixed with the name of the scope in which
+ * they originated - for example, a "shown" event emitted on a view will be re-propagated at the window level as "view-shown", and
+ * then to the application as "window-view-shown", and finally at the system level as "application-window-view-shown".
+ *
+ * All event propagations are visible at the System level, regardless of source, so transitive re-propagations (e.g. from view to window
+ * to application) are visible in their entirety at the system level. So, we can listen to the above event as "shown", "view-shown",
+ * "window-view-shown", or "application-window-view-shown."
+ */
+class EmitterBase extends Base {
+ constructor(wire, topic, ...additionalAccessors) {
+ super(wire);
+ this.topic = topic;
+ _EmitterBase_emitterAccessor.set(this, void 0);
+ this.eventNames = () => (this.hasEmitter() ? this.getOrCreateEmitter().eventNames() : []);
+ /**
+ * @internal
+ */
+ this.emit = (eventType, payload, ...args) => {
+ return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
+ };
+ this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
+ this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
+ this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
+ this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
+ this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
+ const runtimeEvent = {
+ ...this.identity,
+ timestamp: options.timestamp || Date.now(),
+ topic: this.topic,
+ type: eventType
+ };
+ const emitter = this.getOrCreateEmitter();
+ // We apply the subscription and then undo if the async call fails to avoid
+ // indeterminacy in subscription application order, which can break things elsewhere
+ applySubscription(emitter);
+ try {
+ await this.wire.sendAction('subscribe-to-desktop-event', runtimeEvent);
+ }
+ catch (e) {
+ undoSubscription(emitter);
+ this.deleteEmitterIfNothingRegistered(emitter);
+ throw e;
+ }
+ };
+ this.deregisterEventListener = async (eventType, options = {}) => {
+ if (this.hasEmitter()) {
+ const runtimeEvent = {
+ ...this.identity,
+ timestamp: options.timestamp || Date.now(),
+ topic: this.topic,
+ type: eventType
+ };
+ await this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null);
+ const emitter = this.getOrCreateEmitter();
+ return emitter;
+ }
+ // This will only be reached if unsubscribe from event that does not exist but do not want to error here
+ return Promise.resolve();
+ };
+ __classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
+ this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
+ }
+ /**
+ * Adds a listener to the end of the listeners array for the specified event.
+ *
+ * @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
+ */
+ async on(eventType, listener, options) {
+ await this.registerEventListener(eventType, options, (emitter) => {
+ emitter.on(eventType, listener);
+ }, (emitter) => {
+ emitter.removeListener(eventType, listener);
+ });
+ return this;
+ }
+ /**
+ * Adds a listener to the end of the listeners array for the specified event.
+ */
+ async addListener(eventType, listener, options) {
+ return this.on(eventType, listener, options);
+ }
+ /**
+ * Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
+ *
+ * @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
+ */
+ async once(eventType, listener, options) {
+ const deregister = () => this.deregisterEventListener(eventType);
+ await this.registerEventListener(eventType, options, (emitter) => {
+ emitter.once(eventType, deregister);
+ emitter.once(eventType, listener);
+ }, (emitter) => {
+ emitter.removeListener(eventType, deregister);
+ emitter.removeListener(eventType, listener);
+ });
+ return this;
+ }
+ /**
+ * Adds a listener to the beginning of the listeners array for the specified event.
+ *
+ * @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
+ */
+ async prependListener(eventType, listener, options) {
+ await this.registerEventListener(eventType, options, (emitter) => {
+ emitter.prependListener(eventType, listener);
+ }, (emitter) => {
+ emitter.removeListener(eventType, listener);
+ });
+ return this;
+ }
+ /**
+ * Adds a one time listener for the event. The listener is invoked only the first time the event is fired,
+ * after which it is removed. The listener is added to the beginning of the listeners array.
+ *
+ * @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
+ */
+ async prependOnceListener(eventType, listener, options) {
+ const deregister = () => this.deregisterEventListener(eventType);
+ await this.registerEventListener(eventType, options, (emitter) => {
+ emitter.prependOnceListener(eventType, listener);
+ emitter.once(eventType, deregister);
+ }, (emitter) => {
+ emitter.removeListener(eventType, listener);
+ emitter.removeListener(eventType, deregister);
+ });
+ return this;
+ }
+ /**
+ * Remove a listener from the listener array for the specified event.
+ *
+ * @remarks Caution: Calling this method changes the array indices in the listener array behind the listener.
+ */
+ async removeListener(eventType, listener, options) {
+ const emitter = await this.deregisterEventListener(eventType, options);
+ if (emitter) {
+ emitter.removeListener(eventType, listener);
+ this.deleteEmitterIfNothingRegistered(emitter);
+ }
+ return this;
+ }
+ async deregisterAllListeners(eventType) {
+ const runtimeEvent = { ...this.identity, type: eventType, topic: this.topic };
+ if (this.hasEmitter()) {
+ const emitter = this.getOrCreateEmitter();
+ const refCount = emitter.listenerCount(runtimeEvent.type);
+ const unsubscribePromises = [];
+ for (let i = 0; i < refCount; i++) {
+ unsubscribePromises.push(this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null));
+ }
+ await Promise.all(unsubscribePromises);
+ return emitter;
+ }
+ return undefined;
+ }
+ /**
+ * Removes all listeners, or those of the specified event.
+ *
+ */
+ async removeAllListeners(eventType) {
+ const removeByEvent = async (event) => {
+ const emitter = await this.deregisterAllListeners(event);
+ if (emitter) {
+ emitter.removeAllListeners(event);
+ this.deleteEmitterIfNothingRegistered(emitter);
+ }
+ };
+ if (eventType) {
+ await removeByEvent(eventType);
+ }
+ else if (this.hasEmitter()) {
+ const events = this.getOrCreateEmitter().eventNames();
+ await (0, promises_1.promiseMap)(events, removeByEvent);
+ }
+ return this;
+ }
+ deleteEmitterIfNothingRegistered(emitter) {
+ if (emitter.eventNames().length === 0) {
+ this.wire.eventAggregator.delete(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
+ }
+ }
+}
+base.EmitterBase = EmitterBase;
+_EmitterBase_emitterAccessor = new WeakMap();
+class Reply {
+}
+base.Reply = Reply;
+
+var transportErrors = {};
+
+Object.defineProperty(transportErrors, "__esModule", { value: true });
+transportErrors.RuntimeError = transportErrors.NotSupportedError = transportErrors.NotImplementedError = transportErrors.NoAckError = transportErrors.DuplicateCorrelationError = transportErrors.UnexpectedActionError = transportErrors.DisconnectedError = void 0;
+class DisconnectedError extends Error {
+ constructor(readyState) {
+ super(`Expected websocket state OPEN but found ${readyState}`);
+ this.readyState = readyState;
+ }
+}
+transportErrors.DisconnectedError = DisconnectedError;
+class UnexpectedActionError extends Error {
+}
+transportErrors.UnexpectedActionError = UnexpectedActionError;
+class DuplicateCorrelationError extends Error {
+}
+transportErrors.DuplicateCorrelationError = DuplicateCorrelationError;
+class NoAckError extends Error {
+}
+transportErrors.NoAckError = NoAckError;
+class NotImplementedError extends Error {
+}
+transportErrors.NotImplementedError = NotImplementedError;
+class NotSupportedError extends Error {
+}
+transportErrors.NotSupportedError = NotSupportedError;
+class InternalError extends Error {
+ constructor(err) {
+ const { message, name, stack, ...rest } = err;
+ super(message);
+ this.name = name || 'Error';
+ this.stack = stack ?? this.toString();
+ Object.keys(rest).forEach(key => {
+ this[key] = rest[key];
+ });
+ }
+}
+// For documentation of the error methods being used see here: https://v8.dev/docs/stack-trace-api
+class RuntimeError extends Error {
+ static getCallSite(callsToRemove = 0) {
+ const length = Error.stackTraceLimit;
+ const realCallsToRemove = callsToRemove + 1; // remove this call;
+ Error.stackTraceLimit = length + realCallsToRemove;
+ // eslint-disable-next-line no-underscore-dangle
+ const _prepareStackTrace = Error.prepareStackTrace;
+ // This will be called when we access the `stack` property
+ Error.prepareStackTrace = (_, stack) => stack;
+ // stack is optional in non chromium contexts
+ const stack = new Error().stack?.slice(realCallsToRemove) ?? [];
+ Error.prepareStackTrace = _prepareStackTrace;
+ Error.stackTraceLimit = length;
+ return stack;
+ }
+ static prepareStackTrace(err, callSites) {
+ if (typeof Error.prepareStackTrace === 'function') {
+ return Error.prepareStackTrace(err, callSites);
+ }
+ let string = "";
+ string += err.name || "Error";
+ string += `: ${err.message || ""}`;
+ for (const callSite of callSites) {
+ string += `\n at ${callSite.toString()}`;
+ }
+ return string;
+ }
+ ;
+ constructor(payload, callSites) {
+ const { reason, error } = payload;
+ super(reason);
+ this.name = 'RuntimeError';
+ if (error?.stack) {
+ this.cause = new InternalError(error);
+ }
+ if (callSites) {
+ this.stack = RuntimeError.prepareStackTrace(this, callSites);
+ }
+ }
+}
+transportErrors.RuntimeError = RuntimeError;
+
+var window$1 = {};
+
+var Factory$8 = {};
+
+var validate = {};
+
+Object.defineProperty(validate, "__esModule", { value: true });
+validate.validateIdentity = void 0;
+function validateIdentity(identity) {
+ let errorMsg;
+ if (typeof identity !== 'object' || typeof identity.uuid !== 'string') {
+ errorMsg = 'Not a valid identity object';
+ }
+ return errorMsg;
+}
+validate.validateIdentity = validateIdentity;
+
+var Instance$7 = {};
+
+var application = {};
+
+var Factory$7 = {};
+
+var Instance$6 = {};
+
+var view = {};
+
+var Factory$6 = {};
+
+var warnings = {};
+
+Object.defineProperty(warnings, "__esModule", { value: true });
+warnings.handleDeprecatedWarnings = void 0;
+const handleDeprecatedWarnings = (options) => {
+ if (options.contentNavigation?.whitelist ||
+ options.contentNavigation?.blacklist ||
+ options.contentRedirect?.whitelist ||
+ options.contentRedirect?.blacklist) {
+ console.warn(`The properties 'whitelist' and 'blacklist' have been marked as deprecated and will be removed in a future version. Please use 'allowlist' and 'denylist'.`);
+ }
+};
+warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
+
+var hasRequiredFactory$3;
+
+function requireFactory$3 () {
+ if (hasRequiredFactory$3) return Factory$6;
+ hasRequiredFactory$3 = 1;
+ Object.defineProperty(Factory$6, "__esModule", { value: true });
+ Factory$6.ViewModule = void 0;
+ const base_1 = base;
+ const validate_1 = validate;
+ const index_1 = requireView();
+ const warnings_1 = warnings;
+ /**
+ * Static namespace for OpenFin API methods that interact with the {@link View} class, available under `fin.View`.
+ */
+ class ViewModule extends base_1.Base {
+ /**
+ * Creates a new View.
+ * @param options - View creation options
+ *
+ * @example
+ * ```js
+ * let view;
+ * async function createView() {
+ * const me = await fin.Window.getCurrent();
+ * return fin.View.create({
+ * name: 'viewNameCreate',
+ * target: me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ * }
+ *
+ * createView()
+ * .then((createdView) => {
+ * view = createdView;
+ * console.log('View created.', view);
+ * view.navigate('https://google.com');
+ * console.log('View navigated to given url.');
+ * })
+ * .catch(err => console.log(err));
+ * ```
+ * Note that created views needs to navigate somewhere for them to actually render a website.
+ * @experimental
+ */
+ async create(options) {
+ const { uuid } = this.wire.me;
+ if (!options.name || typeof options.name !== 'string') {
+ throw new Error('Please provide a name property as a string in order to create a View.');
+ }
+ (0, warnings_1.handleDeprecatedWarnings)(options);
+ if (this.wire.environment.childViews) {
+ await this.wire.environment.createChildContent({
+ entityType: 'view',
+ options: { ...options, uuid }
+ });
+ }
+ else {
+ await this.wire.sendAction('create-view', { ...options, uuid });
+ }
+ return this.wrapSync({ uuid, name: options.name });
+ }
+ /**
+ * Asynchronously returns an API handle for the given View identity.
+ *
+ * @remarks Wrapping a View identity that does not yet exist will *not* throw an error, and instead
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
+ * for a View throughout its entire lifecycle.
+ *
+ * @example
+ * ```js
+ * fin.View.wrap({ uuid: 'testViewUuid', name: 'testViewName' }))
+ * .then(view => console.log('wrapped view', view))
+ * .catch(err => console.log(err));
+ * ```
+ * @experimental
+ */
+ async wrap(identity) {
+ this.wire.sendAction('view-wrap').catch((e) => {
+ // we do not want to expose this error, just continue if this analytics-only call fails
+ });
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
+ if (errorMsg) {
+ throw new Error(errorMsg);
+ }
+ return new index_1.View(this.wire, identity);
+ }
+ /**
+ * Synchronously returns an API handle for the given View identity.
+ *
+ * @remarks Wrapping a View identity that does not yet exist will *not* throw an error, and instead
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
+ * for a View throughout its entire lifecycle.
+ *
+ * @example
+ * ```js
+ * const view = fin.View.wrapSync({ uuid: 'testView', name: 'testViewName' });
+ * await view.hide();
+ * ```
+ * @experimental
+ */
+ wrapSync(identity) {
+ this.wire.sendAction('view-wrap-sync').catch((e) => {
+ // we do not want to expose this error, just continue if this analytics-only call fails
+ });
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
+ if (errorMsg) {
+ throw new Error(errorMsg);
+ }
+ return new index_1.View(this.wire, identity);
+ }
+ /**
+ * Asynchronously returns a View object that represents the current view
+ *
+ * @example
+ * ```js
+ * fin.View.getCurrent()
+ * .then(view => console.log('current view', view))
+ * .catch(err => console.log(err));
+ *
+ * ```
+ * @experimental
+ */
+ getCurrent() {
+ this.wire.sendAction('view-get-current').catch((e) => {
+ // we do not want to expose this error, just continue if this analytics-only call fails
+ });
+ if (!this.wire.me.isView) {
+ throw new Error('You are not in a View context');
+ }
+ const { uuid, name } = this.wire.me;
+ return this.wrap({ uuid, name });
+ }
+ /**
+ * Synchronously returns a View object that represents the current view
+ *
+ * @example
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ * console.log(view);
+ *
+ * ```
+ * @experimental
+ */
+ getCurrentSync() {
+ this.wire.sendAction('view-get-current-sync').catch((e) => {
+ // we do not want to expose this error, just continue if this analytics-only call fails
+ });
+ if (!this.wire.me.isView) {
+ throw new Error('You are not in a View context');
+ }
+ const { uuid, name } = this.wire.me;
+ return this.wrapSync({ uuid, name });
+ }
+ }
+ Factory$6.ViewModule = ViewModule;
+ return Factory$6;
+}
+
+var Instance$5 = {};
+
+var lazy = {};
+
+Object.defineProperty(lazy, "__esModule", { value: true });
+lazy.AsyncRetryableLazy = lazy.Lazy = void 0;
+/**
+ * Handy class for managing asynchronous dependencies of classes.
+ *
+ * Will call the producer function once and only once when getValue is called,
+ * returning the resultant value for every subsequent call.
+ */
+class Lazy {
+ // eslint-disable-next-line
+ constructor(producerFn) {
+ this.producerFn = producerFn;
+ }
+ /**
+ * Lazily get the value returned by the producer.
+ * @returns The value returned from the producer function
+ */
+ getValue() {
+ if (!this.value) {
+ this.value = this.producerFn();
+ }
+ return this.value;
+ }
+}
+lazy.Lazy = Lazy;
+/**
+ * Handy class for managing asynchronous dependencies of classes.
+ *
+ * Will call asynchronous producer only after `getValue` is called. If the
+ * deferred code errors, we can try it again by re-calling `getValue` after
+ * the promise rejects.
+ */
+class AsyncRetryableLazy {
+ // eslint-disable-next-line
+ constructor(producerFn) {
+ this.producerFn = producerFn;
+ }
+ /**
+ * Lazily get the value returned by the async producer.
+ *
+ * @returns The value returned from the producer function
+ */
+ async getValue() {
+ if (!this.promise) {
+ this.promise = this.producerFn().catch((e) => {
+ delete this.promise;
+ throw e;
+ });
+ }
+ return this.promise;
+ }
+}
+lazy.AsyncRetryableLazy = AsyncRetryableLazy;
+
+var layoutEntities = {};
+
+var apiExposer$1 = {};
+
+var apiConsumer = {};
+
+Object.defineProperty(apiConsumer, "__esModule", { value: true });
+apiConsumer.ApiConsumer = void 0;
+/**
+ * Consumer for apis exposed with {@see ApiExposer}.
+ *
+ * A strategy that matches the strategy used to expose a target API must be provided.
+ */
+class ApiConsumer {
+ // eslint-disable-next-line
+ constructor(strategy) {
+ this.strategy = strategy;
+ /**
+ * Consumes an api exposed using a given transport strategy, and generates a client
+ * for easy, type safe consumption of that client.
+ * @param options Strategy specific consumption options.
+ * @returns An api client matching the given type.
+ */
+ this.consume = async (options) => {
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
+ return exposedProperties.reduce((client, prop) => ({
+ ...client,
+ [prop.key]: this.strategy.createFunction(prop, options)
+ }), {});
+ };
+ }
+}
+apiConsumer.ApiConsumer = ApiConsumer;
+
+var apiExposer = {};
+
+var decorators = {};
+
+Object.defineProperty(decorators, "__esModule", { value: true });
+decorators.expose = decorators.getExposedProperties = void 0;
+const exposedProperties = Symbol('exposedProperties');
+const getExposedProperties = (target) => {
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
+};
+decorators.getExposedProperties = getExposedProperties;
+/**
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
+ * @param options Options specific to the strategy used in {@link ApiExposer}
+ */
+// Returns any as decorator typing is weird.
+const expose = (options) => (target, key, descriptor) => {
+ target[exposedProperties] = target[exposedProperties] || [];
+ target[exposedProperties].push({ key, descriptor, options });
+};
+decorators.expose = expose;
+
+Object.defineProperty(apiExposer, "__esModule", { value: true });
+apiExposer.ApiExposer = void 0;
+const decorators_1 = decorators;
+/**
+ * Exposes api services on the transport of choice.
+ */
+class ApiExposer {
+ /**
+ * @param strategy The expose strategy to use to expose instances.
+ */
+ // eslint-disable-next-line
+ constructor(strategy) {
+ this.strategy = strategy;
+ /**
+ * Exposes an instance of a given api on
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
+ * @param instanceOptions Transport strategy specific options to use when exposing.
+ */
+ this.exposeInstance = async (instance, instanceOptions) => {
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
+ key,
+ options,
+ meta: instanceOptions
+ });
+ return {
+ key,
+ options: customConsumptionOptions
+ };
+ }));
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
+ };
+ }
+ ;
+}
+apiExposer.ApiExposer = ApiExposer;
+
+var strategies = {};
+
+var openfinChannels = {};
+
+var channelsConsumer = {};
+
+Object.defineProperty(channelsConsumer, "__esModule", { value: true });
+channelsConsumer.ChannelsConsumer = void 0;
+class ChannelsConsumer {
+ // eslint-disable-next-line
+ constructor(channel) {
+ this.channel = channel;
+ this.getExposedFunctions = async (options) => {
+ const { id } = options;
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
+ return props;
+ };
+ this.createFunction = (prop) => (...args) => {
+ const { action } = prop.options;
+ return this.channel.dispatch(action, { args });
+ };
+ }
+ ;
+}
+channelsConsumer.ChannelsConsumer = ChannelsConsumer;
+
+var channelsExposer = {};
+
+Object.defineProperty(channelsExposer, "__esModule", { value: true });
+channelsExposer.ChannelsExposer = void 0;
+class ChannelsExposer {
+ // eslint-disable-next-line
+ constructor(channelProviderOrClient) {
+ this.channelProviderOrClient = channelProviderOrClient;
+ this.exposeFunction = async (target, config) => {
+ const { key, options, meta } = config;
+ const { id } = meta;
+ const action = `${id}.${options?.action || key}`;
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
+ return target(...args);
+ });
+ return { action };
+ };
+ this.exposeMeta = async ({ id }, props) => {
+ const action = `api-meta:${id}`;
+ await this.channelProviderOrClient.register(action, () => ({ props }));
+ };
+ }
+}
+channelsExposer.ChannelsExposer = ChannelsExposer;
+
+(function (exports) {
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+ }) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+ }));
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+ };
+ Object.defineProperty(exports, "__esModule", { value: true });
+ __exportStar(channelsConsumer, exports);
+ __exportStar(channelsExposer, exports);
+} (openfinChannels));
+
+(function (exports) {
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+ }) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+ }));
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+ };
+ Object.defineProperty(exports, "__esModule", { value: true });
+ __exportStar(openfinChannels, exports);
+} (strategies));
+
+(function (exports) {
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+ }) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+ }));
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+ };
+ Object.defineProperty(exports, "__esModule", { value: true });
+ __exportStar(apiConsumer, exports);
+ __exportStar(apiExposer, exports);
+ __exportStar(strategies, exports);
+ __exportStar(decorators, exports);
+} (apiExposer$1));
+
+var channelApiRelay = {};
+
+Object.defineProperty(channelApiRelay, "__esModule", { value: true });
+channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
+const EXPECTED_ERRORS = [
+ 'no longer connected',
+ 'RTCDataChannel closed unexpectedly',
+ 'The client you are trying to dispatch from is disconnected from the target provider',
+];
+// Checks possible error messages that we want to trap, client error message can originate
+// from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
+const isDisconnectedError = (errorMsg) => {
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
+};
+/**
+ * @internal
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
+ * actions to the designated clients.
+ *
+ * Designed to be used in conjunction with @expose
+ *
+ * @param channelProvider The channel provider to relay the actions on.
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
+ */
+const relayChannelClientApi = async (channelProvider, relayId) => {
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
+ return channelProvider.dispatch(target, action, payload);
+ });
+ await Promise.resolve();
+};
+channelApiRelay.relayChannelClientApi = relayChannelClientApi;
+const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
+ try {
+ return await client.dispatch(`relay:${relayId}`, {
+ action,
+ payload,
+ target
+ });
+ }
+ catch (e) {
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
+ throw new Error(relayErrorMsg);
+ }
+ throw e;
+ }
+};
+channelApiRelay.createRelayedDispatch = createRelayedDispatch;
+
+var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
+ if (kind === "m") throw new TypeError("Private method is not writable");
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
+};
+var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
+};
+var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
+Object.defineProperty(layoutEntities, "__esModule", { value: true });
+layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
+const api_exposer_1 = apiExposer$1;
+const channel_api_relay_1 = channelApiRelay;
+/*
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
+ refs, we define and export all the classes here.
+*/
+/**
+ * @ignore
+ * @internal
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
+ */
+class LayoutNode {
+ /**
+ * @internal
+ * @ignore
+ */
+ constructor(client, entityId) {
+ /**
+ * @ignore
+ * @internal
+ * ApiClient for {@link LayoutEntitiesController}
+ */
+ _LayoutNode_client.set(this, void 0);
+ /**
+ * Checks if the TabStack or ColumnOrRow is the root content item
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * const isRoot = await stack.isRoot();
+ * // The TabStack is root: false
+ * console.log(`The TabStack is root: ${isRoot}`);
+ *
+ * // Retrieves the parent ColumnOrRow
+ * const parent = await stack.getParent();
+ * const parentIsRoot = await parent.isRoot();
+ * // The parent ColumnOrRow is root: true
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
+ * ```
+ */
+ this.isRoot = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").isRoot(this.entityId);
+ /**
+ * Checks if the TabStack or ColumnOrRow exists
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * // Retrieves the parent ColumnOrRow
+ * const columnOrRow = await stack.getParent();
+ * let exists = await stack.exists();
+ * // or
+ * let exists = await columnOrRow.exists();
+ * // The entity exists: true
+ * console.log(`The entity exists: ${exists}`);
+ * ```
+ */
+ this.exists = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").exists(this.entityId);
+ /**
+ * Retrieves the parent of the TabStack or ColumnOrRow
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * // Retrieves the parent ColumnOrRow
+ * const columnOrRow = await stack.getParent();
+ *
+ * // undefined if entity is the root item
+ * let parent = await columnOrRow.getParent();
+ * // or
+ * let parent = await stack.getParent();
+ * ```
+ */
+ this.getParent = async () => {
+ const parent = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getParent(this.entityId);
+ if (!parent) {
+ return undefined;
+ }
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
+ };
+ /**
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
+ *
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
+ *
+ * @param views The views that will populate the new TabStack.
+ * @param options Additional options that control new TabStack creation.
+ * @returns The newly-created TabStack.
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * const columnOrRow = await stack.getParent();
+ *
+ * // Create view references by supplying a 'name' and 'url'
+ * const views = [
+ * // if 'name' is undefined, one will be generated
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
+ * { name: 'google-view', url: 'http://google.com/'},
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
+ * ];
+ *
+ * // Create a view beforehand to be included in the new tab stack
+ * const outsideView = await fin.View.create({
+ * name: 'outside-bloomberg-view',
+ * url: 'https://bloomberg.com/',
+ * target: fin.me.identity,
+ * });
+ *
+ * // Views to add can be identities, or the reference views mentioned above
+ * const viewsToAdd = [outsideView.identity, ...views];
+ *
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
+ * // Or
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
+ *
+ * ```
+ * @experimental
+ */
+ this.createAdjacentStack = async (views, options) => {
+ const entityId = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
+ };
+ /**
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
+ *
+ * @param edge Edge whose adjacent TabStacks will be returned.
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * const columnOrRow = await stack.getParent();
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
+ * // or
+ * let rightStacks = await stack.getAdjacentStacks('right');
+ * let leftStacks = await stack.getAdjacentStacks('left');
+ *
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
+ *
+ * ```
+ * @experimental
+ */
+ this.getAdjacentStacks = async (edge) => {
+ const adjacentStacks = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getAdjacentStacks({
+ targetId: this.entityId,
+ edge
+ });
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
+ type: 'stack',
+ entityId: stack.entityId
+ }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f")));
+ };
+ __classPrivateFieldSet$b(this, _LayoutNode_client, client, "f");
+ this.entityId = entityId;
+ }
+}
+layoutEntities.LayoutNode = LayoutNode;
+_LayoutNode_client = new WeakMap();
+/**
+ * @ignore
+ * @internal
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
+ * @param client
+ * @param controllerId
+ * @param identity
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
+ */
+LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
+ const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that does not exist or has been destroyed.');
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
+ return consumer.consume({ id: controllerId });
+};
+LayoutNode.getEntity = (definition, client) => {
+ const { entityId, type } = definition;
+ switch (type) {
+ case 'column':
+ case 'row':
+ return new ColumnOrRow(client, entityId, type);
+ case 'stack':
+ return new TabStack(client, entityId);
+ default:
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
+ }
+};
+/**
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
+ */
+class TabStack extends LayoutNode {
+ /** @internal */
+ constructor(client, entityId) {
+ super(client, entityId);
+ /**
+ * @internal
+ * ApiClient for {@link LayoutEntitiesController}
+ */
+ _TabStack_client.set(this, void 0);
+ /**
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
+ */
+ this.type = 'stack';
+ /**
+ * Retrieves a list of all views belonging to this {@link TabStack}.
+ *
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
+ * If that happens and then getViews() is called, it will return the identities in a different order than
+ * than the currently rendered tab order.
+ *
+ *
+ * @throws If the {@link TabStack} has been destroyed.
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * // Alternatively, you can wrap any view and get the stack from there
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
+ * // const stack = await viewFromSomewhere.getCurrentStack();
+ * const views = await stack.getViews();
+ * console.log(`Stack contains ${views.length} view(s)`);
+ * ```
+ * @experimental
+ */
+ this.getViews = () => __classPrivateFieldGet$d(this, _TabStack_client, "f").getStackViews(this.entityId);
+ /**
+ * Adds or creates a view in this {@link TabStack}.
+ *
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
+ *
+ * @param view The identity of an existing view to add, or options to create a view.
+ * @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
+ * @throws If the view does not exist or fails to create.
+ * @throws If the {@link TabStack} has been destroyed.
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * // Alternatively, you can wrap any view and get the stack from there
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
+ * // const stack = await viewFromSomewhere.getCurrentStack();
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
+ * console.log('Identity of the google view just added', { googleViewIdentity });
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
+ * ```
+ * @experimental
+ */
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$d(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
+ /**
+ * Removes a view from this {@link TabStack}.
+ *
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
+ *
+ * @param view - Identity of the view to remove.
+ * @throws If the view does not exist or does not belong to the stack.
+ * @throws If the {@link TabStack} has been destroyed.
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
+ *
+ * await stack.removeView(googleViewIdentity);
+ *
+ * try {
+ * await stack.removeView(googleViewIdentity);
+ * } catch (error) {
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
+ * console.log(error);
+ * }
+ * ```
+ */
+ this.removeView = async (view) => {
+ await __classPrivateFieldGet$d(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
+ };
+ /**
+ * Sets the active view of the {@link TabStack} without focusing it.
+ * @param view - Identity of the view to activate.
+ * @returns Promise which resolves with void once the view has been activated.
+ * @throws If the {@link TabStack} has been destroyed.
+ * @throws If the view does not exist.
+ * @example
+ * Change the active tab of a known View's TabStack:
+ * ```js
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
+ * const stack = await targetView.getCurrentStack();
+ * await stack.setActiveView(targetView.identity);
+ * ```
+ *
+ * Set the current View as active within its TabStack:
+ * ```js
+ * const stack = await fin.me.getCurrentStack();
+ * await stack.setActiveView(fin.me.identity);
+ * ```
+ * @experimental
+ */
+ this.setActiveView = async (view) => {
+ await __classPrivateFieldGet$d(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
+ };
+ __classPrivateFieldSet$b(this, _TabStack_client, client, "f");
+ }
+}
+layoutEntities.TabStack = TabStack;
+_TabStack_client = new WeakMap();
+/**
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
+ */
+class ColumnOrRow extends LayoutNode {
+ /**
+ * @internal
+ */
+ constructor(client, entityId, type) {
+ super(client, entityId);
+ /**
+ * @ignore
+ * @internal
+ * ApiClient for {@link LayoutEntitiesController}
+ */
+ _ColumnOrRow_client.set(this, void 0);
+ /**
+ * Retrieves the content array of the ColumnOrRow
+ *
+ * @example
+ * ```js
+ * if (!fin.me.isView) {
+ * throw new Error('Not running in a platform View.');
+ * }
+ *
+ * const stack = await fin.me.getCurrentStack();
+ * // Retrieves the parent ColumnOrRow
+ * const columnOrRow = await stack.getParent();
+ *
+ * // returns [TabStack]
+ * const contentArray = await columnOrRow.getContent();
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
+ * ```
+ */
+ this.getContent = async () => {
+ const contentItemEntities = await __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f").getContent(this.entityId);
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f")));
+ };
+ __classPrivateFieldSet$b(this, _ColumnOrRow_client, client, "f");
+ this.type = type;
+ }
+}
+layoutEntities.ColumnOrRow = ColumnOrRow;
+_ColumnOrRow_client = new WeakMap();
+
+var layout_constants = {};
+
+Object.defineProperty(layout_constants, "__esModule", { value: true });
+layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
+layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
+// TODO: eventually export this somehow
+layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
+
+var main = {};
+
+Object.defineProperty(main, "__esModule", { value: true });
+main.WebContents = void 0;
+const base_1$j = base;
+class WebContents extends base_1$j.EmitterBase {
+ /**
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
+ */
+ constructor(wire, identity, entityType) {
+ super(wire, entityType, identity.uuid, identity.name);
+ this.identity = identity;
+ this.entityType = entityType;
+ }
+ /**
+ * Gets a base64 encoded image of all or part of the WebContents.
+ * @param options Options for the capturePage call.
+ *
+ * @example
+ *
+ * View:
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ *
+ * // PNG image of a full visible View
+ * console.log(await view.capturePage());
+ *
+ * // Low-quality JPEG image of a defined visible area of the view
+ * const options = {
+ * area: {
+ * height: 100,
+ * width: 100,
+ * x: 10,
+ * y: 10,
+ * },
+ * format: 'jpg',
+ * quality: 20
+ * }
+ * console.log(await view.capturePage(options));
+ * ```
+ *
+ * Window:
+ * ```js
+ * const wnd = await fin.Window.getCurrent();
+ *
+ * // PNG image of a full visible window
+ * console.log(await wnd.capturePage());
+ *
+ * // Low-quality JPEG image of a defined visible area of the window
+ * const options = {
+ * area: {
+ * height: 100,
+ * width: 100,
+ * x: 10,
+ * y: 10,
+ * },
+ * format: 'jpg',
+ * quality: 20
+ * }
+ * console.log(await wnd.capturePage(options));
+ * ```
+ *
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ capturePage(options) {
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
+ }
+ /**
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
+ * applications you have created.
+ * @param code JavaScript code to be executed on the view.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function executeJavaScript(code) {
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
+ * return await view.executeJavaScript(code);
+ * }
+ *
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function executeJavaScript(code) {
+ * const app = await fin.Application.start({
+ * name: 'myApp',
+ * uuid: 'app-1',
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
+ * autoShow: true
+ * });
+ * const win = await app.getWindow();
+ * return await win.executeJavaScript(code);
+ * }
+ *
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ executeJavaScript(code) {
+ return this.wire
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
+ .then(({ payload }) => payload.data);
+ }
+ /**
+ * Returns the zoom level of the WebContents.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function getZoomLevel() {
+ * const view = await fin.View.getCurrent();
+ * return await view.getZoomLevel();
+ * }
+ *
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function createWin() {
+ * const app = await fin.Application.start({
+ * name: 'myApp',
+ * uuid: 'app-1',
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
+ * autoShow: true
+ * });
+ * return await app.getWindow();
+ * }
+ *
+ * async function getZoomLevel() {
+ * const win = await createWin();
+ * return await win.getZoomLevel();
+ * }
+ *
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ getZoomLevel() {
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
+ }
+ /**
+ * Sets the zoom level of the WebContents.
+ * @param level The zoom level
+ *
+ * @example
+ * View:
+ * ```js
+ * async function setZoomLevel(number) {
+ * const view = await fin.View.getCurrent();
+ * return await view.setZoomLevel(number);
+ * }
+ *
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function createWin() {
+ * const app = await fin.Application.start({
+ * name: 'myApp',
+ * uuid: 'app-1',
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
+ * autoShow: true
+ * });
+ * return await app.getWindow();
+ * }
+ *
+ * async function setZoomLevel(number) {
+ * const win = await createWin();
+ * return await win.setZoomLevel(number);
+ * }
+ *
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ setZoomLevel(level) {
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
+ }
+ /**
+ * Navigates the WebContents to a specified URL.
+ *
+ * Note: The url must contain the protocol prefix such as http:// or https://.
+ * @param url - The URL to navigate the WebContents to.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function createView() {
+ * const me = await fin.Window.getCurrent();
+ * return fin.View.create({
+ * name: 'viewName',
+ * target: me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ * }
+ *
+ * createView()
+ * .then(view => view.navigate('https://example.com'))
+ * .then(() => console.log('navigation complete'))
+ * .catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function navigate() {
+ * const win = await fin.Window.getCurrent();
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
+ * }
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
+ * ```
+ * @experimental
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ navigate(url) {
+ return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
+ }
+ /**
+ * Navigates the WebContents back one page.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function navigateBack() {
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
+ * await view.navigate('https://www.google.com');
+ * return await view.navigateBack();
+ * }
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function navigateBack() {
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
+ * await win.navigate('https://www.google.com');
+ * return await win.navigateBack();
+ * }
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ navigateBack() {
+ return this.wire.sendAction('navigate-window-back', { ...this.identity }).then(() => undefined);
+ }
+ /**
+ * Navigates the WebContents forward one page.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function navigateForward() {
+ * const view = await fin.View.getCurrent();
+ * await view.navigate('https://www.google.com');
+ * await view.navigateBack();
+ * return await view.navigateForward();
+ * }
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function navigateForward() {
+ * const win = await fin.Window.getCurrent();
+ * await win.navigate('https://www.google.com');
+ * await win.navigateBack();
+ * return await win.navigateForward();
+ * }
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async navigateForward() {
+ await this.wire.sendAction('navigate-window-forward', { ...this.identity });
+ }
+ /**
+ * Stops any current navigation the WebContents is performing.
+ *
+ * @example
+ * View:
+ * ```js
+ * async function stopNavigation() {
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
+ * await view.navigate('https://www.google.com');
+ * return await view.stopNavigation();
+ * }
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function stopNavigation() {
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
+ * await win.navigate('https://www.google.com');
+ * return await win.stopNavigation();
+ * }
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ stopNavigation() {
+ return this.wire.sendAction('stop-window-navigation', { ...this.identity }).then(() => undefined);
+ }
+ /**
+ * Reloads the WebContents
+ *
+ * @example
+ * View:
+ * ```js
+ * async function reload() {
+ * const view = await fin.View.getCurrent();
+ * return await view.reload();
+ * }
+ *
+ * reload().then(() => {
+ * console.log('Reloaded view')
+ * }).catch(err => console.log(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function reloadWindow() {
+ * const app = await fin.Application.start({
+ * name: 'myApp',
+ * uuid: 'app-1',
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.reload.html',
+ * autoShow: true
+ * });
+ * const win = await app.getWindow();
+ * return await win.reload();
+ * }
+ *
+ * reloadWindow().then(() => {
+ * console.log('Reloaded window')
+ * }).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ reload(ignoreCache = false) {
+ return this.wire
+ .sendAction('reload-window', {
+ ignoreCache,
+ ...this.identity
+ })
+ .then(() => undefined);
+ }
+ /**
+ * Prints the WebContents.
+ * @param options Printer Options
+ *
+ * Note: When `silent` is set to `true`, the API will pick the system's default printer if deviceName
+ * is empty and the default settings for printing.
+ *
+ * Use the CSS style `page-break-before: always;` to force print to a new page.
+ *
+ * @example
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ *
+ * view.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
+ * console.log('print call has been sent to the system');
+ * });
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ print(options = {}) {
+ return this.wire.sendAction('print', { ...this.identity, options }).then(() => undefined);
+ }
+ /**
+ * Find and highlight text on a page.
+ * @param searchTerm Term to find in page
+ * @param options Search options
+ *
+ * Note: By default, each subsequent call will highlight the next text that matches the search term.
+ *
+ * Returns a promise with the results for the request. By subscribing to the
+ * found-in-page event, you can get the results of this call as well.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ *
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
+ * view.addListener('found-in-page', (event) => {
+ * console.log(event);
+ * });
+ *
+ * // The promise also returns the results for the request
+ * view.findInPage('a').then((result) => {
+ * console.log(result)
+ * });
+ * ```
+ *
+ * Window:
+ * ```js
+ * const win = fin.Window.getCurrentSync();
+ *
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
+ * win.addListener('found-in-page', (event) => {
+ * console.log(event);
+ * });
+ *
+ * // The promise also returns the results for the request
+ * win.findInPage('a').then((result) => {
+ * console.log(result)
+ * });
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ findInPage(searchTerm, options) {
+ return this.wire
+ .sendAction('find-in-page', { ...this.identity, searchTerm, options })
+ .then(({ payload }) => payload.data);
+ }
+ /**
+ * Stop a {@link View#findInPage findInPage} call by specifying any of these actions:
+ *
+ * * clearSelection - Clear the selection.
+ * * keepSelection - Translate the selection into a normal selection.
+ * * activateSelection - Focus and click the selection node.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ *
+ * view.addListener('found-in-page', (event) => {
+ * setTimeout(() => {
+ * view.stopFindInPage('clearSelection');
+ * }, 5000);
+ * });
+ *
+ * view.findInPage('a').then(results => {
+ * console.log(results);
+ * });
+ * ```
+ *
+ * Window:
+ * ```js
+ * const win = fin.Window.getCurrentSync();
+ *
+ * win.addListener('found-in-page', (event) => {
+ * setTimeout(() => {
+ * win.stopFindInPage('clearSelection');
+ * }, 5000);
+ * });
+ *
+ * win.findInPage('a').then(results => {
+ * console.log(results);
+ * });
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ stopFindInPage(action) {
+ return this.wire.sendAction('stop-find-in-page', { ...this.identity, action }).then(() => undefined);
+ }
+ /**
+ * Returns an array with all system printers
+ * @deprecated use System.getPrinters instead
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = fin.View.getCurrentSync();
+ *
+ * view.getPrinters()
+ * .then((printers) => {
+ * printers.forEach((printer) => {
+ * if (printer.isDefault) {
+ * console.log(printer);
+ * }
+ * });
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * });
+ * ```
+ *
+ * Window:
+ * ```js
+ * const win = fin.Window.getCurrentSync();
+ *
+ * win.getPrinters()
+ * .then((printers) => {
+ * printers.forEach((printer) => {
+ * if (printer.isDefault) {
+ * console.log(printer);
+ * }
+ * });
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * });
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ getPrinters() {
+ return this.wire.sendAction('get-printers', { ...this.identity }).then(({ payload }) => payload.data);
+ }
+ /**
+ * Gives focus to the WebContents.
+ *
+ * @example
+ * ```js
+ * async function focusWindow() {
+ * const app = await fin.Application.start({
+ * name: 'myApp',
+ * uuid: 'app-1',
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.focus.html',
+ * autoShow: true
+ * });
+ * const win = await app.getWindow();
+ * return await win.focus();
+ * }
+ *
+ * focusWindow().then(() => console.log('Window focused')).catch(err => console.log(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async focus({ emitSynthFocused } = { emitSynthFocused: true }) {
+ await this.wire.sendAction('focus-window', { emitSynthFocused, ...this.identity });
+ }
+ /**
+ * Shows the Chromium Developer Tools
+ *
+ * @example
+ * View:
+ * ```js
+ * async function showDeveloperTools() {
+ * const view = await fin.View.getCurrent();
+ * return view.showDeveloperTools();
+ * }
+ *
+ * showDevelopertools()
+ * .then(() => console.log('Showing dev tools'))
+ * .catch(err => console.error(err));
+ * ```
+ *
+ * Window:
+ * ```js
+ * async function showDeveloperTools() {
+ * const win = await fin.Window.getCurrent();
+ * return win.showDeveloperTools();
+ * }
+ *
+ * showDevelopertools()
+ * .then(() => console.log('Showing dev tools'))
+ * .catch(err => console.error(err));
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async showDeveloperTools() {
+ // Note this hits the system action map in core state for legacy reasons.
+ await this.wire.sendAction('show-developer-tools', this.identity);
+ }
+ /**
+ * Retrieves the process information associated with a WebContents.
+ *
+ * Note: This includes any iframes associated with the WebContents
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = await fin.View.getCurrent();
+ * const processInfo = await view.getProcessInfo();
+ * ```
+ *
+ * Window:
+ * ```js
+ * const win = await fin.Window.getCurrent();
+ * const processInfo = await win.getProcessInfo();
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async getProcessInfo() {
+ const { payload: { data } } = await this.wire.sendAction('get-process-info', this.identity);
+ return data;
+ }
+ /**
+ * Retrieves information on all Shared Workers.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = await fin.View.create({
+ * name: 'viewName',
+ * target: fin.me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ *
+ * await view.navigate('https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/');
+ *
+ * const sharedWorkers = await view.getSharedWorkers();
+ * ```
+ *
+ * Window:
+ * ```js
+ * const winOption = {
+ * name:'child',
+ * defaultWidth: 300,
+ * defaultHeight: 300,
+ * url: 'https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/',
+ * frame: true,
+ * autoShow: true
+ * };
+ * const win = await fin.Window.create(winOption);
+ * const sharedWorkers = await win.getSharedWorkers();
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async getSharedWorkers() {
+ return this.wire.sendAction('get-shared-workers', this.identity).then(({ payload }) => payload.data);
+ }
+ /**
+ * Opens the developer tools for the shared worker context.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = await fin.View.create({
+ * name: 'viewName',
+ * target: fin.me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ *
+ * await view.navigate('https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/');
+ *
+ * await view.inspectSharedWorker();
+ * ```
+ *
+ * Example:
+ * ```js
+ * const winOption = {
+ * name:'child',
+ * defaultWidth: 300,
+ * defaultHeight: 300,
+ * url: 'https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/',
+ * frame: true,
+ * autoShow: true
+ * };
+ * const win = await fin.Window.create(winOption);
+ * await win.inspectSharedWorker();
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async inspectSharedWorker() {
+ await this.wire.sendAction('inspect-shared-worker', { ...this.identity });
+ }
+ /**
+ * Inspects the shared worker based on its ID.
+ * @param workerId - The id of the shared worker.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = await fin.View.create({
+ * name: 'viewName',
+ * target: fin.me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ *
+ * await view.navigate('https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/');
+ *
+ * const sharedWorkers = await view.getSharedWorkers();
+ * await view.inspectSharedWorkerById(sharedWorkers[0].id);
+ * ```
+ *
+ * Window:
+ * ```js
+ * const winOption = {
+ * name:'child',
+ * defaultWidth: 300,
+ * defaultHeight: 300,
+ * url: 'https://mdn.github.io/dom-examples/web-workers/simple-shared-worker/',
+ * frame: true,
+ * autoShow: true
+ * };
+ * const win = await fin.Window.create(winOption);
+ * const sharedWorkers = await win.getSharedWorkers();
+ * await win.inspectSharedWorkerById(sharedWorkers[0].id);
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async inspectSharedWorkerById(workerId) {
+ await this.wire.sendAction('inspect-shared-worker-by-id', { ...this.identity, workerId });
+ }
+ /**
+ * Opens the developer tools for the service worker context.
+ *
+ * @example
+ * View:
+ * ```js
+ * const view = await fin.View.create({
+ * name: 'viewName',
+ * target: fin.me.identity,
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
+ * });
+ *
+ * await view.navigate('http://googlechrome.github.io/samples/service-worker/basic/index.html');
+ *
+ * await view.inspectServiceWorker();
+ * ```
+ *
+ * Window:
+ * ```js
+ * const winOption = {
+ * name:'child',
+ * defaultWidth: 300,
+ * defaultHeight: 300,
+ * url: 'http://googlechrome.github.io/samples/service-worker/basic/index.html',
+ * frame: true,
+ * autoShow: true
+ * };
+ * const win = await fin.Window.create(winOption);
+ * await win.inspectServiceWorker();
+ * ```
+ * @remarks
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
+ * We do not expose an explicit superclass for this functionality, but it does have its own
+ * {@link OpenFin.WebContentsEvents event namespace}.
+ */
+ async inspectServiceWorker() {
+ await this.wire.sendAction('inspect-service-worker', { ...this.identity });
+ }
+ /**
+ * Shows a popup window.
+ *
+ * Note: If this WebContents is a view and its attached window has a popup open, this will close it.
+ *
+ * Shows a popup window. Including a `name` in `options` will attempt to show an existing window as a popup, if
+ * that window doesn't exist or no `name` is included a window will be created. If the caller view or the caller
+ * view's parent window currently has a popup window open, calling `showPopupWindow` again will dismiss the currently
+ * open popup window before showing the new popup window. Also, if the caller view is destroyed or detached, the popup
+ * will be dismissed.
+ *
+ * Note: in the case where the window being shown as a popup needs to be created, it is a child of the caller view's parent window.
+ *
+ * @example
+ *
+ * Create and show a single-use popup window that returns a single result to the caller. `initialOptions` allows
+ * us to pass window options to the popup window that will be created. `resultDispatchBehavior: 'close'` ensures
+ * that once the popup window calls `dispatchPopupResult` it is closed. `blurBehavior: 'close'` will yield a dismissed
+ * result should the popup window lose focus.
+ *
+ * ```js
+ * const result = await fin.me.showPopupWindow({
+ * initialOptions: {
+ * frame: false
+ * },
+ * url: '