@paramms/chat-widget 1.0.43 → 1.0.45
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 +5 -4
- package/dist/chatlist.d.ts +2 -1
- package/dist/chatlist.js +137 -115
- package/dist/chatlist.js.map +1 -1
- package/dist/chatlist.styles.d.ts +1 -0
- package/dist/codec.js +191 -157
- package/dist/codec.js.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/e2e.d.ts +21 -2
- package/dist/e2e.js +50 -40
- package/dist/e2e.js.map +1 -1
- package/dist/embed-lite.js +242 -0
- package/dist/embed-lite.js.map +1 -0
- package/dist/embed.d.ts +8 -0
- package/dist/embed.js +87 -78
- package/dist/embed.js.map +1 -1
- package/dist/history.d.ts +7 -4
- package/dist/index.d.ts +20 -0
- package/dist/index.js +632 -723
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +65 -75
- package/dist/outbox.js.map +1 -1
- package/dist/protocol/entities.d.ts +0 -11
- package/dist/protocol/frames.d.ts +1 -17
- package/dist/react.d.ts +13 -5
- package/dist/react.js +225 -211
- package/dist/react.js.map +1 -1
- package/dist/renderer.d.ts +14 -19
- package/dist/renderer.styles.d.ts +1 -0
- package/dist/store.d.ts +1 -5
- package/dist/theme-tokens.d.ts +4 -0
- package/package.json +2 -2
- package/dist/annotations.d.ts +0 -11
package/dist/codec.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var P = (n, e, t) => e in n ?
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var P = (n, e, t) => e in n ? b(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var o = (n, e, t) => P(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
function R(n, e) {
|
|
5
5
|
var c;
|
|
6
|
-
const t = n.trim().replace(/\/+$/, ""), s = (c = t.match(/^(https|http|wss|ws):\/\//)) == null ? void 0 : c[1], i = s ? s === "https" || s === "wss" : !0, r = (s ? t.slice(s.length + 3) : t).replace(/\/ws$/, ""),
|
|
7
|
-
return { wsUrl: `${i ? "wss" : "ws"}://${r}/ws`, httpBase:
|
|
6
|
+
const t = n.trim().replace(/\/+$/, ""), s = (c = t.match(/^(https|http|wss|ws):\/\//)) == null ? void 0 : c[1], i = s ? s === "https" || s === "wss" : !0, r = (s ? t.slice(s.length + 3) : t).replace(/\/ws$/, ""), a = e ? e.trim().replace(/\/+$/, "") : `${i ? "https" : "http"}://${r}`;
|
|
7
|
+
return { wsUrl: `${i ? "wss" : "ws"}://${r}/ws`, httpBase: a };
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function H(n) {
|
|
10
10
|
return R(n).httpBase;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function K(n, e, t, s) {
|
|
13
13
|
const i = `beforeSeq=${t}&limit=${s}`;
|
|
14
14
|
return [
|
|
15
15
|
`${n}/conversations/${e}/messages?${i}`,
|
|
16
16
|
`${n}/conversations/${e}/history?${i}`
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
let r,
|
|
21
|
-
for (const
|
|
19
|
+
async function $(n, e, t, s, i = 20) {
|
|
20
|
+
let r, a = !1;
|
|
21
|
+
for (const h of K(n, e, s, i))
|
|
22
22
|
try {
|
|
23
|
-
const c = await fetch(
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
return { messages:
|
|
23
|
+
const c = await fetch(h, { headers: { authorization: `Bearer ${t}` } });
|
|
24
|
+
if (a = !0, !c.ok) continue;
|
|
25
|
+
const l = await c.json();
|
|
26
|
+
return { messages: l.messages ?? [], hasMore: l.hasMore ?? !1 };
|
|
27
27
|
} catch (c) {
|
|
28
28
|
r = c;
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return a ? console.error(`[chat-widget] history request to ${n} was rejected for conversation ${e}.`) : console.error(
|
|
31
31
|
`[chat-widget] could not load history from ${n} — the request never reached the server. This is almost always CORS: add this site's origin to the chatroom's allowed origins (dashboard → chatroom → allowed origins) or to the server's CORS_ORIGINS.`,
|
|
32
32
|
r
|
|
33
33
|
), null;
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
35
|
+
async function $e(n, e, t, s, i, r) {
|
|
36
|
+
const a = r ? r.replace(/\/+$/, "") : H(n), h = await $(a, t, e, Number.MAX_SAFE_INTEGER);
|
|
37
|
+
if (!h || (h.messages.length ? (s.apply({ type: "sync", conversationId: t, messages: h.messages }), s.apply({ type: "history", conversationId: t, messages: [], hasMore: h.hasMore }), i.render(s)) : s.apply({ type: "history", conversationId: t, messages: [], hasMore: !1 }), !h.hasMore)) return;
|
|
38
38
|
let c = !1;
|
|
39
|
-
const
|
|
39
|
+
const l = async () => {
|
|
40
40
|
if (c || !s.hasMoreHistory) return;
|
|
41
41
|
c = !0;
|
|
42
42
|
const M = s.messages()[0];
|
|
@@ -44,21 +44,55 @@ async function Te(n, e, t, s, i, r) {
|
|
|
44
44
|
c = !1;
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const S = await
|
|
47
|
+
const S = await $(a, t, e, M.seq);
|
|
48
48
|
S && (s.apply({ type: "history", conversationId: t, messages: S.messages, hasMore: S.hasMore }), i.render(s)), c = !1;
|
|
49
49
|
}, u = i.getScrollEl();
|
|
50
50
|
if (!u) return;
|
|
51
|
-
let
|
|
51
|
+
let d = !1;
|
|
52
52
|
setTimeout(() => {
|
|
53
|
-
|
|
53
|
+
d = !0;
|
|
54
54
|
}, 300);
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const v = () => {
|
|
56
|
+
d && u.scrollTop < 80 && s.hasMoreHistory && !c && l();
|
|
57
57
|
};
|
|
58
|
-
u.addEventListener("scroll",
|
|
58
|
+
u.addEventListener("scroll", v, { passive: !0 }), i.setScrollCleanup(() => u.removeEventListener("scroll", v));
|
|
59
|
+
}
|
|
60
|
+
const N = {
|
|
61
|
+
accent: "#6c5ce7",
|
|
62
|
+
accent2: "#4c6fff",
|
|
63
|
+
bg: "#f4f3fb",
|
|
64
|
+
card: "#fff",
|
|
65
|
+
tint: "#eeecfb",
|
|
66
|
+
line: "#e6e2f5",
|
|
67
|
+
ink: "#221d3a",
|
|
68
|
+
mut: "#8f8aa8",
|
|
69
|
+
onaccent: "#fff",
|
|
70
|
+
rowhover: "#e7e3f8",
|
|
71
|
+
shadow: "0 12px 32px rgba(108,92,231,.14)"
|
|
72
|
+
}, W = {
|
|
73
|
+
accent: "#a99cf2",
|
|
74
|
+
accent2: "#6f8cff",
|
|
75
|
+
bg: "#221d3a",
|
|
76
|
+
card: "#2b2550",
|
|
77
|
+
tint: "#2f2853",
|
|
78
|
+
line: "#3a3363",
|
|
79
|
+
ink: "#eceafc",
|
|
80
|
+
mut: "#9b93c9",
|
|
81
|
+
onaccent: "#221d3a",
|
|
82
|
+
rowhover: "#39325e",
|
|
83
|
+
shadow: "0 12px 32px rgba(0,0,0,.4)"
|
|
84
|
+
}, V = "'Nunito',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif";
|
|
85
|
+
function L(n, e) {
|
|
86
|
+
return Object.entries(e).map(([t, s]) => `--${n}-${t}:${s};`).join(" ");
|
|
87
|
+
}
|
|
88
|
+
function ze(n) {
|
|
89
|
+
return `${L(n, N)} --${n}-fb:${V}; --${n}-fh:'Baloo 2',var(--${n}-fb);`;
|
|
90
|
+
}
|
|
91
|
+
function Le(n) {
|
|
92
|
+
return L(n, W);
|
|
59
93
|
}
|
|
60
94
|
const y = "oc_uid";
|
|
61
|
-
function
|
|
95
|
+
function X(n) {
|
|
62
96
|
try {
|
|
63
97
|
const e = document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));
|
|
64
98
|
return e ? decodeURIComponent(e[1]) : null;
|
|
@@ -66,31 +100,31 @@ function K(n) {
|
|
|
66
100
|
return null;
|
|
67
101
|
}
|
|
68
102
|
}
|
|
69
|
-
function
|
|
103
|
+
function Y(n, e) {
|
|
70
104
|
try {
|
|
71
105
|
const s = location.protocol === "https:" ? "; Secure" : "";
|
|
72
106
|
document.cookie = `${n}=${encodeURIComponent(e)}; Max-Age=31536000; Path=/; SameSite=Lax${s}`;
|
|
73
107
|
} catch {
|
|
74
108
|
}
|
|
75
109
|
}
|
|
76
|
-
function
|
|
110
|
+
function O() {
|
|
77
111
|
return `g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
78
112
|
}
|
|
79
|
-
function
|
|
113
|
+
function De() {
|
|
80
114
|
let n = null;
|
|
81
115
|
try {
|
|
82
116
|
n = localStorage.getItem(y);
|
|
83
117
|
} catch {
|
|
84
118
|
}
|
|
85
|
-
n || (n =
|
|
86
|
-
const e = n ??
|
|
119
|
+
n || (n = X(y));
|
|
120
|
+
const e = n ?? O();
|
|
87
121
|
try {
|
|
88
122
|
localStorage.setItem(y, e);
|
|
89
123
|
} catch {
|
|
90
124
|
}
|
|
91
|
-
return
|
|
125
|
+
return Y(y, e), e;
|
|
92
126
|
}
|
|
93
|
-
function
|
|
127
|
+
function q(n) {
|
|
94
128
|
const e = n.length;
|
|
95
129
|
let t = 0, s = 0;
|
|
96
130
|
for (; s < e; ) {
|
|
@@ -112,69 +146,69 @@ function V(n) {
|
|
|
112
146
|
}
|
|
113
147
|
return t;
|
|
114
148
|
}
|
|
115
|
-
function
|
|
149
|
+
function G(n, e, t) {
|
|
116
150
|
const s = n.length;
|
|
117
151
|
let i = t, r = 0;
|
|
118
152
|
for (; r < s; ) {
|
|
119
|
-
let
|
|
120
|
-
if (
|
|
121
|
-
if (!(
|
|
122
|
-
e[i++] =
|
|
153
|
+
let a = n.charCodeAt(r++);
|
|
154
|
+
if (a & 4294967168)
|
|
155
|
+
if (!(a & 4294965248))
|
|
156
|
+
e[i++] = a >> 6 & 31 | 192;
|
|
123
157
|
else {
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
(
|
|
158
|
+
if (a >= 55296 && a <= 56319 && r < s) {
|
|
159
|
+
const h = n.charCodeAt(r);
|
|
160
|
+
(h & 64512) === 56320 && (++r, a = ((a & 1023) << 10) + (h & 1023) + 65536);
|
|
127
161
|
}
|
|
128
|
-
|
|
162
|
+
a & 4294901760 ? (e[i++] = a >> 18 & 7 | 240, e[i++] = a >> 12 & 63 | 128, e[i++] = a >> 6 & 63 | 128) : (e[i++] = a >> 12 & 15 | 224, e[i++] = a >> 6 & 63 | 128);
|
|
129
163
|
}
|
|
130
164
|
else {
|
|
131
|
-
e[i++] =
|
|
165
|
+
e[i++] = a;
|
|
132
166
|
continue;
|
|
133
167
|
}
|
|
134
|
-
e[i++] =
|
|
168
|
+
e[i++] = a & 63 | 128;
|
|
135
169
|
}
|
|
136
170
|
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
139
|
-
|
|
171
|
+
const J = new TextEncoder(), Z = 50;
|
|
172
|
+
function Q(n, e, t) {
|
|
173
|
+
J.encodeInto(n, e.subarray(t));
|
|
140
174
|
}
|
|
141
|
-
function
|
|
142
|
-
n.length >
|
|
175
|
+
function j(n, e, t) {
|
|
176
|
+
n.length > Z ? Q(n, e, t) : G(n, e, t);
|
|
143
177
|
}
|
|
144
|
-
const
|
|
178
|
+
const ee = 4096;
|
|
145
179
|
function D(n, e, t) {
|
|
146
180
|
let s = e;
|
|
147
181
|
const i = s + t, r = [];
|
|
148
|
-
let
|
|
182
|
+
let a = "";
|
|
149
183
|
for (; s < i; ) {
|
|
150
|
-
const
|
|
151
|
-
if (!(
|
|
152
|
-
r.push(
|
|
153
|
-
else if ((
|
|
184
|
+
const h = n[s++];
|
|
185
|
+
if (!(h & 128))
|
|
186
|
+
r.push(h);
|
|
187
|
+
else if ((h & 224) === 192) {
|
|
154
188
|
const c = n[s++] & 63;
|
|
155
|
-
r.push((
|
|
156
|
-
} else if ((
|
|
157
|
-
const c = n[s++] & 63,
|
|
158
|
-
r.push((
|
|
159
|
-
} else if ((
|
|
160
|
-
const c = n[s++] & 63,
|
|
161
|
-
let
|
|
162
|
-
|
|
189
|
+
r.push((h & 31) << 6 | c);
|
|
190
|
+
} else if ((h & 240) === 224) {
|
|
191
|
+
const c = n[s++] & 63, l = n[s++] & 63;
|
|
192
|
+
r.push((h & 31) << 12 | c << 6 | l);
|
|
193
|
+
} else if ((h & 248) === 240) {
|
|
194
|
+
const c = n[s++] & 63, l = n[s++] & 63, u = n[s++] & 63;
|
|
195
|
+
let d = (h & 7) << 18 | c << 12 | l << 6 | u;
|
|
196
|
+
d > 65535 && (d -= 65536, r.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), r.push(d);
|
|
163
197
|
} else
|
|
164
|
-
r.push(
|
|
165
|
-
r.length >=
|
|
198
|
+
r.push(h);
|
|
199
|
+
r.length >= ee && (a += String.fromCharCode(...r), r.length = 0);
|
|
166
200
|
}
|
|
167
|
-
return r.length > 0 && (
|
|
201
|
+
return r.length > 0 && (a += String.fromCharCode(...r)), a;
|
|
168
202
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
203
|
+
const te = new TextDecoder(), se = 200;
|
|
204
|
+
function ie(n, e, t) {
|
|
171
205
|
const s = n.subarray(e, e + t);
|
|
172
|
-
return
|
|
206
|
+
return te.decode(s);
|
|
173
207
|
}
|
|
174
|
-
function
|
|
175
|
-
return t >
|
|
208
|
+
function ne(n, e, t) {
|
|
209
|
+
return t > se ? ie(n, e, t) : D(n, e, t);
|
|
176
210
|
}
|
|
177
|
-
class
|
|
211
|
+
class m {
|
|
178
212
|
constructor(e, t) {
|
|
179
213
|
o(this, "type");
|
|
180
214
|
o(this, "data");
|
|
@@ -193,26 +227,26 @@ class f extends Error {
|
|
|
193
227
|
}
|
|
194
228
|
}
|
|
195
229
|
const x = 4294967295;
|
|
196
|
-
function
|
|
230
|
+
function re(n, e, t) {
|
|
197
231
|
const s = t / 4294967296, i = t;
|
|
198
232
|
n.setUint32(e, s), n.setUint32(e + 4, i);
|
|
199
233
|
}
|
|
200
|
-
function
|
|
234
|
+
function C(n, e, t) {
|
|
201
235
|
const s = Math.floor(t / 4294967296), i = t;
|
|
202
236
|
n.setUint32(e, s), n.setUint32(e + 4, i);
|
|
203
237
|
}
|
|
204
|
-
function
|
|
238
|
+
function F(n, e) {
|
|
205
239
|
const t = n.getInt32(e), s = n.getUint32(e + 4);
|
|
206
240
|
return t * 4294967296 + s;
|
|
207
241
|
}
|
|
208
|
-
function
|
|
242
|
+
function oe(n, e) {
|
|
209
243
|
const t = n.getUint32(e), s = n.getUint32(e + 4);
|
|
210
244
|
return t * 4294967296 + s;
|
|
211
245
|
}
|
|
212
|
-
const
|
|
213
|
-
function
|
|
214
|
-
if (n >= 0 && e >= 0 && n <=
|
|
215
|
-
if (e === 0 && n <=
|
|
246
|
+
const ae = -1, he = 4294967296 - 1, ce = 17179869184 - 1;
|
|
247
|
+
function fe({ sec: n, nsec: e }) {
|
|
248
|
+
if (n >= 0 && e >= 0 && n <= ce)
|
|
249
|
+
if (e === 0 && n <= he) {
|
|
216
250
|
const t = new Uint8Array(4);
|
|
217
251
|
return new DataView(t.buffer).setUint32(0, n), t;
|
|
218
252
|
} else {
|
|
@@ -221,24 +255,24 @@ function oe({ sec: n, nsec: e }) {
|
|
|
221
255
|
}
|
|
222
256
|
else {
|
|
223
257
|
const t = new Uint8Array(12), s = new DataView(t.buffer);
|
|
224
|
-
return s.setUint32(0, e),
|
|
258
|
+
return s.setUint32(0, e), C(s, 4, n), t;
|
|
225
259
|
}
|
|
226
260
|
}
|
|
227
|
-
function
|
|
261
|
+
function de(n) {
|
|
228
262
|
const e = n.getTime(), t = Math.floor(e / 1e3), s = (e - t * 1e3) * 1e6, i = Math.floor(s / 1e9);
|
|
229
263
|
return {
|
|
230
264
|
sec: t + i,
|
|
231
265
|
nsec: s - i * 1e9
|
|
232
266
|
};
|
|
233
267
|
}
|
|
234
|
-
function
|
|
268
|
+
function le(n) {
|
|
235
269
|
if (n instanceof Date) {
|
|
236
|
-
const e =
|
|
237
|
-
return
|
|
270
|
+
const e = de(n);
|
|
271
|
+
return fe(e);
|
|
238
272
|
} else
|
|
239
273
|
return null;
|
|
240
274
|
}
|
|
241
|
-
function
|
|
275
|
+
function ue(n) {
|
|
242
276
|
const e = new DataView(n.buffer, n.byteOffset, n.byteLength);
|
|
243
277
|
switch (n.byteLength) {
|
|
244
278
|
case 4:
|
|
@@ -248,21 +282,21 @@ function ce(n) {
|
|
|
248
282
|
return { sec: i, nsec: r };
|
|
249
283
|
}
|
|
250
284
|
case 12: {
|
|
251
|
-
const t =
|
|
285
|
+
const t = F(e, 4), s = e.getUint32(0);
|
|
252
286
|
return { sec: t, nsec: s };
|
|
253
287
|
}
|
|
254
288
|
default:
|
|
255
289
|
throw new f(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`);
|
|
256
290
|
}
|
|
257
291
|
}
|
|
258
|
-
function
|
|
259
|
-
const e =
|
|
292
|
+
function xe(n) {
|
|
293
|
+
const e = ue(n);
|
|
260
294
|
return new Date(e.sec * 1e3 + e.nsec / 1e6);
|
|
261
295
|
}
|
|
262
|
-
const
|
|
263
|
-
type:
|
|
264
|
-
encode:
|
|
265
|
-
decode:
|
|
296
|
+
const we = {
|
|
297
|
+
type: ae,
|
|
298
|
+
encode: le,
|
|
299
|
+
decode: xe
|
|
266
300
|
}, p = class p {
|
|
267
301
|
constructor() {
|
|
268
302
|
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
@@ -275,7 +309,7 @@ const le = {
|
|
|
275
309
|
// custom extensions
|
|
276
310
|
o(this, "encoders", []);
|
|
277
311
|
o(this, "decoders", []);
|
|
278
|
-
this.register(
|
|
312
|
+
this.register(we);
|
|
279
313
|
}
|
|
280
314
|
register({ type: e, encode: t, decode: s }) {
|
|
281
315
|
if (e >= 0)
|
|
@@ -291,8 +325,8 @@ const le = {
|
|
|
291
325
|
if (i != null) {
|
|
292
326
|
const r = i(e, t);
|
|
293
327
|
if (r != null) {
|
|
294
|
-
const
|
|
295
|
-
return new
|
|
328
|
+
const a = -1 - s;
|
|
329
|
+
return new m(a, r);
|
|
296
330
|
}
|
|
297
331
|
}
|
|
298
332
|
}
|
|
@@ -301,27 +335,27 @@ const le = {
|
|
|
301
335
|
if (i != null) {
|
|
302
336
|
const r = i(e, t);
|
|
303
337
|
if (r != null) {
|
|
304
|
-
const
|
|
305
|
-
return new
|
|
338
|
+
const a = s;
|
|
339
|
+
return new m(a, r);
|
|
306
340
|
}
|
|
307
341
|
}
|
|
308
342
|
}
|
|
309
|
-
return e instanceof
|
|
343
|
+
return e instanceof m ? e : null;
|
|
310
344
|
}
|
|
311
345
|
decode(e, t, s) {
|
|
312
346
|
const i = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
|
|
313
|
-
return i ? i(e, t, s) : new
|
|
347
|
+
return i ? i(e, t, s) : new m(t, e);
|
|
314
348
|
}
|
|
315
349
|
};
|
|
316
350
|
o(p, "defaultCodec", new p());
|
|
317
|
-
let
|
|
318
|
-
function
|
|
351
|
+
let U = p;
|
|
352
|
+
function ge(n) {
|
|
319
353
|
return n instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && n instanceof SharedArrayBuffer;
|
|
320
354
|
}
|
|
321
355
|
function B(n) {
|
|
322
|
-
return n instanceof Uint8Array ? n : ArrayBuffer.isView(n) ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) :
|
|
356
|
+
return n instanceof Uint8Array ? n : ArrayBuffer.isView(n) ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) : ge(n) ? new Uint8Array(n) : Uint8Array.from(n);
|
|
323
357
|
}
|
|
324
|
-
const
|
|
358
|
+
const ye = 100, me = 2048;
|
|
325
359
|
class I {
|
|
326
360
|
constructor(e) {
|
|
327
361
|
o(this, "extensionCodec");
|
|
@@ -337,7 +371,7 @@ class I {
|
|
|
337
371
|
o(this, "view");
|
|
338
372
|
o(this, "bytes");
|
|
339
373
|
o(this, "entered", !1);
|
|
340
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
374
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? U.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? ye, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? me, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
|
|
341
375
|
}
|
|
342
376
|
clone() {
|
|
343
377
|
return new I({
|
|
@@ -422,8 +456,8 @@ class I {
|
|
|
422
456
|
throw new Error(`Too long string: ${e} bytes in UTF-8`);
|
|
423
457
|
}
|
|
424
458
|
encodeString(e) {
|
|
425
|
-
const s =
|
|
426
|
-
this.ensureBufferSizeToWrite(5 + s), this.writeStringHeader(s),
|
|
459
|
+
const s = q(e);
|
|
460
|
+
this.ensureBufferSizeToWrite(5 + s), this.writeStringHeader(s), j(e, this.bytes, this.pos), this.pos += s;
|
|
427
461
|
}
|
|
428
462
|
encodeObject(e, t) {
|
|
429
463
|
const s = this.extensionCodec.tryToEncode(e, this.context);
|
|
@@ -483,8 +517,8 @@ class I {
|
|
|
483
517
|
else
|
|
484
518
|
throw new Error(`Too large map object: ${i}`);
|
|
485
519
|
for (const r of s) {
|
|
486
|
-
const
|
|
487
|
-
this.ignoreUndefined &&
|
|
520
|
+
const a = e[r];
|
|
521
|
+
this.ignoreUndefined && a === void 0 || (this.encodeString(r), this.doEncode(a, t + 1));
|
|
488
522
|
}
|
|
489
523
|
}
|
|
490
524
|
encodeExtension(e) {
|
|
@@ -545,10 +579,10 @@ class I {
|
|
|
545
579
|
this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
|
|
546
580
|
}
|
|
547
581
|
writeU64(e) {
|
|
548
|
-
this.ensureBufferSizeToWrite(8),
|
|
582
|
+
this.ensureBufferSizeToWrite(8), re(this.view, this.pos, e), this.pos += 8;
|
|
549
583
|
}
|
|
550
584
|
writeI64(e) {
|
|
551
|
-
this.ensureBufferSizeToWrite(8),
|
|
585
|
+
this.ensureBufferSizeToWrite(8), C(this.view, this.pos, e), this.pos += 8;
|
|
552
586
|
}
|
|
553
587
|
writeBigUint64(e) {
|
|
554
588
|
this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
|
|
@@ -557,15 +591,15 @@ class I {
|
|
|
557
591
|
this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
|
|
558
592
|
}
|
|
559
593
|
}
|
|
560
|
-
function
|
|
594
|
+
function Ue(n, e) {
|
|
561
595
|
return new I(e).encodeSharedRef(n);
|
|
562
596
|
}
|
|
563
597
|
function E(n) {
|
|
564
598
|
return `${n < 0 ? "-" : ""}0x${Math.abs(n).toString(16).padStart(2, "0")}`;
|
|
565
599
|
}
|
|
566
|
-
const
|
|
567
|
-
class
|
|
568
|
-
constructor(e =
|
|
600
|
+
const pe = 16, Se = 16;
|
|
601
|
+
class Ee {
|
|
602
|
+
constructor(e = pe, t = Se) {
|
|
569
603
|
o(this, "hit", 0);
|
|
570
604
|
o(this, "miss", 0);
|
|
571
605
|
o(this, "caches");
|
|
@@ -581,9 +615,9 @@ class Ue {
|
|
|
581
615
|
find(e, t, s) {
|
|
582
616
|
const i = this.caches[s - 1];
|
|
583
617
|
e: for (const r of i) {
|
|
584
|
-
const
|
|
585
|
-
for (let
|
|
586
|
-
if (h
|
|
618
|
+
const a = r.bytes;
|
|
619
|
+
for (let h = 0; h < s; h++)
|
|
620
|
+
if (a[h] !== e[t + h])
|
|
587
621
|
continue e;
|
|
588
622
|
return r.str;
|
|
589
623
|
}
|
|
@@ -598,16 +632,16 @@ class Ue {
|
|
|
598
632
|
if (i != null)
|
|
599
633
|
return this.hit++, i;
|
|
600
634
|
this.miss++;
|
|
601
|
-
const r = D(e, t, s),
|
|
602
|
-
return this.store(
|
|
635
|
+
const r = D(e, t, s), a = Uint8Array.prototype.slice.call(e, t, t + s);
|
|
636
|
+
return this.store(a, r), r;
|
|
603
637
|
}
|
|
604
638
|
}
|
|
605
|
-
const A = "array", g = "map_key", _ = "map_value",
|
|
639
|
+
const A = "array", g = "map_key", _ = "map_value", Be = (n) => {
|
|
606
640
|
if (typeof n == "string" || typeof n == "number")
|
|
607
641
|
return n;
|
|
608
642
|
throw new f("The type of key must be string or number but " + typeof n);
|
|
609
643
|
};
|
|
610
|
-
class
|
|
644
|
+
class Ae {
|
|
611
645
|
constructor() {
|
|
612
646
|
o(this, "stack", []);
|
|
613
647
|
o(this, "stackHeadPosition", -1);
|
|
@@ -658,15 +692,15 @@ class pe {
|
|
|
658
692
|
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
659
693
|
}
|
|
660
694
|
}
|
|
661
|
-
const w = -1, T = new DataView(new ArrayBuffer(0)),
|
|
695
|
+
const w = -1, T = new DataView(new ArrayBuffer(0)), Ie = new Uint8Array(T.buffer);
|
|
662
696
|
try {
|
|
663
697
|
T.getInt8(0);
|
|
664
698
|
} catch (n) {
|
|
665
699
|
if (!(n instanceof RangeError))
|
|
666
700
|
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
667
701
|
}
|
|
668
|
-
const
|
|
669
|
-
class
|
|
702
|
+
const z = new RangeError("Insufficient data"), Te = new Ee();
|
|
703
|
+
class k {
|
|
670
704
|
constructor(e) {
|
|
671
705
|
o(this, "extensionCodec");
|
|
672
706
|
o(this, "context");
|
|
@@ -682,14 +716,14 @@ class v {
|
|
|
682
716
|
o(this, "totalPos", 0);
|
|
683
717
|
o(this, "pos", 0);
|
|
684
718
|
o(this, "view", T);
|
|
685
|
-
o(this, "bytes",
|
|
719
|
+
o(this, "bytes", Ie);
|
|
686
720
|
o(this, "headByte", w);
|
|
687
|
-
o(this, "stack", new
|
|
721
|
+
o(this, "stack", new Ae());
|
|
688
722
|
o(this, "entered", !1);
|
|
689
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
723
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? U.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? x, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? x, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? x, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? x, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? x, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : Te, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? Be;
|
|
690
724
|
}
|
|
691
725
|
clone() {
|
|
692
|
-
return new
|
|
726
|
+
return new k({
|
|
693
727
|
extensionCodec: this.extensionCodec,
|
|
694
728
|
context: this.context,
|
|
695
729
|
useBigInt64: this.useBigInt64,
|
|
@@ -759,10 +793,10 @@ class v {
|
|
|
759
793
|
try {
|
|
760
794
|
this.entered = !0;
|
|
761
795
|
let t = !1, s;
|
|
762
|
-
for await (const
|
|
796
|
+
for await (const h of e) {
|
|
763
797
|
if (t)
|
|
764
798
|
throw this.entered = !1, this.createExtraByteError(this.totalPos);
|
|
765
|
-
this.appendBuffer(
|
|
799
|
+
this.appendBuffer(h);
|
|
766
800
|
try {
|
|
767
801
|
s = this.doDecodeSync(), t = !0;
|
|
768
802
|
} catch (c) {
|
|
@@ -776,8 +810,8 @@ class v {
|
|
|
776
810
|
throw this.createExtraByteError(this.totalPos);
|
|
777
811
|
return s;
|
|
778
812
|
}
|
|
779
|
-
const { headByte: i, pos: r, totalPos:
|
|
780
|
-
throw new RangeError(`Insufficient data in parsing ${E(i)} at ${
|
|
813
|
+
const { headByte: i, pos: r, totalPos: a } = this;
|
|
814
|
+
throw new RangeError(`Insufficient data in parsing ${E(i)} at ${a} (${r} in the current buffer)`);
|
|
781
815
|
} finally {
|
|
782
816
|
this.entered = !1;
|
|
783
817
|
}
|
|
@@ -803,9 +837,9 @@ class v {
|
|
|
803
837
|
try {
|
|
804
838
|
for (; yield this.doDecodeSync(), --i !== 0; )
|
|
805
839
|
;
|
|
806
|
-
} catch (
|
|
807
|
-
if (!(
|
|
808
|
-
throw
|
|
840
|
+
} catch (a) {
|
|
841
|
+
if (!(a instanceof RangeError))
|
|
842
|
+
throw a;
|
|
809
843
|
}
|
|
810
844
|
this.totalPos += this.pos;
|
|
811
845
|
}
|
|
@@ -998,10 +1032,10 @@ class v {
|
|
|
998
1032
|
if (e > this.maxStrLength)
|
|
999
1033
|
throw new f(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
|
|
1000
1034
|
if (this.bytes.byteLength < this.pos + t + e)
|
|
1001
|
-
throw
|
|
1035
|
+
throw z;
|
|
1002
1036
|
const s = this.pos + t;
|
|
1003
1037
|
let i;
|
|
1004
|
-
return this.stateIsMapKey() && ((r = this.keyDecoder) != null && r.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, s, e) : i =
|
|
1038
|
+
return this.stateIsMapKey() && ((r = this.keyDecoder) != null && r.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, s, e) : i = ne(this.bytes, s, e), this.pos += t + e, i;
|
|
1005
1039
|
}
|
|
1006
1040
|
stateIsMapKey() {
|
|
1007
1041
|
return this.stack.length > 0 ? this.stack.top().type === g : !1;
|
|
@@ -1013,7 +1047,7 @@ class v {
|
|
|
1013
1047
|
if (e > this.maxBinLength)
|
|
1014
1048
|
throw new f(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
|
|
1015
1049
|
if (!this.hasRemaining(e + t))
|
|
1016
|
-
throw
|
|
1050
|
+
throw z;
|
|
1017
1051
|
const s = this.pos + t, i = this.bytes.subarray(s, s + e);
|
|
1018
1052
|
return this.pos += t + e, i;
|
|
1019
1053
|
}
|
|
@@ -1061,11 +1095,11 @@ class v {
|
|
|
1061
1095
|
return this.pos += 4, e;
|
|
1062
1096
|
}
|
|
1063
1097
|
readU64() {
|
|
1064
|
-
const e =
|
|
1098
|
+
const e = oe(this.view, this.pos);
|
|
1065
1099
|
return this.pos += 8, e;
|
|
1066
1100
|
}
|
|
1067
1101
|
readI64() {
|
|
1068
|
-
const e =
|
|
1102
|
+
const e = F(this.view, this.pos);
|
|
1069
1103
|
return this.pos += 8, e;
|
|
1070
1104
|
}
|
|
1071
1105
|
readU64AsBigInt() {
|
|
@@ -1085,10 +1119,10 @@ class v {
|
|
|
1085
1119
|
return this.pos += 8, e;
|
|
1086
1120
|
}
|
|
1087
1121
|
}
|
|
1088
|
-
function
|
|
1089
|
-
return new
|
|
1122
|
+
function ke(n, e) {
|
|
1123
|
+
return new k(e).decode(n);
|
|
1090
1124
|
}
|
|
1091
|
-
const
|
|
1125
|
+
const ve = /* @__PURE__ */ new Set([
|
|
1092
1126
|
"auth",
|
|
1093
1127
|
"open",
|
|
1094
1128
|
"send",
|
|
@@ -1102,8 +1136,6 @@ const Ae = /* @__PURE__ */ new Set([
|
|
|
1102
1136
|
"invoke",
|
|
1103
1137
|
"pubkey",
|
|
1104
1138
|
"ping",
|
|
1105
|
-
"annotate",
|
|
1106
|
-
"annotate_clear",
|
|
1107
1139
|
"uploadPrekeys",
|
|
1108
1140
|
"fetchPrekey",
|
|
1109
1141
|
"assign",
|
|
@@ -1113,28 +1145,30 @@ const Ae = /* @__PURE__ */ new Set([
|
|
|
1113
1145
|
"subscribe_inbox",
|
|
1114
1146
|
"unsubscribe_inbox"
|
|
1115
1147
|
]);
|
|
1116
|
-
function
|
|
1117
|
-
return
|
|
1148
|
+
function Ce(n) {
|
|
1149
|
+
return ve.has(n.type);
|
|
1118
1150
|
}
|
|
1119
|
-
function
|
|
1120
|
-
return
|
|
1151
|
+
function Fe(n) {
|
|
1152
|
+
return Ue(n);
|
|
1121
1153
|
}
|
|
1122
|
-
function
|
|
1154
|
+
function _e(n) {
|
|
1123
1155
|
let e;
|
|
1124
1156
|
try {
|
|
1125
|
-
e =
|
|
1157
|
+
e = ke(n);
|
|
1126
1158
|
} catch {
|
|
1127
1159
|
return null;
|
|
1128
1160
|
}
|
|
1129
1161
|
return typeof e != "object" || e === null || typeof e.type != "string" ? null : e;
|
|
1130
1162
|
}
|
|
1131
1163
|
export {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1164
|
+
$e as a,
|
|
1165
|
+
Le as b,
|
|
1166
|
+
_e as d,
|
|
1167
|
+
Fe as e,
|
|
1168
|
+
H as h,
|
|
1169
|
+
Ce as i,
|
|
1170
|
+
ze as l,
|
|
1171
|
+
De as p,
|
|
1138
1172
|
R as r
|
|
1139
1173
|
};
|
|
1140
1174
|
//# sourceMappingURL=codec.js.map
|