@quitting/core 1.0.2 → 1.2.0

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"}
@@ -95,6 +95,9 @@ var i = class {
95
95
  usersByExternal(e) {
96
96
  return this.request(`/users/by-external?ids=${e.map(encodeURIComponent).join(",")}`);
97
97
  }
98
+ listUsers() {
99
+ return this.request("/users");
100
+ }
98
101
  callInit(e, t) {
99
102
  return this.request("/call/init", {
100
103
  method: "POST",
@@ -274,7 +277,7 @@ var i = class {
274
277
  return this.currentState;
275
278
  }
276
279
  async connect(t) {
277
- this.uid = t, this.client = new e(this.wsUrl, { getToken: async () => await this.tokenGetter() }), this.client.on("connected", () => {
280
+ this.uid = t, this.client && this.disconnect(), this.client = new e(this.wsUrl, { getToken: async () => await this.tokenGetter() }), this.client.on("connected", () => {
278
281
  this.currentState = "connected", this.emit("connection:state", "connected"), this.subscribe(`personal#${t}`);
279
282
  }), this.client.on("disconnected", (e) => {
280
283
  this.currentState = "disconnected", this.emit("connection:state", "disconnected"), console.warn("[im] centrifugo disconnected", e?.reason);
@@ -348,6 +351,12 @@ var i = class {
348
351
  case "read_receipt":
349
352
  this.emit("read_receipt", n);
350
353
  break;
354
+ case "typing":
355
+ this.emit("typing", {
356
+ from: n.from || "",
357
+ isTyping: !!n.isTyping
358
+ });
359
+ break;
351
360
  case "presence:update":
352
361
  {
353
362
  let e = n.changes || [];
@@ -376,9 +385,22 @@ var i = class {
376
385
  }
377
386
  }
378
387
  disconnect() {
379
- this.client &&= (this.client.disconnect(), null), this.subscriptions.clear(), this.currentState = "disconnected";
388
+ this.client &&= (this.client.disconnect(), null), this.subscriptions.clear(), this.refCount.clear(), this.currentState = "disconnected";
389
+ }
390
+ }, l = null;
391
+ async function u(e) {
392
+ r("silent"), l &&= (clearTimeout(l), null);
393
+ try {
394
+ await e.disconnect();
395
+ } finally {
396
+ l = setTimeout(() => {
397
+ r("warn"), l = null;
398
+ }, 1500);
380
399
  }
381
- }, l = class extends i {
400
+ }
401
+ //#endregion
402
+ //#region src/call.ts
403
+ var d = class extends i {
382
404
  callId;
383
405
  callType;
384
406
  roomName;
@@ -472,25 +494,11 @@ var i = class {
472
494
  } catch (e) {
473
495
  console.error("[im] callEnd 失败", e);
474
496
  }
475
- r("silent");
476
- try {
477
- await this.room.disconnect();
478
- } finally {
479
- r("warn");
480
- }
481
- this.emitSession("ended", { reason: t });
497
+ await u(this.room), this.emitSession("ended", { reason: t });
482
498
  }
483
499
  }
484
500
  async end(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
- }
501
+ this.ended || (this.ended = !0, await u(this.room), this.emitSession("ended", { reason: e }));
494
502
  }
495
503
  registerRpcMethod(e, t) {
496
504
  this.room.localParticipant.registerRpcMethod(e, (e) => t(e.payload));
@@ -520,7 +528,7 @@ var i = class {
520
528
  return this.token;
521
529
  }
522
530
  token;
523
- }, u = class {
531
+ }, f = class {
524
532
  transport;
525
533
  livekitWs;
526
534
  identity;
@@ -530,7 +538,7 @@ var i = class {
530
538
  this.transport = e, this.livekitWs = t, this.identity = n, this.iceServers = r;
531
539
  }
532
540
  async init(e, t) {
533
- let n = await this.transport.callInit(e, t), r = new l({
541
+ let n = await this.transport.callInit(e, t), r = new d({
534
542
  callId: n.callId,
535
543
  callType: t,
536
544
  roomName: n.roomName,
@@ -542,7 +550,7 @@ var i = class {
542
550
  return this.currentSession = r, r;
543
551
  }
544
552
  async accept(e, t) {
545
- let n = await this.transport.callAccept(e), r = new l({
553
+ let n = await this.transport.callAccept(e), r = new d({
546
554
  callId: e,
547
555
  callType: t,
548
556
  roomName: n.roomName,
@@ -573,15 +581,7 @@ var i = class {
573
581
  //#endregion
574
582
  //#region src/meeting.ts
575
583
  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 {
584
+ var p = class e extends i {
585
585
  meetingId;
586
586
  title;
587
587
  roomName;
@@ -633,6 +633,26 @@ var f = class e extends i {
633
633
  }).on("activeSpeakersChanged", (e) => {
634
634
  let t = e.map((e) => e.identity);
635
635
  this.emitSession("activeSpeakersChanged", { identities: t });
636
+ }).on("trackMuted", (e, t) => {
637
+ e.source === n.Source.Microphone ? this.emitSession("participantMuteChanged", {
638
+ identity: t.identity,
639
+ muted: !0,
640
+ kind: "audio"
641
+ }) : e.source === n.Source.Camera && this.emitSession("participantMuteChanged", {
642
+ identity: t.identity,
643
+ muted: !0,
644
+ kind: "video"
645
+ });
646
+ }).on("trackUnmuted", (e, t) => {
647
+ e.source === n.Source.Microphone ? this.emitSession("participantMuteChanged", {
648
+ identity: t.identity,
649
+ muted: !1,
650
+ kind: "audio"
651
+ }) : e.source === n.Source.Camera && this.emitSession("participantMuteChanged", {
652
+ identity: t.identity,
653
+ muted: !1,
654
+ kind: "video"
655
+ });
636
656
  }), await this.room.connect(this.livekitWs, this.token, { rtcConfig: { iceServers: this.iceServers } });
637
657
  let e = this.room.localParticipant.identity;
638
658
  e && (this.identity = e, this.hostIdentity ||= e), this.emitSession("connected", {});
@@ -670,11 +690,11 @@ var f = class e extends i {
670
690
  } catch (e) {
671
691
  console.error("[im] meetingLeave 失败", e);
672
692
  }
673
- await d(this.room), this.emitSession("ended", {});
693
+ await u(this.room), this.emitSession("ended", {});
674
694
  }
675
695
  }
676
696
  async end() {
677
- this.ended || (this.ended = !0, await d(this.room), this.emitSession("ended", {}));
697
+ this.ended || (this.ended = !0, await u(this.room), this.emitSession("ended", {}));
678
698
  }
679
699
  getRemoteParticipants() {
680
700
  let e = [];
@@ -748,7 +768,7 @@ var f = class e extends i {
748
768
  console.error(`[im] session handler error: ${e}`, t);
749
769
  }
750
770
  }
751
- }, p = class {
771
+ }, m = class {
752
772
  transport;
753
773
  livekitWs;
754
774
  identity;
@@ -761,7 +781,7 @@ var f = class e extends i {
761
781
  let n = await this.transport.meetingCreate({
762
782
  inviteeUids: e,
763
783
  title: t
764
- }), r = new f({
784
+ }), r = new p({
765
785
  meetingId: n.meetingId,
766
786
  title: t,
767
787
  roomName: n.roomName,
@@ -785,7 +805,7 @@ var f = class e extends i {
785
805
  };
786
806
  }
787
807
  async join(e, t = "") {
788
- let n = await this.transport.meetingJoin(e), r = new f({
808
+ let n = await this.transport.meetingJoin(e), r = new p({
789
809
  meetingId: e,
790
810
  title: t,
791
811
  roomName: n.roomName,
@@ -807,7 +827,7 @@ var f = class e extends i {
807
827
  async respond(e, t, n) {
808
828
  let r = await this.transport.meetingRespond(e, t);
809
829
  if (t !== "accept" || !r?.token || !r?.roomName) return null;
810
- let i = new f({
830
+ let i = new p({
811
831
  meetingId: e,
812
832
  title: r.title || n || "",
813
833
  roomName: r.roomName,
@@ -831,8 +851,8 @@ var f = class e extends i {
831
851
  }
832
852
  async dissolve() {
833
853
  if (!this.currentSession) return !1;
834
- let e = this.currentSession.meetingId;
835
- return await this.transport.meetingDissolve(e), this.currentSession = null, !0;
854
+ let e = this.currentSession;
855
+ return await this.transport.meetingDissolve(e.meetingId), this.currentSession = null, await e.end().catch(() => {}), !0;
836
856
  }
837
857
  async getParticipantCount() {
838
858
  return this.currentSession ? (await this.transport.meetingParticipantCount(this.currentSession.meetingId)).count : 0;
@@ -850,7 +870,7 @@ var f = class e extends i {
850
870
  async getMembers(e = !1) {
851
871
  return this.currentSession ? this.currentSession.refreshMembers(this.transport, e) : [];
852
872
  }
853
- }, m = class {
873
+ }, h = class {
854
874
  transport;
855
875
  realtime;
856
876
  uid;
@@ -920,7 +940,7 @@ var f = class e extends i {
920
940
  dialogChannel(e) {
921
941
  return `dialog#${[this.uid, e].sort()[0]},${[this.uid, e].sort()[1]}`;
922
942
  }
923
- }, h = class {
943
+ }, g = class {
924
944
  transport;
925
945
  constructor(e) {
926
946
  this.transport = e;
@@ -948,7 +968,36 @@ var f = class e extends i {
948
968
  }
949
969
  return { mediaId: i.mediaId };
950
970
  }
951
- }, g = [
971
+ }, _ = class {
972
+ transport;
973
+ byExternal = /* @__PURE__ */ new Map();
974
+ byUid = /* @__PURE__ */ new Map();
975
+ loaded = !1;
976
+ loading = null;
977
+ constructor(e) {
978
+ this.transport = e;
979
+ }
980
+ async list(e = !1) {
981
+ return this.loaded && !e ? [...this.byExternal.values()] : (this.loading ||= this.transport.listUsers().then((e) => {
982
+ for (let t of e.users || []) this.upsert(t);
983
+ this.loaded = !0;
984
+ }).finally(() => {
985
+ this.loading = null;
986
+ }), await this.loading, [...this.byExternal.values()]);
987
+ }
988
+ async resolve(e) {
989
+ let t = this.byExternal.get(e) || this.byUid.get(e);
990
+ if (t) return t;
991
+ if (!this.loaded) return await this.list(), this.byExternal.get(e) || this.byUid.get(e);
992
+ }
993
+ upsert(e) {
994
+ this.byExternal.set(e.externalId, e), this.byUid.set(e.uid, e);
995
+ }
996
+ updateOnline(e, t) {
997
+ let n = this.byExternal.get(e);
998
+ n && n.online !== t && (n.online = t);
999
+ }
1000
+ }, v = [
952
1001
  "message",
953
1002
  "message_preview",
954
1003
  "message:revoked",
@@ -973,7 +1022,7 @@ var f = class e extends i {
973
1022
  "session:kicked",
974
1023
  "connection:state",
975
1024
  "presence:update"
976
- ], _ = class extends i {
1025
+ ], y = class extends i {
977
1026
  auth;
978
1027
  transport;
979
1028
  realtime;
@@ -981,9 +1030,12 @@ var f = class e extends i {
981
1030
  meeting;
982
1031
  message;
983
1032
  media;
1033
+ users;
984
1034
  uid = "";
985
1035
  appId;
986
1036
  sessionState = "idle";
1037
+ clientType = 4;
1038
+ realtimeBound = !1;
987
1039
  clientConfig = null;
988
1040
  livekitWs;
989
1041
  apiBase;
@@ -993,17 +1045,17 @@ var f = class e extends i {
993
1045
  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));
994
1046
  }
995
1047
  async connect(e) {
996
- e.name && (this.name = e.name), e.avatar && (this.avatar = e.avatar);
1048
+ e.name && (this.name = e.name), e.avatar && (this.avatar = e.avatar), this.clientType = e.clientType ?? 4;
997
1049
  let t = await this.auth.login(this.appId, e.externalId, e.clientType ?? 4, e.deviceName);
998
1050
  return this.uid = t.uid, t.name && (this.name = t.name), t.avatarUrl && (this.avatar = t.avatarUrl), await this.initAfterAuth(), t;
999
1051
  }
1000
1052
  async connectWithExternalJwt(e) {
1001
- e.name && (this.name = e.name), e.avatar && (this.avatar = e.avatar), this.uid = e.uid, this.auth.setExternalToken(e.jwt, e.expiresAt), await this.initAfterAuth();
1053
+ e.name && (this.name = e.name), e.avatar && (this.avatar = e.avatar), this.uid = e.uid, this.clientType = e.clientType ?? 4, this.auth.setExternalToken(e.jwt, e.expiresAt), await this.initAfterAuth();
1002
1054
  }
1003
1055
  async initAfterAuth() {
1004
1056
  await this.loadClientConfig();
1005
1057
  let e = this.clientConfig?.iceServers ?? [];
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);
1058
+ this.call = new f(this.transport, this.livekitWs, this.uid, e), this.meeting = new m(this.transport, this.livekitWs, this.uid, e), this.message = new h(this.transport, this.realtime, this.uid), this.media = new g(this.transport), this.users = new _(this.transport), await this.realtime.connect(this.uid);
1007
1059
  try {
1008
1060
  let e = await this.transport.getSessionState();
1009
1061
  this.sessionState = e.state, this.emit("session:state", {
@@ -1014,7 +1066,7 @@ var f = class e extends i {
1014
1066
  } catch (e) {
1015
1067
  console.warn("[im] 同步 sessionState 失败", e);
1016
1068
  }
1017
- this.realtime.on("call:invite", () => {}), this.realtime.on("call:busy", () => {
1069
+ this.realtimeBound || (this.realtimeBound = !0, this.realtime.on("call:busy", () => {
1018
1070
  this.call.currentSession = null;
1019
1071
  }), this.realtime.on("call:no_answer", () => {
1020
1072
  this.call.currentSession = null;
@@ -1027,13 +1079,17 @@ var f = class e extends i {
1027
1079
  }), this.realtime.on("meeting:kicked", (e) => {
1028
1080
  let t = this.meeting?.currentSession;
1029
1081
  t && e?.meetingId === t.meetingId && t.end().catch((e) => console.warn("[im] kicked end session 失败", e));
1030
- }), this.realtime.on("session:kicked", () => {
1031
- console.warn("[im] 会话被踢(同端新登录),断开连接");
1032
- try {
1033
- this.realtime.disconnect();
1034
- } catch {}
1035
- this.auth.logout(), this.uid = "";
1036
- }), this.forwardRealtimeEvents(), this.fetchAndEmitPendingInvites();
1082
+ }), this.realtime.on("session:kicked", (e) => {
1083
+ if (!(e?.clientType !== void 0 && e.clientType !== this.clientType)) {
1084
+ console.warn("[im] 会话被踢(同端新登录),断开连接");
1085
+ try {
1086
+ this.realtime.disconnect();
1087
+ } catch {}
1088
+ this.auth.logout(), this.uid = "";
1089
+ }
1090
+ }), this.realtime.on("presence:update", (e) => {
1091
+ e?.uid && this.users?.updateOnline(e.uid, !!e.online);
1092
+ }), this.forwardRealtimeEvents()), this.fetchAndEmitPendingInvites();
1037
1093
  }
1038
1094
  async loadClientConfig() {
1039
1095
  if (!this.clientConfig) try {
@@ -1061,7 +1117,7 @@ var f = class e extends i {
1061
1117
  }
1062
1118
  }
1063
1119
  forwardRealtimeEvents() {
1064
- for (let e of g) this.realtime.on(e, (t) => {
1120
+ for (let e of v) this.realtime.on(e, (t) => {
1065
1121
  this.emit(e, t);
1066
1122
  });
1067
1123
  }
@@ -1070,6 +1126,6 @@ var f = class e extends i {
1070
1126
  }
1071
1127
  };
1072
1128
  //#endregion
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 };
1129
+ export { a as ApiError, s as AuthManager, f as CallController, d as CallSession, i as EventEmitter, y as ImClient, g as MediaUploader, m as MeetingController, p as MeetingSession, h as MessageController, c as RealtimeConnection, o as Transport, _ as UserDirectory };
1074
1130
 
1075
1131
  //# sourceMappingURL=im-core.es.js.map