@fkn/lib 0.9.54 → 0.9.55
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/account.d.ts +1 -1
- package/{api-C-VvG5P-.d.ts → api-BSpQkgnM.d.ts} +361 -25
- package/api.d.ts +2 -2
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/net.d.ts +1 -1
- package/{cloud-S8hQywqV.d.ts → cloud-BslRIoKs.d.ts} +2 -2
- package/cloud.d.ts +3 -3
- package/{contract-CMQOic3K.d.ts → contract-DFycgFJK.d.ts} +131 -8
- package/contract.d.ts +2 -2
- package/dgram.d.ts +2 -2
- package/dns.d.ts +1 -1
- package/http.d.ts +1 -1
- package/index.d.ts +2 -2
- package/{net-B8YQuB9E.d.ts → net-eEjhJ0AE.d.ts} +2 -2
- package/net.d.ts +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-ClDBa5il.d.ts → proxy-8hIHeEHD.d.ts} +2 -2
- package/rooms.cjs +1 -1
- package/rooms.d.ts +43 -9
- package/rooms.js +153 -91
- package/storage.d.ts +1 -1
package/rooms.js
CHANGED
|
@@ -4,10 +4,10 @@ import { t as i } from "./busy-DsMWrSzc.js";
|
|
|
4
4
|
import { ROOM_TEMPORARY_MS as a } from "./contract.js";
|
|
5
5
|
//#region src/rooms.ts
|
|
6
6
|
var o = /* @__PURE__ */ e({
|
|
7
|
-
available: () =>
|
|
8
|
-
create: () =>
|
|
9
|
-
join: () =>
|
|
10
|
-
open: () =>
|
|
7
|
+
available: () => w,
|
|
8
|
+
create: () => D,
|
|
9
|
+
join: () => O,
|
|
10
|
+
open: () => E
|
|
11
11
|
}), s = {
|
|
12
12
|
wrongKey: "rooms: wrong room key",
|
|
13
13
|
inviteNoKey: "rooms: the invite carries no key",
|
|
@@ -43,6 +43,14 @@ var o = /* @__PURE__ */ e({
|
|
|
43
43
|
temporaryUnavailable: "rooms: temporary claims are not available",
|
|
44
44
|
mailboxUnavailable: "rooms: the mailbox switch is not available",
|
|
45
45
|
guestUnavailable: "rooms: guest joins are not available",
|
|
46
|
+
schemasUnavailable: "rooms: room schemas are not available",
|
|
47
|
+
badSchema: "rooms: the schema is not one a room can take",
|
|
48
|
+
newerSchema: "rooms: the room holds a newer schema",
|
|
49
|
+
noSchema: "rooms: the room has no schema",
|
|
50
|
+
misfit: "rooms: the message does not fit the room's schema",
|
|
51
|
+
ownerSends: "rooms: only the owner sends this type",
|
|
52
|
+
accountSends: "rooms: sending this needs an account",
|
|
53
|
+
perAccount: "rooms: you have as many of these here as the room allows",
|
|
46
54
|
tooFast: "rooms: sending too fast",
|
|
47
55
|
tooLarge: "rooms: the message is too large",
|
|
48
56
|
unavailable: "rooms: rooms are unavailable",
|
|
@@ -55,95 +63,131 @@ var o = /* @__PURE__ */ e({
|
|
|
55
63
|
send: !0,
|
|
56
64
|
receive: !0,
|
|
57
65
|
maxMessageBytes: 262144
|
|
58
|
-
}, d = () => ({
|
|
66
|
+
}, d = 2048, f = () => ({
|
|
59
67
|
messages: 0,
|
|
60
68
|
bytes: 0,
|
|
61
69
|
cap: 5e8,
|
|
62
70
|
archived: !1
|
|
63
|
-
}),
|
|
71
|
+
}), p = async () => {
|
|
64
72
|
if (!t) return;
|
|
65
73
|
let e = (await n("a room").catch(() => void 0))?.rooms;
|
|
66
74
|
return typeof e?.open == "function" ? e : void 0;
|
|
67
|
-
},
|
|
75
|
+
}, m = () => {
|
|
68
76
|
throw c("unavailable", s.unavailable);
|
|
69
|
-
},
|
|
77
|
+
}, h = (e) => e === "blocked" ? "blocked" : e === "not-found" ? "ended" : "unavailable", g = (e) => {
|
|
70
78
|
if (e !== void 0 && e !== !1) return e === !0 ? a.default : typeof e != "number" || !Number.isInteger(e) ? null : e >= a.min && e <= a.max ? e : null;
|
|
71
|
-
},
|
|
79
|
+
}, _ = (e, t) => {
|
|
72
80
|
let n = t ? e?.guest : e;
|
|
73
81
|
return typeof n?.join == "function" ? n : void 0;
|
|
74
|
-
},
|
|
82
|
+
}, v = (e) => {
|
|
83
|
+
let t;
|
|
84
|
+
try {
|
|
85
|
+
t = JSON.stringify(e);
|
|
86
|
+
} catch {}
|
|
87
|
+
let n = t === void 0 ? void 0 : JSON.parse(t), r = typeof n == "object" && !!n && !Array.isArray(n) && typeof n.type == "string";
|
|
88
|
+
if (t === void 0 || !r || t.length > d) throw c("invalid", s.misfit);
|
|
89
|
+
return t;
|
|
90
|
+
}, y = (e) => {
|
|
91
|
+
let t;
|
|
92
|
+
try {
|
|
93
|
+
t = JSON.parse(JSON.stringify(e));
|
|
94
|
+
} catch {}
|
|
95
|
+
if (typeof t != "object" || !t || Array.isArray(t)) throw c("invalid", s.badSchema);
|
|
96
|
+
return t;
|
|
97
|
+
}, b = (e) => e?.schema === void 0 ? e : {
|
|
98
|
+
...e,
|
|
99
|
+
schema: y(e.schema)
|
|
100
|
+
}, x = (e) => {
|
|
101
|
+
if (e.schemas !== !0) throw c("unavailable", s.schemasUnavailable);
|
|
102
|
+
return e;
|
|
103
|
+
}, S = (e) => {
|
|
75
104
|
let t = e?.guest;
|
|
76
105
|
if (t !== void 0 && typeof t != "boolean") throw c("invalid", s.malformed);
|
|
77
106
|
return t === !0;
|
|
78
|
-
},
|
|
79
|
-
let n = e.invite, a = e, o = 0,
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
let t = [...
|
|
83
|
-
|
|
107
|
+
}, C = async (e, t) => {
|
|
108
|
+
let n = e.invite, a = e, o = 0, d = e.self, p = e.owner, m = e.claimed, b = e.mailbox, S = 0, C = await e.defaults().catch(() => u), w = e.schemas === !0 ? await Promise.resolve(e.schema()).catch(() => null) : null, T = 0, E = !1, D = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), k = i("room"), A = () => {}, j = () => {}, M = new Promise((e) => {
|
|
109
|
+
j = e;
|
|
110
|
+
}), N = (e) => {
|
|
111
|
+
let t = [...O];
|
|
112
|
+
O.clear();
|
|
84
113
|
for (let n of t) try {
|
|
85
114
|
n(e);
|
|
86
115
|
} catch {}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
if (
|
|
116
|
+
}, P = (e) => {
|
|
117
|
+
E || (E = !0, A(), D.clear(), k(), N(c("closed", s.ended)), j({ reason: e }));
|
|
118
|
+
}, F = (e) => {
|
|
119
|
+
if (E) return;
|
|
91
120
|
let t = e;
|
|
92
|
-
if (t.type === "defaults" && (
|
|
93
|
-
|
|
121
|
+
if (t.type === "defaults" && (C = t.defaults), t.type === "schema" && (T += 1, w = t.schema), t.type === "message" || t.type === "edited") {
|
|
122
|
+
let e = {
|
|
123
|
+
...t.message,
|
|
124
|
+
envelope: t.message.envelope ?? null
|
|
125
|
+
};
|
|
126
|
+
t = t.type === "message" ? {
|
|
127
|
+
...t,
|
|
128
|
+
message: e
|
|
129
|
+
} : {
|
|
130
|
+
type: "edited",
|
|
131
|
+
message: e
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (t.type === "permissions" && t.id === d.id && (d = {
|
|
135
|
+
id: d.id,
|
|
94
136
|
permissions: t.permissions,
|
|
95
137
|
maxMessageBytes: t.maxMessageBytes
|
|
96
138
|
}), t.type === "claim") {
|
|
97
|
-
|
|
139
|
+
S += 1;
|
|
98
140
|
let e = t.claimed && t.mailbox !== !1;
|
|
99
141
|
t = {
|
|
100
142
|
type: "claim",
|
|
101
143
|
claimed: t.claimed,
|
|
102
144
|
owner: t.owner,
|
|
103
145
|
mailbox: e
|
|
104
|
-
},
|
|
146
|
+
}, m = t.claimed, p = t.owner, b = e ? f() : null;
|
|
105
147
|
}
|
|
106
|
-
for (let e of [...
|
|
148
|
+
for (let e of [...D]) try {
|
|
107
149
|
e(t);
|
|
108
150
|
} catch {}
|
|
109
|
-
},
|
|
110
|
-
Promise.resolve(e.on(
|
|
111
|
-
t === o &&
|
|
151
|
+
}, I = (e, t) => {
|
|
152
|
+
Promise.resolve(e.on(F)).catch(() => {}), Promise.resolve(e.closed).then((e) => {
|
|
153
|
+
t === o && P(e.reason);
|
|
112
154
|
}, () => {});
|
|
113
|
-
},
|
|
114
|
-
let i =
|
|
115
|
-
if (!i) return
|
|
155
|
+
}, L = async (e, r) => {
|
|
156
|
+
let i = _(e, t);
|
|
157
|
+
if (!i) return P("unavailable");
|
|
116
158
|
let s = await i.join(n).catch(() => void 0);
|
|
117
|
-
if (
|
|
118
|
-
if (!s) return
|
|
119
|
-
if ("error" in s) return
|
|
120
|
-
if (s.self.id !==
|
|
121
|
-
a = s,
|
|
159
|
+
if (E || r !== o) return;
|
|
160
|
+
if (!s) return P("unavailable");
|
|
161
|
+
if ("error" in s) return P(h(s.error));
|
|
162
|
+
if (s.self.id !== d.id) return Promise.resolve(s.leave()).catch(() => {}), P("unavailable");
|
|
163
|
+
a = s, d = s.self, p = s.owner, m = s.claimed, b = s.mailbox, I(s, r);
|
|
122
164
|
let c = await s.defaults().catch(() => void 0);
|
|
123
|
-
c && !
|
|
165
|
+
if (c && !E && r === o && (C = c), s.schemas !== !0) return;
|
|
166
|
+
let l = await Promise.resolve(s.schema()).catch(() => void 0);
|
|
167
|
+
l !== void 0 && !E && r === o && (w = l);
|
|
124
168
|
};
|
|
125
|
-
|
|
169
|
+
A = r((e, t) => {
|
|
126
170
|
let n = o;
|
|
127
|
-
o = t, !(
|
|
128
|
-
}),
|
|
129
|
-
let
|
|
130
|
-
if (
|
|
171
|
+
o = t, !(E || n === 0 || n === t) && (N(c("unavailable", s.unavailable)), L(e.rooms, t));
|
|
172
|
+
}), I(e, o);
|
|
173
|
+
let R = async (e) => {
|
|
174
|
+
if (E) throw c("closed", s.ended);
|
|
131
175
|
let t = () => {}, n = new Promise((e, n) => {
|
|
132
176
|
t = n;
|
|
133
177
|
});
|
|
134
|
-
|
|
178
|
+
O.add(t);
|
|
135
179
|
try {
|
|
136
180
|
return await Promise.race([Promise.resolve(e(a)), n]);
|
|
137
181
|
} catch (e) {
|
|
138
182
|
throw l(e) ? e : c("unavailable", s.unavailable);
|
|
139
183
|
} finally {
|
|
140
|
-
|
|
184
|
+
O.delete(t);
|
|
141
185
|
}
|
|
142
|
-
},
|
|
143
|
-
let t = await
|
|
186
|
+
}, z = async (e) => {
|
|
187
|
+
let t = await R(e);
|
|
144
188
|
if ("error" in t) throw c(t.error, t.message);
|
|
145
|
-
},
|
|
146
|
-
let t = await
|
|
189
|
+
}, B = async (e) => {
|
|
190
|
+
let t = await R(e);
|
|
147
191
|
if (typeof t == "object" && t && "error" in t) throw c(t.error, t.message);
|
|
148
192
|
return t;
|
|
149
193
|
};
|
|
@@ -153,34 +197,47 @@ var o = /* @__PURE__ */ e({
|
|
|
153
197
|
key: e.key,
|
|
154
198
|
invite: n,
|
|
155
199
|
get self() {
|
|
156
|
-
return
|
|
200
|
+
return d;
|
|
157
201
|
},
|
|
158
202
|
get owner() {
|
|
159
203
|
return p;
|
|
160
204
|
},
|
|
161
205
|
get claimed() {
|
|
162
|
-
return
|
|
206
|
+
return m;
|
|
163
207
|
},
|
|
164
208
|
get mailbox() {
|
|
165
|
-
return
|
|
209
|
+
return b;
|
|
210
|
+
},
|
|
211
|
+
defaults: () => C,
|
|
212
|
+
members: () => R((e) => e.members()),
|
|
213
|
+
schema: () => w,
|
|
214
|
+
send: async (e, t) => {
|
|
215
|
+
if (t === void 0) return z((t) => t.send(e));
|
|
216
|
+
let n = v(t);
|
|
217
|
+
return z((t) => x(t).send(e, n));
|
|
218
|
+
},
|
|
219
|
+
edit: async (e, t, n) => {
|
|
220
|
+
if (n === void 0) return z((n) => n.edit(e, t));
|
|
221
|
+
let r = v(n);
|
|
222
|
+
return z((n) => x(n).edit(e, t, r));
|
|
223
|
+
},
|
|
224
|
+
setSchema: async (e) => {
|
|
225
|
+
let t = y(e), n = T;
|
|
226
|
+
await z((e) => x(e).setSchema(t)), T === n && (w = t);
|
|
166
227
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
revoke: (e, t) => P((n) => n.revoke(e, t)),
|
|
177
|
-
remove: (e) => P((t) => t.remove(e)),
|
|
178
|
-
block: (e) => P((t) => t.block(e)),
|
|
179
|
-
unblock: (e) => P((t) => t.unblock(e)),
|
|
228
|
+
delete: (e, t) => z((n) => n.delete(e, t)),
|
|
229
|
+
backlog: (e, t) => B((n) => n.backlog(e, t)),
|
|
230
|
+
setDefault: (e, t) => z((n) => n.setDefault(e, t)),
|
|
231
|
+
limit: (e, t) => z((n) => n.limit(e, t)),
|
|
232
|
+
grant: (e, t) => z((n) => n.grant(e, t)),
|
|
233
|
+
revoke: (e, t) => z((n) => n.revoke(e, t)),
|
|
234
|
+
remove: (e) => z((t) => t.remove(e)),
|
|
235
|
+
block: (e) => z((t) => t.block(e)),
|
|
236
|
+
unblock: (e) => z((t) => t.unblock(e)),
|
|
180
237
|
claim: async (e) => {
|
|
181
238
|
let t = e?.description;
|
|
182
239
|
if (t !== void 0 && typeof t != "string") throw c("invalid", s.badDescription);
|
|
183
|
-
let n =
|
|
240
|
+
let n = g(e?.temporary);
|
|
184
241
|
if (n === null) throw c("invalid", s.badTemporary);
|
|
185
242
|
let r = e?.mailbox;
|
|
186
243
|
if (r !== void 0 && typeof r != "boolean") throw c("invalid", s.malformed);
|
|
@@ -189,7 +246,7 @@ var o = /* @__PURE__ */ e({
|
|
|
189
246
|
...n === void 0 ? {} : { temporary: n },
|
|
190
247
|
...r === void 0 ? {} : { mailbox: r }
|
|
191
248
|
};
|
|
192
|
-
return Object.keys(i).length === 0 ?
|
|
249
|
+
return Object.keys(i).length === 0 ? z((e) => e.claim()) : z((e) => {
|
|
193
250
|
if (n !== void 0 && e.temporaryClaims !== !0) throw c("unavailable", s.temporaryUnavailable);
|
|
194
251
|
if (r === !1 && e.mailboxSwitch !== !0) throw c("unavailable", s.mailboxUnavailable);
|
|
195
252
|
return e.claim(i);
|
|
@@ -197,43 +254,48 @@ var o = /* @__PURE__ */ e({
|
|
|
197
254
|
},
|
|
198
255
|
setMailbox: async (e) => {
|
|
199
256
|
if (typeof e != "boolean") throw c("invalid", s.malformed);
|
|
200
|
-
let t =
|
|
201
|
-
await
|
|
257
|
+
let t = S;
|
|
258
|
+
await z((t) => {
|
|
202
259
|
if (t.mailboxSwitch !== !0) throw c("unavailable", s.mailboxUnavailable);
|
|
203
260
|
return t.setMailbox(e);
|
|
204
|
-
}),
|
|
261
|
+
}), S === t && (e ? b === null && (b = f()) : b = null);
|
|
205
262
|
},
|
|
206
|
-
release: () =>
|
|
263
|
+
release: () => z((e) => e.release()),
|
|
207
264
|
usage: async () => {
|
|
208
|
-
let e = await
|
|
209
|
-
return
|
|
265
|
+
let e = await B((e) => e.usage());
|
|
266
|
+
return b = e, e;
|
|
210
267
|
},
|
|
211
|
-
on: async (e) =>
|
|
212
|
-
|
|
268
|
+
on: async (e) => E ? () => {} : (D.add(e), () => {
|
|
269
|
+
D.delete(e);
|
|
213
270
|
}),
|
|
214
271
|
leave: async () => {
|
|
215
|
-
await Promise.resolve(a.leave()).catch(() => {}),
|
|
272
|
+
await Promise.resolve(a.leave()).catch(() => {}), P("left");
|
|
216
273
|
},
|
|
217
|
-
closed:
|
|
274
|
+
closed: M
|
|
218
275
|
};
|
|
219
|
-
},
|
|
220
|
-
let e = await
|
|
276
|
+
}, w = async () => {
|
|
277
|
+
let e = await p();
|
|
221
278
|
return e ? e.available().catch(() => !1) : !1;
|
|
222
|
-
},
|
|
223
|
-
let
|
|
224
|
-
if (!
|
|
225
|
-
let
|
|
226
|
-
if (!
|
|
227
|
-
let
|
|
228
|
-
if ("error" in
|
|
229
|
-
|
|
230
|
-
|
|
279
|
+
}, T = async (e, t, n) => {
|
|
280
|
+
let r = await p();
|
|
281
|
+
if (!r) throw c("unavailable", s.unavailable);
|
|
282
|
+
let i = _(r, e);
|
|
283
|
+
if (!i) throw c("unavailable", s.guestUnavailable);
|
|
284
|
+
let a = await n(i).catch(m);
|
|
285
|
+
if ("error" in a) throw c(a.error, a.message);
|
|
286
|
+
if (t?.schema !== void 0 && a.schemas !== !0) throw await Promise.resolve(a.leave()).catch(() => {}), c("unavailable", s.schemasUnavailable);
|
|
287
|
+
return C(a, e);
|
|
288
|
+
}, E = async (e, t) => {
|
|
231
289
|
if (typeof e != "string" || e.length === 0 || e.length > 72) throw c("invalid", s.badName);
|
|
232
|
-
|
|
233
|
-
|
|
290
|
+
let n = S(t), r = b(t);
|
|
291
|
+
return T(n, r, (t) => t.open(e, r));
|
|
292
|
+
}, D = async (e) => {
|
|
293
|
+
let t = S(e), n = b(e);
|
|
294
|
+
return T(t, n, (e) => e.create(n));
|
|
295
|
+
}, O = async (e, t) => {
|
|
234
296
|
let n = typeof e == "string" ? e.indexOf(".") : -1;
|
|
235
297
|
if (n <= 0 || n === e.length - 1) throw c("invalid", s.inviteNoKey);
|
|
236
|
-
return
|
|
298
|
+
return T(S(t), void 0, (n) => n.join(e, t));
|
|
237
299
|
};
|
|
238
300
|
//#endregion
|
|
239
|
-
export {
|
|
301
|
+
export { w as available, D as create, O as join, E as open, o as t };
|
package/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as StorageProgress, Mt as StoredObject, Nt as StoredPage, Ot as StoragePutOptions, Tt as StorageErrorCode } from "./contract-DFycgFJK.js";
|
|
2
2
|
declare namespace storage_d_exports {
|
|
3
3
|
export { StorageError, StorageErrorCode, StorageProgress, StoragePutOptions, StoredBlob, StoredObject, StoredPage, available, remove as delete, get, list, put };
|
|
4
4
|
}
|