From 03544e380639401aa9cff38dfd02d774a6a2a417 Mon Sep 17 00:00:00 2001 From: Lars Johansson Date: Fri, 10 Nov 2023 17:11:59 +0100 Subject: [PATCH] feat: dynamic import of socketio client --- source/event_hub.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/event_hub.ts b/source/event_hub.ts index 4cbe451..162f0c9 100644 --- a/source/event_hub.ts +++ b/source/event_hub.ts @@ -1,7 +1,6 @@ // :copyright: Copyright (c) 2016 ftrack import { v4 as uuidV4 } from "uuid"; import loglevel from "loglevel"; -import io from "./simple_socketio.js"; import { Event } from "./event.js"; import { EventServerConnectionTimeoutError, @@ -10,7 +9,7 @@ import { NotUniqueError, } from "./error.js"; import { Data } from "./types.js"; - +import type io from "./simple_socketio.js"; interface BaseActionData { selection: Array<{ entityId: string; @@ -178,7 +177,9 @@ export class EventHub { } /** Connect to the event server. */ - connect(): void { + async connect(): Promise { + const simple_socketio = await import("./simple_socketio.js"); + const io = simple_socketio.default; this._socketIo = io.connect(this._serverUrl, this._apiUser, this._apiKey); this._socketIo.on("connect", this._onSocketConnected); this._socketIo.on("ftrack.event", this._handle);