@poolse/sdk 2.0.3 → 2.0.5
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.cjs +34 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -2
- package/dist/index.d.ts +51 -2
- package/dist/index.js +34 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,26 +4,16 @@ var phoenix = require('phoenix');
|
|
|
4
4
|
|
|
5
5
|
// src/uuid.ts
|
|
6
6
|
function safeUuid() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
c.getRandomValues(bytes);
|
|
16
|
-
return formatV4(bytes);
|
|
7
|
+
const c = globalThis.crypto;
|
|
8
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
9
|
+
const bytes = new Uint8Array(16);
|
|
10
|
+
if (c?.getRandomValues) {
|
|
11
|
+
c.getRandomValues(bytes);
|
|
12
|
+
} else {
|
|
13
|
+
for (let i = 0; i < 16; i++) {
|
|
14
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
17
15
|
}
|
|
18
|
-
} catch {
|
|
19
16
|
}
|
|
20
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch) => {
|
|
21
|
-
const r = Math.random() * 16 | 0;
|
|
22
|
-
const v = ch === "x" ? r : r & 3 | 8;
|
|
23
|
-
return v.toString(16);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function formatV4(bytes) {
|
|
27
17
|
bytes[6] = bytes[6] & 15 | 64;
|
|
28
18
|
bytes[8] = bytes[8] & 63 | 128;
|
|
29
19
|
const hex = [];
|
|
@@ -368,8 +358,10 @@ var UserChannel = class {
|
|
|
368
358
|
channel;
|
|
369
359
|
mentionListeners = /* @__PURE__ */ new Set();
|
|
370
360
|
conversationCreatedListeners = /* @__PURE__ */ new Set();
|
|
361
|
+
conversationUpdatedListeners = /* @__PURE__ */ new Set();
|
|
371
362
|
mentionBound = false;
|
|
372
363
|
conversationCreatedBound = false;
|
|
364
|
+
conversationUpdatedBound = false;
|
|
373
365
|
constructor(userId, channel) {
|
|
374
366
|
this.userId = userId;
|
|
375
367
|
this.channel = channel;
|
|
@@ -406,6 +398,28 @@ var UserChannel = class {
|
|
|
406
398
|
this.conversationCreatedListeners.delete(fn);
|
|
407
399
|
};
|
|
408
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Subscribe to "an existing conversation changed" notifications —
|
|
403
|
+
* fires after every `send_message` in any conversation you're a
|
|
404
|
+
* member of. Use this to update the conversation-list row's last
|
|
405
|
+
* message preview, timestamp, and unread badge without polling.
|
|
406
|
+
*
|
|
407
|
+
* Compare `evt.by_user_id` to your own user id to decide whether
|
|
408
|
+
* to increment a local unread counter; the server already keeps
|
|
409
|
+
* your own outbound messages out of your unread count.
|
|
410
|
+
*/
|
|
411
|
+
onConversationUpdated(fn) {
|
|
412
|
+
if (!this.conversationUpdatedBound) {
|
|
413
|
+
this.conversationUpdatedBound = true;
|
|
414
|
+
this.channel.on("conversation:updated", (payload) => {
|
|
415
|
+
this.conversationUpdatedListeners.forEach((l) => l(payload));
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
this.conversationUpdatedListeners.add(fn);
|
|
419
|
+
return () => {
|
|
420
|
+
this.conversationUpdatedListeners.delete(fn);
|
|
421
|
+
};
|
|
422
|
+
}
|
|
409
423
|
/** @internal */
|
|
410
424
|
_join() {
|
|
411
425
|
this.channel.join();
|
|
@@ -414,6 +428,7 @@ var UserChannel = class {
|
|
|
414
428
|
_destroy() {
|
|
415
429
|
this.mentionListeners.clear();
|
|
416
430
|
this.conversationCreatedListeners.clear();
|
|
431
|
+
this.conversationUpdatedListeners.clear();
|
|
417
432
|
this.channel.leave();
|
|
418
433
|
}
|
|
419
434
|
};
|
|
@@ -1191,7 +1206,7 @@ var Poolse = class {
|
|
|
1191
1206
|
};
|
|
1192
1207
|
|
|
1193
1208
|
// src/version.ts
|
|
1194
|
-
var version = "2.0.
|
|
1209
|
+
var version = "2.0.2";
|
|
1195
1210
|
|
|
1196
1211
|
exports.ApiError = ApiError;
|
|
1197
1212
|
exports.AttachmentHandle = AttachmentHandle;
|