@openfin/core 47.100.26 → 47.100.29

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.d.ts CHANGED
@@ -2798,22 +2798,17 @@ declare class ChannelBase {
2798
2798
  */
2799
2799
  declare class ChannelClient extends ChannelBase {
2800
2800
  #private;
2801
- private disconnectListener;
2802
- private endpointId;
2803
- /**
2804
- * @internal
2805
- */
2806
- static closeChannelByEndpointId(id: string): void;
2807
2801
  /**
2808
2802
  * @internal
2809
- * closes the corresponding channel and invokes the disconnect listener if an event payload is passed.
2810
2803
  */
2811
- static handleProviderDisconnect(eventPayload: OpenFin_2.ProviderIdentity): void;
2804
+ constructor(config: ChannelClientConfig);
2805
+ protected processAction: (action: string, payload: any, senderIdentity: OpenFin_2.ProviderIdentity | OpenFin_2.ClientIdentity) => Promise<any>;
2812
2806
  /**
2813
2807
  * @internal
2808
+ * Closes the client. `notifyRuntime` sends `disconnect-from-channel` for the current endpoint; `emitEvent` then
2809
+ * fires the onDisconnection listener, even if notifying the runtime failed.
2814
2810
  */
2815
- constructor(routingInfo: OpenFin_2.RoutingInfo, close: () => Promise<void>, strategy: AnyStrategy);
2816
- protected processAction: (action: string, payload: any, senderIdentity: OpenFin_2.ProviderIdentity | OpenFin_2.ClientIdentity) => Promise<any>;
2811
+ [teardown](emitEvent?: boolean, notifyRuntime?: boolean): Promise<void>;
2817
2812
  /**
2818
2813
  * a read-only provider identity
2819
2814
  */
@@ -2845,8 +2840,8 @@ declare class ChannelClient extends ChannelBase {
2845
2840
  */
2846
2841
  dispatch(action: string, payload?: any): Promise<any>;
2847
2842
  /**
2848
- * Register a listener that is called on provider disconnection. It is passed the disconnection event of the
2849
- * disconnecting provider.
2843
+ * Register a listener that is called when this client loses its channel: the provider disconnects, the
2844
+ * endpoint drops, or a self-heal fails. It is passed the provider identity.
2850
2845
  *
2851
2846
  * @param listener
2852
2847
  *
@@ -2863,6 +2858,43 @@ declare class ChannelClient extends ChannelBase {
2863
2858
  * ```
2864
2859
  */
2865
2860
  onDisconnection(listener: OpenFin_2.ChannelProviderDisconnectionListener): void;
2861
+ /**
2862
+ * Register a listener that is called each time this client transparently self-heals its connection to the
2863
+ * provider.
2864
+ *
2865
+ * @remarks
2866
+ * A channel client's underlying endpoint is torn down while its document sits in the back/forward cache
2867
+ * (bfcache). If the back/forward cache is supported and the document is restored from it, the client
2868
+ * automatically re-handshakes with the provider and swaps in a fresh endpoint; all of this client's
2869
+ * `register`/middleware handlers are preserved, so no re-registration is required.
2870
+ *
2871
+ * A restore is not guaranteed: Chromium may evict a cached document at any time, in which case navigating
2872
+ * back reloads the page and a new client must connect.
2873
+ *
2874
+ * This listener fires once per successful reconnect, after the new endpoint is live, and can fire multiple
2875
+ * times over the client's lifetime. It is triggered when the document is restored from the back/forward
2876
+ * cache (a bfcache `pageshow`). It does not fire for the initial connection, nor after
2877
+ * {@link ChannelClient#disconnect disconnect}. {@link ChannelClient#onDisconnection onDisconnection} fires
2878
+ * when the provider or endpoint goes away.
2879
+ *
2880
+ * The info provides the reconnected {@link OpenFin.ProviderIdentity provider identity} along with
2881
+ * the previous and new endpoint ids.
2882
+ *
2883
+ * @param listener
2884
+ *
2885
+ * @example
2886
+ *
2887
+ * ```js
2888
+ * (async () => {
2889
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
2890
+ *
2891
+ * client.onReconnection(({ providerIdentity, previousEndpointId, endpointId }) => {
2892
+ * console.log(`Reconnected to ${providerIdentity.channelName}: ${previousEndpointId} -> ${endpointId}`);
2893
+ * });
2894
+ * })();
2895
+ * ```
2896
+ */
2897
+ onReconnection(listener: OpenFin_2.ChannelClientReconnectionListener): void;
2866
2898
  /**
2867
2899
  * Disconnects the client from the channel.
2868
2900
  *
@@ -2877,20 +2909,57 @@ declare class ChannelClient extends ChannelBase {
2877
2909
  * ```
2878
2910
  */
2879
2911
  disconnect(): Promise<void>;
2880
- sendDisconnectAction(): Promise<void>;
2881
2912
  /**
2882
2913
  * @internal
2883
- * Writing this as a static to keep code together, but in environments with a wire, this will be DI'd into the protectedObject class as close.
2914
+ * Notify the runtime that the current endpoint has disconnected.
2884
2915
  */
2885
- static wireClose(wire: Transport, providerIdentity: OpenFin_2.ProviderIdentity, endpointId: string): Promise<void>;
2916
+ sendDisconnectAction(): Promise<void>;
2886
2917
  }
2887
2918
 
2888
2919
  declare type ChannelClient_2 = OpenFin_2.ChannelClient;
2889
2920
 
2921
+ /**
2922
+ * @internal
2923
+ * `wire` and `reestablish` let the client notify the runtime on disconnect and self-heal after a BF-Cache restore.
2924
+ * The in-memory transport has no runtime and passes no-ops.
2925
+ */
2926
+ declare type ChannelClientConfig = {
2927
+ initialConnection: EndpointConnectionInstance;
2928
+ wire: Pick<Transport, 'sendAction'> & {
2929
+ environment: Pick<Transport['environment'], 'onBFCacheRestore'>;
2930
+ };
2931
+ reestablish: () => Promise<EndpointConnectionInstance>;
2932
+ };
2933
+
2890
2934
  declare type ChannelClientConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => Promise<any> | any;
2891
2935
 
2892
2936
  declare type ChannelClientDisconnectionListener = (identity: ClientIdentity) => any;
2893
2937
 
2938
+ /**
2939
+ * Info passed to a {@link ChannelClient.onReconnection} listener when a channel client
2940
+ * re-establishes its connection to the provider after its endpoint was torn down.
2941
+ */
2942
+ declare type ChannelClientReconnectionInfo = {
2943
+ /** Identity of the provider this client re-established its connection to. */
2944
+ providerIdentity: ProviderIdentity_4;
2945
+ /** The client's endpoint id before the reconnect (now torn down). */
2946
+ previousEndpointId: string;
2947
+ /** The client's endpoint id after the reconnect. */
2948
+ endpointId: string;
2949
+ };
2950
+
2951
+ /**
2952
+ * Listener registered via {@link ChannelClient.onReconnection}, called once each time the client self-heals its
2953
+ * connection to the provider.
2954
+ *
2955
+ * Currently, this will only occur during a [bfcache](https://developer.mozilla.org/en-US/docs/Glossary/bfcache) Restore.
2956
+ *
2957
+ * For example, if the Channel Client belongs to a Window / View that is compatible with the bfcache, and
2958
+ * the Window / View is navigated away from and then back to using the history API, the Channel Client will re-establish its connection to the provider if it still
2959
+ * exists.
2960
+ */
2961
+ declare type ChannelClientReconnectionListener = (info: ChannelClientReconnectionInfo) => void;
2962
+
2894
2963
  /**
2895
2964
  * Options provided on a client connection to a channel.
2896
2965
  *
@@ -5416,6 +5485,14 @@ declare type EndLoadEvent = BaseEvent_5 & {
5416
5485
  isMain: boolean;
5417
5486
  };
5418
5487
 
5488
+ /**
5489
+ * @internal
5490
+ */
5491
+ declare type EndpointConnectionInstance = {
5492
+ routingInfo: OpenFin_2.RoutingInfo;
5493
+ strategy: AnyStrategy;
5494
+ };
5495
+
5419
5496
  /**
5420
5497
  * Generated at the end of a user-driven change to a window's size or position.
5421
5498
  *
@@ -7218,6 +7295,11 @@ declare class InterApplicationBus extends Base {
7218
7295
  subscriberRemoved: string;
7219
7296
  };
7220
7297
  private refCounter;
7298
+ /**
7299
+ * One entry per subscription the runtime knows about, keyed by the same subscription key the
7300
+ * emitter and the ref counter use. Listeners sharing a key share a single entry.
7301
+ */
7302
+ private activeSubscriptions;
7221
7303
  protected emitter: EventEmitter;
7222
7304
  on: any;
7223
7305
  removeAllListeners: any;
@@ -7260,16 +7342,21 @@ declare class InterApplicationBus extends Base {
7260
7342
  * Subscribes to messages from the specified application on the specified topic.
7261
7343
  * @param source This object is described in the Identity in the typedef
7262
7344
  * @param topic The topic on which the message is sent
7263
- * @param listener A function that is called when a message has
7264
- * been received. It is passed the message, uuid and name of the sending application.
7345
+ * @param listener A function that is called when a message has been received. It is passed
7346
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
7265
7347
  * The message can be either a primitive data type (string, number, or boolean) or
7266
7348
  * composite data type (object, array) that is composed of other primitive or composite
7267
7349
  * data types
7268
7350
  *
7351
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
7352
+ * which passes `(message, uuid, name)` as separate arguments.
7353
+ *
7269
7354
  * @example
7270
7355
  * ```js
7271
7356
  * // subscribe to a specified application
7272
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
7357
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
7358
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
7359
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
7273
7360
  *
7274
7361
  * // subscribe to wildcard
7275
7362
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
@@ -11521,6 +11608,8 @@ declare namespace OpenFin_2 {
11521
11608
  ChannelClientConnectionListener,
11522
11609
  ChannelClientDisconnectionListener,
11523
11610
  ChannelProviderDisconnectionListener,
11611
+ ChannelClientReconnectionInfo,
11612
+ ChannelClientReconnectionListener,
11524
11613
  RoutingInfo,
11525
11614
  DownloadShelfOptions,
11526
11615
  SnapZoneOptions,
@@ -18035,6 +18124,8 @@ declare type TaskBar = DipScaleRects & {
18035
18124
  rect: RectangleByEdgePositions;
18036
18125
  };
18037
18126
 
18127
+ declare const teardown: unique symbol;
18128
+
18038
18129
  /**
18039
18130
  * @interface
18040
18131
  */