@protobase/client 0.60.0 → 0.60.1
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/channels.js +22 -4
- package/package.json +3 -3
package/dist/channels.js
CHANGED
|
@@ -23,13 +23,25 @@ const channelsClient = (options) => {
|
|
|
23
23
|
const entries = [...channel.presence.values()];
|
|
24
24
|
for (const listener of channel.presenceListeners) listener(entries, change);
|
|
25
25
|
};
|
|
26
|
+
const forget = (id) => {
|
|
27
|
+
joined.delete(id);
|
|
28
|
+
if (joined.size === 0) connection.stop();
|
|
29
|
+
};
|
|
26
30
|
const join = (channel) => {
|
|
31
|
+
const id = `${channel.resource}/${channel.key}`;
|
|
27
32
|
connection.request({
|
|
28
33
|
type: "join",
|
|
29
34
|
resource: channel.resource,
|
|
30
35
|
key: channel.key
|
|
31
36
|
}).then((reply) => {
|
|
32
|
-
if (joined.get(
|
|
37
|
+
if (joined.get(id) !== channel) return;
|
|
38
|
+
if (channel.holders === 0) {
|
|
39
|
+
connection.post({
|
|
40
|
+
type: "leave",
|
|
41
|
+
channel: reply.channel
|
|
42
|
+
});
|
|
43
|
+
return forget(id);
|
|
44
|
+
}
|
|
33
45
|
channel.name = reply.channel;
|
|
34
46
|
byName.set(channel.name, channel);
|
|
35
47
|
setStatus(channel, { state: "joined" });
|
|
@@ -39,6 +51,7 @@ const channelsClient = (options) => {
|
|
|
39
51
|
state: channel.tracked.state
|
|
40
52
|
}).catch(unlessDropped);
|
|
41
53
|
}).catch((error) => {
|
|
54
|
+
if (joined.get(id) === channel && channel.holders === 0 && error instanceof ChannelRefusal) return forget(id);
|
|
42
55
|
if (!(error instanceof ChannelRefusal) || error.code === "disconnected") return unlessDropped(error);
|
|
43
56
|
setStatus(channel, {
|
|
44
57
|
state: "refused",
|
|
@@ -87,7 +100,11 @@ const channelsClient = (options) => {
|
|
|
87
100
|
const connection = channelConnection({
|
|
88
101
|
...options,
|
|
89
102
|
onOpen: () => {
|
|
90
|
-
for (const channel of joined
|
|
103
|
+
for (const [id, channel] of joined) {
|
|
104
|
+
if (channel.status.state !== "joining") continue;
|
|
105
|
+
if (channel.holders === 0) forget(id);
|
|
106
|
+
else join(channel);
|
|
107
|
+
}
|
|
91
108
|
},
|
|
92
109
|
onDown: () => {
|
|
93
110
|
byName.clear();
|
|
@@ -98,7 +115,8 @@ const channelsClient = (options) => {
|
|
|
98
115
|
const release = (id, channel) => {
|
|
99
116
|
channel.holders -= 1;
|
|
100
117
|
if (channel.holders > 0) return;
|
|
101
|
-
|
|
118
|
+
channel.tracked = void 0;
|
|
119
|
+
if (channel.status.state === "joining") return;
|
|
102
120
|
if (channel.name !== void 0) {
|
|
103
121
|
byName.delete(channel.name);
|
|
104
122
|
connection.post({
|
|
@@ -106,7 +124,7 @@ const channelsClient = (options) => {
|
|
|
106
124
|
channel: channel.name
|
|
107
125
|
});
|
|
108
126
|
}
|
|
109
|
-
|
|
127
|
+
forget(id);
|
|
110
128
|
};
|
|
111
129
|
const handleOf = (id, channel) => {
|
|
112
130
|
let left = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/client",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.1",
|
|
4
4
|
"description": "Typed fetch client for the Protobase REST API.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@better-auth/passkey": "^1.7.12",
|
|
34
|
-
"@protobase/layout": "0.60.
|
|
35
|
-
"@protobase/schema": "0.60.
|
|
34
|
+
"@protobase/layout": "0.60.1",
|
|
35
|
+
"@protobase/schema": "0.60.1",
|
|
36
36
|
"@simplewebauthn/browser": "^13.3.0",
|
|
37
37
|
"better-auth": "^1.7.12"
|
|
38
38
|
}
|