@abraca/dabra 1.8.0 → 1.8.1

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/dist/index.d.ts CHANGED
@@ -826,6 +826,13 @@ declare class AbracadabraProvider extends AbracadabraBaseProvider {
826
826
  * the offline store is disabled or when no snapshot has been saved yet.
827
827
  */
828
828
  readonly ready: Promise<void>;
829
+ /**
830
+ * True once `_initFromOfflineStore()` has applied a non-empty snapshot or
831
+ * at least one pending update to the Y.Doc. Lets the UI decide to render
832
+ * cached content immediately instead of waiting for a server round-trip.
833
+ * Only meaningful after `await ready`.
834
+ */
835
+ hasCachedContent: boolean;
829
836
  constructor(configuration: AbracadabraProviderConfiguration);
830
837
  /**
831
838
  * Extract the server hostname from the provider configuration.
@@ -1446,7 +1453,14 @@ interface CompleteAbracadabraWSConfiguration {
1446
1453
  */
1447
1454
  WebSocketPolyfill: any;
1448
1455
  /**
1449
- * Disconnect when no message is received for the defined amount of milliseconds.
1456
+ * Disconnect and reconnect when no message is received for the defined amount
1457
+ * of milliseconds.
1458
+ *
1459
+ * Defaults to 30000 ms to match y-protocols/awareness `Awareness.outdatedTime`
1460
+ * (also 30 s). Awareness heartbeats are what normally keep this timer
1461
+ * resetting, so this value should be ≥ the largest `outdatedTime` of any
1462
+ * awareness instance attached to this socket. If you pass a custom awareness
1463
+ * with a non-default `outdatedTime`, pass the matching value here too.
1450
1464
  */
1451
1465
  messageReconnectTimeout: number;
1452
1466
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/dabra",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "abracadabra provider",
5
5
  "keywords": [
6
6
  "abracadabra",
@@ -129,6 +129,14 @@ export class AbracadabraProvider extends AbracadabraBaseProvider {
129
129
  */
130
130
  public readonly ready: Promise<void>;
131
131
 
132
+ /**
133
+ * True once `_initFromOfflineStore()` has applied a non-empty snapshot or
134
+ * at least one pending update to the Y.Doc. Lets the UI decide to render
135
+ * cached content immediately instead of waiting for a server round-trip.
136
+ * Only meaningful after `await ready`.
137
+ */
138
+ public hasCachedContent = false;
139
+
132
140
  constructor(configuration: AbracadabraProviderConfiguration) {
133
141
  // Derive URL and token from client when not explicitly set.
134
142
  const resolved = { ...configuration } as AbracadabraBaseProviderConfiguration;
@@ -225,9 +233,11 @@ export class AbracadabraProvider extends AbracadabraBaseProvider {
225
233
 
226
234
  if (snapshot) {
227
235
  Y.applyUpdate(this.document, snapshot, this.offlineStore);
236
+ this.hasCachedContent = true;
228
237
  }
229
238
  for (const update of pending) {
230
239
  Y.applyUpdate(this.document, update, this.offlineStore);
240
+ this.hasCachedContent = true;
231
241
  }
232
242
  }
233
243
 
@@ -55,7 +55,14 @@ export interface CompleteAbracadabraWSConfiguration {
55
55
  WebSocketPolyfill: any;
56
56
 
57
57
  /**
58
- * Disconnect when no message is received for the defined amount of milliseconds.
58
+ * Disconnect and reconnect when no message is received for the defined amount
59
+ * of milliseconds.
60
+ *
61
+ * Defaults to 30000 ms to match y-protocols/awareness `Awareness.outdatedTime`
62
+ * (also 30 s). Awareness heartbeats are what normally keep this timer
63
+ * resetting, so this value should be ≥ the largest `outdatedTime` of any
64
+ * awareness instance attached to this socket. If you pass a custom awareness
65
+ * with a non-default `outdatedTime`, pass the matching value here too.
59
66
  */
60
67
  messageReconnectTimeout: number;
61
68
  /**
@@ -121,7 +128,8 @@ export class AbracadabraWS extends EventEmitter {
121
128
  // @ts-ignore
122
129
  document: undefined,
123
130
  WebSocketPolyfill: undefined,
124
- // TODO: this should depend on awareness.outdatedTime
131
+ // Matches y-protocols/awareness Awareness.outdatedTime default (30 s).
132
+ // See the `messageReconnectTimeout` JSDoc on CompleteAbracadabraWSConfiguration.
125
133
  messageReconnectTimeout: 30000,
126
134
  // 1 second
127
135
  delay: 1000,