diff --git a/api-report/driver-base.api.md b/api-report/driver-base.api.md index 296afb0a7c3f..3673833090e7 100644 --- a/api-report/driver-base.api.md +++ b/api-report/driver-base.api.md @@ -18,11 +18,12 @@ import { ISignalClient } from '@fluidframework/protocol-definitions'; import { ISignalMessage } from '@fluidframework/protocol-definitions'; import { ITelemetryLogger } from '@fluidframework/common-definitions'; import { ITokenClaims } from '@fluidframework/protocol-definitions'; +import type { Socket } from 'socket.io-client'; import { TypedEventEmitter } from '@fluidframework/common-utils'; // @public export class DocumentDeltaConnection extends TypedEventEmitter implements IDocumentDeltaConnection, IDisposable { - protected constructor(socket: SocketIOClient.Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean); + protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean); // (undocumented) protected addTrackedListener(event: string, listener: (...args: any[]) => void): void; checkpointSequenceNumber: number | undefined; @@ -68,7 +69,7 @@ export class DocumentDeltaConnection extends TypedEventEmitter, getWebsocketToken: TokenFetcher | undefined, getSocketIOClient: () => Promise, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy); + constructor(getStorageToken: TokenFetcher, getWebsocketToken: TokenFetcher | undefined, getSocketIOClient: () => Promise, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy); // (undocumented) createContainer(createNewSummary: ISummaryTree | undefined, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise; // (undocumented) diff --git a/lerna-package-lock.json b/lerna-package-lock.json index a3420838977b..df47f31af0cb 100644 --- a/lerna-package-lock.json +++ b/lerna-package-lock.json @@ -13296,11 +13296,6 @@ "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-7.5.2.tgz", "integrity": "sha512-T+m89VdXj/eidZyejvmoP9jivXgBDdkOSBVQjU9kF349NEx10QdPNGxHeZUaj1IlJ32/ewdyXJjnJxyxJroYwg==" }, - "@types/socket.io-client": { - "version": "1.4.36", - "resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.36.tgz", - "integrity": "sha512-ZJWjtFBeBy1kRSYpVbeGYTElf6BqPQUkXDlHHD4k/42byCN5Rh027f4yARHCink9sKAkbtGZXEAmR0ZCnc2/Ag==" - }, "@types/source-list-map": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", diff --git a/packages/drivers/driver-base/package.json b/packages/drivers/driver-base/package.json index 4d9f32fb51e4..da775f8a0b44 100644 --- a/packages/drivers/driver-base/package.json +++ b/packages/drivers/driver-base/package.json @@ -46,7 +46,6 @@ "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", - "@types/socket.io-client": "^1.4.32", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", "concurrently": "^6.2.0", @@ -59,6 +58,7 @@ "eslint-plugin-react": "~7.28.0", "eslint-plugin-unicorn": "~40.0.0", "rimraf": "^2.6.2", + "socket.io-client": "^4.4.1", "typescript": "~4.1.3", "typescript-formatter": "7.1.0" } diff --git a/packages/drivers/driver-base/src/documentDeltaConnection.ts b/packages/drivers/driver-base/src/documentDeltaConnection.ts index 498fb5a79b31..01349b1a803f 100644 --- a/packages/drivers/driver-base/src/documentDeltaConnection.ts +++ b/packages/drivers/driver-base/src/documentDeltaConnection.ts @@ -28,6 +28,7 @@ import { loggerToMonitoringContext, MonitoringContext, } from "@fluidframework/telemetry-utils"; +import type { Socket } from "socket.io-client"; // For now, this package is versioned and released in unison with the specific drivers import { pkgVersion as driverVersion } from "./packageVersion"; @@ -107,7 +108,7 @@ export class DocumentDeltaConnection * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure */ protected constructor( - protected readonly socket: SocketIOClient.Socket, + protected readonly socket: Socket, public documentId: string, logger: ITelemetryLogger, private readonly enableLongPollingDowngrades: boolean = false, diff --git a/packages/drivers/driver-base/tsconfig.json b/packages/drivers/driver-base/tsconfig.json index f579caf4a3a6..d6f00b7bb583 100644 --- a/packages/drivers/driver-base/tsconfig.json +++ b/packages/drivers/driver-base/tsconfig.json @@ -7,9 +7,6 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./dist", - "types": [ - "@types/socket.io-client" - ] }, "include": [ "src/**/*" diff --git a/packages/drivers/driver-web-cache/package.json b/packages/drivers/driver-web-cache/package.json index f2c0c169e837..5664079a7ccd 100644 --- a/packages/drivers/driver-web-cache/package.json +++ b/packages/drivers/driver-web-cache/package.json @@ -48,7 +48,6 @@ "@rushstack/eslint-config": "^2.5.1", "@types/jest": "22.2.3", "@types/node": "^14.18.0", - "@types/socket.io-client": "^1.4.32", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", "concurrently": "^6.2.0", diff --git a/packages/drivers/iframe-driver/package.json b/packages/drivers/iframe-driver/package.json index ff42e932cc53..f100ab688506 100644 --- a/packages/drivers/iframe-driver/package.json +++ b/packages/drivers/iframe-driver/package.json @@ -50,7 +50,6 @@ "@types/mocha": "^8.2.2", "@types/nock": "^9.3.0", "@types/node": "^14.18.0", - "@types/socket.io-client": "^1.4.32", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", "concurrently": "^6.2.0", diff --git a/packages/drivers/local-driver/package.json b/packages/drivers/local-driver/package.json index 28348e1e1d5b..769841272115 100644 --- a/packages/drivers/local-driver/package.json +++ b/packages/drivers/local-driver/package.json @@ -93,6 +93,7 @@ "mocha": "^8.4.0", "nyc": "^15.0.0", "rimraf": "^2.6.2", + "socket.io-client": "^4.4.1", "typescript": "~4.1.3", "typescript-formatter": "7.1.0" } diff --git a/packages/drivers/local-driver/src/localDocumentDeltaConnection.ts b/packages/drivers/local-driver/src/localDocumentDeltaConnection.ts index dfc552df6614..ebf8ae92b24c 100644 --- a/packages/drivers/local-driver/src/localDocumentDeltaConnection.ts +++ b/packages/drivers/local-driver/src/localDocumentDeltaConnection.ts @@ -13,6 +13,7 @@ import { } from "@fluidframework/protocol-definitions"; import { LocalWebSocketServer } from "@fluidframework/server-local-server"; import * as core from "@fluidframework/server-services-core"; +import type { Socket } from "socket.io-client"; const testProtocolVersions = ["^0.3.0", "^0.2.0", "^0.1.0"]; @@ -42,7 +43,7 @@ export class LocalDocumentDeltaConnection extends DocumentDeltaConnection { // Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky // but should be fine because this delta connection is for local use only. - const socketWithListener = socket as unknown as SocketIOClient.Socket; + const socketWithListener = socket as unknown as Socket; const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id); @@ -58,7 +59,7 @@ export class LocalDocumentDeltaConnection extends DocumentDeltaConnection { return deltaConnection; } - constructor(socket: SocketIOClient.Socket, documentId: string) { + constructor(socket: Socket, documentId: string) { super(socket, documentId, new TelemetryNullLogger()); } diff --git a/packages/drivers/odsp-driver/package.json b/packages/drivers/odsp-driver/package.json index c6f6f6cd4f62..75b2b819fc7f 100644 --- a/packages/drivers/odsp-driver/package.json +++ b/packages/drivers/odsp-driver/package.json @@ -85,7 +85,6 @@ "@types/mocha": "^8.2.2", "@types/node-fetch": "^2.5.10", "@types/sha.js": "^2.4.0", - "@types/socket.io-client": "^1.4.32", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", "concurrently": "^6.2.0", diff --git a/packages/drivers/odsp-driver/src/getSocketIo.ts b/packages/drivers/odsp-driver/src/getSocketIo.ts index 7f4179e7e1f1..275a8d62d006 100644 --- a/packages/drivers/odsp-driver/src/getSocketIo.ts +++ b/packages/drivers/odsp-driver/src/getSocketIo.ts @@ -9,6 +9,6 @@ import io from "socket.io-client"; * This function only exists to create an ESM wrapper around the socket.io client module * for compatibility with ESM dynamic imports */ -export function getSocketIo(): SocketIOClientStatic { +export function getSocketIo(): typeof io { return io; } diff --git a/packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts b/packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts index 4bb80b65ed6b..8b6f860fce78 100644 --- a/packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts +++ b/packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts @@ -16,6 +16,7 @@ import { ISequencedDocumentMessage, ISignalMessage, } from "@fluidframework/protocol-definitions"; +import type { Socket, io as SocketIOClientStatic } from "socket.io-client"; import { v4 as uuid } from "uuid"; import { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from "./contracts"; import { EpochTracker } from "./epochTracker"; @@ -42,7 +43,7 @@ export interface ISocketEvents extends IEvent { class SocketReference extends TypedEventEmitter { private references: number = 1; private delayDeleteTimeout: ReturnType | undefined; - private _socket: SocketIOClient.Socket | undefined; + private _socket: Socket | undefined; // When making decisions about socket reuse, we do not reuse disconnected socket. // But we want to differentiate the following case from disconnected case: @@ -106,7 +107,7 @@ class SocketReference extends TypedEventEmitter { return this._socket; } - public constructor(public readonly key: string, socket: SocketIOClient.Socket) { + public constructor(public readonly key: string, socket: Socket) { super(); this._socket = socket; @@ -198,7 +199,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection { tenantId: string, documentId: string, token: string | null, - io: SocketIOClientStatic, + io: typeof SocketIOClientStatic, client: IClient, url: string, telemetryLogger: ITelemetryLogger, @@ -300,7 +301,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection { * Gets or create a socket io connection for the given key */ private static getOrCreateSocketIoReference( - io: SocketIOClientStatic, + io: typeof SocketIOClientStatic, timeoutMs: number, key: string, url: string, @@ -337,7 +338,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection { * @param enableMultiplexing - If the websocket is multiplexing multiple documents */ private constructor( - socket: SocketIOClient.Socket, + socket: Socket, documentId: string, socketReference: SocketReference, logger: ITelemetryLogger, diff --git a/packages/drivers/odsp-driver/src/odspDocumentService.ts b/packages/drivers/odsp-driver/src/odspDocumentService.ts index 4db30124a1c4..36a2d29d32c7 100644 --- a/packages/drivers/odsp-driver/src/odspDocumentService.ts +++ b/packages/drivers/odsp-driver/src/odspDocumentService.ts @@ -33,6 +33,7 @@ import { InstrumentedStorageTokenFetcher, OdspErrorType, } from "@fluidframework/odsp-driver-definitions"; +import type { io as SocketIOClientStatic } from "socket.io-client"; import { HostStoragePolicyInternal, ISocketStorageDiscovery } from "./contracts"; import { IOdspCache } from "./odspCache"; import { OdspDeltaStorageService, OdspDeltaStorageWithCache } from "./odspDeltaStorageService"; @@ -73,7 +74,7 @@ export class OdspDocumentService implements IDocumentService { getStorageToken: InstrumentedStorageTokenFetcher, getWebsocketToken: ((options: TokenFetchOptions) => Promise) | undefined, logger: ITelemetryLogger, - socketIoClientFactory: () => Promise, + socketIoClientFactory: () => Promise, cache: IOdspCache, hostPolicy: HostStoragePolicy, epochTracker: EpochTracker, @@ -123,7 +124,7 @@ export class OdspDocumentService implements IDocumentService { private readonly getStorageToken: InstrumentedStorageTokenFetcher, private readonly getWebsocketToken: ((options: TokenFetchOptions) => Promise) | undefined, logger: ITelemetryLogger, - private readonly socketIoClientFactory: () => Promise, + private readonly socketIoClientFactory: () => Promise, private readonly cache: IOdspCache, hostPolicy: HostStoragePolicy, private readonly epochTracker: EpochTracker, @@ -423,7 +424,7 @@ export class OdspDocumentService implements IDocumentService { tenantId: string, documentId: string, token: string | null, - io: SocketIOClientStatic, + io: typeof SocketIOClientStatic, client: IClient, webSocketUrl: string, ): Promise { diff --git a/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts b/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts index 507badb2dbed..ee549f04815a 100644 --- a/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts +++ b/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts @@ -24,6 +24,7 @@ import { IFileEntry, IOdspUrlParts, } from "@fluidframework/odsp-driver-definitions"; +import type { io as SocketIOClientStatic } from "socket.io-client"; import { v4 as uuid } from "uuid"; import { LocalPersistentCache, @@ -133,7 +134,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { constructor( private readonly getStorageToken: TokenFetcher, private readonly getWebsocketToken: TokenFetcher | undefined, - private readonly getSocketIOClient: () => Promise, + private readonly getSocketIOClient: () => Promise, protected persistedCache: IPersistedCache = new LocalPersistentCache(), private readonly hostPolicy: HostStoragePolicy = {}, ) { diff --git a/packages/drivers/routerlicious-driver/package.json b/packages/drivers/routerlicious-driver/package.json index 1e012f2b2f7c..3dae09f6d2fa 100644 --- a/packages/drivers/routerlicious-driver/package.json +++ b/packages/drivers/routerlicious-driver/package.json @@ -83,7 +83,6 @@ "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/nock": "^9.3.0", - "@types/socket.io-client": "^1.4.32", "@types/url-parse": "1.4.4", "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/packages/drivers/routerlicious-driver/src/documentDeltaConnection.ts b/packages/drivers/routerlicious-driver/src/documentDeltaConnection.ts index 494eec10b21f..8077d3e0dc6e 100644 --- a/packages/drivers/routerlicious-driver/src/documentDeltaConnection.ts +++ b/packages/drivers/routerlicious-driver/src/documentDeltaConnection.ts @@ -8,6 +8,7 @@ import { DocumentDeltaConnection } from "@fluidframework/driver-base"; import { IDocumentDeltaConnection } from "@fluidframework/driver-definitions"; import { IAnyDriverError } from "@fluidframework/driver-utils"; import { IClient, IConnect } from "@fluidframework/protocol-definitions"; +import type { io as SocketIOClientStatic } from "socket.io-client"; import { errorObjectFromSocketError, IR11sSocketError } from "./errorUtils"; const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"]; @@ -21,7 +22,7 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection tenantId: string, id: string, token: string | null, - io: SocketIOClientStatic, + io: typeof SocketIOClientStatic, client: IClient, url: string, logger: ITelemetryLogger, diff --git a/tools/build-tools/src/fluidBuild/npmDepChecker.ts b/tools/build-tools/src/fluidBuild/npmDepChecker.ts index ef02ae658c7b..82233e64ac38 100644 --- a/tools/build-tools/src/fluidBuild/npmDepChecker.ts +++ b/tools/build-tools/src/fluidBuild/npmDepChecker.ts @@ -17,8 +17,7 @@ interface DepCheckRecord { }; export class NpmDepChecker { - // @types/socket.io-client is references in the tsconfig.json - private readonly foundTypes: string[] = ["@types/socket.io-client", "@types/node", "@types/expect-puppeteer", "@types/jest-environment-puppeteer"]; + private readonly foundTypes: string[] = ["@types/node", "@types/expect-puppeteer", "@types/jest-environment-puppeteer"]; // hjs is implicitly used private readonly ignored = ["hjs", ...this.foundTypes]; // list of packages that should always in the devDependencies