@quitting/core 1.0.0 → 1.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAG/E,KAAK,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAQnD,qBAAa,WAAY,SAAQ,YAAY;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,KAAK,CAAQ;IAGrB,OAAO,CAAC,gBAAgB,CAAmC;gBAE/C,IAAI,EAAE;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,QAAQ,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,SAAS,EAAE,CAAA;KACxB;IAoBK,OAAO;IA8CP,aAAa,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IA8BnF,gBAAgB,CAAC,EAAE,EAAE,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EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;IA+BhE,GAAG,CAAC,MAAM,GAAE,aAA2B,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAa/E"}
package/dist/events.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { AtimEventName, AtimEventMap } from '@quitting/contract';
1
+ import { ImEventName, ImEventMap } from '@quitting/contract';
2
2
  export declare class EventEmitter {
3
3
  private listeners;
4
- on<K extends AtimEventName>(event: K, handler: (payload: AtimEventMap[K]) => void): () => void;
5
- off<K extends AtimEventName>(event: K, handler: (payload: AtimEventMap[K]) => void): void;
6
- protected emit<K extends AtimEventName>(event: K, payload: AtimEventMap[K]): void;
4
+ on<K extends ImEventName>(event: K, handler: (payload: ImEventMap[K]) => void): () => void;
5
+ off<K extends ImEventName>(event: K, handler: (payload: ImEventMap[K]) => void): void;
6
+ protected emit<K extends ImEventName>(event: K, payload: ImEventMap[K]): void;
7
7
  removeAllListeners(): void;
8
8
  }
9
9
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIrE,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAA0C;IAE3D,EAAE,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAS9F,GAAG,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAIzF,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAajF,kBAAkB,IAAI,IAAI;CAG3B"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIjE,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAwC;IAEzD,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAS1F,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAIrF,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI;IAa7E,kBAAkB,IAAI,IAAI;CAG3B"}
@@ -1,7 +1,8 @@
1
1
  import { Centrifuge as e } from "centrifuge";
2
- import { Room as t, Track as n } from "livekit-client";
2
+ import { Room as t, Track as n, setLogLevel as r } from "livekit-client";
3
+ export * from "@quitting/contract";
3
4
  //#region src/events.ts
4
- var r = class {
5
+ var i = class {
5
6
  listeners = /* @__PURE__ */ new Map();
6
7
  on(e, t) {
7
8
  return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => this.off(e, t);
@@ -14,19 +15,19 @@ var r = class {
14
15
  if (n) for (let r of n) try {
15
16
  r(t);
16
17
  } catch (t) {
17
- console.error(`[atim] event handler error: ${e}`, t);
18
+ console.error(`[im] event handler error: ${e}`, t);
18
19
  }
19
20
  }
20
21
  removeAllListeners() {
21
22
  this.listeners.clear();
22
23
  }
23
- }, i = class extends Error {
24
+ }, a = class extends Error {
24
25
  code;
25
26
  httpStatus;
26
27
  constructor(e, t, n) {
27
28
  super(n), this.name = "ApiError", this.code = e, this.httpStatus = t;
28
29
  }
29
- }, a = class {
30
+ }, o = class {
30
31
  apiBase;
31
32
  tokenGetter;
32
33
  constructor(e, t) {
@@ -36,8 +37,8 @@ var r = class {
36
37
  let n = `${this.apiBase}${e}`, r = {
37
38
  "Content-Type": "application/json",
38
39
  ...t.headers
39
- }, a = this.tokenGetter();
40
- a && (r.Authorization = `Bearer ${a}`), r["X-Trace-Id"] = crypto.randomUUID?.() || Math.random().toString(36).slice(2);
40
+ }, i = this.tokenGetter();
41
+ i && (r.Authorization = `Bearer ${i}`), r["X-Trace-Id"] = crypto.randomUUID?.() || Math.random().toString(36).slice(2);
41
42
  let o = await fetch(n, {
42
43
  ...t,
43
44
  headers: r
@@ -48,7 +49,7 @@ var r = class {
48
49
  let n = await o.json();
49
50
  n?.code && (e = Number(n.code)), n?.message && (t = n.message);
50
51
  } catch {}
51
- throw new i(e, o.status, t);
52
+ throw new a(e, o.status, t);
52
53
  }
53
54
  return o.json();
54
55
  }
@@ -63,7 +64,7 @@ var r = class {
63
64
  keepalive: !0
64
65
  });
65
66
  } catch (e) {
66
- console.warn("[atim] sendBeacon 失败(页面卸载中可能正常)", e);
67
+ console.warn("[im] sendBeacon 失败(页面卸载中可能正常)", e);
67
68
  }
68
69
  }
69
70
  getClientConfig() {
@@ -205,7 +206,7 @@ var r = class {
205
206
  body: JSON.stringify({ md5: e })
206
207
  });
207
208
  }
208
- }, o = class {
209
+ }, s = class {
209
210
  transport;
210
211
  sessionToken = null;
211
212
  centrifugoToken = null;
@@ -243,12 +244,12 @@ var r = class {
243
244
  } catch (t) {
244
245
  let n = String(t?.message || t);
245
246
  if (n.includes("401") || n.includes("kicked") || n.includes("expired")) {
246
- console.error("[atim] refresh 失败(session 失效),需重新登录", t), this.logout();
247
+ console.error("[im] refresh 失败(session 失效),需重新登录", t), this.logout();
247
248
  return;
248
249
  }
249
- console.warn(`[atim] refresh token 失败(第 ${e + 1} 次),5s 后重试`, t), await new Promise((e) => setTimeout(e, 5e3));
250
+ console.warn(`[im] refresh token 失败(第 ${e + 1} 次),5s 后重试`, t), await new Promise((e) => setTimeout(e, 5e3));
250
251
  }
251
- console.error("[atim] refresh token 重试 3 次仍失败,清 token"), this.logout();
252
+ console.error("[im] refresh token 重试 3 次仍失败,清 token"), this.logout();
252
253
  }
253
254
  scheduleRefresh() {
254
255
  this.refreshTimer && clearTimeout(this.refreshTimer);
@@ -258,7 +259,7 @@ var r = class {
258
259
  logout() {
259
260
  this.refreshTimer &&= (clearTimeout(this.refreshTimer), null), this.sessionToken = null, this.centrifugoToken = null;
260
261
  }
261
- }, s = class extends r {
262
+ }, c = class extends i {
262
263
  client = null;
263
264
  subscriptions = /* @__PURE__ */ new Map();
264
265
  refCount = /* @__PURE__ */ new Map();
@@ -276,9 +277,9 @@ var r = class {
276
277
  this.uid = t, this.client = new e(this.wsUrl, { getToken: async () => await this.tokenGetter() }), this.client.on("connected", () => {
277
278
  this.currentState = "connected", this.emit("connection:state", "connected"), this.subscribe(`personal#${t}`);
278
279
  }), this.client.on("disconnected", (e) => {
279
- this.currentState = "disconnected", this.emit("connection:state", "disconnected"), console.warn("[atim] centrifugo disconnected", e?.reason);
280
+ this.currentState = "disconnected", this.emit("connection:state", "disconnected"), console.warn("[im] centrifugo disconnected", e?.reason);
280
281
  }), this.client.on("error", (e) => {
281
- console.error("[atim] centrifugo error", e);
282
+ console.error("[im] centrifugo error", e);
282
283
  }), this.client.connect();
283
284
  }
284
285
  async subscribe(e) {
@@ -371,13 +372,13 @@ var r = class {
371
372
  case "group:profileChanged":
372
373
  this.emit("group:profileChanged", n);
373
374
  break;
374
- default: console.debug("[atim] 未知 publication type", r, e);
375
+ default: console.debug("[im] 未知 publication type", r, e);
375
376
  }
376
377
  }
377
378
  disconnect() {
378
379
  this.client &&= (this.client.disconnect(), null), this.subscriptions.clear(), this.currentState = "disconnected";
379
380
  }
380
- }, c = class extends r {
381
+ }, l = class extends i {
381
382
  callId;
382
383
  callType;
383
384
  roomName;
@@ -414,13 +415,13 @@ var r = class {
414
415
  await this.room.localParticipant.setMicrophoneEnabled(!0), t = !0;
415
416
  } catch (t) {
416
417
  let n = t?.message || String(t);
417
- e.push(`mic: ${n}`), console.warn("[atim] 麦克风开启失败,通话继续(音频不可用)", t);
418
+ e.push(`mic: ${n}`), console.warn("[im] 麦克风开启失败,通话继续(音频不可用)", t);
418
419
  }
419
420
  if (this.callType === "video") try {
420
421
  await this.room.localParticipant.setCameraEnabled(!0), n = !0;
421
422
  } catch (t) {
422
423
  let n = t?.message || String(t);
423
- e.push(`camera: ${n}`), console.warn("[atim] 摄像头开启失败,通话继续(视频不可用)", t);
424
+ e.push(`camera: ${n}`), console.warn("[im] 摄像头开启失败,通话继续(视频不可用)", t);
424
425
  }
425
426
  return this.emitSession("devices", {
426
427
  mic: t,
@@ -469,13 +470,27 @@ var r = class {
469
470
  try {
470
471
  await e.callEnd(this.callId, t);
471
472
  } catch (e) {
472
- console.error("[atim] callEnd 失败", e);
473
+ console.error("[im] callEnd 失败", e);
474
+ }
475
+ r("silent");
476
+ try {
477
+ await this.room.disconnect();
478
+ } finally {
479
+ r("warn");
473
480
  }
474
- await this.room.disconnect(), this.emitSession("ended", { reason: t });
481
+ this.emitSession("ended", { reason: t });
475
482
  }
476
483
  }
477
484
  async end(e) {
478
- this.ended || (this.ended = !0, await this.room.disconnect(), this.emitSession("ended", { reason: e }));
485
+ if (!this.ended) {
486
+ this.ended = !0, r("silent");
487
+ try {
488
+ await this.room.disconnect();
489
+ } finally {
490
+ r("warn");
491
+ }
492
+ this.emitSession("ended", { reason: e });
493
+ }
479
494
  }
480
495
  registerRpcMethod(e, t) {
481
496
  this.room.localParticipant.registerRpcMethod(e, (e) => t(e.payload));
@@ -492,7 +507,7 @@ var r = class {
492
507
  if (n) for (let r of n) try {
493
508
  r(t);
494
509
  } catch (t) {
495
- console.error(`[atim] session handler error: ${e}`, t);
510
+ console.error(`[im] session handler error: ${e}`, t);
496
511
  }
497
512
  }
498
513
  onSession(e, t) {
@@ -505,7 +520,7 @@ var r = class {
505
520
  return this.token;
506
521
  }
507
522
  token;
508
- }, l = class {
523
+ }, u = class {
509
524
  transport;
510
525
  livekitWs;
511
526
  identity;
@@ -515,7 +530,7 @@ var r = class {
515
530
  this.transport = e, this.livekitWs = t, this.identity = n, this.iceServers = r;
516
531
  }
517
532
  async init(e, t) {
518
- let n = await this.transport.callInit(e, t), r = new c({
533
+ let n = await this.transport.callInit(e, t), r = new l({
519
534
  callId: n.callId,
520
535
  callType: t,
521
536
  roomName: n.roomName,
@@ -527,7 +542,7 @@ var r = class {
527
542
  return this.currentSession = r, r;
528
543
  }
529
544
  async accept(e, t) {
530
- let n = await this.transport.callAccept(e), r = new c({
545
+ let n = await this.transport.callAccept(e), r = new l({
531
546
  callId: e,
532
547
  callType: t,
533
548
  roomName: n.roomName,
@@ -543,7 +558,7 @@ var r = class {
543
558
  throw this.currentSession = null, this.transport.callEnd(e, "user_left").catch(() => {}), t;
544
559
  }
545
560
  return r.enableDevices().catch((e) => {
546
- console.warn("[atim] enableDevices 异常", e);
561
+ console.warn("[im] enableDevices 异常", e);
547
562
  }), r;
548
563
  }
549
564
  async end(e = "user_left", t) {
@@ -551,10 +566,22 @@ var r = class {
551
566
  else if (t) try {
552
567
  await this.transport.callEnd(t, e);
553
568
  } catch (e) {
554
- console.warn("[atim] callEnd 失败(不阻塞)", e);
569
+ console.warn("[im] callEnd 失败(不阻塞)", e);
555
570
  }
556
571
  }
557
- }, u = class e extends r {
572
+ };
573
+ //#endregion
574
+ //#region src/meeting.ts
575
+ r("warn");
576
+ async function d(e) {
577
+ r("silent");
578
+ try {
579
+ await e.disconnect();
580
+ } finally {
581
+ r("warn");
582
+ }
583
+ }
584
+ var f = class e extends i {
558
585
  meetingId;
559
586
  title;
560
587
  roomName;
@@ -569,7 +596,7 @@ var r = class {
569
596
  sessionListeners = /* @__PURE__ */ new Map();
570
597
  membersCache = [];
571
598
  membersCacheAt = 0;
572
- static MEMBERS_CACHE_TTL = 2e3;
599
+ static MEMBERS_CACHE_TTL = 8e3;
573
600
  pendingAttach = /* @__PURE__ */ new Map();
574
601
  constructor(e) {
575
602
  super(), this.meetingId = e.meetingId, this.title = e.title, this.roomName = e.roomName, this.identity = e.identity, this.token = e.token, this.isHost = e.isHost, this.hostIdentity = e.hostIdentity, this.livekitWs = e.livekitWs, this.iceServers = e.iceServers, this.room = new t({
@@ -615,12 +642,12 @@ var r = class {
615
642
  try {
616
643
  await this.room.localParticipant.setMicrophoneEnabled(!0), t = !0;
617
644
  } catch (t) {
618
- e.push(`mic: ${t?.message || String(t)}`), console.warn("[atim] 麦克风开启失败,会议继续(音频不可用)", t);
645
+ e.push(`mic: ${t?.message || String(t)}`), console.warn("[im] 麦克风开启失败,会议继续(音频不可用)", t);
619
646
  }
620
647
  try {
621
648
  await this.room.localParticipant.setCameraEnabled(!0), n = !0;
622
649
  } catch (t) {
623
- e.push(`camera: ${t?.message || String(t)}`), console.warn("[atim] 摄像头开启失败,会议继续(视频不可用)", t);
650
+ e.push(`camera: ${t?.message || String(t)}`), console.warn("[im] 摄像头开启失败,会议继续(视频不可用)", t);
624
651
  }
625
652
  return this.emitSession("devices", {
626
653
  mic: t,
@@ -641,13 +668,13 @@ var r = class {
641
668
  try {
642
669
  await e.meetingLeave(this.meetingId);
643
670
  } catch (e) {
644
- console.error("[atim] meetingLeave 失败", e);
671
+ console.error("[im] meetingLeave 失败", e);
645
672
  }
646
- await this.room.disconnect(), this.emitSession("ended", {});
673
+ await d(this.room), this.emitSession("ended", {});
647
674
  }
648
675
  }
649
676
  async end() {
650
- this.ended || (this.ended = !0, await this.room.disconnect(), this.emitSession("ended", {}));
677
+ this.ended || (this.ended = !0, await d(this.room), this.emitSession("ended", {}));
651
678
  }
652
679
  getRemoteParticipants() {
653
680
  let e = [];
@@ -718,10 +745,10 @@ var r = class {
718
745
  if (n) for (let r of n) try {
719
746
  r(t);
720
747
  } catch (t) {
721
- console.error(`[atim] session handler error: ${e}`, t);
748
+ console.error(`[im] session handler error: ${e}`, t);
722
749
  }
723
750
  }
724
- }, d = class {
751
+ }, p = class {
725
752
  transport;
726
753
  livekitWs;
727
754
  identity;
@@ -734,7 +761,7 @@ var r = class {
734
761
  let n = await this.transport.meetingCreate({
735
762
  inviteeUids: e,
736
763
  title: t
737
- }), r = new u({
764
+ }), r = new f({
738
765
  meetingId: n.meetingId,
739
766
  title: t,
740
767
  roomName: n.roomName,
@@ -747,7 +774,7 @@ var r = class {
747
774
  });
748
775
  this.currentSession = r;
749
776
  try {
750
- await r.connect(), r.enableDevices().catch((e) => console.warn("[atim] enableDevices 异常", e));
777
+ await r.connect(), r.enableDevices().catch((e) => console.warn("[im] enableDevices 异常", e));
751
778
  } catch (e) {
752
779
  throw this.currentSession = null, this.transport.meetingLeave(n.meetingId).catch(() => {}), e;
753
780
  }
@@ -758,7 +785,7 @@ var r = class {
758
785
  };
759
786
  }
760
787
  async join(e, t = "") {
761
- let n = await this.transport.meetingJoin(e), r = new u({
788
+ let n = await this.transport.meetingJoin(e), r = new f({
762
789
  meetingId: e,
763
790
  title: t,
764
791
  roomName: n.roomName,
@@ -771,7 +798,7 @@ var r = class {
771
798
  });
772
799
  this.currentSession = r;
773
800
  try {
774
- await r.connect(), r.enableDevices().catch((e) => console.warn("[atim] enableDevices 异常", e));
801
+ await r.connect(), r.enableDevices().catch((e) => console.warn("[im] enableDevices 异常", e));
775
802
  } catch (t) {
776
803
  throw this.currentSession = null, this.transport.meetingLeave(e).catch(() => {}), t;
777
804
  }
@@ -780,7 +807,7 @@ var r = class {
780
807
  async respond(e, t, n) {
781
808
  let r = await this.transport.meetingRespond(e, t);
782
809
  if (t !== "accept" || !r?.token || !r?.roomName) return null;
783
- let i = new u({
810
+ let i = new f({
784
811
  meetingId: e,
785
812
  title: r.title || n || "",
786
813
  roomName: r.roomName,
@@ -793,7 +820,7 @@ var r = class {
793
820
  });
794
821
  this.currentSession = i;
795
822
  try {
796
- await i.connect(), i.enableDevices().catch((e) => console.warn("[atim] enableDevices 异常", e));
823
+ await i.connect(), i.enableDevices().catch((e) => console.warn("[im] enableDevices 异常", e));
797
824
  } catch (t) {
798
825
  throw this.currentSession = null, this.transport.meetingLeave(e).catch(() => {}), t;
799
826
  }
@@ -814,7 +841,7 @@ var r = class {
814
841
  try {
815
842
  return (await this.transport.meetingPendingInvites()).invites || [];
816
843
  } catch (e) {
817
- return console.warn("[atim] fetchPendingInvites 失败", e), [];
844
+ return console.warn("[im] fetchPendingInvites 失败", e), [];
818
845
  }
819
846
  }
820
847
  async reinvite(e, t) {
@@ -823,7 +850,7 @@ var r = class {
823
850
  async getMembers(e = !1) {
824
851
  return this.currentSession ? this.currentSession.refreshMembers(this.transport, e) : [];
825
852
  }
826
- }, f = class {
853
+ }, m = class {
827
854
  transport;
828
855
  realtime;
829
856
  uid;
@@ -893,7 +920,7 @@ var r = class {
893
920
  dialogChannel(e) {
894
921
  return `dialog#${[this.uid, e].sort()[0]},${[this.uid, e].sort()[1]}`;
895
922
  }
896
- }, p = class {
923
+ }, h = class {
897
924
  transport;
898
925
  constructor(e) {
899
926
  this.transport = e;
@@ -921,31 +948,7 @@ var r = class {
921
948
  }
922
949
  return { mediaId: i.mediaId };
923
950
  }
924
- }, m;
925
- (function(e) {
926
- e[e.PC = 1] = "PC", e[e.Android = 2] = "Android", e[e.iOS = 3] = "iOS", e[e.Web = 4] = "Web";
927
- })(m ||= {});
928
- //#endregion
929
- //#region ../contract/dist/group.js
930
- var h;
931
- (function(e) {
932
- e[e.Join = 1] = "Join", e[e.Leave = 2] = "Leave", e[e.Kicked = 3] = "Kicked", e[e.AdminChange = 4] = "AdminChange", e[e.ProfileChange = 5] = "ProfileChange";
933
- })(h ||= {});
934
- //#endregion
935
- //#region ../contract/dist/error.js
936
- var g = {
937
- BadBody: 40001,
938
- BadParam: 40002,
939
- Unauth: 40101,
940
- SessionKicked: 40102,
941
- BadSig: 40103,
942
- Forbidden: 40301,
943
- NotFound: 40401,
944
- Busy: 40901,
945
- Conflict: 40902,
946
- Internal: 50001,
947
- Upstream: 50201
948
- }, _ = [
951
+ }, g = [
949
952
  "message",
950
953
  "message_preview",
951
954
  "message:revoked",
@@ -970,7 +973,7 @@ var g = {
970
973
  "session:kicked",
971
974
  "connection:state",
972
975
  "presence:update"
973
- ], v = class extends r {
976
+ ], _ = class extends i {
974
977
  auth;
975
978
  transport;
976
979
  realtime;
@@ -987,7 +990,7 @@ var g = {
987
990
  name = "";
988
991
  avatar = "";
989
992
  constructor(e) {
990
- super(), this.appId = e.appId, this.apiBase = e.apiBase, this.livekitWs = e.livekitWs, this.auth = new o(null), this.transport = new a(e.apiBase, () => this.auth.getToken()), this.auth = new o(this.transport), this.realtime = new s(e.centrifugoWs, async () => await this.auth.getCentrifugoToken(this.name, this.avatar));
993
+ super(), this.appId = e.appId, this.apiBase = e.apiBase, this.livekitWs = e.livekitWs, this.auth = new s(null), this.transport = new o(e.apiBase, () => this.auth.getToken()), this.auth = new s(this.transport), this.realtime = new c(e.centrifugoWs, async () => await this.auth.getCentrifugoToken(this.name, this.avatar));
991
994
  }
992
995
  async connect(e) {
993
996
  e.name && (this.name = e.name), e.avatar && (this.avatar = e.avatar);
@@ -1000,7 +1003,7 @@ var g = {
1000
1003
  async initAfterAuth() {
1001
1004
  await this.loadClientConfig();
1002
1005
  let e = this.clientConfig?.iceServers ?? [];
1003
- this.call = new l(this.transport, this.livekitWs, this.uid, e), this.meeting = new d(this.transport, this.livekitWs, this.uid, e), this.message = new f(this.transport, this.realtime, this.uid), this.media = new p(this.transport), await this.realtime.connect(this.uid);
1006
+ this.call = new u(this.transport, this.livekitWs, this.uid, e), this.meeting = new p(this.transport, this.livekitWs, this.uid, e), this.message = new m(this.transport, this.realtime, this.uid), this.media = new h(this.transport), await this.realtime.connect(this.uid);
1004
1007
  try {
1005
1008
  let e = await this.transport.getSessionState();
1006
1009
  this.sessionState = e.state, this.emit("session:state", {
@@ -1009,7 +1012,7 @@ var g = {
1009
1012
  meetingId: e.id
1010
1013
  });
1011
1014
  } catch (e) {
1012
- console.warn("[atim] 同步 sessionState 失败", e);
1015
+ console.warn("[im] 同步 sessionState 失败", e);
1013
1016
  }
1014
1017
  this.realtime.on("call:invite", () => {}), this.realtime.on("call:busy", () => {
1015
1018
  this.call.currentSession = null;
@@ -1020,12 +1023,12 @@ var g = {
1020
1023
  t && e?.meetingId === t.meetingId && e?.hostUid && (t.hostIdentity = e.hostUid);
1021
1024
  }), this.realtime.on("meeting:dissolved", (e) => {
1022
1025
  let t = this.meeting?.currentSession;
1023
- t && e?.meetingId === t.meetingId && t.end().catch((e) => console.warn("[atim] dissolved end session 失败", e));
1026
+ t && e?.meetingId === t.meetingId && t.end().catch((e) => console.warn("[im] dissolved end session 失败", e));
1024
1027
  }), this.realtime.on("meeting:kicked", (e) => {
1025
1028
  let t = this.meeting?.currentSession;
1026
- t && e?.meetingId === t.meetingId && t.end().catch((e) => console.warn("[atim] kicked end session 失败", e));
1029
+ t && e?.meetingId === t.meetingId && t.end().catch((e) => console.warn("[im] kicked end session 失败", e));
1027
1030
  }), this.realtime.on("session:kicked", () => {
1028
- console.warn("[atim] 会话被踢(同端新登录),断开连接");
1031
+ console.warn("[im] 会话被踢(同端新登录),断开连接");
1029
1032
  try {
1030
1033
  this.realtime.disconnect();
1031
1034
  } catch {}
@@ -1036,7 +1039,7 @@ var g = {
1036
1039
  if (!this.clientConfig) try {
1037
1040
  this.clientConfig = await this.transport.getClientConfig();
1038
1041
  } catch (e) {
1039
- console.warn("[atim] 拉取 client/config 失败,使用空 iceServers 兜底", e), this.clientConfig = { iceServers: [] };
1042
+ console.warn("[im] 拉取 client/config 失败,使用空 iceServers 兜底", e), this.clientConfig = { iceServers: [] };
1040
1043
  }
1041
1044
  }
1042
1045
  getConfig() {
@@ -1054,11 +1057,11 @@ var g = {
1054
1057
  reinvite: n.variant === "reinvite"
1055
1058
  });
1056
1059
  } catch (e) {
1057
- console.warn("[atim] fetchAndEmitPendingInvites 失败", e);
1060
+ console.warn("[im] fetchAndEmitPendingInvites 失败", e);
1058
1061
  }
1059
1062
  }
1060
1063
  forwardRealtimeEvents() {
1061
- for (let e of _) this.realtime.on(e, (t) => {
1064
+ for (let e of g) this.realtime.on(e, (t) => {
1062
1065
  this.emit(e, t);
1063
1066
  });
1064
1067
  }
@@ -1067,6 +1070,6 @@ var g = {
1067
1070
  }
1068
1071
  };
1069
1072
  //#endregion
1070
- export { i as ApiError, g as ApiErrorCode, v as AtimClient, o as AuthManager, l as CallController, c as CallSession, m as ClientType, r as EventEmitter, h as GroupTipType, p as MediaUploader, d as MeetingController, u as MeetingSession, f as MessageController, s as RealtimeConnection, a as Transport };
1073
+ export { a as ApiError, s as AuthManager, u as CallController, l as CallSession, i as EventEmitter, _ as ImClient, h as MediaUploader, p as MeetingController, f as MeetingSession, m as MessageController, c as RealtimeConnection, o as Transport };
1071
1074
 
1072
- //# sourceMappingURL=atim-core.es.js.map
1075
+ //# sourceMappingURL=im-core.es.js.map