@openfin/core 27.70.2 → 27.70.5
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 +2 -1
- package/package.json +1 -1
- package/src/api/view/Instance.d.ts +9 -0
- package/src/api/view/Instance.js +12 -1
- package/src/api/webcontents/main.d.ts +1 -0
- package/src/api/webcontents/main.js +63 -0
- package/src/api/window/Instance.d.ts +3 -1
- package/src/api/window/Instance.js +3 -60
package/OpenFin.d.ts
CHANGED
|
@@ -1621,8 +1621,9 @@ declare namespace OpenFin {
|
|
|
1621
1621
|
|
|
1622
1622
|
export type PopupBlurBehavior = 'modal' | PopupBaseBehavior;
|
|
1623
1623
|
|
|
1624
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
1624
1625
|
export interface PopupOptions {
|
|
1625
|
-
initialOptions?: OpenFin.WindowCreationOptions
|
|
1626
|
+
initialOptions?: Optional<OpenFin.WindowCreationOptions, 'name'>;
|
|
1626
1627
|
additionalOptions?: OpenFin.UpdatableWindowOptions;
|
|
1627
1628
|
name?: string;
|
|
1628
1629
|
url?: string;
|
package/package.json
CHANGED
|
@@ -303,6 +303,15 @@ export declare class View extends WebContents<ViewEvents> {
|
|
|
303
303
|
* @return {Promise.<void>}
|
|
304
304
|
* @tutorial View.inspectServiceWorker
|
|
305
305
|
*/
|
|
306
|
+
/**
|
|
307
|
+
* Shows a popup window. If the window this view is currently attached to has a popup open, closes it.
|
|
308
|
+
* @function showPopupWindow
|
|
309
|
+
* @memberOf View
|
|
310
|
+
* @instance
|
|
311
|
+
* @param {PopupOptions} options
|
|
312
|
+
* @return {Promise<PopupResult>}
|
|
313
|
+
* @tutorial View.showPopupWindow
|
|
314
|
+
*/
|
|
306
315
|
/**
|
|
307
316
|
* Attaches the current view to a the given window identity.
|
|
308
317
|
* Identity must be the identity of a window in the same application.
|
package/src/api/view/Instance.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.View = void 0;
|
|
4
4
|
/* eslint-disable import/prefer-default-export */
|
|
5
|
+
/* eslint-disable consistent-return */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
5
7
|
const main_1 = require("../webcontents/main");
|
|
6
8
|
const window_1 = require("../window");
|
|
7
9
|
/**
|
|
@@ -273,6 +275,15 @@ class View extends main_1.WebContents {
|
|
|
273
275
|
* @return {Promise.<void>}
|
|
274
276
|
* @tutorial View.inspectServiceWorker
|
|
275
277
|
*/
|
|
278
|
+
/**
|
|
279
|
+
* Shows a popup window. If the window this view is currently attached to has a popup open, closes it.
|
|
280
|
+
* @function showPopupWindow
|
|
281
|
+
* @memberOf View
|
|
282
|
+
* @instance
|
|
283
|
+
* @param {PopupOptions} options
|
|
284
|
+
* @return {Promise<PopupResult>}
|
|
285
|
+
* @tutorial View.showPopupWindow
|
|
286
|
+
*/
|
|
276
287
|
/**
|
|
277
288
|
* Attaches the current view to a the given window identity.
|
|
278
289
|
* Identity must be the identity of a window in the same application.
|
|
@@ -349,7 +360,7 @@ class View extends main_1.WebContents {
|
|
|
349
360
|
* @experimental
|
|
350
361
|
*/
|
|
351
362
|
this.getParentLayout = async () => {
|
|
352
|
-
this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch((
|
|
363
|
+
this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
|
|
353
364
|
// don't expose
|
|
354
365
|
});
|
|
355
366
|
const currentWindow = await this.getCurrentWindow();
|
|
@@ -32,5 +32,6 @@ export declare class WebContents<T extends WebContentsEventMapping> extends Emit
|
|
|
32
32
|
inspectSharedWorker(): Promise<void>;
|
|
33
33
|
inspectSharedWorkerById(workerId: string): Promise<void>;
|
|
34
34
|
inspectServiceWorker(): Promise<void>;
|
|
35
|
+
showPopupWindow(options: OpenFin.PopupOptions): Promise<OpenFin.PopupResult>;
|
|
35
36
|
}
|
|
36
37
|
export {};
|
|
@@ -78,5 +78,68 @@ class WebContents extends base_1.EmitterBase {
|
|
|
78
78
|
async inspectServiceWorker() {
|
|
79
79
|
await this.wire.sendAction('inspect-service-worker', { ...this.identity });
|
|
80
80
|
}
|
|
81
|
+
async showPopupWindow(options) {
|
|
82
|
+
this.wire.sendAction(`${this.entityType}-show-popup-window`, this.identity).catch(() => {
|
|
83
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
84
|
+
});
|
|
85
|
+
if (options === null || options === void 0 ? void 0 : options.onPopupReady) {
|
|
86
|
+
const readyListener = async ({ popupName }) => {
|
|
87
|
+
try {
|
|
88
|
+
const popupWindow = this.fin.Window.wrapSync({ uuid: this.fin.me.uuid, name: popupName });
|
|
89
|
+
await options.onPopupReady(popupWindow);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Something went wrong during onPopupReady execution: ${error}`);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
await this.once('popup-ready', readyListener);
|
|
96
|
+
}
|
|
97
|
+
const { payload: tryCreatePayload } = await this.wire.sendAction('try-create-popup-window', {
|
|
98
|
+
options: {
|
|
99
|
+
...options,
|
|
100
|
+
// Internal use only.
|
|
101
|
+
// @ts-expect-error
|
|
102
|
+
hasResultCallback: !!(options === null || options === void 0 ? void 0 : options.onPopupResult),
|
|
103
|
+
hasReadyCallback: !!(options === null || options === void 0 ? void 0 : options.onPopupReady)
|
|
104
|
+
},
|
|
105
|
+
...this.identity
|
|
106
|
+
});
|
|
107
|
+
const { data: { willOpen, options: popupOptions } } = tryCreatePayload;
|
|
108
|
+
if (willOpen) {
|
|
109
|
+
await this.wire.environment.createChildContent({
|
|
110
|
+
options: popupOptions.initialOptions,
|
|
111
|
+
entityType: 'window'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const normalizePopupResult = (payload) => {
|
|
115
|
+
const { name, uuid, result, data } = payload;
|
|
116
|
+
const popupResult = {
|
|
117
|
+
identity: {
|
|
118
|
+
name,
|
|
119
|
+
uuid
|
|
120
|
+
},
|
|
121
|
+
result
|
|
122
|
+
};
|
|
123
|
+
if (data) {
|
|
124
|
+
popupResult.data = data;
|
|
125
|
+
}
|
|
126
|
+
return popupResult;
|
|
127
|
+
};
|
|
128
|
+
if (options === null || options === void 0 ? void 0 : options.onPopupResult) {
|
|
129
|
+
const dispatchResultListener = async (payload) => {
|
|
130
|
+
await options.onPopupResult(normalizePopupResult(payload));
|
|
131
|
+
};
|
|
132
|
+
const teardownListener = async () => {
|
|
133
|
+
await this.removeListener('popup-result', dispatchResultListener);
|
|
134
|
+
};
|
|
135
|
+
await this.on('popup-result', dispatchResultListener);
|
|
136
|
+
await this.once('popup-teardown', teardownListener);
|
|
137
|
+
}
|
|
138
|
+
const { payload } = await this.wire.sendAction('show-popup-window', {
|
|
139
|
+
options: popupOptions,
|
|
140
|
+
...this.identity
|
|
141
|
+
});
|
|
142
|
+
return payload.data;
|
|
143
|
+
}
|
|
81
144
|
}
|
|
82
145
|
exports.WebContents = WebContents;
|
|
@@ -994,11 +994,13 @@ export declare class _Window extends WebContents<WindowEvents> {
|
|
|
994
994
|
*/
|
|
995
995
|
/**
|
|
996
996
|
* Shows a popup window. If this window currently has a popup open, closes it.
|
|
997
|
+
* @function showPopupWindow
|
|
998
|
+
* @memberOf Window
|
|
999
|
+
* @instance
|
|
997
1000
|
* @param {PopupOptions} options
|
|
998
1001
|
* @return {Promise<PopupResult>}
|
|
999
1002
|
* @tutorial Window.showPopupWindow
|
|
1000
1003
|
*/
|
|
1001
|
-
showPopupWindow(options: OpenFin.PopupOptions): Promise<OpenFin.PopupResult>;
|
|
1002
1004
|
/**
|
|
1003
1005
|
* Dispatch a result to the caller of `showPopupWindow`. If this window isn't currently being shown as a popup, this call will silently fail.
|
|
1004
1006
|
* @param {*} data Serializable data to send to the caller window.
|
|
@@ -1233,70 +1233,13 @@ class _Window extends main_1.WebContents {
|
|
|
1233
1233
|
*/
|
|
1234
1234
|
/**
|
|
1235
1235
|
* Shows a popup window. If this window currently has a popup open, closes it.
|
|
1236
|
+
* @function showPopupWindow
|
|
1237
|
+
* @memberOf Window
|
|
1238
|
+
* @instance
|
|
1236
1239
|
* @param {PopupOptions} options
|
|
1237
1240
|
* @return {Promise<PopupResult>}
|
|
1238
1241
|
* @tutorial Window.showPopupWindow
|
|
1239
1242
|
*/
|
|
1240
|
-
async showPopupWindow(options) {
|
|
1241
|
-
this.wire.sendAction('window-show-popup-window', this.identity).catch((e) => {
|
|
1242
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1243
|
-
});
|
|
1244
|
-
if (options === null || options === void 0 ? void 0 : options.onPopupReady) {
|
|
1245
|
-
const readyListener = async ({ popupName }) => {
|
|
1246
|
-
try {
|
|
1247
|
-
const popupWindow = this.fin.Window.wrapSync({ uuid: this.fin.me.uuid, name: popupName });
|
|
1248
|
-
await options.onPopupReady(popupWindow);
|
|
1249
|
-
}
|
|
1250
|
-
catch (error) {
|
|
1251
|
-
throw new Error(`Something went wrong during onPopupReady execution: ${error}`);
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
await this.once('popup-ready', readyListener);
|
|
1255
|
-
}
|
|
1256
|
-
const { payload: tryCreatePayload } = await this.wire.sendAction('try-create-popup-window', {
|
|
1257
|
-
options: {
|
|
1258
|
-
...options,
|
|
1259
|
-
// Internal use only.
|
|
1260
|
-
// @ts-expect-error
|
|
1261
|
-
hasResultCallback: !!(options === null || options === void 0 ? void 0 : options.onPopupResult),
|
|
1262
|
-
hasReadyCallback: !!(options === null || options === void 0 ? void 0 : options.onPopupReady)
|
|
1263
|
-
},
|
|
1264
|
-
...this.identity
|
|
1265
|
-
});
|
|
1266
|
-
const { data: { willOpen, options: popupOptions } } = tryCreatePayload;
|
|
1267
|
-
if (willOpen) {
|
|
1268
|
-
await this.wire.environment.createChildContent({
|
|
1269
|
-
options: popupOptions.initialOptions,
|
|
1270
|
-
entityType: 'window'
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
const normalizePopupResult = (payload) => {
|
|
1274
|
-
const { name, uuid, result, data } = payload;
|
|
1275
|
-
return {
|
|
1276
|
-
identity: {
|
|
1277
|
-
name,
|
|
1278
|
-
uuid
|
|
1279
|
-
},
|
|
1280
|
-
result,
|
|
1281
|
-
data
|
|
1282
|
-
};
|
|
1283
|
-
};
|
|
1284
|
-
if (options === null || options === void 0 ? void 0 : options.onPopupResult) {
|
|
1285
|
-
const dispatchResultListener = async (payload) => {
|
|
1286
|
-
await options.onPopupResult(normalizePopupResult(payload));
|
|
1287
|
-
};
|
|
1288
|
-
const teardownListener = async () => {
|
|
1289
|
-
await this.removeListener('popup-result', dispatchResultListener);
|
|
1290
|
-
};
|
|
1291
|
-
await this.on('popup-result', dispatchResultListener);
|
|
1292
|
-
await this.once('popup-teardown', teardownListener);
|
|
1293
|
-
}
|
|
1294
|
-
const { payload } = await this.wire.sendAction('show-popup-window', {
|
|
1295
|
-
options: popupOptions,
|
|
1296
|
-
...this.identity
|
|
1297
|
-
});
|
|
1298
|
-
return payload.data;
|
|
1299
|
-
}
|
|
1300
1243
|
/**
|
|
1301
1244
|
* Dispatch a result to the caller of `showPopupWindow`. If this window isn't currently being shown as a popup, this call will silently fail.
|
|
1302
1245
|
* @param {*} data Serializable data to send to the caller window.
|