@openfin/core 41.103.3 → 41.103.10

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/stub.js CHANGED
@@ -332,35 +332,6 @@ var system = {};
332
332
 
333
333
  var base = {};
334
334
 
335
- var promises = {};
336
-
337
- Object.defineProperty(promises, "__esModule", { value: true });
338
- promises.promiseMapSerial = promises.serial = promises.promiseMap = promises.promisify = void 0;
339
- function promisify(func) {
340
- return (...args) => new Promise((resolve, reject) => {
341
- func(...args, (err, val) => (err ? reject(err) : resolve(val)));
342
- });
343
- }
344
- promises.promisify = promisify;
345
- async function promiseMap(arr, asyncF) {
346
- return Promise.all(arr.map(asyncF));
347
- }
348
- promises.promiseMap = promiseMap;
349
- async function serial(arr) {
350
- const ret = [];
351
- for (const func of arr) {
352
- // eslint-disable-next-line no-await-in-loop
353
- const next = await func();
354
- ret.push(next);
355
- }
356
- return ret;
357
- }
358
- promises.serial = serial;
359
- async function promiseMapSerial(arr, func) {
360
- return serial(arr.map((value, index, array) => () => func(value, index, array)));
361
- }
362
- promises.promiseMapSerial = promiseMapSerial;
363
-
364
335
  var __classPrivateFieldSet$h = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
365
336
  if (kind === "m") throw new TypeError("Private method is not writable");
366
337
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -375,7 +346,6 @@ var __classPrivateFieldGet$i = (commonjsGlobal && commonjsGlobal.__classPrivateF
375
346
  var _EmitterBase_emitterAccessor, _EmitterBase_deregisterOnceListeners;
376
347
  Object.defineProperty(base, "__esModule", { value: true });
377
348
  base.Reply = base.EmitterBase = base.Base = void 0;
378
- const promises_1 = promises;
379
349
  class Base {
380
350
  /**
381
351
  * @internal
@@ -453,27 +423,8 @@ class EmitterBase extends Base {
453
423
  return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
454
424
  };
455
425
  this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
456
- /**
457
- * Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
458
- * `once` subscription.
459
- *
460
- * @remarks Implementing this as a `removeListener` handler ensures that direct removal of a listener
461
- * on the base emitter will not leak additional core handlers. We could do this in the forwarding method,
462
- * which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
463
- */
464
- this.cleanUpRemovedListener = (eventType, listener) => {
465
- const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
466
- if (deregister) {
467
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
468
- emitter.removeListener(eventType, deregister);
469
- }
470
- };
471
426
  this.getOrCreateEmitter = () => {
472
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
473
- if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
474
- emitter.on('removeListener', this.cleanUpRemovedListener);
475
- }
476
- return emitter;
427
+ return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
477
428
  };
478
429
  this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
479
430
  this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
@@ -513,7 +464,6 @@ class EmitterBase extends Base {
513
464
  };
514
465
  __classPrivateFieldSet$h(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
515
466
  __classPrivateFieldSet$h(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
516
- this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
517
467
  }
518
468
  /**
519
469
  * Adds a listener to the end of the listeners array for the specified event.
@@ -591,6 +541,10 @@ class EmitterBase extends Base {
591
541
  const emitter = await this.deregisterEventListener(eventType, options);
592
542
  if (emitter) {
593
543
  emitter.removeListener(eventType, listener);
544
+ const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
545
+ if (deregister) {
546
+ emitter.removeListener(eventType, deregister);
547
+ }
594
548
  this.deleteEmitterIfNothingRegistered(emitter);
595
549
  }
596
550
  return this;
@@ -626,12 +580,13 @@ class EmitterBase extends Base {
626
580
  }
627
581
  else if (this.hasEmitter()) {
628
582
  const events = this.getOrCreateEmitter().eventNames();
629
- await (0, promises_1.promiseMap)(events, removeByEvent);
583
+ await Promise.all(events.map(removeByEvent));
630
584
  }
631
585
  return this;
632
586
  }
633
587
  deleteEmitterIfNothingRegistered(emitter) {
634
- if (emitter.eventNames().every((type) => type === 'removeListener')) {
588
+ // TODO: maybe emitterMap should clean up itself..
589
+ if (emitter.eventNames().length === 0) {
635
590
  this.wire.eventAggregator.delete(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
636
591
  }
637
592
  }
@@ -940,9 +895,7 @@ function requireFactory$2 () {
940
895
  * @experimental
941
896
  */
942
897
  async wrap(identity) {
943
- this.wire.sendAction('view-wrap').catch((e) => {
944
- // we do not want to expose this error, just continue if this analytics-only call fails
945
- });
898
+ this.wire.recordAnalytic('view-wrap');
946
899
  const errorMsg = (0, validate_1.validateIdentity)(identity);
947
900
  if (errorMsg) {
948
901
  throw new Error(errorMsg);
@@ -964,9 +917,7 @@ function requireFactory$2 () {
964
917
  * @experimental
965
918
  */
966
919
  wrapSync(identity) {
967
- this.wire.sendAction('view-wrap-sync').catch((e) => {
968
- // we do not want to expose this error, just continue if this analytics-only call fails
969
- });
920
+ this.wire.recordAnalytic('view-wrap-sync');
970
921
  const errorMsg = (0, validate_1.validateIdentity)(identity);
971
922
  if (errorMsg) {
972
923
  throw new Error(errorMsg);
@@ -986,9 +937,7 @@ function requireFactory$2 () {
986
937
  * @experimental
987
938
  */
988
939
  getCurrent() {
989
- this.wire.sendAction('view-get-current').catch((e) => {
990
- // we do not want to expose this error, just continue if this analytics-only call fails
991
- });
940
+ this.wire.recordAnalytic('view-get-current');
992
941
  if (!this.wire.me.isView) {
993
942
  throw new Error('You are not in a View context');
994
943
  }
@@ -1007,9 +956,7 @@ function requireFactory$2 () {
1007
956
  * @experimental
1008
957
  */
1009
958
  getCurrentSync() {
1010
- this.wire.sendAction('view-get-current-sync').catch((e) => {
1011
- // we do not want to expose this error, just continue if this analytics-only call fails
1012
- });
959
+ this.wire.recordAnalytic('view-get-current-sync');
1013
960
  if (!this.wire.me.isView) {
1014
961
  throw new Error('You are not in a View context');
1015
962
  }
@@ -2077,9 +2024,7 @@ class WebContents extends base_1$m.EmitterBase {
2077
2024
  * {@link OpenFin.WebContentsEvents event namespace}.
2078
2025
  */
2079
2026
  async showPopupWindow(options) {
2080
- this.wire.sendAction(`${this.entityType}-show-popup-window`, this.identity).catch(() => {
2081
- // we do not want to expose this error, just continue if this analytics-only call fails
2082
- });
2027
+ this.wire.recordAnalytic(`${this.entityType}-show-popup-window`);
2083
2028
  if (options?.onPopupReady) {
2084
2029
  const readyListener = async ({ popupName }) => {
2085
2030
  try {
@@ -2505,9 +2450,7 @@ function requireInstance$2 () {
2505
2450
  * @experimental
2506
2451
  */
2507
2452
  this.getParentLayout = async () => {
2508
- this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
2509
- // don't expose
2510
- });
2453
+ this.wire.recordAnalytic('view-get-parent-layout');
2511
2454
  return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
2512
2455
  };
2513
2456
  /**
@@ -2620,9 +2563,7 @@ function requireInstance$2 () {
2620
2563
  * ```
2621
2564
  */
2622
2565
  this.getCurrentStack = async () => {
2623
- this.wire.sendAction('view-get-current-stack').catch(() => {
2624
- // don't expose
2625
- });
2566
+ this.wire.recordAnalytic('view-get-current-stack');
2626
2567
  try {
2627
2568
  const layout = await this.getParentLayout();
2628
2569
  return layout.getStackByViewIdentity(this.identity);
@@ -2868,9 +2809,7 @@ function requireInstance$1 () {
2868
2809
  */
2869
2810
  close(force = false) {
2870
2811
  console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2871
- this.wire.sendAction('application-close', this.identity).catch((e) => {
2872
- // we do not want to expose this error, just continue if this analytics-only call fails
2873
- });
2812
+ this.wire.recordAnalytic('application-close');
2874
2813
  return this._close(force);
2875
2814
  }
2876
2815
  /**
@@ -3011,9 +2950,7 @@ function requireInstance$1 () {
3011
2950
  * ```
3012
2951
  */
3013
2952
  getWindow() {
3014
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
3015
- // we do not want to expose this error, just continue if this analytics-only call fails
3016
- });
2953
+ this.wire.recordAnalytic('application-get-window');
3017
2954
  return Promise.resolve(this.window);
3018
2955
  }
3019
2956
  /**
@@ -3091,9 +3028,7 @@ function requireInstance$1 () {
3091
3028
  */
3092
3029
  run() {
3093
3030
  console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3094
- this.wire.sendAction('application-run', this.identity).catch((e) => {
3095
- // we do not want to expose this error, just continue if this analytics-only call fails
3096
- });
3031
+ this.wire.recordAnalytic('application-run');
3097
3032
  return this._run();
3098
3033
  }
3099
3034
  _run(opts = {}) {
@@ -3618,9 +3553,7 @@ function requireFactory$1 () {
3618
3553
  *
3619
3554
  */
3620
3555
  async wrap(identity) {
3621
- this.wire.sendAction('wrap-application').catch((e) => {
3622
- // we do not want to expose this error, just continue if this analytics-only call fails
3623
- });
3556
+ this.wire.recordAnalytic('wrap-application');
3624
3557
  const errorMsg = (0, validate_1.validateIdentity)(identity);
3625
3558
  if (errorMsg) {
3626
3559
  throw new Error(errorMsg);
@@ -3643,9 +3576,7 @@ function requireFactory$1 () {
3643
3576
  *
3644
3577
  */
3645
3578
  wrapSync(identity) {
3646
- this.wire.sendAction('wrap-application-sync').catch((e) => {
3647
- // we do not want to expose this error, just continue if this analytics-only call fails
3648
- });
3579
+ this.wire.recordAnalytic('wrap-application-sync');
3649
3580
  const errorMsg = (0, validate_1.validateIdentity)(identity);
3650
3581
  if (errorMsg) {
3651
3582
  throw new Error(errorMsg);
@@ -3686,9 +3617,7 @@ function requireFactory$1 () {
3686
3617
  */
3687
3618
  create(appOptions) {
3688
3619
  console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3689
- this.wire.sendAction('application-create').catch((e) => {
3690
- // we do not want to expose this error, just continue if this analytics-only call fails
3691
- });
3620
+ this.wire.recordAnalytic('application-create');
3692
3621
  return this._create(appOptions);
3693
3622
  }
3694
3623
  /**
@@ -3710,9 +3639,7 @@ function requireFactory$1 () {
3710
3639
  *
3711
3640
  */
3712
3641
  async start(appOptions) {
3713
- this.wire.sendAction('start-application').catch((e) => {
3714
- // we do not want to expose this error, just continue if this analytics-only call fails
3715
- });
3642
+ this.wire.recordAnalytic('start-application');
3716
3643
  const app = await this._create(appOptions);
3717
3644
  await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3718
3645
  return app;
@@ -3775,9 +3702,7 @@ function requireFactory$1 () {
3775
3702
  * ```
3776
3703
  */
3777
3704
  getCurrent() {
3778
- this.wire.sendAction('get-current-application').catch((e) => {
3779
- // we do not want to expose this error, just continue if this analytics-only call fails
3780
- });
3705
+ this.wire.recordAnalytic('get-current-application');
3781
3706
  return this.wrap({ uuid: this.wire.me.uuid });
3782
3707
  }
3783
3708
  /**
@@ -3800,9 +3725,7 @@ function requireFactory$1 () {
3800
3725
  * ```
3801
3726
  */
3802
3727
  getCurrentSync() {
3803
- this.wire.sendAction('get-current-application-sync').catch((e) => {
3804
- // we do not want to expose this error, just continue if this analytics-only call fails
3805
- });
3728
+ this.wire.recordAnalytic('get-current-application-sync');
3806
3729
  return this.wrapSync({ uuid: this.wire.me.uuid });
3807
3730
  }
3808
3731
  /**
@@ -3820,9 +3743,7 @@ function requireFactory$1 () {
3820
3743
  * ```
3821
3744
  */
3822
3745
  async startFromManifest(manifestUrl, opts) {
3823
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
3824
- // we do not want to expose this error, just continue if this analytics-only call fails
3825
- });
3746
+ this.wire.recordAnalytic('application-start-from-manifest');
3826
3747
  const app = await this._createFromManifest(manifestUrl);
3827
3748
  // @ts-expect-error using private method without warning.
3828
3749
  await app._run(opts); // eslint-disable-line no-underscore-dangle
@@ -3844,9 +3765,7 @@ function requireFactory$1 () {
3844
3765
  */
3845
3766
  createFromManifest(manifestUrl) {
3846
3767
  console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3847
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
3848
- // we do not want to expose this error, just continue if this analytics-only call fails
3849
- });
3768
+ this.wire.recordAnalytic('application-create-from-manifest');
3850
3769
  return this._createFromManifest(manifestUrl);
3851
3770
  }
3852
3771
  _createFromManifest(manifestUrl) {
@@ -3967,9 +3886,7 @@ function requireInstance () {
3967
3886
  super(wire, identity, 'window');
3968
3887
  }
3969
3888
  async createWindow(options) {
3970
- this.wire.sendAction('window-create-window', this.identity).catch((e) => {
3971
- // we do not want to expose this error, just continue if this analytics-only call fails
3972
- });
3889
+ this.wire.recordAnalytic('window-create-window');
3973
3890
  const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
3974
3891
  const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
3975
3892
  // set defaults:
@@ -4443,9 +4360,7 @@ function requireInstance () {
4443
4360
  * @experimental
4444
4361
  */
4445
4362
  async getLayout(layoutIdentity) {
4446
- this.wire.sendAction('window-get-layout', this.identity).catch((e) => {
4447
- // don't expose
4448
- });
4363
+ this.wire.recordAnalytic('window-get-layout');
4449
4364
  const opts = await this.getOptions();
4450
4365
  if (!opts.layout && !opts.layoutSnapshot) {
4451
4366
  throw new Error('Window does not have a Layout');
@@ -4494,9 +4409,7 @@ function requireInstance () {
4494
4409
  * ```
4495
4410
  */
4496
4411
  getParentApplication() {
4497
- this.wire.sendAction('window-get-parent-application', this.identity).catch((e) => {
4498
- // we do not want to expose this error, just continue if this analytics-only call fails
4499
- });
4412
+ this.wire.recordAnalytic('window-get-parent-application');
4500
4413
  return Promise.resolve(new application_1.Application(this.wire, this.identity));
4501
4414
  }
4502
4415
  /**
@@ -4519,9 +4432,7 @@ function requireInstance () {
4519
4432
  * ```
4520
4433
  */
4521
4434
  getParentWindow() {
4522
- this.wire.sendAction('window-get-parent-window', this.identity).catch((e) => {
4523
- // we do not want to expose this error, just continue if this analytics-only call fails
4524
- });
4435
+ this.wire.recordAnalytic('window-get-parent-window');
4525
4436
  return Promise.resolve(new application_1.Application(this.wire, this.identity)).then((app) => app.getWindow());
4526
4437
  }
4527
4438
  /**
@@ -4625,9 +4536,7 @@ function requireInstance () {
4625
4536
  * ```
4626
4537
  */
4627
4538
  getWebWindow() {
4628
- this.wire.sendAction('window-get-web-window', this.identity).catch((e) => {
4629
- // we do not want to expose this error, just continue if this analytics-only call fails
4630
- });
4539
+ this.wire.recordAnalytic('window-get-web-window');
4631
4540
  return this.wire.environment.getWebWindow(this.identity);
4632
4541
  }
4633
4542
  /**
@@ -4641,9 +4550,7 @@ function requireInstance () {
4641
4550
  * ```
4642
4551
  */
4643
4552
  isMainWindow() {
4644
- this.wire.sendAction('window-is-main-window', this.identity).catch((e) => {
4645
- // we do not want to expose this error, just continue if this analytics-only call fails
4646
- });
4553
+ this.wire.recordAnalytic('window-is-main-window');
4647
4554
  return this.me.uuid === this.me.name;
4648
4555
  }
4649
4556
  /**
@@ -5026,6 +4933,9 @@ function requireInstance () {
5026
4933
  * ```
5027
4934
  */
5028
4935
  updateOptions(options) {
4936
+ if ('frame' in options) {
4937
+ console.warn(`Deprecation Warning: Starting with version 45 it will not be possible to change the frame value after window has been created.`);
4938
+ }
5029
4939
  return this.wire.sendAction('update-window-options', { options, ...this.identity }).then(() => undefined);
5030
4940
  }
5031
4941
  /**
@@ -5162,9 +5072,7 @@ function requireInstance () {
5162
5072
  * ```
5163
5073
  */
5164
5074
  async dispatchPopupResult(data) {
5165
- this.wire.sendAction('window-dispatch-popup-result', this.identity).catch((e) => {
5166
- // we do not want to expose this error, just continue if this analytics-only call fails
5167
- });
5075
+ this.wire.recordAnalytic('window-dispatch-popup-result');
5168
5076
  await this.wire.sendAction('dispatch-popup-result', { data, ...this.identity });
5169
5077
  }
5170
5078
  /**
@@ -5264,9 +5172,7 @@ function requireFactory () {
5264
5172
  * ```
5265
5173
  */
5266
5174
  async wrap(identity) {
5267
- this.wire.sendAction('window-wrap').catch((e) => {
5268
- // we do not want to expose this error, just continue if this analytics-only call fails
5269
- });
5175
+ this.wire.recordAnalytic('window-wrap');
5270
5176
  const errorMsg = (0, validate_1.validateIdentity)(identity);
5271
5177
  if (errorMsg) {
5272
5178
  throw new Error(errorMsg);
@@ -5296,9 +5202,7 @@ function requireFactory () {
5296
5202
  * ```
5297
5203
  */
5298
5204
  wrapSync(identity) {
5299
- this.wire.sendAction('window-wrap-sync').catch((e) => {
5300
- // we do not want to expose this error, just continue if this analytics-only call fails
5301
- });
5205
+ this.wire.recordAnalytic('window-wrap-sync');
5302
5206
  const errorMsg = (0, validate_1.validateIdentity)(identity);
5303
5207
  if (errorMsg) {
5304
5208
  throw new Error(errorMsg);
@@ -5327,9 +5231,7 @@ function requireFactory () {
5327
5231
  * ```
5328
5232
  */
5329
5233
  create(options) {
5330
- this.wire.sendAction('create-window').catch((e) => {
5331
- // we do not want to expose this error, just continue if this analytics-only call fails
5332
- });
5234
+ this.wire.recordAnalytic('create-window');
5333
5235
  const win = new Instance_1._Window(this.wire, { uuid: this.me.uuid, name: options.name });
5334
5236
  return win.createWindow(options);
5335
5237
  }
@@ -5345,9 +5247,7 @@ function requireFactory () {
5345
5247
  * ```
5346
5248
  */
5347
5249
  getCurrent() {
5348
- this.wire.sendAction('get-current-window').catch((e) => {
5349
- // we do not want to expose this error, just continue if this analytics-only call fails
5350
- });
5250
+ this.wire.recordAnalytic('get-current-window');
5351
5251
  if (!this.wire.me.isWindow) {
5352
5252
  throw new Error('You are not in a Window context');
5353
5253
  }
@@ -5366,9 +5266,7 @@ function requireFactory () {
5366
5266
  * ```
5367
5267
  */
5368
5268
  getCurrentSync() {
5369
- this.wire.sendAction('get-current-window-sync').catch((e) => {
5370
- // we do not want to expose this error, just continue if this analytics-only call fails
5371
- });
5269
+ this.wire.recordAnalytic('get-current-window-sync');
5372
5270
  if (!this.wire.me.isWindow) {
5373
5271
  throw new Error('You are not in a Window context');
5374
5272
  }
@@ -5514,13 +5412,15 @@ class System extends base_1$l.EmitterBase {
5514
5412
  * * cookies: browser [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
5515
5413
  * * localStorage: browser data that can be used across sessions ([local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage))
5516
5414
  * * appcache: html5 [application cache](https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache)
5415
+ * * windowState: clears data written for windows using `saveWindowState`; after clearing, previously saved bounds and state will not be restored until new state is written
5517
5416
  * @example
5518
5417
  * ```js
5519
5418
  * const clearCacheOptions = {
5520
5419
  * appcache: true,
5521
5420
  * cache: true,
5522
5421
  * cookies: true,
5523
- * localStorage: true
5422
+ * localStorage: true,
5423
+ * windowState: true
5524
5424
  * };
5525
5425
  * fin.System.clearCache(clearCacheOptions).then(() => console.log('Cache cleared')).catch(err => console.log(err));
5526
5426
  * ```
@@ -6922,9 +6822,7 @@ class System extends base_1$l.EmitterBase {
6922
6822
  * @experimental
6923
6823
  */
6924
6824
  async registerShutdownHandler(handler) {
6925
- this.wire.sendAction('system-register-shutdown-handler').catch((e) => {
6926
- // don't expose, analytics-only call
6927
- });
6825
+ this.wire.recordAnalytic('system-register-shutdown-handler');
6928
6826
  const SystemShutdownEventName = 'system-shutdown';
6929
6827
  const SystemShutdownHandledEventName = 'system-shutdown-handled';
6930
6828
  const { uuid, name } = this.wire.me;
@@ -8540,9 +8438,8 @@ class ChannelProvider extends channel_1.ChannelBase {
8540
8438
  return [...__classPrivateFieldGet$d(this, _ChannelProvider_connections, "f")];
8541
8439
  }
8542
8440
  static handleClientDisconnection(channel, payload) {
8543
- if (payload?.endpointId) {
8544
- const { uuid, name, endpointId, isLocalEndpointId } = payload;
8545
- __classPrivateFieldGet$d(channel, _ChannelProvider_removeEndpoint, "f").call(channel, { uuid, name, endpointId, isLocalEndpointId });
8441
+ if (payload.endpointId) {
8442
+ __classPrivateFieldGet$d(channel, _ChannelProvider_removeEndpoint, "f").call(channel, { endpointId: payload.endpointId });
8546
8443
  }
8547
8444
  else {
8548
8445
  // this is here to support older runtimes that did not have endpointId
@@ -8712,7 +8609,9 @@ class ChannelProvider extends channel_1.ChannelBase {
8712
8609
  * ```
8713
8610
  */
8714
8611
  onDisconnection(listener) {
8715
- this.disconnectListener = listener;
8612
+ this.disconnectListener = (identity) => {
8613
+ listener(identity);
8614
+ };
8716
8615
  }
8717
8616
  /**
8718
8617
  * Destroy the channel, raises `disconnected` events on all connected channel clients.
@@ -8729,7 +8628,6 @@ class ChannelProvider extends channel_1.ChannelBase {
8729
8628
  */
8730
8629
  async destroy() {
8731
8630
  const protectedObj = __classPrivateFieldGet$d(this, _ChannelProvider_protectedObj, "f");
8732
- protectedObj.providerIdentity;
8733
8631
  __classPrivateFieldSet$c(this, _ChannelProvider_connections, [], "f");
8734
8632
  await protectedObj.close();
8735
8633
  __classPrivateFieldGet$d(this, _ChannelProvider_close, "f").call(this);
@@ -9036,7 +8934,7 @@ const base_1$i = base;
9036
8934
  const strategy_1 = strategy$3;
9037
8935
  const strategy_2 = strategy$2;
9038
8936
  const ice_manager_1 = iceManager;
9039
- const provider_1$1 = provider;
8937
+ const provider_1 = provider;
9040
8938
  const message_receiver_1 = messageReceiver;
9041
8939
  const protocol_manager_1 = protocolManager;
9042
8940
  const strategy_3 = __importDefault$6(strategy);
@@ -9058,6 +8956,13 @@ class ConnectionManager extends base_1$i.Base {
9058
8956
  _ConnectionManager_messageReceiver.set(this, void 0);
9059
8957
  _ConnectionManager_rtcConnectionManager.set(this, void 0);
9060
8958
  this.removeChannelFromProviderMap = (channelId) => {
8959
+ const providerEntry = this.providerMap.get(channelId);
8960
+ if (providerEntry) {
8961
+ const { channelName } = providerEntry.providerIdentity;
8962
+ if (this.providerChannelIdByName.get(channelName) === channelId) {
8963
+ this.providerChannelIdByName.delete(channelName);
8964
+ }
8965
+ }
9061
8966
  this.providerMap.delete(channelId);
9062
8967
  };
9063
8968
  this.onmessage = (msg) => {
@@ -9068,6 +8973,7 @@ class ConnectionManager extends base_1$i.Base {
9068
8973
  return false;
9069
8974
  };
9070
8975
  this.providerMap = new Map();
8976
+ this.providerChannelIdByName = new Map();
9071
8977
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
9072
8978
  __classPrivateFieldSet$b(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
9073
8979
  __classPrivateFieldSet$b(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
@@ -9101,14 +9007,16 @@ class ConnectionManager extends base_1$i.Base {
9101
9007
  // Should be impossible.
9102
9008
  throw new Error('failed to combine strategies');
9103
9009
  }
9104
- const channel = new provider_1$1.ChannelProvider(providerIdentity, () => provider_1$1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
9010
+ const channel = new provider_1.ChannelProvider(providerIdentity, () => provider_1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
9105
9011
  const key = providerIdentity.channelId;
9106
9012
  this.providerMap.set(key, {
9013
+ providerIdentity,
9107
9014
  provider: channel,
9108
9015
  strategy,
9109
9016
  supportedProtocols: ConnectionManager.getProtocolOptionsFromStrings(protocols)
9110
9017
  });
9111
- provider_1$1.ChannelProvider.setProviderRemoval(channel, this.removeChannelFromProviderMap.bind(this));
9018
+ this.providerChannelIdByName.set(providerIdentity.channelName, key);
9019
+ provider_1.ChannelProvider.setProviderRemoval(channel, this.removeChannelFromProviderMap.bind(this));
9112
9020
  return channel;
9113
9021
  }
9114
9022
  async createClientOffer(options) {
@@ -9182,6 +9090,16 @@ class ConnectionManager extends base_1$i.Base {
9182
9090
  strategy.addEndpoint(routingInfo.channelId, endpointPayload);
9183
9091
  return strategy;
9184
9092
  }
9093
+ handleClientDisconnection(eventPayload) {
9094
+ const channelId = eventPayload.channelId ?? this.providerChannelIdByName.get(eventPayload.channelName ?? '');
9095
+ if (!channelId) {
9096
+ return;
9097
+ }
9098
+ const providerEntry = this.providerMap.get(channelId);
9099
+ if (providerEntry) {
9100
+ provider_1.ChannelProvider.handleClientDisconnection(providerEntry.provider, eventPayload);
9101
+ }
9102
+ }
9185
9103
  async processChannelConnection(msg) {
9186
9104
  const { clientIdentity, providerIdentity, ackToSender, payload, offer: clientOffer } = msg.payload;
9187
9105
  if (!clientIdentity.endpointId) {
@@ -9201,7 +9119,7 @@ class ConnectionManager extends base_1$i.Base {
9201
9119
  }
9202
9120
  const { provider, strategy, supportedProtocols } = bus;
9203
9121
  try {
9204
- if (!(provider instanceof provider_1$1.ChannelProvider)) {
9122
+ if (!(provider instanceof provider_1.ChannelProvider)) {
9205
9123
  throw Error('Cannot connect to a channel client');
9206
9124
  }
9207
9125
  const offer = clientOffer ?? {
@@ -9282,7 +9200,7 @@ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateF
9282
9200
  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");
9283
9201
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9284
9202
  };
9285
- var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnect;
9203
+ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyForProvider, _Channel_readyToConnect;
9286
9204
  Object.defineProperty(channel$1, "__esModule", { value: true });
9287
9205
  channel$1.Channel = void 0;
9288
9206
  /* eslint-disable no-console */
@@ -9291,7 +9209,6 @@ const lazy_1$2 = lazy;
9291
9209
  const base_1$h = base;
9292
9210
  const client_1 = client;
9293
9211
  const connection_manager_1 = connectionManager;
9294
- const provider_1 = provider;
9295
9212
  function retryDelay(count) {
9296
9213
  const interval = 500; // base delay
9297
9214
  const steps = 10; // How many retries to do before incrementing the delay
@@ -9327,9 +9244,19 @@ class Channel extends base_1$h.EmitterBase {
9327
9244
  super(wire, 'channel');
9328
9245
  _Channel_connectionManager.set(this, void 0);
9329
9246
  _Channel_internalEmitter.set(this, new events_1$5.EventEmitter());
9247
+ // Provider-side disconnect routing setup. This must exist before first create()
9248
+ // so provider onDisconnection callbacks are wired even if connect() is never called.
9249
+ _Channel_readyForProvider.set(this, new lazy_1$2.AsyncRetryableLazy(async () => {
9250
+ // TODO: fix typing (internal)
9251
+ // @ts-expect-error
9252
+ await this.on('client-disconnected', (eventPayload) => {
9253
+ __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").handleClientDisconnection(eventPayload);
9254
+ });
9255
+ }));
9330
9256
  // OpenFin API has not been injected at construction time, *must* wait for API to be ready.
9331
9257
  _Channel_readyToConnect.set(this, new lazy_1$2.AsyncRetryableLazy(async () => {
9332
9258
  await Promise.all([
9259
+ __classPrivateFieldGet$b(this, _Channel_readyForProvider, "f").getValue(),
9333
9260
  this.on('disconnected', (eventPayload) => {
9334
9261
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9335
9262
  }),
@@ -9586,23 +9513,16 @@ class Channel extends base_1$h.EmitterBase {
9586
9513
  * ```
9587
9514
  */
9588
9515
  async create(channelName, options) {
9516
+ await __classPrivateFieldGet$b(this, _Channel_readyForProvider, "f").getValue();
9589
9517
  if (!channelName) {
9590
9518
  throw new Error('Please provide a channelName to create a channel');
9591
9519
  }
9592
9520
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
9593
- const channel = __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9594
- // TODO: fix typing (internal)
9595
- // @ts-expect-error
9596
- this.on('client-disconnected', (eventPayload) => {
9597
- if (eventPayload.channelName === channelName) {
9598
- provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
9599
- }
9600
- });
9601
- return channel;
9521
+ return __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9602
9522
  }
9603
9523
  }
9604
9524
  channel$1.Channel = Channel;
9605
- _Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyToConnect = new WeakMap();
9525
+ _Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyForProvider = new WeakMap(), _Channel_readyToConnect = new WeakMap();
9606
9526
 
9607
9527
  Object.defineProperty(interappbus, "__esModule", { value: true });
9608
9528
  interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
@@ -9628,6 +9548,16 @@ class InterApplicationBus extends base_1$g.Base {
9628
9548
  */
9629
9549
  constructor(wire) {
9630
9550
  super(wire);
9551
+ /**
9552
+ * Event types for the InterApplicationBus.
9553
+ *
9554
+ * @remarks The `subscriber-added` and `subscriber-removed` events are disabled by default.
9555
+ * To re-enable them, launch the runtime with the `--emit-legacy-iab-events` flag.
9556
+ * These events will be removed in a future version. Use {@link Channel} for connection
9557
+ * lifecycle management instead.
9558
+ *
9559
+ * @deprecated Use {@link Channel} `onConnection` / `onDisconnection` instead.
9560
+ */
9631
9561
  this.events = {
9632
9562
  subscriberAdded: 'subscriber-added',
9633
9563
  subscriberRemoved: 'subscriber-removed'
@@ -10114,9 +10044,7 @@ class ExternalApplicationModule extends base_1$d.Base {
10114
10044
  * ```
10115
10045
  */
10116
10046
  wrap(uuid) {
10117
- this.wire.sendAction('external-application-wrap').catch((e) => {
10118
- // we do not want to expose this error, just continue if this analytics-only call fails
10119
- });
10047
+ this.wire.recordAnalytic('external-application-wrap');
10120
10048
  return Promise.resolve(new Instance_1$4.ExternalApplication(this.wire, { uuid }));
10121
10049
  }
10122
10050
  /**
@@ -10133,9 +10061,7 @@ class ExternalApplicationModule extends base_1$d.Base {
10133
10061
  * ```
10134
10062
  */
10135
10063
  wrapSync(uuid) {
10136
- this.wire.sendAction('external-application-wrap-sync').catch((e) => {
10137
- // we do not want to expose this error, just continue if this analytics-only call fails
10138
- });
10064
+ this.wire.recordAnalytic('external-application-wrap-sync');
10139
10065
  return new Instance_1$4.ExternalApplication(this.wire, { uuid });
10140
10066
  }
10141
10067
  }
@@ -10270,9 +10196,7 @@ class _FrameModule extends base_1$b.Base {
10270
10196
  * ```
10271
10197
  */
10272
10198
  async wrap(identity) {
10273
- this.wire.sendAction('frame-wrap').catch((e) => {
10274
- // we do not want to expose this error, just continue if this analytics-only call fails
10275
- });
10199
+ this.wire.recordAnalytic('frame-wrap');
10276
10200
  const errorMsg = (0, validate_1$2.validateIdentity)(identity);
10277
10201
  if (errorMsg) {
10278
10202
  throw new Error(errorMsg);
@@ -10294,9 +10218,7 @@ class _FrameModule extends base_1$b.Base {
10294
10218
  * ```
10295
10219
  */
10296
10220
  wrapSync(identity) {
10297
- this.wire.sendAction('frame-wrap-sync').catch((e) => {
10298
- // we do not want to expose this error, just continue if this analytics-only call fails
10299
- });
10221
+ this.wire.recordAnalytic('frame-wrap-sync');
10300
10222
  const errorMsg = (0, validate_1$2.validateIdentity)(identity);
10301
10223
  if (errorMsg) {
10302
10224
  throw new Error(errorMsg);
@@ -10314,9 +10236,7 @@ class _FrameModule extends base_1$b.Base {
10314
10236
  * ```
10315
10237
  */
10316
10238
  getCurrent() {
10317
- this.wire.sendAction('frame-get-current').catch((e) => {
10318
- // we do not want to expose this error, just continue if this analytics-only call fails
10319
- });
10239
+ this.wire.recordAnalytic('frame-get-current');
10320
10240
  return Promise.resolve(new Instance_1$3._Frame(this.wire, this.wire.environment.getCurrentEntityIdentity()));
10321
10241
  }
10322
10242
  /**
@@ -10330,9 +10250,7 @@ class _FrameModule extends base_1$b.Base {
10330
10250
  * ```
10331
10251
  */
10332
10252
  getCurrentSync() {
10333
- this.wire.sendAction('frame-get-current-sync').catch((e) => {
10334
- // we do not want to expose this error, just continue if this analytics-only call fails
10335
- });
10253
+ this.wire.recordAnalytic('frame-get-current-sync');
10336
10254
  return new Instance_1$3._Frame(this.wire, this.wire.environment.getCurrentEntityIdentity());
10337
10255
  }
10338
10256
  }
@@ -12562,9 +12480,7 @@ class LayoutModule extends base_1$7.Base {
12562
12480
  * ```
12563
12481
  */
12564
12482
  this.init = async (options = {}) => {
12565
- this.wire.sendAction('layout-init').catch((e) => {
12566
- // don't expose
12567
- });
12483
+ this.wire.recordAnalytic('layout-init');
12568
12484
  if (!this.wire.environment.layoutAllowedInContext(this.fin)) {
12569
12485
  throw new Error('Layout.init can only be called from a Window context.');
12570
12486
  }
@@ -12642,9 +12558,7 @@ class LayoutModule extends base_1$7.Base {
12642
12558
  * ```
12643
12559
  */
12644
12560
  async wrap(identity) {
12645
- this.wire.sendAction('layout-wrap').catch((e) => {
12646
- // don't expose
12647
- });
12561
+ this.wire.recordAnalytic('layout-wrap');
12648
12562
  return new Instance_1$2.Layout(identity, this.wire);
12649
12563
  }
12650
12564
  /**
@@ -12667,9 +12581,7 @@ class LayoutModule extends base_1$7.Base {
12667
12581
  * ```
12668
12582
  */
12669
12583
  wrapSync(identity) {
12670
- this.wire.sendAction('layout-wrap-sync').catch((e) => {
12671
- // don't expose
12672
- });
12584
+ this.wire.recordAnalytic('layout-wrap-sync');
12673
12585
  return new Instance_1$2.Layout(identity, this.wire);
12674
12586
  }
12675
12587
  /**
@@ -12683,9 +12595,7 @@ class LayoutModule extends base_1$7.Base {
12683
12595
  * ```
12684
12596
  */
12685
12597
  async getCurrent() {
12686
- this.wire.sendAction('layout-get-current').catch((e) => {
12687
- // don't expose
12688
- });
12598
+ this.wire.recordAnalytic('layout-get-current');
12689
12599
  if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12690
12600
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12691
12601
  }
@@ -12706,9 +12616,7 @@ class LayoutModule extends base_1$7.Base {
12706
12616
  * ```
12707
12617
  */
12708
12618
  getCurrentSync() {
12709
- this.wire.sendAction('layout-get-current-sync').catch((e) => {
12710
- // don't expose
12711
- });
12619
+ this.wire.recordAnalytic('layout-get-current-sync');
12712
12620
  if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12713
12621
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12714
12622
  }
@@ -12726,9 +12634,7 @@ class LayoutModule extends base_1$7.Base {
12726
12634
  * ```
12727
12635
  */
12728
12636
  async getLayoutByViewIdentity(viewIdentity) {
12729
- this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12730
- // don't expose
12731
- });
12637
+ this.wire.recordAnalytic('layout-get-by-view-identity');
12732
12638
  const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12733
12639
  let layoutWindowIdentity = winIdentity;
12734
12640
  // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
@@ -12890,9 +12796,7 @@ class PlatformModule extends base_1$6.Base {
12890
12796
  * ```
12891
12797
  */
12892
12798
  async wrap(identity) {
12893
- this.wire.sendAction('platform-wrap').catch((e) => {
12894
- // don't expose
12895
- });
12799
+ this.wire.recordAnalytic('platform-wrap');
12896
12800
  return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12897
12801
  }
12898
12802
  /**
@@ -12907,9 +12811,7 @@ class PlatformModule extends base_1$6.Base {
12907
12811
  * ```
12908
12812
  */
12909
12813
  wrapSync(identity) {
12910
- this.wire.sendAction('platform-wrap-sync').catch((e) => {
12911
- // don't expose
12912
- });
12814
+ this.wire.recordAnalytic('platform-wrap-sync');
12913
12815
  return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12914
12816
  }
12915
12817
  /**
@@ -12923,9 +12825,7 @@ class PlatformModule extends base_1$6.Base {
12923
12825
  * ```
12924
12826
  */
12925
12827
  async getCurrent() {
12926
- this.wire.sendAction('platform-get-current').catch((e) => {
12927
- // don't expose
12928
- });
12828
+ this.wire.recordAnalytic('platform-get-current');
12929
12829
  return this.wrap({ uuid: this.wire.me.uuid });
12930
12830
  }
12931
12831
  /**
@@ -12939,9 +12839,7 @@ class PlatformModule extends base_1$6.Base {
12939
12839
  * ```
12940
12840
  */
12941
12841
  getCurrentSync() {
12942
- this.wire.sendAction('platform-get-current-sync').catch((e) => {
12943
- // don't expose
12944
- });
12842
+ this.wire.recordAnalytic('platform-get-current-sync');
12945
12843
  return this.wrapSync({ uuid: this.wire.me.uuid });
12946
12844
  }
12947
12845
  /**
@@ -12969,9 +12867,7 @@ class PlatformModule extends base_1$6.Base {
12969
12867
  * ```
12970
12868
  */
12971
12869
  start(platformOptions) {
12972
- this.wire.sendAction('platform-start').catch((e) => {
12973
- // don't expose
12974
- });
12870
+ this.wire.recordAnalytic('platform-start');
12975
12871
  // eslint-disable-next-line no-async-promise-executor
12976
12872
  return new Promise(async (resolve, reject) => {
12977
12873
  try {
@@ -13013,9 +12909,7 @@ class PlatformModule extends base_1$6.Base {
13013
12909
  * ```
13014
12910
  */
13015
12911
  startFromManifest(manifestUrl, opts) {
13016
- this.wire.sendAction('platform-start-from-manifest').catch((e) => {
13017
- // don't expose
13018
- });
12912
+ this.wire.recordAnalytic('platform-start-from-manifest');
13019
12913
  // eslint-disable-next-line no-async-promise-executor
13020
12914
  return new Promise(async (resolve, reject) => {
13021
12915
  try {
@@ -16057,7 +15951,6 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
16057
15951
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
16058
15952
  // The broker will then setContext on that session context group later with our Intent Result,
16059
15953
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
16060
- let isPromiseSettled = false;
16061
15954
  // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
16062
15955
  const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
16063
15956
  const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
@@ -16073,21 +15966,11 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
16073
15966
  reject(new Error('getResult is not supported in this environment'));
16074
15967
  });
16075
15968
  });
16076
- getResultPromise
16077
- .then(() => {
16078
- isPromiseSettled = true;
16079
- })
16080
- .catch(() => {
16081
- isPromiseSettled = true;
16082
- });
16083
15969
  // Set up the getResult call.
16084
15970
  const getResult = async () => {
16085
- // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
16086
- if (!isPromiseSettled) {
16087
- return undefined;
16088
- }
16089
15971
  let intentResult = await getResultPromise;
16090
- if (isPromiseSettled && !intentResult) {
15972
+ // void / no payload, or web path where subscribe resolves undefined (see getResultPromise above)
15973
+ if (intentResult == null) {
16091
15974
  return undefined;
16092
15975
  }
16093
15976
  if (typeof intentResult !== 'object') {
@@ -16178,9 +16061,7 @@ class FDC3ModuleBase {
16178
16061
  * @static
16179
16062
  */
16180
16063
  async broadcast(context) {
16181
- this.wire.sendAction('fdc3-broadcast').catch((e) => {
16182
- // we do not want to expose this error, just continue if this analytics-only call fails
16183
- });
16064
+ this.wire.recordAnalytic('fdc3-broadcast');
16184
16065
  return this.client.setContext(context);
16185
16066
  }
16186
16067
  /**
@@ -16191,9 +16072,7 @@ class FDC3ModuleBase {
16191
16072
  * @tutorial fdc3.open
16192
16073
  */
16193
16074
  async _open(app, context) {
16194
- this.wire.sendAction('fdc3-open').catch((e) => {
16195
- // we do not want to expose this error, just continue if this analytics-only call fails
16196
- });
16075
+ this.wire.recordAnalytic('fdc3-open');
16197
16076
  try {
16198
16077
  return await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
16199
16078
  }
@@ -16217,9 +16096,7 @@ class FDC3ModuleBase {
16217
16096
  * @tutorial fdc3.getOrCreateChannel
16218
16097
  */
16219
16098
  async getOrCreateChannel(channelId, fdc3Factory) {
16220
- this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
16221
- // we do not want to expose this error, just continue if this analytics-only call fails
16222
- });
16099
+ this.wire.recordAnalytic('fdc3-get-or-create-channel');
16223
16100
  const hasChannelIdBeenUsed = await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
16224
16101
  channelId
16225
16102
  });
@@ -16247,9 +16124,7 @@ class FDC3ModuleBase {
16247
16124
  * @static
16248
16125
  */
16249
16126
  async getSystemChannels() {
16250
- this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
16251
- // we do not want to expose this error, just continue if this analytics-only call fails
16252
- });
16127
+ this.wire.recordAnalytic('fdc3-get-system-channels');
16253
16128
  return this._getChannels();
16254
16129
  }
16255
16130
  /**
@@ -16264,9 +16139,7 @@ class FDC3ModuleBase {
16264
16139
  * @static
16265
16140
  */
16266
16141
  async joinChannel(channelId) {
16267
- this.wire.sendAction('fdc3-join-channel').catch((e) => {
16268
- // we do not want to expose this error, just continue if this analytics-only call fails
16269
- });
16142
+ this.wire.recordAnalytic('fdc3-join-channel');
16270
16143
  try {
16271
16144
  return await this.client.joinContextGroup(channelId);
16272
16145
  }
@@ -16289,9 +16162,7 @@ class FDC3ModuleBase {
16289
16162
  * @tutorial fdc3.getCurrentChannel
16290
16163
  */
16291
16164
  async getCurrentChannel() {
16292
- this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
16293
- // we do not want to expose this error, just continue if this analytics-only call fails
16294
- });
16165
+ this.wire.recordAnalytic('fdc3-get-current-channel');
16295
16166
  const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
16296
16167
  if (!currentContextGroupInfo) {
16297
16168
  return null;
@@ -16306,9 +16177,7 @@ class FDC3ModuleBase {
16306
16177
  * @static
16307
16178
  */
16308
16179
  async leaveCurrentChannel() {
16309
- this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
16310
- // we do not want to expose this error, just continue if this analytics-only call fails
16311
- });
16180
+ this.wire.recordAnalytic('fdc3-leave-current-channel');
16312
16181
  return this.client.removeFromContextGroup();
16313
16182
  }
16314
16183
  // utils
@@ -16434,9 +16303,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16434
16303
  */
16435
16304
  // @ts-expect-error TODO [CORE-1524]
16436
16305
  addContextListener(contextType, handler) {
16437
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
16438
- // we do not want to expose this error, just continue if this analytics-only call fails
16439
- });
16306
+ this.wire.recordAnalytic('fdc3-add-context-listener');
16440
16307
  let listener;
16441
16308
  if (typeof contextType === 'function') {
16442
16309
  console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
@@ -16459,9 +16326,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16459
16326
  * @static
16460
16327
  */
16461
16328
  addIntentListener(intent, handler) {
16462
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
16463
- // we do not want to expose this error, just continue if this analytics-only call fails
16464
- });
16329
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
16465
16330
  const contextHandler = (raisedIntent) => {
16466
16331
  const { context, metadata: intentMetadata } = raisedIntent;
16467
16332
  const { metadata } = context;
@@ -16489,9 +16354,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16489
16354
  * @static
16490
16355
  */
16491
16356
  async raiseIntent(intent, context, app) {
16492
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
16493
- // we do not want to expose this error, just continue if this analytics-only call fails
16494
- });
16357
+ this.wire.recordAnalytic('fdc3-raise-intent');
16495
16358
  const intentObj = app
16496
16359
  ? { name: intent, context, metadata: { target: app } }
16497
16360
  : { name: intent, context };
@@ -16511,9 +16374,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16511
16374
  * @tutorial fdc3.findIntent
16512
16375
  */
16513
16376
  async findIntent(intent, context) {
16514
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
16515
- // we do not want to expose this error, just continue if this analytics-only call fails
16516
- });
16377
+ this.wire.recordAnalytic('fdc3-find-intent');
16517
16378
  try {
16518
16379
  return await this.client.getInfoForIntent({ name: intent, context });
16519
16380
  }
@@ -16529,9 +16390,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16529
16390
  * @tutorial fdc3.findIntentsByContext
16530
16391
  */
16531
16392
  async findIntentsByContext(context) {
16532
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
16533
- // we do not want to expose this error, just continue if this analytics-only call fails
16534
- });
16393
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
16535
16394
  try {
16536
16395
  return await this.client.getInfoForIntentsByContext(context);
16537
16396
  }
@@ -16548,9 +16407,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16548
16407
  * @tutorial fdc3.raiseIntentForContext
16549
16408
  */
16550
16409
  async raiseIntentForContext(context, app) {
16551
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
16552
- // we do not want to expose this error, just continue if this analytics-only call fails
16553
- });
16410
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
16554
16411
  try {
16555
16412
  return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
16556
16413
  }
@@ -16574,9 +16431,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16574
16431
  * @tutorial fdc3.getInfo
16575
16432
  */
16576
16433
  getInfo() {
16577
- this.wire.sendAction('fdc3-get-info').catch((e) => {
16578
- // we do not want to expose this error, just continue if this analytics-only call fails
16579
- });
16434
+ this.wire.recordAnalytic('fdc3-get-info');
16580
16435
  const version = this.wire.environment.getAdapterVersionSync();
16581
16436
  return {
16582
16437
  providerVersion: version,
@@ -16654,9 +16509,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16654
16509
  * @tutorial fdc3v2.findInstances
16655
16510
  */
16656
16511
  async findInstances(app) {
16657
- this.wire.sendAction('fdc3-find-instances').catch((e) => {
16658
- // we do not want to expose this error, just continue if this analytics-only call fails
16659
- });
16512
+ this.wire.recordAnalytic('fdc3-find-instances');
16660
16513
  try {
16661
16514
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
16662
16515
  }
@@ -16672,9 +16525,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16672
16525
  * @tutorial fdc3v2.getAppMetadata
16673
16526
  */
16674
16527
  async getAppMetadata(app) {
16675
- this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
16676
- // we do not want to expose this error, just continue if this analytics-only call fails
16677
- });
16528
+ this.wire.recordAnalytic('fdc3-get-app-metadata');
16678
16529
  try {
16679
16530
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
16680
16531
  }
@@ -16692,9 +16543,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16692
16543
  */
16693
16544
  // @ts-expect-error TODO [CORE-1524]
16694
16545
  async addContextListener(contextType, handler) {
16695
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
16696
- // we do not want to expose this error, just continue if this analytics-only call fails
16697
- });
16546
+ this.wire.recordAnalytic('fdc3-add-context-listener');
16698
16547
  // The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
16699
16548
  // here so it only gets passed these parameters
16700
16549
  const getWrappedHandler = (handlerToWrap) => {
@@ -16723,9 +16572,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16723
16572
  * @tutorial fdc3.findIntent
16724
16573
  */
16725
16574
  async findIntent(intent, context, resultType) {
16726
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
16727
- // we do not want to expose this error, just continue if this analytics-only call fails
16728
- });
16575
+ this.wire.recordAnalytic('fdc3-find-intent');
16729
16576
  try {
16730
16577
  return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
16731
16578
  }
@@ -16742,9 +16589,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16742
16589
  * @tutorial fdc3v2.findIntentsByContext
16743
16590
  */
16744
16591
  async findIntentsByContext(context, resultType) {
16745
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
16746
- // we do not want to expose this error, just continue if this analytics-only call fails
16747
- });
16592
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
16748
16593
  const payload = resultType ? { context, metadata: { resultType } } : context;
16749
16594
  try {
16750
16595
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
@@ -16763,9 +16608,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16763
16608
  * @tutorial fdc3v2.raiseIntent
16764
16609
  */
16765
16610
  async raiseIntent(intent, context, app) {
16766
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
16767
- // we do not want to expose this error, just continue if this analytics-only call fails
16768
- });
16611
+ this.wire.recordAnalytic('fdc3-raise-intent');
16769
16612
  try {
16770
16613
  if (typeof app === 'string') {
16771
16614
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -16786,9 +16629,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16786
16629
  */
16787
16630
  async raiseIntentForContext(context, app) {
16788
16631
  // TODO: We have to do the same thing we do for raiseIntent here as well.
16789
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
16790
- // we do not want to expose this error, just continue if this analytics-only call fails
16791
- });
16632
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
16792
16633
  try {
16793
16634
  if (typeof app === 'string') {
16794
16635
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -16808,9 +16649,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16808
16649
  * @tutorial fdc3.addIntentListener
16809
16650
  */
16810
16651
  async addIntentListener(intent, handler) {
16811
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
16812
- // we do not want to expose this error, just continue if this analytics-only call fails
16813
- });
16652
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
16814
16653
  if (typeof intent !== 'string') {
16815
16654
  throw new Error('First argument must be an Intent name');
16816
16655
  }
@@ -16987,9 +16826,7 @@ class InteropModule extends base_1$2.Base {
16987
16826
  * ```
16988
16827
  */
16989
16828
  async init(name, override = defaultOverride) {
16990
- this.wire.sendAction('interop-init').catch(() => {
16991
- // don't expose, analytics-only call
16992
- });
16829
+ this.wire.recordAnalytic('interop-init');
16993
16830
  // Allows for manifest-level configuration, without having to override. (e.g. specifying custom context groups)
16994
16831
  const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
16995
16832
  const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
@@ -17038,9 +16875,7 @@ class InteropModule extends base_1$2.Base {
17038
16875
  * ```
17039
16876
  */
17040
16877
  connectSync(name, interopConfig) {
17041
- this.wire.sendAction('interop-connect-sync').catch(() => {
17042
- // don't expose, analytics-only call
17043
- });
16878
+ this.wire.recordAnalytic('interop-connect-sync');
17044
16879
  return new InteropClient_1.InteropClient(this.wire, this.wire.environment.whenReady().then(() => {
17045
16880
  return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
17046
16881
  payload: interopConfig
@@ -17209,9 +17044,7 @@ class SnapshotSource extends base_1$1.Base {
17209
17044
  * ```
17210
17045
  */
17211
17046
  async ready() {
17212
- this.wire.sendAction('snapshot-source-ready').catch((e) => {
17213
- // don't expose, analytics-only call
17214
- });
17047
+ this.wire.recordAnalytic('snapshot-source-ready');
17215
17048
  // eslint-disable-next-line no-async-promise-executor
17216
17049
  try {
17217
17050
  // If getClient was already called before this, do we have a timing issue where the channel might have been created but we missed the event but this still fails?
@@ -17227,9 +17060,7 @@ class SnapshotSource extends base_1$1.Base {
17227
17060
  *
17228
17061
  */
17229
17062
  async getSnapshot() {
17230
- this.wire.sendAction('snapshot-source-get-snapshot').catch((e) => {
17231
- // don't expose, analytics-only call
17232
- });
17063
+ this.wire.recordAnalytic('snapshot-source-get-snapshot');
17233
17064
  const client = await __classPrivateFieldGet$1(this, _SnapshotSource_getClient, "f").call(this);
17234
17065
  const response = (await client.dispatch('get-snapshot'));
17235
17066
  return (await response).snapshot;
@@ -17239,9 +17070,7 @@ class SnapshotSource extends base_1$1.Base {
17239
17070
  *
17240
17071
  */
17241
17072
  async applySnapshot(snapshot) {
17242
- this.wire.sendAction('snapshot-source-apply-snapshot').catch((e) => {
17243
- // don't expose, analytics-only call
17244
- });
17073
+ this.wire.recordAnalytic('snapshot-source-apply-snapshot');
17245
17074
  const client = await __classPrivateFieldGet$1(this, _SnapshotSource_getClient, "f").call(this);
17246
17075
  return client.dispatch('apply-snapshot', { snapshot });
17247
17076
  }
@@ -17282,9 +17111,7 @@ class SnapshotSourceModule extends base_1.Base {
17282
17111
  *
17283
17112
  */
17284
17113
  async init(provider) {
17285
- this.wire.sendAction('snapshot-source-init').catch((e) => {
17286
- // don't expose, analytics-only call
17287
- });
17114
+ this.wire.recordAnalytic('snapshot-source-init');
17288
17115
  if (typeof provider !== 'object' ||
17289
17116
  typeof provider.getSnapshot !== 'function' ||
17290
17117
  typeof provider.applySnapshot !== 'function') {
@@ -17308,9 +17135,7 @@ class SnapshotSourceModule extends base_1.Base {
17308
17135
  * ```
17309
17136
  */
17310
17137
  wrapSync(identity) {
17311
- this.wire.sendAction('snapshot-source-wrap-sync').catch((e) => {
17312
- // don't expose, analytics-only call
17313
- });
17138
+ this.wire.recordAnalytic('snapshot-source-wrap-sync');
17314
17139
  return new Instance_1.SnapshotSource(this.wire, identity);
17315
17140
  }
17316
17141
  /**
@@ -17324,9 +17149,7 @@ class SnapshotSourceModule extends base_1.Base {
17324
17149
  * ```
17325
17150
  */
17326
17151
  async wrap(identity) {
17327
- this.wire.sendAction('snapshot-source-wrap').catch((e) => {
17328
- // don't expose, analytics-only call
17329
- });
17152
+ this.wire.recordAnalytic('snapshot-source-wrap');
17330
17153
  return this.wrapSync(identity);
17331
17154
  }
17332
17155
  }
@@ -17544,7 +17367,7 @@ var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFie
17544
17367
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
17545
17368
  return (mod && mod.__esModule) ? mod : { "default": mod };
17546
17369
  };
17547
- var _Transport_wire, _Transport_fin;
17370
+ var _Transport_instances, _Transport_wire, _Transport_analyticsEnabled, _Transport_analyticsBuffer, _Transport_analyticsFlushTimeout, _Transport_fin, _Transport_flushAnalytics;
17548
17371
  Object.defineProperty(transport, "__esModule", { value: true });
17549
17372
  var Transport_1 = transport.Transport = void 0;
17550
17373
  const events_1$1 = require$$0;
@@ -17556,11 +17379,15 @@ const errors_1 = errors;
17556
17379
  class Transport extends events_1$1.EventEmitter {
17557
17380
  constructor(factory, environment, config) {
17558
17381
  super();
17382
+ _Transport_instances.add(this);
17559
17383
  this.wireListeners = new Map();
17560
17384
  this.topicRefMap = new Map();
17561
17385
  this.eventAggregator = new eventAggregator_1.default();
17562
17386
  this.messageHandlers = [this.eventAggregator.dispatchEvent];
17563
17387
  _Transport_wire.set(this, void 0);
17388
+ _Transport_analyticsEnabled.set(this, true);
17389
+ _Transport_analyticsBuffer.set(this, new Map());
17390
+ _Transport_analyticsFlushTimeout.set(this, void 0);
17564
17391
  // Typing as unknown to avoid circular dependency, should not be used directly.
17565
17392
  _Transport_fin.set(this, void 0);
17566
17393
  this.connectSync = () => {
@@ -17574,6 +17401,7 @@ class Transport extends events_1$1.EventEmitter {
17574
17401
  };
17575
17402
  __classPrivateFieldSet(this, _Transport_wire, factory(this.onmessage.bind(this)), "f");
17576
17403
  this.environment = environment;
17404
+ __classPrivateFieldSet(this, _Transport_analyticsEnabled, config.apiDiagnostics !== false, "f");
17577
17405
  this.sendRaw = __classPrivateFieldGet(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet(this, _Transport_wire, "f"));
17578
17406
  this.registerMessageHandler(this.handleMessage.bind(this));
17579
17407
  __classPrivateFieldGet(this, _Transport_wire, "f").on('disconnected', () => {
@@ -17581,6 +17409,9 @@ class Transport extends events_1$1.EventEmitter {
17581
17409
  handleNack({ reason: 'Remote connection has closed' });
17582
17410
  }
17583
17411
  this.wireListeners.clear();
17412
+ clearTimeout(__classPrivateFieldGet(this, _Transport_analyticsFlushTimeout, "f"));
17413
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, undefined, "f");
17414
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").clear();
17584
17415
  this.emit('disconnected');
17585
17416
  });
17586
17417
  const { uuid, name } = config;
@@ -17599,6 +17430,18 @@ class Transport extends events_1$1.EventEmitter {
17599
17430
  }
17600
17431
  __classPrivateFieldSet(this, _Transport_fin, _fin, "f");
17601
17432
  }
17433
+ recordAnalytic(action) {
17434
+ if (!__classPrivateFieldGet(this, _Transport_analyticsEnabled, "f"))
17435
+ return;
17436
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").set(action, (__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").get(action) ?? 0) + 1);
17437
+ if (__classPrivateFieldGet(this, _Transport_analyticsFlushTimeout, "f") === undefined) {
17438
+ const timeout = setTimeout(() => __classPrivateFieldGet(this, _Transport_instances, "m", _Transport_flushAnalytics).call(this), 30000);
17439
+ if (typeof timeout === 'object' && timeout !== null) {
17440
+ timeout.unref?.();
17441
+ }
17442
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, timeout, "f");
17443
+ }
17444
+ }
17602
17445
  shutdown() {
17603
17446
  const wire = __classPrivateFieldGet(this, _Transport_wire, "f");
17604
17447
  return wire.shutdown();
@@ -17762,7 +17605,16 @@ class Transport extends events_1$1.EventEmitter {
17762
17605
  }
17763
17606
  }
17764
17607
  Transport_1 = transport.Transport = Transport;
17765
- _Transport_wire = new WeakMap(), _Transport_fin = new WeakMap();
17608
+ _Transport_wire = new WeakMap(), _Transport_analyticsEnabled = new WeakMap(), _Transport_analyticsBuffer = new WeakMap(), _Transport_analyticsFlushTimeout = new WeakMap(), _Transport_fin = new WeakMap(), _Transport_instances = new WeakSet(), _Transport_flushAnalytics = function _Transport_flushAnalytics() {
17609
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, undefined, "f");
17610
+ if (__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").size === 0)
17611
+ return;
17612
+ const counts = Object.fromEntries(__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f"));
17613
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").clear();
17614
+ this.sendAction('send-analytics-batch', { counts }).catch(() => {
17615
+ // analytics flush failure is non-fatal, counts are already cleared
17616
+ });
17617
+ };
17766
17618
 
17767
17619
  var stubEnvironment = {};
17768
17620