@talkjs/core 0.0.4 → 0.0.6
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/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +24 -223
- package/dist/talkSession.js +79 -64
- package/package.json +3 -2
package/dist/talkSession.js
CHANGED
|
@@ -75,7 +75,7 @@ const i = () => true;
|
|
|
75
75
|
function a(_0, _1, _2) {
|
|
76
76
|
return __async(this, arguments, function* (e2, t2, { initialDelay: s2, maxDelay: o2, log: u2, shouldRetry: c2 = i }) {
|
|
77
77
|
return t2().catch((i2) => __async(this, null, function* () {
|
|
78
|
-
if (
|
|
78
|
+
if (0 === e2) throw i2;
|
|
79
79
|
if (!(yield c2(i2))) throw i2;
|
|
80
80
|
const l2 = 1e3 * s2 * 1.2, h2 = r(o2 ? Math.min(1e3 * o2, l2) : l2, 0.05);
|
|
81
81
|
return n(h2).then(() => a(e2 - 1, t2, { initialDelay: h2 / 1e3, maxDelay: o2, log: u2, shouldRetry: c2 }));
|
|
@@ -649,7 +649,7 @@ class M {
|
|
|
649
649
|
function R(e2) {
|
|
650
650
|
return e2.map((e3) => encodeURIComponent(e3)).join();
|
|
651
651
|
}
|
|
652
|
-
class
|
|
652
|
+
class _ {
|
|
653
653
|
constructor() {
|
|
654
654
|
this.paths = {};
|
|
655
655
|
}
|
|
@@ -669,9 +669,9 @@ class O {
|
|
|
669
669
|
Object.values(this.paths).forEach((t2) => e2(t2));
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
class
|
|
672
|
+
class O {
|
|
673
673
|
constructor(e2, t2, s2) {
|
|
674
|
-
this.handlers = s2, this.targetSubscriptions = new
|
|
674
|
+
this.handlers = s2, this.targetSubscriptions = new _(), this.connection = new B(e2, t2, { onUpstreamRestarting: () => this.handlers.onUpstreamRestarting(), onSubscriptionsLost: () => {
|
|
675
675
|
this.targetSubscriptions.forEach((e3) => {
|
|
676
676
|
this.resubscribe(e3);
|
|
677
677
|
}), this.handlers.onResubscribeSent();
|
|
@@ -747,7 +747,7 @@ class j {
|
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
class
|
|
750
|
+
class $ {
|
|
751
751
|
constructor(e2, t2) {
|
|
752
752
|
this.onTeardown = t2, this.error = null, this.lastLoadedState = void 0, this.lastGoodState = Promise.resolve(void 0), this.initialised = false, this.getDeepMutex = new j(), this.lastDeep = void 0;
|
|
753
753
|
const s2 = { seq: 0, resultPromise: new Promise((e3) => setTimeout(e3)).then(() => __async(this, null, function* () {
|
|
@@ -806,7 +806,7 @@ class W {
|
|
|
806
806
|
}));
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
class
|
|
809
|
+
class W extends $ {
|
|
810
810
|
constructor(e2, t2, s2) {
|
|
811
811
|
super(e2, s2), this.emitMutex = t2, this.unsubscribeTimer = new q(), this.referencedByOtherStores = 0, this.listeners = [], this.lastEmitSeq = void 0, this.lastEmitResult = void 0, t2.runExclusive(() => __async(this, null, function* () {
|
|
812
812
|
yield this.emit(e2);
|
|
@@ -855,7 +855,7 @@ class q {
|
|
|
855
855
|
clearTimeout(this.timerId);
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
|
-
class H extends
|
|
858
|
+
class H extends W {
|
|
859
859
|
constructor(e2, t2, s2, n2, r2) {
|
|
860
860
|
super(e2, n2, r2), this.userId = t2, this.realtimeClient = s2, this.unsubscribeDebounceMs = 1e4;
|
|
861
861
|
}
|
|
@@ -1055,7 +1055,7 @@ function ae(e2, t2) {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
}).join("");
|
|
1057
1057
|
}
|
|
1058
|
-
class oe extends
|
|
1058
|
+
class oe extends $ {
|
|
1059
1059
|
constructor(e2, t2, s2, n2) {
|
|
1060
1060
|
super(e2), this.conversationId = t2, this.message = s2, this.realtimeClient = n2;
|
|
1061
1061
|
}
|
|
@@ -1116,7 +1116,7 @@ class oe extends W {
|
|
|
1116
1116
|
});
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
|
-
class ue extends
|
|
1119
|
+
class ue extends $ {
|
|
1120
1120
|
constructor(e2, t2, s2, n2) {
|
|
1121
1121
|
super(e2), this.createdAt = t2, this.dataStore = s2, this.referencedDataStore = n2;
|
|
1122
1122
|
}
|
|
@@ -1150,7 +1150,7 @@ class ue extends W {
|
|
|
1150
1150
|
});
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
|
-
class ce extends
|
|
1153
|
+
class ce extends W {
|
|
1154
1154
|
constructor(e2, t2, s2, n2, r2) {
|
|
1155
1155
|
super(e2, t2, r2), this.conversationId = s2, this.realtimeClient = n2, this.unsubscribeDebounceMs = 1e3, this.pendingLoadMore = void 0;
|
|
1156
1156
|
}
|
|
@@ -1295,7 +1295,7 @@ function de(e2) {
|
|
|
1295
1295
|
Object.values(e2.stores).forEach((e3) => e3.setError(t2)), e2.inWindow.forEach((e3) => e3.setError(t2));
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
|
-
class pe extends
|
|
1298
|
+
class pe extends W {
|
|
1299
1299
|
constructor(e2, t2, s2, n2, r2) {
|
|
1300
1300
|
super(e2, t2, r2), this.conversationId = s2, this.realtimeClient = n2, this.unsubscribeDebounceMs = 5e3;
|
|
1301
1301
|
}
|
|
@@ -1353,11 +1353,11 @@ class pe extends $ {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
function fe(e2, t2) {
|
|
1355
1355
|
const s2 = t2;
|
|
1356
|
-
return { id: e2.id, createdAt: e2.createdAt, subject: N(e2.subject, s2.subject), photoUrl: N(e2.photoUrl, s2.photoUrl), welcomeMessages: N(e2.welcomeMessages, s2.welcomeMessages), custom: P(e2.custom, s2.custom), lastMessageAt: N(e2.lastMessageAt, s2.lastMessageAt), unreadMessageCount: N(e2.unreadMessageCount, s2.unreadMessageCount), isUnread: N(e2.isUnread, s2.isUnread), access: N(e2.access, s2.access), notify: N(e2.notify, s2.notify), joinedAt: e2.joinedAt };
|
|
1356
|
+
return { id: e2.id, createdAt: e2.createdAt, subject: N(e2.subject, s2.subject), photoUrl: N(e2.photoUrl, s2.photoUrl), welcomeMessages: N(e2.welcomeMessages, s2.welcomeMessages), custom: P(e2.custom, s2.custom), lastMessageAt: N(e2.lastMessageAt, s2.lastMessageAt), unreadMessageCount: N(e2.unreadMessageCount, s2.unreadMessageCount), isUnread: N(e2.isUnread, s2.isUnread), access: N(e2.access, s2.access), notify: N(e2.notify, s2.notify), readUntil: N(e2.readUntil, s2.readUntil), joinedAt: e2.joinedAt };
|
|
1357
1357
|
}
|
|
1358
1358
|
class me {
|
|
1359
1359
|
constructor(e2, t2, s2) {
|
|
1360
|
-
this.realtimeClient = s2, this.userStores = {}, this.messageWindowStores = {}, this.conversationStores = {}, this.emitMutex = new j(), this.seqOffset = 0, this.seqInThisConnection = 0, this.refetchOnNextNetworkLoss = true, this.connection = new
|
|
1360
|
+
this.realtimeClient = s2, this.userStores = {}, this.messageWindowStores = {}, this.conversationStores = {}, this.emitMutex = new j(), this.seqOffset = 0, this.seqInThisConnection = 0, this.refetchOnNextNetworkLoss = true, this.connection = new O(e2, t2, { onUpstreamRestarting: () => {
|
|
1361
1361
|
this.refetchOnNextNetworkLoss = false;
|
|
1362
1362
|
}, onReady: () => {
|
|
1363
1363
|
this.refetchOnNextNetworkLoss = true;
|
|
@@ -1615,7 +1615,7 @@ class ge {
|
|
|
1615
1615
|
});
|
|
1616
1616
|
}
|
|
1617
1617
|
createConversationSnapshotPreloaded(e2, t2) {
|
|
1618
|
-
return { id: e2.id, subject: e2.subject, photoUrl: e2.photoUrl, welcomeMessages: e2.welcomeMessages, custom: e2.custom, createdAt: e2.createdAt, joinedAt: e2.joinedAt, lastMessageAt: e2.lastMessageAt, unreadMessageCount: e2.unreadMessageCount, isUnread: e2.isUnread, access: e2.access, notify: e2.notify, lastMessage: t2 };
|
|
1618
|
+
return { id: e2.id, subject: e2.subject, photoUrl: e2.photoUrl, welcomeMessages: e2.welcomeMessages, custom: e2.custom, createdAt: e2.createdAt, joinedAt: e2.joinedAt, lastMessageAt: e2.lastMessageAt, unreadMessageCount: e2.unreadMessageCount, isUnread: e2.isUnread, access: e2.access, notify: e2.notify, lastMessage: t2, readUntil: e2.readUntil };
|
|
1619
1619
|
}
|
|
1620
1620
|
createUserSnapshot(e2) {
|
|
1621
1621
|
return { id: e2.id, name: e2.name, custom: e2.custom, locale: e2.locale, photoUrl: e2.photoUrl, role: e2.role, welcomeMessage: e2.welcomeMessage };
|
|
@@ -1683,15 +1683,15 @@ class ye {
|
|
|
1683
1683
|
set(t2) {
|
|
1684
1684
|
return __async(this, null, function* () {
|
|
1685
1685
|
null === t2.role && (t2.role = "default");
|
|
1686
|
-
const s2 = yield this._realtimeClient.call("PUT", ["users", this.brandedId], t2);
|
|
1687
|
-
e("Set user " + this.id,
|
|
1686
|
+
const s2 = "string" == typeof t2.email ? [t2.email] : t2.email, n2 = "string" == typeof t2.phone ? [t2.phone] : t2.phone, r2 = yield this._realtimeClient.call("PUT", ["users", this.brandedId], __spreadProps(__spreadValues({}, t2), { email: s2, phone: n2 }));
|
|
1687
|
+
e("Set user " + this.id, r2);
|
|
1688
1688
|
});
|
|
1689
1689
|
}
|
|
1690
1690
|
createIfNotExists(t2) {
|
|
1691
1691
|
return __async(this, null, function* () {
|
|
1692
1692
|
void 0 === t2.role && (t2.role = "default");
|
|
1693
|
-
const s2 = yield this._realtimeClient.call("POST", ["users", this.brandedId], t2);
|
|
1694
|
-
(
|
|
1693
|
+
const s2 = "string" == typeof t2.email ? [t2.email] : t2.email, n2 = "string" == typeof t2.phone ? [t2.phone] : t2.phone, r2 = yield this._realtimeClient.call("POST", ["users", this.brandedId], __spreadProps(__spreadValues({}, t2), { email: s2, phone: n2 }));
|
|
1694
|
+
(r2.ok || "server" !== r2.where || 409 != r2.value.status) && e(`Create user ${this.id} if not exists`, r2);
|
|
1695
1695
|
});
|
|
1696
1696
|
}
|
|
1697
1697
|
subscribe(e2) {
|
|
@@ -1857,7 +1857,7 @@ function Me(e2, t2) {
|
|
|
1857
1857
|
function Re(e2) {
|
|
1858
1858
|
throw new Error("Unhandled case for value: '" + e2 + "'");
|
|
1859
1859
|
}
|
|
1860
|
-
var
|
|
1860
|
+
var _e = function() {
|
|
1861
1861
|
function e2(e3) {
|
|
1862
1862
|
void 0 === e3 && (e3 = {}), this.tagName = "", this.attrs = {}, this.innerHTML = "", this.whitespaceRegex = /\s+/, this.tagName = e3.tagName || "", this.attrs = e3.attrs || {}, this.innerHTML = e3.innerHtml || e3.innerHTML || "";
|
|
1863
1863
|
}
|
|
@@ -1906,12 +1906,12 @@ var Oe = function() {
|
|
|
1906
1906
|
return t2.join(" ");
|
|
1907
1907
|
}, e2;
|
|
1908
1908
|
}();
|
|
1909
|
-
var
|
|
1909
|
+
var Oe = function() {
|
|
1910
1910
|
function e2(e3) {
|
|
1911
1911
|
void 0 === e3 && (e3 = {}), this.newWindow = false, this.truncate = {}, this.className = "", this.newWindow = e3.newWindow || false, this.truncate = e3.truncate || {}, this.className = e3.className || "";
|
|
1912
1912
|
}
|
|
1913
1913
|
return e2.prototype.build = function(e3) {
|
|
1914
|
-
return new
|
|
1914
|
+
return new _e({ tagName: "a", attrs: this.createAttrs(e3), innerHtml: this.processAnchorText(e3.getAnchorText()) });
|
|
1915
1915
|
}, e2.prototype.createAttrs = function(e3) {
|
|
1916
1916
|
var t2 = { href: e3.getAnchorHref() }, s2 = this.createCssClass(e3);
|
|
1917
1917
|
return s2 && (t2.class = s2), this.newWindow && (t2.target = "_blank", t2.rel = "noopener noreferrer"), this.truncate && this.truncate.length && this.truncate.length < e3.getAnchorText().length && (t2.title = e3.getAnchorHref()), t2;
|
|
@@ -2009,12 +2009,12 @@ function Ue(e2, t2) {
|
|
|
2009
2009
|
}
|
|
2010
2010
|
Pe(e2, t2), e2.prototype = null === t2 ? Object.create(t2) : (s2.prototype = t2.prototype, new s2());
|
|
2011
2011
|
}
|
|
2012
|
-
var je,
|
|
2013
|
-
return
|
|
2012
|
+
var je, $e = function() {
|
|
2013
|
+
return $e = Object.assign || function(e2) {
|
|
2014
2014
|
for (var t2, s2 = 1, n2 = arguments.length; s2 < n2; s2++) for (var r2 in t2 = arguments[s2]) Object.prototype.hasOwnProperty.call(t2, r2) && (e2[r2] = t2[r2]);
|
|
2015
2015
|
return e2;
|
|
2016
|
-
},
|
|
2017
|
-
},
|
|
2016
|
+
}, $e.apply(this, arguments);
|
|
2017
|
+
}, We = function(e2) {
|
|
2018
2018
|
function t2(t3) {
|
|
2019
2019
|
var s2 = e2.call(this, t3) || this;
|
|
2020
2020
|
return s2.email = "", s2.email = t3.email, s2;
|
|
@@ -2180,7 +2180,7 @@ var je, We = function() {
|
|
|
2180
2180
|
"m" === e4 ? w2(1) : s2.test(e4) && w2();
|
|
2181
2181
|
}
|
|
2182
2182
|
function p2(e4, t4) {
|
|
2183
|
-
":" === e4 ? s2.test(t4) ? (c2 = 2, l2 = new pt(
|
|
2183
|
+
":" === e4 ? s2.test(t4) ? (c2 = 2, l2 = new pt($e($e({}, l2), { hasMailtoPrefix: true }))) : A2() : o2[e4] === t4 || (s2.test(t4) ? c2 = 2 : "." === t4 ? c2 = 3 : "@" === t4 ? c2 = 4 : A2());
|
|
2184
2184
|
}
|
|
2185
2185
|
function f2(e4) {
|
|
2186
2186
|
"." === e4 ? c2 = 3 : "@" === e4 ? c2 = 4 : s2.test(e4) || A2();
|
|
@@ -2198,7 +2198,7 @@ var je, We = function() {
|
|
|
2198
2198
|
"-" === e4 || "." === e4 ? C2() : ut.test(e4) ? c2 = 5 : C2();
|
|
2199
2199
|
}
|
|
2200
2200
|
function y2(e4) {
|
|
2201
|
-
"." === e4 || "-" === e4 ? C2() : ut.test(e4) ? (c2 = 5, l2 = new pt(
|
|
2201
|
+
"." === e4 || "-" === e4 ? C2() : ut.test(e4) ? (c2 = 5, l2 = new pt($e($e({}, l2), { hasDomainDot: true }))) : C2();
|
|
2202
2202
|
}
|
|
2203
2203
|
function w2(e4) {
|
|
2204
2204
|
void 0 === e4 && (e4 = 2), c2 = e4, l2 = new pt({ idx: u2 });
|
|
@@ -2214,7 +2214,7 @@ var je, We = function() {
|
|
|
2214
2214
|
(function(e4) {
|
|
2215
2215
|
var t4 = e4.split(".").pop() || "", s4 = t4.toLowerCase();
|
|
2216
2216
|
return n2.test(s4);
|
|
2217
|
-
})(i3) && r2.push(new
|
|
2217
|
+
})(i3) && r2.push(new We({ tagBuilder: t3, matchedText: s3, offset: l2.idx, email: i3 }));
|
|
2218
2218
|
}
|
|
2219
2219
|
A2();
|
|
2220
2220
|
}
|
|
@@ -2396,10 +2396,10 @@ function Dt(e2, t2) {
|
|
|
2396
2396
|
R2(f2);
|
|
2397
2397
|
break;
|
|
2398
2398
|
case 19:
|
|
2399
|
-
|
|
2399
|
+
_2(f2);
|
|
2400
2400
|
break;
|
|
2401
2401
|
case 20:
|
|
2402
|
-
|
|
2402
|
+
O2(f2);
|
|
2403
2403
|
break;
|
|
2404
2404
|
default:
|
|
2405
2405
|
Re(h2);
|
|
@@ -2410,10 +2410,10 @@ function Dt(e2, t2) {
|
|
|
2410
2410
|
"<" === e3 && P2();
|
|
2411
2411
|
}
|
|
2412
2412
|
function g2(e3) {
|
|
2413
|
-
"!" === e3 ? h2 = 13 : "/" === e3 ? (h2 = 2, p2 = new It(
|
|
2413
|
+
"!" === e3 ? h2 = 13 : "/" === e3 ? (h2 = 2, p2 = new It($e($e({}, p2), { isClosing: true }))) : "<" === e3 ? P2() : Je.test(e3) ? (h2 = 3, p2 = new It($e($e({}, p2), { isOpening: true }))) : (h2 = 0, p2 = u2);
|
|
2414
2414
|
}
|
|
2415
2415
|
function v2(e3) {
|
|
2416
|
-
Ke.test(e3) ? (p2 = new It(
|
|
2416
|
+
Ke.test(e3) ? (p2 = new It($e($e({}, p2), { name: j2() })), h2 = 4) : "<" === e3 ? P2() : "/" === e3 ? (p2 = new It($e($e({}, p2), { name: j2() })), h2 = 12) : ">" === e3 ? (p2 = new It($e($e({}, p2), { name: j2() })), U2()) : Je.test(e3) || Ye.test(e3) || ":" === e3 || N2();
|
|
2417
2417
|
}
|
|
2418
2418
|
function b2(e3) {
|
|
2419
2419
|
">" === e3 ? N2() : Je.test(e3) ? h2 = 3 : N2();
|
|
@@ -2443,10 +2443,10 @@ function Dt(e2, t2) {
|
|
|
2443
2443
|
Ke.test(e3) ? h2 = 4 : "/" === e3 ? h2 = 12 : ">" === e3 ? U2() : "<" === e3 ? P2() : (h2 = 4, c2--);
|
|
2444
2444
|
}
|
|
2445
2445
|
function S2(e3) {
|
|
2446
|
-
">" === e3 ? (p2 = new It(
|
|
2446
|
+
">" === e3 ? (p2 = new It($e($e({}, p2), { isClosing: true })), U2()) : h2 = 4;
|
|
2447
2447
|
}
|
|
2448
2448
|
function D2(t3) {
|
|
2449
|
-
"--" === e2.substr(c2, 2) ? (c2 += 2, p2 = new It(
|
|
2449
|
+
"--" === e2.substr(c2, 2) ? (c2 += 2, p2 = new It($e($e({}, p2), { type: "comment" })), h2 = 14) : "DOCTYPE" === e2.substr(c2, 7).toUpperCase() ? (c2 += 7, p2 = new It($e($e({}, p2), { type: "doctype" })), h2 = 20) : N2();
|
|
2450
2450
|
}
|
|
2451
2451
|
function I2(e3) {
|
|
2452
2452
|
"-" === e3 ? h2 = 15 : ">" === e3 ? N2() : h2 = 16;
|
|
@@ -2463,10 +2463,10 @@ function Dt(e2, t2) {
|
|
|
2463
2463
|
function R2(e3) {
|
|
2464
2464
|
">" === e3 ? U2() : "!" === e3 ? h2 = 19 : "-" === e3 || (h2 = 16);
|
|
2465
2465
|
}
|
|
2466
|
-
function
|
|
2466
|
+
function _2(e3) {
|
|
2467
2467
|
"-" === e3 ? h2 = 17 : ">" === e3 ? U2() : h2 = 16;
|
|
2468
2468
|
}
|
|
2469
|
-
function
|
|
2469
|
+
function O2(e3) {
|
|
2470
2470
|
">" === e3 ? U2() : "<" === e3 && P2();
|
|
2471
2471
|
}
|
|
2472
2472
|
function N2() {
|
|
@@ -2582,15 +2582,15 @@ var It = function(e2) {
|
|
|
2582
2582
|
return s2.push(e3.substring(n2)), s2.join("");
|
|
2583
2583
|
}, e2.prototype.createMatchReturnVal = function(e3) {
|
|
2584
2584
|
var t2;
|
|
2585
|
-
return this.replaceFn && (t2 = this.replaceFn.call(this.context, e3)), "string" == typeof t2 ? t2 : false === t2 ? e3.getMatchedText() : t2 instanceof
|
|
2585
|
+
return this.replaceFn && (t2 = this.replaceFn.call(this.context, e3)), "string" == typeof t2 ? t2 : false === t2 ? e3.getMatchedText() : t2 instanceof _e ? t2.toAnchorString() : e3.buildTag().toAnchorString();
|
|
2586
2586
|
}, e2.prototype.getMatchers = function() {
|
|
2587
2587
|
if (this.matchers) return this.matchers;
|
|
2588
2588
|
var e3 = this.getTagBuilder(), t2 = [new wt({ tagBuilder: e3, serviceName: this.hashtag }), new dt({ tagBuilder: e3 }), new Ct({ tagBuilder: e3 }), new St({ tagBuilder: e3, serviceName: this.mention }), new vt({ tagBuilder: e3, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })];
|
|
2589
2589
|
return this.matchers = t2;
|
|
2590
2590
|
}, e2.prototype.getTagBuilder = function() {
|
|
2591
2591
|
var e3 = this.tagBuilder;
|
|
2592
|
-
return e3 || (e3 = this.tagBuilder = new
|
|
2593
|
-
}, e2.version = "3.14.3", e2.AnchorTagBuilder =
|
|
2592
|
+
return e3 || (e3 = this.tagBuilder = new Oe({ newWindow: this.newWindow, truncate: this.truncate, className: this.className })), e3;
|
|
2593
|
+
}, e2.version = "3.14.3", e2.AnchorTagBuilder = Oe, e2.HtmlTag = _e, e2.matcher = { Email: dt, Hashtag: wt, Matcher: ze, Mention: St, Phone: Ct, Url: vt }, e2.match = { Email: We, Hashtag: qe, Match: Ne, Mention: He, Phone: Le, Url: Ge }, e2;
|
|
2594
2594
|
}();
|
|
2595
2595
|
function Bt(e2, t2 = e2) {
|
|
2596
2596
|
return { type: "autolink", url: e2, text: t2 };
|
|
@@ -2602,9 +2602,9 @@ const Mt = Ee(/<!!mention:([^>\s]*?)\|(.*?)>/gm, ([e2, t2, s2]) => /* @__PURE__
|
|
|
2602
2602
|
return { type: "mention", id: e3, text: t3 };
|
|
2603
2603
|
}(decodeURIComponent(t2), s2)), Rt = Ee(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ function(e3) {
|
|
2604
2604
|
return { type: "customemoji", text: e3 };
|
|
2605
|
-
}(t2)),
|
|
2605
|
+
}(t2)), _t = Ee(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ function(e3, t3 = []) {
|
|
2606
2606
|
return { type: "link", url: e3, children: t3 };
|
|
2607
|
-
}(t2, [s2])),
|
|
2607
|
+
}(t2, [s2])), Ot = Ee(/<actionlink:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
|
|
2608
2608
|
const { action: n2, params: r2 } = Pt(t2);
|
|
2609
2609
|
return /* @__PURE__ */ function(e3, t3, s3 = []) {
|
|
2610
2610
|
return { type: "actionlink", action: e3, params: t3, children: s3 };
|
|
@@ -2622,7 +2622,7 @@ function Pt(e2) {
|
|
|
2622
2622
|
}
|
|
2623
2623
|
const Ut = Ee(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__ */ function(e3 = []) {
|
|
2624
2624
|
return { type: "bulletlist", children: e3 };
|
|
2625
|
-
}([e2.startsWith("\n") ? e2.slice(1) : e2])), jt = Ee(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm, ([e2, t2]) => ({ type: "bulletpoint", children: [t2] })),
|
|
2625
|
+
}([e2.startsWith("\n") ? e2.slice(1) : e2])), jt = Ee(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm, ([e2, t2]) => ({ type: "bulletpoint", children: [t2] })), $t = (e2) => {
|
|
2626
2626
|
const t2 = /(?:^|[^-:/\w])([(+]?[0-9](?:[-_+ ().]?[0-9]){5,11}[0-9])(?:[^-:/\w]|$)/g;
|
|
2627
2627
|
let s2 = 0;
|
|
2628
2628
|
const n2 = [];
|
|
@@ -2633,20 +2633,20 @@ const Ut = Ee(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__
|
|
|
2633
2633
|
n2.push(o2), s2 = a2 + i2.length;
|
|
2634
2634
|
}
|
|
2635
2635
|
return s2 < e2.length && n2.push(e2.substring(s2)), n2;
|
|
2636
|
-
},
|
|
2636
|
+
}, Wt = (e2) => _t(e2).flatMap((e3) => "string" == typeof e3 ? qt(e3) : ["<", ...qt(e3.url), ...qt("|" + e3.children[0] + ">")]), qt = (e2) => {
|
|
2637
2637
|
const t2 = Ft.parse(e2, { urls: true, email: true, phone: false, hashtag: false, mention: false }), s2 = [];
|
|
2638
2638
|
let n2 = 0;
|
|
2639
2639
|
for (const r2 of t2) {
|
|
2640
2640
|
const t3 = r2.getOffset(), i2 = r2.getMatchedText(), a2 = i2.length;
|
|
2641
2641
|
let o2 = i2;
|
|
2642
|
-
r2 instanceof
|
|
2642
|
+
r2 instanceof We ? o2 = "mailto:" + r2.getEmail() : r2 instanceof Ge && (o2 = r2.getUrl()), t3 > n2 && s2.push(e2.substring(n2, t3)), s2.push(Bt(o2, i2)), n2 = t3 + a2;
|
|
2643
2643
|
}
|
|
2644
2644
|
return n2 < e2.length && s2.push(e2.substring(n2)), s2;
|
|
2645
2645
|
}, Ht = ["Codeblock", "Codespan", "FormattedLink", "Wikitext", "Autolink", "Actions", "Mention", "Mention", "BulletPoint", "CustomEmoji"];
|
|
2646
2646
|
function Lt(e2 = { except: [] }) {
|
|
2647
2647
|
var _a2;
|
|
2648
2648
|
const t2 = { multilineSteps: [], singlelineSteps: [] }, s2 = (_a2 = e2.except) != null ? _a2 : Ht.filter((t3) => !e2.only.includes(t3));
|
|
2649
|
-
return s2.includes("BulletPoint") || t2.multilineSteps.push(Ut, jt), s2.includes("Mention") || t2.singlelineSteps.push(Mt), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Rt), s2.includes("Codespan") || t2.multilineSteps.push(Ee(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3 }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(
|
|
2649
|
+
return s2.includes("BulletPoint") || t2.multilineSteps.push(Ut, jt), s2.includes("Mention") || t2.singlelineSteps.push(Mt), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Rt), s2.includes("Codespan") || t2.multilineSteps.push(Ee(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3 }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(_t), s2.includes("Actions") || (t2.singlelineSteps.push(Ot), t2.singlelineSteps.push(Nt)), s2.includes("Wikitext") || t2.singlelineSteps.push(De), s2.includes("Autolink") || t2.singlelineSteps.push(Wt, $t), t2;
|
|
2650
2650
|
}
|
|
2651
2651
|
const Gt = function(e2) {
|
|
2652
2652
|
const t2 = RegExp(`[^${e2}]+${e2}?|${e2}`, "g");
|
|
@@ -2821,7 +2821,7 @@ class ts {
|
|
|
2821
2821
|
function ss({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2 }) {
|
|
2822
2822
|
var _a2;
|
|
2823
2823
|
(!r2 || r2 <= 0) && (r2 = 1);
|
|
2824
|
-
const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-04-
|
|
2824
|
+
const u2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2025-04-25T12:29:48.685Z" };
|
|
2825
2825
|
s2 instanceof FormData || (u2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
|
|
2826
2826
|
return a(r2, () => __async(this, null, function* () {
|
|
2827
2827
|
if (o2) {
|
|
@@ -2874,7 +2874,7 @@ const cs = rs.startsWith("app.talkjs.com");
|
|
|
2874
2874
|
const ls = "undefined" == typeof window ? { log: (e2) => Promise.resolve(), setData: (e2) => {
|
|
2875
2875
|
} } : new class {
|
|
2876
2876
|
constructor(e2) {
|
|
2877
|
-
this._timeCreated = Date.now(), this._enabled = cs, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-04-
|
|
2877
|
+
this._timeCreated = Date.now(), this._enabled = cs, this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2025-04-25T12:29:48.685Z" }, 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-04-25T12:29:48.685Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
|
|
2878
2878
|
}
|
|
2879
2879
|
setData({ appId: e2, meId: t2, sessionId: s2 }) {
|
|
2880
2880
|
this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
|
|
@@ -2973,7 +2973,7 @@ class ds {
|
|
|
2973
2973
|
};
|
|
2974
2974
|
}
|
|
2975
2975
|
emitTokenRefreshFailed(e2) {
|
|
2976
|
-
this.eventEmitter.emit("tokenRefreshFailed", e2), console.error(`[TalkJS]
|
|
2976
|
+
this.eventEmitter.emit("tokenRefreshFailed", e2), console.error(`[TalkJS] Could not authenticate, cannot recover automatically: ${e2}`);
|
|
2977
2977
|
}
|
|
2978
2978
|
onTokenAccepted(e2) {
|
|
2979
2979
|
return this.eventEmitter.on("tokenAccepted", e2), () => {
|
|
@@ -3003,18 +3003,17 @@ class ds {
|
|
|
3003
3003
|
return __async(this, null, function* () {
|
|
3004
3004
|
if (this.requestInProgress) return;
|
|
3005
3005
|
this.requestInProgress = true;
|
|
3006
|
-
const t2 = (
|
|
3007
|
-
if (this.usingBokens && e3 instanceof Response && 401 === e3.status) throw "Check that you provided a valid signature";
|
|
3008
|
-
return true;
|
|
3009
|
-
}, s2 = () => __async(this, null, function* () {
|
|
3006
|
+
const t2 = () => __async(this, null, function* () {
|
|
3010
3007
|
const t3 = yield e2();
|
|
3011
3008
|
return this.checkJwt(t3), t3;
|
|
3012
3009
|
});
|
|
3013
3010
|
try {
|
|
3014
3011
|
const e3 = void 0 !== this.token;
|
|
3015
|
-
this.token =
|
|
3016
|
-
|
|
3017
|
-
|
|
3012
|
+
this.token = t2(), yield this.token.then((t3) => {
|
|
3013
|
+
e3 && this.emitTokenChanged(t3);
|
|
3014
|
+
}).catch((e4) => {
|
|
3015
|
+
this.emitTokenRefreshFailed(e4);
|
|
3016
|
+
});
|
|
3018
3017
|
} catch (e3) {
|
|
3019
3018
|
this.emitTokenRefreshFailed(e3);
|
|
3020
3019
|
} finally {
|
|
@@ -3071,9 +3070,17 @@ class ds {
|
|
|
3071
3070
|
}
|
|
3072
3071
|
sendBokenRequest(e2, t2) {
|
|
3073
3072
|
return __async(this, null, function* () {
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3073
|
+
let s2 = 0;
|
|
3074
|
+
const n2 = e2.getBokensUrl(this.appId, this.userId, t2), r2 = yield ss({ method: "GET", url: n2, attempts: 1e4, shouldRetry: (e3) => {
|
|
3075
|
+
if (e3 instanceof Error) return true;
|
|
3076
|
+
if (401 === e3.status) throw "Check that you provided a valid signature.";
|
|
3077
|
+
if (404 === e3.status) throw "Check that you specified the correct App ID.";
|
|
3078
|
+
if (429 === e3.status || 502 === e3.status) return true;
|
|
3079
|
+
if (e3.status >= 400 && e3.status < 500) throw `Unexpected HTTP ${e3.status} response when fetching auth token. Check that you configured the session correctly.`;
|
|
3080
|
+
if (s2++, s2 >= 5) throw `Unexpected HTTP ${e3.status} response when fetching auth token, retrying did not help.`;
|
|
3081
|
+
return true;
|
|
3082
|
+
} });
|
|
3083
|
+
return (yield r2.json()).boken;
|
|
3077
3084
|
});
|
|
3078
3085
|
}
|
|
3079
3086
|
}
|
|
@@ -3126,7 +3133,7 @@ class bs {
|
|
|
3126
3133
|
void 0 !== e3.tokenFetcher && t3("function" == typeof e3.tokenFetcher, "The `tokenFetcher` property of TalkSession#constructor must be a function.");
|
|
3127
3134
|
}(e2);
|
|
3128
3135
|
const { appId: t2, userId: s2, token: n2, tokenFetcher: r2, signature: i2 } = e2;
|
|
3129
|
-
this._appId = t2, this._apiUrls = e2.apiUrls ? new ts(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : fs, this._authProvider = new ds(this._apiUrls, t2, s2, n2, r2, i2), this._realtimeClient = new ge(this._apiUrls.getRealtimeWsUrl(t2, s2, "0.0.
|
|
3136
|
+
this._appId = t2, this._apiUrls = e2.apiUrls ? new ts(e2.apiUrls.realtimeWsApiUrl, e2.apiUrls.internalHttpApiUrl, e2.apiUrls.restApiHttpUrl) : fs, this._authProvider = new ds(this._apiUrls, t2, s2, n2, r2, i2), this._realtimeClient = new ge(this._apiUrls.getRealtimeWsUrl(t2, s2, "0.0.5", e2.clientBuild), s2, this._authProvider), this.currentUser = new ye(this._realtimeClient.userId, this._realtimeClient), this._terminationReason = o(), this._terminationReason.promise.then((e3) => {
|
|
3130
3137
|
console.error(`[TalkSession] ${e3}`);
|
|
3131
3138
|
}), function(e3, t3, s3) {
|
|
3132
3139
|
return __async(this, null, function* () {
|
|
@@ -3139,9 +3146,9 @@ class bs {
|
|
|
3139
3146
|
});
|
|
3140
3147
|
});
|
|
3141
3148
|
}(this._appId, this._apiUrls.internalHttpApiUrl, this._authProvider).then((e3) => {
|
|
3142
|
-
e3 || this.terminate(new Error(`
|
|
3149
|
+
e3 || this.terminate(new Error(`The app ID ${this._appId} does not exist. Make sure you are using the correct app ID as found on the TalkJS dashboard. App IDs are case-sensitive.`));
|
|
3143
3150
|
}), this._authProvider.onTokenRefreshFailed((e3) => {
|
|
3144
|
-
this.terminate(new Error(`
|
|
3151
|
+
this.terminate(new Error(`Could not authenticate, cannot recover automatically: ${e3}`));
|
|
3145
3152
|
});
|
|
3146
3153
|
}
|
|
3147
3154
|
onError(e2) {
|
|
@@ -3178,9 +3185,17 @@ class bs {
|
|
|
3178
3185
|
return ys(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, e2, __spreadValues({ subtype: "voice" }, t2));
|
|
3179
3186
|
}
|
|
3180
3187
|
}
|
|
3181
|
-
function ys(
|
|
3182
|
-
|
|
3183
|
-
|
|
3188
|
+
function ys(_0, _1, _2, _3) {
|
|
3189
|
+
return __async(this, arguments, function* (e2, t2, s2, { subtype: n2, filename: r2, width: i2, height: a2, duration: o2 }) {
|
|
3190
|
+
const u2 = new FormData();
|
|
3191
|
+
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()), ss({ method: "POST", url: e2, data: u2, authProvider: t2 }).then((e3) => e3.json()).then((e3) => e3.attachmentToken).catch((e3) => __async(this, null, function* () {
|
|
3192
|
+
if (e3 instanceof Response) {
|
|
3193
|
+
const t3 = yield e3.json(), s3 = `Unexpected response when uploading file, status code ${e3.status} ${t3.errorCode}, ${t3.reasons}`;
|
|
3194
|
+
throw new Error(s3);
|
|
3195
|
+
}
|
|
3196
|
+
throw e3;
|
|
3197
|
+
}));
|
|
3198
|
+
});
|
|
3184
3199
|
}
|
|
3185
3200
|
export {
|
|
3186
3201
|
vs as getTalkSession,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talkjs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Lets you connect to your TalkJS chat as a user and read, subscribe to, and update your chat data.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://talkjs.com/?chat"
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"test": "vitest run",
|
|
31
31
|
"test:ci": "vitest run --mode production",
|
|
32
32
|
"test:watch": "vitest",
|
|
33
|
-
"package:prepare": "yarn typecheck && yarn lint && yarn test && yarn build",
|
|
34
33
|
"build": "vite build"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
@@ -39,9 +38,11 @@
|
|
|
39
38
|
"@types/ws": "^8.18.0",
|
|
40
39
|
"eslint": "^9.21.0",
|
|
41
40
|
"globals": "^16.0.0",
|
|
41
|
+
"jssha": "^2.2.0",
|
|
42
42
|
"terser": "^5.39.0",
|
|
43
43
|
"typescript": "^5.8.2",
|
|
44
44
|
"typescript-eslint": "^8.26.0",
|
|
45
|
+
"uuid": "^11.1.0",
|
|
45
46
|
"vite": "^6.2.0",
|
|
46
47
|
"vite-plugin-dts": "^3.7.3",
|
|
47
48
|
"vite-plugin-externalize-deps": "^0.9.0",
|