@dittolive/ditto-chat-core 0.1.1 → 0.1.3
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/index.es.js +528 -525
- package/dist/index.umd.js +3 -3
- package/dist/src/slices/useMessages.d.ts +2 -3
- package/dist/src/useChat.d.ts +3 -2
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -7,8 +7,8 @@ const ze = {
|
|
|
7
7
|
canRemoveOwnReaction: !0,
|
|
8
8
|
canMentionUsers: !0,
|
|
9
9
|
canSubscribeToRoom: !0
|
|
10
|
-
},
|
|
11
|
-
rbacConfig:
|
|
10
|
+
}, Le = (e, r, { rbacConfig: t = {} }) => ({
|
|
11
|
+
rbacConfig: t,
|
|
12
12
|
/**
|
|
13
13
|
* Check if a specific permission action is allowed.
|
|
14
14
|
*
|
|
@@ -24,8 +24,8 @@ const ze = {
|
|
|
24
24
|
* @returns boolean indicating if action is allowed
|
|
25
25
|
*/
|
|
26
26
|
canPerformAction: (s) => {
|
|
27
|
-
const
|
|
28
|
-
return
|
|
27
|
+
const c = r().rbacConfig[s];
|
|
28
|
+
return c !== void 0 ? c : ze[s];
|
|
29
29
|
},
|
|
30
30
|
/**
|
|
31
31
|
* Update the RBAC permission configuration.
|
|
@@ -49,7 +49,7 @@ const ze = {
|
|
|
49
49
|
}));
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
|
-
var Ae = /* @__PURE__ */ Symbol.for("immer-nothing"), ye = /* @__PURE__ */ Symbol.for("immer-draftable"),
|
|
52
|
+
var Ae = /* @__PURE__ */ Symbol.for("immer-nothing"), ye = /* @__PURE__ */ Symbol.for("immer-draftable"), S = /* @__PURE__ */ Symbol.for("immer-state"), He = process.env.NODE_ENV !== "production" ? [
|
|
53
53
|
// All error codes, starting by 0:
|
|
54
54
|
function(e) {
|
|
55
55
|
return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
|
|
@@ -80,9 +80,9 @@ var Ae = /* @__PURE__ */ Symbol.for("immer-nothing"), ye = /* @__PURE__ */ Symbo
|
|
|
80
80
|
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
81
81
|
// See Patches.ts for additional errors
|
|
82
82
|
] : [];
|
|
83
|
-
function T(e, ...
|
|
83
|
+
function T(e, ...r) {
|
|
84
84
|
if (process.env.NODE_ENV !== "production") {
|
|
85
|
-
const
|
|
85
|
+
const t = He[e], n = typeof t == "function" ? t.apply(null, r) : t;
|
|
86
86
|
throw new Error(`[Immer] ${n}`);
|
|
87
87
|
}
|
|
88
88
|
throw new Error(
|
|
@@ -91,92 +91,92 @@ function T(e, ...t) {
|
|
|
91
91
|
}
|
|
92
92
|
var B = Object.getPrototypeOf;
|
|
93
93
|
function N(e) {
|
|
94
|
-
return !!e && !!e[
|
|
94
|
+
return !!e && !!e[S];
|
|
95
95
|
}
|
|
96
96
|
function U(e) {
|
|
97
|
-
return e ? ve(e) || Array.isArray(e) || !!e[ye] || !!e.constructor?.[ye] ||
|
|
97
|
+
return e ? ve(e) || Array.isArray(e) || !!e[ye] || !!e.constructor?.[ye] || L(e) || X(e) : !1;
|
|
98
98
|
}
|
|
99
99
|
var $e = Object.prototype.constructor.toString(), ge = /* @__PURE__ */ new WeakMap();
|
|
100
100
|
function ve(e) {
|
|
101
101
|
if (!e || typeof e != "object")
|
|
102
102
|
return !1;
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const r = Object.getPrototypeOf(e);
|
|
104
|
+
if (r === null || r === Object.prototype)
|
|
105
105
|
return !0;
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
106
|
+
const t = Object.hasOwnProperty.call(r, "constructor") && r.constructor;
|
|
107
|
+
if (t === Object)
|
|
108
108
|
return !0;
|
|
109
|
-
if (typeof
|
|
109
|
+
if (typeof t != "function")
|
|
110
110
|
return !1;
|
|
111
|
-
let n = ge.get(
|
|
112
|
-
return n === void 0 && (n = Function.toString.call(
|
|
111
|
+
let n = ge.get(t);
|
|
112
|
+
return n === void 0 && (n = Function.toString.call(t), ge.set(t, n)), n === $e;
|
|
113
113
|
}
|
|
114
|
-
function q(e,
|
|
115
|
-
V(e) === 0 ? (
|
|
116
|
-
|
|
117
|
-
}) : e.forEach((n, s) =>
|
|
114
|
+
function q(e, r, t = !0) {
|
|
115
|
+
V(e) === 0 ? (t ? Reflect.ownKeys(e) : Object.keys(e)).forEach((s) => {
|
|
116
|
+
r(s, e[s], e);
|
|
117
|
+
}) : e.forEach((n, s) => r(s, n, e));
|
|
118
118
|
}
|
|
119
119
|
function V(e) {
|
|
120
|
-
const
|
|
121
|
-
return
|
|
120
|
+
const r = e[S];
|
|
121
|
+
return r ? r.type_ : Array.isArray(e) ? 1 : L(e) ? 2 : X(e) ? 3 : 0;
|
|
122
122
|
}
|
|
123
|
-
function oe(e,
|
|
124
|
-
return V(e) === 2 ? e.has(
|
|
123
|
+
function oe(e, r) {
|
|
124
|
+
return V(e) === 2 ? e.has(r) : Object.prototype.hasOwnProperty.call(e, r);
|
|
125
125
|
}
|
|
126
|
-
function Me(e,
|
|
126
|
+
function Me(e, r, t) {
|
|
127
127
|
const n = V(e);
|
|
128
|
-
n === 2 ? e.set(
|
|
128
|
+
n === 2 ? e.set(r, t) : n === 3 ? e.add(t) : e[r] = t;
|
|
129
129
|
}
|
|
130
|
-
function je(e,
|
|
131
|
-
return e ===
|
|
130
|
+
function je(e, r) {
|
|
131
|
+
return e === r ? e !== 0 || 1 / e === 1 / r : e !== e && r !== r;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function L(e) {
|
|
134
134
|
return e instanceof Map;
|
|
135
135
|
}
|
|
136
136
|
function X(e) {
|
|
137
137
|
return e instanceof Set;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function C(e) {
|
|
140
140
|
return e.copy_ || e.base_;
|
|
141
141
|
}
|
|
142
|
-
function ie(e,
|
|
143
|
-
if (
|
|
142
|
+
function ie(e, r) {
|
|
143
|
+
if (L(e))
|
|
144
144
|
return new Map(e);
|
|
145
145
|
if (X(e))
|
|
146
146
|
return new Set(e);
|
|
147
147
|
if (Array.isArray(e))
|
|
148
148
|
return Array.prototype.slice.call(e);
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
149
|
+
const t = ve(e);
|
|
150
|
+
if (r === !0 || r === "class_only" && !t) {
|
|
151
151
|
const n = Object.getOwnPropertyDescriptors(e);
|
|
152
|
-
delete n[
|
|
152
|
+
delete n[S];
|
|
153
153
|
let s = Reflect.ownKeys(n);
|
|
154
154
|
for (let o = 0; o < s.length; o++) {
|
|
155
|
-
const
|
|
156
|
-
|
|
155
|
+
const c = s[o], a = n[c];
|
|
156
|
+
a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (n[c] = {
|
|
157
157
|
configurable: !0,
|
|
158
158
|
writable: !0,
|
|
159
159
|
// could live with !!desc.set as well here...
|
|
160
|
-
enumerable:
|
|
161
|
-
value: e[
|
|
160
|
+
enumerable: a.enumerable,
|
|
161
|
+
value: e[c]
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
return Object.create(B(e), n);
|
|
165
165
|
} else {
|
|
166
166
|
const n = B(e);
|
|
167
|
-
if (n !== null &&
|
|
167
|
+
if (n !== null && t)
|
|
168
168
|
return { ...e };
|
|
169
169
|
const s = Object.create(n);
|
|
170
170
|
return Object.assign(s, e);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function fe(e,
|
|
173
|
+
function fe(e, r = !1) {
|
|
174
174
|
return Z(e) || N(e) || !U(e) || (V(e) > 1 && Object.defineProperties(e, {
|
|
175
175
|
set: W,
|
|
176
176
|
add: W,
|
|
177
177
|
clear: W,
|
|
178
178
|
delete: W
|
|
179
|
-
}), Object.freeze(e),
|
|
179
|
+
}), Object.freeze(e), r && Object.values(e).forEach((t) => fe(t, !0))), e;
|
|
180
180
|
}
|
|
181
181
|
function We() {
|
|
182
182
|
T(2);
|
|
@@ -189,117 +189,117 @@ function Z(e) {
|
|
|
189
189
|
}
|
|
190
190
|
var Ge = {};
|
|
191
191
|
function P(e) {
|
|
192
|
-
const
|
|
193
|
-
return
|
|
192
|
+
const r = Ge[e];
|
|
193
|
+
return r || T(0, e), r;
|
|
194
194
|
}
|
|
195
195
|
var F;
|
|
196
196
|
function Ce() {
|
|
197
197
|
return F;
|
|
198
198
|
}
|
|
199
|
-
function qe(e,
|
|
199
|
+
function qe(e, r) {
|
|
200
200
|
return {
|
|
201
201
|
drafts_: [],
|
|
202
202
|
parent_: e,
|
|
203
|
-
immer_:
|
|
203
|
+
immer_: r,
|
|
204
204
|
// Whenever the modified draft contains a draft from another scope, we
|
|
205
205
|
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
206
206
|
canAutoFreeze_: !0,
|
|
207
207
|
unfinalizedDrafts_: 0
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function he(e,
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
function ae(e) {
|
|
214
|
-
ce(e), e.drafts_.forEach(Qe), e.drafts_ = null;
|
|
210
|
+
function he(e, r) {
|
|
211
|
+
r && (P("Patches"), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = r);
|
|
215
212
|
}
|
|
216
213
|
function ce(e) {
|
|
214
|
+
ae(e), e.drafts_.forEach(Qe), e.drafts_ = null;
|
|
215
|
+
}
|
|
216
|
+
function ae(e) {
|
|
217
217
|
e === F && (F = e.parent_);
|
|
218
218
|
}
|
|
219
219
|
function be(e) {
|
|
220
220
|
return F = qe(F, e);
|
|
221
221
|
}
|
|
222
222
|
function Qe(e) {
|
|
223
|
-
const
|
|
224
|
-
|
|
223
|
+
const r = e[S];
|
|
224
|
+
r.type_ === 0 || r.type_ === 1 ? r.revoke_() : r.revoked_ = !0;
|
|
225
225
|
}
|
|
226
|
-
function _e(e,
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
return e !== void 0 && e !==
|
|
230
|
-
|
|
226
|
+
function _e(e, r) {
|
|
227
|
+
r.unfinalizedDrafts_ = r.drafts_.length;
|
|
228
|
+
const t = r.drafts_[0];
|
|
229
|
+
return e !== void 0 && e !== t ? (t[S].modified_ && (ce(r), T(4)), U(e) && (e = Q(r, e), r.parent_ || Y(r, e)), r.patches_ && P("Patches").generateReplacementPatches_(
|
|
230
|
+
t[S].base_,
|
|
231
231
|
e,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
)) : e = Q(
|
|
232
|
+
r.patches_,
|
|
233
|
+
r.inversePatches_
|
|
234
|
+
)) : e = Q(r, t, []), ce(r), r.patches_ && r.patchListener_(r.patches_, r.inversePatches_), e !== Ae ? e : void 0;
|
|
235
235
|
}
|
|
236
|
-
function Q(e,
|
|
237
|
-
if (Z(
|
|
238
|
-
return
|
|
239
|
-
const n = e.immer_.shouldUseStrictIteration(), s =
|
|
236
|
+
function Q(e, r, t) {
|
|
237
|
+
if (Z(r))
|
|
238
|
+
return r;
|
|
239
|
+
const n = e.immer_.shouldUseStrictIteration(), s = r[S];
|
|
240
240
|
if (!s)
|
|
241
241
|
return q(
|
|
242
|
-
|
|
243
|
-
(o,
|
|
242
|
+
r,
|
|
243
|
+
(o, c) => we(e, s, r, o, c, t),
|
|
244
244
|
n
|
|
245
|
-
),
|
|
245
|
+
), r;
|
|
246
246
|
if (s.scope_ !== e)
|
|
247
|
-
return
|
|
247
|
+
return r;
|
|
248
248
|
if (!s.modified_)
|
|
249
249
|
return Y(e, s.base_, !0), s.base_;
|
|
250
250
|
if (!s.finalized_) {
|
|
251
251
|
s.finalized_ = !0, s.scope_.unfinalizedDrafts_--;
|
|
252
252
|
const o = s.copy_;
|
|
253
|
-
let
|
|
254
|
-
s.type_ === 3 && (
|
|
255
|
-
|
|
256
|
-
(
|
|
253
|
+
let c = o, a = !1;
|
|
254
|
+
s.type_ === 3 && (c = new Set(o), o.clear(), a = !0), q(
|
|
255
|
+
c,
|
|
256
|
+
(y, g) => we(
|
|
257
257
|
e,
|
|
258
258
|
s,
|
|
259
259
|
o,
|
|
260
|
-
d,
|
|
261
260
|
y,
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
g,
|
|
262
|
+
t,
|
|
263
|
+
a
|
|
264
264
|
),
|
|
265
265
|
n
|
|
266
|
-
), Y(e, o, !1),
|
|
266
|
+
), Y(e, o, !1), t && e.patches_ && P("Patches").generatePatches_(
|
|
267
267
|
s,
|
|
268
|
-
|
|
268
|
+
t,
|
|
269
269
|
e.patches_,
|
|
270
270
|
e.inversePatches_
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
return s.copy_;
|
|
274
274
|
}
|
|
275
|
-
function we(e,
|
|
276
|
-
if (s == null || typeof s != "object" && !
|
|
275
|
+
function we(e, r, t, n, s, o, c) {
|
|
276
|
+
if (s == null || typeof s != "object" && !c)
|
|
277
277
|
return;
|
|
278
|
-
const
|
|
279
|
-
if (!(
|
|
280
|
-
if (process.env.NODE_ENV !== "production" && s ===
|
|
281
|
-
const
|
|
282
|
-
!oe(
|
|
283
|
-
if (Me(
|
|
278
|
+
const a = Z(s);
|
|
279
|
+
if (!(a && !c)) {
|
|
280
|
+
if (process.env.NODE_ENV !== "production" && s === t && T(5), N(s)) {
|
|
281
|
+
const y = o && r && r.type_ !== 3 && // Set objects are atomic since they have no keys.
|
|
282
|
+
!oe(r.assigned_, n) ? o.concat(n) : void 0, g = Q(e, s, y);
|
|
283
|
+
if (Me(t, n, g), N(g))
|
|
284
284
|
e.canAutoFreeze_ = !1;
|
|
285
285
|
else
|
|
286
286
|
return;
|
|
287
|
-
} else
|
|
288
|
-
if (U(s) && !
|
|
289
|
-
if (!e.immer_.autoFreeze_ && e.unfinalizedDrafts_ < 1 ||
|
|
287
|
+
} else c && t.add(s);
|
|
288
|
+
if (U(s) && !a) {
|
|
289
|
+
if (!e.immer_.autoFreeze_ && e.unfinalizedDrafts_ < 1 || r && r.base_ && r.base_[n] === s && a)
|
|
290
290
|
return;
|
|
291
|
-
Q(e, s), (!
|
|
291
|
+
Q(e, s), (!r || !r.scope_.parent_) && typeof n != "symbol" && (L(t) ? t.has(n) : Object.prototype.propertyIsEnumerable.call(t, n)) && Y(e, s);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
function Y(e,
|
|
296
|
-
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && fe(
|
|
295
|
+
function Y(e, r, t = !1) {
|
|
296
|
+
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && fe(r, t);
|
|
297
297
|
}
|
|
298
|
-
function Ye(e,
|
|
299
|
-
const
|
|
300
|
-
type_:
|
|
298
|
+
function Ye(e, r) {
|
|
299
|
+
const t = Array.isArray(e), n = {
|
|
300
|
+
type_: t ? 1 : 0,
|
|
301
301
|
// Track which produce call this is associated with.
|
|
302
|
-
scope_:
|
|
302
|
+
scope_: r ? r.scope_ : Ce(),
|
|
303
303
|
// True for both shallow and deep changes.
|
|
304
304
|
modified_: !1,
|
|
305
305
|
// Used during finalization.
|
|
@@ -307,7 +307,7 @@ function Ye(e, t) {
|
|
|
307
307
|
// Track which properties have been assigned (true) or deleted (false).
|
|
308
308
|
assigned_: {},
|
|
309
309
|
// The parent draft state.
|
|
310
|
-
parent_:
|
|
310
|
+
parent_: r,
|
|
311
311
|
// The base state.
|
|
312
312
|
base_: e,
|
|
313
313
|
// The base proxy.
|
|
@@ -320,54 +320,54 @@ function Ye(e, t) {
|
|
|
320
320
|
isManual_: !1
|
|
321
321
|
};
|
|
322
322
|
let s = n, o = me;
|
|
323
|
-
|
|
324
|
-
const { revoke:
|
|
325
|
-
return n.draft_ =
|
|
323
|
+
t && (s = [n], o = z);
|
|
324
|
+
const { revoke: c, proxy: a } = Proxy.revocable(s, o);
|
|
325
|
+
return n.draft_ = a, n.revoke_ = c, a;
|
|
326
326
|
}
|
|
327
327
|
var me = {
|
|
328
|
-
get(e,
|
|
329
|
-
if (
|
|
328
|
+
get(e, r) {
|
|
329
|
+
if (r === S)
|
|
330
330
|
return e;
|
|
331
|
-
const
|
|
332
|
-
if (!oe(
|
|
333
|
-
return Ve(e,
|
|
334
|
-
const n = r
|
|
335
|
-
return e.finalized_ || !U(n) ? n : n === ee(e.base_,
|
|
331
|
+
const t = C(e);
|
|
332
|
+
if (!oe(t, r))
|
|
333
|
+
return Ve(e, t, r);
|
|
334
|
+
const n = t[r];
|
|
335
|
+
return e.finalized_ || !U(n) ? n : n === ee(e.base_, r) ? (re(e), e.copy_[r] = le(n, e)) : n;
|
|
336
336
|
},
|
|
337
|
-
has(e,
|
|
338
|
-
return
|
|
337
|
+
has(e, r) {
|
|
338
|
+
return r in C(e);
|
|
339
339
|
},
|
|
340
340
|
ownKeys(e) {
|
|
341
|
-
return Reflect.ownKeys(
|
|
341
|
+
return Reflect.ownKeys(C(e));
|
|
342
342
|
},
|
|
343
|
-
set(e,
|
|
344
|
-
const n = Ue(
|
|
343
|
+
set(e, r, t) {
|
|
344
|
+
const n = Ue(C(e), r);
|
|
345
345
|
if (n?.set)
|
|
346
|
-
return n.set.call(e.draft_,
|
|
346
|
+
return n.set.call(e.draft_, t), !0;
|
|
347
347
|
if (!e.modified_) {
|
|
348
|
-
const s = ee(
|
|
349
|
-
if (o && o.base_ ===
|
|
350
|
-
return e.copy_[
|
|
351
|
-
if (je(
|
|
348
|
+
const s = ee(C(e), r), o = s?.[S];
|
|
349
|
+
if (o && o.base_ === t)
|
|
350
|
+
return e.copy_[r] = t, e.assigned_[r] = !1, !0;
|
|
351
|
+
if (je(t, s) && (t !== void 0 || oe(e.base_, r)))
|
|
352
352
|
return !0;
|
|
353
|
-
|
|
353
|
+
re(e), ue(e);
|
|
354
354
|
}
|
|
355
|
-
return e.copy_[
|
|
356
|
-
(
|
|
357
|
-
Number.isNaN(
|
|
355
|
+
return e.copy_[r] === t && // special case: handle new props with value 'undefined'
|
|
356
|
+
(t !== void 0 || r in e.copy_) || // special case: NaN
|
|
357
|
+
Number.isNaN(t) && Number.isNaN(e.copy_[r]) || (e.copy_[r] = t, e.assigned_[r] = !0), !0;
|
|
358
358
|
},
|
|
359
|
-
deleteProperty(e,
|
|
360
|
-
return ee(e.base_,
|
|
359
|
+
deleteProperty(e, r) {
|
|
360
|
+
return ee(e.base_, r) !== void 0 || r in e.base_ ? (e.assigned_[r] = !1, re(e), ue(e)) : delete e.assigned_[r], e.copy_ && delete e.copy_[r], !0;
|
|
361
361
|
},
|
|
362
362
|
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
363
363
|
// the same guarantee in ES5 mode.
|
|
364
|
-
getOwnPropertyDescriptor(e,
|
|
365
|
-
const
|
|
364
|
+
getOwnPropertyDescriptor(e, r) {
|
|
365
|
+
const t = C(e), n = Reflect.getOwnPropertyDescriptor(t, r);
|
|
366
366
|
return n && {
|
|
367
367
|
writable: !0,
|
|
368
|
-
configurable: e.type_ !== 1 ||
|
|
368
|
+
configurable: e.type_ !== 1 || r !== "length",
|
|
369
369
|
enumerable: n.enumerable,
|
|
370
|
-
value: r
|
|
370
|
+
value: t[r]
|
|
371
371
|
};
|
|
372
372
|
},
|
|
373
373
|
defineProperty() {
|
|
@@ -380,44 +380,44 @@ var me = {
|
|
|
380
380
|
T(12);
|
|
381
381
|
}
|
|
382
382
|
}, z = {};
|
|
383
|
-
q(me, (e,
|
|
383
|
+
q(me, (e, r) => {
|
|
384
384
|
z[e] = function() {
|
|
385
|
-
return arguments[0] = arguments[0][0],
|
|
385
|
+
return arguments[0] = arguments[0][0], r.apply(this, arguments);
|
|
386
386
|
};
|
|
387
387
|
});
|
|
388
|
-
z.deleteProperty = function(e,
|
|
389
|
-
return process.env.NODE_ENV !== "production" && isNaN(parseInt(
|
|
388
|
+
z.deleteProperty = function(e, r) {
|
|
389
|
+
return process.env.NODE_ENV !== "production" && isNaN(parseInt(r)) && T(13), z.set.call(this, e, r, void 0);
|
|
390
390
|
};
|
|
391
|
-
z.set = function(e,
|
|
392
|
-
return process.env.NODE_ENV !== "production" &&
|
|
391
|
+
z.set = function(e, r, t) {
|
|
392
|
+
return process.env.NODE_ENV !== "production" && r !== "length" && isNaN(parseInt(r)) && T(14), me.set.call(this, e[0], r, t, e[0]);
|
|
393
393
|
};
|
|
394
|
-
function ee(e,
|
|
395
|
-
const
|
|
396
|
-
return (
|
|
394
|
+
function ee(e, r) {
|
|
395
|
+
const t = e[S];
|
|
396
|
+
return (t ? C(t) : e)[r];
|
|
397
397
|
}
|
|
398
|
-
function Ve(e,
|
|
399
|
-
const n = Ue(
|
|
398
|
+
function Ve(e, r, t) {
|
|
399
|
+
const n = Ue(r, t);
|
|
400
400
|
return n ? "value" in n ? n.value : (
|
|
401
401
|
// This is a very special case, if the prop is a getter defined by the
|
|
402
402
|
// prototype, we should invoke it with the draft as context!
|
|
403
403
|
n.get?.call(e.draft_)
|
|
404
404
|
) : void 0;
|
|
405
405
|
}
|
|
406
|
-
function Ue(e,
|
|
407
|
-
if (!(
|
|
406
|
+
function Ue(e, r) {
|
|
407
|
+
if (!(r in e))
|
|
408
408
|
return;
|
|
409
|
-
let
|
|
410
|
-
for (;
|
|
411
|
-
const n = Object.getOwnPropertyDescriptor(
|
|
409
|
+
let t = B(e);
|
|
410
|
+
for (; t; ) {
|
|
411
|
+
const n = Object.getOwnPropertyDescriptor(t, r);
|
|
412
412
|
if (n)
|
|
413
413
|
return n;
|
|
414
|
-
|
|
414
|
+
t = B(t);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
function ue(e) {
|
|
418
418
|
e.modified_ || (e.modified_ = !0, e.parent_ && ue(e.parent_));
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function re(e) {
|
|
421
421
|
e.copy_ || (e.copy_ = ie(
|
|
422
422
|
e.base_,
|
|
423
423
|
e.scope_.immer_.useStrictShallowCopy_
|
|
@@ -425,53 +425,53 @@ function te(e) {
|
|
|
425
425
|
}
|
|
426
426
|
var Xe = class {
|
|
427
427
|
constructor(e) {
|
|
428
|
-
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !0, this.produce = (
|
|
429
|
-
if (typeof
|
|
430
|
-
const o =
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
return function(
|
|
434
|
-
return
|
|
428
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !0, this.produce = (r, t, n) => {
|
|
429
|
+
if (typeof r == "function" && typeof t != "function") {
|
|
430
|
+
const o = t;
|
|
431
|
+
t = r;
|
|
432
|
+
const c = this;
|
|
433
|
+
return function(y = o, ...g) {
|
|
434
|
+
return c.produce(y, (p) => t.call(this, p, ...g));
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
|
-
typeof
|
|
437
|
+
typeof t != "function" && T(6), n !== void 0 && typeof n != "function" && T(7);
|
|
438
438
|
let s;
|
|
439
|
-
if (U(
|
|
440
|
-
const o = be(this),
|
|
441
|
-
let
|
|
439
|
+
if (U(r)) {
|
|
440
|
+
const o = be(this), c = le(r, void 0);
|
|
441
|
+
let a = !0;
|
|
442
442
|
try {
|
|
443
|
-
s =
|
|
443
|
+
s = t(c), a = !1;
|
|
444
444
|
} finally {
|
|
445
|
-
|
|
445
|
+
a ? ce(o) : ae(o);
|
|
446
446
|
}
|
|
447
447
|
return he(o, n), _e(s, o);
|
|
448
|
-
} else if (!
|
|
449
|
-
if (s = r
|
|
450
|
-
const o = [],
|
|
451
|
-
P("Patches").generateReplacementPatches_(
|
|
448
|
+
} else if (!r || typeof r != "object") {
|
|
449
|
+
if (s = t(r), s === void 0 && (s = r), s === Ae && (s = void 0), this.autoFreeze_ && fe(s, !0), n) {
|
|
450
|
+
const o = [], c = [];
|
|
451
|
+
P("Patches").generateReplacementPatches_(r, s, o, c), n(o, c);
|
|
452
452
|
}
|
|
453
453
|
return s;
|
|
454
454
|
} else
|
|
455
|
-
T(1,
|
|
456
|
-
}, this.produceWithPatches = (
|
|
457
|
-
if (typeof
|
|
458
|
-
return (
|
|
455
|
+
T(1, r);
|
|
456
|
+
}, this.produceWithPatches = (r, t) => {
|
|
457
|
+
if (typeof r == "function")
|
|
458
|
+
return (c, ...a) => this.produceWithPatches(c, (y) => r(y, ...a));
|
|
459
459
|
let n, s;
|
|
460
|
-
return [this.produce(
|
|
461
|
-
n =
|
|
460
|
+
return [this.produce(r, t, (c, a) => {
|
|
461
|
+
n = c, s = a;
|
|
462
462
|
}), n, s];
|
|
463
463
|
}, typeof e?.autoFreeze == "boolean" && this.setAutoFreeze(e.autoFreeze), typeof e?.useStrictShallowCopy == "boolean" && this.setUseStrictShallowCopy(e.useStrictShallowCopy), typeof e?.useStrictIteration == "boolean" && this.setUseStrictIteration(e.useStrictIteration);
|
|
464
464
|
}
|
|
465
465
|
createDraft(e) {
|
|
466
466
|
U(e) || T(8), N(e) && (e = Ze(e));
|
|
467
|
-
const
|
|
468
|
-
return
|
|
467
|
+
const r = be(this), t = le(e, void 0);
|
|
468
|
+
return t[S].isManual_ = !0, ae(r), t;
|
|
469
469
|
}
|
|
470
|
-
finishDraft(e,
|
|
471
|
-
const
|
|
472
|
-
(!
|
|
473
|
-
const { scope_: n } =
|
|
474
|
-
return he(n,
|
|
470
|
+
finishDraft(e, r) {
|
|
471
|
+
const t = e && e[S];
|
|
472
|
+
(!t || !t.isManual_) && T(9);
|
|
473
|
+
const { scope_: n } = t;
|
|
474
|
+
return he(n, r), _e(void 0, n);
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Pass true to automatically freeze all copies created by Immer.
|
|
@@ -501,26 +501,26 @@ var Xe = class {
|
|
|
501
501
|
shouldUseStrictIteration() {
|
|
502
502
|
return this.useStrictIteration_;
|
|
503
503
|
}
|
|
504
|
-
applyPatches(e,
|
|
505
|
-
let
|
|
506
|
-
for (
|
|
507
|
-
const s = t
|
|
504
|
+
applyPatches(e, r) {
|
|
505
|
+
let t;
|
|
506
|
+
for (t = r.length - 1; t >= 0; t--) {
|
|
507
|
+
const s = r[t];
|
|
508
508
|
if (s.path.length === 0 && s.op === "replace") {
|
|
509
509
|
e = s.value;
|
|
510
510
|
break;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
|
|
513
|
+
t > -1 && (r = r.slice(t + 1));
|
|
514
514
|
const n = P("Patches").applyPatches_;
|
|
515
|
-
return N(e) ? n(e,
|
|
515
|
+
return N(e) ? n(e, r) : this.produce(
|
|
516
516
|
e,
|
|
517
|
-
(s) => n(s,
|
|
517
|
+
(s) => n(s, r)
|
|
518
518
|
);
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
|
-
function le(e,
|
|
522
|
-
const
|
|
523
|
-
return (
|
|
521
|
+
function le(e, r) {
|
|
522
|
+
const t = L(e) ? P("MapSet").proxyMap_(e, r) : X(e) ? P("MapSet").proxySet_(e, r) : Ye(e, r);
|
|
523
|
+
return (r ? r.scope_ : Ce()).drafts_.push(t), t;
|
|
524
524
|
}
|
|
525
525
|
function Ze(e) {
|
|
526
526
|
return N(e) || T(10, e), Pe(e);
|
|
@@ -528,94 +528,96 @@ function Ze(e) {
|
|
|
528
528
|
function Pe(e) {
|
|
529
529
|
if (!U(e) || Z(e))
|
|
530
530
|
return e;
|
|
531
|
-
const
|
|
532
|
-
let
|
|
533
|
-
if (
|
|
534
|
-
if (!
|
|
535
|
-
return
|
|
536
|
-
|
|
531
|
+
const r = e[S];
|
|
532
|
+
let t, n = !0;
|
|
533
|
+
if (r) {
|
|
534
|
+
if (!r.modified_)
|
|
535
|
+
return r.base_;
|
|
536
|
+
r.finalized_ = !0, t = ie(e, r.scope_.immer_.useStrictShallowCopy_), n = r.scope_.immer_.shouldUseStrictIteration();
|
|
537
537
|
} else
|
|
538
|
-
|
|
538
|
+
t = ie(e, !0);
|
|
539
539
|
return q(
|
|
540
|
-
|
|
540
|
+
t,
|
|
541
541
|
(s, o) => {
|
|
542
|
-
Me(
|
|
542
|
+
Me(t, s, Pe(o));
|
|
543
543
|
},
|
|
544
544
|
n
|
|
545
|
-
),
|
|
545
|
+
), r && (r.finalized_ = !1), t;
|
|
546
546
|
}
|
|
547
|
-
var Je = new Xe(),
|
|
547
|
+
var Je = new Xe(), v = Je.produce;
|
|
548
548
|
const E = [];
|
|
549
549
|
for (let e = 0; e < 256; ++e)
|
|
550
550
|
E.push((e + 256).toString(16).slice(1));
|
|
551
|
-
function Ke(e,
|
|
552
|
-
return (E[e[
|
|
551
|
+
function Ke(e, r = 0) {
|
|
552
|
+
return (E[e[r + 0]] + E[e[r + 1]] + E[e[r + 2]] + E[e[r + 3]] + "-" + E[e[r + 4]] + E[e[r + 5]] + "-" + E[e[r + 6]] + E[e[r + 7]] + "-" + E[e[r + 8]] + E[e[r + 9]] + "-" + E[e[r + 10]] + E[e[r + 11]] + E[e[r + 12]] + E[e[r + 13]] + E[e[r + 14]] + E[e[r + 15]]).toLowerCase();
|
|
553
553
|
}
|
|
554
|
-
let
|
|
555
|
-
const
|
|
556
|
-
function
|
|
557
|
-
if (!
|
|
554
|
+
let te;
|
|
555
|
+
const er = new Uint8Array(16);
|
|
556
|
+
function rr() {
|
|
557
|
+
if (!te) {
|
|
558
558
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
559
559
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
560
|
-
|
|
560
|
+
te = crypto.getRandomValues.bind(crypto);
|
|
561
561
|
}
|
|
562
|
-
return
|
|
562
|
+
return te(er);
|
|
563
563
|
}
|
|
564
|
-
const
|
|
565
|
-
function
|
|
564
|
+
const tr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), pe = { randomUUID: tr };
|
|
565
|
+
function nr(e, r, t) {
|
|
566
566
|
e = e || {};
|
|
567
|
-
const n = e.random ?? e.rng?.() ??
|
|
567
|
+
const n = e.random ?? e.rng?.() ?? rr();
|
|
568
568
|
if (n.length < 16)
|
|
569
569
|
throw new Error("Random bytes length must be >= 16");
|
|
570
570
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Ke(n);
|
|
571
571
|
}
|
|
572
|
-
function Ne(e,
|
|
573
|
-
return pe.randomUUID && !e ? pe.randomUUID() :
|
|
572
|
+
function Ne(e, r, t) {
|
|
573
|
+
return pe.randomUUID && !e ? pe.randomUUID() : nr(e);
|
|
574
574
|
}
|
|
575
|
-
function Ee(e,
|
|
576
|
-
if (
|
|
575
|
+
function Ee(e, r, t) {
|
|
576
|
+
if (t.items.length === 0) {
|
|
577
|
+
e((s) => v(s, (o) => (o.roomsLoading = !1, o.messagesLoading = !1, o)));
|
|
577
578
|
return;
|
|
578
|
-
|
|
579
|
-
|
|
579
|
+
}
|
|
580
|
+
const n = t.items.map((s) => {
|
|
581
|
+
const o = r().messagesPublisher;
|
|
580
582
|
return o(s.value), s.value;
|
|
581
583
|
});
|
|
582
|
-
e((s) =>
|
|
583
|
-
const
|
|
584
|
-
(
|
|
584
|
+
e((s) => v(s, (o) => {
|
|
585
|
+
const c = s.rooms.filter(
|
|
586
|
+
(a) => a.collectionId !== n[0].collectionId
|
|
585
587
|
);
|
|
586
|
-
return o.rooms =
|
|
588
|
+
return o.rooms = c.concat(n), o.roomsLoading = !1, o;
|
|
587
589
|
}));
|
|
588
590
|
}
|
|
589
591
|
async function ne({
|
|
590
592
|
ditto: e,
|
|
591
|
-
currentUserId:
|
|
592
|
-
name:
|
|
593
|
+
currentUserId: r,
|
|
594
|
+
name: t,
|
|
593
595
|
collectionId: n,
|
|
594
596
|
messagesId: s,
|
|
595
597
|
participants: o = [],
|
|
596
|
-
retentionDays:
|
|
597
|
-
isGenerated:
|
|
598
|
-
id:
|
|
598
|
+
retentionDays: c,
|
|
599
|
+
isGenerated: a = !1,
|
|
600
|
+
id: y
|
|
599
601
|
}) {
|
|
600
602
|
if (e)
|
|
601
603
|
try {
|
|
602
604
|
const p = {
|
|
603
|
-
_id:
|
|
604
|
-
name:
|
|
605
|
+
_id: y || Ne(),
|
|
606
|
+
name: t,
|
|
605
607
|
messagesId: s,
|
|
606
608
|
collectionId: n,
|
|
607
|
-
isGenerated:
|
|
608
|
-
createdBy:
|
|
609
|
+
isGenerated: a,
|
|
610
|
+
createdBy: r,
|
|
609
611
|
createdOn: (/* @__PURE__ */ new Date()).toISOString(),
|
|
610
612
|
participants: o || void 0,
|
|
611
|
-
...
|
|
612
|
-
},
|
|
613
|
-
return await e.store.execute(
|
|
614
|
-
} catch (
|
|
615
|
-
console.error(`Error creating ${n}:`,
|
|
613
|
+
...c !== void 0 && { retentionDays: c }
|
|
614
|
+
}, O = `INSERT INTO \`${n}\` DOCUMENTS (:newDoc) ON ID CONFLICT DO UPDATE`;
|
|
615
|
+
return await e.store.execute(O, { newDoc: p }), p;
|
|
616
|
+
} catch (g) {
|
|
617
|
+
console.error(`Error creating ${n}:`, g);
|
|
616
618
|
}
|
|
617
619
|
}
|
|
618
|
-
const
|
|
620
|
+
const sr = (e, r, { ditto: t, userId: n }) => {
|
|
619
621
|
const s = {
|
|
620
622
|
rooms: [],
|
|
621
623
|
dmRooms: [],
|
|
@@ -658,18 +660,18 @@ const st = (e, t, { ditto: r, userId: n }) => {
|
|
|
658
660
|
* @param options.isGenerated - Optional flag to mark room as generated (hidden from main list)
|
|
659
661
|
* @returns Promise resolving to the created Room object, or undefined if permission denied
|
|
660
662
|
*/
|
|
661
|
-
createRoom(o,
|
|
662
|
-
if (!
|
|
663
|
+
createRoom(o, c) {
|
|
664
|
+
if (!r().canPerformAction("canCreateRoom"))
|
|
663
665
|
return console.warn("Permission denied: canCreateRoom is false"), Promise.resolve(void 0);
|
|
664
|
-
const
|
|
666
|
+
const a = r().currentUser;
|
|
665
667
|
return ne({
|
|
666
|
-
ditto:
|
|
667
|
-
currentUserId:
|
|
668
|
+
ditto: t,
|
|
669
|
+
currentUserId: a?._id || n,
|
|
668
670
|
name: o,
|
|
669
671
|
collectionId: "rooms",
|
|
670
672
|
messagesId: "messages",
|
|
671
|
-
retentionDays:
|
|
672
|
-
isGenerated:
|
|
673
|
+
retentionDays: c?.retentionDays,
|
|
674
|
+
isGenerated: c?.isGenerated ?? !1
|
|
673
675
|
});
|
|
674
676
|
},
|
|
675
677
|
/**
|
|
@@ -704,16 +706,16 @@ const st = (e, t, { ditto: r, userId: n }) => {
|
|
|
704
706
|
* @throws Error if either user ID is invalid or missing
|
|
705
707
|
*/
|
|
706
708
|
createDMRoom(o) {
|
|
707
|
-
const
|
|
708
|
-
if (!
|
|
709
|
+
const c = r().currentUser;
|
|
710
|
+
if (!c?._id || !o?._id)
|
|
709
711
|
throw Error("Invalid users");
|
|
710
712
|
return ne({
|
|
711
|
-
ditto:
|
|
712
|
-
currentUserId:
|
|
713
|
-
name: `${
|
|
713
|
+
ditto: t,
|
|
714
|
+
currentUserId: c?._id || n,
|
|
715
|
+
name: `${c?.name} & ${o.name}`,
|
|
714
716
|
collectionId: "dm_rooms",
|
|
715
717
|
messagesId: "dm_messages",
|
|
716
|
-
participants: [
|
|
718
|
+
participants: [c?._id, o._id]
|
|
717
719
|
});
|
|
718
720
|
},
|
|
719
721
|
/**
|
|
@@ -727,20 +729,20 @@ const st = (e, t, { ditto: r, userId: n }) => {
|
|
|
727
729
|
* @param name - Display name for the room
|
|
728
730
|
* @returns Promise resolving to the created Room object
|
|
729
731
|
*/
|
|
730
|
-
async createGeneratedRoom(o,
|
|
731
|
-
const
|
|
732
|
-
ditto:
|
|
733
|
-
currentUserId:
|
|
734
|
-
name:
|
|
732
|
+
async createGeneratedRoom(o, c) {
|
|
733
|
+
const a = r().currentUser, y = await ne({
|
|
734
|
+
ditto: t,
|
|
735
|
+
currentUserId: a?._id || n,
|
|
736
|
+
name: c,
|
|
735
737
|
collectionId: "rooms",
|
|
736
738
|
messagesId: "messages",
|
|
737
739
|
isGenerated: !0,
|
|
738
740
|
id: o
|
|
739
741
|
});
|
|
740
|
-
return
|
|
741
|
-
...
|
|
742
|
-
generatedRooms: [...
|
|
743
|
-
}),
|
|
742
|
+
return y && e((g) => g.generatedRooms.some((O) => O._id === y._id) ? g : {
|
|
743
|
+
...g,
|
|
744
|
+
generatedRooms: [...g.generatedRooms, y]
|
|
745
|
+
}), y;
|
|
744
746
|
},
|
|
745
747
|
/**
|
|
746
748
|
* Returns all public rooms, filtering out generated rooms.
|
|
@@ -751,22 +753,22 @@ const st = (e, t, { ditto: r, userId: n }) => {
|
|
|
751
753
|
* @returns Array of non-generated rooms
|
|
752
754
|
*/
|
|
753
755
|
getPublicRooms() {
|
|
754
|
-
return
|
|
756
|
+
return r().rooms.filter((o) => !o.isGenerated);
|
|
755
757
|
}
|
|
756
758
|
};
|
|
757
|
-
if (
|
|
758
|
-
const o = "SELECT * from rooms WHERE isGenerated = false OR isGenerated IS NULL",
|
|
759
|
-
s.roomsSubscription =
|
|
759
|
+
if (t) {
|
|
760
|
+
const o = "SELECT * from rooms WHERE isGenerated = false OR isGenerated IS NULL", c = "SELECT * from dm_rooms where (array_contains(participants, :userId))";
|
|
761
|
+
s.roomsSubscription = t.sync.registerSubscription(o), s.dmRoomsSubscription = t.sync.registerSubscription(c, {
|
|
760
762
|
userId: n
|
|
761
|
-
}), s.roomsObserver =
|
|
763
|
+
}), s.roomsObserver = t.store.registerObserver(
|
|
762
764
|
o,
|
|
763
|
-
(
|
|
764
|
-
Ee(e,
|
|
765
|
+
(a) => {
|
|
766
|
+
Ee(e, r, a);
|
|
765
767
|
}
|
|
766
|
-
), s.dmRoomsObserver =
|
|
767
|
-
|
|
768
|
-
(
|
|
769
|
-
Ee(e,
|
|
768
|
+
), s.dmRoomsObserver = t.store.registerObserver(
|
|
769
|
+
c,
|
|
770
|
+
(a) => {
|
|
771
|
+
Ee(e, r, a);
|
|
770
772
|
},
|
|
771
773
|
{
|
|
772
774
|
userId: n
|
|
@@ -775,59 +777,59 @@ const st = (e, t, { ditto: r, userId: n }) => {
|
|
|
775
777
|
}
|
|
776
778
|
return s;
|
|
777
779
|
}, Te = (e) => {
|
|
778
|
-
let
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
if (!Object.is(
|
|
782
|
-
const x =
|
|
783
|
-
|
|
780
|
+
let r;
|
|
781
|
+
const t = /* @__PURE__ */ new Set(), n = (g, p) => {
|
|
782
|
+
const O = typeof g == "function" ? g(r) : g;
|
|
783
|
+
if (!Object.is(O, r)) {
|
|
784
|
+
const x = r;
|
|
785
|
+
r = p ?? (typeof O != "object" || O === null) ? O : Object.assign({}, r, O), t.forEach((H) => H(r, x));
|
|
784
786
|
}
|
|
785
|
-
}, s = () =>
|
|
786
|
-
return
|
|
787
|
-
},
|
|
788
|
-
function xe(e,
|
|
789
|
-
const
|
|
787
|
+
}, s = () => r, a = { setState: n, getState: s, getInitialState: () => y, subscribe: (g) => (t.add(g), () => t.delete(g)) }, y = r = e(n, s, a);
|
|
788
|
+
return a;
|
|
789
|
+
}, or = ((e) => e ? Te(e) : Te), ir = (e) => e;
|
|
790
|
+
function xe(e, r = ir) {
|
|
791
|
+
const t = k.useSyncExternalStore(
|
|
790
792
|
e.subscribe,
|
|
791
|
-
k.useCallback(() =>
|
|
792
|
-
k.useCallback(() =>
|
|
793
|
+
k.useCallback(() => r(e.getState()), [e, r]),
|
|
794
|
+
k.useCallback(() => r(e.getInitialState()), [e, r])
|
|
793
795
|
);
|
|
794
|
-
return k.useDebugValue(
|
|
796
|
+
return k.useDebugValue(t), t;
|
|
795
797
|
}
|
|
796
|
-
const
|
|
798
|
+
const Oe = (e) => Symbol.iterator in e, Se = (e) => (
|
|
797
799
|
// HACK: avoid checking entries type
|
|
798
800
|
"entries" in e
|
|
799
|
-
), Re = (e,
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
801
|
+
), Re = (e, r) => {
|
|
802
|
+
const t = e instanceof Map ? e : new Map(e.entries()), n = r instanceof Map ? r : new Map(r.entries());
|
|
803
|
+
if (t.size !== n.size)
|
|
802
804
|
return !1;
|
|
803
|
-
for (const [s, o] of
|
|
805
|
+
for (const [s, o] of t)
|
|
804
806
|
if (!n.has(s) || !Object.is(o, n.get(s)))
|
|
805
807
|
return !1;
|
|
806
808
|
return !0;
|
|
807
|
-
},
|
|
808
|
-
const
|
|
809
|
-
let s =
|
|
809
|
+
}, cr = (e, r) => {
|
|
810
|
+
const t = e[Symbol.iterator](), n = r[Symbol.iterator]();
|
|
811
|
+
let s = t.next(), o = n.next();
|
|
810
812
|
for (; !s.done && !o.done; ) {
|
|
811
813
|
if (!Object.is(s.value, o.value))
|
|
812
814
|
return !1;
|
|
813
|
-
s =
|
|
815
|
+
s = t.next(), o = n.next();
|
|
814
816
|
}
|
|
815
817
|
return !!s.done && !!o.done;
|
|
816
818
|
};
|
|
817
|
-
function
|
|
818
|
-
return Object.is(e,
|
|
819
|
+
function ar(e, r) {
|
|
820
|
+
return Object.is(e, r) ? !0 : typeof e != "object" || e === null || typeof r != "object" || r === null || Object.getPrototypeOf(e) !== Object.getPrototypeOf(r) ? !1 : Oe(e) && Oe(r) ? Se(e) && Se(r) ? Re(e, r) : cr(e, r) : Re(
|
|
819
821
|
{ entries: () => Object.entries(e) },
|
|
820
|
-
{ entries: () => Object.entries(
|
|
822
|
+
{ entries: () => Object.entries(r) }
|
|
821
823
|
);
|
|
822
824
|
}
|
|
823
|
-
function
|
|
824
|
-
const
|
|
825
|
-
return (
|
|
826
|
-
const n = e(
|
|
827
|
-
return
|
|
825
|
+
function ur(e) {
|
|
826
|
+
const r = k.useRef(void 0);
|
|
827
|
+
return (t) => {
|
|
828
|
+
const n = e(t);
|
|
829
|
+
return ar(r.current, n) ? r.current : r.current = n;
|
|
828
830
|
};
|
|
829
831
|
}
|
|
830
|
-
const
|
|
832
|
+
const lr = (e, r, { ditto: t, userId: n, userCollectionKey: s }) => {
|
|
831
833
|
const o = {
|
|
832
834
|
usersLoading: !0,
|
|
833
835
|
currentUser: null,
|
|
@@ -849,15 +851,15 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
849
851
|
*
|
|
850
852
|
* @param user - User object (with optional _id for upsert)
|
|
851
853
|
*/
|
|
852
|
-
async addUser(
|
|
853
|
-
if (
|
|
854
|
+
async addUser(c) {
|
|
855
|
+
if (t)
|
|
854
856
|
try {
|
|
855
|
-
await
|
|
857
|
+
await t.store.execute(
|
|
856
858
|
`INSERT INTO ${s} DOCUMENTS (:newUser) ON ID CONFLICT DO UPDATE`,
|
|
857
|
-
{ newUser:
|
|
859
|
+
{ newUser: c }
|
|
858
860
|
);
|
|
859
|
-
} catch (
|
|
860
|
-
console.error("Error in addUser:",
|
|
861
|
+
} catch (a) {
|
|
862
|
+
console.error("Error in addUser:", a);
|
|
861
863
|
}
|
|
862
864
|
},
|
|
863
865
|
/**
|
|
@@ -874,19 +876,19 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
874
876
|
*
|
|
875
877
|
* @param params - Object with _id and fields to update
|
|
876
878
|
*/
|
|
877
|
-
async updateUser({ _id:
|
|
878
|
-
if (
|
|
879
|
+
async updateUser({ _id: c, ...a }) {
|
|
880
|
+
if (t && c)
|
|
879
881
|
try {
|
|
880
|
-
const
|
|
881
|
-
if (!
|
|
882
|
+
const y = await r().findUserById(c);
|
|
883
|
+
if (!y)
|
|
882
884
|
return;
|
|
883
|
-
const
|
|
884
|
-
await
|
|
885
|
+
const g = { ...y, ...a };
|
|
886
|
+
await t.store.execute(
|
|
885
887
|
`INSERT INTO ${s} DOCUMENTS (:newUser) ON ID CONFLICT DO UPDATE`,
|
|
886
|
-
{ newUser:
|
|
888
|
+
{ newUser: g }
|
|
887
889
|
);
|
|
888
|
-
} catch (
|
|
889
|
-
console.error("Error in updateUser:",
|
|
890
|
+
} catch (y) {
|
|
891
|
+
console.error("Error in updateUser:", y);
|
|
890
892
|
}
|
|
891
893
|
},
|
|
892
894
|
/**
|
|
@@ -902,16 +904,16 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
902
904
|
* @param userId - The unique identifier of the user
|
|
903
905
|
* @returns Promise resolving to ChatUser or null
|
|
904
906
|
*/
|
|
905
|
-
async findUserById(
|
|
906
|
-
if (!
|
|
907
|
+
async findUserById(c) {
|
|
908
|
+
if (!t)
|
|
907
909
|
return null;
|
|
908
910
|
try {
|
|
909
|
-
return (await
|
|
911
|
+
return (await t.store.execute(
|
|
910
912
|
`SELECT * FROM ${s} WHERE _id = :id`,
|
|
911
|
-
{ id:
|
|
913
|
+
{ id: c }
|
|
912
914
|
)).items?.[0]?.value;
|
|
913
|
-
} catch (
|
|
914
|
-
return console.error("Error in findUserById:",
|
|
915
|
+
} catch (a) {
|
|
916
|
+
return console.error("Error in findUserById:", a), null;
|
|
915
917
|
}
|
|
916
918
|
},
|
|
917
919
|
/**
|
|
@@ -929,21 +931,21 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
929
931
|
*
|
|
930
932
|
* @param roomId - ID of the room to mark as read
|
|
931
933
|
*/
|
|
932
|
-
async markRoomAsRead(
|
|
933
|
-
if (!(!
|
|
934
|
+
async markRoomAsRead(c) {
|
|
935
|
+
if (!(!t || !n))
|
|
934
936
|
try {
|
|
935
|
-
let
|
|
936
|
-
const
|
|
937
|
-
if (!
|
|
937
|
+
let a = !1;
|
|
938
|
+
const y = await r().findUserById(n);
|
|
939
|
+
if (!y)
|
|
938
940
|
return;
|
|
939
|
-
const
|
|
940
|
-
if (
|
|
941
|
-
const
|
|
942
|
-
|
|
941
|
+
const g = y.subscriptions || {}, p = y.mentions || {};
|
|
942
|
+
if (g[c]) {
|
|
943
|
+
const O = (/* @__PURE__ */ new Date()).toISOString();
|
|
944
|
+
g[c] = O, a = !0;
|
|
943
945
|
}
|
|
944
|
-
p[
|
|
945
|
-
} catch (
|
|
946
|
-
console.error("Error in markRoomAsRead:",
|
|
946
|
+
p[c] && (p[c] = [], a = !0), a && await r().updateUser({ _id: n, subscriptions: g, mentions: p });
|
|
947
|
+
} catch (a) {
|
|
948
|
+
console.error("Error in markRoomAsRead:", a);
|
|
947
949
|
}
|
|
948
950
|
},
|
|
949
951
|
/**
|
|
@@ -960,76 +962,76 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
960
962
|
*
|
|
961
963
|
* @param roomId - ID of the room to toggle subscription for
|
|
962
964
|
*/
|
|
963
|
-
async toggleRoomSubscription(
|
|
964
|
-
if (!(!
|
|
965
|
-
if (!
|
|
965
|
+
async toggleRoomSubscription(c) {
|
|
966
|
+
if (!(!t || !n)) {
|
|
967
|
+
if (!r().canPerformAction("canSubscribeToRoom")) {
|
|
966
968
|
console.warn("Permission denied: canSubscribeToRoom is false");
|
|
967
969
|
return;
|
|
968
970
|
}
|
|
969
971
|
try {
|
|
970
|
-
const
|
|
971
|
-
if (!
|
|
972
|
+
const a = await r().findUserById(n);
|
|
973
|
+
if (!a)
|
|
972
974
|
return;
|
|
973
|
-
const
|
|
974
|
-
if (
|
|
975
|
-
|
|
975
|
+
const y = { ...a.subscriptions };
|
|
976
|
+
if (c in y && y[c] !== null)
|
|
977
|
+
y[c] = null;
|
|
976
978
|
else {
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
+
const g = (/* @__PURE__ */ new Date()).toISOString();
|
|
980
|
+
y[c] = g;
|
|
979
981
|
}
|
|
980
|
-
await
|
|
982
|
+
await r().updateUser({
|
|
981
983
|
_id: n,
|
|
982
|
-
subscriptions:
|
|
984
|
+
subscriptions: y
|
|
983
985
|
});
|
|
984
|
-
} catch (
|
|
985
|
-
console.error("Error in toggleRoomSubscription:",
|
|
986
|
+
} catch (a) {
|
|
987
|
+
console.error("Error in toggleRoomSubscription:", a);
|
|
986
988
|
}
|
|
987
989
|
}
|
|
988
990
|
}
|
|
989
991
|
};
|
|
990
|
-
if (
|
|
991
|
-
const
|
|
992
|
-
o.userSubscription =
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
), o.userObserver =
|
|
996
|
-
a,
|
|
997
|
-
(y) => {
|
|
998
|
-
e({ currentUser: y.items?.[0]?.value });
|
|
999
|
-
},
|
|
1000
|
-
d
|
|
1001
|
-
), o.allUsersSubscription = r.sync.registerSubscription(c), o.allUsersObserver = r.store.registerObserver(
|
|
992
|
+
if (t) {
|
|
993
|
+
const c = `SELECT * FROM ${s} WHERE _id = :id`, a = `SELECT * FROM ${s}`, y = { id: n };
|
|
994
|
+
o.userSubscription = t.sync.registerSubscription(
|
|
995
|
+
c,
|
|
996
|
+
y
|
|
997
|
+
), o.userObserver = t.store.registerObserver(
|
|
1002
998
|
c,
|
|
1003
|
-
(
|
|
999
|
+
(g) => {
|
|
1000
|
+
e({ currentUser: g.items?.[0]?.value });
|
|
1001
|
+
},
|
|
1002
|
+
y
|
|
1003
|
+
), o.allUsersSubscription = t.sync.registerSubscription(a), o.allUsersObserver = t.store.registerObserver(
|
|
1004
|
+
a,
|
|
1005
|
+
(g) => {
|
|
1004
1006
|
e({
|
|
1005
|
-
allUsers:
|
|
1007
|
+
allUsers: g.items.map((p) => p.value),
|
|
1006
1008
|
usersLoading: !1
|
|
1007
1009
|
});
|
|
1008
1010
|
}
|
|
1009
1011
|
);
|
|
1010
1012
|
}
|
|
1011
1013
|
return o;
|
|
1012
|
-
}, Ie = 30,
|
|
1013
|
-
ditto:
|
|
1014
|
+
}, Ie = 30, fr = 1e4, G = 282, mr = (e, r, {
|
|
1015
|
+
ditto: t,
|
|
1014
1016
|
userId: n,
|
|
1015
1017
|
userCollectionKey: s,
|
|
1016
1018
|
retentionDays: o,
|
|
1017
|
-
notificationHandler:
|
|
1019
|
+
notificationHandler: c
|
|
1018
1020
|
}) => {
|
|
1019
|
-
const
|
|
1020
|
-
if (!
|
|
1021
|
+
const a = async (i) => {
|
|
1022
|
+
if (!t)
|
|
1021
1023
|
throw new Error("Ditto not initialized");
|
|
1022
|
-
const u = await
|
|
1024
|
+
const u = await t.store.execute(
|
|
1023
1025
|
`SELECT * FROM ${i.collectionId || "rooms"} WHERE _id = :id`,
|
|
1024
1026
|
{ id: i._id }
|
|
1025
1027
|
);
|
|
1026
1028
|
if (u.items.length === 0)
|
|
1027
1029
|
throw new Error("Room not found");
|
|
1028
1030
|
return u.items[0].value;
|
|
1029
|
-
},
|
|
1030
|
-
if (!
|
|
1031
|
+
}, y = async () => {
|
|
1032
|
+
if (!t || !n)
|
|
1031
1033
|
throw new Error("Ditto not initialized or user not found");
|
|
1032
|
-
const u = (await
|
|
1034
|
+
const u = (await t.store.execute(
|
|
1033
1035
|
`SELECT * FROM ${s} WHERE _id = :id`,
|
|
1034
1036
|
{ id: n }
|
|
1035
1037
|
)).items?.[0]?.value;
|
|
@@ -1037,43 +1039,43 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1037
1039
|
id: n,
|
|
1038
1040
|
name: u?.name ?? n
|
|
1039
1041
|
};
|
|
1040
|
-
},
|
|
1041
|
-
e((i) =>
|
|
1042
|
+
}, g = () => {
|
|
1043
|
+
e((i) => v(i, (u) => {
|
|
1042
1044
|
u.messagesLoading = !u.rooms.every(
|
|
1043
1045
|
(l) => l._id in u.messagesByRoom
|
|
1044
1046
|
);
|
|
1045
1047
|
}));
|
|
1046
|
-
}, p = (i, u, l,
|
|
1047
|
-
const
|
|
1048
|
+
}, p = (i, u, l, d) => {
|
|
1049
|
+
const f = {
|
|
1048
1050
|
message: l,
|
|
1049
|
-
user:
|
|
1051
|
+
user: d,
|
|
1050
1052
|
id: l._id
|
|
1051
|
-
},
|
|
1052
|
-
...
|
|
1053
|
-
message:
|
|
1054
|
-
user:
|
|
1053
|
+
}, m = {
|
|
1054
|
+
...f,
|
|
1055
|
+
message: f.message,
|
|
1056
|
+
user: f.user
|
|
1055
1057
|
}, b = i.findIndex((h) => h.id === l._id);
|
|
1056
|
-
if (b === -1 && !l.archivedMessage &&
|
|
1057
|
-
const _ =
|
|
1058
|
-
|
|
1058
|
+
if (b === -1 && !l.archivedMessage && O(l, u) && c && r().activeRoomId !== u._id) {
|
|
1059
|
+
const _ = d?.name || "Unknown User", w = u.name, D = u.collectionId === "dm_rooms" ? `New message from ${_}` : `#${w}: ${_}`, A = l.text ? l.text.substring(0, 30) + (l.text.length > 30 ? "..." : "") : "Sent an attachment";
|
|
1060
|
+
c(D, A);
|
|
1059
1061
|
}
|
|
1060
1062
|
if (l.archivedMessage) {
|
|
1061
1063
|
const h = i.findIndex(
|
|
1062
1064
|
(_) => _.id === l.archivedMessage
|
|
1063
1065
|
);
|
|
1064
|
-
h !== -1 ? i[h] =
|
|
1066
|
+
h !== -1 ? i[h] = m : b === -1 ? i.push(m) : i[b] = m;
|
|
1065
1067
|
} else
|
|
1066
|
-
b === -1 ? i.push(
|
|
1067
|
-
},
|
|
1068
|
-
const
|
|
1069
|
-
(w) => w.userId ===
|
|
1068
|
+
b === -1 ? i.push(m) : i[b] = m;
|
|
1069
|
+
}, O = (i, u) => {
|
|
1070
|
+
const d = r().currentUser, f = i.userId === d?._id, m = new Date(i.createdOn).getTime() > Date.now() - fr, b = d?.subscriptions?.[u._id], h = i.mentions?.some(
|
|
1071
|
+
(w) => w.userId === d?._id
|
|
1070
1072
|
), _ = u.collectionId === "dm_rooms";
|
|
1071
|
-
return !
|
|
1073
|
+
return !f && m && (b || _ || h);
|
|
1072
1074
|
}, x = async (i, u, l = "") => {
|
|
1073
|
-
if (!
|
|
1075
|
+
if (!t || !n)
|
|
1074
1076
|
throw new Error("Ditto not initialized or user not found");
|
|
1075
|
-
const
|
|
1076
|
-
_id:
|
|
1077
|
+
const d = await a(i), f = u._id || Ne(), m = {
|
|
1078
|
+
_id: f,
|
|
1077
1079
|
roomId: i._id,
|
|
1078
1080
|
userId: n,
|
|
1079
1081
|
createdOn: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1087,12 +1089,12 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1087
1089
|
...u,
|
|
1088
1090
|
mentions: u.mentions?.map((h) => ({ ...h })) || [],
|
|
1089
1091
|
reactions: u.reactions?.map((h) => ({ ...h })) || []
|
|
1090
|
-
}, b = l ? `COLLECTION ${
|
|
1091
|
-
if (await
|
|
1092
|
+
}, b = l ? `COLLECTION ${d.messagesId} ${l}` : d.messagesId;
|
|
1093
|
+
if (await t.store.execute(
|
|
1092
1094
|
`INSERT INTO ${b} DOCUMENTS (:newDoc) ON ID CONFLICT DO UPDATE`,
|
|
1093
|
-
{ newDoc:
|
|
1095
|
+
{ newDoc: m }
|
|
1094
1096
|
), u.mentions && u.mentions.length > 0) {
|
|
1095
|
-
const h =
|
|
1097
|
+
const h = r().allUsers;
|
|
1096
1098
|
await Promise.all(
|
|
1097
1099
|
u.mentions.map((_) => {
|
|
1098
1100
|
const w = h.find((D) => D._id === _.userId);
|
|
@@ -1100,20 +1102,20 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1100
1102
|
return;
|
|
1101
1103
|
const R = {
|
|
1102
1104
|
...w.mentions || {},
|
|
1103
|
-
[i._id]: [...w.mentions?.[i._id] || [],
|
|
1105
|
+
[i._id]: [...w.mentions?.[i._id] || [], f]
|
|
1104
1106
|
};
|
|
1105
|
-
return
|
|
1107
|
+
return t.store.execute(
|
|
1106
1108
|
"UPDATE users SET mentions = :mentions WHERE _id = :id",
|
|
1107
1109
|
{ id: w._id, mentions: R }
|
|
1108
1110
|
);
|
|
1109
1111
|
})
|
|
1110
1112
|
);
|
|
1111
1113
|
}
|
|
1112
|
-
return
|
|
1113
|
-
},
|
|
1114
|
-
if (!
|
|
1114
|
+
return m;
|
|
1115
|
+
}, H = async (i, u, l) => {
|
|
1116
|
+
if (!t)
|
|
1115
1117
|
throw new Error("Ditto not initialized");
|
|
1116
|
-
return await
|
|
1118
|
+
return await t.store.execute(
|
|
1117
1119
|
`UPDATE ${u.messagesId} SET isArchived = :isArchived WHERE _id = :id`,
|
|
1118
1120
|
{ id: i._id, isArchived: !0 }
|
|
1119
1121
|
), x(u, {
|
|
@@ -1122,38 +1124,38 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1122
1124
|
archivedMessage: i._id,
|
|
1123
1125
|
...l
|
|
1124
1126
|
});
|
|
1125
|
-
}, de = async (i, u, l,
|
|
1126
|
-
if (!
|
|
1127
|
+
}, de = async (i, u, l, d) => {
|
|
1128
|
+
if (!t || !n)
|
|
1127
1129
|
throw new Error("Ditto not initialized or user not found");
|
|
1128
|
-
const
|
|
1130
|
+
const f = await y(), m = {
|
|
1129
1131
|
thumbnailImageToken: null,
|
|
1130
1132
|
largeImageToken: null,
|
|
1131
1133
|
fileAttachmentToken: null
|
|
1132
1134
|
};
|
|
1133
|
-
if (
|
|
1134
|
-
const h = await
|
|
1135
|
-
|
|
1135
|
+
if (d === "image") {
|
|
1136
|
+
const h = await dr(u), _ = await De(h), w = new Uint8Array(await _.arrayBuffer());
|
|
1137
|
+
m.thumbnailImageToken = await t.store.newAttachment(
|
|
1136
1138
|
w,
|
|
1137
|
-
se(
|
|
1139
|
+
se(f.id, f.name, "thumbnail", u)
|
|
1138
1140
|
);
|
|
1139
1141
|
const R = await De(await ke(u)), D = new Uint8Array(await R.arrayBuffer());
|
|
1140
|
-
|
|
1142
|
+
m.largeImageToken = await t.store.newAttachment(
|
|
1141
1143
|
D,
|
|
1142
|
-
se(
|
|
1144
|
+
se(f.id, f.name, "large", u)
|
|
1143
1145
|
);
|
|
1144
1146
|
} else {
|
|
1145
1147
|
const h = new Uint8Array(await u.arrayBuffer());
|
|
1146
|
-
|
|
1148
|
+
m.fileAttachmentToken = await t.store.newAttachment(
|
|
1147
1149
|
h,
|
|
1148
|
-
se(
|
|
1150
|
+
se(f.id, f.name, "file", u)
|
|
1149
1151
|
);
|
|
1150
1152
|
}
|
|
1151
|
-
const b =
|
|
1153
|
+
const b = d === "image" ? "(thumbnailImageToken ATTACHMENT, largeImageToken ATTACHMENT)" : "(fileAttachmentToken ATTACHMENT)";
|
|
1152
1154
|
await x(
|
|
1153
1155
|
i,
|
|
1154
1156
|
{
|
|
1155
|
-
text: l || (
|
|
1156
|
-
...
|
|
1157
|
+
text: l || (d === "file" ? u.name : ""),
|
|
1158
|
+
...m
|
|
1157
1159
|
},
|
|
1158
1160
|
b
|
|
1159
1161
|
);
|
|
@@ -1194,42 +1196,42 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1194
1196
|
* @param retentionDays - Optional override for message retention period
|
|
1195
1197
|
*/
|
|
1196
1198
|
async messagesPublisher(i, u) {
|
|
1197
|
-
if (!
|
|
1199
|
+
if (!t)
|
|
1198
1200
|
return;
|
|
1199
1201
|
const l = i._id;
|
|
1200
|
-
if (
|
|
1202
|
+
if (r().messageSubscriptionsByRoom[l])
|
|
1201
1203
|
return;
|
|
1202
|
-
const
|
|
1203
|
-
Date.now() -
|
|
1204
|
-
),
|
|
1204
|
+
const d = u ?? i.retentionDays ?? o ?? Ie, f = new Date(
|
|
1205
|
+
Date.now() - d * 24 * 60 * 60 * 1e3
|
|
1206
|
+
), m = `SELECT * FROM COLLECTION ${i.messagesId} (thumbnailImageToken ATTACHMENT, largeImageToken ATTACHMENT, fileAttachmentToken ATTACHMENT)
|
|
1205
1207
|
WHERE roomId = :roomId AND createdOn >= :date AND isArchived = false
|
|
1206
1208
|
ORDER BY createdOn ASC`, b = {
|
|
1207
1209
|
roomId: i._id,
|
|
1208
|
-
date:
|
|
1210
|
+
date: f.toISOString()
|
|
1209
1211
|
};
|
|
1210
1212
|
try {
|
|
1211
|
-
const h =
|
|
1212
|
-
|
|
1213
|
+
const h = t.sync.registerSubscription(m, b), _ = r().allUsers, w = t.store.registerObserver(
|
|
1214
|
+
m,
|
|
1213
1215
|
async (R) => {
|
|
1214
|
-
e((D) =>
|
|
1216
|
+
e((D) => v(D, (A) => {
|
|
1215
1217
|
if (A.messagesByRoom[i._id] || (A.messagesByRoom[i._id] = []), R.items.length === 0)
|
|
1216
1218
|
return A;
|
|
1217
|
-
for (const
|
|
1218
|
-
const $ =
|
|
1219
|
+
for (const M of R.items) {
|
|
1220
|
+
const $ = M.value, j = A.messagesByRoom[i._id], J = _.find((K) => K._id === $.userId);
|
|
1219
1221
|
p(j, i, $, J);
|
|
1220
1222
|
}
|
|
1221
1223
|
return A;
|
|
1222
|
-
})),
|
|
1224
|
+
})), g();
|
|
1223
1225
|
},
|
|
1224
1226
|
b
|
|
1225
1227
|
);
|
|
1226
1228
|
e({
|
|
1227
1229
|
messageSubscriptionsByRoom: {
|
|
1228
|
-
...
|
|
1230
|
+
...r().messageSubscriptionsByRoom,
|
|
1229
1231
|
[l]: h
|
|
1230
1232
|
},
|
|
1231
1233
|
messageObserversByRoom: {
|
|
1232
|
-
...
|
|
1234
|
+
...r().messageObserversByRoom,
|
|
1233
1235
|
[l]: w
|
|
1234
1236
|
}
|
|
1235
1237
|
});
|
|
@@ -1257,19 +1259,19 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1257
1259
|
* @param retentionDays - Optional message retention override
|
|
1258
1260
|
*/
|
|
1259
1261
|
async subscribeToRoomMessages(i, u, l) {
|
|
1260
|
-
if (!
|
|
1262
|
+
if (!t || r().messageSubscriptionsByRoom[i])
|
|
1261
1263
|
return;
|
|
1262
|
-
const
|
|
1263
|
-
Date.now() -
|
|
1264
|
-
),
|
|
1264
|
+
const d = l ?? o ?? Ie, f = new Date(
|
|
1265
|
+
Date.now() - d * 24 * 60 * 60 * 1e3
|
|
1266
|
+
), m = `SELECT * FROM COLLECTION ${u} (thumbnailImageToken ATTACHMENT, largeImageToken ATTACHMENT, fileAttachmentToken ATTACHMENT)
|
|
1265
1267
|
WHERE roomId = :roomId AND createdOn >= :date AND isArchived = false
|
|
1266
1268
|
ORDER BY createdOn ASC`, b = {
|
|
1267
1269
|
roomId: i,
|
|
1268
|
-
date:
|
|
1270
|
+
date: f.toISOString()
|
|
1269
1271
|
};
|
|
1270
1272
|
try {
|
|
1271
|
-
const h =
|
|
1272
|
-
|
|
1273
|
+
const h = t.sync.registerSubscription(m, b), _ = r().allUsers, w = t.store.registerObserver(
|
|
1274
|
+
m,
|
|
1273
1275
|
async (R) => {
|
|
1274
1276
|
const D = {
|
|
1275
1277
|
_id: i,
|
|
@@ -1280,25 +1282,25 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1280
1282
|
createdOn: "",
|
|
1281
1283
|
isGenerated: !0
|
|
1282
1284
|
};
|
|
1283
|
-
e((A) =>
|
|
1284
|
-
if (
|
|
1285
|
-
return
|
|
1285
|
+
e((A) => v(A, (M) => {
|
|
1286
|
+
if (M.messagesByRoom[i] || (M.messagesByRoom[i] = []), R.items.length === 0)
|
|
1287
|
+
return M;
|
|
1286
1288
|
for (const $ of R.items) {
|
|
1287
|
-
const j = $.value, J =
|
|
1289
|
+
const j = $.value, J = M.messagesByRoom[i], K = _.find((Be) => Be._id === j.userId);
|
|
1288
1290
|
p(J, D, j, K);
|
|
1289
1291
|
}
|
|
1290
|
-
return
|
|
1291
|
-
})),
|
|
1292
|
+
return M;
|
|
1293
|
+
})), g();
|
|
1292
1294
|
},
|
|
1293
1295
|
b
|
|
1294
1296
|
);
|
|
1295
1297
|
e({
|
|
1296
1298
|
messageSubscriptionsByRoom: {
|
|
1297
|
-
...
|
|
1299
|
+
...r().messageSubscriptionsByRoom,
|
|
1298
1300
|
[i]: h
|
|
1299
1301
|
},
|
|
1300
1302
|
messageObserversByRoom: {
|
|
1301
|
-
...
|
|
1303
|
+
...r().messageObserversByRoom,
|
|
1302
1304
|
[i]: w
|
|
1303
1305
|
}
|
|
1304
1306
|
});
|
|
@@ -1324,8 +1326,8 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1324
1326
|
* @param roomId - Room ID to unsubscribe from
|
|
1325
1327
|
*/
|
|
1326
1328
|
unsubscribeFromRoomMessages(i) {
|
|
1327
|
-
const u =
|
|
1328
|
-
u && !u.isCancelled && u.cancel(), l && !l.isCancelled && l.cancel(), e((
|
|
1329
|
+
const u = r().messageSubscriptionsByRoom[i], l = r().messageObserversByRoom[i];
|
|
1330
|
+
u && !u.isCancelled && u.cancel(), l && !l.isCancelled && l.cancel(), e((d) => v(d, (f) => (delete f.messagesByRoom[i], delete f.messageSubscriptionsByRoom[i], delete f.messageObserversByRoom[i], f)));
|
|
1329
1331
|
},
|
|
1330
1332
|
/**
|
|
1331
1333
|
* Create a new text message in a room.
|
|
@@ -1344,17 +1346,17 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1344
1346
|
* @param mentions - Optional array of user mentions
|
|
1345
1347
|
*/
|
|
1346
1348
|
async createMessage(i, u, l = []) {
|
|
1347
|
-
if (!
|
|
1349
|
+
if (!t || !n)
|
|
1348
1350
|
return;
|
|
1349
|
-
const
|
|
1350
|
-
l.length > 0 && !
|
|
1351
|
+
const d = r().canPerformAction("canMentionUsers"), f = l.length > 0 && !d ? [] : l;
|
|
1352
|
+
l.length > 0 && !d && console.warn("Permission denied: canMentionUsers is false");
|
|
1351
1353
|
try {
|
|
1352
1354
|
await x(i, {
|
|
1353
1355
|
text: u,
|
|
1354
|
-
mentions:
|
|
1356
|
+
mentions: f
|
|
1355
1357
|
});
|
|
1356
|
-
} catch (
|
|
1357
|
-
console.error("Error in createMessage:",
|
|
1358
|
+
} catch (m) {
|
|
1359
|
+
console.error("Error in createMessage:", m);
|
|
1358
1360
|
}
|
|
1359
1361
|
},
|
|
1360
1362
|
/**
|
|
@@ -1373,12 +1375,12 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1373
1375
|
* @param room - Room containing the message
|
|
1374
1376
|
*/
|
|
1375
1377
|
async saveEditedTextMessage(i, u) {
|
|
1376
|
-
if (!
|
|
1378
|
+
if (!r().canPerformAction("canEditOwnMessage")) {
|
|
1377
1379
|
console.warn("Permission denied: canEditOwnMessage is false");
|
|
1378
1380
|
return;
|
|
1379
1381
|
}
|
|
1380
1382
|
try {
|
|
1381
|
-
await
|
|
1383
|
+
await H(i, u, {
|
|
1382
1384
|
text: i.text,
|
|
1383
1385
|
largeImageToken: i.largeImageToken || null,
|
|
1384
1386
|
thumbnailImageToken: i.thumbnailImageToken || null,
|
|
@@ -1409,18 +1411,18 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1409
1411
|
* @param type - Type of content: 'text', 'image', or 'file'
|
|
1410
1412
|
*/
|
|
1411
1413
|
async saveDeletedMessage(i, u, l = "text") {
|
|
1412
|
-
if (!
|
|
1414
|
+
if (!r().canPerformAction("canDeleteOwnMessage")) {
|
|
1413
1415
|
console.warn("Permission denied: canDeleteOwnMessage is false");
|
|
1414
1416
|
return;
|
|
1415
1417
|
}
|
|
1416
|
-
const
|
|
1418
|
+
const d = {
|
|
1417
1419
|
text: "[deleted message]",
|
|
1418
1420
|
image: "[deleted image]",
|
|
1419
1421
|
file: "[deleted file]"
|
|
1420
1422
|
}[l];
|
|
1421
1423
|
try {
|
|
1422
|
-
await
|
|
1423
|
-
text:
|
|
1424
|
+
await H(i, u, {
|
|
1425
|
+
text: d,
|
|
1424
1426
|
createdOn: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1425
1427
|
largeImageToken: null,
|
|
1426
1428
|
thumbnailImageToken: null,
|
|
@@ -1429,8 +1431,8 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1429
1431
|
isDeleted: !0,
|
|
1430
1432
|
mentions: []
|
|
1431
1433
|
});
|
|
1432
|
-
} catch (
|
|
1433
|
-
console.error("Error in saveDeletedMessage:",
|
|
1434
|
+
} catch (f) {
|
|
1435
|
+
console.error("Error in saveDeletedMessage:", f);
|
|
1434
1436
|
}
|
|
1435
1437
|
},
|
|
1436
1438
|
/**
|
|
@@ -1451,8 +1453,8 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1451
1453
|
async createImageMessage(i, u, l) {
|
|
1452
1454
|
try {
|
|
1453
1455
|
await de(i, u, l, "image");
|
|
1454
|
-
} catch (
|
|
1455
|
-
console.error("Error in createImageMessage:",
|
|
1456
|
+
} catch (d) {
|
|
1457
|
+
console.error("Error in createImageMessage:", d);
|
|
1456
1458
|
}
|
|
1457
1459
|
},
|
|
1458
1460
|
/**
|
|
@@ -1473,8 +1475,8 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1473
1475
|
async createFileMessage(i, u, l) {
|
|
1474
1476
|
try {
|
|
1475
1477
|
await de(i, u, l, "file");
|
|
1476
|
-
} catch (
|
|
1477
|
-
console.error("Error in createFileMessage:",
|
|
1478
|
+
} catch (d) {
|
|
1479
|
+
console.error("Error in createFileMessage:", d);
|
|
1478
1480
|
}
|
|
1479
1481
|
},
|
|
1480
1482
|
/**
|
|
@@ -1493,9 +1495,10 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1493
1495
|
* @param token - Attachment token from message
|
|
1494
1496
|
* @param onProgress - Callback receiving progress (0-1)
|
|
1495
1497
|
* @param onComplete - Callback receiving AttachmentResult
|
|
1498
|
+
* @returns The fetcher object from the SDK for cleanup
|
|
1496
1499
|
*/
|
|
1497
1500
|
fetchAttachment(i, u, l) {
|
|
1498
|
-
if (!
|
|
1501
|
+
if (!t) {
|
|
1499
1502
|
l({
|
|
1500
1503
|
success: !1,
|
|
1501
1504
|
error: new Error("Ditto not initialized")
|
|
@@ -1510,7 +1513,7 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1510
1513
|
return;
|
|
1511
1514
|
}
|
|
1512
1515
|
try {
|
|
1513
|
-
|
|
1516
|
+
return t.store.fetchAttachment(i, async (f) => {
|
|
1514
1517
|
switch (f.type) {
|
|
1515
1518
|
case "Progress": {
|
|
1516
1519
|
const m = Number(f.downloadedBytes) / (Number(f.totalBytes) || 1);
|
|
@@ -1519,10 +1522,10 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1519
1522
|
}
|
|
1520
1523
|
case "Completed":
|
|
1521
1524
|
try {
|
|
1522
|
-
const m = f.attachment.getData(),
|
|
1525
|
+
const m = f.attachment.getData(), b = m instanceof Promise ? await m : m;
|
|
1523
1526
|
l({
|
|
1524
1527
|
success: !0,
|
|
1525
|
-
data:
|
|
1528
|
+
data: b,
|
|
1526
1529
|
metadata: f.attachment.metadata || {}
|
|
1527
1530
|
});
|
|
1528
1531
|
} catch (m) {
|
|
@@ -1540,11 +1543,11 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1540
1543
|
break;
|
|
1541
1544
|
}
|
|
1542
1545
|
});
|
|
1543
|
-
} catch (
|
|
1544
|
-
l({
|
|
1546
|
+
} catch (d) {
|
|
1547
|
+
return l({
|
|
1545
1548
|
success: !1,
|
|
1546
|
-
error:
|
|
1547
|
-
});
|
|
1549
|
+
error: d instanceof Error ? d : new Error("Failed to fetch attachment")
|
|
1550
|
+
}), null;
|
|
1548
1551
|
}
|
|
1549
1552
|
},
|
|
1550
1553
|
/**
|
|
@@ -1574,26 +1577,26 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1574
1577
|
* @param reactions - The new array of reactions to apply
|
|
1575
1578
|
*/
|
|
1576
1579
|
async updateMessageReactions(i, u, l) {
|
|
1577
|
-
if (!
|
|
1580
|
+
if (!t || !n)
|
|
1578
1581
|
return;
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1582
|
+
const d = u._id, f = r().messagesByRoom[d] || [], m = f.findIndex((_) => _.id === i._id);
|
|
1583
|
+
if (m === -1)
|
|
1581
1584
|
throw new Error("Message not found");
|
|
1582
|
-
const b = m
|
|
1585
|
+
const b = f[m].message, h = b.reactions || [];
|
|
1583
1586
|
e(
|
|
1584
|
-
(_) =>
|
|
1585
|
-
w.messagesByRoom[
|
|
1587
|
+
(_) => v(_, (w) => {
|
|
1588
|
+
w.messagesByRoom[d][m].message.reactions = l;
|
|
1586
1589
|
})
|
|
1587
1590
|
), setTimeout(async () => {
|
|
1588
1591
|
try {
|
|
1589
|
-
await
|
|
1592
|
+
await t.store.execute(
|
|
1590
1593
|
`UPDATE ${u.messagesId} SET reactions = :reactions WHERE _id = :id`,
|
|
1591
1594
|
{ id: b._id, reactions: l }
|
|
1592
1595
|
);
|
|
1593
1596
|
} catch (_) {
|
|
1594
1597
|
console.error("Error updating reactions, rolling back:", _), e(
|
|
1595
|
-
(w) =>
|
|
1596
|
-
R.messagesByRoom[
|
|
1598
|
+
(w) => v(w, (R) => {
|
|
1599
|
+
R.messagesByRoom[d][m].message.reactions = h;
|
|
1597
1600
|
})
|
|
1598
1601
|
);
|
|
1599
1602
|
}
|
|
@@ -1616,17 +1619,17 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1616
1619
|
* @param reaction - Reaction object with emoji and userId
|
|
1617
1620
|
*/
|
|
1618
1621
|
async addReactionToMessage(i, u, l) {
|
|
1619
|
-
if (!
|
|
1622
|
+
if (!t || !n)
|
|
1620
1623
|
return;
|
|
1621
|
-
if (!
|
|
1624
|
+
if (!r().canPerformAction("canAddReaction")) {
|
|
1622
1625
|
console.warn("Permission denied: canAddReaction is false");
|
|
1623
1626
|
return;
|
|
1624
1627
|
}
|
|
1625
|
-
const
|
|
1626
|
-
if (
|
|
1628
|
+
const d = r().messagesByRoom[u._id], f = d.findIndex((h) => h.id === i._id);
|
|
1629
|
+
if (f === -1)
|
|
1627
1630
|
throw new Error("Message not found");
|
|
1628
|
-
const
|
|
1629
|
-
await
|
|
1631
|
+
const m = d[f].message, b = [...m.reactions || [], l];
|
|
1632
|
+
await r().updateMessageReactions(m, u, b);
|
|
1630
1633
|
},
|
|
1631
1634
|
/**
|
|
1632
1635
|
* Remove a reaction from a message.
|
|
@@ -1645,43 +1648,43 @@ const lt = (e, t, { ditto: r, userId: n, userCollectionKey: s }) => {
|
|
|
1645
1648
|
* @param reaction - Reaction to remove (matched by emoji and userId)
|
|
1646
1649
|
*/
|
|
1647
1650
|
async removeReactionFromMessage(i, u, l) {
|
|
1648
|
-
if (!
|
|
1651
|
+
if (!t || !n)
|
|
1649
1652
|
return;
|
|
1650
|
-
if (!
|
|
1653
|
+
if (!r().canPerformAction("canRemoveOwnReaction")) {
|
|
1651
1654
|
console.warn("Permission denied: canRemoveOwnReaction is false");
|
|
1652
1655
|
return;
|
|
1653
1656
|
}
|
|
1654
|
-
const
|
|
1655
|
-
if (
|
|
1657
|
+
const d = r().messagesByRoom[u._id], f = d.findIndex((h) => h.id === i._id);
|
|
1658
|
+
if (f === -1)
|
|
1656
1659
|
throw new Error("Message not found");
|
|
1657
|
-
const
|
|
1660
|
+
const m = d[f].message, b = (m.reactions || []).filter(
|
|
1658
1661
|
(h) => !(h.emoji === l.emoji && h.userId === l.userId)
|
|
1659
1662
|
);
|
|
1660
|
-
await
|
|
1663
|
+
await r().updateMessageReactions(m, u, b);
|
|
1661
1664
|
}
|
|
1662
1665
|
};
|
|
1663
1666
|
};
|
|
1664
|
-
async function
|
|
1665
|
-
const
|
|
1667
|
+
async function dr(e) {
|
|
1668
|
+
const r = await ke(e), t = document.createElement("canvas"), n = t.getContext("2d");
|
|
1666
1669
|
if (!n)
|
|
1667
1670
|
throw new Error("Failed to get 2D context");
|
|
1668
|
-
let { width: s, height: o } =
|
|
1669
|
-
return s > o ? (o = G / s * o, s = G) : (s = G / o * s, o = G),
|
|
1671
|
+
let { width: s, height: o } = r;
|
|
1672
|
+
return s > o ? (o = G / s * o, s = G) : (s = G / o * s, o = G), t.width = s, t.height = o, n.drawImage(r, 0, 0, s, o), t;
|
|
1670
1673
|
}
|
|
1671
1674
|
function ke(e) {
|
|
1672
|
-
return new Promise((
|
|
1675
|
+
return new Promise((r, t) => {
|
|
1673
1676
|
const n = new FileReader();
|
|
1674
1677
|
n.onload = (s) => {
|
|
1675
1678
|
const o = new Image();
|
|
1676
|
-
o.onload = () =>
|
|
1677
|
-
}, n.onerror =
|
|
1679
|
+
o.onload = () => r(o), o.onerror = t, o.src = String(s.target?.result);
|
|
1680
|
+
}, n.onerror = t, n.readAsDataURL(e);
|
|
1678
1681
|
});
|
|
1679
1682
|
}
|
|
1680
1683
|
async function De(e) {
|
|
1681
|
-
return new Promise((
|
|
1684
|
+
return new Promise((r, t) => {
|
|
1682
1685
|
const n = (s) => {
|
|
1683
1686
|
s.toBlob(
|
|
1684
|
-
(o) => o ?
|
|
1687
|
+
(o) => o ? r(o) : t(new Error("Failed to convert to blob")),
|
|
1685
1688
|
"image/jpeg",
|
|
1686
1689
|
1
|
|
1687
1690
|
);
|
|
@@ -1693,20 +1696,20 @@ async function De(e) {
|
|
|
1693
1696
|
s.width = e.width, s.height = e.height;
|
|
1694
1697
|
const o = s.getContext("2d");
|
|
1695
1698
|
if (!o) {
|
|
1696
|
-
|
|
1699
|
+
t(new Error("Failed to get 2D context"));
|
|
1697
1700
|
return;
|
|
1698
1701
|
}
|
|
1699
1702
|
o.drawImage(e, 0, 0), n(s);
|
|
1700
1703
|
}
|
|
1701
1704
|
});
|
|
1702
1705
|
}
|
|
1703
|
-
function se(e,
|
|
1704
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), o =
|
|
1706
|
+
function se(e, r, t, n) {
|
|
1707
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), o = r.replace(/\s/g, "-"), c = s.replace(/:/g, "-"), a = t === "file" ? n.name.split(".").pop() || "bin" : "jpg";
|
|
1705
1708
|
return {
|
|
1706
|
-
filename: `${o}_${
|
|
1709
|
+
filename: `${o}_${t}_${c}.${a}`,
|
|
1707
1710
|
userId: e,
|
|
1708
|
-
username:
|
|
1709
|
-
fileformat: `.${
|
|
1711
|
+
username: r,
|
|
1712
|
+
fileformat: `.${a}`,
|
|
1710
1713
|
filesize: n.size.toString(),
|
|
1711
1714
|
timestamp: s,
|
|
1712
1715
|
originalName: n.name
|
|
@@ -1715,15 +1718,15 @@ function se(e, t, r, n) {
|
|
|
1715
1718
|
function I(e) {
|
|
1716
1719
|
e && !e.isCancelled && e.cancel();
|
|
1717
1720
|
}
|
|
1718
|
-
function
|
|
1719
|
-
const
|
|
1720
|
-
(
|
|
1721
|
-
...
|
|
1722
|
-
...
|
|
1723
|
-
...
|
|
1724
|
-
...
|
|
1721
|
+
function hr(e) {
|
|
1722
|
+
const r = Fe(() => (globalThis.__DITTO_CHAT_STORE__ || (globalThis.__DITTO_CHAT_STORE__ = or()(
|
|
1723
|
+
(t, n) => ({
|
|
1724
|
+
...sr(t, n, e),
|
|
1725
|
+
...lr(t, n, e),
|
|
1726
|
+
...mr(t, n, e),
|
|
1727
|
+
...Le(t, n, e),
|
|
1725
1728
|
activeRoomId: null,
|
|
1726
|
-
setActiveRoomId: (s) =>
|
|
1729
|
+
setActiveRoomId: (s) => t({ activeRoomId: s }),
|
|
1727
1730
|
chatLogout: () => {
|
|
1728
1731
|
const s = n();
|
|
1729
1732
|
I(s.roomsSubscription), I(s.roomsObserver), I(s.dmRoomsSubscription), I(s.dmRoomsObserver), Object.values(s.messageSubscriptionsByRoom || {}).map(
|
|
@@ -1734,31 +1737,31 @@ function ht(e) {
|
|
|
1734
1737
|
}
|
|
1735
1738
|
})
|
|
1736
1739
|
)), globalThis.__DITTO_CHAT_STORE__), [e]);
|
|
1737
|
-
return xe(
|
|
1740
|
+
return xe(r);
|
|
1738
1741
|
}
|
|
1739
|
-
function
|
|
1742
|
+
function br(e) {
|
|
1740
1743
|
if (!globalThis.__DITTO_CHAT_STORE__)
|
|
1741
1744
|
throw new Error(
|
|
1742
1745
|
"chatStore must be initialized before useDittoChatStore. use useDittoChat for initialization"
|
|
1743
1746
|
);
|
|
1744
|
-
const
|
|
1747
|
+
const r = ur(
|
|
1745
1748
|
e || ((n) => n)
|
|
1746
1749
|
);
|
|
1747
|
-
return xe(globalThis.__DITTO_CHAT_STORE__,
|
|
1750
|
+
return xe(globalThis.__DITTO_CHAT_STORE__, r);
|
|
1748
1751
|
}
|
|
1749
|
-
function
|
|
1752
|
+
function _r() {
|
|
1750
1753
|
return globalThis.__DITTO_CHAT_STORE__;
|
|
1751
1754
|
}
|
|
1752
|
-
function
|
|
1755
|
+
function wr() {
|
|
1753
1756
|
globalThis.__DITTO_CHAT_STORE__ = void 0;
|
|
1754
1757
|
}
|
|
1755
1758
|
export {
|
|
1756
1759
|
ze as DEFAULT_PERMISSIONS,
|
|
1757
1760
|
I as cancelSubscriptionOrObserver,
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1761
|
+
Le as createRBACSlice,
|
|
1762
|
+
sr as createRoomSlice,
|
|
1763
|
+
_r as getChatStore,
|
|
1764
|
+
wr as resetChatStore,
|
|
1765
|
+
hr as useDittoChat,
|
|
1766
|
+
br as useDittoChatStore
|
|
1764
1767
|
};
|