Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated socket.io client types package #9479

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api-report/driver-base.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<IDocumentDeltaConnectionEvents> 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;
Expand Down Expand Up @@ -68,7 +69,7 @@ export class DocumentDeltaConnection extends TypedEventEmitter<IDocumentDeltaCon
protected readonly queuedSignals: ISignalMessage[];
get serviceConfiguration(): IClientConfiguration;
// (undocumented)
protected readonly socket: SocketIOClient.Socket;
protected readonly socket: Socket;
submit(messages: IDocumentMessage[]): void;
// (undocumented)
protected submitCore(type: string, messages: IDocumentMessage[]): void;
Expand Down
3 changes: 2 additions & 1 deletion api-report/odsp-driver.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IdentityType } from '@fluidframework/odsp-driver-definitions';
import { IDocumentService } from '@fluidframework/driver-definitions';
import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
import { IFluidCodeDetails } from '@fluidframework/core-interfaces';
import type { io } from 'socket.io-client';
import { IOdspResolvedUrl } from '@fluidframework/odsp-driver-definitions';
import { IOdspUrlParts } from '@fluidframework/odsp-driver-definitions';
import { IPersistedCache } from '@fluidframework/odsp-driver-definitions';
Expand Down Expand Up @@ -91,7 +92,7 @@ export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore i

// @public
export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, getSocketIOClient: () => Promise<SocketIOClientStatic>, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, getSocketIOClient: () => Promise<typeof io>, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
// (undocumented)
createContainer(createNewSummary: ISummaryTree | undefined, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise<IDocumentService>;
// (undocumented)
Expand Down
5 changes: 0 additions & 5 deletions lerna-package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/drivers/driver-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Copy link
Member

@tylerbutler tylerbutler Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in devDependencies? Don't these packages need to use socket.io-client at runtime?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh -- we're just using the types from the package.

"typescript": "~4.1.3",
"typescript-formatter": "7.1.0"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/drivers/driver-base/src/documentDeltaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions packages/drivers/driver-base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"types": [
"@types/socket.io-client"
]
},
"include": [
"src/**/*"
Expand Down
1 change: 0 additions & 1 deletion packages/drivers/driver-web-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/drivers/iframe-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/drivers/local-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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);

Expand All @@ -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());
}

Expand Down
1 change: 0 additions & 1 deletion packages/drivers/odsp-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/drivers/odsp-driver/src/getSocketIo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 6 additions & 5 deletions packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -42,7 +43,7 @@ export interface ISocketEvents extends IEvent {
class SocketReference extends TypedEventEmitter<ISocketEvents> {
private references: number = 1;
private delayDeleteTimeout: ReturnType<typeof setTimeout> | 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:
Expand Down Expand Up @@ -106,7 +107,7 @@ class SocketReference extends TypedEventEmitter<ISocketEvents> {
return this._socket;
}

public constructor(public readonly key: string, socket: SocketIOClient.Socket) {
public constructor(public readonly key: string, socket: Socket) {
super();

this._socket = socket;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions packages/drivers/odsp-driver/src/odspDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -73,7 +74,7 @@ export class OdspDocumentService implements IDocumentService {
getStorageToken: InstrumentedStorageTokenFetcher,
getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,
logger: ITelemetryLogger,
socketIoClientFactory: () => Promise<SocketIOClientStatic>,
socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,
cache: IOdspCache,
hostPolicy: HostStoragePolicy,
epochTracker: EpochTracker,
Expand Down Expand Up @@ -123,7 +124,7 @@ export class OdspDocumentService implements IDocumentService {
private readonly getStorageToken: InstrumentedStorageTokenFetcher,
private readonly getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,
logger: ITelemetryLogger,
private readonly socketIoClientFactory: () => Promise<SocketIOClientStatic>,
private readonly socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,
private readonly cache: IOdspCache,
hostPolicy: HostStoragePolicy,
private readonly epochTracker: EpochTracker,
Expand Down Expand Up @@ -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<OdspDocumentDeltaConnection> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -133,7 +134,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
constructor(
private readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,
private readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,
private readonly getSocketIOClient: () => Promise<SocketIOClientStatic>,
private readonly getSocketIOClient: () => Promise<typeof SocketIOClientStatic>,
protected persistedCache: IPersistedCache = new LocalPersistentCache(),
private readonly hostPolicy: HostStoragePolicy = {},
) {
Expand Down
1 change: 0 additions & 1 deletion packages/drivers/routerlicious-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions tools/build-tools/src/fluidBuild/npmDepChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down