@fkn/lib 0.9.52 → 0.9.54
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-generation-BZ_gXQoZ.js → account-generation-CTB1J33G.js} +4 -3
- package/account-generation-DOuApHq5.cjs +1 -0
- package/{account-storage-BT2pPuWs.cjs → account-storage-CL0wLuQw.cjs} +1 -1
- package/{account-storage-DHl6bXdb.d.ts → account-storage-Co9IvkPr.d.ts} +3 -3
- package/{account-storage-C38Ydzh-.js → account-storage-D1RiskV6.js} +2 -2
- package/account.cjs +1 -1
- package/account.d.ts +21 -11
- package/account.js +2 -2
- package/{api-BrqGe-Yz.js → api-BYtMzj8u.js} +43 -63
- package/{api-eOIMGYAJ.d.ts → api-C-VvG5P-.d.ts} +833 -1
- package/api-Csb5b8dE.cjs +3 -0
- package/api.cjs +1 -1
- package/api.d.ts +2 -2
- package/api.js +1 -1
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +2 -2
- package/cloud/fs.js +1 -1
- package/cloud/net.d.ts +1 -1
- package/{cloud-DyXqlXh9.js → cloud-8sJ1Sg8n.js} +3 -3
- package/{cloud-CCMu_LZl.cjs → cloud-CI6WMBPa.cjs} +1 -1
- package/{cloud-DrgnsG8_.d.ts → cloud-S8hQywqV.d.ts} +3 -3
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +2 -2
- package/{contract-De1rQSCD.d.ts → contract-CMQOic3K.d.ts} +34 -4
- package/contract.d.ts +1 -1
- package/dgram.cjs +1 -1
- package/dgram.d.ts +2 -2
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.d.ts +1 -1
- package/dns.js +1 -1
- package/{extension-D-MgH488.cjs → extension-BXI3MVXw.cjs} +1 -1
- package/{extension-Cqd8OFr3.js → extension-BmqjgSIQ.js} +3 -3
- package/extension.cjs +1 -1
- package/extension.js +2 -2
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/{fs-BUf_-umC.cjs → fs-CPU00CI3.cjs} +1 -1
- package/{fs-BZv2djbS.d.ts → fs-DCJAYoYy.d.ts} +1 -1
- package/{fs-BaZ7k_5D.js → fs-ohcMNiu2.js} +2 -2
- package/fs.cjs +1 -1
- package/fs.d.ts +2 -2
- package/fs.js +2 -2
- package/http.d.ts +1 -1
- package/{index-DawD_N1P.d.ts → index-57lTXnoe.d.ts} +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +4 -4
- package/index.js +5 -5
- package/{lib-ERmfLvVp.js → lib-BGAmzIcU.js} +1 -23
- package/{lib-B3BXMegM.cjs → lib-BiQ6cOZ7.cjs} +1 -1
- package/{net-2q-K92j1.d.ts → net-B8YQuB9E.d.ts} +2 -2
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.d.ts +15 -2
- package/packages.js +114 -113
- package/{proxy-CKNx2dKf.cjs → proxy-CL8j00ao.cjs} +1 -1
- package/{proxy-CjxVIiz2.d.ts → proxy-ClDBa5il.d.ts} +2 -2
- package/{proxy-Bwr-0XVF.js → proxy-vAsYHMIa.js} +1 -1
- package/rooms.cjs +1 -1
- package/rooms.d.ts +11 -11
- package/rooms.js +99 -89
- package/storage.cjs +1 -1
- package/storage.d.ts +1 -1
- package/storage.js +3 -3
- package/account-generation-D8wbg2Lb.cjs +0 -1
- package/api-2ecr7axy.cjs +0 -3
package/packages.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { c as t, l as n, o as r, u as i } from "./api-
|
|
2
|
+
import { c as t, l as n, o as r, u as i } from "./api-BYtMzj8u.js";
|
|
3
3
|
import { i as a, t as o } from "./busy-DsMWrSzc.js";
|
|
4
4
|
import { expose as s } from "osra";
|
|
5
5
|
//#region src/packages.ts
|
|
6
6
|
var c = /* @__PURE__ */ e({
|
|
7
|
-
attach: () =>
|
|
8
|
-
connect: () =>
|
|
9
|
-
hide: () =>
|
|
10
|
-
install: () =>
|
|
11
|
-
isVisible: () =>
|
|
12
|
-
list: () =>
|
|
13
|
-
mount: () =>
|
|
14
|
-
onConnect: () =>
|
|
15
|
-
onVisibilityChange: () =>
|
|
16
|
-
pick: () =>
|
|
17
|
-
search: () =>
|
|
18
|
-
show: () =>
|
|
19
|
-
uninstall: () =>
|
|
20
|
-
}), l = "fkn-packages-connection", u =
|
|
21
|
-
if (!n) throw
|
|
7
|
+
attach: () => I,
|
|
8
|
+
connect: () => A,
|
|
9
|
+
hide: () => k,
|
|
10
|
+
install: () => v,
|
|
11
|
+
isVisible: () => X,
|
|
12
|
+
list: () => y,
|
|
13
|
+
mount: () => F,
|
|
14
|
+
onConnect: () => Y,
|
|
15
|
+
onVisibilityChange: () => Z,
|
|
16
|
+
pick: () => _,
|
|
17
|
+
search: () => g,
|
|
18
|
+
show: () => O,
|
|
19
|
+
uninstall: () => b
|
|
20
|
+
}), l = "fkn-packages-connection", u = "https://fkn.app", d = 3e4, f = (e, t) => Object.assign(Error(t), { code: e }), p = async () => {
|
|
21
|
+
if (!n) throw f("unavailable", "packages: no FKN transport in this realm - use relayWorker to bridge workers");
|
|
22
22
|
return r;
|
|
23
|
-
},
|
|
23
|
+
}, m = (e, t, n) => s(e ?? {}, {
|
|
24
24
|
transport: t,
|
|
25
25
|
key: l,
|
|
26
26
|
unregisterSignal: n
|
|
27
|
-
}),
|
|
27
|
+
}), h = async (e, t, n = {}) => {
|
|
28
28
|
let { signal: r, closed: i } = n;
|
|
29
|
-
if (r?.aborted) throw
|
|
29
|
+
if (r?.aborted) throw f("unavailable", "packages.connect: aborted before connecting");
|
|
30
30
|
let a = new AbortController();
|
|
31
31
|
r && r.addEventListener("abort", () => a.abort(r.reason), { once: !0 });
|
|
32
32
|
let o = new AbortController(), s = new Promise((e, n) => {
|
|
33
|
-
let a = setTimeout(() => n(
|
|
33
|
+
let a = setTimeout(() => n(f("timeout", "packages.connect: the package did not complete the connection")), d);
|
|
34
34
|
o.signal.addEventListener("abort", () => clearTimeout(a), { once: !0 }), t.addEventListener("message", (e) => {
|
|
35
35
|
if (e.data?.type === "fkn-packages-nack") {
|
|
36
36
|
let t = e.data.message;
|
|
37
|
-
n(
|
|
37
|
+
n(f("unavailable", typeof t == "string" && t ? t : "packages.connect: the package refused the connection"));
|
|
38
38
|
}
|
|
39
|
-
}, { signal: o.signal }), t.start(), r && r.addEventListener("abort", () => n(
|
|
39
|
+
}, { signal: o.signal }), t.start(), r && r.addEventListener("abort", () => n(f("unavailable", "packages.connect: aborted before connecting")), {
|
|
40
40
|
once: !0,
|
|
41
41
|
signal: o.signal
|
|
42
|
-
}), i?.then(() => n(
|
|
42
|
+
}), i?.then(() => n(f("unavailable", "packages.connect: the package closed before connecting")));
|
|
43
43
|
});
|
|
44
44
|
try {
|
|
45
|
-
return await Promise.race([
|
|
45
|
+
return await Promise.race([m(e, t, a.signal), s]);
|
|
46
46
|
} catch (e) {
|
|
47
47
|
a.abort(e);
|
|
48
48
|
try {
|
|
@@ -52,27 +52,27 @@ var c = /* @__PURE__ */ e({
|
|
|
52
52
|
} finally {
|
|
53
53
|
o.abort();
|
|
54
54
|
}
|
|
55
|
-
},
|
|
56
|
-
let t = await (await
|
|
57
|
-
if ("error" in t) throw
|
|
55
|
+
}, g = async (e) => {
|
|
56
|
+
let t = await (await p()).packages.search(e);
|
|
57
|
+
if ("error" in t) throw f(t.error, t.message);
|
|
58
58
|
return t.results;
|
|
59
|
-
}, g = async (e, t) => {
|
|
60
|
-
let n = await (await f()).packages.pick(e, t);
|
|
61
|
-
if ("error" in n) throw d(n.error, n.message);
|
|
62
|
-
return "declined" in n ? [] : n.results;
|
|
63
59
|
}, _ = async (e, t) => {
|
|
64
|
-
let n = await (await
|
|
65
|
-
if ("error" in n) throw
|
|
60
|
+
let n = await (await p()).packages.pick(e, t);
|
|
61
|
+
if ("error" in n) throw f(n.error, n.message);
|
|
62
|
+
return "declined" in n ? [] : n.results;
|
|
63
|
+
}, v = async (e, t) => {
|
|
64
|
+
let n = await (await p()).packages.install(e, t);
|
|
65
|
+
if ("error" in n) throw f(n.error, n.message);
|
|
66
66
|
return "declined" in n ? null : n.installed;
|
|
67
|
-
},
|
|
68
|
-
let t = await (await
|
|
69
|
-
if ("error" in t) throw
|
|
70
|
-
},
|
|
67
|
+
}, y = async () => (await (await p()).packages.list()).results, b = async (e) => {
|
|
68
|
+
let t = await (await p()).packages.uninstall(e);
|
|
69
|
+
if ("error" in t) throw f(t.error, t.message);
|
|
70
|
+
}, x = ({ x: e, y: t, width: n, height: r }) => ({
|
|
71
71
|
x: Math.round(e),
|
|
72
72
|
y: Math.round(t),
|
|
73
73
|
width: Math.round(n),
|
|
74
74
|
height: Math.round(r)
|
|
75
|
-
}),
|
|
75
|
+
}), S = (e, t) => {
|
|
76
76
|
let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y);
|
|
77
77
|
return {
|
|
78
78
|
x: n,
|
|
@@ -80,14 +80,14 @@ var c = /* @__PURE__ */ e({
|
|
|
80
80
|
width: Math.max(0, Math.min(e.x + e.width, t.x + t.width) - n),
|
|
81
81
|
height: Math.max(0, Math.min(e.y + e.height, t.y + t.height) - r)
|
|
82
82
|
};
|
|
83
|
-
},
|
|
83
|
+
}, C = (e, t) => {
|
|
84
84
|
let n = t;
|
|
85
85
|
for (let t = e.parentElement; t; t = t.parentElement) {
|
|
86
86
|
let e = getComputedStyle(t);
|
|
87
|
-
if ((e.overflowX !== "visible" || e.overflowY !== "visible") && (n =
|
|
87
|
+
if ((e.overflowX !== "visible" || e.overflowY !== "visible") && (n = S(n, x(t.getBoundingClientRect())), n.width === 0 || n.height === 0)) break;
|
|
88
88
|
}
|
|
89
89
|
return n;
|
|
90
|
-
},
|
|
90
|
+
}, w = (e) => {
|
|
91
91
|
let t = getComputedStyle(e), n = [
|
|
92
92
|
t.borderTopLeftRadius,
|
|
93
93
|
t.borderTopRightRadius,
|
|
@@ -100,66 +100,66 @@ var c = /* @__PURE__ */ e({
|
|
|
100
100
|
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
101
101
|
});
|
|
102
102
|
return r.some((e) => e > 0) ? r : void 0;
|
|
103
|
-
},
|
|
103
|
+
}, T = (e, t) => {
|
|
104
104
|
if (!e) return !1;
|
|
105
105
|
let n = (e, t) => e === t || !!e && !!t && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
|
|
106
106
|
return n(e.rect, t.rect) && n(e.clip, t.clip) && ((e, t) => e === t || !!e && !!t && e.every((e, n) => e === t[n]))(e.radius, t.radius);
|
|
107
|
-
},
|
|
108
|
-
a("package view", () =>
|
|
109
|
-
var
|
|
110
|
-
let n =
|
|
107
|
+
}, E = /* @__PURE__ */ new Map();
|
|
108
|
+
a("package view", () => E.size > 0);
|
|
109
|
+
var D = async (e, t) => {
|
|
110
|
+
let n = E.get(e);
|
|
111
111
|
if (n) {
|
|
112
112
|
for (let e of n) t && e.element !== t || (e.stop(), n.delete(e));
|
|
113
113
|
if (n.size > 0) return;
|
|
114
|
-
|
|
114
|
+
E.delete(e);
|
|
115
115
|
}
|
|
116
|
-
let r = await (await
|
|
117
|
-
if ("error" in r) throw
|
|
118
|
-
},
|
|
116
|
+
let r = await (await p()).packages.hide(e);
|
|
117
|
+
if ("error" in r) throw f(r.error, r.message);
|
|
118
|
+
}, O = async (e, t) => {
|
|
119
119
|
let { element: n, rect: r } = t;
|
|
120
|
-
if (!n && !r) throw
|
|
121
|
-
let i = (await
|
|
122
|
-
if (!n) return { rect:
|
|
123
|
-
let e =
|
|
120
|
+
if (!n && !r) throw f("invalid", "packages.show: pass an element or a rect");
|
|
121
|
+
let i = (await p()).packages, a = () => {
|
|
122
|
+
if (!n) return { rect: x(r) };
|
|
123
|
+
let e = x(n.getBoundingClientRect());
|
|
124
124
|
return {
|
|
125
125
|
rect: e,
|
|
126
|
-
clip:
|
|
127
|
-
radius:
|
|
126
|
+
clip: C(n, e),
|
|
127
|
+
radius: w(n)
|
|
128
128
|
};
|
|
129
129
|
}, o = !0, s, c = 0, l = async (t) => {
|
|
130
130
|
s = t;
|
|
131
131
|
let n = await i.show(e, t);
|
|
132
|
-
if ("error" in n) throw o = !1,
|
|
132
|
+
if ("error" in n) throw o = !1, f(n.error, n.message);
|
|
133
133
|
};
|
|
134
134
|
await l(a());
|
|
135
135
|
let u = () => {
|
|
136
136
|
if (!o) return;
|
|
137
137
|
let e = a();
|
|
138
|
-
|
|
138
|
+
T(s, e) || l(e).catch(() => {}), c = requestAnimationFrame(u);
|
|
139
139
|
};
|
|
140
140
|
n && (c = requestAnimationFrame(u));
|
|
141
|
-
let
|
|
141
|
+
let d = {
|
|
142
142
|
element: n,
|
|
143
143
|
stop: () => {
|
|
144
144
|
o = !1, cancelAnimationFrame(c);
|
|
145
145
|
}
|
|
146
|
-
}, m =
|
|
147
|
-
return m.add(
|
|
146
|
+
}, m = E.get(e) ?? /* @__PURE__ */ new Set();
|
|
147
|
+
return m.add(d), E.set(e, m), {
|
|
148
148
|
hide: () => {
|
|
149
|
-
|
|
149
|
+
D(e, n).catch(() => {});
|
|
150
150
|
},
|
|
151
151
|
refresh: () => {
|
|
152
152
|
if (!o) return;
|
|
153
153
|
let e = a();
|
|
154
|
-
|
|
154
|
+
T(s, e) || l(e).catch(() => {});
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
},
|
|
158
|
-
let r = await (await
|
|
157
|
+
}, k = async (e, t = {}) => D(e, t.element), A = (async (e, n = {}) => {
|
|
158
|
+
let r = await (await p()).packages.connect(e, {
|
|
159
159
|
protocol: n.protocol,
|
|
160
160
|
...n.path === void 0 ? {} : { path: n.path }
|
|
161
161
|
});
|
|
162
|
-
if ("error" in r) throw
|
|
162
|
+
if ("error" in r) throw f(r.error, r.message);
|
|
163
163
|
let a = o("package connection"), s = t()?.epoch ?? 0, c = i((e, t) => {
|
|
164
164
|
t !== s && (a(), c());
|
|
165
165
|
});
|
|
@@ -173,7 +173,7 @@ var E = async (e, t) => {
|
|
|
173
173
|
closed: u,
|
|
174
174
|
port: l
|
|
175
175
|
};
|
|
176
|
-
let
|
|
176
|
+
let d = await h(n.payload, l, {
|
|
177
177
|
signal: n.signal,
|
|
178
178
|
closed: u
|
|
179
179
|
});
|
|
@@ -182,34 +182,34 @@ var E = async (e, t) => {
|
|
|
182
182
|
l.postMessage({ type: "fkn-packages-disconnect" });
|
|
183
183
|
} catch {}
|
|
184
184
|
}, { once: !0 }), {
|
|
185
|
-
remote:
|
|
185
|
+
remote: d,
|
|
186
186
|
closed: u,
|
|
187
187
|
port: l
|
|
188
188
|
};
|
|
189
|
-
}),
|
|
189
|
+
}), j = ["allow-scripts", "allow-same-origin"], M = (e) => {
|
|
190
190
|
let t = e.getAttribute("sandbox");
|
|
191
191
|
if (t !== null) {
|
|
192
|
-
let e = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), n =
|
|
193
|
-
if (n.length) throw
|
|
192
|
+
let e = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), n = j.filter((t) => !e.has(t));
|
|
193
|
+
if (n.length) throw f("invalid", `packages.mount: the iframe's sandbox attribute must include ${n.join(" and ")}, or the package cannot start`);
|
|
194
194
|
}
|
|
195
|
-
if (globalThis.crossOriginIsolated && !new Set((e.getAttribute("allow") ?? "").toLowerCase().split(";").map((e) => e.trim().split(/\s+/)[0]).filter(Boolean)).has("cross-origin-isolated")) throw
|
|
196
|
-
},
|
|
195
|
+
if (globalThis.crossOriginIsolated && !new Set((e.getAttribute("allow") ?? "").toLowerCase().split(";").map((e) => e.trim().split(/\s+/)[0]).filter(Boolean)).has("cross-origin-isolated")) throw f("invalid", "packages.mount: this page is cross-origin isolated, so the iframe's allow attribute must include 'cross-origin-isolated' to hand that down to the package");
|
|
196
|
+
}, N = 3e4, P = (e, t) => new Promise((n, r) => {
|
|
197
197
|
let i = (e) => {
|
|
198
198
|
clearTimeout(o), window.removeEventListener("message", a), e ? r(e) : n();
|
|
199
199
|
}, a = (n) => {
|
|
200
200
|
if (n.source !== e.contentWindow || n.origin !== t) return;
|
|
201
201
|
let r = n.data;
|
|
202
202
|
if (r?.type === "fkn-packages-ready") return i();
|
|
203
|
-
r?.type === "fkn-packages-failed" && i(
|
|
204
|
-
}, o = setTimeout(() => i(
|
|
203
|
+
r?.type === "fkn-packages-failed" && i(f("unavailable", typeof r.message == "string" && r.message ? r.message : "packages.mount: the package failed to boot"));
|
|
204
|
+
}, o = setTimeout(() => i(f("timeout", "packages.mount: the package did not register a connection handler")), N);
|
|
205
205
|
window.addEventListener("message", a);
|
|
206
|
-
}),
|
|
206
|
+
}), F = async (e, t) => {
|
|
207
207
|
let { iframe: n } = t;
|
|
208
|
-
if (!(n instanceof HTMLIFrameElement)) throw
|
|
209
|
-
if (!n.isConnected) throw
|
|
210
|
-
|
|
211
|
-
let r = await (await
|
|
212
|
-
if ("error" in r) throw
|
|
208
|
+
if (!(n instanceof HTMLIFrameElement)) throw f("invalid", "packages.mount: pass the iframe to load the package into");
|
|
209
|
+
if (!n.isConnected) throw f("invalid", "packages.mount: the iframe must be in the document before mounting into it");
|
|
210
|
+
M(n);
|
|
211
|
+
let r = await (await p()).packages.frame(e);
|
|
212
|
+
if ("error" in r) throw f(r.error, r.message);
|
|
213
213
|
n.src = r.url;
|
|
214
214
|
let i = { done: !1 }, a = () => {}, s = new Promise((e) => {
|
|
215
215
|
a = e;
|
|
@@ -223,13 +223,13 @@ var E = async (e, t) => {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
try {
|
|
226
|
-
await
|
|
226
|
+
await P(n, r.origin);
|
|
227
227
|
} catch (e) {
|
|
228
228
|
throw l(), e;
|
|
229
229
|
}
|
|
230
|
-
let u = new MessageChannel(),
|
|
231
|
-
if (!
|
|
232
|
-
|
|
230
|
+
let u = new MessageChannel(), d = n.contentWindow;
|
|
231
|
+
if (!d) throw l(), f("unavailable", "packages.mount: the frame was detached before it could connect");
|
|
232
|
+
d.postMessage({
|
|
233
233
|
type: "fkn-packages-port",
|
|
234
234
|
from: r.from,
|
|
235
235
|
protocol: t.protocol,
|
|
@@ -238,7 +238,7 @@ var E = async (e, t) => {
|
|
|
238
238
|
version: r.version
|
|
239
239
|
}, r.origin, [u.port2]);
|
|
240
240
|
try {
|
|
241
|
-
|
|
241
|
+
d.postMessage({
|
|
242
242
|
type: "fkn-packages-visibility",
|
|
243
243
|
visible: !0
|
|
244
244
|
}, r.origin);
|
|
@@ -251,7 +251,7 @@ var E = async (e, t) => {
|
|
|
251
251
|
};
|
|
252
252
|
try {
|
|
253
253
|
return {
|
|
254
|
-
remote: await
|
|
254
|
+
remote: await h(t.payload, u.port1, {
|
|
255
255
|
signal: t.signal,
|
|
256
256
|
closed: s
|
|
257
257
|
}),
|
|
@@ -263,10 +263,10 @@ var E = async (e, t) => {
|
|
|
263
263
|
} catch (e) {
|
|
264
264
|
throw l(), e;
|
|
265
265
|
}
|
|
266
|
-
},
|
|
267
|
-
let t =
|
|
268
|
-
t && (
|
|
269
|
-
},
|
|
266
|
+
}, I = (e, t, n) => h(t, e, { signal: n?.signal }), L = null, R = !1, z = /* @__PURE__ */ new Set(), B = [], V = /* @__PURE__ */ new Map(), H = !1, U = !1, W = (e) => {
|
|
267
|
+
let t = V.get(e);
|
|
268
|
+
t && (V.delete(e), t());
|
|
269
|
+
}, G = (e, t) => {
|
|
270
270
|
try {
|
|
271
271
|
e.postMessage({
|
|
272
272
|
type: "fkn-packages-nack",
|
|
@@ -276,26 +276,26 @@ var E = async (e, t) => {
|
|
|
276
276
|
try {
|
|
277
277
|
e.close();
|
|
278
278
|
} catch {}
|
|
279
|
-
},
|
|
279
|
+
}, K = async (e, t) => {
|
|
280
280
|
let { port: n, ...r } = e;
|
|
281
281
|
e.port.addEventListener("message", (t) => {
|
|
282
|
-
t.data?.type === "fkn-packages-disconnect" &&
|
|
282
|
+
t.data?.type === "fkn-packages-disconnect" && W(e.port);
|
|
283
283
|
});
|
|
284
284
|
let i;
|
|
285
285
|
try {
|
|
286
286
|
i = await t.createPayload(r);
|
|
287
287
|
} catch (t) {
|
|
288
|
-
throw
|
|
288
|
+
throw G(e.port, t instanceof Error ? t.message : "the package failed to produce a connection"), t;
|
|
289
289
|
}
|
|
290
|
-
let a = new Promise((t) =>
|
|
290
|
+
let a = new Promise((t) => V.set(e.port, t)), o = await m(i, e.port);
|
|
291
291
|
t.handler?.({
|
|
292
292
|
...r,
|
|
293
293
|
remote: o,
|
|
294
294
|
closed: a,
|
|
295
295
|
port: e.port
|
|
296
296
|
});
|
|
297
|
-
},
|
|
298
|
-
|
|
297
|
+
}, q = () => {
|
|
298
|
+
H || typeof window > "u" || window.parent === window || (H = !0, window.addEventListener("message", (e) => {
|
|
299
299
|
if (e.source !== window.parent) return;
|
|
300
300
|
let t = e.data;
|
|
301
301
|
if (t?.type === "fkn-packages-port") {
|
|
@@ -304,43 +304,44 @@ var E = async (e, t) => {
|
|
|
304
304
|
let r = {
|
|
305
305
|
port: n,
|
|
306
306
|
from: typeof t.from == "string" ? t.from : "",
|
|
307
|
+
brokered: e.origin === u,
|
|
307
308
|
protocol: typeof t.protocol == "string" ? t.protocol : null,
|
|
308
309
|
uri: typeof t.uri == "string" ? t.uri : "",
|
|
309
310
|
name: typeof t.name == "string" ? t.name : "",
|
|
310
311
|
version: typeof t.version == "string" ? t.version : ""
|
|
311
312
|
};
|
|
312
|
-
|
|
313
|
+
L ? K(r, L).catch((e) => console.warn("packages.onConnect:", e)) : B.push(r);
|
|
313
314
|
}
|
|
314
|
-
if (t?.type === "fkn-packages-close") for (let e of [...
|
|
315
|
+
if (t?.type === "fkn-packages-close") for (let e of [...V.keys()]) W(e);
|
|
315
316
|
if (t?.type === "fkn-packages-visibility") {
|
|
316
|
-
|
|
317
|
-
for (let e of
|
|
318
|
-
e(
|
|
317
|
+
R = t.visible === !0;
|
|
318
|
+
for (let e of z) try {
|
|
319
|
+
e(R);
|
|
319
320
|
} catch {}
|
|
320
321
|
}
|
|
321
322
|
}));
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
},
|
|
323
|
+
}, J = () => {
|
|
324
|
+
U || typeof window > "u" || window.parent === window || (U = !0, window.parent.postMessage({ type: "fkn-packages-ready" }, "*"));
|
|
325
|
+
}, Y = (e, t) => {
|
|
325
326
|
if (typeof window > "u") return { unsubscribe: () => {} };
|
|
326
|
-
|
|
327
|
+
q();
|
|
327
328
|
let n = {
|
|
328
329
|
createPayload: e,
|
|
329
330
|
handler: t
|
|
330
331
|
};
|
|
331
|
-
for (
|
|
332
|
+
for (L = n, J(); B.length && L === n;) K(B.shift(), n).catch((e) => console.warn("packages.onConnect:", e));
|
|
332
333
|
return { unsubscribe: () => {
|
|
333
|
-
|
|
334
|
+
L === n && (L = null);
|
|
334
335
|
} };
|
|
335
|
-
},
|
|
336
|
+
}, X = () => R, Z = (e) => {
|
|
336
337
|
if (typeof window > "u") return { unsubscribe: () => {} };
|
|
337
|
-
|
|
338
|
+
q(), z.add(e);
|
|
338
339
|
try {
|
|
339
|
-
e(
|
|
340
|
+
e(R);
|
|
340
341
|
} catch {}
|
|
341
342
|
return { unsubscribe: () => {
|
|
342
|
-
|
|
343
|
+
z.delete(e);
|
|
343
344
|
} };
|
|
344
345
|
};
|
|
345
346
|
//#endregion
|
|
346
|
-
export {
|
|
347
|
+
export { I as attach, A as connect, k as hide, v as install, X as isVisible, y as list, F as mount, Y as onConnect, Z as onVisibilityChange, _ as pick, g as search, O as show, c as t, b as uninstall };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./api-
|
|
1
|
+
const e=require("./api-Csb5b8dE.cjs"),t=require("./busy-BXbVH595.cjs");var n=typeof FinalizationRegistry>`u`?void 0:new FinalizationRegistry(e=>e()),r=e=>{let r=e.body;if(!r)return e;let i=t.t(`streamed response`),a=r.getReader(),o=new ReadableStream({pull:async e=>{try{let{done:t,value:n}=await a.read();if(t){i(),e.close();return}e.enqueue(n)}catch(t){i(),e.error(t)}},cancel:async e=>{i(),await a.cancel(e).catch(()=>{})}}),s=new Response(o,{status:e.status,statusText:e.statusText,headers:e.headers});return n?.register(s,i),s},i=async e=>{if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e:new Request(`https://body.invalid/`,{method:`POST`,body:e,duplex:`half`}).arrayBuffer()},a=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},o=async(t,n)=>{if(e.p(t),typeof t==`object`&&t&&!(t instanceof URL)&&typeof t.url==`string`){let o=t,s={};o.headers.forEach((e,t)=>{s[t]=e});let c=await i(n?.body===void 0?await a(o):n.body);return e.o.then(e=>e.cloud.fetch(o.url,{...n,method:n?.method??o.method,headers:n?.headers??s,body:c})).then(r)}let o=t instanceof URL?t.href:t,s=await i(n?.body);return e.o.then(e=>e.cloud.fetch(o,n?.body===void 0?n:{...n,body:s})).then(r)};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as Resolvers } from "./contract-
|
|
2
|
-
import "./api-
|
|
1
|
+
import { K as Resolvers } from "./contract-CMQOic3K.js";
|
|
2
|
+
import "./api-C-VvG5P-.js";
|
|
3
3
|
//#region src/proxy.d.ts
|
|
4
4
|
type ProxyFetch = Resolvers['cloud']['fetch'];
|
|
5
5
|
type FetchParameters = Parameters<ProxyFetch>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e, p as t } from "./api-
|
|
1
|
+
import { o as e, p as t } from "./api-BYtMzj8u.js";
|
|
2
2
|
import { t as n } from "./busy-DsMWrSzc.js";
|
|
3
3
|
//#region src/proxy.ts
|
|
4
4
|
var r = typeof FinalizationRegistry > "u" ? void 0 : new FinalizationRegistry((e) => e()), i = (e) => {
|
package/rooms.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-Csb5b8dE.cjs"),n=require("./busy-BXbVH595.cjs"),r=require("./contract.cjs");var i=e.t({available:()=>_,create:()=>b,join:()=>x,open:()=>y}),a={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,notClaimingApp:`rooms: only the app that claimed the room can change it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,mailboxUnavailable:`rooms: the mailbox switch is not available`,guestUnavailable:`rooms: guest joins are not available`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},o=(e,t)=>Object.assign(Error(t),{code:e}),s=e=>e instanceof Error&&typeof e.code==`string`,c={send:!0,receive:!0,maxMessageBytes:262144},l=()=>({messages:0,bytes:0,cap:5e8,archived:!1}),u=async()=>{if(!t.l)return;let e=(await t.s(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},d=()=>{throw o(`unavailable`,a.unavailable)},f=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,p=e=>{if(e!==void 0&&e!==!1)return e===!0?r.ROOM_TEMPORARY_MS.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=r.ROOM_TEMPORARY_MS.min&&e<=r.ROOM_TEMPORARY_MS.max?e:null},m=(e,t)=>{let n=t?e?.guest:e;return typeof n?.join==`function`?n:void 0},h=e=>{let t=e?.guest;if(t!==void 0&&typeof t!=`boolean`)throw o(`invalid`,a.malformed);return t===!0},g=async(e,r)=>{let i=e.invite,u=e,d=0,h=e.self,g=e.owner,_=e.claimed,v=e.mailbox,y=0,b=await e.defaults().catch(()=>c),x=!1,S=new Set,C=new Set,w=n.t(`room`),T=()=>{},E=()=>{},D=new Promise(e=>{E=e}),O=e=>{let t=[...C];C.clear();for(let n of t)try{n(e)}catch{}},k=e=>{x||(x=!0,T(),S.clear(),w(),O(o(`closed`,a.ended)),E({reason:e}))},A=e=>{if(x)return;let t=e;if(t.type===`defaults`&&(b=t.defaults),t.type===`permissions`&&t.id===h.id&&(h={id:h.id,permissions:t.permissions,maxMessageBytes:t.maxMessageBytes}),t.type===`claim`){y+=1;let e=t.claimed&&t.mailbox!==!1;t={type:`claim`,claimed:t.claimed,owner:t.owner,mailbox:e},_=t.claimed,g=t.owner,v=e?l():null}for(let e of[...S])try{e(t)}catch{}},j=(e,t)=>{Promise.resolve(e.on(A)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===d&&k(e.reason)},()=>{})},M=async(e,t)=>{let n=m(e,r);if(!n)return k(`unavailable`);let a=await n.join(i).catch(()=>void 0);if(x||t!==d)return;if(!a)return k(`unavailable`);if(`error`in a)return k(f(a.error));if(a.self.id!==h.id)return Promise.resolve(a.leave()).catch(()=>{}),k(`unavailable`);u=a,h=a.self,g=a.owner,_=a.claimed,v=a.mailbox,j(a,t);let o=await a.defaults().catch(()=>void 0);o&&!x&&t===d&&(b=o)};T=t.u((e,t)=>{let n=d;d=t,!(x||n===0||n===t)&&(O(o(`unavailable`,a.unavailable)),M(e.rooms,t))}),j(e,d);let N=async e=>{if(x)throw o(`closed`,a.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});C.add(t);try{return await Promise.race([Promise.resolve(e(u)),n])}catch(e){throw s(e)?e:o(`unavailable`,a.unavailable)}finally{C.delete(t)}},P=async e=>{let t=await N(e);if(`error`in t)throw o(t.error,t.message)},F=async e=>{let t=await N(e);if(typeof t==`object`&&t&&`error`in t)throw o(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:i,get self(){return h},get owner(){return g},get claimed(){return _},get mailbox(){return v},defaults:()=>b,members:()=>N(e=>e.members()),send:e=>P(t=>t.send(e)),edit:(e,t)=>P(n=>n.edit(e,t)),delete:(e,t)=>P(n=>n.delete(e,t)),backlog:(e,t)=>F(n=>n.backlog(e,t)),setDefault:(e,t)=>P(n=>n.setDefault(e,t)),limit:(e,t)=>P(n=>n.limit(e,t)),grant:(e,t)=>P(n=>n.grant(e,t)),revoke:(e,t)=>P(n=>n.revoke(e,t)),remove:e=>P(t=>t.remove(e)),block:e=>P(t=>t.block(e)),unblock:e=>P(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw o(`invalid`,a.badDescription);let n=p(e?.temporary);if(n===null)throw o(`invalid`,a.badTemporary);let r=e?.mailbox;if(r!==void 0&&typeof r!=`boolean`)throw o(`invalid`,a.malformed);let i={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n},...r===void 0?{}:{mailbox:r}};return Object.keys(i).length===0?P(e=>e.claim()):P(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw o(`unavailable`,a.temporaryUnavailable);if(r===!1&&e.mailboxSwitch!==!0)throw o(`unavailable`,a.mailboxUnavailable);return e.claim(i)})},setMailbox:async e=>{if(typeof e!=`boolean`)throw o(`invalid`,a.malformed);let t=y;await P(t=>{if(t.mailboxSwitch!==!0)throw o(`unavailable`,a.mailboxUnavailable);return t.setMailbox(e)}),y===t&&(e?v===null&&(v=l()):v=null)},release:()=>P(e=>e.release()),usage:async()=>{let e=await F(e=>e.usage());return v=e,e},on:async e=>x?()=>{}:(S.add(e),()=>{S.delete(e)}),leave:async()=>{await Promise.resolve(u.leave()).catch(()=>{}),k(`left`)},closed:D}},_=async()=>{let e=await u();return e?e.available().catch(()=>!1):!1},v=async(e,t)=>{let n=await u();if(!n)throw o(`unavailable`,a.unavailable);let r=m(n,e);if(!r)throw o(`unavailable`,a.guestUnavailable);let i=await t(r).catch(d);if(`error`in i)throw o(i.error,i.message);return g(i,e)},y=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw o(`invalid`,a.badName);return v(h(t),n=>n.open(e,t))},b=async e=>v(h(e),t=>t.create(e)),x=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw o(`invalid`,a.inviteNoKey);return v(h(t),n=>n.join(e,t))};exports.available=_,exports.create=b,exports.join=x,exports.open=y,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/rooms.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-
|
|
1
|
+
import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-CMQOic3K.js";
|
|
2
2
|
declare namespace rooms_d_exports {
|
|
3
3
|
export { RoomClaimOptions as ClaimOptions, RoomCreateOptions as CreateOptions, RoomJoinOptions as JoinOptions, RoomOpenOptions as OpenOptions, Room, RoomBacklog, RoomDefaults, RoomEnd, RoomEvent, RoomMailbox, RoomMember, RoomMessage, RoomPermission, RoomPermissions, RoomsError, RoomsErrorCode, available, create, join, open };
|
|
4
4
|
}
|
|
@@ -22,7 +22,7 @@ export type Room = {
|
|
|
22
22
|
readonly self: RoomMember;
|
|
23
23
|
/** the owner's member id, or '' while a claimed room's owner has never joined */
|
|
24
24
|
readonly owner: string;
|
|
25
|
-
/** whether
|
|
25
|
+
/** whether an account keeps this name. Whether it keeps the messages too is `mailbox`. */
|
|
26
26
|
readonly claimed: boolean;
|
|
27
27
|
/**
|
|
28
28
|
* what the mailbox holds, as the room last said. Null while the room keeps no messages: nobody has
|
|
@@ -98,11 +98,12 @@ export type Room = {
|
|
|
98
98
|
*/
|
|
99
99
|
unblock: (id: string) => Promise<void>;
|
|
100
100
|
/**
|
|
101
|
-
* keeps the name for the signed-in
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
101
|
+
* keeps the name for the signed-in account, and a mailbox unless asked not to. A free account holds 5
|
|
102
|
+
* claims and a premium one 10, in any scope, `global` included; once premium lapses the account keeps its
|
|
103
|
+
* 5 oldest claims and the others are released 30 days later. `description`
|
|
104
|
+
* says what the room is for, shown to the account in its fkn.app settings; a permanent claim with an
|
|
105
|
+
* unchanged one on every open is free. Claiming on every open also claims the room again after the
|
|
106
|
+
* account unclaims it from fkn.app, so claim when the person wants the room kept, or make it `temporary`.
|
|
106
107
|
*
|
|
107
108
|
* `temporary` makes the claim end by itself, in milliseconds (`true` is 7 days), that long after its
|
|
108
109
|
* last claim: a temporary claim goes to the account's ledger every time, which is what restarts its
|
|
@@ -137,10 +138,9 @@ export type Room = {
|
|
|
137
138
|
* claim's account. Off deletes every stored message at once, the archive included, and the room then
|
|
138
139
|
* relays as an unclaimed one does while keeping its claim; whoever is present hears a `claim` event
|
|
139
140
|
* with `mailbox: false` and no `deleted`, so what an app shows stays. On starts an empty mailbox that
|
|
140
|
-
* keeps messages from the next `seq`, and nothing deleted comes back.
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* or a newer one when a release or the account's own switch landed before the answer.
|
|
141
|
+
* keeps messages from the next `seq`, and nothing deleted comes back. Neither way needs premium.
|
|
142
|
+
* Setting what it already is changes nothing. Resolves once the room answered, with `mailbox` reading the
|
|
143
|
+
* new state, or a newer one when a release or the account's own switch landed before the answer.
|
|
144
144
|
*
|
|
145
145
|
* Refused `invalid` (`rooms: the room is not claimed`) on an unclaimed room, `denied` (`rooms: not the
|
|
146
146
|
* room owner`) from anyone else, `denied` (`rooms: only the app that claimed the room can change it`)
|