@talkjs/core 1.4.0 → 1.4.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.
- package/README.md +8 -0
- package/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +1 -1
- package/dist/talkSession.js +93 -81
- package/package.json +1 -1
package/dist/talkSession.d.ts
CHANGED
|
@@ -1002,7 +1002,7 @@ export declare interface GenericFileBlock {
|
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Never set for generic file blocks.
|
|
1004
1004
|
*/
|
|
1005
|
-
subtype?:
|
|
1005
|
+
subtype?: never;
|
|
1006
1006
|
/**
|
|
1007
1007
|
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this file in another message.
|
|
1008
1008
|
*/
|
package/dist/talkSession.js
CHANGED
|
@@ -763,8 +763,7 @@ class j {
|
|
|
763
763
|
this.pendingStates.push({ seq: e2, resultPromise: s2 });
|
|
764
764
|
}
|
|
765
765
|
get(e2) {
|
|
766
|
-
|
|
767
|
-
for (; this.pendingStates.length > 0 && this.pendingStates[0].seq <= e2; ) this.getPointer = this.pendingStates.shift();
|
|
766
|
+
for (; this.pendingStates.length > 0 && (void 0 === this.getPointer || this.pendingStates[0].seq <= e2); ) this.getPointer = this.pendingStates.shift();
|
|
768
767
|
return this.getPointer;
|
|
769
768
|
}
|
|
770
769
|
}
|
|
@@ -798,8 +797,9 @@ class $ extends j {
|
|
|
798
797
|
}
|
|
799
798
|
}
|
|
800
799
|
class W extends $ {
|
|
801
|
-
constructor(e2) {
|
|
802
|
-
|
|
800
|
+
constructor(e2, t2) {
|
|
801
|
+
const s2 = new Promise((e3) => setTimeout(e3)).then(() => this.fetchInitial(e2));
|
|
802
|
+
super({ seq: e2, resultPromise: s2 }, t2), this.initialSeq = e2, this.getDeepMutex = new U(), this.lastDeep = void 0;
|
|
803
803
|
}
|
|
804
804
|
refetchInitial(e2) {
|
|
805
805
|
return __async(this, null, function* () {
|
|
@@ -819,7 +819,7 @@ class W extends $ {
|
|
|
819
819
|
if (e2 >= t2) return false;
|
|
820
820
|
const s2 = this.get(t2), n2 = yield s2.resultPromise;
|
|
821
821
|
if (!n2.ok) return false;
|
|
822
|
-
if (n2.value.lastChanged > e2) return true;
|
|
822
|
+
if (n2.value.lastChanged > Math.max(this.initialSeq, e2) && n2.value.lastChanged <= t2) return true;
|
|
823
823
|
return yield this.anyChildChanged(e2, t2, n2.value);
|
|
824
824
|
});
|
|
825
825
|
}
|
|
@@ -843,9 +843,9 @@ class W extends $ {
|
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
845
|
class q extends W {
|
|
846
|
-
constructor(e2, t2) {
|
|
847
|
-
super(
|
|
848
|
-
yield this.emit(
|
|
846
|
+
constructor(e2, t2, s2) {
|
|
847
|
+
super(e2, s2), this.emitMutex = t2, this.unsubscribeTimer = new H(), this.referencedByOtherStores = 0, this.listeners = [], this.lastEmitSeq = void 0, this.lastEmitResult = void 0, t2.runExclusive(() => __async(this, null, function* () {
|
|
848
|
+
yield this.emit(e2);
|
|
849
849
|
}));
|
|
850
850
|
}
|
|
851
851
|
registerInternalSubscription() {
|
|
@@ -897,8 +897,8 @@ class H {
|
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
class G extends q {
|
|
900
|
-
constructor(e2, t2, s2, n2) {
|
|
901
|
-
super(
|
|
900
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
901
|
+
super(e2, n2, r2), this.userId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e4;
|
|
902
902
|
}
|
|
903
903
|
fetchInitial(e2) {
|
|
904
904
|
return __async(this, null, function* () {
|
|
@@ -1081,8 +1081,8 @@ function se(e2, t2) {
|
|
|
1081
1081
|
}).join("");
|
|
1082
1082
|
}
|
|
1083
1083
|
class ne extends W {
|
|
1084
|
-
constructor(e2, t2, s2) {
|
|
1085
|
-
super(), this.conversationId =
|
|
1084
|
+
constructor(e2, t2, s2, n2) {
|
|
1085
|
+
super(e2), this.conversationId = t2, this.message = s2, this.realtimeClient = n2;
|
|
1086
1086
|
}
|
|
1087
1087
|
get messageId() {
|
|
1088
1088
|
return "string" == typeof this.message ? this.message : this.message.id;
|
|
@@ -1149,8 +1149,8 @@ class ne extends W {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
class re extends W {
|
|
1152
|
-
constructor(e2, t2, s2) {
|
|
1153
|
-
super(), this.createdAt =
|
|
1152
|
+
constructor(e2, t2, s2, n2) {
|
|
1153
|
+
super(e2), this.createdAt = t2, this.dataStore = s2, this.referencedDataStore = n2;
|
|
1154
1154
|
}
|
|
1155
1155
|
get messageId() {
|
|
1156
1156
|
return this.dataStore.messageId;
|
|
@@ -1189,8 +1189,8 @@ class re extends W {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
class ie extends q {
|
|
1192
|
-
constructor(e2, t2, s2, n2) {
|
|
1193
|
-
super(
|
|
1192
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1193
|
+
super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
|
|
1194
1194
|
}
|
|
1195
1195
|
listen(e2) {
|
|
1196
1196
|
return this.onlyUsedInternally && this.mostRecentState.resultPromise.then((e3) => {
|
|
@@ -1265,12 +1265,12 @@ class ie extends q {
|
|
|
1265
1265
|
if (null === s2.value.stores) return console.warn("[TalkJS] Received a 'message.created' event for a nonexistent conversation."), s2;
|
|
1266
1266
|
if (s2.value.windowEnd && t2.state.createdAt < s2.value.windowEnd.oldestMessageTs) return s2;
|
|
1267
1267
|
if (Object.hasOwnProperty.call(s2.value.stores, t2.state.id)) return s2;
|
|
1268
|
-
const n2 = __spreadValues({}, s2.value.stores), r2 = new ne(this.conversationId, t2.state, this.realtimeClient);
|
|
1268
|
+
const n2 = __spreadValues({}, s2.value.stores), r2 = new ne(e2, this.conversationId, t2.state, this.realtimeClient);
|
|
1269
1269
|
n2[t2.state.id] = r2;
|
|
1270
1270
|
const i2 = t2.state.referencedMessageId;
|
|
1271
1271
|
let a2;
|
|
1272
|
-
null === i2 ? a2 = null : i2 in n2 ? a2 = n2[i2] : (a2 = new ne(this.conversationId, i2, this.realtimeClient), n2[i2] = a2);
|
|
1273
|
-
const o2 = new re(t2.state.createdAt, r2, a2), u2 = [...s2.value.inWindow, o2];
|
|
1272
|
+
null === i2 ? a2 = null : i2 in n2 ? a2 = n2[i2] : (a2 = new ne(e2, this.conversationId, i2, this.realtimeClient), n2[i2] = a2);
|
|
1273
|
+
const o2 = new re(e2, t2.state.createdAt, r2, a2), u2 = [...s2.value.inWindow, o2];
|
|
1274
1274
|
u2.sort((e3, t3) => t3.createdAt - e3.createdAt);
|
|
1275
1275
|
const l2 = u2[0].messageId === t2.messageId ? e2 : s2.value.lastMessageChanged;
|
|
1276
1276
|
return c({ lastChanged: e2, lastMessageChanged: l2, stores: n2, inWindow: u2, windowEnd: s2.value.windowEnd });
|
|
@@ -1290,13 +1290,13 @@ class ie extends q {
|
|
|
1290
1290
|
delete n2[t2.messageId];
|
|
1291
1291
|
const r2 = s2.value.inWindow.filter((e3) => e3.messageId !== t2.messageId);
|
|
1292
1292
|
if (t2.newLastMessage && 0 === r2.length) {
|
|
1293
|
-
const
|
|
1294
|
-
n2[
|
|
1295
|
-
const
|
|
1296
|
-
let
|
|
1297
|
-
null ===
|
|
1298
|
-
const
|
|
1299
|
-
r2.push(
|
|
1293
|
+
const s3 = new ne(e2, this.conversationId, t2.newLastMessage, this.realtimeClient);
|
|
1294
|
+
n2[s3.messageId] = s3;
|
|
1295
|
+
const i3 = t2.newLastMessage.referencedMessageId;
|
|
1296
|
+
let a2;
|
|
1297
|
+
null === i3 ? a2 = null : i3 in n2 ? a2 = n2[i3] : (a2 = new ne(e2, this.conversationId, i3, this.realtimeClient), n2[i3] = a2);
|
|
1298
|
+
const o2 = new re(e2, t2.newLastMessage.createdAt, s3, a2);
|
|
1299
|
+
r2.push(o2);
|
|
1300
1300
|
}
|
|
1301
1301
|
const i2 = void 0 !== t2.newLastMessage ? e2 : s2.value.lastMessageChanged;
|
|
1302
1302
|
return c({ lastChanged: e2, lastMessageChanged: i2, stores: n2, inWindow: r2, windowEnd: s2.value.windowEnd });
|
|
@@ -1340,27 +1340,27 @@ function ae(_0) {
|
|
|
1340
1340
|
function oe({ seq: e2, prevState: t2, messages: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
|
|
1341
1341
|
var _a2, _b, _c, _d;
|
|
1342
1342
|
const a2 = t2 ? __spreadValues({}, t2.stores) : {};
|
|
1343
|
-
for (const
|
|
1344
|
-
const
|
|
1345
|
-
a2[
|
|
1346
|
-
}
|
|
1347
|
-
for (const
|
|
1348
|
-
const
|
|
1349
|
-
if (
|
|
1350
|
-
const
|
|
1351
|
-
a2[
|
|
1343
|
+
for (const t3 of s2) if (void 0 === a2[t3.id]) {
|
|
1344
|
+
const s3 = new ne(e2, r2, t3, i2);
|
|
1345
|
+
a2[s3.messageId] = s3;
|
|
1346
|
+
}
|
|
1347
|
+
for (const t3 of s2) {
|
|
1348
|
+
const s3 = t3.referencedMessageId;
|
|
1349
|
+
if (s3 && void 0 === a2[s3]) {
|
|
1350
|
+
const t4 = new ne(e2, r2, s3, i2);
|
|
1351
|
+
a2[t4.messageId] = t4;
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
1354
|
const o2 = t2 ? [...t2.inWindow] : [];
|
|
1355
|
-
for (const
|
|
1355
|
+
for (const t3 of s2) o2.push(new re(e2, t3.createdAt, a2[t3.id], t3.referencedMessageId ? a2[t3.referencedMessageId] : null));
|
|
1356
1356
|
o2.sort((e3, t3) => t3.createdAt - e3.createdAt);
|
|
1357
1357
|
const u2 = (_b = (_a2 = t2 == null ? void 0 : t2.inWindow) == null ? void 0 : _a2[0]) == null ? void 0 : _b.messageId, l2 = (_c = o2 == null ? void 0 : o2[0]) == null ? void 0 : _c.messageId, h2 = u2 === l2 ? (_d = t2 == null ? void 0 : t2.lastMessageChanged) != null ? _d : e2 : e2;
|
|
1358
1358
|
if (null === n2) return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: null });
|
|
1359
1359
|
return c({ lastChanged: e2, lastMessageChanged: h2, stores: a2, inWindow: o2, windowEnd: { cursor: n2, oldestMessageTs: s2[s2.length - 1].createdAt } });
|
|
1360
1360
|
}
|
|
1361
1361
|
class ue extends q {
|
|
1362
|
-
constructor(e2, t2, s2, n2) {
|
|
1363
|
-
super(
|
|
1362
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1363
|
+
super(e2, n2, r2), this.convDataStore = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 0;
|
|
1364
1364
|
}
|
|
1365
1365
|
fetchInitial(e2) {
|
|
1366
1366
|
return __async(this, null, function* () {
|
|
@@ -1402,8 +1402,8 @@ function le(e2, t2) {
|
|
|
1402
1402
|
}(e2, ([e3, s2]) => [e3, t2(s2, e3)]);
|
|
1403
1403
|
}
|
|
1404
1404
|
class he extends q {
|
|
1405
|
-
constructor(e2, t2, s2, n2) {
|
|
1406
|
-
super(
|
|
1405
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1406
|
+
super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e4;
|
|
1407
1407
|
}
|
|
1408
1408
|
fetchInitial(e2) {
|
|
1409
1409
|
return __async(this, null, function* () {
|
|
@@ -1471,8 +1471,8 @@ class he extends q {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
class de extends W {
|
|
1474
|
-
constructor(e2, t2, s2) {
|
|
1475
|
-
super(), this.conversationId =
|
|
1474
|
+
constructor(e2, t2, s2, n2) {
|
|
1475
|
+
super(e2), this.conversationId = t2, this.participantData = s2, this.realtimeClient = n2;
|
|
1476
1476
|
}
|
|
1477
1477
|
fetchInitial(e2) {
|
|
1478
1478
|
return __async(this, null, function* () {
|
|
@@ -1527,8 +1527,8 @@ class de extends W {
|
|
|
1527
1527
|
}
|
|
1528
1528
|
}
|
|
1529
1529
|
class pe extends q {
|
|
1530
|
-
constructor(e2, t2, s2, n2) {
|
|
1531
|
-
super(
|
|
1530
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1531
|
+
super(e2, n2, r2), this.conversationId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
|
|
1532
1532
|
}
|
|
1533
1533
|
fetchInitial(e2) {
|
|
1534
1534
|
return __async(this, null, function* () {
|
|
@@ -1584,7 +1584,7 @@ class pe extends q {
|
|
|
1584
1584
|
if (null === s2.value.stores) return console.warn("[TalkJS] Received a 'participant.created' event for a nonexistent conversation."), s2;
|
|
1585
1585
|
if (s2.value.windowEnd && t2.state.joinedAt < s2.value.windowEnd.oldestParticipantTs) return s2;
|
|
1586
1586
|
if (Object.hasOwnProperty.call(s2.value.stores, t2.state.id)) return s2;
|
|
1587
|
-
const n2 = __spreadValues({}, s2.value.stores), r2 = new de(this.conversationId, t2.state, this.realtimeClient);
|
|
1587
|
+
const n2 = __spreadValues({}, s2.value.stores), r2 = new de(e2, this.conversationId, t2.state, this.realtimeClient);
|
|
1588
1588
|
n2[t2.state.id] = r2;
|
|
1589
1589
|
return c({ lastChanged: e2, stores: n2, windowEnd: s2.value.windowEnd });
|
|
1590
1590
|
});
|
|
@@ -1636,16 +1636,16 @@ function fe(_0) {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
function me({ seq: e2, prevStores: t2, participants: s2, cursor: n2, conversationId: r2, realtimeClient: i2 }) {
|
|
1638
1638
|
const a2 = t2 ? __spreadValues({}, t2) : {};
|
|
1639
|
-
for (const
|
|
1640
|
-
const
|
|
1641
|
-
a2[
|
|
1639
|
+
for (const t3 of s2) if (void 0 === a2[t3.id]) {
|
|
1640
|
+
const s3 = new de(e2, r2, t3, i2);
|
|
1641
|
+
a2[t3.id] = s3;
|
|
1642
1642
|
}
|
|
1643
1643
|
if (null === n2) return c({ lastChanged: e2, stores: a2, windowEnd: null });
|
|
1644
1644
|
return c({ lastChanged: e2, stores: a2, windowEnd: { cursor: n2, oldestParticipantTs: s2[s2.length - 1].joinedAt } });
|
|
1645
1645
|
}
|
|
1646
1646
|
class ge extends q {
|
|
1647
|
-
constructor(e2, t2, s2, n2) {
|
|
1648
|
-
super(
|
|
1647
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1648
|
+
super(e2, n2, r2), this.getConvDataStore = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
|
|
1649
1649
|
}
|
|
1650
1650
|
fetchInitial(e2) {
|
|
1651
1651
|
return __async(this, null, function* () {
|
|
@@ -1758,8 +1758,8 @@ function we({ seq: e2, prevStores: t2, conversations: s2, cursor: n2, getConvDat
|
|
|
1758
1758
|
return c({ lastChanged: e2, stores: i2, windowEnd: { cursor: n2, oldestMessageTs: Math.min(...s2.map((e3) => e3.lastMessageAt)) } });
|
|
1759
1759
|
}
|
|
1760
1760
|
class be extends q {
|
|
1761
|
-
constructor(e2, t2, s2, n2) {
|
|
1762
|
-
super(
|
|
1761
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1762
|
+
super(e2, n2, r2), this.conversation = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 5e3;
|
|
1763
1763
|
}
|
|
1764
1764
|
get conversationId() {
|
|
1765
1765
|
return "string" == typeof this.conversation ? this.conversation : this.conversation.id;
|
|
@@ -1828,8 +1828,8 @@ function ye(e2, t2) {
|
|
|
1828
1828
|
return { id: e2.id, createdAt: e2.createdAt, subject: _(e2.subject, s2.subject), photoUrl: _(e2.photoUrl, s2.photoUrl), welcomeMessages: _(e2.welcomeMessages, s2.welcomeMessages), custom: P(e2.custom, s2.custom), lastMessageAt: _(e2.lastMessageAt, s2.lastMessageAt), unreadMessageCount: _(e2.unreadMessageCount, s2.unreadMessageCount), isUnread: _(e2.isUnread, s2.isUnread), access: _(e2.access, s2.access), notify: _(e2.notify, s2.notify), readUntil: _(e2.readUntil, s2.readUntil), everyoneReadUntil: _(e2.everyoneReadUntil, s2.everyoneReadUntil), joinedAt: e2.joinedAt };
|
|
1829
1829
|
}
|
|
1830
1830
|
class Ce extends q {
|
|
1831
|
-
constructor(e2, t2, s2, n2) {
|
|
1832
|
-
super(
|
|
1831
|
+
constructor(e2, t2, s2, n2, r2) {
|
|
1832
|
+
super(e2, n2, r2), this.userId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e3;
|
|
1833
1833
|
}
|
|
1834
1834
|
fetchInitial(e2) {
|
|
1835
1835
|
return __async(this, null, function* () {
|
|
@@ -2033,13 +2033,13 @@ class Ae {
|
|
|
2033
2033
|
return this.connection.isConnected();
|
|
2034
2034
|
}
|
|
2035
2035
|
instantiateStore(e2, t2) {
|
|
2036
|
-
if (s(e2, ["users", "*"])) return new G(e2[1], this.realtimeClient, this.emitMutex, t2);
|
|
2037
|
-
if (s(e2, ["me", "conversations", "*"])) return new ue(this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, t2);
|
|
2038
|
-
if (s(e2, ["me", "conversations", "*", "messages"])) return new ie(e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2039
|
-
if (s(e2, ["me", "conversations", "*", "participants"])) return new pe(e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2040
|
-
if (s(e2, ["me", "conversations", "*", "typing"])) return new he(e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2041
|
-
if (s(e2, ["me", "conversations"])) return new ge((e3) => this.subscribeConvData(e3), this.realtimeClient, this.emitMutex, t2);
|
|
2042
|
-
if (s(e2, ["users", "*", "online"])) return new Ce(e2[1], this.realtimeClient, this.emitMutex, t2);
|
|
2036
|
+
if (s(e2, ["users", "*"])) return new G(this.seq, e2[1], this.realtimeClient, this.emitMutex, t2);
|
|
2037
|
+
if (s(e2, ["me", "conversations", "*"])) return new ue(this.seq, this.subscribeConvData(e2[2]), this.realtimeClient, this.emitMutex, t2);
|
|
2038
|
+
if (s(e2, ["me", "conversations", "*", "messages"])) return new ie(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2039
|
+
if (s(e2, ["me", "conversations", "*", "participants"])) return new pe(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2040
|
+
if (s(e2, ["me", "conversations", "*", "typing"])) return new he(this.seq, e2[2], this.realtimeClient, this.emitMutex, t2);
|
|
2041
|
+
if (s(e2, ["me", "conversations"])) return new ge(this.seq, (e3) => this.subscribeConvData(e3), this.realtimeClient, this.emitMutex, t2);
|
|
2042
|
+
if (s(e2, ["users", "*", "online"])) return new Ce(this.seq, e2[1], this.realtimeClient, this.emitMutex, t2);
|
|
2043
2043
|
throw "Unreachable";
|
|
2044
2044
|
}
|
|
2045
2045
|
subscribeConvData(e2) {
|
|
@@ -2048,7 +2048,7 @@ class Ae {
|
|
|
2048
2048
|
const e3 = this.convDataStores[t2];
|
|
2049
2049
|
return { store: e3, unsubscribe: e3.registerInternalSubscription() };
|
|
2050
2050
|
}
|
|
2051
|
-
const s2 = new be(e2, this.realtimeClient, this.emitMutex, () => {
|
|
2051
|
+
const s2 = new be(this.seq, e2, this.realtimeClient, this.emitMutex, () => {
|
|
2052
2052
|
delete this.convDataStores[t2];
|
|
2053
2053
|
});
|
|
2054
2054
|
return this.convDataStores[t2] = s2, { store: s2, unsubscribe: s2.registerInternalSubscription() };
|
|
@@ -3305,11 +3305,24 @@ class cs {
|
|
|
3305
3305
|
const i2 = encodeURIComponent(t2);
|
|
3306
3306
|
return this.realtimeWsApiUrl + `/${e2}/realtime/${i2}?talkjs-client-build=${r2 != null ? r2 : "standalone"}&talkjs-core=${s2}&talkjs-client-id=${n2}`;
|
|
3307
3307
|
}
|
|
3308
|
+
static fromHost(e2) {
|
|
3309
|
+
const t2 = new cs("wss://realtime.talkjs.com/v1", "https://app.talkjs.com/api/v0", "https://api.talkjs.com/v1");
|
|
3310
|
+
if (!e2) return t2;
|
|
3311
|
+
if (e2.endsWith("talkjs.com")) {
|
|
3312
|
+
const s2 = e2.match(/\w+-(\w+)\.talkjs\.com/);
|
|
3313
|
+
if (s2) {
|
|
3314
|
+
const e3 = s2[1];
|
|
3315
|
+
return new cs(`wss://realtime-${e3}.talkjs.com/v1`, `https://app-${e3}.talkjs.com/api/v0`, `https://api-${e3}.talkjs.com/v1`);
|
|
3316
|
+
}
|
|
3317
|
+
return t2;
|
|
3318
|
+
}
|
|
3319
|
+
return e2.includes("localhost") || e2.includes("localtest.me") || /^\d+\.\d+\.\d+\.\d+(:\d+)?$/.test(e2) ? new cs(`ws://${e2}/public_api/v1`, `http://${e2}/api/v0`, `http://${e2}/public_api/v1`) : new cs(`wss://${e2}/public_api/v1`, `https://${e2}/api/v0`, `https://${e2}/public_api/v1`);
|
|
3320
|
+
}
|
|
3308
3321
|
}
|
|
3309
3322
|
function ls({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2 }) {
|
|
3310
3323
|
var _a2;
|
|
3311
3324
|
(!r2 || r2 <= 0) && (r2 = 1);
|
|
3312
|
-
const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-07-
|
|
3325
|
+
const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-07-28T10:49:18.625Z" };
|
|
3313
3326
|
s2 instanceof FormData || (u2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
|
|
3314
3327
|
return a(r2, () => __async(this, null, function* () {
|
|
3315
3328
|
if (o2) {
|
|
@@ -3362,7 +3375,7 @@ const vs = ds.startsWith("app.talkjs.com");
|
|
|
3362
3375
|
const ws = "undefined" == typeof window ? { log: (e2) => Promise.resolve(), setData: (e2) => {
|
|
3363
3376
|
} } : new class {
|
|
3364
3377
|
constructor(e2) {
|
|
3365
|
-
this._timeCreated = Date.now(), this._enabled = vs, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-07-
|
|
3378
|
+
this._timeCreated = Date.now(), this._enabled = vs, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-07-28T10:49:18.625Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: window.location.href, referrer: document.referrer, userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: window.location.href, stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2025-07-28T10:49:18.625Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
|
|
3366
3379
|
}
|
|
3367
3380
|
setData({ appId: e2, meId: t2, sessionId: s2 }) {
|
|
3368
3381
|
this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
|
|
@@ -3582,8 +3595,7 @@ function Cs(e2) {
|
|
|
3582
3595
|
throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
|
|
3583
3596
|
}
|
|
3584
3597
|
}
|
|
3585
|
-
|
|
3586
|
-
class Es {
|
|
3598
|
+
class As {
|
|
3587
3599
|
constructor(e2) {
|
|
3588
3600
|
this.target = e2;
|
|
3589
3601
|
}
|
|
@@ -3591,7 +3603,7 @@ class Es {
|
|
|
3591
3603
|
return this.target;
|
|
3592
3604
|
}
|
|
3593
3605
|
}
|
|
3594
|
-
const
|
|
3606
|
+
const Es = new class {
|
|
3595
3607
|
constructor() {
|
|
3596
3608
|
this.registry = {};
|
|
3597
3609
|
}
|
|
@@ -3599,7 +3611,7 @@ const ks = new class {
|
|
|
3599
3611
|
var _a2;
|
|
3600
3612
|
const t2 = this.key(e2), s2 = (_a2 = this.registry[t2]) == null ? void 0 : _a2.deref();
|
|
3601
3613
|
if (s2) return s2;
|
|
3602
|
-
const n2 = new
|
|
3614
|
+
const n2 = new xs(e2), r2 = globalThis.WeakRef ? new WeakRef(n2) : new As(n2);
|
|
3603
3615
|
return this.registry[t2] = r2, n2;
|
|
3604
3616
|
}
|
|
3605
3617
|
deregister(e2, t2) {
|
|
@@ -3610,10 +3622,10 @@ const ks = new class {
|
|
|
3610
3622
|
return `${e2}:${t2}`;
|
|
3611
3623
|
}
|
|
3612
3624
|
}();
|
|
3613
|
-
function
|
|
3614
|
-
return e2.forceCreateNew ? new
|
|
3625
|
+
function ks(e2) {
|
|
3626
|
+
return e2.forceCreateNew ? new xs(e2) : Es.getOrCreate(e2);
|
|
3615
3627
|
}
|
|
3616
|
-
class
|
|
3628
|
+
class xs {
|
|
3617
3629
|
constructor(e2) {
|
|
3618
3630
|
!function(e3) {
|
|
3619
3631
|
function t3(e4, t4) {
|
|
@@ -3623,9 +3635,9 @@ class Ts {
|
|
|
3623
3635
|
void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of TalkSession#constructor must be a function.");
|
|
3624
3636
|
}(e2);
|
|
3625
3637
|
const { appId: t2, userId: s2, token: n2, tokenFetcher: r2, signature: i2 } = e2;
|
|
3626
|
-
this._appId = t2, this._apiUrls = e2.apiUrls ? new cs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) :
|
|
3638
|
+
this._appId = t2, this._apiUrls = e2.apiUrls ? new cs(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : cs.fromHost(e2.host), this._authProvider = new ys(this._apiUrls, t2, s2, n2, r2, i2);
|
|
3627
3639
|
const a2 = Math.random().toString().split(".")[1];
|
|
3628
|
-
this._realtimeClient = new ke(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.
|
|
3640
|
+
this._realtimeClient = new ke(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.4.1", a2, e2.clientBuild), s2, this._authProvider), this.currentUser = new Ie(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
|
|
3629
3641
|
console.error(`[TalkSession] ${e3}`);
|
|
3630
3642
|
}), function(e3, t3, s3) {
|
|
3631
3643
|
return __async(this, null, function* () {
|
|
@@ -3659,28 +3671,28 @@ class Ts {
|
|
|
3659
3671
|
return this._realtimeClient.subscribe(["me", "conversations"], e2);
|
|
3660
3672
|
}
|
|
3661
3673
|
terminate(e2) {
|
|
3662
|
-
|
|
3674
|
+
Es.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
|
|
3663
3675
|
}
|
|
3664
3676
|
_isConnected() {
|
|
3665
3677
|
return this._realtimeClient.isConnected();
|
|
3666
3678
|
}
|
|
3667
3679
|
uploadFile(e2, t2) {
|
|
3668
|
-
return
|
|
3680
|
+
return Ts(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, t2);
|
|
3669
3681
|
}
|
|
3670
3682
|
uploadImage(e2, t2) {
|
|
3671
|
-
return
|
|
3683
|
+
return Ts(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "image" }, t2));
|
|
3672
3684
|
}
|
|
3673
3685
|
uploadVideo(e2, t2) {
|
|
3674
|
-
return
|
|
3686
|
+
return Ts(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "video" }, t2));
|
|
3675
3687
|
}
|
|
3676
3688
|
uploadAudio(e2, t2) {
|
|
3677
|
-
return
|
|
3689
|
+
return Ts(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "audio" }, t2));
|
|
3678
3690
|
}
|
|
3679
3691
|
uploadVoice(e2, t2) {
|
|
3680
|
-
return
|
|
3692
|
+
return Ts(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "voice" }, t2));
|
|
3681
3693
|
}
|
|
3682
3694
|
}
|
|
3683
|
-
function
|
|
3695
|
+
function Ts(_0, _1, _2, _3) {
|
|
3684
3696
|
return __async(this, arguments, function* (e2, t2, s2, { subtype: n2, filename: r2, width: i2, height: a2, duration: o2 }) {
|
|
3685
3697
|
const u2 = new FormData();
|
|
3686
3698
|
return u2.set("file", s2, r2), void 0 !== n2 && u2.set("subtype", n2), void 0 !== i2 && u2.set("width", i2.toString()), void 0 !== a2 && u2.set("height", a2.toString()), void 0 !== o2 && u2.set("duration", o2.toString()), ls({ method: "POST", url: e2, data: u2, authProvider: t2 }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
|
|
@@ -3693,7 +3705,7 @@ function Is(_0, _1, _2, _3) {
|
|
|
3693
3705
|
});
|
|
3694
3706
|
}
|
|
3695
3707
|
export {
|
|
3696
|
-
|
|
3708
|
+
ks as getTalkSession,
|
|
3697
3709
|
f as registerPolyfills
|
|
3698
3710
|
};
|
|
3699
3711
|
//# sourceMappingURL=talkSession.js.map
|