@openfin/core 27.70.1 → 27.70.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OpenFin.d.ts CHANGED
@@ -874,7 +874,56 @@ declare namespace OpenFin {
874
874
  payload: import('./src/api/events/window').WindowOptionsChangedEvent<'window', 'options-changed'>
875
875
  ): Promise<OpenFin.HostContextChangedPayload | undefined>;
876
876
 
877
+ /**
878
+ * Closes a Window.
879
+ * By default it will fire any before unload handler set by a View in the Window.
880
+ * This can be disabled by setting skipBeforeUnload in the options object of the payload.
881
+ * This method is called by {@link Platform#closeWindow Platform.closeWindow}.
882
+ * @param {CloseWindowPayload} payload Object that contains the Window Identity and related options.
883
+ * @param {Identity} callerIdentity
884
+ * @returns {Promise<void>}
885
+ */
877
886
  closeWindow(payload: CloseWindowPayload, callerIdentity: Identity): Promise<void>;
887
+
888
+ /**
889
+ * Gets all the Views attached to a Window that should close along with it. This is meant to be overridable
890
+ * in the case where you want to return other Views that may not be attached to the Window that is closing.
891
+ * @param winId Identity of the Window that is closing
892
+ * @returns { Promise<View> }
893
+ */
894
+ getViewsForWindowClose(windowId: OpenFin.Identity): Promise<OpenFin.View[]>;
895
+
896
+ /**
897
+ * It takes in an array of Views and returns an object specifying which of them are trying to prevent an unload and which are not.
898
+ * @param {View[]} views Array of Views
899
+ * @returns { Promise<ViewStatuses> }
900
+ */
901
+ checkViewsForPreventUnload(views: OpenFin.View[]): Promise<OpenFin.ViewStatuses>;
902
+
903
+ /**
904
+ * Handle the decision of whether a Window or specific View should close when trying to prevent an unload. This is meant to be overridden.
905
+ * Called in {@link PlatformProvider#closeWindow PlatformProvider.closeWindow}.
906
+ * Normally you would use this method to show a dialog indicating that there are Views that are trying to prevent an unload.
907
+ * By default it will always return all Views passed into it as meaning to close.
908
+ * @param {ViewsPreventingUnloadPayload} payload
909
+ * @tutorial PlatformProvider.getUserDecisionForBeforeUnload
910
+ * @returns {Promise<BeforeUnloadUserDecision>}
911
+ */
912
+ getUserDecisionForBeforeUnload(
913
+ payload: OpenFin.ViewsPreventingUnloadPayload
914
+ ): Promise<OpenFin.BeforeUnloadUserDecision>;
915
+
916
+ /**
917
+ * Handles the closing of a Window and/or its Views. Called in {@link PlatformProvider#closeWindow PlatformProvider.closeWindow}.
918
+ * The return of {@link PlatformProvider#getUserDecisionForBeforeUnload PlatformProvider.getUserDecisionForBeforeUnload} is passed into this method.
919
+ * @param {Identity} winId Identity of the Window
920
+ * @param {BeforeUnloadUserDecision} userDecision Decision object
921
+ * @returns {Promise<void>}
922
+ */
923
+ handleViewsAndWindowClose(
924
+ windowId: OpenFin.Identity,
925
+ userDecision: OpenFin.BeforeUnloadUserDecision
926
+ ): Promise<void>;
878
927
  };
879
928
 
880
929
  export type InitPlatformOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "27.70.1",
3
+ "version": "27.70.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -119,6 +119,15 @@ export declare class Platform extends EmitterBase<PlatformEvents> {
119
119
  * @experimental
120
120
  */
121
121
  getWindowContext(target?: OpenFin.Identity): Promise<any>;
122
+ /**
123
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
124
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
125
+ * @param {Identity} winId
126
+ * @param {closeWindowoptions} [options]
127
+ * @returns {Promise<void>}
128
+ * @tutorial Platform.closeWindow
129
+ * @experimental
130
+ */
122
131
  closeWindow(windowId: OpenFin.Identity, options?: {
123
132
  skipBeforeUnload: boolean;
124
133
  }): Promise<void>;
@@ -293,6 +293,15 @@ class Platform extends base_1.EmitterBase {
293
293
  entityType
294
294
  });
295
295
  }
296
+ /**
297
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
298
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
299
+ * @param {Identity} winId
300
+ * @param {closeWindowoptions} [options]
301
+ * @returns {Promise<void>}
302
+ * @tutorial Platform.closeWindow
303
+ * @experimental
304
+ */
296
305
  async closeWindow(windowId, options = { skipBeforeUnload: false }) {
297
306
  this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
298
307
  // don't expose
@@ -384,5 +384,12 @@ export declare class View extends WebContents<ViewEvents> {
384
384
  * @experimental
385
385
  */
386
386
  getCurrentWindow: () => Promise<OpenFin.Window>;
387
+ /**
388
+ * 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.
389
+ * Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
390
+ * @returns {Promise<boolean>}
391
+ * @tutorial View.triggerBeforeUnload
392
+ * @experimental
393
+ */
387
394
  triggerBeforeUnload: () => Promise<boolean>;
388
395
  }
@@ -383,6 +383,13 @@ class View extends main_1.WebContents {
383
383
  const { payload: { data } } = await this.wire.sendAction('get-view-window', { ...this.identity });
384
384
  return new window_1._Window(this.wire, data);
385
385
  };
386
+ /**
387
+ * 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.
388
+ * Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
389
+ * @returns {Promise<boolean>}
390
+ * @tutorial View.triggerBeforeUnload
391
+ * @experimental
392
+ */
386
393
  this.triggerBeforeUnload = async () => {
387
394
  const message = await this.wire.sendAction('trigger-before-unload', { ...this.identity });
388
395
  return message.payload.data;