@openfin/core 45.102.1 → 45.102.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2000,6 +2000,8 @@ declare type BeginUserBoundsChangingEvent = UserBoundsChangeEvent & {
2000
2000
  type: 'begin-user-bounds-changing';
2001
2001
  };
2002
2002
 
2003
+ declare type BFCacheRestoreListener = () => void | Promise<void>;
2004
+
2003
2005
  /**
2004
2006
  * A rule prescribing content creation that should be blocked.
2005
2007
  *
@@ -5387,6 +5389,16 @@ declare interface Environment {
5387
5389
  resolveLayout(layoutManager: OpenFin_2.LayoutManager<OpenFin_2.LayoutSnapshot>, layoutIdentity: OpenFin_2.LayoutIdentity): Promise<any>;
5388
5390
  initPlatform(fin: OpenFin_2.Fin<OpenFin_2.EntityType>, ...args: Parameters<OpenFin_2.Fin['Platform']['init']>): ReturnType<OpenFin_2.Fin['Platform']['init']>;
5389
5391
  observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): () => void;
5392
+ /**
5393
+ * Registers a listener invoked when the current page has been restored from the
5394
+ * browser's back/forward cache. Stateful APIs (e.g. channels) use this to re-establish
5395
+ * connections that were torn down while the page was cached.
5396
+ *
5397
+ * No-op in environments that cannot be bfcached.
5398
+ *
5399
+ * @returns a function that unregisters the listener.
5400
+ */
5401
+ onBFCacheRestore(listener: BFCacheRestoreListener): () => void;
5390
5402
  writeToken(path: string, token: string): Promise<string>;
5391
5403
  retrievePort(config: NewConnectConfig): Promise<number>;
5392
5404
  getNextMessageId(): any;
@@ -2000,6 +2000,8 @@ declare type BeginUserBoundsChangingEvent = UserBoundsChangeEvent & {
2000
2000
  type: 'begin-user-bounds-changing';
2001
2001
  };
2002
2002
 
2003
+ declare type BFCacheRestoreListener = () => void | Promise<void>;
2004
+
2003
2005
  /**
2004
2006
  * A rule prescribing content creation that should be blocked.
2005
2007
  *
@@ -5387,6 +5389,16 @@ declare interface Environment {
5387
5389
  resolveLayout(layoutManager: OpenFin_2.LayoutManager<OpenFin_2.LayoutSnapshot>, layoutIdentity: OpenFin_2.LayoutIdentity): Promise<any>;
5388
5390
  initPlatform(fin: OpenFin_2.Fin<OpenFin_2.EntityType>, ...args: Parameters<OpenFin_2.Fin['Platform']['init']>): ReturnType<OpenFin_2.Fin['Platform']['init']>;
5389
5391
  observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): () => void;
5392
+ /**
5393
+ * Registers a listener invoked when the current page has been restored from the
5394
+ * browser's back/forward cache. Stateful APIs (e.g. channels) use this to re-establish
5395
+ * connections that were torn down while the page was cached.
5396
+ *
5397
+ * No-op in environments that cannot be bfcached.
5398
+ *
5399
+ * @returns a function that unregisters the listener.
5400
+ */
5401
+ onBFCacheRestore(listener: BFCacheRestoreListener): () => void;
5390
5402
  writeToken(path: string, token: string): Promise<string>;
5391
5403
  retrievePort(config: NewConnectConfig): Promise<number>;
5392
5404
  getNextMessageId(): any;
@@ -2000,6 +2000,8 @@ declare type BeginUserBoundsChangingEvent = UserBoundsChangeEvent & {
2000
2000
  type: 'begin-user-bounds-changing';
2001
2001
  };
2002
2002
 
2003
+ declare type BFCacheRestoreListener = () => void | Promise<void>;
2004
+
2003
2005
  /**
2004
2006
  * A rule prescribing content creation that should be blocked.
2005
2007
  *
@@ -5387,6 +5389,16 @@ declare interface Environment {
5387
5389
  resolveLayout(layoutManager: OpenFin_2.LayoutManager<OpenFin_2.LayoutSnapshot>, layoutIdentity: OpenFin_2.LayoutIdentity): Promise<any>;
5388
5390
  initPlatform(fin: OpenFin_2.Fin<OpenFin_2.EntityType>, ...args: Parameters<OpenFin_2.Fin['Platform']['init']>): ReturnType<OpenFin_2.Fin['Platform']['init']>;
5389
5391
  observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): () => void;
5392
+ /**
5393
+ * Registers a listener invoked when the current page has been restored from the
5394
+ * browser's back/forward cache. Stateful APIs (e.g. channels) use this to re-establish
5395
+ * connections that were torn down while the page was cached.
5396
+ *
5397
+ * No-op in environments that cannot be bfcached.
5398
+ *
5399
+ * @returns a function that unregisters the listener.
5400
+ */
5401
+ onBFCacheRestore(listener: BFCacheRestoreListener): () => void;
5390
5402
  writeToken(path: string, token: string): Promise<string>;
5391
5403
  retrievePort(config: NewConnectConfig): Promise<number>;
5392
5404
  getNextMessageId(): any;
package/out/stub.d.ts CHANGED
@@ -2032,6 +2032,8 @@ declare type BeginUserBoundsChangingEvent = UserBoundsChangeEvent & {
2032
2032
  type: 'begin-user-bounds-changing';
2033
2033
  };
2034
2034
 
2035
+ declare type BFCacheRestoreListener = () => void | Promise<void>;
2036
+
2035
2037
  /**
2036
2038
  * A rule prescribing content creation that should be blocked.
2037
2039
  *
@@ -5498,6 +5500,16 @@ declare interface Environment {
5498
5500
  resolveLayout(layoutManager: OpenFin_2.LayoutManager<OpenFin_2.LayoutSnapshot>, layoutIdentity: OpenFin_2.LayoutIdentity): Promise<any>;
5499
5501
  initPlatform(fin: OpenFin_2.Fin<OpenFin_2.EntityType>, ...args: Parameters<OpenFin_2.Fin['Platform']['init']>): ReturnType<OpenFin_2.Fin['Platform']['init']>;
5500
5502
  observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): () => void;
5503
+ /**
5504
+ * Registers a listener invoked when the current page has been restored from the
5505
+ * browser's back/forward cache. Stateful APIs (e.g. channels) use this to re-establish
5506
+ * connections that were torn down while the page was cached.
5507
+ *
5508
+ * No-op in environments that cannot be bfcached.
5509
+ *
5510
+ * @returns a function that unregisters the listener.
5511
+ */
5512
+ onBFCacheRestore(listener: BFCacheRestoreListener): () => void;
5501
5513
  writeToken(path: string, token: string): Promise<string>;
5502
5514
  retrievePort(config: NewConnectConfig): Promise<number>;
5503
5515
  getNextMessageId(): any;
package/out/stub.js CHANGED
@@ -17134,6 +17134,15 @@ class Transport extends events.EventEmitter {
17134
17134
  const { uuid, name } = config;
17135
17135
  const entityType = this.environment.getCurrentEntityType();
17136
17136
  this.me = getBaseMe(entityType, uuid, name);
17137
+ // Registered here rather than per-caller so that a restoration is logged exactly once,
17138
+ // however many parts of the adapter go on to subscribe.
17139
+ this.environment.onBFCacheRestore(async () => {
17140
+ await this.sendAction('write-to-log', {
17141
+ level: 'verbose',
17142
+ message: `Page restored from the back/forward cache for ${uuid}/${name}`,
17143
+ target: {}
17144
+ });
17145
+ });
17137
17146
  }
17138
17147
  getFin() {
17139
17148
  if (!__classPrivateFieldGet(this, _Transport_fin, "f")) {
@@ -17376,6 +17385,11 @@ class StubEnvironment {
17376
17385
  observeBounds() {
17377
17386
  throw new Error(environmentUnsupportedMessage);
17378
17387
  }
17388
+ onBFCacheRestore(listener) {
17389
+ // Deliberately not throwing: callers register unconditionally, including from the
17390
+ // Transport constructor, which the stub environment has to survive.
17391
+ return () => undefined;
17392
+ }
17379
17393
  writeToken(path, token) {
17380
17394
  throw new Error(environmentUnsupportedMessage);
17381
17395
  }
package/out/stub.mjs CHANGED
@@ -17092,6 +17092,15 @@ class Transport extends EventEmitter {
17092
17092
  const { uuid, name } = config;
17093
17093
  const entityType = this.environment.getCurrentEntityType();
17094
17094
  this.me = getBaseMe(entityType, uuid, name);
17095
+ // Registered here rather than per-caller so that a restoration is logged exactly once,
17096
+ // however many parts of the adapter go on to subscribe.
17097
+ this.environment.onBFCacheRestore(async () => {
17098
+ await this.sendAction('write-to-log', {
17099
+ level: 'verbose',
17100
+ message: `Page restored from the back/forward cache for ${uuid}/${name}`,
17101
+ target: {}
17102
+ });
17103
+ });
17095
17104
  }
17096
17105
  getFin() {
17097
17106
  if (!__classPrivateFieldGet(this, _Transport_fin, "f")) {
@@ -17334,6 +17343,11 @@ class StubEnvironment {
17334
17343
  observeBounds() {
17335
17344
  throw new Error(environmentUnsupportedMessage);
17336
17345
  }
17346
+ onBFCacheRestore(listener) {
17347
+ // Deliberately not throwing: callers register unconditionally, including from the
17348
+ // Transport constructor, which the stub environment has to survive.
17349
+ return () => undefined;
17350
+ }
17337
17351
  writeToken(path, token) {
17338
17352
  throw new Error(environmentUnsupportedMessage);
17339
17353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "45.102.1",
3
+ "version": "45.102.2",
4
4
  "description": "The core renderer entry point of OpenFin",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "out/stub.js",