@fluidframework/driver-base 2.91.0 → 2.93.0

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.
@@ -3,14 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import {
7
- IDisposable,
8
- ITelemetryBaseProperties,
9
- LogLevel,
10
- } from "@fluidframework/core-interfaces";
6
+ import type { IDisposable, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
7
+ import { LogLevel } from "@fluidframework/core-interfaces";
11
8
  import { assert } from "@fluidframework/core-utils/internal";
12
- import { ConnectionMode } from "@fluidframework/driver-definitions";
13
- import {
9
+ import type { ConnectionMode } from "@fluidframework/driver-definitions";
10
+ import type {
14
11
  IAnyDriverError,
15
12
  IDocumentDeltaConnection,
16
13
  IDocumentDeltaConnectionEvents,
@@ -18,28 +15,30 @@ import {
18
15
  IConnect,
19
16
  IConnected,
20
17
  IDocumentMessage,
21
- type ISentSignalMessage,
18
+ ISentSignalMessage,
22
19
  ISignalClient,
23
20
  ITokenClaims,
24
- ScopeType,
25
21
  ISequencedDocumentMessage,
26
22
  ISignalMessage,
27
23
  } from "@fluidframework/driver-definitions/internal";
24
+ import { ScopeType } from "@fluidframework/driver-definitions/internal";
28
25
  import {
29
26
  UsageError,
30
27
  createGenericNetworkError,
31
28
  type DriverErrorTelemetryProps,
32
29
  } from "@fluidframework/driver-utils/internal";
33
- import {
30
+ import type {
31
+ IFluidErrorBase,
34
32
  ITelemetryLoggerExt,
35
- EventEmitterWithErrorHandling,
36
33
  MonitoringContext,
34
+ } from "@fluidframework/telemetry-utils/internal";
35
+ import {
36
+ EventEmitterWithErrorHandling,
37
37
  createChildMonitoringContext,
38
38
  extractLogSafeErrorProperties,
39
39
  getCircularReplacer,
40
40
  isFluidError,
41
41
  normalizeError,
42
- type IFluidErrorBase,
43
42
  } from "@fluidframework/telemetry-utils/internal";
44
43
  import type { Socket } from "socket.io-client";
45
44
 
@@ -179,7 +178,7 @@ export class DocumentDeltaConnection
179
178
  // Better flow might be to always unconditionally register all handlers on successful connection,
180
179
  // though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)
181
180
  assert(
182
- (this.listeners(event).length !== 0) === this.trackedListeners.has(event),
181
+ this.listeners(event).length > 0 === this.trackedListeners.has(event),
183
182
  0x20b /* "mismatch" */,
184
183
  );
185
184
  if (!this.trackedListeners.has(event)) {
@@ -285,7 +284,7 @@ export class DocumentDeltaConnection
285
284
  // latest ops. This could possibly indicate that initialMessages was called twice.
286
285
  assert(this.earlyOpHandlerAttached, 0x08e /* "Potentially missed initial messages" */);
287
286
  // We will lose ops and perf will tank as we need to go to storage to become current!
288
- assert(this.listeners("op").length !== 0, 0x08f /* "No op handler is setup!" */);
287
+ assert(this.listeners("op").length > 0, 0x08f /* "No op handler is setup!" */);
289
288
 
290
289
  this.removeEarlyOpHandler();
291
290
 
@@ -306,7 +305,7 @@ export class DocumentDeltaConnection
306
305
  */
307
306
  public get initialSignals(): ISignalMessage[] {
308
307
  this.checkNotDisposed();
309
- assert(this.listeners("signal").length !== 0, 0x090 /* "No signal handler is setup!" */);
308
+ assert(this.listeners("signal").length > 0, 0x090 /* "No signal handler is setup!" */);
310
309
 
311
310
  this.removeEarlySignalHandler();
312
311
 
@@ -381,12 +380,12 @@ export class DocumentDeltaConnection
381
380
  signal.targetClientId = targetClientId;
382
381
  }
383
382
  this.emitMessages("submitSignal", [signal]);
384
- } else if (targetClientId !== undefined) {
383
+ } else if (targetClientId === undefined) {
384
+ this.emitMessages("submitSignal", [[content]]);
385
+ } else {
385
386
  throw new UsageError(
386
387
  "Sending signals to specific client ids is not supported with this service.",
387
388
  );
388
- } else {
389
- this.emitMessages("submitSignal", [[content]]);
390
389
  }
391
390
  }
392
391
 
@@ -559,7 +558,7 @@ export class DocumentDeltaConnection
559
558
  // That's a WebSocket. Clear it as we can't log it.
560
559
  description.target = undefined;
561
560
  }
562
- } catch (_e) {
561
+ } catch {
563
562
  // TODO: document why we are ignoring the error here
564
563
  }
565
564
 
@@ -788,7 +787,7 @@ export class DocumentDeltaConnection
788
787
  return extractLogSafeErrorProperties(error, true).message;
789
788
  }
790
789
  // JSON.stringify drops Error.message
791
- const messagePrefix = error?.message !== undefined ? `${error.message}: ` : "";
790
+ const messagePrefix = error?.message === undefined ? "" : `${error.message}: `;
792
791
 
793
792
  // Websocket errors reported by engine.io-client.
794
793
  // They are Error objects with description containing WS error and description = "TransportError"
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
7
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
6
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
7
+ import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
8
8
 
9
9
  /**
10
10
  * Extract and return the w3c data.
@@ -111,9 +111,9 @@ export async function promiseRaceWithWinner<T>(
111
111
  promises: Promise<T>[],
112
112
  ): Promise<{ index: number; value: T }> {
113
113
  return new Promise((resolve, reject) => {
114
- promises.forEach((p, index) => {
114
+ for (const [index, p] of promises.entries()) {
115
115
  p.then((v): void => resolve({ index, value: v })).catch(reject);
116
- });
116
+ }
117
117
  });
118
118
  }
119
119
 
@@ -129,7 +129,7 @@ export function validateMessages(
129
129
  logger: ITelemetryLoggerExt,
130
130
  strict: boolean = true,
131
131
  ): void {
132
- if (messages.length !== 0) {
132
+ if (messages.length > 0) {
133
133
  const start = messages[0].sequenceNumber;
134
134
  const length = messages.length;
135
135
  const last = messages[length - 1].sequenceNumber;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/driver-base";
9
- export const pkgVersion = "2.91.0";
9
+ export const pkgVersion = "2.93.0";