diff --git a/dist/src/client.d.ts b/dist/src/client.d.ts index a90b166..3be41e1 100644 --- a/dist/src/client.d.ts +++ b/dist/src/client.d.ts @@ -39,7 +39,7 @@ interface CreateRoom { initialState?: Array<{ type: string; content: any; - stateKey: string; + stateKey?: string; }>; version?: string; } diff --git a/dist/src/client.js b/dist/src/client.js index 0fa3bb6..d4744f4 100644 --- a/dist/src/client.js +++ b/dist/src/client.js @@ -18,7 +18,7 @@ class Rooms extends Map { initial_state: options.initialState?.map(ev => ({ type: ev.type, content: ev.content, - state_key: ev.stateKey, + state_key: ev.stateKey ?? "", })), creation_content: options.creationContent, }); @@ -111,6 +111,7 @@ export class Client extends EventEmitter { await this.conn.sync(); } catch (err) { + console.error(err); this.setState({ state: "error", reason: err }); } } diff --git a/dist/src/client.js.map b/dist/src/client.js.map index e98f4a4..4df06cf 100644 --- a/dist/src/client.js.map +++ b/dist/src/client.js.map @@ -1 +1 @@ -{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqDlC,MAAM,KAAM,SAAQ,GAAiB;IACnC,YAAmB,MAAc;QAC/B,KAAK,EAAE,CAAC;QADE;;;;mBAAO,MAAM;WAAQ;IAEjC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAmB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;YAChC,YAAY,EAAE,OAAO,CAAC,OAAO;YAC7B,aAAa,EAAE,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC9C,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,OAAO,EAAE,EAAE,CAAC,OAAO;gBACnB,SAAS,EAAE,EAAE,CAAC,QA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ACH,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACnB,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,EAAE,CAAA;IACN,CAAC;IAED,oCAAoC;IACpC,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;CACF"} \ No newline at end of file diff --git a/dist/src/room.d.ts b/dist/src/room.d.ts index 2755b37..90d20e6 100644 --- a/dist/src/room.d.ts +++ b/dist/src/room.d.ts @@ -22,7 +22,7 @@ export declare class Room extends Room_base { private state; timelines: TimelineSet; events: Map; - threads: Map; + threads: RoomThreads; constructor(client: Client, id: string, data: SyncResponseRoom); _merge(data: SyncResponseRoom): void; getState(type: string, stateKey?: string): StateEvent | null; @@ -32,6 +32,20 @@ export declare class Room extends Room_base { leave(reason?: string): Promise; ack(eventId?: EventId): Promise; } +declare class RoomThreads extends Map { + room: Room; + constructor(room: Room); + fetch(eventId: EventId): Promise; + paginate(opts?: { + from?: string; + limit?: number; + watching?: boolean; + include?: Array; + }): Promise<{ + threads: Thread[]; + nextBatch: string | undefined; + }>; +} export declare class ThreadPaginator extends Map { client: Client; rooms: Array; diff --git a/dist/src/room.js b/dist/src/room.js index 018fbab..2ac14e6 100644 --- a/dist/src/room.js +++ b/dist/src/room.js @@ -43,7 +43,7 @@ export class Room extends EventEmitter { enumerable: true, configurable: true, writable: true, - value: void 0 + value: new TimelineSet(this) }); Object.defineProperty(this, "events", { enumerable: true, @@ -55,11 +55,9 @@ export class Room extends EventEmitter { enumerable: true, configurable: true, writable: true, - value: new Map() + value: new RoomThreads(this) }); - this.timelines = new TimelineSet(this); this.timelines.live.prevBatch = data.prev_batch; - this.threads = new RoomThreads(this); this._merge(data); } // should be private to only the library like pub(crate), but there's no way currently diff --git a/dist/src/room.js.map b/dist/src/room.js.map index 62298a8..f90441a 100644 --- a/dist/src/room.js.map +++ b/dist/src/room.js.map @@ -1 +1 @@ -{"version":3,"file":"room.js","sourceRoot":"","sources":["../../src/room.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAIlC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAsBrC,MAAM,OAAO,IAAK,SAAS,YAA8D;IAOvF,2BAA2B;IAE3B;;;;;;;;;;;;MAYE;IAEF,YACS,MAAc,EACd,EAAU,EACjB,IAAsB;QAEtB,KAAK,EAAE,CAAC;QAJR;;;;mBAAO,MAAM;WAAQ;QACrB;;;;mBAAO,EAAE;WAAQ;QAxBnB,+CAA+C;QACvC;;;;mBAA8C,IAAI,GAAG,EAAE;WAAC;QAEzD;;;;;WAAuB;QACvB;;;;mBAA8B,IAAI,GAAG,EAAE;WAAC;QACxC;;;;mBAAgC,IAAI,GAAG,EAAE;WAAC;QAuB/C,IAAI,CAAC,SAAS,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CA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AAI,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAE,GAAW,CAAC,OAAO,CAAE,CAAC;YAC1D,MAAM,MAAM,GAAY,GAAW,CAAC,OAAO,CAAC;YAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,QAAQ,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;gBAChD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;gBAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;gBACpC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACF"} \ No newline at end of file diff --git a/dist/src/thread.d.ts b/dist/src/thread.d.ts index afc5ba7..0dc532c 100644 --- a/dist/src/thread.d.ts +++ b/dist/src/thread.d.ts @@ -11,8 +11,11 @@ declare const Thread_base: new () => TypedEmitter; export declare class Thread extends Thread_base { baseEvent: Event; room: Room; - timeline: ThreadTimeline; id: string; + participation: string; + messageCount: number; + latestEvent: Event; + timeline: ThreadTimeline; constructor(baseEvent: Event); ack(eventId?: EventId): Promise; } diff --git a/dist/src/thread.js b/dist/src/thread.js index 38a2480..ec25f6f 100644 --- a/dist/src/thread.js +++ b/dist/src/thread.js @@ -1,7 +1,11 @@ import EventEmitter from "events"; +import { Event } from "./event.js"; import { ThreadTimeline } from "./timeline.js"; export class Thread extends EventEmitter { constructor(baseEvent) { + const threadRel = baseEvent.unsigned["m.relations"]?.["m.thread"]; + if (!threadRel) + throw new Error("Tried to create a thread from a non-thread event!"); super(); Object.defineProperty(this, "baseEvent", { enumerable: true, @@ -15,18 +19,44 @@ export class Thread extends EventEmitter { writable: true, value: this.baseEvent.room }); - Object.defineProperty(this, "timeline", { - enumerable: true, - configurable: true, - writable: true, - value: new ThreadTimeline(this) - }); Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: this.baseEvent.id }); + Object.defineProperty(this, "participation", { + enumerable: true, + configurable: true, + writable: true, + value: "participating" + }); + Object.defineProperty(this, "messageCount", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "latestEvent", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + // @deprecated: Threads will have multiple timelines + Object.defineProperty(this, "timeline", { + enumerable: true, + configurable: true, + writable: true, + value: new ThreadTimeline(this) + }); + const latestRaw = threadRel.latest_event; + const latestCached = this.room.events.get(latestRaw.event_id); + const latestEvent = latestCached ?? new Event(this.room, latestRaw); + if (!latestCached) + this.room.events.set(latestEvent.id, latestEvent); + this.latestEvent = latestEvent; + this.messageCount = threadRel.count; } // // TODO: local echo(?), return event // async sendEvent(type: string, content: any) { diff --git a/dist/src/thread.js.map b/dist/src/thread.js.map index d2b3c5a..cc20de5 100644 --- a/dist/src/thread.js.map +++ b/dist/src/thread.js.map @@ -1 +1 @@ -{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../src/thread.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAU/C,MAAM,OAAO,MAAO,SAAS,YAAgE;IAK3F,YAAmB,SAAgB;QACjC,KAAK,E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;WAAC;QAChC;;;;;WAAqB;QACrB;;;;;WAAmB;QAE1B,oDAAoD;QAC7C;;;;mBAA2B,IAAI,cAAc,CAAC,IAAI,CAAC;WAAC;QAQzD,MAAM,SAAS,GAAG,SAAS,CAAC,YAAY,CAAC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC9D,MAAM,WAAW,GAAG,YAAY,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpE,IAAI,CAAC,YAAY;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QACrE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC;IACtC,CAAC;IAED,uCAAuC;IACvC,gDAAgD;IAChD,uEAAuE;IACvE,IAAI;IAEJ,sDAAsD;IACtD,sDAAsD;IACtD,IAAI;IAEJ,KAAK,CAAC,GAAG,CAAC,OAAiB;QACzB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;YAC7B,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;SACnF,CAAC,CAAC;IACL,CAAC;CACF"} \ No newline at end of file diff --git a/dist/src/timeline.d.ts b/dist/src/timeline.d.ts index 2c17230..863be18 100644 --- a/dist/src/timeline.d.ts +++ b/dist/src/timeline.d.ts @@ -1,34 +1,44 @@ -import { EventId } from "./api.js"; +import { ApiEphemeralEvent, EventId } from "./api.js"; import { Room } from "./room.js"; import { Event } from "./event.js"; import { Thread } from "./thread.js"; -export interface Timeline { +import TypedEmitter from "typed-emitter"; +type TimelineEvents = { + timelineUpdate: (batch: Array, toBeginning: boolean) => void; + timelineAppend: (event: Event) => void; + ephemeral: (event: ApiEphemeralEvent) => void; +}; +export interface Timeline extends TypedEmitter { isLive: boolean; isAtBeginning: boolean; isAtEnd: boolean; - events: Array; + getEvents(): Array; paginate(dir: "f" | "b", limit: number): Promise; } -export declare class RoomTimeline implements Timeline { +declare const RoomTimeline_base: new () => TypedEmitter; +export declare class RoomTimeline extends RoomTimeline_base implements Timeline { room: Room; - events: Array; isLive: boolean; isAtBeginning: boolean; isAtEnd: boolean; + _events: Array; prevBatch: string | undefined; nextBatch: string | undefined; constructor(room: Room); + getEvents(): Array; paginate(dir: "f" | "b", limit?: number): Promise; } -export declare class ThreadTimeline implements Timeline { +declare const ThreadTimeline_base: new () => TypedEmitter; +export declare class ThreadTimeline extends ThreadTimeline_base implements Timeline { thread: Thread; - events: Array; isLive: boolean; isAtBeginning: boolean; isAtEnd: boolean; + _events: Array; prevBatch: string | undefined; nextBatch: string | undefined; constructor(thread: Thread); + getEvents(): Array; paginate(dir: "f" | "b", limit?: number): Promise; } export declare class TimelineSet { @@ -39,3 +49,4 @@ export declare class TimelineSet { forEvent(eventId: EventId): Promise; _appendEvents(events: Array): void; } +export {}; diff --git a/dist/src/timeline.js b/dist/src/timeline.js index 40d84dd..baaded5 100644 --- a/dist/src/timeline.js +++ b/dist/src/timeline.js @@ -1,19 +1,15 @@ // Timelines are ordered sequences of events. import { Event } from "./event.js"; -export class RoomTimeline { +import EventEmitter from "events"; +export class RoomTimeline extends EventEmitter { constructor(room) { + super(); Object.defineProperty(this, "room", { enumerable: true, configurable: true, writable: true, value: room }); - Object.defineProperty(this, "events", { - enumerable: true, - configurable: true, - writable: true, - value: [] - }); Object.defineProperty(this, "isLive", { enumerable: true, configurable: true, @@ -32,6 +28,13 @@ export class RoomTimeline { writable: true, value: false }); + // These should be private, but typescript doesn't have "private to module" + Object.defineProperty(this, "_events", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); Object.defineProperty(this, "prevBatch", { enumerable: true, configurable: true, @@ -45,6 +48,9 @@ export class RoomTimeline { value: void 0 }); } + getEvents() { + return this._events; + } async paginate(dir, limit = 50) { if (dir === "b" && this.isAtBeginning) return false; @@ -65,9 +71,10 @@ export class RoomTimeline { else { this.isAtEnd = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) this.room.events.set(event.id, event); + this.emit("timelineUpdate", events, false); } else { const events = data.chunk.reverse().map(raw => new Event(this.room, raw)); @@ -77,27 +84,23 @@ export class RoomTimeline { else { this.isAtBeginning = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) this.room.events.set(event.id, event); + this.emit("timelineUpdate", events, true); } return true; } } -export class ThreadTimeline { +export class ThreadTimeline extends EventEmitter { constructor(thread) { + super(); Object.defineProperty(this, "thread", { enumerable: true, configurable: true, writable: true, value: thread }); - Object.defineProperty(this, "events", { - enumerable: true, - configurable: true, - writable: true, - value: [] - }); Object.defineProperty(this, "isLive", { enumerable: true, configurable: true, @@ -116,6 +119,13 @@ export class ThreadTimeline { writable: true, value: false }); + // These should be private, but typescript doesn't have "private to module" + Object.defineProperty(this, "_events", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); Object.defineProperty(this, "prevBatch", { enumerable: true, configurable: true, @@ -129,6 +139,9 @@ export class ThreadTimeline { value: void 0 }); } + getEvents() { + return this._events; + } async paginate(dir, limit = 50) { if (dir === "b" && this.isAtBeginning) return false; @@ -137,6 +150,7 @@ export class ThreadTimeline { // This is to prevent someone from trying to paginate forwards, // then paginate backwards. The timeline will end up with events from // the beginning and end! + // NOTE: deprecated? // FIXME: implement /context in threads if (dir === "f") this.isAtBeginning = true; @@ -150,30 +164,31 @@ export class ThreadTimeline { limit, }); if (dir === "f") { - const events = data.chunk.map(raw => new Event(room, raw)); + const events = data.chunk.reverse().map(raw => new Event(room, raw)); if (data.next_batch) { this.nextBatch = data.next_batch; } else { this.isAtEnd = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) room.events.set(event.id, event); + this.emit("timelineUpdate", events, false); return !!data.next_batch; } else { - // FIXME: conduit doesn't implement ?dir=b - const events = data.chunk.map(raw => new Event(room, raw)); + const events = data.chunk.reverse().map(raw => new Event(room, raw)); if (data.prev_batch) { this.prevBatch = data.prev_batch; } else { this.isAtBeginning = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) room.events.set(event.id, event); + this.emit("timelineUpdate", events, true); return !!data.prev_batch; } } @@ -215,7 +230,7 @@ export class TimelineSet { async forEvent(eventId) { const context = await this.room.client.net.fetchContext(this.room.id, eventId); const tl = new RoomTimeline(this.room); - tl.events = context.events_before + tl._events = context.events_before .reverse() .concat([context.event]) .concat(context.events_after) @@ -230,19 +245,21 @@ export class TimelineSet { // thread, they need to be merged together for (const event of events) { this.room.events.set(event.id, event); + this.live._events.push(...events); + for (const event of events) + this.live.emit("timelineAppend", event); const threadId = event.content["m.relations"]?.find((rel) => rel.rel_type === "m.thread")?.event_id; - if (threadId) { - const tl = this.room.threads.get(threadId)?.timeline; - if (tl?.isLive) - tl.events.push(event); + const thread = this.room.threads.get(threadId); + if (thread) { + thread.messageCount++; + thread.latestEvent = event; + const tl = thread.timeline; + if (tl?.isLive) { + tl._events.push(event); + tl.emit("timelineAppend", event); + } } } - for (const timeline of this.timelines) { - // if (timeline.isLive) timeline.events.push(...events); - if (timeline.isLive && timeline instanceof RoomTimeline) - timeline.events.push(...events); - // this.room.threads.get() - } } } //# sourceMappingURL=timeline.js.map \ No newline at end of file diff --git a/dist/src/timeline.js.map b/dist/src/timeline.js.map index 100ef2f..bd8e5cc 100644 --- a/dist/src/timeline.js.map +++ b/dist/src/timeline.js.map @@ -1 +1 @@ -{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAK7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAwBnC,MAAM,OAAO,YAAY;IASvB,YAAmB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ist/tsconfig.tsbuildinfo b/dist/tsconfig.tsbuildinfo index e845a28..7e85653 100644 --- a/dist/tsconfig.tsbuildinfo +++ b/dist/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"program":{"fileNames":["../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/api.ts","../src/net.ts","../node_modules/.pnpm/@types+events@3.0.3/node_modules/@types/events/index.d.ts","../node_modules/.pnpm/typed-emitter@2.1.0/node_modules/typed-emitter/index.d.ts","../src/event.ts","../src/thread.ts","../src/timeline.ts","../node_modules/.pnpm/nanoid@5.0.4/node_modules/nanoid/index.d.ts","../src/room.ts","../src/index.ts","../src/sync.ts","../src/client.ts","../src/setup.ts","../src/utils.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc",{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"aa96ec3974eb602a0ffdcd9841f69c2fb8b4647bd7f2a9f7baf37b3a3acf0f27","signature":"1230d499af44ac7431072efa5643f44ec443b82ab90adceb2402e40b7db53ca1"},{"version":"e361a708dca4e8f188b404ad53bac6fa4e3e1bf3cc748057d77ca1e158b830ec","signature":"977b9cc5510fbe08bf3b1e8b9418ccdcc48916d10411c76233f71f719f22eb7c"},"93d28b4eb12c68fccc1f2fc04a4ef83ea3b2a03b18055d3bf29cab267aa7042e","6c27d4b5ba01295ef334456d9af4366aca789f228eee70fcb874b903a59b0e5b",{"version":"40b6151e7d128f519410808f41bf2b731624cd209e013775b0c8169d684b8cc2","signature":"3ea684d983334687f96e80b806ac8f4550da743303e70afc857c42cd1b01a8b7"},{"version":"989f79d5cece5e8685a7033b248a2b296ba6bf391187fd09cdac951f752360d0","signature":"67e16bf3df60eeec03594e37b9d88930eeb92834a32c34e66fd6f29b601a770b"},{"version":"febeb590f9089b6f02fd850e2013c1b5f17691ea727bcefe0a92036cf2b17b03","signature":"4713a318237ffaf81cb591b04a8be924e696d316e4d446aeb3efe30ebd3068bd"},"a45ee7555d019a67fbe092898d1aef0b1d02a9f6679ab84461ff515b4460d706",{"version":"3fd6e980af94307568799d56761c711d34d17dcb15df31d7be403ab44db74b08","signature":"3042ce926d8e09a40e0950f9bfbf23904dc245f38880608fa2851bac46989ce3"},"fdb7841ac7f0ad247f9c75a512d9272fc4048bae2c630b3a6f42eba37bfee3ee",{"version":"d84e7ceebdf0ca5666019c1a7d69110326993ede96347b6e40eeaef36047d492","signature":"72848e8c0680b2f2b81304c45137ce94af346b19ba084a90eb37437b8f14a163"},{"version":"d25afadd00ae25c57f498f5fd2fea9537b1bbbb30caccd2ddf768100d451506e","signature":"587709bf716bd6e377c755533ccdcd70c7b59bc8ff7ecf4992f7f80746c60d6b"},{"version":"8f8d0bf3babdb97438eb27caaae3fb6186208704a82446d03971e185c1f5f009","signature":"16f4188a578c2e2a5278d75399ac88b039a9a0c08f852c221d3b03410dff08ff","affectsGlobalScope":true},{"version":"00732cfad7bfbc344b48cebb977fb5c06b7394f3008488947d27383cccfb4e54","signature":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}],"root":[59,60,[63,65],[67,72]],"options":{"composite":true,"module":99,"noFallthroughCasesInSwitch":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"strictNullChecks":true,"target":7,"useDefineForClassFields":true},"fileIdsList":[[59,60,61,62,67,69],[59,67,70],[63,64,65,67,70],[59,70],[59,61,62,63,64,65,66,70],[59,66,67,68],[59,61,62,63,65,67],[59,63,64,67],[59,60,62,67,69],[59,62,63,64,65,70],[59,68],[59,62,63,65,67]],"referencedMap":[[70,1],[63,2],[68,3],[60,4],[67,5],[69,6],[64,7],[65,8]],"exportedModulesMap":[[70,9],[63,2],[68,3],[60,4],[67,10],[69,11],[64,12],[65,8]],"semanticDiagnosticsPerFile":[61,66,62,57,58,10,11,13,12,2,14,15,16,17,18,19,20,21,3,4,22,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,1,59,70,63,68,60,67,71,69,64,65,72],"latestChangedDtsFile":"./src/timeline.d.ts"},"version":"5.3.2"} \ No newline at end of file +{"program":{"fileNames":["../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/.pnpm/typescript@5.3.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/api.ts","../src/net.ts","../node_modules/.pnpm/@types+events@3.0.3/node_modules/@types/events/index.d.ts","../node_modules/.pnpm/typed-emitter@2.1.0/node_modules/typed-emitter/index.d.ts","../src/event.ts","../src/thread.ts","../src/timeline.ts","../node_modules/.pnpm/nanoid@5.0.4/node_modules/nanoid/index.d.ts","../src/room.ts","../src/index.ts","../src/sync.ts","../src/client.ts","../src/setup.ts","../src/utils.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc",{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"1edaa6ea6b1b94bd571e0250e0a535cb39c2efba0de3b93daeb1b3d722d6a05d","signature":"1230d499af44ac7431072efa5643f44ec443b82ab90adceb2402e40b7db53ca1"},{"version":"e361a708dca4e8f188b404ad53bac6fa4e3e1bf3cc748057d77ca1e158b830ec","signature":"977b9cc5510fbe08bf3b1e8b9418ccdcc48916d10411c76233f71f719f22eb7c"},"93d28b4eb12c68fccc1f2fc04a4ef83ea3b2a03b18055d3bf29cab267aa7042e","6c27d4b5ba01295ef334456d9af4366aca789f228eee70fcb874b903a59b0e5b",{"version":"40b6151e7d128f519410808f41bf2b731624cd209e013775b0c8169d684b8cc2","signature":"3ea684d983334687f96e80b806ac8f4550da743303e70afc857c42cd1b01a8b7"},{"version":"7f761f3d53cafe34d73f54bdd5e0216f99d99b302f58b28568416f4f29213a5a","signature":"33cc1d4266045174b1f71c400b8d9d84c0ca4ee30d7df0b8d0550e931a187cf4"},{"version":"4b9a18de81a26df62499b349996bbd4796c88ed1bb3904662922831c2fde285f","signature":"ec95c104d09a2d3c19c2683ff2264e11c1f0ee2afeb1d540fa2c49eac4fd66a9"},"a45ee7555d019a67fbe092898d1aef0b1d02a9f6679ab84461ff515b4460d706",{"version":"7a42b0bdfc40087902f334dbbce9390394a92b7afdf24b72c14b77b530963a51","signature":"84972c56ff5b8038a24b35201f789ec7e93b75f5072b1370f53b0a736436b512"},"fdb7841ac7f0ad247f9c75a512d9272fc4048bae2c630b3a6f42eba37bfee3ee",{"version":"d84e7ceebdf0ca5666019c1a7d69110326993ede96347b6e40eeaef36047d492","signature":"72848e8c0680b2f2b81304c45137ce94af346b19ba084a90eb37437b8f14a163"},{"version":"982a4b70445a3da991403adeccb39ecd006845f3ba2f09c9cbb8613209351af9","signature":"c3c3fa5db7ca7720886f27a109786c1e47d591c9fef0fc16b9f2cad4178ef1be"},{"version":"8f8d0bf3babdb97438eb27caaae3fb6186208704a82446d03971e185c1f5f009","signature":"16f4188a578c2e2a5278d75399ac88b039a9a0c08f852c221d3b03410dff08ff","affectsGlobalScope":true},{"version":"00732cfad7bfbc344b48cebb977fb5c06b7394f3008488947d27383cccfb4e54","signature":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}],"root":[59,60,[63,65],[67,72]],"options":{"composite":true,"module":99,"noFallthroughCasesInSwitch":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"strictNullChecks":true,"target":7,"useDefineForClassFields":true},"fileIdsList":[[59,60,61,62,67,69],[59,67,70],[63,64,65,67,70],[59,70],[59,61,62,63,64,65,66,70],[59,66,67,68],[59,61,62,63,65,67],[59,61,62,63,64,67],[59,60,62,67,69],[59,62,63,64,65,70],[59,68],[59,62,63,65,67],[59,62,63,64,67]],"referencedMap":[[70,1],[63,2],[68,3],[60,4],[67,5],[69,6],[64,7],[65,8]],"exportedModulesMap":[[70,9],[63,2],[68,3],[60,4],[67,10],[69,11],[64,12],[65,13]],"semanticDiagnosticsPerFile":[61,66,62,57,58,10,11,13,12,2,14,15,16,17,18,19,20,21,3,4,22,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,1,59,70,63,68,60,67,71,69,64,65,72],"latestChangedDtsFile":"./src/thread.d.ts"},"version":"5.3.2"} \ No newline at end of file diff --git a/docs/bot.ts b/docs/bot.ts new file mode 100644 index 0000000..0d2db8c --- /dev/null +++ b/docs/bot.ts @@ -0,0 +1,32 @@ +// An example pong-pong bot +// I might add a higher level bot sdk at some point, since this is relatively low level + +import { Client, Event } from "../dist/src/index.js"; + +// Create the client +const client = new Client({ + // baseUrl: "https://homeserver.tld", + // deviceId: "something", + // token: "supersecrettoken", + // userId: "@userid:homeserver.tld", + baseUrl: "http://localhost:6167", + deviceId: "something", + token: "9SWeOqc5g42O0fS3JesE43s1JujCDD8S", + userId: "@asdf:localhost", +}); + +function handleEvent(event: Event) { + console.log("received event from " + event.sender); +} + +client.on("roomInit", (room) => room.timelines.live.on("timelineAppend", handleEvent)); +client.on("roomDeinit", (room) => room.timelines.live.on("timelineAppend", handleEvent)); + +client.lists.subscribe("allrooms", { + ranges: [[0, 9999999]], // fetch all rooms + required_state: [["m.room.name", ""]], // get their names + timeline_limit: 1, // only listen to the last event (this will not trigger timelineAppend) +}); + +// Start syncing and receiving events +client.start(); diff --git a/src/api.ts b/src/api.ts index 381122a..3f1213f 100644 --- a/src/api.ts +++ b/src/api.ts @@ -188,7 +188,7 @@ export interface MessagesResponse { } export interface RelationsResponse { - chunk: Array, + chunk: Array, // always in reverse chronological order! (later relations are always first) next_batch: string, prev_batch: string, } diff --git a/src/client.ts b/src/client.ts index 9306152..4cbc9c5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -53,7 +53,7 @@ type RoomList = { interface CreateRoom { creationContent?: Record, - initialState?: Array<{ type: string, content: any, stateKey: string }>, + initialState?: Array<{ type: string, content: any, stateKey?: string }>, version?: string, } @@ -68,7 +68,7 @@ class Rooms extends Map { initial_state: options.initialState?.map(ev => ({ type: ev.type, content: ev.content, - state_key: ev.stateKey, + state_key: ev.stateKey ?? "", })), creation_content: options.creationContent, }); @@ -135,6 +135,7 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter void, // an ephemeral event was received + // @deprecated: use timelines.live ephemeral: (event: ApiEphemeralEvent) => void, // this room's state updated @@ -31,9 +33,9 @@ export class Room extends (EventEmitter as unknown as new () => TypedEmitter> = new Map(); - public timelines: TimelineSet; + public timelines = new TimelineSet(this); public events: Map = new Map(); - public threads: Map = new Map(); + public threads = new RoomThreads(this); // public members: Members; /* @@ -56,9 +58,7 @@ room.unban(userid) data: SyncResponseRoom, ) { super(); - this.timelines = new TimelineSet(this); this.timelines.live.prevBatch = data.prev_batch; - this.threads = new RoomThreads(this); this._merge(data); } @@ -137,7 +137,7 @@ class RoomThreads extends Map { return thread; } - async paginate(opts: { from?: string, limit?: number, watching?: boolean, include?: Array }) { + async paginate(opts?: { from?: string, limit?: number, watching?: boolean, include?: Array }) { const data = await this.room.client.net.fetchThreads({ ...opts, roomIds: [this.room.id] }); const threads = data.chunk?.map(raw => new Thread(new Event(this.room, raw))) || []; for (const th of threads) this.set(th.id, th); diff --git a/src/thread.ts b/src/thread.ts index 98707ca..1dfe1d5 100644 --- a/src/thread.ts +++ b/src/thread.ts @@ -15,11 +15,27 @@ type ThreadEvents = { export class Thread extends (EventEmitter as unknown as new () => TypedEmitter) { public room: Room = this.baseEvent.room; - public timeline: ThreadTimeline = new ThreadTimeline(this); public id = this.baseEvent.id; + public participation = "participating"; + public messageCount: number; + public latestEvent: Event; + + // @deprecated: Threads will have multiple timelines + public timeline: ThreadTimeline = new ThreadTimeline(this); + constructor(public baseEvent: Event) { + const threadRel = baseEvent.unsigned["m.relations"]?.["m.thread"]; + if (!threadRel) throw new Error("Tried to create a thread from a non-thread event!"); + super(); + + const latestRaw = threadRel.latest_event; + const latestCached = this.room.events.get(latestRaw.event_id); + const latestEvent = latestCached ?? new Event(this.room, latestRaw); + if (!latestCached) this.room.events.set(latestEvent.id, latestEvent); + this.latestEvent = latestEvent; + this.messageCount = threadRel.count; } // // TODO: local echo(?), return event diff --git a/src/timeline.ts b/src/timeline.ts index 6e26652..2a11863 100644 --- a/src/timeline.ts +++ b/src/timeline.ts @@ -1,12 +1,26 @@ // Timelines are ordered sequences of events. // import TypedEventEmitter from "typed-emitter"; -import { EventId } from "./api.js"; +import { ApiEphemeralEvent, EventId } from "./api.js"; import { Room } from "./room.js"; import { Event } from "./event.js"; import { Thread } from "./thread.js"; +import TypedEmitter from "typed-emitter"; +import EventEmitter from "events"; -export interface Timeline { +type TimelineEvents = { + // This room's live timeline is updated, usually via pagination. + timelineUpdate: (batch: Array, toBeginning: boolean) => void, + + // An event is appended to this timeline. + // Only fires if this timeline is live. + timelineAppend: (event: Event) => void, + + // An ephemeral event was received + ephemeral: (event: ApiEphemeralEvent) => void, +} + +export interface Timeline extends TypedEmitter { // if this timeline is actively receiving new events isLive: boolean, @@ -18,8 +32,8 @@ export interface Timeline { // isPaginating: boolean, - // the events in this timeline - events: Array, + // Get the events in this timeline + getEvents(): Array, // Paginate a timeline for more events // TODO: fuse two neighboring timelines together @@ -27,16 +41,23 @@ export interface Timeline { paginate(dir: "f" | "b", limit: number): Promise; } -export class RoomTimeline implements Timeline { - public events: Array = []; +export class RoomTimeline extends (EventEmitter as unknown as new () => TypedEmitter) implements Timeline { public isLive: boolean = false; public isAtBeginning: boolean = false; public isAtEnd: boolean = false; - + + // These should be private, but typescript doesn't have "private to module" + _events: Array = []; prevBatch: string | undefined; nextBatch: string | undefined; - constructor(public room: Room) {} + constructor(public room: Room) { + super(); + } + + public getEvents(): Array { + return this._events; + } public async paginate(dir: "f" | "b", limit: number = 50): Promise { if (dir === "b" && this.isAtBeginning) return false; @@ -56,8 +77,9 @@ export class RoomTimeline implements Timeline { } else { this.isAtEnd = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) this.room.events.set(event.id, event); + this.emit("timelineUpdate", events, false); } else { const events = data.chunk.reverse().map(raw => new Event(this.room, raw)); if (data.end) { @@ -65,8 +87,9 @@ export class RoomTimeline implements Timeline { } else { this.isAtBeginning = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) this.room.events.set(event.id, event); + this.emit("timelineUpdate", events, true); } return true; } @@ -79,17 +102,24 @@ export class RoomTimeline implements Timeline { // } } -export class ThreadTimeline implements Timeline { - public events: Array = []; +export class ThreadTimeline extends (EventEmitter as unknown as new () => TypedEmitter) implements Timeline { public isLive: boolean = true; // FIXME: live threads public isAtBeginning: boolean = false; public isAtEnd: boolean = false; + // These should be private, but typescript doesn't have "private to module" + _events: Array = []; prevBatch: string | undefined; nextBatch: string | undefined; - constructor(public thread: Thread) {} + constructor(public thread: Thread) { + super(); + } + public getEvents(): Array { + return this._events; + } + public async paginate(dir: "f" | "b", limit: number = 50): Promise { if (dir === "b" && this.isAtBeginning) return false; if (dir === "f" && this.isAtEnd) return false; @@ -97,6 +127,7 @@ export class ThreadTimeline implements Timeline { // This is to prevent someone from trying to paginate forwards, // then paginate backwards. The timeline will end up with events from // the beginning and end! + // NOTE: deprecated? // FIXME: implement /context in threads if (dir === "f") this.isAtBeginning = true; if (dir === "b") this.isAtEnd = true; @@ -109,25 +140,26 @@ export class ThreadTimeline implements Timeline { limit, }); if (dir === "f") { - const events = data.chunk.map(raw => new Event(room, raw)); + const events = data.chunk.reverse().map(raw => new Event(room, raw)); if (data.next_batch) { this.nextBatch = data.next_batch; } else { this.isAtEnd = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) room.events.set(event.id, event); + this.emit("timelineUpdate", events, false); return !!data.next_batch; } else { - // FIXME: conduit doesn't implement ?dir=b - const events = data.chunk.map(raw => new Event(room, raw)); + const events = data.chunk.reverse().map(raw => new Event(room, raw)); if (data.prev_batch) { this.prevBatch = data.prev_batch; } else { this.isAtBeginning = true; } - this.events.push(...events); + this._events.push(...events); for (const event of events) room.events.set(event.id, event); + this.emit("timelineUpdate", events, true); return !!data.prev_batch; } } @@ -157,7 +189,7 @@ export class TimelineSet { public async forEvent(eventId: EventId): Promise { const context = await this.room.client.net.fetchContext(this.room.id, eventId); const tl = new RoomTimeline(this.room); - tl.events = context.events_before + tl._events = context.events_before .reverse() .concat([context.event]) .concat(context.events_after) @@ -173,17 +205,22 @@ export class TimelineSet { // thread, they need to be merged together for (const event of events) { this.room.events.set(event.id, event); + + this.live._events.push(...events); + for (const event of events) this.live.emit("timelineAppend", event); + const threadId = event.content["m.relations"]?.find((rel: any) => rel.rel_type === "m.thread")?.event_id; - if (threadId) { - const tl = this.room.threads.get(threadId)?.timeline; - if (tl?.isLive) tl.events.push(event); + const thread = this.room.threads.get(threadId); + if (thread) { + thread.messageCount++; + thread.latestEvent = event; + + const tl = thread.timeline; + if (tl?.isLive) { + tl._events.push(event); + tl.emit("timelineAppend", event); + } } } - - for (const timeline of this.timelines) { - // if (timeline.isLive) timeline.events.push(...events); - if (timeline.isLive && timeline instanceof RoomTimeline) timeline.events.push(...events); - // this.room.threads.get() - } } }