@openfin/node-adapter 40.104.1 → 40.104.3
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/out/node-adapter.js +1297 -1243
- package/package.json +2 -2
package/out/node-adapter.js
CHANGED
|
@@ -73,13 +73,13 @@ async function promiseMapSerial(arr, func) {
|
|
|
73
73
|
}
|
|
74
74
|
promises.promiseMapSerial = promiseMapSerial;
|
|
75
75
|
|
|
76
|
-
var __classPrivateFieldSet$
|
|
76
|
+
var __classPrivateFieldSet$e = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
77
77
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
78
78
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
79
79
|
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");
|
|
80
80
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
81
81
|
};
|
|
82
|
-
var __classPrivateFieldGet$
|
|
82
|
+
var __classPrivateFieldGet$f = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
83
83
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
84
84
|
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");
|
|
85
85
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -164,7 +164,7 @@ class EmitterBase extends Base {
|
|
|
164
164
|
this.emit = (eventType, payload, ...args) => {
|
|
165
165
|
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
|
166
166
|
};
|
|
167
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$
|
|
167
|
+
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$f(this, _EmitterBase_emitterAccessor, "f"));
|
|
168
168
|
/**
|
|
169
169
|
* Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
|
|
170
170
|
* `once` subscription.
|
|
@@ -174,14 +174,14 @@ class EmitterBase extends Base {
|
|
|
174
174
|
* which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
|
|
175
175
|
*/
|
|
176
176
|
this.cleanUpRemovedListener = (eventType, listener) => {
|
|
177
|
-
const deregister = __classPrivateFieldGet$
|
|
177
|
+
const deregister = __classPrivateFieldGet$f(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
|
|
178
178
|
if (deregister) {
|
|
179
|
-
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$
|
|
179
|
+
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$f(this, _EmitterBase_emitterAccessor, "f"));
|
|
180
180
|
emitter.removeListener(eventType, deregister);
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
this.getOrCreateEmitter = () => {
|
|
184
|
-
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$
|
|
184
|
+
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$f(this, _EmitterBase_emitterAccessor, "f"));
|
|
185
185
|
if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
|
|
186
186
|
emitter.on('removeListener', this.cleanUpRemovedListener);
|
|
187
187
|
}
|
|
@@ -223,8 +223,8 @@ class EmitterBase extends Base {
|
|
|
223
223
|
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
224
224
|
return Promise.resolve();
|
|
225
225
|
};
|
|
226
|
-
__classPrivateFieldSet$
|
|
227
|
-
__classPrivateFieldSet$
|
|
226
|
+
__classPrivateFieldSet$e(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
227
|
+
__classPrivateFieldSet$e(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
|
|
228
228
|
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
@@ -253,7 +253,7 @@ class EmitterBase extends Base {
|
|
|
253
253
|
*/
|
|
254
254
|
async once(eventType, listener, options) {
|
|
255
255
|
const deregister = () => this.deregisterEventListener(eventType);
|
|
256
|
-
__classPrivateFieldGet$
|
|
256
|
+
__classPrivateFieldGet$f(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
257
257
|
await this.registerEventListener(eventType, options, (emitter) => {
|
|
258
258
|
emitter.once(eventType, deregister);
|
|
259
259
|
emitter.once(eventType, listener);
|
|
@@ -284,7 +284,7 @@ class EmitterBase extends Base {
|
|
|
284
284
|
*/
|
|
285
285
|
async prependOnceListener(eventType, listener, options) {
|
|
286
286
|
const deregister = () => this.deregisterEventListener(eventType);
|
|
287
|
-
__classPrivateFieldGet$
|
|
287
|
+
__classPrivateFieldGet$f(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
288
288
|
await this.registerEventListener(eventType, options, (emitter) => {
|
|
289
289
|
emitter.prependOnceListener(eventType, listener);
|
|
290
290
|
emitter.once(eventType, deregister);
|
|
@@ -344,7 +344,7 @@ class EmitterBase extends Base {
|
|
|
344
344
|
}
|
|
345
345
|
deleteEmitterIfNothingRegistered(emitter) {
|
|
346
346
|
if (emitter.eventNames().every((type) => type === 'removeListener')) {
|
|
347
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet$
|
|
347
|
+
this.wire.eventAggregator.delete(__classPrivateFieldGet$f(this, _EmitterBase_emitterAccessor, "f"));
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
}
|
|
@@ -576,11 +576,11 @@ const handleDeprecatedWarnings = (options) => {
|
|
|
576
576
|
};
|
|
577
577
|
warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
|
|
578
578
|
|
|
579
|
-
var hasRequiredFactory$
|
|
579
|
+
var hasRequiredFactory$3;
|
|
580
580
|
|
|
581
|
-
function requireFactory$
|
|
582
|
-
if (hasRequiredFactory$
|
|
583
|
-
hasRequiredFactory$
|
|
581
|
+
function requireFactory$3 () {
|
|
582
|
+
if (hasRequiredFactory$3) return Factory$6;
|
|
583
|
+
hasRequiredFactory$3 = 1;
|
|
584
584
|
Object.defineProperty(Factory$6, "__esModule", { value: true });
|
|
585
585
|
Factory$6.ViewModule = void 0;
|
|
586
586
|
const base_1 = base;
|
|
@@ -795,8 +795,8 @@ var main = {};
|
|
|
795
795
|
|
|
796
796
|
Object.defineProperty(main, "__esModule", { value: true });
|
|
797
797
|
main.WebContents = void 0;
|
|
798
|
-
const base_1$
|
|
799
|
-
class WebContents extends base_1$
|
|
798
|
+
const base_1$j = base;
|
|
799
|
+
class WebContents extends base_1$j.EmitterBase {
|
|
800
800
|
/**
|
|
801
801
|
* @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
802
802
|
* @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
@@ -1877,11 +1877,11 @@ class WebContents extends base_1$l.EmitterBase {
|
|
|
1877
1877
|
}
|
|
1878
1878
|
main.WebContents = WebContents;
|
|
1879
1879
|
|
|
1880
|
-
var hasRequiredInstance$
|
|
1880
|
+
var hasRequiredInstance$2;
|
|
1881
1881
|
|
|
1882
|
-
function requireInstance$
|
|
1883
|
-
if (hasRequiredInstance$
|
|
1884
|
-
hasRequiredInstance$
|
|
1882
|
+
function requireInstance$2 () {
|
|
1883
|
+
if (hasRequiredInstance$2) return Instance$5;
|
|
1884
|
+
hasRequiredInstance$2 = 1;
|
|
1885
1885
|
var _View_providerChannelClient;
|
|
1886
1886
|
Object.defineProperty(Instance$5, "__esModule", { value: true });
|
|
1887
1887
|
Instance$5.View = void 0;
|
|
@@ -2461,1139 +2461,1160 @@ function requireView () {
|
|
|
2461
2461
|
*
|
|
2462
2462
|
* @packageDocumentation
|
|
2463
2463
|
*/
|
|
2464
|
-
__exportStar(requireFactory$
|
|
2465
|
-
__exportStar(requireInstance$
|
|
2464
|
+
__exportStar(requireFactory$3(), exports);
|
|
2465
|
+
__exportStar(requireInstance$2(), exports);
|
|
2466
2466
|
} (view));
|
|
2467
2467
|
return view;
|
|
2468
2468
|
}
|
|
2469
2469
|
|
|
2470
|
-
|
|
2471
|
-
Instance$6.Application = void 0;
|
|
2472
|
-
/* eslint-disable import/prefer-default-export */
|
|
2473
|
-
const base_1$k = base;
|
|
2474
|
-
const window_1$1 = requireWindow();
|
|
2475
|
-
const view_1 = requireView();
|
|
2476
|
-
/**
|
|
2477
|
-
* An object representing an application. Allows the developer to create,
|
|
2478
|
-
* execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
|
|
2479
|
-
*/
|
|
2480
|
-
class Application extends base_1$k.EmitterBase {
|
|
2481
|
-
/**
|
|
2482
|
-
* @internal
|
|
2483
|
-
*/
|
|
2484
|
-
constructor(wire, identity) {
|
|
2485
|
-
super(wire, 'application', identity.uuid);
|
|
2486
|
-
this.identity = identity;
|
|
2487
|
-
this.window = new window_1$1._Window(this.wire, {
|
|
2488
|
-
uuid: this.identity.uuid,
|
|
2489
|
-
name: this.identity.uuid
|
|
2490
|
-
});
|
|
2491
|
-
}
|
|
2492
|
-
windowListFromIdentityList(identityList) {
|
|
2493
|
-
const windowList = [];
|
|
2494
|
-
identityList.forEach((identity) => {
|
|
2495
|
-
windowList.push(new window_1$1._Window(this.wire, {
|
|
2496
|
-
uuid: identity.uuid,
|
|
2497
|
-
name: identity.name
|
|
2498
|
-
}));
|
|
2499
|
-
});
|
|
2500
|
-
return windowList;
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Determines if the application is currently running.
|
|
2504
|
-
*
|
|
2505
|
-
* @example
|
|
2506
|
-
*
|
|
2507
|
-
* ```js
|
|
2508
|
-
* async function isAppRunning() {
|
|
2509
|
-
* const app = await fin.Application.getCurrent();
|
|
2510
|
-
* return await app.isRunning();
|
|
2511
|
-
* }
|
|
2512
|
-
* isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
|
|
2513
|
-
* ```
|
|
2514
|
-
*/
|
|
2515
|
-
isRunning() {
|
|
2516
|
-
return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
|
|
2517
|
-
}
|
|
2518
|
-
/**
|
|
2519
|
-
* Closes the application and any child windows created by the application.
|
|
2520
|
-
* Cleans the application from state so it is no longer found in getAllApplications.
|
|
2521
|
-
* @param force Close will be prevented from closing when force is false and
|
|
2522
|
-
* ‘close-requested’ has been subscribed to for application’s main window.
|
|
2523
|
-
*
|
|
2524
|
-
* @example
|
|
2525
|
-
*
|
|
2526
|
-
* ```js
|
|
2527
|
-
* async function closeApp() {
|
|
2528
|
-
* const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
|
|
2529
|
-
* const app = await fin.Application.wrap({uuid: 'app2'});
|
|
2530
|
-
* await app.quit();
|
|
2531
|
-
* const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
|
|
2532
|
-
*
|
|
2533
|
-
* }
|
|
2534
|
-
* closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
|
|
2535
|
-
* ```
|
|
2536
|
-
*/
|
|
2537
|
-
async quit(force = false) {
|
|
2538
|
-
try {
|
|
2539
|
-
await this._close(force);
|
|
2540
|
-
await this.wire.sendAction('destroy-application', { force, ...this.identity });
|
|
2541
|
-
}
|
|
2542
|
-
catch (error) {
|
|
2543
|
-
const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
|
|
2544
|
-
if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
|
|
2545
|
-
throw error;
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
async _close(force = false) {
|
|
2550
|
-
try {
|
|
2551
|
-
await this.wire.sendAction('close-application', { force, ...this.identity });
|
|
2552
|
-
}
|
|
2553
|
-
catch (error) {
|
|
2554
|
-
if (!error.message.includes('Remote connection has closed')) {
|
|
2555
|
-
throw error;
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
/**
|
|
2560
|
-
* @deprecated use Application.quit instead
|
|
2561
|
-
* Closes the application and any child windows created by the application.
|
|
2562
|
-
* @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
|
|
2563
|
-
* @param callback - called if the method succeeds.
|
|
2564
|
-
* @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
|
|
2565
|
-
*
|
|
2566
|
-
* @example
|
|
2567
|
-
*
|
|
2568
|
-
* ```js
|
|
2569
|
-
* async function closeApp() {
|
|
2570
|
-
* const app = await fin.Application.getCurrent();
|
|
2571
|
-
* return await app.close();
|
|
2572
|
-
* }
|
|
2573
|
-
* closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
|
|
2574
|
-
* ```
|
|
2575
|
-
*/
|
|
2576
|
-
close(force = false) {
|
|
2577
|
-
console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
|
|
2578
|
-
this.wire.sendAction('application-close', this.identity).catch((e) => {
|
|
2579
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2580
|
-
});
|
|
2581
|
-
return this._close(force);
|
|
2582
|
-
}
|
|
2583
|
-
/**
|
|
2584
|
-
* Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
|
|
2585
|
-
*
|
|
2586
|
-
* @example
|
|
2587
|
-
*
|
|
2588
|
-
* ```js
|
|
2589
|
-
* async function getChildWindows() {
|
|
2590
|
-
* const app = await fin.Application.getCurrent();
|
|
2591
|
-
* return await app.getChildWindows();
|
|
2592
|
-
* }
|
|
2593
|
-
*
|
|
2594
|
-
* getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
|
|
2595
|
-
* ```
|
|
2596
|
-
*/
|
|
2597
|
-
getChildWindows() {
|
|
2598
|
-
return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
|
|
2599
|
-
const identityList = [];
|
|
2600
|
-
payload.data.forEach((winName) => {
|
|
2601
|
-
identityList.push({ uuid: this.identity.uuid, name: winName });
|
|
2602
|
-
});
|
|
2603
|
-
return this.windowListFromIdentityList(identityList);
|
|
2604
|
-
});
|
|
2605
|
-
}
|
|
2606
|
-
/**
|
|
2607
|
-
* Retrieves the JSON manifest that was used to create the application. Invokes the error callback
|
|
2608
|
-
* if the application was not created from a manifest.
|
|
2609
|
-
*
|
|
2610
|
-
* @example
|
|
2611
|
-
*
|
|
2612
|
-
* ```js
|
|
2613
|
-
* async function getManifest() {
|
|
2614
|
-
* const app = await fin.Application.getCurrent();
|
|
2615
|
-
* return await app.getManifest();
|
|
2616
|
-
* }
|
|
2617
|
-
*
|
|
2618
|
-
* getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
|
|
2619
|
-
* ```
|
|
2620
|
-
*/
|
|
2621
|
-
getManifest() {
|
|
2622
|
-
return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
|
|
2623
|
-
}
|
|
2624
|
-
/**
|
|
2625
|
-
* Retrieves UUID of the application that launches this application. Invokes the error callback
|
|
2626
|
-
* if the application was created from a manifest.
|
|
2627
|
-
*
|
|
2628
|
-
* @example
|
|
2629
|
-
*
|
|
2630
|
-
* ```js
|
|
2631
|
-
* async function getParentUuid() {
|
|
2632
|
-
* const app = await fin.Application.start({
|
|
2633
|
-
* uuid: 'app-1',
|
|
2634
|
-
* name: 'myApp',
|
|
2635
|
-
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
|
|
2636
|
-
* autoShow: true
|
|
2637
|
-
* });
|
|
2638
|
-
* return await app.getParentUuid();
|
|
2639
|
-
* }
|
|
2640
|
-
*
|
|
2641
|
-
* getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
|
|
2642
|
-
* ```
|
|
2643
|
-
*/
|
|
2644
|
-
getParentUuid() {
|
|
2645
|
-
return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
|
|
2646
|
-
}
|
|
2647
|
-
/**
|
|
2648
|
-
* Retrieves current application's shortcut configuration.
|
|
2649
|
-
*
|
|
2650
|
-
* @example
|
|
2651
|
-
*
|
|
2652
|
-
* ```js
|
|
2653
|
-
* async function getShortcuts() {
|
|
2654
|
-
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
2655
|
-
* return await app.getShortcuts();
|
|
2656
|
-
* }
|
|
2657
|
-
* getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
|
|
2658
|
-
* ```
|
|
2659
|
-
*/
|
|
2660
|
-
getShortcuts() {
|
|
2661
|
-
return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
|
|
2662
|
-
}
|
|
2663
|
-
/**
|
|
2664
|
-
* Retrieves current application's views.
|
|
2665
|
-
* @experimental
|
|
2666
|
-
*
|
|
2667
|
-
* @example
|
|
2668
|
-
*
|
|
2669
|
-
* ```js
|
|
2670
|
-
* async function getViews() {
|
|
2671
|
-
* const app = await fin.Application.getCurrent();
|
|
2672
|
-
* return await app.getViews();
|
|
2673
|
-
* }
|
|
2674
|
-
* getViews().then(views => console.log(views)).catch(err => console.log(err));
|
|
2675
|
-
* ```
|
|
2676
|
-
*/
|
|
2677
|
-
async getViews() {
|
|
2678
|
-
const { payload } = await this.wire.sendAction('application-get-views', this.identity);
|
|
2679
|
-
return payload.data.map((id) => new view_1.View(this.wire, id));
|
|
2680
|
-
}
|
|
2681
|
-
/**
|
|
2682
|
-
* Returns the current zoom level of the application.
|
|
2683
|
-
*
|
|
2684
|
-
* @example
|
|
2685
|
-
*
|
|
2686
|
-
* ```js
|
|
2687
|
-
* async function getZoomLevel() {
|
|
2688
|
-
* const app = await fin.Application.getCurrent();
|
|
2689
|
-
* return await app.getZoomLevel();
|
|
2690
|
-
* }
|
|
2691
|
-
*
|
|
2692
|
-
* getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
|
|
2693
|
-
* ```
|
|
2694
|
-
*/
|
|
2695
|
-
getZoomLevel() {
|
|
2696
|
-
return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
|
|
2697
|
-
}
|
|
2698
|
-
/**
|
|
2699
|
-
* Returns an instance of the main Window of the application
|
|
2700
|
-
*
|
|
2701
|
-
* @example
|
|
2702
|
-
*
|
|
2703
|
-
* ```js
|
|
2704
|
-
* async function getWindow() {
|
|
2705
|
-
* const app = await fin.Application.start({
|
|
2706
|
-
* uuid: 'app-1',
|
|
2707
|
-
* name: 'myApp',
|
|
2708
|
-
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
|
|
2709
|
-
* autoShow: true
|
|
2710
|
-
* });
|
|
2711
|
-
* return await app.getWindow();
|
|
2712
|
-
* }
|
|
2713
|
-
*
|
|
2714
|
-
* getWindow().then(win => {
|
|
2715
|
-
* win.showAt(0, 400);
|
|
2716
|
-
* win.flash();
|
|
2717
|
-
* }).catch(err => console.log(err));
|
|
2718
|
-
* ```
|
|
2719
|
-
*/
|
|
2720
|
-
getWindow() {
|
|
2721
|
-
this.wire.sendAction('application-get-window', this.identity).catch((e) => {
|
|
2722
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2723
|
-
});
|
|
2724
|
-
return Promise.resolve(this.window);
|
|
2725
|
-
}
|
|
2726
|
-
/**
|
|
2727
|
-
* Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
|
|
2728
|
-
* @param userName - username to be passed to the RVM.
|
|
2729
|
-
* @param appName - app name to be passed to the RVM.
|
|
2730
|
-
*
|
|
2731
|
-
* @example
|
|
2732
|
-
*
|
|
2733
|
-
* ```js
|
|
2734
|
-
* async function registerUser() {
|
|
2735
|
-
* const app = await fin.Application.getCurrent();
|
|
2736
|
-
* return await app.registerUser('user', 'myApp');
|
|
2737
|
-
* }
|
|
2738
|
-
*
|
|
2739
|
-
* registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
|
|
2740
|
-
* ```
|
|
2741
|
-
*/
|
|
2742
|
-
registerUser(userName, appName) {
|
|
2743
|
-
return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
|
|
2744
|
-
}
|
|
2745
|
-
/**
|
|
2746
|
-
* Removes the application’s icon from the tray.
|
|
2747
|
-
*
|
|
2748
|
-
* @example
|
|
2749
|
-
*
|
|
2750
|
-
* ```js
|
|
2751
|
-
* async function removeTrayIcon() {
|
|
2752
|
-
* const app = await fin.Application.getCurrent();
|
|
2753
|
-
* return await app.removeTrayIcon();
|
|
2754
|
-
* }
|
|
2755
|
-
*
|
|
2756
|
-
* removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
|
|
2757
|
-
* ```
|
|
2758
|
-
*/
|
|
2759
|
-
removeTrayIcon() {
|
|
2760
|
-
return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
|
|
2761
|
-
}
|
|
2762
|
-
/**
|
|
2763
|
-
* Restarts the application.
|
|
2764
|
-
*
|
|
2765
|
-
* @example
|
|
2766
|
-
*
|
|
2767
|
-
* ```js
|
|
2768
|
-
* async function restartApp() {
|
|
2769
|
-
* const app = await fin.Application.getCurrent();
|
|
2770
|
-
* return await app.restart();
|
|
2771
|
-
* }
|
|
2772
|
-
* restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
|
|
2773
|
-
* ```
|
|
2774
|
-
*/
|
|
2775
|
-
restart() {
|
|
2776
|
-
return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
|
|
2777
|
-
}
|
|
2778
|
-
/**
|
|
2779
|
-
* DEPRECATED method to run the application.
|
|
2780
|
-
* Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
|
|
2781
|
-
*
|
|
2782
|
-
* @example
|
|
2783
|
-
*
|
|
2784
|
-
* ```js
|
|
2785
|
-
* async function run() {
|
|
2786
|
-
* const app = await fin.Application.create({
|
|
2787
|
-
* name: 'myApp',
|
|
2788
|
-
* uuid: 'app-1',
|
|
2789
|
-
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
|
|
2790
|
-
* autoShow: true
|
|
2791
|
-
* });
|
|
2792
|
-
* await app.run();
|
|
2793
|
-
* }
|
|
2794
|
-
* run().then(() => console.log('Application is running')).catch(err => console.log(err));
|
|
2795
|
-
* ```
|
|
2796
|
-
*
|
|
2797
|
-
* @ignore
|
|
2798
|
-
*/
|
|
2799
|
-
run() {
|
|
2800
|
-
console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
|
|
2801
|
-
this.wire.sendAction('application-run', this.identity).catch((e) => {
|
|
2802
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2803
|
-
});
|
|
2804
|
-
return this._run();
|
|
2805
|
-
}
|
|
2806
|
-
_run(opts = {}) {
|
|
2807
|
-
return this.wire
|
|
2808
|
-
.sendAction('run-application', {
|
|
2809
|
-
manifestUrl: this._manifestUrl,
|
|
2810
|
-
opts,
|
|
2811
|
-
...this.identity
|
|
2812
|
-
})
|
|
2813
|
-
.then(() => undefined);
|
|
2814
|
-
}
|
|
2815
|
-
/**
|
|
2816
|
-
* Instructs the RVM to schedule one restart of the application.
|
|
2817
|
-
*
|
|
2818
|
-
* @example
|
|
2819
|
-
*
|
|
2820
|
-
* ```js
|
|
2821
|
-
* async function scheduleRestart() {
|
|
2822
|
-
* const app = await fin.Application.getCurrent();
|
|
2823
|
-
* return await app.scheduleRestart();
|
|
2824
|
-
* }
|
|
2825
|
-
*
|
|
2826
|
-
* scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
|
|
2827
|
-
* ```
|
|
2828
|
-
*/
|
|
2829
|
-
scheduleRestart() {
|
|
2830
|
-
return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
|
|
2831
|
-
}
|
|
2832
|
-
/**
|
|
2833
|
-
* Sends a message to the RVM to upload the application's logs. On success,
|
|
2834
|
-
* an object containing logId is returned.
|
|
2835
|
-
*
|
|
2836
|
-
* @example
|
|
2837
|
-
*
|
|
2838
|
-
* ```js
|
|
2839
|
-
* async function sendLog() {
|
|
2840
|
-
* const app = await fin.Application.getCurrent();
|
|
2841
|
-
* return await app.sendApplicationLog();
|
|
2842
|
-
* }
|
|
2843
|
-
*
|
|
2844
|
-
* sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
|
|
2845
|
-
* ```
|
|
2846
|
-
*/
|
|
2847
|
-
async sendApplicationLog() {
|
|
2848
|
-
const { payload } = await this.wire.sendAction('send-application-log', this.identity);
|
|
2849
|
-
return payload.data;
|
|
2850
|
-
}
|
|
2851
|
-
/**
|
|
2852
|
-
* Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
|
|
2853
|
-
* If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
|
|
2854
|
-
*
|
|
2855
|
-
* Note: If the "name" property is omitted it defaults to "tasks".
|
|
2856
|
-
* @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
* @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
|
|
2860
|
-
*
|
|
2861
|
-
* The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
|
|
2862
|
-
* **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
|
|
2863
|
-
*
|
|
2864
|
-
* Note: If the "name" property is omitted it defaults to "tasks".
|
|
2865
|
-
*
|
|
2866
|
-
* Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
|
|
2867
|
-
* uuid or shortcut.name is changed.
|
|
2868
|
-
*
|
|
2869
|
-
* @example
|
|
2870
|
-
*
|
|
2871
|
-
* ```js
|
|
2872
|
-
* const app = fin.Application.getCurrentSync();
|
|
2873
|
-
* const appName = 'My App';
|
|
2874
|
-
* const jumpListConfig = [ // array of JumpList categories
|
|
2875
|
-
* {
|
|
2876
|
-
* // has no name and no type so `type` is assumed to be "tasks"
|
|
2877
|
-
* items: [ // array of JumpList items
|
|
2878
|
-
* {
|
|
2879
|
-
* type: 'task',
|
|
2880
|
-
* title: `Launch ${appName}`,
|
|
2881
|
-
* description: `Runs ${appName} with the default configuration`,
|
|
2882
|
-
* deepLink: 'fins://path.to/app/manifest.json',
|
|
2883
|
-
* iconPath: 'https://path.to/app/icon.ico',
|
|
2884
|
-
* iconIndex: 0
|
|
2885
|
-
* },
|
|
2886
|
-
* { type: 'separator' },
|
|
2887
|
-
* {
|
|
2888
|
-
* type: 'task',
|
|
2889
|
-
* title: `Restore ${appName}`,
|
|
2890
|
-
* description: 'Restore to last configuration',
|
|
2891
|
-
* deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
|
|
2892
|
-
* iconPath: 'https://path.to/app/icon.ico',
|
|
2893
|
-
* iconIndex: 0
|
|
2894
|
-
* },
|
|
2895
|
-
* ]
|
|
2896
|
-
* },
|
|
2897
|
-
* {
|
|
2898
|
-
* name: 'Tools',
|
|
2899
|
-
* items: [ // array of JumpList items
|
|
2900
|
-
* {
|
|
2901
|
-
* type: 'task',
|
|
2902
|
-
* title: 'Tool A',
|
|
2903
|
-
* description: 'Runs Tool A',
|
|
2904
|
-
* deepLink: 'fins://path.to/tool-a/manifest.json',
|
|
2905
|
-
* iconPath: 'https://path.to/tool-a/icon.ico',
|
|
2906
|
-
* iconIndex: 0
|
|
2907
|
-
* },
|
|
2908
|
-
* {
|
|
2909
|
-
* type: 'task',
|
|
2910
|
-
* title: 'Tool B',
|
|
2911
|
-
* description: 'Runs Tool B',
|
|
2912
|
-
* deepLink: 'fins://path.to/tool-b/manifest.json',
|
|
2913
|
-
* iconPath: 'https://path.to/tool-b/icon.ico',
|
|
2914
|
-
* iconIndex: 0
|
|
2915
|
-
* }]
|
|
2916
|
-
* }
|
|
2917
|
-
* ];
|
|
2918
|
-
*
|
|
2919
|
-
* app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
|
|
2920
|
-
* ```
|
|
2921
|
-
*
|
|
2922
|
-
* To handle deeplink args:
|
|
2923
|
-
* ```js
|
|
2924
|
-
* function handleUseLastConfiguration() {
|
|
2925
|
-
* // this handler is called when the app is being launched
|
|
2926
|
-
* app.on('run-requested', event => {
|
|
2927
|
-
* if(event.userAppConfigArgs['use-last-configuration']) {
|
|
2928
|
-
* // your logic here
|
|
2929
|
-
* }
|
|
2930
|
-
* });
|
|
2931
|
-
* // this handler is called when the app was already running when the launch was requested
|
|
2932
|
-
* fin.desktop.main(function(args) {
|
|
2933
|
-
* if(args && args['use-last-configuration']) {
|
|
2934
|
-
* // your logic here
|
|
2935
|
-
* }
|
|
2936
|
-
* });
|
|
2937
|
-
* }
|
|
2938
|
-
* ```
|
|
2939
|
-
*/
|
|
2940
|
-
async setJumpList(jumpListCategories) {
|
|
2941
|
-
await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
|
|
2942
|
-
}
|
|
2943
|
-
/**
|
|
2944
|
-
* Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
|
|
2945
|
-
* @param icon Image URL or base64 encoded string to be used as the icon
|
|
2946
|
-
*
|
|
2947
|
-
* @example
|
|
2948
|
-
*
|
|
2949
|
-
* ```js
|
|
2950
|
-
* const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
|
|
2951
|
-
* const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
|
|
2952
|
-
* ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
|
|
2953
|
-
* const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
|
|
2954
|
-
* xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
|
2955
|
-
*
|
|
2956
|
-
* async function setTrayIcon(icon) {
|
|
2957
|
-
* const app = await fin.Application.getCurrent();
|
|
2958
|
-
* return await app.setTrayIcon(icon);
|
|
2959
|
-
* }
|
|
2960
|
-
*
|
|
2961
|
-
* // use image url to set tray icon
|
|
2962
|
-
* setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2963
|
-
*
|
|
2964
|
-
* // use base64 encoded string to set tray icon
|
|
2965
|
-
* setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2966
|
-
*
|
|
2967
|
-
* // use a dataURL to set tray icon
|
|
2968
|
-
* setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2969
|
-
* ```
|
|
2970
|
-
*/
|
|
2971
|
-
setTrayIcon(icon) {
|
|
2972
|
-
return this.wire
|
|
2973
|
-
.sendAction('set-tray-icon', {
|
|
2974
|
-
enabledIcon: icon,
|
|
2975
|
-
...this.identity
|
|
2976
|
-
})
|
|
2977
|
-
.then(() => undefined);
|
|
2978
|
-
}
|
|
2979
|
-
/**
|
|
2980
|
-
* Set hover text for this application's system tray icon.
|
|
2981
|
-
* Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
|
|
2982
|
-
* @param toolTip
|
|
2983
|
-
*
|
|
2984
|
-
* @example
|
|
2985
|
-
*
|
|
2986
|
-
* ```js
|
|
2987
|
-
* const app = fin.Application.getCurrentSync();
|
|
2988
|
-
* const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
|
|
2989
|
-
*
|
|
2990
|
-
* await app.setTrayIcon(iconUrl);
|
|
2991
|
-
*
|
|
2992
|
-
* await app.setTrayIconToolTip('My Application');
|
|
2993
|
-
* ```
|
|
2994
|
-
*/
|
|
2995
|
-
async setTrayIconToolTip(toolTip) {
|
|
2996
|
-
await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
|
|
2997
|
-
}
|
|
2998
|
-
/**
|
|
2999
|
-
* Sets new application's shortcut configuration. Windows only.
|
|
3000
|
-
* @param config New application's shortcut configuration.
|
|
3001
|
-
*
|
|
3002
|
-
* @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
|
|
3003
|
-
* to be able to change shortcut states.
|
|
3004
|
-
*
|
|
3005
|
-
* @example
|
|
3006
|
-
*
|
|
3007
|
-
* ```js
|
|
3008
|
-
* async function setShortcuts(config) {
|
|
3009
|
-
* const app = await fin.Application.getCurrent();
|
|
3010
|
-
* return app.setShortcuts(config);
|
|
3011
|
-
* }
|
|
3012
|
-
*
|
|
3013
|
-
* setShortcuts({
|
|
3014
|
-
* desktop: true,
|
|
3015
|
-
* startMenu: false,
|
|
3016
|
-
* systemStartup: true
|
|
3017
|
-
* }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
|
|
3018
|
-
* ```
|
|
3019
|
-
*/
|
|
3020
|
-
setShortcuts(config) {
|
|
3021
|
-
return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
|
|
3022
|
-
}
|
|
3023
|
-
/**
|
|
3024
|
-
* Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
|
|
3025
|
-
* @param queryString The new query string for this app's shortcuts.
|
|
3026
|
-
*
|
|
3027
|
-
* @example
|
|
3028
|
-
*
|
|
3029
|
-
* ```js
|
|
3030
|
-
* const newQueryArgs = 'arg=true&arg2=false';
|
|
3031
|
-
* const app = await fin.Application.getCurrent();
|
|
3032
|
-
* try {
|
|
3033
|
-
* await app.setShortcutQueryParams(newQueryArgs);
|
|
3034
|
-
* } catch(err) {
|
|
3035
|
-
* console.error(err)
|
|
3036
|
-
* }
|
|
3037
|
-
* ```
|
|
3038
|
-
*/
|
|
3039
|
-
async setShortcutQueryParams(queryString) {
|
|
3040
|
-
await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
|
|
3041
|
-
}
|
|
3042
|
-
/**
|
|
3043
|
-
* Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
|
|
3044
|
-
* larger or smaller to default limits of 300% and 50% of original size, respectively.
|
|
3045
|
-
* @param level The zoom level
|
|
3046
|
-
*
|
|
3047
|
-
* @example
|
|
3048
|
-
*
|
|
3049
|
-
* ```js
|
|
3050
|
-
* async function setZoomLevel(number) {
|
|
3051
|
-
* const app = await fin.Application.getCurrent();
|
|
3052
|
-
* return await app.setZoomLevel(number);
|
|
3053
|
-
* }
|
|
3054
|
-
*
|
|
3055
|
-
* setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
|
|
3056
|
-
* ```
|
|
3057
|
-
*/
|
|
3058
|
-
setZoomLevel(level) {
|
|
3059
|
-
return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
|
|
3060
|
-
}
|
|
3061
|
-
/**
|
|
3062
|
-
* Sets a username to correlate with App Log Management.
|
|
3063
|
-
* @param username Username to correlate with App's Log.
|
|
3064
|
-
*
|
|
3065
|
-
* @example
|
|
3066
|
-
*
|
|
3067
|
-
* ```js
|
|
3068
|
-
* async function setAppLogUser() {
|
|
3069
|
-
* const app = await fin.Application.getCurrent();
|
|
3070
|
-
* return await app.setAppLogUsername('username');
|
|
3071
|
-
* }
|
|
3072
|
-
*
|
|
3073
|
-
* setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
|
|
3074
|
-
*
|
|
3075
|
-
* ```
|
|
3076
|
-
*/
|
|
3077
|
-
async setAppLogUsername(username) {
|
|
3078
|
-
await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
|
|
3079
|
-
}
|
|
3080
|
-
/**
|
|
3081
|
-
* Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
|
|
3082
|
-
* @remarks The only information currently returned is the position and dimensions.
|
|
3083
|
-
*
|
|
3084
|
-
* @example
|
|
3085
|
-
*
|
|
3086
|
-
* ```js
|
|
3087
|
-
* async function getTrayIconInfo() {
|
|
3088
|
-
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
3089
|
-
* return await app.getTrayIconInfo();
|
|
3090
|
-
* }
|
|
3091
|
-
* getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
|
|
3092
|
-
* ```
|
|
3093
|
-
*/
|
|
3094
|
-
getTrayIconInfo() {
|
|
3095
|
-
return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
|
|
3096
|
-
}
|
|
3097
|
-
/**
|
|
3098
|
-
* Checks if the application has an associated tray icon.
|
|
3099
|
-
*
|
|
3100
|
-
* @example
|
|
3101
|
-
*
|
|
3102
|
-
* ```js
|
|
3103
|
-
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
3104
|
-
* const hasTrayIcon = await app.hasTrayIcon();
|
|
3105
|
-
* console.log(hasTrayIcon);
|
|
3106
|
-
* ```
|
|
3107
|
-
*/
|
|
3108
|
-
hasTrayIcon() {
|
|
3109
|
-
return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
|
|
3110
|
-
}
|
|
3111
|
-
/**
|
|
3112
|
-
* Closes the application by terminating its process.
|
|
3113
|
-
*
|
|
3114
|
-
* @example
|
|
3115
|
-
*
|
|
3116
|
-
* ```js
|
|
3117
|
-
* async function terminateApp() {
|
|
3118
|
-
* const app = await fin.Application.getCurrent();
|
|
3119
|
-
* return await app.terminate();
|
|
3120
|
-
* }
|
|
3121
|
-
* terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
|
|
3122
|
-
* ```
|
|
3123
|
-
*/
|
|
3124
|
-
terminate() {
|
|
3125
|
-
return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
|
|
3126
|
-
}
|
|
3127
|
-
/**
|
|
3128
|
-
* Waits for a hanging application. This method can be called in response to an application
|
|
3129
|
-
* "not-responding" to allow the application to continue and to generate another "not-responding"
|
|
3130
|
-
* message after a certain period of time.
|
|
3131
|
-
*
|
|
3132
|
-
* @ignore
|
|
3133
|
-
*/
|
|
3134
|
-
wait() {
|
|
3135
|
-
return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
|
|
3136
|
-
}
|
|
3137
|
-
/**
|
|
3138
|
-
* Retrieves information about the application.
|
|
3139
|
-
*
|
|
3140
|
-
* @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
|
|
3141
|
-
* and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
|
|
3142
|
-
* if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
|
|
3143
|
-
*
|
|
3144
|
-
* @example
|
|
3145
|
-
*
|
|
3146
|
-
* ```js
|
|
3147
|
-
* async function getInfo() {
|
|
3148
|
-
* const app = await fin.Application.getCurrent();
|
|
3149
|
-
* return await app.getInfo();
|
|
3150
|
-
* }
|
|
3151
|
-
*
|
|
3152
|
-
* getInfo().then(info => console.log(info)).catch(err => console.log(err));
|
|
3153
|
-
* ```
|
|
3154
|
-
*/
|
|
3155
|
-
getInfo() {
|
|
3156
|
-
return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
|
|
3157
|
-
}
|
|
3158
|
-
/**
|
|
3159
|
-
* Retrieves all process information for entities (windows and views) associated with an application.
|
|
3160
|
-
*
|
|
3161
|
-
* @example
|
|
3162
|
-
* ```js
|
|
3163
|
-
* const app = await fin.Application.getCurrent();
|
|
3164
|
-
* const processInfo = await app.getProcessInfo();
|
|
3165
|
-
* ```
|
|
3166
|
-
* @experimental
|
|
3167
|
-
*/
|
|
3168
|
-
async getProcessInfo() {
|
|
3169
|
-
const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
|
|
3170
|
-
return data;
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Sets file auto download location. It's only allowed in the same application.
|
|
3174
|
-
*
|
|
3175
|
-
* Note: This method is restricted by default and must be enabled via
|
|
3176
|
-
* <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
|
|
3177
|
-
* @param downloadLocation file auto download location
|
|
3178
|
-
*
|
|
3179
|
-
* @throws if setting file auto download location on different applications.
|
|
3180
|
-
* @example
|
|
3181
|
-
*
|
|
3182
|
-
* ```js
|
|
3183
|
-
* const downloadLocation = 'C:\\dev\\temp';
|
|
3184
|
-
* const app = await fin.Application.getCurrent();
|
|
3185
|
-
* try {
|
|
3186
|
-
* await app.setFileDownloadLocation(downloadLocation);
|
|
3187
|
-
* console.log('File download location is set');
|
|
3188
|
-
* } catch(err) {
|
|
3189
|
-
* console.error(err)
|
|
3190
|
-
* }
|
|
3191
|
-
* ```
|
|
3192
|
-
*/
|
|
3193
|
-
async setFileDownloadLocation(downloadLocation) {
|
|
3194
|
-
const { name } = this.wire.me;
|
|
3195
|
-
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3196
|
-
await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
|
|
3197
|
-
}
|
|
3198
|
-
/**
|
|
3199
|
-
* Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
|
|
3200
|
-
*
|
|
3201
|
-
* Note: This method is restricted by default and must be enabled via
|
|
3202
|
-
* <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
|
|
3203
|
-
*
|
|
3204
|
-
* @throws if getting file auto download location on different applications.
|
|
3205
|
-
* @example
|
|
3206
|
-
*
|
|
3207
|
-
* ```js
|
|
3208
|
-
* const app = await fin.Application.getCurrent();
|
|
3209
|
-
* const fileDownloadDir = await app.getFileDownloadLocation();
|
|
3210
|
-
* ```
|
|
3211
|
-
*/
|
|
3212
|
-
async getFileDownloadLocation() {
|
|
3213
|
-
const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
|
|
3214
|
-
return data;
|
|
3215
|
-
}
|
|
3216
|
-
/**
|
|
3217
|
-
* Shows a menu on the tray icon. Use with tray-icon-clicked event.
|
|
3218
|
-
* @param options
|
|
3219
|
-
* @typeParam Data User-defined shape for data returned upon menu item click. Should be a
|
|
3220
|
-
* [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
|
|
3221
|
-
* of all possible data shapes for the entire menu, and the click handler should process
|
|
3222
|
-
* these with a "reducer" pattern.
|
|
3223
|
-
* @throws if the application has no tray icon set
|
|
3224
|
-
* @throws if the system tray is currently hidden
|
|
3225
|
-
* @example
|
|
3226
|
-
*
|
|
3227
|
-
* ```js
|
|
3228
|
-
* const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
|
|
3229
|
-
* const app = fin.Application.getCurrentSync();
|
|
3230
|
-
*
|
|
3231
|
-
* await app.setTrayIcon(iconUrl);
|
|
3232
|
-
*
|
|
3233
|
-
* const template = [
|
|
3234
|
-
* {
|
|
3235
|
-
* label: 'Menu Item 1',
|
|
3236
|
-
* data: 'hello from item 1'
|
|
3237
|
-
* },
|
|
3238
|
-
* { type: 'separator' },
|
|
3239
|
-
* {
|
|
3240
|
-
* label: 'Menu Item 2',
|
|
3241
|
-
* type: 'checkbox',
|
|
3242
|
-
* checked: true,
|
|
3243
|
-
* data: 'The user clicked the checkbox'
|
|
3244
|
-
* },
|
|
3245
|
-
* {
|
|
3246
|
-
* label: 'see more',
|
|
3247
|
-
* enabled: false,
|
|
3248
|
-
* submenu: [
|
|
3249
|
-
* { label: 'submenu 1', data: 'hello from submenu' }
|
|
3250
|
-
* ]
|
|
3251
|
-
* }
|
|
3252
|
-
* ];
|
|
3253
|
-
*
|
|
3254
|
-
* app.addListener('tray-icon-clicked', (event) => {
|
|
3255
|
-
* // right-click
|
|
3256
|
-
* if (event.button === 2) {
|
|
3257
|
-
* app.showTrayIconPopupMenu({ template }).then(r => {
|
|
3258
|
-
* if (r.result === 'closed') {
|
|
3259
|
-
* console.log('nothing happened');
|
|
3260
|
-
* } else {
|
|
3261
|
-
* console.log(r.data);
|
|
3262
|
-
* }
|
|
3263
|
-
* });
|
|
3264
|
-
* }
|
|
3265
|
-
* });
|
|
3266
|
-
* ```
|
|
3267
|
-
*/
|
|
3268
|
-
async showTrayIconPopupMenu(options) {
|
|
3269
|
-
const { name } = this.wire.me;
|
|
3270
|
-
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3271
|
-
const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
|
|
3272
|
-
return payload.data;
|
|
3273
|
-
}
|
|
3274
|
-
/**
|
|
3275
|
-
* Closes the tray icon menu.
|
|
3276
|
-
*
|
|
3277
|
-
* @throws if the application has no tray icon set
|
|
3278
|
-
* @example
|
|
3279
|
-
*
|
|
3280
|
-
* ```js
|
|
3281
|
-
* const app = fin.Application.getCurrentSync();
|
|
3282
|
-
*
|
|
3283
|
-
* await app.closeTrayIconPopupMenu();
|
|
3284
|
-
* ```
|
|
3285
|
-
*/
|
|
3286
|
-
async closeTrayIconPopupMenu() {
|
|
3287
|
-
const { name } = this.wire.me;
|
|
3288
|
-
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3289
|
-
await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
Instance$6.Application = Application;
|
|
2470
|
+
var hasRequiredInstance$1;
|
|
3293
2471
|
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
2472
|
+
function requireInstance$1 () {
|
|
2473
|
+
if (hasRequiredInstance$1) return Instance$6;
|
|
2474
|
+
hasRequiredInstance$1 = 1;
|
|
2475
|
+
Object.defineProperty(Instance$6, "__esModule", { value: true });
|
|
2476
|
+
Instance$6.Application = void 0;
|
|
2477
|
+
/* eslint-disable import/prefer-default-export */
|
|
2478
|
+
const base_1 = base;
|
|
2479
|
+
const window_1 = requireWindow();
|
|
2480
|
+
const view_1 = requireView();
|
|
2481
|
+
/**
|
|
2482
|
+
* An object representing an application. Allows the developer to create,
|
|
2483
|
+
* execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
|
|
2484
|
+
*/
|
|
2485
|
+
class Application extends base_1.EmitterBase {
|
|
2486
|
+
/**
|
|
2487
|
+
* @internal
|
|
2488
|
+
*/
|
|
2489
|
+
constructor(wire, identity) {
|
|
2490
|
+
super(wire, 'application', identity.uuid);
|
|
2491
|
+
this.identity = identity;
|
|
2492
|
+
this.window = new window_1._Window(this.wire, {
|
|
2493
|
+
uuid: this.identity.uuid,
|
|
2494
|
+
name: this.identity.uuid
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
windowListFromIdentityList(identityList) {
|
|
2498
|
+
const windowList = [];
|
|
2499
|
+
identityList.forEach((identity) => {
|
|
2500
|
+
windowList.push(new window_1._Window(this.wire, {
|
|
2501
|
+
uuid: identity.uuid,
|
|
2502
|
+
name: identity.name
|
|
2503
|
+
}));
|
|
2504
|
+
});
|
|
2505
|
+
return windowList;
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Determines if the application is currently running.
|
|
2509
|
+
*
|
|
2510
|
+
* @example
|
|
2511
|
+
*
|
|
2512
|
+
* ```js
|
|
2513
|
+
* async function isAppRunning() {
|
|
2514
|
+
* const app = await fin.Application.getCurrent();
|
|
2515
|
+
* return await app.isRunning();
|
|
2516
|
+
* }
|
|
2517
|
+
* isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
|
|
2518
|
+
* ```
|
|
2519
|
+
*/
|
|
2520
|
+
isRunning() {
|
|
2521
|
+
return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
|
|
2522
|
+
}
|
|
2523
|
+
/**
|
|
2524
|
+
* Closes the application and any child windows created by the application.
|
|
2525
|
+
* Cleans the application from state so it is no longer found in getAllApplications.
|
|
2526
|
+
* @param force Close will be prevented from closing when force is false and
|
|
2527
|
+
* ‘close-requested’ has been subscribed to for application’s main window.
|
|
2528
|
+
*
|
|
2529
|
+
* @example
|
|
2530
|
+
*
|
|
2531
|
+
* ```js
|
|
2532
|
+
* async function closeApp() {
|
|
2533
|
+
* const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
|
|
2534
|
+
* const app = await fin.Application.wrap({uuid: 'app2'});
|
|
2535
|
+
* await app.quit();
|
|
2536
|
+
* const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
|
|
2537
|
+
*
|
|
2538
|
+
* }
|
|
2539
|
+
* closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
|
|
2540
|
+
* ```
|
|
2541
|
+
*/
|
|
2542
|
+
async quit(force = false) {
|
|
2543
|
+
try {
|
|
2544
|
+
await this._close(force);
|
|
2545
|
+
await this.wire.sendAction('destroy-application', { force, ...this.identity });
|
|
2546
|
+
}
|
|
2547
|
+
catch (error) {
|
|
2548
|
+
const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
|
|
2549
|
+
if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
|
|
2550
|
+
throw error;
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
async _close(force = false) {
|
|
2555
|
+
try {
|
|
2556
|
+
await this.wire.sendAction('close-application', { force, ...this.identity });
|
|
2557
|
+
}
|
|
2558
|
+
catch (error) {
|
|
2559
|
+
if (!error.message.includes('Remote connection has closed')) {
|
|
2560
|
+
throw error;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* @deprecated use Application.quit instead
|
|
2566
|
+
* Closes the application and any child windows created by the application.
|
|
2567
|
+
* @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
|
|
2568
|
+
* @param callback - called if the method succeeds.
|
|
2569
|
+
* @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
|
|
2570
|
+
*
|
|
2571
|
+
* @example
|
|
2572
|
+
*
|
|
2573
|
+
* ```js
|
|
2574
|
+
* async function closeApp() {
|
|
2575
|
+
* const app = await fin.Application.getCurrent();
|
|
2576
|
+
* return await app.close();
|
|
2577
|
+
* }
|
|
2578
|
+
* closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
|
|
2579
|
+
* ```
|
|
2580
|
+
*/
|
|
2581
|
+
close(force = false) {
|
|
2582
|
+
console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
|
|
2583
|
+
this.wire.sendAction('application-close', this.identity).catch((e) => {
|
|
2584
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2585
|
+
});
|
|
2586
|
+
return this._close(force);
|
|
2587
|
+
}
|
|
2588
|
+
/**
|
|
2589
|
+
* Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
|
|
2590
|
+
*
|
|
2591
|
+
* @example
|
|
2592
|
+
*
|
|
2593
|
+
* ```js
|
|
2594
|
+
* async function getChildWindows() {
|
|
2595
|
+
* const app = await fin.Application.getCurrent();
|
|
2596
|
+
* return await app.getChildWindows();
|
|
2597
|
+
* }
|
|
2598
|
+
*
|
|
2599
|
+
* getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
|
|
2600
|
+
* ```
|
|
2601
|
+
*/
|
|
2602
|
+
getChildWindows() {
|
|
2603
|
+
return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
|
|
2604
|
+
const identityList = [];
|
|
2605
|
+
payload.data.forEach((winName) => {
|
|
2606
|
+
identityList.push({ uuid: this.identity.uuid, name: winName });
|
|
2607
|
+
});
|
|
2608
|
+
return this.windowListFromIdentityList(identityList);
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2612
|
+
* Retrieves the JSON manifest that was used to create the application. Invokes the error callback
|
|
2613
|
+
* if the application was not created from a manifest.
|
|
2614
|
+
*
|
|
2615
|
+
* @example
|
|
2616
|
+
*
|
|
2617
|
+
* ```js
|
|
2618
|
+
* async function getManifest() {
|
|
2619
|
+
* const app = await fin.Application.getCurrent();
|
|
2620
|
+
* return await app.getManifest();
|
|
2621
|
+
* }
|
|
2622
|
+
*
|
|
2623
|
+
* getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
|
|
2624
|
+
* ```
|
|
2625
|
+
*/
|
|
2626
|
+
getManifest() {
|
|
2627
|
+
return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Retrieves UUID of the application that launches this application. Invokes the error callback
|
|
2631
|
+
* if the application was created from a manifest.
|
|
2632
|
+
*
|
|
2633
|
+
* @example
|
|
2634
|
+
*
|
|
2635
|
+
* ```js
|
|
2636
|
+
* async function getParentUuid() {
|
|
2637
|
+
* const app = await fin.Application.start({
|
|
2638
|
+
* uuid: 'app-1',
|
|
2639
|
+
* name: 'myApp',
|
|
2640
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
|
|
2641
|
+
* autoShow: true
|
|
2642
|
+
* });
|
|
2643
|
+
* return await app.getParentUuid();
|
|
2644
|
+
* }
|
|
2645
|
+
*
|
|
2646
|
+
* getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
|
|
2647
|
+
* ```
|
|
2648
|
+
*/
|
|
2649
|
+
getParentUuid() {
|
|
2650
|
+
return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Retrieves current application's shortcut configuration.
|
|
2654
|
+
*
|
|
2655
|
+
* @example
|
|
2656
|
+
*
|
|
2657
|
+
* ```js
|
|
2658
|
+
* async function getShortcuts() {
|
|
2659
|
+
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
2660
|
+
* return await app.getShortcuts();
|
|
2661
|
+
* }
|
|
2662
|
+
* getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
|
|
2663
|
+
* ```
|
|
2664
|
+
*/
|
|
2665
|
+
getShortcuts() {
|
|
2666
|
+
return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
|
|
2667
|
+
}
|
|
2668
|
+
/**
|
|
2669
|
+
* Retrieves current application's views.
|
|
2670
|
+
* @experimental
|
|
2671
|
+
*
|
|
2672
|
+
* @example
|
|
2673
|
+
*
|
|
2674
|
+
* ```js
|
|
2675
|
+
* async function getViews() {
|
|
2676
|
+
* const app = await fin.Application.getCurrent();
|
|
2677
|
+
* return await app.getViews();
|
|
2678
|
+
* }
|
|
2679
|
+
* getViews().then(views => console.log(views)).catch(err => console.log(err));
|
|
2680
|
+
* ```
|
|
2681
|
+
*/
|
|
2682
|
+
async getViews() {
|
|
2683
|
+
const { payload } = await this.wire.sendAction('application-get-views', this.identity);
|
|
2684
|
+
return payload.data.map((id) => new view_1.View(this.wire, id));
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Returns the current zoom level of the application.
|
|
2688
|
+
*
|
|
2689
|
+
* @example
|
|
2690
|
+
*
|
|
2691
|
+
* ```js
|
|
2692
|
+
* async function getZoomLevel() {
|
|
2693
|
+
* const app = await fin.Application.getCurrent();
|
|
2694
|
+
* return await app.getZoomLevel();
|
|
2695
|
+
* }
|
|
2696
|
+
*
|
|
2697
|
+
* getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
|
|
2698
|
+
* ```
|
|
2699
|
+
*/
|
|
2700
|
+
getZoomLevel() {
|
|
2701
|
+
return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
|
|
2702
|
+
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Returns an instance of the main Window of the application
|
|
2705
|
+
*
|
|
2706
|
+
* @example
|
|
2707
|
+
*
|
|
2708
|
+
* ```js
|
|
2709
|
+
* async function getWindow() {
|
|
2710
|
+
* const app = await fin.Application.start({
|
|
2711
|
+
* uuid: 'app-1',
|
|
2712
|
+
* name: 'myApp',
|
|
2713
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
|
|
2714
|
+
* autoShow: true
|
|
2715
|
+
* });
|
|
2716
|
+
* return await app.getWindow();
|
|
2717
|
+
* }
|
|
2718
|
+
*
|
|
2719
|
+
* getWindow().then(win => {
|
|
2720
|
+
* win.showAt(0, 400);
|
|
2721
|
+
* win.flash();
|
|
2722
|
+
* }).catch(err => console.log(err));
|
|
2723
|
+
* ```
|
|
2724
|
+
*/
|
|
2725
|
+
getWindow() {
|
|
2726
|
+
this.wire.sendAction('application-get-window', this.identity).catch((e) => {
|
|
2727
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2728
|
+
});
|
|
2729
|
+
return Promise.resolve(this.window);
|
|
2730
|
+
}
|
|
2731
|
+
/**
|
|
2732
|
+
* Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
|
|
2733
|
+
* @param userName - username to be passed to the RVM.
|
|
2734
|
+
* @param appName - app name to be passed to the RVM.
|
|
2735
|
+
*
|
|
2736
|
+
* @example
|
|
2737
|
+
*
|
|
2738
|
+
* ```js
|
|
2739
|
+
* async function registerUser() {
|
|
2740
|
+
* const app = await fin.Application.getCurrent();
|
|
2741
|
+
* return await app.registerUser('user', 'myApp');
|
|
2742
|
+
* }
|
|
2743
|
+
*
|
|
2744
|
+
* registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
2747
|
+
registerUser(userName, appName) {
|
|
2748
|
+
return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
|
|
2749
|
+
}
|
|
2750
|
+
/**
|
|
2751
|
+
* Removes the application’s icon from the tray.
|
|
2752
|
+
*
|
|
2753
|
+
* @example
|
|
2754
|
+
*
|
|
2755
|
+
* ```js
|
|
2756
|
+
* async function removeTrayIcon() {
|
|
2757
|
+
* const app = await fin.Application.getCurrent();
|
|
2758
|
+
* return await app.removeTrayIcon();
|
|
2759
|
+
* }
|
|
2760
|
+
*
|
|
2761
|
+
* removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
|
|
2762
|
+
* ```
|
|
2763
|
+
*/
|
|
2764
|
+
removeTrayIcon() {
|
|
2765
|
+
return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
|
|
2766
|
+
}
|
|
2767
|
+
/**
|
|
2768
|
+
* Restarts the application.
|
|
2769
|
+
*
|
|
2770
|
+
* @example
|
|
2771
|
+
*
|
|
2772
|
+
* ```js
|
|
2773
|
+
* async function restartApp() {
|
|
2774
|
+
* const app = await fin.Application.getCurrent();
|
|
2775
|
+
* return await app.restart();
|
|
2776
|
+
* }
|
|
2777
|
+
* restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
|
|
2778
|
+
* ```
|
|
2779
|
+
*/
|
|
2780
|
+
restart() {
|
|
2781
|
+
return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* DEPRECATED method to run the application.
|
|
2785
|
+
* Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
|
|
2786
|
+
*
|
|
2787
|
+
* @example
|
|
2788
|
+
*
|
|
2789
|
+
* ```js
|
|
2790
|
+
* async function run() {
|
|
2791
|
+
* const app = await fin.Application.create({
|
|
2792
|
+
* name: 'myApp',
|
|
2793
|
+
* uuid: 'app-1',
|
|
2794
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
|
|
2795
|
+
* autoShow: true
|
|
2796
|
+
* });
|
|
2797
|
+
* await app.run();
|
|
2798
|
+
* }
|
|
2799
|
+
* run().then(() => console.log('Application is running')).catch(err => console.log(err));
|
|
2800
|
+
* ```
|
|
2801
|
+
*
|
|
2802
|
+
* @ignore
|
|
2803
|
+
*/
|
|
2804
|
+
run() {
|
|
2805
|
+
console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
|
|
2806
|
+
this.wire.sendAction('application-run', this.identity).catch((e) => {
|
|
2807
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2808
|
+
});
|
|
2809
|
+
return this._run();
|
|
2810
|
+
}
|
|
2811
|
+
_run(opts = {}) {
|
|
2812
|
+
return this.wire
|
|
2813
|
+
.sendAction('run-application', {
|
|
2814
|
+
manifestUrl: this._manifestUrl,
|
|
2815
|
+
opts,
|
|
2816
|
+
...this.identity
|
|
2817
|
+
})
|
|
2818
|
+
.then(() => undefined);
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2821
|
+
* Instructs the RVM to schedule one restart of the application.
|
|
2822
|
+
*
|
|
2823
|
+
* @example
|
|
2824
|
+
*
|
|
2825
|
+
* ```js
|
|
2826
|
+
* async function scheduleRestart() {
|
|
2827
|
+
* const app = await fin.Application.getCurrent();
|
|
2828
|
+
* return await app.scheduleRestart();
|
|
2829
|
+
* }
|
|
2830
|
+
*
|
|
2831
|
+
* scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
|
|
2832
|
+
* ```
|
|
2833
|
+
*/
|
|
2834
|
+
scheduleRestart() {
|
|
2835
|
+
return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Sends a message to the RVM to upload the application's logs. On success,
|
|
2839
|
+
* an object containing logId is returned.
|
|
2840
|
+
*
|
|
2841
|
+
* @example
|
|
2842
|
+
*
|
|
2843
|
+
* ```js
|
|
2844
|
+
* async function sendLog() {
|
|
2845
|
+
* const app = await fin.Application.getCurrent();
|
|
2846
|
+
* return await app.sendApplicationLog();
|
|
2847
|
+
* }
|
|
2848
|
+
*
|
|
2849
|
+
* sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
|
|
2850
|
+
* ```
|
|
2851
|
+
*/
|
|
2852
|
+
async sendApplicationLog() {
|
|
2853
|
+
const { payload } = await this.wire.sendAction('send-application-log', this.identity);
|
|
2854
|
+
return payload.data;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
|
|
2858
|
+
* If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
|
|
2859
|
+
*
|
|
2860
|
+
* Note: If the "name" property is omitted it defaults to "tasks".
|
|
2861
|
+
* @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
|
|
2862
|
+
*
|
|
2863
|
+
*
|
|
2864
|
+
* @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
|
|
2865
|
+
*
|
|
2866
|
+
* The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
|
|
2867
|
+
* **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
|
|
2868
|
+
*
|
|
2869
|
+
* Note: If the "name" property is omitted it defaults to "tasks".
|
|
2870
|
+
*
|
|
2871
|
+
* Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
|
|
2872
|
+
* uuid or shortcut.name is changed.
|
|
2873
|
+
*
|
|
2874
|
+
* @example
|
|
2875
|
+
*
|
|
2876
|
+
* ```js
|
|
2877
|
+
* const app = fin.Application.getCurrentSync();
|
|
2878
|
+
* const appName = 'My App';
|
|
2879
|
+
* const jumpListConfig = [ // array of JumpList categories
|
|
2880
|
+
* {
|
|
2881
|
+
* // has no name and no type so `type` is assumed to be "tasks"
|
|
2882
|
+
* items: [ // array of JumpList items
|
|
2883
|
+
* {
|
|
2884
|
+
* type: 'task',
|
|
2885
|
+
* title: `Launch ${appName}`,
|
|
2886
|
+
* description: `Runs ${appName} with the default configuration`,
|
|
2887
|
+
* deepLink: 'fins://path.to/app/manifest.json',
|
|
2888
|
+
* iconPath: 'https://path.to/app/icon.ico',
|
|
2889
|
+
* iconIndex: 0
|
|
2890
|
+
* },
|
|
2891
|
+
* { type: 'separator' },
|
|
2892
|
+
* {
|
|
2893
|
+
* type: 'task',
|
|
2894
|
+
* title: `Restore ${appName}`,
|
|
2895
|
+
* description: 'Restore to last configuration',
|
|
2896
|
+
* deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
|
|
2897
|
+
* iconPath: 'https://path.to/app/icon.ico',
|
|
2898
|
+
* iconIndex: 0
|
|
2899
|
+
* },
|
|
2900
|
+
* ]
|
|
2901
|
+
* },
|
|
2902
|
+
* {
|
|
2903
|
+
* name: 'Tools',
|
|
2904
|
+
* items: [ // array of JumpList items
|
|
2905
|
+
* {
|
|
2906
|
+
* type: 'task',
|
|
2907
|
+
* title: 'Tool A',
|
|
2908
|
+
* description: 'Runs Tool A',
|
|
2909
|
+
* deepLink: 'fins://path.to/tool-a/manifest.json',
|
|
2910
|
+
* iconPath: 'https://path.to/tool-a/icon.ico',
|
|
2911
|
+
* iconIndex: 0
|
|
2912
|
+
* },
|
|
2913
|
+
* {
|
|
2914
|
+
* type: 'task',
|
|
2915
|
+
* title: 'Tool B',
|
|
2916
|
+
* description: 'Runs Tool B',
|
|
2917
|
+
* deepLink: 'fins://path.to/tool-b/manifest.json',
|
|
2918
|
+
* iconPath: 'https://path.to/tool-b/icon.ico',
|
|
2919
|
+
* iconIndex: 0
|
|
2920
|
+
* }]
|
|
2921
|
+
* }
|
|
2922
|
+
* ];
|
|
2923
|
+
*
|
|
2924
|
+
* app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
|
|
2925
|
+
* ```
|
|
2926
|
+
*
|
|
2927
|
+
* To handle deeplink args:
|
|
2928
|
+
* ```js
|
|
2929
|
+
* function handleUseLastConfiguration() {
|
|
2930
|
+
* // this handler is called when the app is being launched
|
|
2931
|
+
* app.on('run-requested', event => {
|
|
2932
|
+
* if(event.userAppConfigArgs['use-last-configuration']) {
|
|
2933
|
+
* // your logic here
|
|
2934
|
+
* }
|
|
2935
|
+
* });
|
|
2936
|
+
* // this handler is called when the app was already running when the launch was requested
|
|
2937
|
+
* fin.desktop.main(function(args) {
|
|
2938
|
+
* if(args && args['use-last-configuration']) {
|
|
2939
|
+
* // your logic here
|
|
2940
|
+
* }
|
|
2941
|
+
* });
|
|
2942
|
+
* }
|
|
2943
|
+
* ```
|
|
2944
|
+
*/
|
|
2945
|
+
async setJumpList(jumpListCategories) {
|
|
2946
|
+
await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
|
|
2947
|
+
}
|
|
2948
|
+
/**
|
|
2949
|
+
* Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
|
|
2950
|
+
* @param icon Image URL or base64 encoded string to be used as the icon
|
|
2951
|
+
*
|
|
2952
|
+
* @example
|
|
2953
|
+
*
|
|
2954
|
+
* ```js
|
|
2955
|
+
* const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
|
|
2956
|
+
* const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
|
|
2957
|
+
* ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
|
|
2958
|
+
* const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
|
|
2959
|
+
* xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
|
2960
|
+
*
|
|
2961
|
+
* async function setTrayIcon(icon) {
|
|
2962
|
+
* const app = await fin.Application.getCurrent();
|
|
2963
|
+
* return await app.setTrayIcon(icon);
|
|
2964
|
+
* }
|
|
2965
|
+
*
|
|
2966
|
+
* // use image url to set tray icon
|
|
2967
|
+
* setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2968
|
+
*
|
|
2969
|
+
* // use base64 encoded string to set tray icon
|
|
2970
|
+
* setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2971
|
+
*
|
|
2972
|
+
* // use a dataURL to set tray icon
|
|
2973
|
+
* setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
|
|
2974
|
+
* ```
|
|
2975
|
+
*/
|
|
2976
|
+
setTrayIcon(icon) {
|
|
2977
|
+
return this.wire
|
|
2978
|
+
.sendAction('set-tray-icon', {
|
|
2979
|
+
enabledIcon: icon,
|
|
2980
|
+
...this.identity
|
|
2981
|
+
})
|
|
2982
|
+
.then(() => undefined);
|
|
2983
|
+
}
|
|
2984
|
+
/**
|
|
2985
|
+
* Set hover text for this application's system tray icon.
|
|
2986
|
+
* Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
|
|
2987
|
+
* @param toolTip
|
|
2988
|
+
*
|
|
2989
|
+
* @example
|
|
2990
|
+
*
|
|
2991
|
+
* ```js
|
|
2992
|
+
* const app = fin.Application.getCurrentSync();
|
|
2993
|
+
* const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
|
|
2994
|
+
*
|
|
2995
|
+
* await app.setTrayIcon(iconUrl);
|
|
2996
|
+
*
|
|
2997
|
+
* await app.setTrayIconToolTip('My Application');
|
|
2998
|
+
* ```
|
|
2999
|
+
*/
|
|
3000
|
+
async setTrayIconToolTip(toolTip) {
|
|
3001
|
+
await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Sets new application's shortcut configuration. Windows only.
|
|
3005
|
+
* @param config New application's shortcut configuration.
|
|
3006
|
+
*
|
|
3007
|
+
* @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
|
|
3008
|
+
* to be able to change shortcut states.
|
|
3009
|
+
*
|
|
3010
|
+
* @example
|
|
3011
|
+
*
|
|
3012
|
+
* ```js
|
|
3013
|
+
* async function setShortcuts(config) {
|
|
3014
|
+
* const app = await fin.Application.getCurrent();
|
|
3015
|
+
* return app.setShortcuts(config);
|
|
3016
|
+
* }
|
|
3017
|
+
*
|
|
3018
|
+
* setShortcuts({
|
|
3019
|
+
* desktop: true,
|
|
3020
|
+
* startMenu: false,
|
|
3021
|
+
* systemStartup: true
|
|
3022
|
+
* }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
|
|
3023
|
+
* ```
|
|
3024
|
+
*/
|
|
3025
|
+
setShortcuts(config) {
|
|
3026
|
+
return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
|
|
3030
|
+
* @param queryString The new query string for this app's shortcuts.
|
|
3031
|
+
*
|
|
3032
|
+
* @example
|
|
3033
|
+
*
|
|
3034
|
+
* ```js
|
|
3035
|
+
* const newQueryArgs = 'arg=true&arg2=false';
|
|
3036
|
+
* const app = await fin.Application.getCurrent();
|
|
3037
|
+
* try {
|
|
3038
|
+
* await app.setShortcutQueryParams(newQueryArgs);
|
|
3039
|
+
* } catch(err) {
|
|
3040
|
+
* console.error(err)
|
|
3041
|
+
* }
|
|
3042
|
+
* ```
|
|
3043
|
+
*/
|
|
3044
|
+
async setShortcutQueryParams(queryString) {
|
|
3045
|
+
await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
|
|
3046
|
+
}
|
|
3047
|
+
/**
|
|
3048
|
+
* Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
|
|
3049
|
+
* larger or smaller to default limits of 300% and 50% of original size, respectively.
|
|
3050
|
+
* @param level The zoom level
|
|
3051
|
+
*
|
|
3052
|
+
* @example
|
|
3053
|
+
*
|
|
3054
|
+
* ```js
|
|
3055
|
+
* async function setZoomLevel(number) {
|
|
3056
|
+
* const app = await fin.Application.getCurrent();
|
|
3057
|
+
* return await app.setZoomLevel(number);
|
|
3058
|
+
* }
|
|
3059
|
+
*
|
|
3060
|
+
* setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
|
|
3061
|
+
* ```
|
|
3062
|
+
*/
|
|
3063
|
+
setZoomLevel(level) {
|
|
3064
|
+
return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
|
|
3065
|
+
}
|
|
3066
|
+
/**
|
|
3067
|
+
* Sets a username to correlate with App Log Management.
|
|
3068
|
+
* @param username Username to correlate with App's Log.
|
|
3069
|
+
*
|
|
3070
|
+
* @example
|
|
3071
|
+
*
|
|
3072
|
+
* ```js
|
|
3073
|
+
* async function setAppLogUser() {
|
|
3074
|
+
* const app = await fin.Application.getCurrent();
|
|
3075
|
+
* return await app.setAppLogUsername('username');
|
|
3076
|
+
* }
|
|
3077
|
+
*
|
|
3078
|
+
* setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
|
|
3079
|
+
*
|
|
3080
|
+
* ```
|
|
3081
|
+
*/
|
|
3082
|
+
async setAppLogUsername(username) {
|
|
3083
|
+
await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
|
|
3084
|
+
}
|
|
3085
|
+
/**
|
|
3086
|
+
* Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
|
|
3087
|
+
* @remarks The only information currently returned is the position and dimensions.
|
|
3088
|
+
*
|
|
3089
|
+
* @example
|
|
3090
|
+
*
|
|
3091
|
+
* ```js
|
|
3092
|
+
* async function getTrayIconInfo() {
|
|
3093
|
+
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
3094
|
+
* return await app.getTrayIconInfo();
|
|
3095
|
+
* }
|
|
3096
|
+
* getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
|
|
3097
|
+
* ```
|
|
3098
|
+
*/
|
|
3099
|
+
getTrayIconInfo() {
|
|
3100
|
+
return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
|
|
3101
|
+
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Checks if the application has an associated tray icon.
|
|
3104
|
+
*
|
|
3105
|
+
* @example
|
|
3106
|
+
*
|
|
3107
|
+
* ```js
|
|
3108
|
+
* const app = await fin.Application.wrap({ uuid: 'testapp' });
|
|
3109
|
+
* const hasTrayIcon = await app.hasTrayIcon();
|
|
3110
|
+
* console.log(hasTrayIcon);
|
|
3111
|
+
* ```
|
|
3112
|
+
*/
|
|
3113
|
+
hasTrayIcon() {
|
|
3114
|
+
return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Closes the application by terminating its process.
|
|
3118
|
+
*
|
|
3119
|
+
* @example
|
|
3120
|
+
*
|
|
3121
|
+
* ```js
|
|
3122
|
+
* async function terminateApp() {
|
|
3123
|
+
* const app = await fin.Application.getCurrent();
|
|
3124
|
+
* return await app.terminate();
|
|
3125
|
+
* }
|
|
3126
|
+
* terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
|
|
3127
|
+
* ```
|
|
3128
|
+
*/
|
|
3129
|
+
terminate() {
|
|
3130
|
+
return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
|
|
3131
|
+
}
|
|
3132
|
+
/**
|
|
3133
|
+
* Waits for a hanging application. This method can be called in response to an application
|
|
3134
|
+
* "not-responding" to allow the application to continue and to generate another "not-responding"
|
|
3135
|
+
* message after a certain period of time.
|
|
3136
|
+
*
|
|
3137
|
+
* @ignore
|
|
3138
|
+
*/
|
|
3139
|
+
wait() {
|
|
3140
|
+
return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Retrieves information about the application.
|
|
3144
|
+
*
|
|
3145
|
+
* @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
|
|
3146
|
+
* and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
|
|
3147
|
+
* if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
|
|
3148
|
+
*
|
|
3149
|
+
* @example
|
|
3150
|
+
*
|
|
3151
|
+
* ```js
|
|
3152
|
+
* async function getInfo() {
|
|
3153
|
+
* const app = await fin.Application.getCurrent();
|
|
3154
|
+
* return await app.getInfo();
|
|
3155
|
+
* }
|
|
3156
|
+
*
|
|
3157
|
+
* getInfo().then(info => console.log(info)).catch(err => console.log(err));
|
|
3158
|
+
* ```
|
|
3159
|
+
*/
|
|
3160
|
+
getInfo() {
|
|
3161
|
+
return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* Retrieves all process information for entities (windows and views) associated with an application.
|
|
3165
|
+
*
|
|
3166
|
+
* @example
|
|
3167
|
+
* ```js
|
|
3168
|
+
* const app = await fin.Application.getCurrent();
|
|
3169
|
+
* const processInfo = await app.getProcessInfo();
|
|
3170
|
+
* ```
|
|
3171
|
+
* @experimental
|
|
3172
|
+
*/
|
|
3173
|
+
async getProcessInfo() {
|
|
3174
|
+
const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
|
|
3175
|
+
return data;
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Sets file auto download location. It's only allowed in the same application.
|
|
3179
|
+
*
|
|
3180
|
+
* Note: This method is restricted by default and must be enabled via
|
|
3181
|
+
* <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
|
|
3182
|
+
* @param downloadLocation file auto download location
|
|
3183
|
+
*
|
|
3184
|
+
* @throws if setting file auto download location on different applications.
|
|
3185
|
+
* @example
|
|
3186
|
+
*
|
|
3187
|
+
* ```js
|
|
3188
|
+
* const downloadLocation = 'C:\\dev\\temp';
|
|
3189
|
+
* const app = await fin.Application.getCurrent();
|
|
3190
|
+
* try {
|
|
3191
|
+
* await app.setFileDownloadLocation(downloadLocation);
|
|
3192
|
+
* console.log('File download location is set');
|
|
3193
|
+
* } catch(err) {
|
|
3194
|
+
* console.error(err)
|
|
3195
|
+
* }
|
|
3196
|
+
* ```
|
|
3197
|
+
*/
|
|
3198
|
+
async setFileDownloadLocation(downloadLocation) {
|
|
3199
|
+
const { name } = this.wire.me;
|
|
3200
|
+
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3201
|
+
await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
|
|
3205
|
+
*
|
|
3206
|
+
* Note: This method is restricted by default and must be enabled via
|
|
3207
|
+
* <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
|
|
3208
|
+
*
|
|
3209
|
+
* @throws if getting file auto download location on different applications.
|
|
3210
|
+
* @example
|
|
3211
|
+
*
|
|
3212
|
+
* ```js
|
|
3213
|
+
* const app = await fin.Application.getCurrent();
|
|
3214
|
+
* const fileDownloadDir = await app.getFileDownloadLocation();
|
|
3215
|
+
* ```
|
|
3216
|
+
*/
|
|
3217
|
+
async getFileDownloadLocation() {
|
|
3218
|
+
const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
|
|
3219
|
+
return data;
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* Shows a menu on the tray icon. Use with tray-icon-clicked event.
|
|
3223
|
+
* @param options
|
|
3224
|
+
* @typeParam Data User-defined shape for data returned upon menu item click. Should be a
|
|
3225
|
+
* [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
|
|
3226
|
+
* of all possible data shapes for the entire menu, and the click handler should process
|
|
3227
|
+
* these with a "reducer" pattern.
|
|
3228
|
+
* @throws if the application has no tray icon set
|
|
3229
|
+
* @throws if the system tray is currently hidden
|
|
3230
|
+
* @example
|
|
3231
|
+
*
|
|
3232
|
+
* ```js
|
|
3233
|
+
* const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
|
|
3234
|
+
* const app = fin.Application.getCurrentSync();
|
|
3235
|
+
*
|
|
3236
|
+
* await app.setTrayIcon(iconUrl);
|
|
3237
|
+
*
|
|
3238
|
+
* const template = [
|
|
3239
|
+
* {
|
|
3240
|
+
* label: 'Menu Item 1',
|
|
3241
|
+
* data: 'hello from item 1'
|
|
3242
|
+
* },
|
|
3243
|
+
* { type: 'separator' },
|
|
3244
|
+
* {
|
|
3245
|
+
* label: 'Menu Item 2',
|
|
3246
|
+
* type: 'checkbox',
|
|
3247
|
+
* checked: true,
|
|
3248
|
+
* data: 'The user clicked the checkbox'
|
|
3249
|
+
* },
|
|
3250
|
+
* {
|
|
3251
|
+
* label: 'see more',
|
|
3252
|
+
* enabled: false,
|
|
3253
|
+
* submenu: [
|
|
3254
|
+
* { label: 'submenu 1', data: 'hello from submenu' }
|
|
3255
|
+
* ]
|
|
3256
|
+
* }
|
|
3257
|
+
* ];
|
|
3258
|
+
*
|
|
3259
|
+
* app.addListener('tray-icon-clicked', (event) => {
|
|
3260
|
+
* // right-click
|
|
3261
|
+
* if (event.button === 2) {
|
|
3262
|
+
* app.showTrayIconPopupMenu({ template }).then(r => {
|
|
3263
|
+
* if (r.result === 'closed') {
|
|
3264
|
+
* console.log('nothing happened');
|
|
3265
|
+
* } else {
|
|
3266
|
+
* console.log(r.data);
|
|
3267
|
+
* }
|
|
3268
|
+
* });
|
|
3269
|
+
* }
|
|
3270
|
+
* });
|
|
3271
|
+
* ```
|
|
3272
|
+
*/
|
|
3273
|
+
async showTrayIconPopupMenu(options) {
|
|
3274
|
+
const { name } = this.wire.me;
|
|
3275
|
+
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3276
|
+
const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
|
|
3277
|
+
return payload.data;
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Closes the tray icon menu.
|
|
3281
|
+
*
|
|
3282
|
+
* @throws if the application has no tray icon set
|
|
3283
|
+
* @example
|
|
3284
|
+
*
|
|
3285
|
+
* ```js
|
|
3286
|
+
* const app = fin.Application.getCurrentSync();
|
|
3287
|
+
*
|
|
3288
|
+
* await app.closeTrayIconPopupMenu();
|
|
3289
|
+
* ```
|
|
3290
|
+
*/
|
|
3291
|
+
async closeTrayIconPopupMenu() {
|
|
3292
|
+
const { name } = this.wire.me;
|
|
3293
|
+
const entityIdentity = { uuid: this.identity.uuid, name };
|
|
3294
|
+
await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
Instance$6.Application = Application;
|
|
3298
|
+
return Instance$6;
|
|
3564
3299
|
}
|
|
3565
|
-
Factory$7.ApplicationModule = ApplicationModule;
|
|
3566
3300
|
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
o[k2] = m[k];
|
|
3578
|
-
}));
|
|
3579
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
3580
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3581
|
-
};
|
|
3582
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3301
|
+
var hasRequiredFactory$2;
|
|
3302
|
+
|
|
3303
|
+
function requireFactory$2 () {
|
|
3304
|
+
if (hasRequiredFactory$2) return Factory$7;
|
|
3305
|
+
hasRequiredFactory$2 = 1;
|
|
3306
|
+
Object.defineProperty(Factory$7, "__esModule", { value: true });
|
|
3307
|
+
Factory$7.ApplicationModule = void 0;
|
|
3308
|
+
const base_1 = base;
|
|
3309
|
+
const validate_1 = validate;
|
|
3310
|
+
const Instance_1 = requireInstance$1();
|
|
3583
3311
|
/**
|
|
3584
|
-
*
|
|
3585
|
-
*
|
|
3586
|
-
* * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
|
|
3587
|
-
* * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
|
|
3588
|
-
*
|
|
3589
|
-
* These are separate code entities, and are documented separately. In the [previous version of the API documentation](https://cdn.openfin.co/docs/javascript/32.114.76.10/index.html),
|
|
3590
|
-
* both of these were documented on the same page.
|
|
3591
|
-
*
|
|
3592
|
-
* @packageDocumentation
|
|
3312
|
+
* Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
|
|
3593
3313
|
*/
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3314
|
+
class ApplicationModule extends base_1.Base {
|
|
3315
|
+
/**
|
|
3316
|
+
* Asynchronously returns an API handle for the given Application identity.
|
|
3317
|
+
*
|
|
3318
|
+
* @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
|
|
3319
|
+
* returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
|
|
3320
|
+
* for an Application throughout its entire lifecycle.
|
|
3321
|
+
*
|
|
3322
|
+
* @example
|
|
3323
|
+
*
|
|
3324
|
+
* ```js
|
|
3325
|
+
* fin.Application.wrap({ uuid: 'testapp' })
|
|
3326
|
+
* .then(app => app.isRunning())
|
|
3327
|
+
* .then(running => console.log('Application is running: ' + running))
|
|
3328
|
+
* .catch(err => console.log(err));
|
|
3329
|
+
* ```
|
|
3330
|
+
*
|
|
3331
|
+
*/
|
|
3332
|
+
async wrap(identity) {
|
|
3333
|
+
this.wire.sendAction('wrap-application').catch((e) => {
|
|
3334
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3335
|
+
});
|
|
3336
|
+
const errorMsg = (0, validate_1.validateIdentity)(identity);
|
|
3337
|
+
if (errorMsg) {
|
|
3338
|
+
throw new Error(errorMsg);
|
|
3339
|
+
}
|
|
3340
|
+
return new Instance_1.Application(this.wire, identity);
|
|
3341
|
+
}
|
|
3342
|
+
/**
|
|
3343
|
+
* Synchronously returns an API handle for the given Application identity.
|
|
3344
|
+
*
|
|
3345
|
+
* @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
|
|
3346
|
+
* returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
|
|
3347
|
+
* for an Aplication throughout its entire lifecycle.
|
|
3348
|
+
*
|
|
3349
|
+
* @example
|
|
3350
|
+
*
|
|
3351
|
+
* ```js
|
|
3352
|
+
* const app = fin.Application.wrapSync({ uuid: 'testapp' });
|
|
3353
|
+
* await app.close();
|
|
3354
|
+
* ```
|
|
3355
|
+
*
|
|
3356
|
+
*/
|
|
3357
|
+
wrapSync(identity) {
|
|
3358
|
+
this.wire.sendAction('wrap-application-sync').catch((e) => {
|
|
3359
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3360
|
+
});
|
|
3361
|
+
const errorMsg = (0, validate_1.validateIdentity)(identity);
|
|
3362
|
+
if (errorMsg) {
|
|
3363
|
+
throw new Error(errorMsg);
|
|
3364
|
+
}
|
|
3365
|
+
return new Instance_1.Application(this.wire, identity);
|
|
3366
|
+
}
|
|
3367
|
+
async _create(appOptions) {
|
|
3368
|
+
// set defaults:
|
|
3369
|
+
if (appOptions.waitForPageLoad === undefined) {
|
|
3370
|
+
appOptions.waitForPageLoad = false;
|
|
3371
|
+
}
|
|
3372
|
+
if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
|
|
3373
|
+
appOptions.autoShow = true;
|
|
3374
|
+
}
|
|
3375
|
+
await this.wire.sendAction('create-application', appOptions);
|
|
3376
|
+
return this.wrap({ uuid: appOptions.uuid });
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
|
|
3380
|
+
*
|
|
3381
|
+
* @example
|
|
3382
|
+
*
|
|
3383
|
+
* ```js
|
|
3384
|
+
* async function createApp() {
|
|
3385
|
+
* const app = await fin.Application.create({
|
|
3386
|
+
* name: 'myApp',
|
|
3387
|
+
* uuid: 'app-3',
|
|
3388
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
|
|
3389
|
+
* autoShow: true
|
|
3390
|
+
* });
|
|
3391
|
+
* await app.run();
|
|
3392
|
+
* }
|
|
3393
|
+
*
|
|
3394
|
+
* createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
|
|
3395
|
+
* ```
|
|
3396
|
+
*
|
|
3397
|
+
* @ignore
|
|
3398
|
+
*/
|
|
3399
|
+
create(appOptions) {
|
|
3400
|
+
console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
|
|
3401
|
+
this.wire.sendAction('application-create').catch((e) => {
|
|
3402
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3403
|
+
});
|
|
3404
|
+
return this._create(appOptions);
|
|
3405
|
+
}
|
|
3406
|
+
/**
|
|
3407
|
+
* Creates and starts a new Application.
|
|
3408
|
+
*
|
|
3409
|
+
* @example
|
|
3410
|
+
*
|
|
3411
|
+
* ```js
|
|
3412
|
+
* async function start() {
|
|
3413
|
+
* return fin.Application.start({
|
|
3414
|
+
* name: 'app-1',
|
|
3415
|
+
* uuid: 'app-1',
|
|
3416
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
|
|
3417
|
+
* autoShow: true
|
|
3418
|
+
* });
|
|
3419
|
+
* }
|
|
3420
|
+
* start().then(() => console.log('Application is running')).catch(err => console.log(err));
|
|
3421
|
+
* ```
|
|
3422
|
+
*
|
|
3423
|
+
*/
|
|
3424
|
+
async start(appOptions) {
|
|
3425
|
+
this.wire.sendAction('start-application').catch((e) => {
|
|
3426
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3427
|
+
});
|
|
3428
|
+
const app = await this._create(appOptions);
|
|
3429
|
+
await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
|
|
3430
|
+
return app;
|
|
3431
|
+
}
|
|
3432
|
+
/**
|
|
3433
|
+
* Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
|
|
3434
|
+
* Returns once the RVM is finished attempting to launch the applications.
|
|
3435
|
+
* @param opts - Parameters that the RVM will use.
|
|
3436
|
+
*
|
|
3437
|
+
* @example
|
|
3438
|
+
*
|
|
3439
|
+
* ```js
|
|
3440
|
+
*
|
|
3441
|
+
* const applicationInfoArray = [
|
|
3442
|
+
* {
|
|
3443
|
+
* "uuid": 'App-1',
|
|
3444
|
+
* "manifestUrl": 'http://localhost:5555/app1.json',
|
|
3445
|
+
* },
|
|
3446
|
+
* {
|
|
3447
|
+
* "uuid": 'App-2',
|
|
3448
|
+
* "manifestUrl": 'http://localhost:5555/app2.json',
|
|
3449
|
+
* },
|
|
3450
|
+
* {
|
|
3451
|
+
* "uuid": 'App-3',
|
|
3452
|
+
* "manifestUrl": 'http://localhost:5555/app3.json',
|
|
3453
|
+
* }
|
|
3454
|
+
* ]
|
|
3455
|
+
*
|
|
3456
|
+
* fin.Application.startManyManifests(applicationInfoArray)
|
|
3457
|
+
* .then(() => {
|
|
3458
|
+
* console.log('RVM has finished launching the application list.');
|
|
3459
|
+
* })
|
|
3460
|
+
* .catch((err) => {
|
|
3461
|
+
* console.log(err);
|
|
3462
|
+
* })
|
|
3463
|
+
* ```
|
|
3464
|
+
*
|
|
3465
|
+
* @experimental
|
|
3466
|
+
*/
|
|
3467
|
+
async startManyManifests(applications, opts) {
|
|
3468
|
+
return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
|
|
3469
|
+
}
|
|
3470
|
+
/**
|
|
3471
|
+
* Asynchronously returns an Application object that represents the current application
|
|
3472
|
+
*
|
|
3473
|
+
* @example
|
|
3474
|
+
*
|
|
3475
|
+
* ```js
|
|
3476
|
+
* async function isCurrentAppRunning () {
|
|
3477
|
+
* const app = await fin.Application.getCurrent();
|
|
3478
|
+
* return app.isRunning();
|
|
3479
|
+
* }
|
|
3480
|
+
*
|
|
3481
|
+
* isCurrentAppRunning().then(running => {
|
|
3482
|
+
* console.log(`Current app is running: ${running}`);
|
|
3483
|
+
* }).catch(err => {
|
|
3484
|
+
* console.error(err);
|
|
3485
|
+
* });
|
|
3486
|
+
*
|
|
3487
|
+
* ```
|
|
3488
|
+
*/
|
|
3489
|
+
getCurrent() {
|
|
3490
|
+
this.wire.sendAction('get-current-application').catch((e) => {
|
|
3491
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3492
|
+
});
|
|
3493
|
+
return this.wrap({ uuid: this.wire.me.uuid });
|
|
3494
|
+
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Synchronously returns an Application object that represents the current application
|
|
3497
|
+
*
|
|
3498
|
+
* @example
|
|
3499
|
+
*
|
|
3500
|
+
* ```js
|
|
3501
|
+
* async function isCurrentAppRunning () {
|
|
3502
|
+
* const app = fin.Application.getCurrentSync();
|
|
3503
|
+
* return app.isRunning();
|
|
3504
|
+
* }
|
|
3505
|
+
*
|
|
3506
|
+
* isCurrentAppRunning().then(running => {
|
|
3507
|
+
* console.log(`Current app is running: ${running}`);
|
|
3508
|
+
* }).catch(err => {
|
|
3509
|
+
* console.error(err);
|
|
3510
|
+
* });
|
|
3511
|
+
*
|
|
3512
|
+
* ```
|
|
3513
|
+
*/
|
|
3514
|
+
getCurrentSync() {
|
|
3515
|
+
this.wire.sendAction('get-current-application-sync').catch((e) => {
|
|
3516
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3517
|
+
});
|
|
3518
|
+
return this.wrapSync({ uuid: this.wire.me.uuid });
|
|
3519
|
+
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Retrieves application's manifest and returns a running instance of the application.
|
|
3522
|
+
* @param manifestUrl - The URL of app's manifest.
|
|
3523
|
+
* @param opts - Parameters that the RVM will use.
|
|
3524
|
+
*
|
|
3525
|
+
* @example
|
|
3526
|
+
*
|
|
3527
|
+
* ```js
|
|
3528
|
+
* fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
|
|
3529
|
+
*
|
|
3530
|
+
* // For a local manifest file:
|
|
3531
|
+
* fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
|
|
3532
|
+
* ```
|
|
3533
|
+
*/
|
|
3534
|
+
async startFromManifest(manifestUrl, opts) {
|
|
3535
|
+
this.wire.sendAction('application-start-from-manifest').catch((e) => {
|
|
3536
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3537
|
+
});
|
|
3538
|
+
const app = await this._createFromManifest(manifestUrl);
|
|
3539
|
+
// @ts-expect-error using private method without warning.
|
|
3540
|
+
await app._run(opts); // eslint-disable-line no-underscore-dangle
|
|
3541
|
+
return app;
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
|
|
3545
|
+
* Retrieves application's manifest and returns a wrapped application.
|
|
3546
|
+
* @param manifestUrl - The URL of app's manifest.
|
|
3547
|
+
* @param callback - called if the method succeeds.
|
|
3548
|
+
* @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
|
|
3549
|
+
*
|
|
3550
|
+
* @example
|
|
3551
|
+
*
|
|
3552
|
+
* ```js
|
|
3553
|
+
* fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
|
|
3554
|
+
* ```
|
|
3555
|
+
* @ignore
|
|
3556
|
+
*/
|
|
3557
|
+
createFromManifest(manifestUrl) {
|
|
3558
|
+
console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
|
|
3559
|
+
this.wire.sendAction('application-create-from-manifest').catch((e) => {
|
|
3560
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
3561
|
+
});
|
|
3562
|
+
return this._createFromManifest(manifestUrl);
|
|
3563
|
+
}
|
|
3564
|
+
_createFromManifest(manifestUrl) {
|
|
3565
|
+
return this.wire
|
|
3566
|
+
.sendAction('get-application-manifest', { manifestUrl })
|
|
3567
|
+
.then(({ payload }) => {
|
|
3568
|
+
const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
|
|
3569
|
+
return this.wrap({ uuid });
|
|
3570
|
+
})
|
|
3571
|
+
.then((app) => {
|
|
3572
|
+
app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
|
|
3573
|
+
return app;
|
|
3574
|
+
});
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
Factory$7.ApplicationModule = ApplicationModule;
|
|
3578
|
+
return Factory$7;
|
|
3579
|
+
}
|
|
3580
|
+
|
|
3581
|
+
var hasRequiredApplication;
|
|
3582
|
+
|
|
3583
|
+
function requireApplication () {
|
|
3584
|
+
if (hasRequiredApplication) return application;
|
|
3585
|
+
hasRequiredApplication = 1;
|
|
3586
|
+
(function (exports) {
|
|
3587
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3588
|
+
if (k2 === undefined) k2 = k;
|
|
3589
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3590
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3591
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3592
|
+
}
|
|
3593
|
+
Object.defineProperty(o, k2, desc);
|
|
3594
|
+
}) : (function(o, m, k, k2) {
|
|
3595
|
+
if (k2 === undefined) k2 = k;
|
|
3596
|
+
o[k2] = m[k];
|
|
3597
|
+
}));
|
|
3598
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
3599
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3600
|
+
};
|
|
3601
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3602
|
+
/**
|
|
3603
|
+
* Entry points for the OpenFin `Application` API (`fin.Application`).
|
|
3604
|
+
*
|
|
3605
|
+
* * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
|
|
3606
|
+
* * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
|
|
3607
|
+
*
|
|
3608
|
+
* These are separate code entities, and are documented separately. In the [previous version of the API documentation](https://cdn.openfin.co/docs/javascript/32.114.76.10/index.html),
|
|
3609
|
+
* both of these were documented on the same page.
|
|
3610
|
+
*
|
|
3611
|
+
* @packageDocumentation
|
|
3612
|
+
*/
|
|
3613
|
+
__exportStar(requireFactory$2(), exports);
|
|
3614
|
+
__exportStar(requireInstance$1(), exports);
|
|
3615
|
+
} (application));
|
|
3616
|
+
return application;
|
|
3617
|
+
}
|
|
3597
3618
|
|
|
3598
3619
|
var promisifySubscription$1 = {};
|
|
3599
3620
|
|
|
@@ -3637,7 +3658,7 @@ function requireInstance () {
|
|
|
3637
3658
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3638
3659
|
/* eslint-disable no-console */
|
|
3639
3660
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3640
|
-
const application_1 =
|
|
3661
|
+
const application_1 = requireApplication();
|
|
3641
3662
|
const main_1 = main;
|
|
3642
3663
|
const view_1 = requireView();
|
|
3643
3664
|
const warnings_1 = warnings;
|
|
@@ -7404,12 +7425,12 @@ class ChannelError extends Error {
|
|
|
7404
7425
|
}
|
|
7405
7426
|
channelError.ChannelError = ChannelError;
|
|
7406
7427
|
|
|
7407
|
-
var __classPrivateFieldGet$
|
|
7428
|
+
var __classPrivateFieldGet$e = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7408
7429
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7409
7430
|
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");
|
|
7410
7431
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7411
7432
|
};
|
|
7412
|
-
var __classPrivateFieldSet$
|
|
7433
|
+
var __classPrivateFieldSet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7413
7434
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7414
7435
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7415
7436
|
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");
|
|
@@ -7453,7 +7474,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7453
7474
|
static closeChannelByEndpointId(id) {
|
|
7454
7475
|
const channel = channelClientsByEndpointId.get(id);
|
|
7455
7476
|
if (channel) {
|
|
7456
|
-
__classPrivateFieldGet$
|
|
7477
|
+
__classPrivateFieldGet$e(channel, _ChannelClient_close, "f").call(channel);
|
|
7457
7478
|
}
|
|
7458
7479
|
}
|
|
7459
7480
|
/**
|
|
@@ -7464,7 +7485,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7464
7485
|
for (const channelClient of channelClientsByEndpointId.values()) {
|
|
7465
7486
|
if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
|
|
7466
7487
|
channelClient.disconnectListener(eventPayload);
|
|
7467
|
-
__classPrivateFieldGet$
|
|
7488
|
+
__classPrivateFieldGet$e(channelClient, _ChannelClient_close, "f").call(channelClient);
|
|
7468
7489
|
}
|
|
7469
7490
|
}
|
|
7470
7491
|
}
|
|
@@ -7479,12 +7500,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7479
7500
|
this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
|
|
7480
7501
|
_ChannelClient_close.set(this, () => {
|
|
7481
7502
|
channelClientsByEndpointId.delete(this.endpointId);
|
|
7482
|
-
__classPrivateFieldGet$
|
|
7503
|
+
__classPrivateFieldGet$e(this, _ChannelClient_strategy, "f").close();
|
|
7483
7504
|
});
|
|
7484
|
-
__classPrivateFieldSet$
|
|
7505
|
+
__classPrivateFieldSet$d(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
|
|
7485
7506
|
this.disconnectListener = () => undefined;
|
|
7486
7507
|
this.endpointId = routingInfo.endpointId;
|
|
7487
|
-
__classPrivateFieldSet$
|
|
7508
|
+
__classPrivateFieldSet$d(this, _ChannelClient_strategy, strategy, "f");
|
|
7488
7509
|
channelClientsByEndpointId.set(this.endpointId, this);
|
|
7489
7510
|
strategy.receive(this.processAction);
|
|
7490
7511
|
}
|
|
@@ -7492,7 +7513,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7492
7513
|
* a read-only provider identity
|
|
7493
7514
|
*/
|
|
7494
7515
|
get providerIdentity() {
|
|
7495
|
-
const protectedObj = __classPrivateFieldGet$
|
|
7516
|
+
const protectedObj = __classPrivateFieldGet$e(this, _ChannelClient_protectedObj, "f");
|
|
7496
7517
|
return protectedObj.providerIdentity;
|
|
7497
7518
|
}
|
|
7498
7519
|
/**
|
|
@@ -7521,9 +7542,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7521
7542
|
* ```
|
|
7522
7543
|
*/
|
|
7523
7544
|
async dispatch(action, payload) {
|
|
7524
|
-
if (__classPrivateFieldGet$
|
|
7545
|
+
if (__classPrivateFieldGet$e(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
|
|
7525
7546
|
const callSites = transport_errors_1$3.RuntimeError.getCallSite();
|
|
7526
|
-
return __classPrivateFieldGet$
|
|
7547
|
+
return __classPrivateFieldGet$e(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
|
|
7527
7548
|
throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
|
|
7528
7549
|
});
|
|
7529
7550
|
}
|
|
@@ -7575,10 +7596,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
7575
7596
|
*/
|
|
7576
7597
|
async disconnect() {
|
|
7577
7598
|
await this.sendDisconnectAction();
|
|
7578
|
-
__classPrivateFieldGet$
|
|
7599
|
+
__classPrivateFieldGet$e(this, _ChannelClient_close, "f").call(this);
|
|
7579
7600
|
}
|
|
7580
7601
|
async sendDisconnectAction() {
|
|
7581
|
-
const protectedObj = __classPrivateFieldGet$
|
|
7602
|
+
const protectedObj = __classPrivateFieldGet$e(this, _ChannelClient_protectedObj, "f");
|
|
7582
7603
|
await protectedObj.close();
|
|
7583
7604
|
}
|
|
7584
7605
|
/**
|
|
@@ -7611,13 +7632,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
|
|
|
7611
7632
|
|
|
7612
7633
|
var strategy$3 = {};
|
|
7613
7634
|
|
|
7614
|
-
var __classPrivateFieldSet$
|
|
7635
|
+
var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7615
7636
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7616
7637
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7617
7638
|
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");
|
|
7618
7639
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7619
7640
|
};
|
|
7620
|
-
var __classPrivateFieldGet$
|
|
7641
|
+
var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7621
7642
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7622
7643
|
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");
|
|
7623
7644
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -7642,7 +7663,7 @@ class ClassicStrategy {
|
|
|
7642
7663
|
// connection problems occur
|
|
7643
7664
|
_ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
|
|
7644
7665
|
this.send = async (endpointId, action, payload) => {
|
|
7645
|
-
const to = __classPrivateFieldGet$
|
|
7666
|
+
const to = __classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
7646
7667
|
if (!to) {
|
|
7647
7668
|
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
7648
7669
|
}
|
|
@@ -7654,13 +7675,13 @@ class ClassicStrategy {
|
|
|
7654
7675
|
}
|
|
7655
7676
|
delete cleanId.isLocalEndpointId;
|
|
7656
7677
|
// grab the promise before awaiting it to save in our pending messages map
|
|
7657
|
-
const p = __classPrivateFieldGet$
|
|
7678
|
+
const p = __classPrivateFieldGet$d(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
|
|
7658
7679
|
...cleanId,
|
|
7659
7680
|
providerIdentity: this.providerIdentity,
|
|
7660
7681
|
action,
|
|
7661
7682
|
payload
|
|
7662
7683
|
});
|
|
7663
|
-
__classPrivateFieldGet$
|
|
7684
|
+
__classPrivateFieldGet$d(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
|
|
7664
7685
|
const raw = await p
|
|
7665
7686
|
.catch((error) => {
|
|
7666
7687
|
if ('cause' in error) {
|
|
@@ -7670,16 +7691,16 @@ class ClassicStrategy {
|
|
|
7670
7691
|
})
|
|
7671
7692
|
.finally(() => {
|
|
7672
7693
|
// clean up the pending promise
|
|
7673
|
-
__classPrivateFieldGet$
|
|
7694
|
+
__classPrivateFieldGet$d(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
|
|
7674
7695
|
});
|
|
7675
7696
|
return raw.payload.data.result;
|
|
7676
7697
|
};
|
|
7677
7698
|
this.close = async () => {
|
|
7678
7699
|
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
7679
|
-
[...__classPrivateFieldGet$
|
|
7680
|
-
__classPrivateFieldSet$
|
|
7700
|
+
[...__classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
|
|
7701
|
+
__classPrivateFieldSet$c(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
|
7681
7702
|
};
|
|
7682
|
-
__classPrivateFieldSet$
|
|
7703
|
+
__classPrivateFieldSet$c(this, _ClassicStrategy_wire, wire, "f");
|
|
7683
7704
|
}
|
|
7684
7705
|
onEndpointDisconnect(endpointId, listener) {
|
|
7685
7706
|
// Never fires for 'classic'.
|
|
@@ -7688,20 +7709,20 @@ class ClassicStrategy {
|
|
|
7688
7709
|
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
7689
7710
|
}
|
|
7690
7711
|
async closeEndpoint(endpointId) {
|
|
7691
|
-
const id = __classPrivateFieldGet$
|
|
7692
|
-
__classPrivateFieldGet$
|
|
7693
|
-
const pendingSet = __classPrivateFieldGet$
|
|
7712
|
+
const id = __classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
7713
|
+
__classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
|
7714
|
+
const pendingSet = __classPrivateFieldGet$d(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
|
|
7694
7715
|
pendingSet?.forEach((p) => {
|
|
7695
7716
|
const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
|
|
7696
7717
|
p.cancel(new Error(errorMsg));
|
|
7697
7718
|
});
|
|
7698
7719
|
}
|
|
7699
7720
|
isEndpointConnected(endpointId) {
|
|
7700
|
-
return __classPrivateFieldGet$
|
|
7721
|
+
return __classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
|
7701
7722
|
}
|
|
7702
7723
|
addEndpoint(endpointId, payload) {
|
|
7703
|
-
__classPrivateFieldGet$
|
|
7704
|
-
__classPrivateFieldGet$
|
|
7724
|
+
__classPrivateFieldGet$d(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
|
7725
|
+
__classPrivateFieldGet$d(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
|
|
7705
7726
|
}
|
|
7706
7727
|
isValidEndpointPayload(payload) {
|
|
7707
7728
|
return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
|
|
@@ -7736,12 +7757,12 @@ function errorToPOJO(error) {
|
|
|
7736
7757
|
}
|
|
7737
7758
|
errors.errorToPOJO = errorToPOJO;
|
|
7738
7759
|
|
|
7739
|
-
var __classPrivateFieldGet$
|
|
7760
|
+
var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7740
7761
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7741
7762
|
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");
|
|
7742
7763
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7743
7764
|
};
|
|
7744
|
-
var __classPrivateFieldSet$
|
|
7765
|
+
var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7745
7766
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7746
7767
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7747
7768
|
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");
|
|
@@ -7776,8 +7797,8 @@ class RTCEndpoint {
|
|
|
7776
7797
|
if (this.rtc.rtcClient.connectionState !== 'connected') {
|
|
7777
7798
|
this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
|
7778
7799
|
this.close();
|
|
7779
|
-
if (__classPrivateFieldGet$
|
|
7780
|
-
__classPrivateFieldGet$
|
|
7800
|
+
if (__classPrivateFieldGet$c(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
7801
|
+
__classPrivateFieldGet$c(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
7781
7802
|
}
|
|
7782
7803
|
}
|
|
7783
7804
|
};
|
|
@@ -7825,9 +7846,9 @@ class RTCEndpoint {
|
|
|
7825
7846
|
data = new TextDecoder().decode(e.data);
|
|
7826
7847
|
}
|
|
7827
7848
|
const { messageId, action, payload } = JSON.parse(data);
|
|
7828
|
-
if (__classPrivateFieldGet$
|
|
7849
|
+
if (__classPrivateFieldGet$c(this, _RTCEndpoint_processAction, "f")) {
|
|
7829
7850
|
try {
|
|
7830
|
-
const res = await __classPrivateFieldGet$
|
|
7851
|
+
const res = await __classPrivateFieldGet$c(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
|
|
7831
7852
|
this.rtc.channels.response.send(JSON.stringify({
|
|
7832
7853
|
messageId,
|
|
7833
7854
|
payload: res,
|
|
@@ -7861,25 +7882,25 @@ class RTCEndpoint {
|
|
|
7861
7882
|
datachannel.onclose = (e) => {
|
|
7862
7883
|
[...this.responseMap.values()].forEach((promise) => promise.reject(new Error('RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.')));
|
|
7863
7884
|
this.close();
|
|
7864
|
-
if (__classPrivateFieldGet$
|
|
7865
|
-
__classPrivateFieldGet$
|
|
7885
|
+
if (__classPrivateFieldGet$c(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
7886
|
+
__classPrivateFieldGet$c(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
7866
7887
|
}
|
|
7867
7888
|
};
|
|
7868
7889
|
});
|
|
7869
7890
|
}
|
|
7870
7891
|
onDisconnect(listener) {
|
|
7871
|
-
if (!__classPrivateFieldGet$
|
|
7872
|
-
__classPrivateFieldSet$
|
|
7892
|
+
if (!__classPrivateFieldGet$c(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
7893
|
+
__classPrivateFieldSet$b(this, _RTCEndpoint_disconnectListener, listener, "f");
|
|
7873
7894
|
}
|
|
7874
7895
|
else {
|
|
7875
7896
|
throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
|
|
7876
7897
|
}
|
|
7877
7898
|
}
|
|
7878
7899
|
receive(listener) {
|
|
7879
|
-
if (__classPrivateFieldGet$
|
|
7900
|
+
if (__classPrivateFieldGet$c(this, _RTCEndpoint_processAction, "f")) {
|
|
7880
7901
|
throw new Error('You have already set a listener for this RTC Endpoint.');
|
|
7881
7902
|
}
|
|
7882
|
-
__classPrivateFieldSet$
|
|
7903
|
+
__classPrivateFieldSet$b(this, _RTCEndpoint_processAction, listener, "f");
|
|
7883
7904
|
}
|
|
7884
7905
|
get connected() {
|
|
7885
7906
|
return this.rtc.rtcClient.connectionState === 'connected';
|
|
@@ -7890,12 +7911,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
|
|
|
7890
7911
|
|
|
7891
7912
|
var strategy$1 = {};
|
|
7892
7913
|
|
|
7893
|
-
var __classPrivateFieldGet$
|
|
7914
|
+
var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7894
7915
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7895
7916
|
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");
|
|
7896
7917
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7897
7918
|
};
|
|
7898
|
-
var __classPrivateFieldSet$
|
|
7919
|
+
var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7899
7920
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7900
7921
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7901
7922
|
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");
|
|
@@ -7916,11 +7937,11 @@ class EndpointStrategy {
|
|
|
7916
7937
|
return this.getEndpointById(endpointId).send(action, payload);
|
|
7917
7938
|
};
|
|
7918
7939
|
this.close = async () => {
|
|
7919
|
-
if (__classPrivateFieldGet$
|
|
7920
|
-
__classPrivateFieldGet$
|
|
7921
|
-
__classPrivateFieldSet$
|
|
7940
|
+
if (__classPrivateFieldGet$b(this, _EndpointStrategy_connected, "f")) {
|
|
7941
|
+
__classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
|
|
7942
|
+
__classPrivateFieldSet$a(this, _EndpointStrategy_endpointMap, new Map(), "f");
|
|
7922
7943
|
}
|
|
7923
|
-
__classPrivateFieldSet$
|
|
7944
|
+
__classPrivateFieldSet$a(this, _EndpointStrategy_connected, false, "f");
|
|
7924
7945
|
};
|
|
7925
7946
|
this.isValidEndpointPayload = validateEndpoint;
|
|
7926
7947
|
}
|
|
@@ -7928,39 +7949,39 @@ class EndpointStrategy {
|
|
|
7928
7949
|
this.getEndpointById(endpointId).onDisconnect(listener);
|
|
7929
7950
|
}
|
|
7930
7951
|
receive(listener) {
|
|
7931
|
-
if (__classPrivateFieldGet$
|
|
7952
|
+
if (__classPrivateFieldGet$b(this, _EndpointStrategy_processAction, "f")) {
|
|
7932
7953
|
throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
|
|
7933
7954
|
}
|
|
7934
|
-
__classPrivateFieldSet$
|
|
7955
|
+
__classPrivateFieldSet$a(this, _EndpointStrategy_processAction, listener, "f");
|
|
7935
7956
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7936
|
-
__classPrivateFieldGet$
|
|
7957
|
+
__classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$b(this, _EndpointStrategy_processAction, "f")));
|
|
7937
7958
|
}
|
|
7938
7959
|
getEndpointById(endpointId) {
|
|
7939
|
-
const endpoint = __classPrivateFieldGet$
|
|
7960
|
+
const endpoint = __classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
|
|
7940
7961
|
if (!endpoint) {
|
|
7941
7962
|
throw new Error(`Client with endpoint id ${endpointId} is not connected`);
|
|
7942
7963
|
}
|
|
7943
7964
|
return endpoint;
|
|
7944
7965
|
}
|
|
7945
7966
|
get connected() {
|
|
7946
|
-
return __classPrivateFieldGet$
|
|
7967
|
+
return __classPrivateFieldGet$b(this, _EndpointStrategy_connected, "f");
|
|
7947
7968
|
}
|
|
7948
7969
|
isEndpointConnected(endpointId) {
|
|
7949
|
-
return __classPrivateFieldGet$
|
|
7970
|
+
return __classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
|
|
7950
7971
|
}
|
|
7951
7972
|
addEndpoint(endpointId, payload) {
|
|
7952
|
-
if (!__classPrivateFieldGet$
|
|
7973
|
+
if (!__classPrivateFieldGet$b(this, _EndpointStrategy_connected, "f")) {
|
|
7953
7974
|
console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
|
|
7954
7975
|
return;
|
|
7955
7976
|
}
|
|
7956
7977
|
const clientStrat = new this.EndpointType(payload);
|
|
7957
|
-
if (__classPrivateFieldGet$
|
|
7958
|
-
clientStrat.receive(__classPrivateFieldGet$
|
|
7978
|
+
if (__classPrivateFieldGet$b(this, _EndpointStrategy_processAction, "f")) {
|
|
7979
|
+
clientStrat.receive(__classPrivateFieldGet$b(this, _EndpointStrategy_processAction, "f"));
|
|
7959
7980
|
}
|
|
7960
|
-
__classPrivateFieldGet$
|
|
7981
|
+
__classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
|
|
7961
7982
|
}
|
|
7962
7983
|
async closeEndpoint(endpointId) {
|
|
7963
|
-
__classPrivateFieldGet$
|
|
7984
|
+
__classPrivateFieldGet$b(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
|
|
7964
7985
|
}
|
|
7965
7986
|
}
|
|
7966
7987
|
strategy$1.EndpointStrategy = EndpointStrategy;
|
|
@@ -8142,12 +8163,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
|
|
|
8142
8163
|
}
|
|
8143
8164
|
runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
|
|
8144
8165
|
|
|
8145
|
-
var __classPrivateFieldGet$
|
|
8166
|
+
var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8146
8167
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8147
8168
|
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");
|
|
8148
8169
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
8149
8170
|
};
|
|
8150
|
-
var __classPrivateFieldSet$
|
|
8171
|
+
var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8151
8172
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8152
8173
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8153
8174
|
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");
|
|
@@ -8191,19 +8212,19 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8191
8212
|
* a read-only array containing all the identities of connecting clients.
|
|
8192
8213
|
*/
|
|
8193
8214
|
get connections() {
|
|
8194
|
-
return [...__classPrivateFieldGet$
|
|
8215
|
+
return [...__classPrivateFieldGet$a(this, _ChannelProvider_connections, "f")];
|
|
8195
8216
|
}
|
|
8196
8217
|
static handleClientDisconnection(channel, payload) {
|
|
8197
8218
|
if (payload?.endpointId) {
|
|
8198
8219
|
const { uuid, name, endpointId, isLocalEndpointId } = payload;
|
|
8199
|
-
__classPrivateFieldGet$
|
|
8220
|
+
__classPrivateFieldGet$a(channel, _ChannelProvider_removeEndpoint, "f").call(channel, { uuid, name, endpointId, isLocalEndpointId });
|
|
8200
8221
|
}
|
|
8201
8222
|
else {
|
|
8202
8223
|
// this is here to support older runtimes that did not have endpointId
|
|
8203
8224
|
const multipleRemoves = channel.connections.filter((identity) => {
|
|
8204
8225
|
return identity.uuid === payload.uuid && identity.name === payload.name;
|
|
8205
8226
|
});
|
|
8206
|
-
multipleRemoves.forEach(__classPrivateFieldGet$
|
|
8227
|
+
multipleRemoves.forEach(__classPrivateFieldGet$a(channel, _ChannelProvider_removeEndpoint, "f"));
|
|
8207
8228
|
}
|
|
8208
8229
|
channel.disconnectListener(payload);
|
|
8209
8230
|
}
|
|
@@ -8220,8 +8241,8 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8220
8241
|
_ChannelProvider_strategy.set(this, void 0);
|
|
8221
8242
|
_ChannelProvider_removeEndpoint.set(this, (identity) => {
|
|
8222
8243
|
const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
|
|
8223
|
-
__classPrivateFieldGet$
|
|
8224
|
-
__classPrivateFieldSet$
|
|
8244
|
+
__classPrivateFieldGet$a(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
|
|
8245
|
+
__classPrivateFieldSet$9(this, _ChannelProvider_connections, remainingConnections, "f");
|
|
8225
8246
|
});
|
|
8226
8247
|
// Must be bound.
|
|
8227
8248
|
this.processAction = async (action, payload, senderIdentity) => {
|
|
@@ -8235,17 +8256,17 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8235
8256
|
return super.processAction(action, payload, senderIdentity);
|
|
8236
8257
|
};
|
|
8237
8258
|
_ChannelProvider_close.set(this, () => {
|
|
8238
|
-
__classPrivateFieldGet$
|
|
8259
|
+
__classPrivateFieldGet$a(this, _ChannelProvider_strategy, "f").close();
|
|
8239
8260
|
const remove = ChannelProvider.removalMap.get(this);
|
|
8240
8261
|
if (remove) {
|
|
8241
8262
|
remove();
|
|
8242
8263
|
}
|
|
8243
8264
|
});
|
|
8244
|
-
__classPrivateFieldSet$
|
|
8265
|
+
__classPrivateFieldSet$9(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
|
|
8245
8266
|
this.connectListener = () => undefined;
|
|
8246
8267
|
this.disconnectListener = () => undefined;
|
|
8247
|
-
__classPrivateFieldSet$
|
|
8248
|
-
__classPrivateFieldSet$
|
|
8268
|
+
__classPrivateFieldSet$9(this, _ChannelProvider_connections, [], "f");
|
|
8269
|
+
__classPrivateFieldSet$9(this, _ChannelProvider_strategy, strategy, "f");
|
|
8249
8270
|
strategy.receive(this.processAction);
|
|
8250
8271
|
}
|
|
8251
8272
|
/**
|
|
@@ -8276,16 +8297,16 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8276
8297
|
*/
|
|
8277
8298
|
dispatch(to, action, payload) {
|
|
8278
8299
|
const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
|
|
8279
|
-
if (endpointId && __classPrivateFieldGet$
|
|
8300
|
+
if (endpointId && __classPrivateFieldGet$a(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
|
|
8280
8301
|
const callSites = transport_errors_1$2.RuntimeError.getCallSite();
|
|
8281
|
-
return __classPrivateFieldGet$
|
|
8302
|
+
return __classPrivateFieldGet$a(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
|
|
8282
8303
|
throw new channel_error_1.ChannelError(e, action, payload, callSites);
|
|
8283
8304
|
});
|
|
8284
8305
|
}
|
|
8285
8306
|
return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
|
|
8286
8307
|
}
|
|
8287
8308
|
async processConnection(senderId, payload) {
|
|
8288
|
-
__classPrivateFieldGet$
|
|
8309
|
+
__classPrivateFieldGet$a(this, _ChannelProvider_connections, "f").push(senderId);
|
|
8289
8310
|
return this.connectListener(senderId, payload);
|
|
8290
8311
|
}
|
|
8291
8312
|
/**
|
|
@@ -8308,7 +8329,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8308
8329
|
* ```
|
|
8309
8330
|
*/
|
|
8310
8331
|
publish(action, payload) {
|
|
8311
|
-
return this.connections.map((to) => __classPrivateFieldGet$
|
|
8332
|
+
return this.connections.map((to) => __classPrivateFieldGet$a(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
|
|
8312
8333
|
}
|
|
8313
8334
|
/**
|
|
8314
8335
|
* Register a listener that is called on every new client connection.
|
|
@@ -8382,11 +8403,11 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8382
8403
|
* ```
|
|
8383
8404
|
*/
|
|
8384
8405
|
async destroy() {
|
|
8385
|
-
const protectedObj = __classPrivateFieldGet$
|
|
8406
|
+
const protectedObj = __classPrivateFieldGet$a(this, _ChannelProvider_protectedObj, "f");
|
|
8386
8407
|
protectedObj.providerIdentity;
|
|
8387
|
-
__classPrivateFieldSet$
|
|
8408
|
+
__classPrivateFieldSet$9(this, _ChannelProvider_connections, [], "f");
|
|
8388
8409
|
await protectedObj.close();
|
|
8389
|
-
__classPrivateFieldGet$
|
|
8410
|
+
__classPrivateFieldGet$a(this, _ChannelProvider_close, "f").call(this);
|
|
8390
8411
|
}
|
|
8391
8412
|
/**
|
|
8392
8413
|
* Returns an array with info on every Client connected to the Provider
|
|
@@ -8456,7 +8477,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
8456
8477
|
getEndpointIdForOpenFinId(clientIdentity, action) {
|
|
8457
8478
|
const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
|
|
8458
8479
|
if (matchingConnections.length >= 2) {
|
|
8459
|
-
const protectedObj = __classPrivateFieldGet$
|
|
8480
|
+
const protectedObj = __classPrivateFieldGet$a(this, _ChannelProvider_protectedObj, "f");
|
|
8460
8481
|
const { uuid, name } = clientIdentity;
|
|
8461
8482
|
const providerUuid = protectedObj?.providerIdentity.uuid;
|
|
8462
8483
|
const providerName = protectedObj?.providerIdentity.name;
|
|
@@ -8668,13 +8689,13 @@ class CombinedStrategy {
|
|
|
8668
8689
|
}
|
|
8669
8690
|
strategy.default = CombinedStrategy;
|
|
8670
8691
|
|
|
8671
|
-
var __classPrivateFieldSet$
|
|
8692
|
+
var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8672
8693
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8673
8694
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8674
8695
|
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");
|
|
8675
8696
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
8676
8697
|
};
|
|
8677
|
-
var __classPrivateFieldGet$
|
|
8698
|
+
var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8678
8699
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8679
8700
|
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");
|
|
8680
8701
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -8723,8 +8744,8 @@ class ConnectionManager extends base_1$f.Base {
|
|
|
8723
8744
|
};
|
|
8724
8745
|
this.providerMap = new Map();
|
|
8725
8746
|
this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
|
|
8726
|
-
__classPrivateFieldSet$
|
|
8727
|
-
__classPrivateFieldSet$
|
|
8747
|
+
__classPrivateFieldSet$8(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
|
|
8748
|
+
__classPrivateFieldSet$8(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
|
|
8728
8749
|
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
8729
8750
|
}
|
|
8730
8751
|
createProvider(options, providerIdentity) {
|
|
@@ -8735,7 +8756,7 @@ class ConnectionManager extends base_1$f.Base {
|
|
|
8735
8756
|
case 'rtc':
|
|
8736
8757
|
return new strategy_2.RTCStrategy();
|
|
8737
8758
|
case 'classic':
|
|
8738
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
|
8759
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$9(this, _ConnectionManager_messageReceiver, "f"),
|
|
8739
8760
|
// Providers do not have an endpointId, use channelId as endpointId in the strategy.
|
|
8740
8761
|
providerIdentity.channelId, providerIdentity);
|
|
8741
8762
|
default:
|
|
@@ -8771,7 +8792,7 @@ class ConnectionManager extends base_1$f.Base {
|
|
|
8771
8792
|
const supportedProtocols = await Promise.all(protocols.map(async (type) => {
|
|
8772
8793
|
switch (type) {
|
|
8773
8794
|
case 'rtc': {
|
|
8774
|
-
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$
|
|
8795
|
+
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$9(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
|
|
8775
8796
|
rtcPacket = { rtcClient, channels, channelsOpened };
|
|
8776
8797
|
return {
|
|
8777
8798
|
type: 'rtc',
|
|
@@ -8798,18 +8819,18 @@ class ConnectionManager extends base_1$f.Base {
|
|
|
8798
8819
|
routingInfo.endpointId = this.wire.environment.getNextMessageId();
|
|
8799
8820
|
// For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
|
|
8800
8821
|
// clients that are in the same context as the newly-connected client.
|
|
8801
|
-
__classPrivateFieldGet$
|
|
8822
|
+
__classPrivateFieldGet$9(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
|
|
8802
8823
|
}
|
|
8803
8824
|
const answer = routingInfo.answer ?? {
|
|
8804
8825
|
supportedProtocols: [{ type: 'classic', version: 1 }]
|
|
8805
8826
|
};
|
|
8806
8827
|
const createStrategyFromAnswer = async (protocol) => {
|
|
8807
8828
|
if (protocol.type === 'rtc' && rtcPacket) {
|
|
8808
|
-
await __classPrivateFieldGet$
|
|
8829
|
+
await __classPrivateFieldGet$9(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
|
|
8809
8830
|
return new strategy_2.RTCStrategy();
|
|
8810
8831
|
}
|
|
8811
8832
|
if (protocol.type === 'classic') {
|
|
8812
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
|
8833
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$9(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
|
|
8813
8834
|
}
|
|
8814
8835
|
return null;
|
|
8815
8836
|
};
|
|
@@ -8877,7 +8898,7 @@ class ConnectionManager extends base_1$f.Base {
|
|
|
8877
8898
|
clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
|
|
8878
8899
|
const answer = await accumP;
|
|
8879
8900
|
if (protocolToUse.type === 'rtc') {
|
|
8880
|
-
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$
|
|
8901
|
+
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$9(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
|
|
8881
8902
|
answer.supportedProtocols.push({
|
|
8882
8903
|
type: 'rtc',
|
|
8883
8904
|
version: strategy_2.RTCInfo.version,
|
|
@@ -8925,13 +8946,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
|
|
|
8925
8946
|
*
|
|
8926
8947
|
* @packageDocumentation
|
|
8927
8948
|
*/
|
|
8928
|
-
var __classPrivateFieldSet$
|
|
8949
|
+
var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8929
8950
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8930
8951
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8931
8952
|
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");
|
|
8932
8953
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
8933
8954
|
};
|
|
8934
|
-
var __classPrivateFieldGet$
|
|
8955
|
+
var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8935
8956
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8936
8957
|
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");
|
|
8937
8958
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -8988,11 +9009,11 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
8988
9009
|
client_1.ChannelClient.handleProviderDisconnect(eventPayload);
|
|
8989
9010
|
}),
|
|
8990
9011
|
this.on('connected', (...args) => {
|
|
8991
|
-
__classPrivateFieldGet$
|
|
9012
|
+
__classPrivateFieldGet$8(this, _Channel_internalEmitter, "f").emit('connected', ...args);
|
|
8992
9013
|
})
|
|
8993
9014
|
]).catch(() => new Error('error setting up channel connection listeners'));
|
|
8994
9015
|
}));
|
|
8995
|
-
__classPrivateFieldSet$
|
|
9016
|
+
__classPrivateFieldSet$7(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
|
8996
9017
|
}
|
|
8997
9018
|
/**
|
|
8998
9019
|
*
|
|
@@ -9067,7 +9088,7 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
9067
9088
|
resolve(true);
|
|
9068
9089
|
}
|
|
9069
9090
|
};
|
|
9070
|
-
__classPrivateFieldGet$
|
|
9091
|
+
__classPrivateFieldGet$8(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
|
|
9071
9092
|
});
|
|
9072
9093
|
try {
|
|
9073
9094
|
if (retryInfo.count > 0) {
|
|
@@ -9099,7 +9120,7 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
9099
9120
|
finally {
|
|
9100
9121
|
retryInfo.count += 1;
|
|
9101
9122
|
// in case of other errors, remove our listener
|
|
9102
|
-
__classPrivateFieldGet$
|
|
9123
|
+
__classPrivateFieldGet$8(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
|
|
9103
9124
|
}
|
|
9104
9125
|
} while (shouldWait); // If we're waiting we retry the above loop
|
|
9105
9126
|
// Should wait was false, no channel was found.
|
|
@@ -9158,12 +9179,12 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
9158
9179
|
async connect(channelName, options = {}) {
|
|
9159
9180
|
// Make sure we don't connect before listeners are set up
|
|
9160
9181
|
// This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
|
|
9161
|
-
await __classPrivateFieldGet$
|
|
9182
|
+
await __classPrivateFieldGet$8(this, _Channel_readyToConnect, "f").getValue();
|
|
9162
9183
|
if (!channelName || typeof channelName !== 'string') {
|
|
9163
9184
|
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
9164
9185
|
}
|
|
9165
9186
|
const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
|
|
9166
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$
|
|
9187
|
+
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$8(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
|
9167
9188
|
let connectionUrl;
|
|
9168
9189
|
if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
|
|
9169
9190
|
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
@@ -9175,7 +9196,7 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
9175
9196
|
connectionUrl
|
|
9176
9197
|
};
|
|
9177
9198
|
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
|
9178
|
-
const strategy = await __classPrivateFieldGet$
|
|
9199
|
+
const strategy = await __classPrivateFieldGet$8(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
9179
9200
|
const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
|
|
9180
9201
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
9181
9202
|
// If the endpoint dies, the client will force a disconnection through the core.
|
|
@@ -9244,7 +9265,7 @@ class Channel extends base_1$e.EmitterBase {
|
|
|
9244
9265
|
throw new Error('Please provide a channelName to create a channel');
|
|
9245
9266
|
}
|
|
9246
9267
|
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
9247
|
-
const channel = __classPrivateFieldGet$
|
|
9268
|
+
const channel = __classPrivateFieldGet$8(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
|
|
9248
9269
|
// TODO: fix typing (internal)
|
|
9249
9270
|
// @ts-expect-error
|
|
9250
9271
|
this.on('client-disconnected', (eventPayload) => {
|
|
@@ -9480,14 +9501,32 @@ var clipboard = {};
|
|
|
9480
9501
|
*
|
|
9481
9502
|
* @packageDocumentation
|
|
9482
9503
|
*/
|
|
9504
|
+
var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9505
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9506
|
+
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");
|
|
9507
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9508
|
+
};
|
|
9509
|
+
var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9510
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9511
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9512
|
+
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");
|
|
9513
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
9514
|
+
};
|
|
9515
|
+
var _Clipboard_instances, _Clipboard_securedApiWarningCount, _Clipboard_warnSecuredApi;
|
|
9483
9516
|
Object.defineProperty(clipboard, "__esModule", { value: true });
|
|
9484
9517
|
clipboard.Clipboard = void 0;
|
|
9485
9518
|
const base_1$c = base;
|
|
9519
|
+
const maxSecuredApiWarnings = 10;
|
|
9486
9520
|
/**
|
|
9487
9521
|
* The Clipboard API allows reading and writing to the clipboard in multiple formats.
|
|
9488
9522
|
*
|
|
9489
9523
|
*/
|
|
9490
9524
|
class Clipboard extends base_1$c.Base {
|
|
9525
|
+
constructor() {
|
|
9526
|
+
super(...arguments);
|
|
9527
|
+
_Clipboard_instances.add(this);
|
|
9528
|
+
_Clipboard_securedApiWarningCount.set(this, 0);
|
|
9529
|
+
}
|
|
9491
9530
|
/**
|
|
9492
9531
|
* Writes data into the clipboard as plain text
|
|
9493
9532
|
* @param writeObj The object for writing data into the clipboard
|
|
@@ -9500,6 +9539,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9500
9539
|
* ```
|
|
9501
9540
|
*/
|
|
9502
9541
|
async writeText(writeObj) {
|
|
9542
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.writeText');
|
|
9503
9543
|
await this.wire.sendAction('clipboard-write-text', writeObj);
|
|
9504
9544
|
}
|
|
9505
9545
|
/**
|
|
@@ -9512,6 +9552,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9512
9552
|
* ```
|
|
9513
9553
|
*/
|
|
9514
9554
|
async readText(type) {
|
|
9555
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.readText');
|
|
9515
9556
|
// NOTE: When we start supporting linux, we could detect the OS and choose 'selection' automatically for the user
|
|
9516
9557
|
const { payload } = await this.wire.sendAction('clipboard-read-text', { type });
|
|
9517
9558
|
return payload.data;
|
|
@@ -9529,6 +9570,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9529
9570
|
* ```
|
|
9530
9571
|
*/
|
|
9531
9572
|
async writeImage(writeRequest) {
|
|
9573
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.writeImage');
|
|
9532
9574
|
await this.wire.sendAction('clipboard-write-image', writeRequest);
|
|
9533
9575
|
}
|
|
9534
9576
|
/**
|
|
@@ -9564,6 +9606,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9564
9606
|
* ```
|
|
9565
9607
|
*/
|
|
9566
9608
|
async readImage(readRequest = { format: 'dataURL' }) {
|
|
9609
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.readImage');
|
|
9567
9610
|
const { payload } = await this.wire.sendAction('clipboard-read-image', readRequest);
|
|
9568
9611
|
return payload.data;
|
|
9569
9612
|
}
|
|
@@ -9579,6 +9622,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9579
9622
|
* ```
|
|
9580
9623
|
*/
|
|
9581
9624
|
async writeHtml(writeObj) {
|
|
9625
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.writeHtml');
|
|
9582
9626
|
await this.wire.sendAction('clipboard-write-html', writeObj);
|
|
9583
9627
|
}
|
|
9584
9628
|
/**
|
|
@@ -9591,6 +9635,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9591
9635
|
* ```
|
|
9592
9636
|
*/
|
|
9593
9637
|
async readHtml(type) {
|
|
9638
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.readHtml');
|
|
9594
9639
|
const { payload } = await this.wire.sendAction('clipboard-read-html', { type });
|
|
9595
9640
|
return payload.data;
|
|
9596
9641
|
}
|
|
@@ -9606,6 +9651,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9606
9651
|
* ```
|
|
9607
9652
|
*/
|
|
9608
9653
|
async writeRtf(writeObj) {
|
|
9654
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.writeRtf');
|
|
9609
9655
|
await this.wire.sendAction('clipboard-write-rtf', writeObj);
|
|
9610
9656
|
}
|
|
9611
9657
|
/**
|
|
@@ -9626,6 +9672,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9626
9672
|
* ```
|
|
9627
9673
|
*/
|
|
9628
9674
|
async readRtf(type) {
|
|
9675
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.readRtf');
|
|
9629
9676
|
const { payload } = await this.wire.sendAction('clipboard-read-rtf', { type });
|
|
9630
9677
|
return payload.data;
|
|
9631
9678
|
}
|
|
@@ -9649,6 +9696,7 @@ class Clipboard extends base_1$c.Base {
|
|
|
9649
9696
|
* ```
|
|
9650
9697
|
*/
|
|
9651
9698
|
async write(writeObj) {
|
|
9699
|
+
__classPrivateFieldGet$7(this, _Clipboard_instances, "m", _Clipboard_warnSecuredApi).call(this, 'Clipboard.write');
|
|
9652
9700
|
await this.wire.sendAction('clipboard-write', writeObj);
|
|
9653
9701
|
}
|
|
9654
9702
|
/**
|
|
@@ -9666,6 +9714,12 @@ class Clipboard extends base_1$c.Base {
|
|
|
9666
9714
|
}
|
|
9667
9715
|
}
|
|
9668
9716
|
clipboard.Clipboard = Clipboard;
|
|
9717
|
+
_Clipboard_securedApiWarningCount = new WeakMap(), _Clipboard_instances = new WeakSet(), _Clipboard_warnSecuredApi = async function _Clipboard_warnSecuredApi(apiName) {
|
|
9718
|
+
if (__classPrivateFieldGet$7(this, _Clipboard_securedApiWarningCount, "f") <= maxSecuredApiWarnings) {
|
|
9719
|
+
console.warn(`Clipboard APIs will be secure-by-default starting in v42. To continue using this API without interruption, make sure to grant explicit API permissions for ${apiName} in the Desktop Owner Settings, and in the Application, Window, View, or Domain Settings. For more information, see https://resources.here.io/docs/core/develop/security/api-security/`);
|
|
9720
|
+
__classPrivateFieldSet$6(this, _Clipboard_securedApiWarningCount, __classPrivateFieldGet$7(this, _Clipboard_securedApiWarningCount, "f") + 1, "f");
|
|
9721
|
+
}
|
|
9722
|
+
};
|
|
9669
9723
|
|
|
9670
9724
|
var externalApplication = {};
|
|
9671
9725
|
|
|
@@ -16985,7 +17039,7 @@ const events_1$3 = require$$0;
|
|
|
16985
17039
|
// Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
|
|
16986
17040
|
const index_1 = system;
|
|
16987
17041
|
const index_2 = requireWindow();
|
|
16988
|
-
const index_3 =
|
|
17042
|
+
const index_3 = requireApplication();
|
|
16989
17043
|
const index_4 = interappbus;
|
|
16990
17044
|
const index_5 = clipboard;
|
|
16991
17045
|
const index_6 = externalApplication;
|
|
@@ -17786,7 +17840,7 @@ class NodeEnvironment extends BaseEnvironment_1 {
|
|
|
17786
17840
|
};
|
|
17787
17841
|
}
|
|
17788
17842
|
getAdapterVersionSync() {
|
|
17789
|
-
return "40.104.
|
|
17843
|
+
return "40.104.3";
|
|
17790
17844
|
}
|
|
17791
17845
|
observeBounds(element, onChange) {
|
|
17792
17846
|
throw new Error('Method not implemented.');
|