@banou/stub 0.0.18 → 0.0.20
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/build/.well-known/fkn.json +1 -1
- package/build/assets/lib-Preview-B6uZKyhl.js +82 -0
- package/build/assets/lib-account-BuVN6Bsx.js +41 -0
- package/build/assets/lib-account-Cw8yCZtf.js +2 -0
- package/build/assets/lib-api-DLvscoll-DhlBp9Wz.js +312 -0
- package/build/assets/lib-api-DVwR-22s.js +2 -0
- package/build/assets/lib-build-DEOZ3A7n.js +1846 -0
- package/build/assets/lib-compat-D8G4_Lzi.js +860 -0
- package/build/assets/lib-custom-media-element-CnANKrGl.js +217 -0
- package/build/assets/lib-dash.all.min-CDvdorbj.js +27251 -0
- package/build/assets/lib-dist-Dv8d3Kr0.js +7 -0
- package/build/assets/lib-dist-S8Gxnnq-.js +12468 -0
- package/build/assets/lib-dist-T0QlKbbk.js +18578 -0
- package/build/assets/lib-dist-xBHT3Lfz.js +911 -0
- package/build/assets/lib-react-BEg4mBBK.js +112 -0
- package/build/assets/lib-react-C0OCUIWX.js +434 -0
- package/build/assets/lib-react-CAkOlDha.js +367 -0
- package/build/assets/lib-react-CGlZXIjl.js +2187 -0
- package/build/assets/lib-react-CLVoi_ZM.js +334 -0
- package/build/assets/lib-react-DUxKSzCt.js +311 -0
- package/build/assets/lib-react-QvmpnEVK.js +334 -0
- package/build/assets/lib-react-WTnxAo6F.js +202 -0
- package/build/assets/lib-remote-DeY2A2G7.js +416 -0
- package/build/assets/lib-remote-DxEZmpd0.js +2 -0
- package/build/assets/lib-rolldown-runtime-B1bRi_D7.js +27 -0
- package/build/assets/lib-worker-anime-index-Jbe1K3rX.js +1 -0
- package/build/assets/lib-worker-anime-seasons-CVM0BQGM.js +1 -0
- package/build/assets/lib-worker-index-C7ynIZYg.js +1401 -0
- package/build/assets/{main-C8JOinyp.js → main-DejLBzlj.js} +1 -1
- package/build/fkn.json +1 -1
- package/build/index.html +1 -1
- package/build/index.js +40639 -0
- package/fkn.json +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,1846 @@
|
|
|
1
|
+
//#region node_modules/osra/build/index.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, n = "__OSRA_KEY__", r = "__OSRA_DEFAULT_KEY__", i = "__OSRA_BOX__", a = () => globalThis.browser ?? globalThis.chrome, o = () => a()?.runtime, s = (e, t) => ne(e) && e.__OSRA_KEY__ === t, c = (e, t) => {
|
|
10
|
+
if (e) {
|
|
11
|
+
if (e.aborted) {
|
|
12
|
+
t();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
e.addEventListener("abort", t, { once: !0 });
|
|
16
|
+
}
|
|
17
|
+
}, l = ({ listener: e, transport: t, remoteName: n, key: i = r, origin: a = "*", unregisterSignal: o }) => {
|
|
18
|
+
if (o?.aborted) return;
|
|
19
|
+
let l = pe(t) ? t.receive : t;
|
|
20
|
+
if (typeof l == "function") {
|
|
21
|
+
let t = l((t, r) => {
|
|
22
|
+
o?.aborted || s(t, i) && (n && t.name !== n || e(t, r));
|
|
23
|
+
});
|
|
24
|
+
typeof t == "function" && c(o, t);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (T(l) || E(l) || oe(l) || se(l)) {
|
|
28
|
+
let t = (t, r) => {
|
|
29
|
+
let a = (t, a) => {
|
|
30
|
+
s(t, i) && (n && t.name !== n || e(t, {
|
|
31
|
+
port: r,
|
|
32
|
+
sender: a
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
t.addListener(a), c(o, () => t.removeListener(a));
|
|
36
|
+
};
|
|
37
|
+
if (T(l)) t(l.onMessage);
|
|
38
|
+
else if (oe(l)) {
|
|
39
|
+
let e = (e) => t(e.onMessage, e);
|
|
40
|
+
l.addListener(e), c(o, () => l.removeListener(e));
|
|
41
|
+
} else se(l) ? t(l) : t(l.onMessage);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let u = S(l) ? l.port : l, d = a !== "*" && D(l), f = (t) => {
|
|
45
|
+
let r = t.data;
|
|
46
|
+
if (typeof r == "string") try {
|
|
47
|
+
r = JSON.parse(r);
|
|
48
|
+
} catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
s(r, i) && (n && r.name !== n || d && t.origin && t.origin !== a || e(r, {
|
|
52
|
+
receiveTransport: l,
|
|
53
|
+
source: t.source,
|
|
54
|
+
origin: t.origin
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
u.addEventListener("message", f), u instanceof MessagePort && u.start(), c(o, () => u.removeEventListener("message", f));
|
|
58
|
+
}, u = /* @__PURE__ */ new WeakSet(), d = (e) => String(e?.message ?? e).includes("disconnected port"), f = (e, t, n = "*", r = []) => {
|
|
59
|
+
let i = pe(e) ? e.emit : e;
|
|
60
|
+
if (typeof i == "function") i(t, r);
|
|
61
|
+
else if (D(i)) i.postMessage(t, n, r);
|
|
62
|
+
else if (E(i)) {
|
|
63
|
+
if (u.has(i)) return;
|
|
64
|
+
try {
|
|
65
|
+
i.postMessage(t);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (!d(e)) throw e;
|
|
68
|
+
u.add(i);
|
|
69
|
+
}
|
|
70
|
+
} else if (T(i)) i.sendMessage(t)?.catch?.((e) => {
|
|
71
|
+
if (!String(e?.message).includes("Receiving end does not exist")) throw e;
|
|
72
|
+
});
|
|
73
|
+
else if (v(i)) {
|
|
74
|
+
let e = JSON.stringify(t);
|
|
75
|
+
i.readyState === WebSocket.CONNECTING ? i.addEventListener("open", () => i.send(e), { once: !0 }) : i.send(e);
|
|
76
|
+
} else S(i) ? i.port.postMessage(t, r) : i.postMessage(t, r);
|
|
77
|
+
}, p = globalThis.Float16Array, m = {
|
|
78
|
+
Int8Array,
|
|
79
|
+
Uint8Array,
|
|
80
|
+
Uint8ClampedArray,
|
|
81
|
+
Int16Array,
|
|
82
|
+
Uint16Array,
|
|
83
|
+
Int32Array,
|
|
84
|
+
Uint32Array,
|
|
85
|
+
Float16Array: p,
|
|
86
|
+
Float32Array,
|
|
87
|
+
Float64Array,
|
|
88
|
+
BigInt64Array,
|
|
89
|
+
BigUint64Array
|
|
90
|
+
}, h = Object.values(m), g = (e) => {
|
|
91
|
+
let t = e.constructor.name;
|
|
92
|
+
if (t in m) return t;
|
|
93
|
+
for (let [t, n] of Object.entries(m)) if (n && e instanceof n) return t;
|
|
94
|
+
throw Error("Unknown typed array type");
|
|
95
|
+
}, ee = (e) => {
|
|
96
|
+
let t = m[e];
|
|
97
|
+
if (!t) throw Error("Unknown typed array type");
|
|
98
|
+
return t;
|
|
99
|
+
}, _ = (e) => w(e, h), v = (e) => e instanceof WebSocket, y = (e) => !!globalThis.ServiceWorkerContainer && e instanceof ServiceWorkerContainer, b = (e) => !!globalThis.ServiceWorker && e instanceof ServiceWorker, te = (e) => !!globalThis.Worker && e instanceof Worker, x = (e) => {
|
|
100
|
+
let t = globalThis.DedicatedWorkerGlobalScope;
|
|
101
|
+
return !!t && e instanceof t;
|
|
102
|
+
}, S = (e) => !!globalThis.SharedWorker && e instanceof SharedWorker, C = (e) => e instanceof MessagePort, ne = (e) => !!e && typeof e == "object" && "__OSRA_KEY__" in e && !!e.__OSRA_KEY__, w = (e, t) => {
|
|
103
|
+
if (e === null || typeof e != "object" && typeof e != "function") return !1;
|
|
104
|
+
for (let n of t) if (n && e instanceof n) return !0;
|
|
105
|
+
return !1;
|
|
106
|
+
}, re = (e) => w(e, [globalThis.SharedArrayBuffer]), ie = (e) => w(e, [
|
|
107
|
+
globalThis.ArrayBuffer,
|
|
108
|
+
globalThis.MessagePort,
|
|
109
|
+
globalThis.ReadableStream,
|
|
110
|
+
globalThis.WritableStream,
|
|
111
|
+
globalThis.TransformStream,
|
|
112
|
+
globalThis.ImageBitmap,
|
|
113
|
+
globalThis.OffscreenCanvas,
|
|
114
|
+
globalThis.AudioData,
|
|
115
|
+
globalThis.VideoFrame,
|
|
116
|
+
globalThis.MediaSourceHandle,
|
|
117
|
+
globalThis.MediaStreamTrack,
|
|
118
|
+
globalThis.MIDIAccess,
|
|
119
|
+
globalThis.RTCDataChannel,
|
|
120
|
+
globalThis.WebTransportReceiveStream,
|
|
121
|
+
globalThis.WebTransportSendStream
|
|
122
|
+
]), T = (e) => {
|
|
123
|
+
let t = o();
|
|
124
|
+
return t ? e === t : !1;
|
|
125
|
+
}, E = (e, t = !1) => !e || typeof e != "object" || D(e) || !("name" in e) || !("disconnect" in e) || !("postMessage" in e) ? !1 : t ? "sender" in e && "onMessage" in e && "onDisconnect" in e : !0, ae = (e) => !!e && typeof e == "object" && !D(e) && "addListener" in e && "hasListener" in e && "removeListener" in e, oe = (e) => {
|
|
126
|
+
let t = o();
|
|
127
|
+
return t ? e === t.onConnect || e === t.onConnectExternal : !1;
|
|
128
|
+
}, se = (e) => ae(e), D = (e) => {
|
|
129
|
+
if (!e || typeof e != "object") return !1;
|
|
130
|
+
try {
|
|
131
|
+
return "window" in e && e.window === e;
|
|
132
|
+
} catch {
|
|
133
|
+
try {
|
|
134
|
+
return "closed" in e && typeof e.closed == "boolean" && "close" in e && typeof e.close == "function";
|
|
135
|
+
} catch {
|
|
136
|
+
return !1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, ce = (e) => v(e) || E(e) || T(e), le = (e) => v(e) || E(e) || oe(e) || se(e) || T(e), O = (e) => !!e && typeof e == "object" && !D(e) && "isJson" in e && e.isJson === !0 || ce(e) || le(e), k = (e) => D(e) || ce(e) || b(e) || te(e) || x(e) || S(e) || C(e) || de(e), A = (e) => D(e) || le(e) || y(e) || te(e) || x(e) || S(e) || C(e) || fe(e), ue = (e) => {
|
|
140
|
+
if (!e || typeof e != "object" || D(e)) return !1;
|
|
141
|
+
let t = Object.getPrototypeOf(e);
|
|
142
|
+
return t === Object.prototype || t === null;
|
|
143
|
+
}, de = (e) => !ue(e) || !("emit" in e) ? !1 : k(e.emit) || typeof e.emit == "function", fe = (e) => !ue(e) || !("receive" in e) ? !1 : A(e.receive) || typeof e.receive == "function", pe = (e) => de(e) || fe(e), me = () => globalThis.Buffer, he = 32768, ge = (e) => {
|
|
144
|
+
let t = e.toBase64;
|
|
145
|
+
if (typeof t == "function") return t.call(e);
|
|
146
|
+
let n = me();
|
|
147
|
+
if (n) return n.from(e).toString("base64");
|
|
148
|
+
let r = "";
|
|
149
|
+
for (let t = 0; t < e.length; t += he) r += String.fromCharCode(...e.subarray(t, t + he));
|
|
150
|
+
return btoa(r);
|
|
151
|
+
}, _e = (e) => {
|
|
152
|
+
let t = Uint8Array.fromBase64;
|
|
153
|
+
if (typeof t == "function") return t(e);
|
|
154
|
+
let n = me();
|
|
155
|
+
if (n) return new Uint8Array(n.from(e, "base64"));
|
|
156
|
+
let r = atob(e), i = new Uint8Array(r.length);
|
|
157
|
+
for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
|
|
158
|
+
return i;
|
|
159
|
+
}, j = { [i]: "revivable" }, ve = (e) => !!e && typeof e == "object" && "__OSRA_BOX__" in e && e.__OSRA_BOX__ === "revivable", ye = (e, t) => O(t.transport) ? { base64Buffer: ge(new Uint8Array(e)) } : { arrayBuffer: e }, be = (e) => "arrayBuffer" in e ? e.arrayBuffer : _e(e.base64Buffer).buffer, xe = /* @__PURE__ */ t({
|
|
160
|
+
box: () => we,
|
|
161
|
+
isType: () => Ce,
|
|
162
|
+
objectsOnly: () => !0,
|
|
163
|
+
revive: () => Te,
|
|
164
|
+
type: () => Se
|
|
165
|
+
}), Se = "arrayBuffer", Ce = (e) => e instanceof ArrayBuffer, we = (e, t) => ({
|
|
166
|
+
...j,
|
|
167
|
+
type: Se,
|
|
168
|
+
...ye(e, t)
|
|
169
|
+
}), Te = (e, t) => be(e), Ee = /* @__PURE__ */ t({
|
|
170
|
+
box: () => ke,
|
|
171
|
+
isType: () => Oe,
|
|
172
|
+
objectsOnly: () => !0,
|
|
173
|
+
revive: () => Ae,
|
|
174
|
+
type: () => De
|
|
175
|
+
}), De = "date", Oe = (e) => e instanceof Date, ke = (e, t) => ({
|
|
176
|
+
...j,
|
|
177
|
+
type: De,
|
|
178
|
+
ISOString: e.toISOString()
|
|
179
|
+
}), Ae = (e, t) => new Date(e.ISOString), je = /* @__PURE__ */ t({
|
|
180
|
+
box: () => Pe,
|
|
181
|
+
isType: () => Ne,
|
|
182
|
+
objectsOnly: () => !0,
|
|
183
|
+
revive: () => Fe,
|
|
184
|
+
type: () => Me
|
|
185
|
+
}), Me = "headers", Ne = (e) => e instanceof Headers, Pe = (e, t) => ({
|
|
186
|
+
...j,
|
|
187
|
+
type: Me,
|
|
188
|
+
entries: [...e.entries()]
|
|
189
|
+
}), Fe = (e, t) => new Headers(e.entries), Ie = /* @__PURE__ */ t({
|
|
190
|
+
box: () => Be,
|
|
191
|
+
isType: () => ze,
|
|
192
|
+
objectsOnly: () => !0,
|
|
193
|
+
revive: () => Ve,
|
|
194
|
+
type: () => Le
|
|
195
|
+
}), Le = "error", Re = {
|
|
196
|
+
Error,
|
|
197
|
+
TypeError,
|
|
198
|
+
RangeError,
|
|
199
|
+
SyntaxError,
|
|
200
|
+
ReferenceError,
|
|
201
|
+
EvalError,
|
|
202
|
+
URIError
|
|
203
|
+
}, ze = (e) => e instanceof Error, Be = (e, t) => {
|
|
204
|
+
let n = "cause" in e && e.cause !== void 0, r = typeof AggregateError < "u" && e instanceof AggregateError, i = typeof DOMException < "u" && e instanceof DOMException;
|
|
205
|
+
return {
|
|
206
|
+
...j,
|
|
207
|
+
type: Le,
|
|
208
|
+
name: e.name,
|
|
209
|
+
message: e.message,
|
|
210
|
+
stack: e.stack || e.toString(),
|
|
211
|
+
...n ? { cause: Q(e.cause, t) } : {},
|
|
212
|
+
...r ? { errors: Q(e.errors, t) } : {},
|
|
213
|
+
...i ? { isDOMException: !0 } : {}
|
|
214
|
+
};
|
|
215
|
+
}, Ve = (e, t) => {
|
|
216
|
+
let n = e.cause === void 0 ? void 0 : $(e.cause, t), r = n === void 0 ? void 0 : { cause: n };
|
|
217
|
+
if (e.isDOMException && typeof DOMException < "u") {
|
|
218
|
+
let t = new DOMException(e.message, e.name);
|
|
219
|
+
if (e.stack) try {
|
|
220
|
+
Object.defineProperty(t, "stack", {
|
|
221
|
+
value: e.stack,
|
|
222
|
+
configurable: !0
|
|
223
|
+
});
|
|
224
|
+
} catch {}
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
let i;
|
|
228
|
+
if (e.errors !== void 0 && typeof AggregateError < "u") i = AggregateError($(e.errors, t), e.message, r);
|
|
229
|
+
else {
|
|
230
|
+
let t = Re[e.name] ?? Error;
|
|
231
|
+
i = r === void 0 ? new t(e.message) : new t(e.message, r);
|
|
232
|
+
}
|
|
233
|
+
return e.name && i.name !== e.name && (i.name = e.name), e.stack && (i.stack = e.stack), i;
|
|
234
|
+
}, He = /* @__PURE__ */ t({
|
|
235
|
+
box: () => Ge,
|
|
236
|
+
isType: () => We,
|
|
237
|
+
objectsOnly: () => !0,
|
|
238
|
+
revive: () => Ke,
|
|
239
|
+
type: () => Ue
|
|
240
|
+
}), Ue = "typedArray", We = _, Ge = (e, t) => {
|
|
241
|
+
let n = e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
242
|
+
return {
|
|
243
|
+
...j,
|
|
244
|
+
type: Ue,
|
|
245
|
+
typedArrayType: g(e),
|
|
246
|
+
...ye(n, t)
|
|
247
|
+
};
|
|
248
|
+
}, Ke = (e, t) => new (ee(e.typedArrayType))(be(e)), qe = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakSet(), M = (e, t) => {
|
|
249
|
+
if (Je.has(e)) return t(), () => {};
|
|
250
|
+
let n = qe.get(e);
|
|
251
|
+
return n || qe.set(e, n = /* @__PURE__ */ new Set()), n.add(t), () => n.delete(t);
|
|
252
|
+
}, N = (e) => Je.has(e), Ye = (e) => {
|
|
253
|
+
if (Je.has(e)) return;
|
|
254
|
+
Je.add(e);
|
|
255
|
+
let t = qe.get(e);
|
|
256
|
+
if (t) {
|
|
257
|
+
qe.delete(e);
|
|
258
|
+
for (let e of t) try {
|
|
259
|
+
e();
|
|
260
|
+
} catch {}
|
|
261
|
+
}
|
|
262
|
+
}, Xe = /* @__PURE__ */ t({
|
|
263
|
+
box: () => at,
|
|
264
|
+
forceTransfer: () => rt,
|
|
265
|
+
isInTransfer: () => nt,
|
|
266
|
+
isType: () => it,
|
|
267
|
+
objectsOnly: () => !0,
|
|
268
|
+
outsideTransfer: () => I,
|
|
269
|
+
revive: () => ot,
|
|
270
|
+
transfer: () => tt,
|
|
271
|
+
type: () => Ze
|
|
272
|
+
}), Ze = "transfer", P = Symbol.for("osra.transfer"), Qe = (e) => typeof e == "object" && !!e, $e = (e) => Qe(e) && P in e && e[P] === !0, et = (e) => Qe(e) ? ArrayBuffer.isView(e) ? !0 : w(e, [
|
|
273
|
+
globalThis.ArrayBuffer,
|
|
274
|
+
globalThis.MessagePort,
|
|
275
|
+
globalThis.ReadableStream,
|
|
276
|
+
globalThis.WritableStream,
|
|
277
|
+
globalThis.TransformStream,
|
|
278
|
+
globalThis.Request,
|
|
279
|
+
globalThis.Response,
|
|
280
|
+
globalThis.ImageBitmap,
|
|
281
|
+
globalThis.OffscreenCanvas,
|
|
282
|
+
globalThis.VideoFrame,
|
|
283
|
+
globalThis.AudioData
|
|
284
|
+
]) : !1, tt = (e) => et(e) ? {
|
|
285
|
+
[P]: !0,
|
|
286
|
+
value: e
|
|
287
|
+
} : e, F = 0, nt = () => F > 0, rt = (e) => Qe(e) && !$e(e) ? {
|
|
288
|
+
[P]: !0,
|
|
289
|
+
value: e
|
|
290
|
+
} : e, I = (e) => {
|
|
291
|
+
let t = F;
|
|
292
|
+
F = 0;
|
|
293
|
+
try {
|
|
294
|
+
return e();
|
|
295
|
+
} finally {
|
|
296
|
+
F = t;
|
|
297
|
+
}
|
|
298
|
+
}, it = (e) => $e(e), at = (e, t) => {
|
|
299
|
+
F++;
|
|
300
|
+
try {
|
|
301
|
+
return {
|
|
302
|
+
...j,
|
|
303
|
+
type: Ze,
|
|
304
|
+
inner: Q(e.value, t),
|
|
305
|
+
degraded: O(t.transport)
|
|
306
|
+
};
|
|
307
|
+
} finally {
|
|
308
|
+
F--;
|
|
309
|
+
}
|
|
310
|
+
}, ot = (e, t) => $(e.inner, t), st = (e) => w(e, [
|
|
311
|
+
globalThis.MessagePort,
|
|
312
|
+
globalThis.ReadableStream,
|
|
313
|
+
globalThis.WritableStream,
|
|
314
|
+
globalThis.TransformStream,
|
|
315
|
+
globalThis.OffscreenCanvas,
|
|
316
|
+
globalThis.MediaSourceHandle,
|
|
317
|
+
globalThis.MediaStreamTrack,
|
|
318
|
+
globalThis.MIDIAccess,
|
|
319
|
+
globalThis.RTCDataChannel,
|
|
320
|
+
globalThis.WebTransportReceiveStream,
|
|
321
|
+
globalThis.WebTransportSendStream
|
|
322
|
+
]), ct = (e) => ve(e) && e.type === "transfer", L = (e) => {
|
|
323
|
+
let t = [], n = /* @__PURE__ */ new WeakSet(), r = (e, i) => {
|
|
324
|
+
if (!(!e || typeof e != "object") && !n.has(e) && (n.add(e), !re(e))) {
|
|
325
|
+
if (ct(e)) {
|
|
326
|
+
r(e.inner, i || !e.degraded);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (st(e)) {
|
|
330
|
+
t.push(e);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (ie(e)) {
|
|
334
|
+
i && t.push(e);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (ArrayBuffer.isView(e)) {
|
|
338
|
+
i && e instanceof DataView && !re(e.buffer) && !n.has(e.buffer) && (n.add(e.buffer), t.push(e.buffer));
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (Array.isArray(e)) {
|
|
342
|
+
for (let t of e) r(t, i);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
for (let t of Object.values(e)) r(t, i);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
return r(e, !1), t;
|
|
349
|
+
}, R = class {
|
|
350
|
+
_listeners = /* @__PURE__ */ new Map();
|
|
351
|
+
addEventListener(e, t, n) {
|
|
352
|
+
if (!t) return;
|
|
353
|
+
let r = this._listeners.get(e);
|
|
354
|
+
r || (r = /* @__PURE__ */ new Map(), this._listeners.set(e, r)), r.has(t) || r.set(t, typeof n == "object" && !!n?.once);
|
|
355
|
+
}
|
|
356
|
+
removeEventListener(e, t, n) {
|
|
357
|
+
t && this._listeners.get(e)?.delete(t);
|
|
358
|
+
}
|
|
359
|
+
_peer;
|
|
360
|
+
_queue = [];
|
|
361
|
+
_started = !1;
|
|
362
|
+
_closed = !1;
|
|
363
|
+
_onClose;
|
|
364
|
+
_onmessage = null;
|
|
365
|
+
get onmessage() {
|
|
366
|
+
return this._onmessage;
|
|
367
|
+
}
|
|
368
|
+
set onmessage(e) {
|
|
369
|
+
this._onmessage = e, e !== null && this.start();
|
|
370
|
+
}
|
|
371
|
+
onmessageerror = null;
|
|
372
|
+
dispatchEvent(e) {
|
|
373
|
+
e.type === "message" ? this._onmessage?.call(this, e) : e.type === "messageerror" && this.onmessageerror?.call(this, e);
|
|
374
|
+
let t = this._listeners.get(e.type);
|
|
375
|
+
if (t) for (let [n, r] of [...t]) r && t.delete(n), typeof n == "function" ? n.call(this, e) : n.handleEvent(e);
|
|
376
|
+
return !0;
|
|
377
|
+
}
|
|
378
|
+
postMessage(e, t) {
|
|
379
|
+
let n = this._peer;
|
|
380
|
+
!n || n._closed || queueMicrotask(() => {
|
|
381
|
+
if (n._closed) return;
|
|
382
|
+
let t = new MessageEvent("message", { data: e });
|
|
383
|
+
n._started ? n.dispatchEvent(t) : n._queue.push(t);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
start() {
|
|
387
|
+
if (!this._started) {
|
|
388
|
+
this._started = !0;
|
|
389
|
+
for (let e of this._queue.splice(0)) this.dispatchEvent(e);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
close() {
|
|
393
|
+
if (this._closed) return;
|
|
394
|
+
this._closed = !0, this._queue.length = 0, this._onClose?.();
|
|
395
|
+
let e = this._peer;
|
|
396
|
+
e && !e._closed && queueMicrotask(() => {
|
|
397
|
+
e._closed || e.dispatchEvent(new Event("close"));
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}, z = class {
|
|
401
|
+
port1;
|
|
402
|
+
port2;
|
|
403
|
+
constructor() {
|
|
404
|
+
let e = new R(), t = new R();
|
|
405
|
+
e._peer = t, t._peer = e, this.port1 = e, this.port2 = t;
|
|
406
|
+
}
|
|
407
|
+
}, lt = new FinalizationRegistry((e) => {
|
|
408
|
+
try {
|
|
409
|
+
e();
|
|
410
|
+
} catch {}
|
|
411
|
+
}), ut = (e, t) => {
|
|
412
|
+
let n = {};
|
|
413
|
+
return lt.register(e, t, n), () => lt.unregister(n);
|
|
414
|
+
}, dt = /* @__PURE__ */ t({
|
|
415
|
+
box: () => U,
|
|
416
|
+
createRevivableChannel: () => K,
|
|
417
|
+
init: () => xt,
|
|
418
|
+
isType: () => St,
|
|
419
|
+
markPortsShipped: () => G,
|
|
420
|
+
objectsOnly: () => !0,
|
|
421
|
+
postPreBoxed: () => Ot,
|
|
422
|
+
revive: () => W,
|
|
423
|
+
type: () => ft
|
|
424
|
+
}), ft = "messagePort", pt = 2048, mt = 128, ht = 1024, gt = /* @__PURE__ */ new WeakMap(), B = (e) => {
|
|
425
|
+
let t = gt.get(e);
|
|
426
|
+
if (!t) throw Error("osra message-port: connection state missing; did init() run?");
|
|
427
|
+
return t;
|
|
428
|
+
}, _t = (e, t) => {
|
|
429
|
+
let n = e.ports.get(t);
|
|
430
|
+
return n || (n = {
|
|
431
|
+
nextSeq: 0,
|
|
432
|
+
buffer: /* @__PURE__ */ new Map(),
|
|
433
|
+
outSeq: 0
|
|
434
|
+
}, e.ports.set(t, n), e.pendingPorts++), n;
|
|
435
|
+
}, V = (e, t) => {
|
|
436
|
+
let n = e.ports.get(t);
|
|
437
|
+
if (n && !n.handler && e.pendingPorts--, e.ports.delete(t), e.tombstones.size >= mt) {
|
|
438
|
+
let t = e.tombstones.values().next().value;
|
|
439
|
+
t !== void 0 && e.tombstones.delete(t);
|
|
440
|
+
}
|
|
441
|
+
e.tombstones.add(t);
|
|
442
|
+
}, vt = (e) => {
|
|
443
|
+
if (e.handler) for (let t = e.buffer.get(e.nextSeq); t !== void 0; t = e.buffer.get(e.nextSeq)) e.buffer.delete(e.nextSeq), e.nextSeq++, e.handler(t);
|
|
444
|
+
}, yt = (e, t) => _t(B(e), t).outSeq++, bt = (e, t, n) => {
|
|
445
|
+
let r = B(e);
|
|
446
|
+
if (r.tombstones.has(t)) {
|
|
447
|
+
setTimeout(() => n({
|
|
448
|
+
type: "message-port-close",
|
|
449
|
+
remoteUuid: e.remoteUuid,
|
|
450
|
+
portId: t
|
|
451
|
+
}));
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
let i = _t(r, t);
|
|
455
|
+
i.handler || r.pendingPorts--, i.handler = n, vt(i);
|
|
456
|
+
}, xt = (e) => {
|
|
457
|
+
let t = {
|
|
458
|
+
ports: /* @__PURE__ */ new Map(),
|
|
459
|
+
tombstones: /* @__PURE__ */ new Set(),
|
|
460
|
+
pendingPorts: 0
|
|
461
|
+
};
|
|
462
|
+
gt.set(e, t), e.eventTarget.addEventListener("message", ({ detail: n }) => {
|
|
463
|
+
if (n.type !== "message" && n.type !== "message-port-close" || t.tombstones.has(n.portId)) return;
|
|
464
|
+
let r = t.ports.get(n.portId);
|
|
465
|
+
if (n.seq === void 0) {
|
|
466
|
+
r?.handler?.(n);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!r) {
|
|
470
|
+
if (t.pendingPorts >= ht) return;
|
|
471
|
+
r = _t(t, n.portId);
|
|
472
|
+
}
|
|
473
|
+
if (!(n.seq < r.nextSeq)) {
|
|
474
|
+
if (r.buffer.size >= pt && !(n.seq === r.nextSeq && r.handler)) {
|
|
475
|
+
r.buffer.clear(), V(t, n.portId), r.handler?.({
|
|
476
|
+
type: "message-port-close",
|
|
477
|
+
remoteUuid: e.remoteUuid,
|
|
478
|
+
portId: n.portId
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
r.buffer.set(n.seq, n), vt(r);
|
|
483
|
+
}
|
|
484
|
+
}), M(e, () => {
|
|
485
|
+
for (let [n, r] of [...t.ports]) r.handler?.({
|
|
486
|
+
type: "message-port-close",
|
|
487
|
+
remoteUuid: e.remoteUuid,
|
|
488
|
+
portId: n
|
|
489
|
+
});
|
|
490
|
+
t.ports.clear(), t.tombstones.clear(), t.pendingPorts = 0;
|
|
491
|
+
});
|
|
492
|
+
}, St = (e) => e instanceof MessagePort || e instanceof R, H = (e, t) => {
|
|
493
|
+
try {
|
|
494
|
+
let n = B(e).ports.get(t);
|
|
495
|
+
e.sendMessage({
|
|
496
|
+
type: "message-port-close",
|
|
497
|
+
remoteUuid: e.remoteUuid,
|
|
498
|
+
portId: t,
|
|
499
|
+
seq: n ? n.outSeq++ : 0
|
|
500
|
+
});
|
|
501
|
+
} catch {}
|
|
502
|
+
}, Ct = (e, t, n) => {
|
|
503
|
+
if (n) {
|
|
504
|
+
e.postMessage(t);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
let r = L(t);
|
|
508
|
+
e.postMessage(t, r), G(r);
|
|
509
|
+
}, wt = (e, t, n, r) => {
|
|
510
|
+
let i;
|
|
511
|
+
try {
|
|
512
|
+
i = $(e, t);
|
|
513
|
+
} catch (e) {
|
|
514
|
+
r(), globalThis.reportError?.(e);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
n(i);
|
|
518
|
+
}, Tt = (e, t, n) => () => {
|
|
519
|
+
let r = e.deref();
|
|
520
|
+
r && H(r, n);
|
|
521
|
+
let i = t.deref();
|
|
522
|
+
i && V(i, n);
|
|
523
|
+
}, Et = /* @__PURE__ */ new WeakSet(), Dt = (e) => e !== null && (typeof e == "object" || typeof e == "function"), Ot = (e, t, n) => {
|
|
524
|
+
Dt(t) && Et.add(t), e.postMessage(t, n ?? []);
|
|
525
|
+
}, kt = (e, t) => Dt(e) && Et.delete(e) ? e : I(() => Q(e, t)), U = (e, t, n) => {
|
|
526
|
+
let r = e instanceof R;
|
|
527
|
+
if (!r && !O(t.transport)) return {
|
|
528
|
+
...j,
|
|
529
|
+
type: ft,
|
|
530
|
+
port: e,
|
|
531
|
+
...n?.autoBox ? { autoBox: !0 } : {}
|
|
532
|
+
};
|
|
533
|
+
let i = B(t), a = e, o = globalThis.crypto.randomUUID(), s = new WeakRef(a), c = new WeakRef(t), l = new WeakRef(i), u = !1, d = () => {
|
|
534
|
+
if (u) return;
|
|
535
|
+
u = !0;
|
|
536
|
+
let e = l.deref();
|
|
537
|
+
e && V(e, o), m?.();
|
|
538
|
+
let t = s.deref();
|
|
539
|
+
t?.removeEventListener("message", p), t instanceof R && (t._onClose = void 0);
|
|
540
|
+
}, f = (e) => {
|
|
541
|
+
if (e.type === "message-port-close") {
|
|
542
|
+
d(), a.dispatchEvent(new Event("close")), a.close();
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
wt(e.data, t, (e) => Ct(a, e, !1), () => {});
|
|
546
|
+
};
|
|
547
|
+
function p({ data: e }) {
|
|
548
|
+
t.sendMessage({
|
|
549
|
+
type: "message",
|
|
550
|
+
remoteUuid: t.remoteUuid,
|
|
551
|
+
data: kt(e, t),
|
|
552
|
+
portId: o,
|
|
553
|
+
seq: yt(t, o)
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
let m = ut(a, Tt(c, l, o));
|
|
557
|
+
return a.addEventListener("message", p), a.start(), a instanceof R && (a._onClose = () => {
|
|
558
|
+
u || (H(t, o), d());
|
|
559
|
+
}), bt(t, o, f), {
|
|
560
|
+
...j,
|
|
561
|
+
type: ft,
|
|
562
|
+
portId: o,
|
|
563
|
+
synthetic: r
|
|
564
|
+
};
|
|
565
|
+
}, W = (e, t) => "port" in e ? (G([e.port]), e.autoBox ? jt(e.port, t) : e.port) : Mt(e.portId, t, e.synthetic), At = /* @__PURE__ */ new WeakMap(), G = (e) => {
|
|
566
|
+
for (let t of e) {
|
|
567
|
+
let e = At.get(t);
|
|
568
|
+
if (e) {
|
|
569
|
+
At.delete(t), e.shipped = !0;
|
|
570
|
+
for (let t of e.pending.splice(0)) t();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}, jt = (e, t, n) => {
|
|
574
|
+
let r = new EventTarget(), i = ({ data: e }) => {
|
|
575
|
+
wt(e, t, (e) => r.dispatchEvent(new MessageEvent("message", { data: e })), () => r.dispatchEvent(new Event("messageerror")));
|
|
576
|
+
}, a = () => {
|
|
577
|
+
r.dispatchEvent(new Event("messageerror"));
|
|
578
|
+
}, o = () => {
|
|
579
|
+
r.dispatchEvent(new Event("close"));
|
|
580
|
+
};
|
|
581
|
+
e.addEventListener("message", i), e.addEventListener("messageerror", a), e.addEventListener("close", o), r.postMessage = (r, i) => {
|
|
582
|
+
let a = I(() => Q(r, t)), o = L(a), s = Array.isArray(i) ? i : [], c = s.length ? [...o, ...s] : o, l = () => {
|
|
583
|
+
e.postMessage(a, c), G(c);
|
|
584
|
+
};
|
|
585
|
+
if (n && !n.shipped) {
|
|
586
|
+
n.pending.push(l);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
l();
|
|
590
|
+
}, r.start = () => e.start();
|
|
591
|
+
let s = () => {
|
|
592
|
+
e.removeEventListener("message", i), e.removeEventListener("messageerror", a), e.removeEventListener("close", o), e.close();
|
|
593
|
+
};
|
|
594
|
+
return r.close = () => {
|
|
595
|
+
if (n && !n.shipped) {
|
|
596
|
+
n.pending.push(s);
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
s();
|
|
600
|
+
}, r;
|
|
601
|
+
}, K = (e) => {
|
|
602
|
+
if (O(e.transport)) {
|
|
603
|
+
let { port1: t, port2: n } = new z();
|
|
604
|
+
return {
|
|
605
|
+
localPort: t,
|
|
606
|
+
boxedRemote: U(n, e)
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
let { port1: t, port2: n } = new MessageChannel(), r = {
|
|
610
|
+
shipped: !1,
|
|
611
|
+
pending: []
|
|
612
|
+
};
|
|
613
|
+
return At.set(n, r), {
|
|
614
|
+
localPort: jt(t, e, r),
|
|
615
|
+
boxedRemote: U(n, e, { autoBox: !0 })
|
|
616
|
+
};
|
|
617
|
+
}, Mt = (e, t, n) => {
|
|
618
|
+
let r = B(t), { port1: i, port2: a } = n ? new z() : new MessageChannel(), o = new WeakRef(i), s = new WeakRef(a), c = !1, l = !1;
|
|
619
|
+
i instanceof R || i.addEventListener("close", (e) => {
|
|
620
|
+
l && e.stopImmediatePropagation();
|
|
621
|
+
});
|
|
622
|
+
let u = () => {
|
|
623
|
+
if (c) return;
|
|
624
|
+
c = !0, V(r, e);
|
|
625
|
+
let t = s.deref();
|
|
626
|
+
t?.removeEventListener("message", f), t?.close(), p?.();
|
|
627
|
+
}, d = (e) => {
|
|
628
|
+
if (e.type === "message-port-close") {
|
|
629
|
+
u();
|
|
630
|
+
let e = o.deref();
|
|
631
|
+
e?.dispatchEvent(new Event("close")), l = !0, e?.close();
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (!o.deref()) {
|
|
635
|
+
u();
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
let r = s.deref();
|
|
639
|
+
r && wt(e.data, t, (e) => Ct(r, e, n), () => o.deref()?.dispatchEvent(new Event("messageerror")));
|
|
640
|
+
}, f = ({ data: n }) => {
|
|
641
|
+
t.sendMessage({
|
|
642
|
+
type: "message",
|
|
643
|
+
remoteUuid: t.remoteUuid,
|
|
644
|
+
data: kt(n, t),
|
|
645
|
+
portId: e,
|
|
646
|
+
seq: yt(t, e)
|
|
647
|
+
});
|
|
648
|
+
}, p = ut(i, () => {
|
|
649
|
+
H(t, e), u();
|
|
650
|
+
});
|
|
651
|
+
return i instanceof R && (i._onClose = () => {
|
|
652
|
+
c || (H(t, e), u());
|
|
653
|
+
}), a.addEventListener("message", f), a.start(), bt(t, e, d), i;
|
|
654
|
+
}, Nt = /* @__PURE__ */ t({
|
|
655
|
+
box: () => Rt,
|
|
656
|
+
isType: () => Lt,
|
|
657
|
+
objectsOnly: () => !0,
|
|
658
|
+
revive: () => zt,
|
|
659
|
+
type: () => Pt
|
|
660
|
+
}), Pt = "promise", Ft = (e) => e instanceof Promise, It = /* @__PURE__ */ new Set(), Lt = (e) => e instanceof Promise, Rt = (e, t) => {
|
|
661
|
+
if (!Ft(e)) throw TypeError("Expected Promise");
|
|
662
|
+
let { localPort: n, boxedRemote: r } = K(t), i = (e) => {
|
|
663
|
+
n.postMessage(e), n.close();
|
|
664
|
+
};
|
|
665
|
+
return e.then((e) => i({
|
|
666
|
+
type: "resolve",
|
|
667
|
+
data: e
|
|
668
|
+
})).catch((e) => i({
|
|
669
|
+
type: "reject",
|
|
670
|
+
error: e
|
|
671
|
+
})), {
|
|
672
|
+
...j,
|
|
673
|
+
type: Pt,
|
|
674
|
+
port: r
|
|
675
|
+
};
|
|
676
|
+
}, zt = (e, t) => {
|
|
677
|
+
let n = W(e.port, t);
|
|
678
|
+
It.add(n);
|
|
679
|
+
let r = "portId" in e.port;
|
|
680
|
+
return new Promise((e, i) => {
|
|
681
|
+
let a, o = () => {
|
|
682
|
+
n.close(), It.delete(n), a?.();
|
|
683
|
+
};
|
|
684
|
+
if (r && N(t)) {
|
|
685
|
+
i(/* @__PURE__ */ Error("osra: connection closed")), o();
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
a = r ? M(t, () => {
|
|
689
|
+
i(/* @__PURE__ */ Error("osra: connection closed")), o();
|
|
690
|
+
}) : void 0, n.addEventListener("message", ({ data: t }) => {
|
|
691
|
+
t.type === "resolve" ? e(t.data) : i(t.error), o();
|
|
692
|
+
}, { once: !0 }), n.start();
|
|
693
|
+
});
|
|
694
|
+
}, Bt = /* @__PURE__ */ t({
|
|
695
|
+
box: () => q,
|
|
696
|
+
isType: () => Wt,
|
|
697
|
+
objectsOnly: () => !0,
|
|
698
|
+
revive: () => J,
|
|
699
|
+
type: () => Vt
|
|
700
|
+
}), Vt = "function", Ht = /* @__PURE__ */ new Set(), Ut = (e) => {
|
|
701
|
+
e instanceof ReadableStream ? e.locked || e.cancel(/* @__PURE__ */ Error("osra: connection closed")).catch(() => {}) : typeof WritableStream < "u" && e instanceof WritableStream && (e.locked || e.abort(/* @__PURE__ */ Error("osra: connection closed")).catch(() => {}));
|
|
702
|
+
}, Wt = (e) => typeof e == "function", q = (e, t) => {
|
|
703
|
+
let { port1: n, port2: r } = new z();
|
|
704
|
+
return n.addEventListener("message", ({ data: n }) => {
|
|
705
|
+
let [r, i] = n;
|
|
706
|
+
(async () => {
|
|
707
|
+
let n;
|
|
708
|
+
try {
|
|
709
|
+
n = {
|
|
710
|
+
type: "return",
|
|
711
|
+
value: await e(...i)
|
|
712
|
+
};
|
|
713
|
+
} catch (e) {
|
|
714
|
+
n = {
|
|
715
|
+
type: "throw",
|
|
716
|
+
error: e
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
if (N(t)) {
|
|
720
|
+
n.type === "return" && Ut(n.value);
|
|
721
|
+
try {
|
|
722
|
+
r.close();
|
|
723
|
+
} catch {}
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
let a = (() => {
|
|
727
|
+
try {
|
|
728
|
+
return Q(n, t);
|
|
729
|
+
} catch (e) {
|
|
730
|
+
return Q({
|
|
731
|
+
type: "throw",
|
|
732
|
+
error: e
|
|
733
|
+
}, t);
|
|
734
|
+
}
|
|
735
|
+
})();
|
|
736
|
+
Ot(r, a), queueMicrotask(() => {
|
|
737
|
+
try {
|
|
738
|
+
r.close();
|
|
739
|
+
} catch {}
|
|
740
|
+
});
|
|
741
|
+
})();
|
|
742
|
+
}), n.start(), {
|
|
743
|
+
...j,
|
|
744
|
+
type: Vt,
|
|
745
|
+
port: U(r, t)
|
|
746
|
+
};
|
|
747
|
+
}, J = (e, t) => {
|
|
748
|
+
let n = W(e.port, t);
|
|
749
|
+
return ((...e) => new Promise((r, i) => {
|
|
750
|
+
if (N(t)) {
|
|
751
|
+
i(/* @__PURE__ */ Error("osra: connection closed"));
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
let { port1: a, port2: o } = new z();
|
|
755
|
+
Ht.add(a);
|
|
756
|
+
let s, c = () => {
|
|
757
|
+
a.close(), Ht.delete(a), s?.();
|
|
758
|
+
};
|
|
759
|
+
s = M(t, () => {
|
|
760
|
+
i(/* @__PURE__ */ Error("osra: connection closed")), c();
|
|
761
|
+
}), a.addEventListener("message", ({ data: e }) => {
|
|
762
|
+
let t = e;
|
|
763
|
+
t.type === "return" ? r(t.value) : i(t.error), c();
|
|
764
|
+
}, { once: !0 }), a.start();
|
|
765
|
+
let l = I(() => Q([o, e], t));
|
|
766
|
+
Ot(n, l);
|
|
767
|
+
}));
|
|
768
|
+
}, Gt = /* @__PURE__ */ t({
|
|
769
|
+
MAX_CREDIT_WINDOW: () => 64,
|
|
770
|
+
box: () => Zt,
|
|
771
|
+
isType: () => qt,
|
|
772
|
+
objectsOnly: () => !0,
|
|
773
|
+
revive: () => tn,
|
|
774
|
+
type: () => Kt
|
|
775
|
+
}), Kt = "readableStream", qt = (e) => e instanceof ReadableStream, Jt = 2, Yt = 8, Xt = 4 * 1024 * 1024, Zt = (e, t) => {
|
|
776
|
+
let { localPort: n, boxedRemote: r } = K(t), i = e.getReader(), a = nt(), o = 0, s = !1, c = !1, l = (e) => {
|
|
777
|
+
c = !0;
|
|
778
|
+
try {
|
|
779
|
+
n.postMessage(e);
|
|
780
|
+
} catch {}
|
|
781
|
+
n.close();
|
|
782
|
+
}, u = async () => {
|
|
783
|
+
if (!(s || c)) {
|
|
784
|
+
for (s = !0; o > 0;) {
|
|
785
|
+
let e;
|
|
786
|
+
try {
|
|
787
|
+
e = await i.read();
|
|
788
|
+
} catch (e) {
|
|
789
|
+
c || l({
|
|
790
|
+
type: "error",
|
|
791
|
+
error: e
|
|
792
|
+
});
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
if (c) return;
|
|
796
|
+
if (e.done) {
|
|
797
|
+
l({ type: "end" });
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
o--;
|
|
801
|
+
let t = a ? rt(e.value) : e.value;
|
|
802
|
+
try {
|
|
803
|
+
n.postMessage({
|
|
804
|
+
type: "chunk",
|
|
805
|
+
value: t
|
|
806
|
+
});
|
|
807
|
+
} catch (e) {
|
|
808
|
+
l({
|
|
809
|
+
type: "error",
|
|
810
|
+
error: e
|
|
811
|
+
}), i.cancel(e).catch(() => {});
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
s = !1;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
return n.addEventListener("message", ({ data: e }) => {
|
|
819
|
+
e instanceof Promise || !("type" in e) || (e.type === "pull" ? n.postMessage(i.read()) : e.type === "credit" ? (o += e.n, u()) : e.type === "cancel" && (c = !0, i.cancel(e.reason).catch(() => {}), n.close()));
|
|
820
|
+
}), n.addEventListener("close", () => {
|
|
821
|
+
c || (c = !0, i.cancel(/* @__PURE__ */ Error("osra: connection closed")).catch(() => {}));
|
|
822
|
+
}, { once: !0 }), n.start(), {
|
|
823
|
+
...j,
|
|
824
|
+
type: Kt,
|
|
825
|
+
credit: !0,
|
|
826
|
+
port: r
|
|
827
|
+
};
|
|
828
|
+
}, Qt = (e) => ArrayBuffer.isView(e) || e instanceof ArrayBuffer ? e.byteLength : typeof e == "string" ? e.length * 2 : typeof Blob < "u" && e instanceof Blob ? e.size : void 0, $t = (e) => {
|
|
829
|
+
let t = !1, n = 0, r, i = [], a = !1, o = !1, s, c, l = () => r === void 0 ? Yt : Math.max(Jt, Math.min(64, Math.floor(Xt / r))), u = () => {
|
|
830
|
+
let t = l(), r = n + i.length;
|
|
831
|
+
if (r > t / 2) return;
|
|
832
|
+
let a = t - r;
|
|
833
|
+
n += a, e.postMessage({
|
|
834
|
+
type: "credit",
|
|
835
|
+
n: a
|
|
836
|
+
});
|
|
837
|
+
}, d = () => {
|
|
838
|
+
t = !0, queueMicrotask(() => e.close());
|
|
839
|
+
}, f = (e) => {
|
|
840
|
+
if (o = !0, s = e, !c || i.length) return;
|
|
841
|
+
let t = c;
|
|
842
|
+
c = void 0, d(), t.reject(e);
|
|
843
|
+
};
|
|
844
|
+
return new ReadableStream({
|
|
845
|
+
start: () => {
|
|
846
|
+
e.addEventListener("message", ({ data: o }) => {
|
|
847
|
+
if (!(o instanceof Promise || !("type" in o))) {
|
|
848
|
+
if (o.type === "chunk") {
|
|
849
|
+
if (t) return;
|
|
850
|
+
if (n <= 0) {
|
|
851
|
+
i.length = 0, f(/* @__PURE__ */ Error("osra: stream exceeded its credit window")), queueMicrotask(() => e.close());
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
n--;
|
|
855
|
+
let a = Qt(o.value);
|
|
856
|
+
if (a !== void 0 && (r = r === void 0 ? a : r * .875 + a * .125), c) {
|
|
857
|
+
let e = c;
|
|
858
|
+
c = void 0, e.controller.enqueue(o.value), e.resolve();
|
|
859
|
+
} else i.push(o.value);
|
|
860
|
+
} else if (o.type === "end") {
|
|
861
|
+
if (t || (a = !0, !c || i.length)) return;
|
|
862
|
+
let e = c;
|
|
863
|
+
c = void 0, d(), e.controller.close(), e.resolve();
|
|
864
|
+
} else if (o.type === "error") {
|
|
865
|
+
if (t) return;
|
|
866
|
+
f(o.error);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}), e.addEventListener("messageerror", () => {
|
|
870
|
+
t || f(/* @__PURE__ */ Error("osra: a chunk failed to deserialize on this platform"));
|
|
871
|
+
}), e.addEventListener("close", () => {
|
|
872
|
+
t || a || o || f(/* @__PURE__ */ Error("osra: connection closed"));
|
|
873
|
+
}, { once: !0 });
|
|
874
|
+
},
|
|
875
|
+
pull: (e) => {
|
|
876
|
+
if (!t) {
|
|
877
|
+
if (i.length) {
|
|
878
|
+
e.enqueue(i.shift()), !a && !o && u();
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
if (o) return d(), Promise.reject(s);
|
|
882
|
+
if (a) {
|
|
883
|
+
d(), e.close();
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
return u(), new Promise((t, n) => {
|
|
887
|
+
c = {
|
|
888
|
+
controller: e,
|
|
889
|
+
resolve: t,
|
|
890
|
+
reject: n
|
|
891
|
+
};
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
cancel: (n) => {
|
|
896
|
+
t = !0, i.length = 0;
|
|
897
|
+
let r = c;
|
|
898
|
+
c = void 0, r?.resolve(), e.postMessage({
|
|
899
|
+
type: "cancel",
|
|
900
|
+
reason: n
|
|
901
|
+
}), queueMicrotask(() => e.close());
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
}, en = (e) => {
|
|
905
|
+
let t = !1;
|
|
906
|
+
return new ReadableStream({
|
|
907
|
+
start: (n) => {
|
|
908
|
+
e.addEventListener("messageerror", () => {
|
|
909
|
+
if (!t) {
|
|
910
|
+
t = !0;
|
|
911
|
+
try {
|
|
912
|
+
n.error(/* @__PURE__ */ Error("osra: a chunk failed to deserialize on this platform"));
|
|
913
|
+
} catch {}
|
|
914
|
+
queueMicrotask(() => e.close());
|
|
915
|
+
}
|
|
916
|
+
}), e.addEventListener("close", () => {
|
|
917
|
+
if (!t) {
|
|
918
|
+
t = !0;
|
|
919
|
+
try {
|
|
920
|
+
n.error(/* @__PURE__ */ Error("osra: connection closed"));
|
|
921
|
+
} catch {}
|
|
922
|
+
}
|
|
923
|
+
}, { once: !0 });
|
|
924
|
+
},
|
|
925
|
+
pull: (n) => new Promise((r, i) => {
|
|
926
|
+
e.addEventListener("message", ({ data: a }) => {
|
|
927
|
+
a instanceof Promise && a.then((i) => {
|
|
928
|
+
i.done ? (t = !0, n.close(), e.postMessage({ type: "cancel" }), queueMicrotask(() => e.close())) : n.enqueue(i.value), r();
|
|
929
|
+
}).catch((e) => {
|
|
930
|
+
t = !0, i(e);
|
|
931
|
+
});
|
|
932
|
+
}, { once: !0 }), e.postMessage({ type: "pull" });
|
|
933
|
+
}),
|
|
934
|
+
cancel: (n) => {
|
|
935
|
+
t = !0, e.postMessage({
|
|
936
|
+
type: "cancel",
|
|
937
|
+
reason: n
|
|
938
|
+
}), queueMicrotask(() => e.close());
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
}, tn = (e, t) => {
|
|
942
|
+
let n = W(e.port, t);
|
|
943
|
+
return n.start(), e.credit ? $t(n) : en(n);
|
|
944
|
+
}, nn = /* @__PURE__ */ t({
|
|
945
|
+
box: () => on,
|
|
946
|
+
isType: () => an,
|
|
947
|
+
objectsOnly: () => !0,
|
|
948
|
+
revive: () => sn,
|
|
949
|
+
type: () => rn
|
|
950
|
+
}), rn = "writableStream", an = (e) => e instanceof WritableStream, on = (e, t) => {
|
|
951
|
+
let { localPort: n, boxedRemote: r } = K(t), i = e.getWriter(), a = !1, o = (e, t) => e.then(() => n.postMessage({ type: "ack" })).catch((e) => n.postMessage({
|
|
952
|
+
type: "err",
|
|
953
|
+
error: e?.message ?? String(e)
|
|
954
|
+
})).then(() => {
|
|
955
|
+
t && (a = !0, queueMicrotask(() => n.close()));
|
|
956
|
+
});
|
|
957
|
+
return n.addEventListener("message", ({ data: e }) => {
|
|
958
|
+
!e || typeof e != "object" || !("type" in e) || (e.type === "write" ? o(i.write(e.chunk), !1) : e.type === "close" ? o(i.close(), !0) : e.type === "abort" && o(i.abort(e.reason), !0));
|
|
959
|
+
}), n.addEventListener("messageerror", () => {
|
|
960
|
+
n.postMessage({
|
|
961
|
+
type: "err",
|
|
962
|
+
error: "osra: a chunk failed to deserialize on this platform"
|
|
963
|
+
});
|
|
964
|
+
}), n.addEventListener("close", () => {
|
|
965
|
+
a || (a = !0, i.abort(/* @__PURE__ */ Error("osra: connection closed")).catch(() => {}));
|
|
966
|
+
}, { once: !0 }), n.start(), {
|
|
967
|
+
...j,
|
|
968
|
+
type: rn,
|
|
969
|
+
port: r,
|
|
970
|
+
...nt() ? { transferChunks: !0 } : {}
|
|
971
|
+
};
|
|
972
|
+
}, sn = (e, t) => {
|
|
973
|
+
let n = W(e.port, t);
|
|
974
|
+
n.start();
|
|
975
|
+
let r = /* @__PURE__ */ new Set(), i = !1;
|
|
976
|
+
n.addEventListener("close", () => {
|
|
977
|
+
i = !0;
|
|
978
|
+
let e = /* @__PURE__ */ Error("osra: connection closed");
|
|
979
|
+
for (let t of [...r]) t(e);
|
|
980
|
+
r.clear();
|
|
981
|
+
}, { once: !0 });
|
|
982
|
+
let a = Promise.resolve(), o = (e) => {
|
|
983
|
+
let t = a.then(() => new Promise((t, a) => {
|
|
984
|
+
if (i) {
|
|
985
|
+
a(/* @__PURE__ */ Error("osra: connection closed"));
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
let o = (e) => {
|
|
989
|
+
r.delete(a), e();
|
|
990
|
+
};
|
|
991
|
+
r.add(a), n.addEventListener("message", ({ data: e }) => {
|
|
992
|
+
!e || typeof e != "object" || !("type" in e) || (e.type === "ack" ? o(t) : e.type === "err" && o(() => a(Error(e.error))));
|
|
993
|
+
}, { once: !0 }), n.postMessage(e);
|
|
994
|
+
}));
|
|
995
|
+
return a = t.catch(() => {}), t;
|
|
996
|
+
}, s = e.transferChunks === !0;
|
|
997
|
+
return new WritableStream({
|
|
998
|
+
write: (e) => o({
|
|
999
|
+
type: "write",
|
|
1000
|
+
chunk: s ? rt(e) : e
|
|
1001
|
+
}),
|
|
1002
|
+
close: () => o({ type: "close" }),
|
|
1003
|
+
abort: (e) => o({
|
|
1004
|
+
type: "abort",
|
|
1005
|
+
reason: e
|
|
1006
|
+
})
|
|
1007
|
+
});
|
|
1008
|
+
}, cn = /* @__PURE__ */ t({
|
|
1009
|
+
box: () => fn,
|
|
1010
|
+
isType: () => un,
|
|
1011
|
+
objectsOnly: () => !0,
|
|
1012
|
+
revive: () => pn,
|
|
1013
|
+
type: () => ln
|
|
1014
|
+
}), ln = "abortSignal", un = (e) => e instanceof AbortSignal, dn = /* @__PURE__ */ new WeakMap(), fn = (e, t) => {
|
|
1015
|
+
if (e.aborted) return {
|
|
1016
|
+
...j,
|
|
1017
|
+
type: ln,
|
|
1018
|
+
aborted: !0,
|
|
1019
|
+
reason: Q(e.reason, t)
|
|
1020
|
+
};
|
|
1021
|
+
let { localPort: n, boxedRemote: r } = K(t), i = () => {
|
|
1022
|
+
n.postMessage({
|
|
1023
|
+
type: "abort",
|
|
1024
|
+
reason: e.reason
|
|
1025
|
+
}), n.close(), a();
|
|
1026
|
+
}, a = M(t, () => {
|
|
1027
|
+
e.removeEventListener("abort", i), n.close();
|
|
1028
|
+
});
|
|
1029
|
+
return e.addEventListener("abort", i, { once: !0 }), {
|
|
1030
|
+
...j,
|
|
1031
|
+
type: ln,
|
|
1032
|
+
aborted: !1,
|
|
1033
|
+
reason: void 0,
|
|
1034
|
+
port: r
|
|
1035
|
+
};
|
|
1036
|
+
}, pn = (e, t) => {
|
|
1037
|
+
let n = new AbortController();
|
|
1038
|
+
if (e.aborted || e.port === void 0) return n.abort($(e.reason, t)), n.signal;
|
|
1039
|
+
let r = W(e.port, t);
|
|
1040
|
+
return dn.set(n.signal, r), r.start(), r.addEventListener("message", ({ data: e }) => {
|
|
1041
|
+
e.type === "abort" && (n.abort($(e.reason, t)), dn.delete(n.signal), r.close());
|
|
1042
|
+
}), n.signal;
|
|
1043
|
+
}, mn = /* @__PURE__ */ t({
|
|
1044
|
+
box: () => _n,
|
|
1045
|
+
isType: () => gn,
|
|
1046
|
+
objectsOnly: () => !0,
|
|
1047
|
+
revive: () => vn,
|
|
1048
|
+
type: () => hn
|
|
1049
|
+
}), hn = "response", gn = (e) => e instanceof Response, _n = (e, t) => ({
|
|
1050
|
+
...j,
|
|
1051
|
+
type: hn,
|
|
1052
|
+
status: e.status,
|
|
1053
|
+
statusText: e.statusText,
|
|
1054
|
+
headers: Pe(e.headers, t),
|
|
1055
|
+
body: e.body ? Zt(e.body, t) : null,
|
|
1056
|
+
url: e.url,
|
|
1057
|
+
redirected: e.redirected
|
|
1058
|
+
}), vn = (e, t) => {
|
|
1059
|
+
if (e.status === 0) return Response.error();
|
|
1060
|
+
let n = Fe(e.headers, t), r = e.body ? tn(e.body, t) : null, i = e.status === 101 || e.status === 204 || e.status === 205 || e.status === 304;
|
|
1061
|
+
r && i && r.cancel().catch(() => {});
|
|
1062
|
+
let a = new Response(i ? null : r, {
|
|
1063
|
+
status: e.status,
|
|
1064
|
+
statusText: e.statusText,
|
|
1065
|
+
headers: n
|
|
1066
|
+
});
|
|
1067
|
+
return e.url && Object.defineProperty(a, "url", {
|
|
1068
|
+
value: e.url,
|
|
1069
|
+
configurable: !0
|
|
1070
|
+
}), e.redirected && Object.defineProperty(a, "redirected", {
|
|
1071
|
+
value: !0,
|
|
1072
|
+
configurable: !0
|
|
1073
|
+
}), a;
|
|
1074
|
+
}, yn = /* @__PURE__ */ t({
|
|
1075
|
+
box: () => Sn,
|
|
1076
|
+
isType: () => xn,
|
|
1077
|
+
objectsOnly: () => !0,
|
|
1078
|
+
revive: () => Cn,
|
|
1079
|
+
type: () => bn
|
|
1080
|
+
}), bn = "request", xn = (e) => e instanceof Request, Sn = (e, t) => ({
|
|
1081
|
+
...j,
|
|
1082
|
+
type: bn,
|
|
1083
|
+
method: e.method,
|
|
1084
|
+
url: e.url,
|
|
1085
|
+
headers: Pe(e.headers, t),
|
|
1086
|
+
body: e.body ? Zt(e.body, t) : null,
|
|
1087
|
+
credentials: e.credentials,
|
|
1088
|
+
cache: e.cache,
|
|
1089
|
+
mode: e.mode,
|
|
1090
|
+
redirect: e.redirect,
|
|
1091
|
+
referrer: e.referrer,
|
|
1092
|
+
referrerPolicy: e.referrerPolicy,
|
|
1093
|
+
integrity: e.integrity,
|
|
1094
|
+
keepalive: e.keepalive,
|
|
1095
|
+
signal: fn(e.signal, t)
|
|
1096
|
+
}), Cn = (e, t) => {
|
|
1097
|
+
let n = Fe(e.headers, t), r = {
|
|
1098
|
+
method: e.method,
|
|
1099
|
+
headers: n,
|
|
1100
|
+
credentials: e.credentials,
|
|
1101
|
+
cache: e.cache,
|
|
1102
|
+
redirect: e.redirect,
|
|
1103
|
+
referrer: e.referrer,
|
|
1104
|
+
referrerPolicy: e.referrerPolicy,
|
|
1105
|
+
integrity: e.integrity,
|
|
1106
|
+
keepalive: e.keepalive,
|
|
1107
|
+
signal: pn(e.signal, t)
|
|
1108
|
+
};
|
|
1109
|
+
return e.mode !== "navigate" && (r.mode = e.mode), e.body && (r.body = tn(e.body, t), r.duplex = "half"), new Request(e.url, r);
|
|
1110
|
+
}, wn = /* @__PURE__ */ t({
|
|
1111
|
+
box: () => Pn,
|
|
1112
|
+
boxByReference: () => Fn,
|
|
1113
|
+
identity: () => On,
|
|
1114
|
+
isType: () => jn,
|
|
1115
|
+
objectsOnly: () => !0,
|
|
1116
|
+
revive: () => In,
|
|
1117
|
+
type: () => Y
|
|
1118
|
+
}), Y = "identity", Tn = (e) => e !== null && (typeof e == "object" || typeof e == "function"), En = (e) => {
|
|
1119
|
+
if (e === null) return !1;
|
|
1120
|
+
let t = typeof e;
|
|
1121
|
+
return t === "object" || t === "function" ? !0 : t === "symbol" ? Symbol.keyFor(e) === void 0 : !1;
|
|
1122
|
+
}, X = /* @__PURE__ */ new WeakMap(), Dn = (e) => {
|
|
1123
|
+
let t = X.get(e);
|
|
1124
|
+
if (t !== void 0) return t;
|
|
1125
|
+
let n = globalThis.crypto.randomUUID();
|
|
1126
|
+
return X.set(e, n), n;
|
|
1127
|
+
}, On = (e) => (Tn(e) && Dn(e), e), kn = /* @__PURE__ */ new WeakMap(), An = (e) => {
|
|
1128
|
+
let t = kn.get(e);
|
|
1129
|
+
if (t) return t;
|
|
1130
|
+
let n = /* @__PURE__ */ new Map(), r = {
|
|
1131
|
+
idToLocal: n,
|
|
1132
|
+
pins: /* @__PURE__ */ new Map(),
|
|
1133
|
+
aliasIds: /* @__PURE__ */ new WeakMap(),
|
|
1134
|
+
disposeRegistry: new FinalizationRegistry((t) => {
|
|
1135
|
+
if (n.delete(t), !N(e)) try {
|
|
1136
|
+
e.sendMessage({
|
|
1137
|
+
type: "identity-dispose",
|
|
1138
|
+
remoteUuid: e.remoteUuid,
|
|
1139
|
+
id: t
|
|
1140
|
+
});
|
|
1141
|
+
} catch {}
|
|
1142
|
+
})
|
|
1143
|
+
};
|
|
1144
|
+
return kn.set(e, r), e.eventTarget.addEventListener("message", ({ detail: e }) => {
|
|
1145
|
+
e?.type === "identity-dispose" && (r.pins.delete(e.id), r.idToLocal.delete(e.id));
|
|
1146
|
+
}), M(e, () => {
|
|
1147
|
+
r.pins.clear(), r.idToLocal.clear();
|
|
1148
|
+
}), r;
|
|
1149
|
+
}, jn = (e) => Tn(e) && X.has(e), Mn = (e, t) => {
|
|
1150
|
+
let n = t.aliasIds.get(e);
|
|
1151
|
+
if (n !== void 0) return n;
|
|
1152
|
+
let r = Dn(e), i = t.idToLocal.get(r);
|
|
1153
|
+
if (i === void 0 || i.deref() === e) return r;
|
|
1154
|
+
let a = globalThis.crypto.randomUUID();
|
|
1155
|
+
return t.aliasIds.set(e, a), a;
|
|
1156
|
+
}, Nn = (e, t, n) => {
|
|
1157
|
+
let r = Mn(e, n);
|
|
1158
|
+
if (n.idToLocal.has(r)) return {
|
|
1159
|
+
...j,
|
|
1160
|
+
type: Y,
|
|
1161
|
+
id: r
|
|
1162
|
+
};
|
|
1163
|
+
let i = t();
|
|
1164
|
+
return n.idToLocal.set(r, new WeakRef(e)), n.disposeRegistry.register(e, r, e), Pr(() => {}, () => {
|
|
1165
|
+
n.idToLocal.delete(r), n.disposeRegistry.unregister(e);
|
|
1166
|
+
}), {
|
|
1167
|
+
...j,
|
|
1168
|
+
type: Y,
|
|
1169
|
+
id: r,
|
|
1170
|
+
inner: i
|
|
1171
|
+
};
|
|
1172
|
+
}, Pn = (e, t) => {
|
|
1173
|
+
let n = An(t), r = () => Br(e, t, Y);
|
|
1174
|
+
return En(e) ? Nn(e, r, n) : {
|
|
1175
|
+
...j,
|
|
1176
|
+
type: Y,
|
|
1177
|
+
id: globalThis.crypto.randomUUID(),
|
|
1178
|
+
inner: r()
|
|
1179
|
+
};
|
|
1180
|
+
}, Fn = (e, t, n) => Nn(e, () => t, An(n)), In = (e, t) => {
|
|
1181
|
+
let n = An(t);
|
|
1182
|
+
if (n.pins.has(e.id)) return n.pins.get(e.id);
|
|
1183
|
+
let r = n.idToLocal.get(e.id)?.deref();
|
|
1184
|
+
if (r !== void 0) return r;
|
|
1185
|
+
if (!("inner" in e) || e.inner === void 0) {
|
|
1186
|
+
try {
|
|
1187
|
+
t.sendMessage({
|
|
1188
|
+
type: "identity-dispose",
|
|
1189
|
+
remoteUuid: t.remoteUuid,
|
|
1190
|
+
id: e.id
|
|
1191
|
+
});
|
|
1192
|
+
} catch {}
|
|
1193
|
+
throw Error(`osra identity: received id=${e.id} with no inner payload and nothing local to resolve it to`);
|
|
1194
|
+
}
|
|
1195
|
+
let i = $(e.inner, t);
|
|
1196
|
+
return n.pins.set(e.id, i), En(i) && (X.has(i) || X.set(i, e.id), n.idToLocal.set(e.id, new WeakRef(i))), i;
|
|
1197
|
+
}, Ln = /* @__PURE__ */ t({
|
|
1198
|
+
box: () => zn,
|
|
1199
|
+
isType: () => Rn,
|
|
1200
|
+
objectsOnly: () => !0,
|
|
1201
|
+
revive: () => Bn,
|
|
1202
|
+
type: () => "map"
|
|
1203
|
+
}), Rn = (e) => e instanceof Map, zn = (e, t) => ({
|
|
1204
|
+
...j,
|
|
1205
|
+
type: "map",
|
|
1206
|
+
entries: Array.from(e, ([e, n]) => [Q(e, t), Q(n, t)])
|
|
1207
|
+
}), Bn = (e, t) => new Map(e.entries.map(([e, n]) => [$(e, t), $(n, t)])), Vn = /* @__PURE__ */ t({
|
|
1208
|
+
box: () => Un,
|
|
1209
|
+
isType: () => Hn,
|
|
1210
|
+
objectsOnly: () => !0,
|
|
1211
|
+
revive: () => Wn,
|
|
1212
|
+
type: () => "set"
|
|
1213
|
+
}), Hn = (e) => e instanceof Set, Un = (e, t) => ({
|
|
1214
|
+
...j,
|
|
1215
|
+
type: "set",
|
|
1216
|
+
values: Array.from(e, (e) => Q(e, t))
|
|
1217
|
+
}), Wn = (e, t) => new Set(e.values.map((e) => $(e, t))), Gn = /* @__PURE__ */ t({
|
|
1218
|
+
box: () => Jn,
|
|
1219
|
+
isType: () => qn,
|
|
1220
|
+
revive: () => Yn,
|
|
1221
|
+
type: () => Kn
|
|
1222
|
+
}), Kn = "bigint", qn = (e) => typeof e == "bigint", Jn = (e, t) => ({
|
|
1223
|
+
...j,
|
|
1224
|
+
type: Kn,
|
|
1225
|
+
value: e.toString()
|
|
1226
|
+
}), Yn = (e, t) => BigInt(e.value), Xn = /* @__PURE__ */ t({
|
|
1227
|
+
box: () => $n,
|
|
1228
|
+
isType: () => Qn,
|
|
1229
|
+
objectsOnly: () => !0,
|
|
1230
|
+
revive: () => er,
|
|
1231
|
+
type: () => Zn
|
|
1232
|
+
}), Zn = "event", Qn = (e) => e instanceof Event, $n = (e, t) => ({
|
|
1233
|
+
...j,
|
|
1234
|
+
type: Zn,
|
|
1235
|
+
eventType: e.type,
|
|
1236
|
+
bubbles: e.bubbles,
|
|
1237
|
+
cancelable: e.cancelable,
|
|
1238
|
+
composed: e.composed,
|
|
1239
|
+
...e instanceof CustomEvent ? { detail: Q(e.detail, t) } : {}
|
|
1240
|
+
}), er = (e, t) => {
|
|
1241
|
+
let n = {
|
|
1242
|
+
bubbles: e.bubbles,
|
|
1243
|
+
cancelable: e.cancelable,
|
|
1244
|
+
composed: e.composed
|
|
1245
|
+
};
|
|
1246
|
+
return "detail" in e ? new CustomEvent(e.eventType, {
|
|
1247
|
+
...n,
|
|
1248
|
+
detail: $(e.detail, t)
|
|
1249
|
+
}) : new Event(e.eventType, n);
|
|
1250
|
+
}, tr = /* @__PURE__ */ t({
|
|
1251
|
+
box: () => ir,
|
|
1252
|
+
isType: () => rr,
|
|
1253
|
+
objectsOnly: () => !0,
|
|
1254
|
+
revive: () => cr,
|
|
1255
|
+
type: () => nr
|
|
1256
|
+
}), nr = "eventTarget", rr = (e) => e instanceof EventTarget, ir = (e, t) => {
|
|
1257
|
+
let n = [], r = (e) => typeof e == "boolean" ? e : !!e?.capture;
|
|
1258
|
+
return {
|
|
1259
|
+
...j,
|
|
1260
|
+
type: nr,
|
|
1261
|
+
addListener: q((t, i, a) => {
|
|
1262
|
+
n.push({
|
|
1263
|
+
eventType: t,
|
|
1264
|
+
listener: i,
|
|
1265
|
+
capture: r(a)
|
|
1266
|
+
}), e.addEventListener(t, i, a);
|
|
1267
|
+
}, t),
|
|
1268
|
+
removeListener: q((t, i, a) => {
|
|
1269
|
+
let o = r(a), s = n.findIndex((e) => e.eventType === t && e.listener === i && e.capture === o);
|
|
1270
|
+
s !== -1 && n.splice(s, 1), e.removeEventListener(t, i, a);
|
|
1271
|
+
}, t),
|
|
1272
|
+
removeAllListeners: q(() => {
|
|
1273
|
+
for (let { eventType: t, listener: r, capture: i } of n.splice(0)) e.removeEventListener(t, r, { capture: i });
|
|
1274
|
+
}, t)
|
|
1275
|
+
};
|
|
1276
|
+
}, ar = /* @__PURE__ */ new WeakMap(), or = (e) => {
|
|
1277
|
+
if (typeof e == "function") return e;
|
|
1278
|
+
let t = ar.get(e);
|
|
1279
|
+
return t || ar.set(e, t = (t) => e.handleEvent(t)), t;
|
|
1280
|
+
}, sr = (e, t, n, r) => e.find((e) => e.eventType === t && e.listener === n && e.capture === r), cr = (e, t) => {
|
|
1281
|
+
let n = J(e.addListener, t), r = J(e.removeListener, t), i = J(e.removeAllListeners, t), a = new EventTarget(), o = [], s = (e) => {
|
|
1282
|
+
let t = o.indexOf(e);
|
|
1283
|
+
t !== -1 && o.splice(t, 1);
|
|
1284
|
+
};
|
|
1285
|
+
return Object.defineProperty(a, "addEventListener", { value: (e, t, r) => {
|
|
1286
|
+
if (t === null) return;
|
|
1287
|
+
let i = or(t), a = typeof r == "boolean" ? r : !!r?.capture;
|
|
1288
|
+
if (sr(o, e, i, a)) return;
|
|
1289
|
+
let c = typeof r == "object" && r?.once ? (e) => (s(l), i(e)) : i, l = {
|
|
1290
|
+
eventType: e,
|
|
1291
|
+
listener: i,
|
|
1292
|
+
capture: a,
|
|
1293
|
+
wire: c
|
|
1294
|
+
};
|
|
1295
|
+
o.push(l), (typeof r == "object" ? r?.signal : void 0)?.addEventListener("abort", () => s(l), { once: !0 }), n(e, On(c), r).catch(() => {});
|
|
1296
|
+
} }), Object.defineProperty(a, "removeEventListener", { value: (e, t, n) => {
|
|
1297
|
+
if (t === null) return;
|
|
1298
|
+
let i = or(t), a = typeof n == "boolean" ? n : !!n?.capture, c = sr(o, e, i, a);
|
|
1299
|
+
c && (s(c), r(e, On(c.wire), { capture: a }).catch(() => {}));
|
|
1300
|
+
} }), ut(a, () => {
|
|
1301
|
+
i().catch(() => {});
|
|
1302
|
+
}), a;
|
|
1303
|
+
}, lr = /* @__PURE__ */ t({
|
|
1304
|
+
box: () => fr,
|
|
1305
|
+
isType: () => dr,
|
|
1306
|
+
revive: () => pr,
|
|
1307
|
+
type: () => ur
|
|
1308
|
+
}), ur = "symbol", dr = (e) => typeof e == "symbol", fr = (e, t) => {
|
|
1309
|
+
let n = Symbol.keyFor(e);
|
|
1310
|
+
return n === void 0 ? Fn(e, {
|
|
1311
|
+
...j,
|
|
1312
|
+
type: ur,
|
|
1313
|
+
description: e.description
|
|
1314
|
+
}, t) : {
|
|
1315
|
+
...j,
|
|
1316
|
+
type: ur,
|
|
1317
|
+
registryKey: n
|
|
1318
|
+
};
|
|
1319
|
+
}, pr = (e, t) => "registryKey" in e ? Symbol.for(e.registryKey) : Symbol(e.description), mr = /* @__PURE__ */ t({
|
|
1320
|
+
box: () => _r,
|
|
1321
|
+
isType: () => gr,
|
|
1322
|
+
objectsOnly: () => !0,
|
|
1323
|
+
revive: () => vr,
|
|
1324
|
+
type: () => hr
|
|
1325
|
+
}), hr = "asyncIterator", gr = (e) => !e || typeof e != "object" || typeof ReadableStream < "u" && e instanceof ReadableStream ? !1 : typeof e[Symbol.asyncIterator] == "function", _r = (e, t) => {
|
|
1326
|
+
let n = e[Symbol.asyncIterator]();
|
|
1327
|
+
return {
|
|
1328
|
+
...j,
|
|
1329
|
+
type: hr,
|
|
1330
|
+
next: q(((e) => n.next(e)), t),
|
|
1331
|
+
return: q(((e) => n.return?.(e) ?? Promise.resolve({
|
|
1332
|
+
done: !0,
|
|
1333
|
+
value: e
|
|
1334
|
+
})), t),
|
|
1335
|
+
throw: q(((e) => n.throw?.(e) ?? Promise.reject(e)), t)
|
|
1336
|
+
};
|
|
1337
|
+
}, vr = (e, t) => {
|
|
1338
|
+
let n = J(e.next, t), r = J(e.return, t), i = J(e.throw, t), a = {
|
|
1339
|
+
next: (...e) => n(...e),
|
|
1340
|
+
return: (e) => r(e),
|
|
1341
|
+
throw: (e) => i(e),
|
|
1342
|
+
[Symbol.asyncIterator]: () => a
|
|
1343
|
+
};
|
|
1344
|
+
return a;
|
|
1345
|
+
}, yr = [
|
|
1346
|
+
globalThis.File,
|
|
1347
|
+
globalThis.FileList,
|
|
1348
|
+
globalThis.RegExp,
|
|
1349
|
+
globalThis.DataView,
|
|
1350
|
+
globalThis.ImageData,
|
|
1351
|
+
globalThis.FormData,
|
|
1352
|
+
globalThis.DOMException,
|
|
1353
|
+
globalThis.DOMMatrix,
|
|
1354
|
+
globalThis.DOMMatrixReadOnly,
|
|
1355
|
+
globalThis.DOMPoint,
|
|
1356
|
+
globalThis.DOMPointReadOnly,
|
|
1357
|
+
globalThis.DOMQuad,
|
|
1358
|
+
globalThis.DOMRect,
|
|
1359
|
+
globalThis.DOMRectReadOnly,
|
|
1360
|
+
globalThis.CryptoKey,
|
|
1361
|
+
globalThis.FileSystemHandle,
|
|
1362
|
+
globalThis.FileSystemFileHandle,
|
|
1363
|
+
globalThis.FileSystemDirectoryHandle,
|
|
1364
|
+
globalThis.RTCCertificate
|
|
1365
|
+
], br = [
|
|
1366
|
+
globalThis.CropTarget,
|
|
1367
|
+
globalThis.EncodedAudioChunk,
|
|
1368
|
+
globalThis.EncodedVideoChunk,
|
|
1369
|
+
globalThis.FencedFrameConfig,
|
|
1370
|
+
globalThis.GPUCompilationInfo,
|
|
1371
|
+
globalThis.GPUCompilationMessage,
|
|
1372
|
+
globalThis.GPUPipelineError,
|
|
1373
|
+
globalThis.RTCEncodedAudioFrame,
|
|
1374
|
+
globalThis.RTCEncodedVideoFrame,
|
|
1375
|
+
globalThis.WebTransportError
|
|
1376
|
+
], xr = {
|
|
1377
|
+
type: "clonable",
|
|
1378
|
+
capableOnly: !0,
|
|
1379
|
+
objectsOnly: !0,
|
|
1380
|
+
isType: (e) => w(e, yr) || w(e, br),
|
|
1381
|
+
box: (e, t) => e,
|
|
1382
|
+
revive: (e, t) => e
|
|
1383
|
+
}, Sr = [
|
|
1384
|
+
globalThis.ImageBitmap,
|
|
1385
|
+
globalThis.OffscreenCanvas,
|
|
1386
|
+
globalThis.WritableStream,
|
|
1387
|
+
globalThis.TransformStream,
|
|
1388
|
+
globalThis.MediaStreamTrack,
|
|
1389
|
+
globalThis.RTCDataChannel
|
|
1390
|
+
], Cr = [
|
|
1391
|
+
globalThis.AudioData,
|
|
1392
|
+
globalThis.VideoFrame,
|
|
1393
|
+
globalThis.MediaSourceHandle,
|
|
1394
|
+
globalThis.MIDIAccess,
|
|
1395
|
+
globalThis.WebTransportReceiveStream,
|
|
1396
|
+
globalThis.WebTransportSendStream
|
|
1397
|
+
], wr = {
|
|
1398
|
+
type: "transferable",
|
|
1399
|
+
capableOnly: !0,
|
|
1400
|
+
objectsOnly: !0,
|
|
1401
|
+
isType: (e) => w(e, Sr) || w(e, Cr),
|
|
1402
|
+
box: (e, t) => e,
|
|
1403
|
+
revive: (e, t) => e
|
|
1404
|
+
}, Tr = {
|
|
1405
|
+
type: "blob",
|
|
1406
|
+
capableOnly: !0,
|
|
1407
|
+
objectsOnly: !0,
|
|
1408
|
+
isType: (e) => typeof Blob < "u" && e instanceof Blob,
|
|
1409
|
+
box: (e, t) => {
|
|
1410
|
+
if (O(t.transport)) throw TypeError("osra: Blob is only supported on structured-clone transports, send an ArrayBuffer or Uint8Array instead");
|
|
1411
|
+
return e;
|
|
1412
|
+
},
|
|
1413
|
+
revive: (e, t) => e
|
|
1414
|
+
}, Er = (e) => {
|
|
1415
|
+
if (typeof e != "object" || !e) return !1;
|
|
1416
|
+
let t = Object.getPrototypeOf(e);
|
|
1417
|
+
return t === Object.prototype || t === null;
|
|
1418
|
+
}, Dr = [
|
|
1419
|
+
Xe,
|
|
1420
|
+
wn,
|
|
1421
|
+
xe,
|
|
1422
|
+
Ee,
|
|
1423
|
+
je,
|
|
1424
|
+
Ie,
|
|
1425
|
+
He,
|
|
1426
|
+
Nt,
|
|
1427
|
+
Bt,
|
|
1428
|
+
dt,
|
|
1429
|
+
Gt,
|
|
1430
|
+
nn,
|
|
1431
|
+
cn,
|
|
1432
|
+
mn,
|
|
1433
|
+
yn,
|
|
1434
|
+
Ln,
|
|
1435
|
+
Vn,
|
|
1436
|
+
Gn,
|
|
1437
|
+
lr,
|
|
1438
|
+
Xn,
|
|
1439
|
+
mr,
|
|
1440
|
+
{
|
|
1441
|
+
type: "nonFiniteNumber",
|
|
1442
|
+
isType: (e) => typeof e == "number" && !Number.isFinite(e),
|
|
1443
|
+
box: (e, t) => O(t.transport) ? {
|
|
1444
|
+
...j,
|
|
1445
|
+
type: "nonFiniteNumber",
|
|
1446
|
+
value: String(e)
|
|
1447
|
+
} : e,
|
|
1448
|
+
revive: (e, t) => Number(e.value)
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
type: "undefined",
|
|
1452
|
+
isType: (e) => e === void 0,
|
|
1453
|
+
box: (e, t) => O(t.transport) ? {
|
|
1454
|
+
...j,
|
|
1455
|
+
type: "undefined"
|
|
1456
|
+
} : e,
|
|
1457
|
+
revive: (e, t) => void 0
|
|
1458
|
+
},
|
|
1459
|
+
xr,
|
|
1460
|
+
wr,
|
|
1461
|
+
Tr,
|
|
1462
|
+
tr,
|
|
1463
|
+
{
|
|
1464
|
+
type: "unclonable",
|
|
1465
|
+
objectsOnly: !0,
|
|
1466
|
+
isType: (e) => {
|
|
1467
|
+
if (typeof e != "object" || !e || Array.isArray(e) || Er(e)) return !1;
|
|
1468
|
+
try {
|
|
1469
|
+
return structuredClone(e), !1;
|
|
1470
|
+
} catch {
|
|
1471
|
+
return !0;
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
box: (e, t) => ({
|
|
1475
|
+
...j,
|
|
1476
|
+
type: "unclonable"
|
|
1477
|
+
}),
|
|
1478
|
+
revive: (e, t) => ({})
|
|
1479
|
+
}
|
|
1480
|
+
], Or = (e, t) => t.find((t) => t.type === e.type), kr = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, Ar = (e, t) => Array.isArray(e) ? e.map((e) => t(e)) : kr(e) ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, t(n)])) : e, jr = /* @__PURE__ */ new WeakSet(), Mr = /* @__PURE__ */ new WeakSet(), Z = 0, Nr = [], Pr = (e, t) => {
|
|
1481
|
+
if (Z === 0) {
|
|
1482
|
+
e();
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
Nr.push({
|
|
1486
|
+
commit: e,
|
|
1487
|
+
rollback: t
|
|
1488
|
+
});
|
|
1489
|
+
}, Fr = (e) => {
|
|
1490
|
+
let t = Nr;
|
|
1491
|
+
Nr = [];
|
|
1492
|
+
for (let n of t) try {
|
|
1493
|
+
e ? n.rollback() : n.commit();
|
|
1494
|
+
} catch {}
|
|
1495
|
+
}, Ir = (e) => e !== null && (typeof e == "object" || typeof e == "function"), Lr = /* @__PURE__ */ new WeakMap(), Rr = (e) => {
|
|
1496
|
+
let t = Lr.get(e);
|
|
1497
|
+
if (t) return t;
|
|
1498
|
+
let n = e.filter((e) => !e.objectsOnly);
|
|
1499
|
+
return Lr.set(e, n), n;
|
|
1500
|
+
}, zr = (e, t, n) => {
|
|
1501
|
+
let r = (e === null || typeof e != "object" && typeof e != "function" ? Rr(t.revivableModules) : t.revivableModules).find((t) => t.type !== n && t.isType(e));
|
|
1502
|
+
return r ? r.box(e, t) : Ar(e, (e) => Q(e, t));
|
|
1503
|
+
}, Q = (e, t) => {
|
|
1504
|
+
if (ve(e)) return e;
|
|
1505
|
+
let n = Ir(e);
|
|
1506
|
+
if (n) {
|
|
1507
|
+
if (jr.has(e)) throw TypeError("osra: cannot serialize a circular structure - break the cycle or send the container by reference");
|
|
1508
|
+
jr.add(e);
|
|
1509
|
+
}
|
|
1510
|
+
Z++;
|
|
1511
|
+
let r = !0;
|
|
1512
|
+
try {
|
|
1513
|
+
let n = zr(e, t);
|
|
1514
|
+
return r = !1, n;
|
|
1515
|
+
} finally {
|
|
1516
|
+
n && jr.delete(e), Z--, Z === 0 && Fr(r);
|
|
1517
|
+
}
|
|
1518
|
+
}, Br = (e, t, n) => zr(e, t, n), $ = (e, t) => {
|
|
1519
|
+
let n = Ir(e);
|
|
1520
|
+
if (n) {
|
|
1521
|
+
if (Mr.has(e)) throw TypeError("osra: cannot revive a circular structure");
|
|
1522
|
+
Mr.add(e);
|
|
1523
|
+
}
|
|
1524
|
+
try {
|
|
1525
|
+
if (ve(e)) {
|
|
1526
|
+
let n = Or(e, t.revivableModules);
|
|
1527
|
+
if (n) return n.revive(e, t);
|
|
1528
|
+
}
|
|
1529
|
+
return Ar(e, (e) => $(e, t));
|
|
1530
|
+
} finally {
|
|
1531
|
+
n && Mr.delete(e);
|
|
1532
|
+
}
|
|
1533
|
+
}, Vr = /* @__PURE__ */ t({
|
|
1534
|
+
init: () => Wr,
|
|
1535
|
+
startBidirectionalConnection: () => Ur,
|
|
1536
|
+
type: () => Hr
|
|
1537
|
+
}), Hr = "bidirectional", Ur = ({ transport: e, value: t, remoteUuid: n, eventTarget: r, send: i, revivableModules: a }) => {
|
|
1538
|
+
let o = {
|
|
1539
|
+
transport: e,
|
|
1540
|
+
remoteUuid: n,
|
|
1541
|
+
sendMessage: i,
|
|
1542
|
+
eventTarget: r,
|
|
1543
|
+
revivableModules: a
|
|
1544
|
+
};
|
|
1545
|
+
for (let e of a) e.init?.(o);
|
|
1546
|
+
let { promise: s, resolve: c } = Promise.withResolvers();
|
|
1547
|
+
return r.addEventListener("message", function e({ detail: t }) {
|
|
1548
|
+
t.type === "init" && (c(t.data), r.removeEventListener("message", e));
|
|
1549
|
+
}), i({
|
|
1550
|
+
type: "init",
|
|
1551
|
+
remoteUuid: n,
|
|
1552
|
+
data: Q(t, o)
|
|
1553
|
+
}), {
|
|
1554
|
+
revivableContext: o,
|
|
1555
|
+
remoteValue: s.then((e) => $(e, o))
|
|
1556
|
+
};
|
|
1557
|
+
}, Wr = (e) => {
|
|
1558
|
+
if (!(k(e.transport) && A(e.transport))) return;
|
|
1559
|
+
if (e.protocolEventTarget.addEventListener("message", ({ detail: { message: t, peer: n } }) => {
|
|
1560
|
+
if (t.type === "announce") {
|
|
1561
|
+
if (!t.remoteUuid) {
|
|
1562
|
+
e.sendMessage({
|
|
1563
|
+
type: "announce",
|
|
1564
|
+
remoteUuid: t.uuid
|
|
1565
|
+
});
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
if (t.remoteUuid !== e.getUuid() || e.connectionContexts.has(t.uuid)) return;
|
|
1569
|
+
e.sendMessage({
|
|
1570
|
+
type: "announce",
|
|
1571
|
+
remoteUuid: t.uuid
|
|
1572
|
+
});
|
|
1573
|
+
let r = e.createConnectionEventTarget(), i = {
|
|
1574
|
+
...n(),
|
|
1575
|
+
abort: () => e.abortConnection(t.uuid)
|
|
1576
|
+
}, a;
|
|
1577
|
+
try {
|
|
1578
|
+
let n = e.valueFor(i);
|
|
1579
|
+
if (e.claimPendingAbort(t.uuid)) {
|
|
1580
|
+
e.sendMessage({
|
|
1581
|
+
type: "close",
|
|
1582
|
+
remoteUuid: t.uuid
|
|
1583
|
+
});
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
a = Ur({
|
|
1587
|
+
transport: e.transport,
|
|
1588
|
+
value: n,
|
|
1589
|
+
remoteUuid: t.uuid,
|
|
1590
|
+
eventTarget: r,
|
|
1591
|
+
send: (t) => e.sendMessage(t),
|
|
1592
|
+
revivableModules: e.revivableModules
|
|
1593
|
+
});
|
|
1594
|
+
} catch (n) {
|
|
1595
|
+
e.sendMessage({
|
|
1596
|
+
type: "close",
|
|
1597
|
+
remoteUuid: t.uuid
|
|
1598
|
+
}), e.rejectRemoteValue(n);
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
let o = {
|
|
1602
|
+
type: "bidirectional",
|
|
1603
|
+
eventTarget: r,
|
|
1604
|
+
connection: a
|
|
1605
|
+
};
|
|
1606
|
+
e.connectionContexts.set(t.uuid, o), o.connection.remoteValue.then((t) => e.addConnection(i, t), (t) => e.rejectRemoteValue(t));
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
if (t.type === "close") {
|
|
1610
|
+
if (t.remoteUuid !== e.getUuid()) return;
|
|
1611
|
+
let n = e.connectionContexts.get(t.uuid);
|
|
1612
|
+
if (!n) return;
|
|
1613
|
+
e.connectionContexts.delete(t.uuid), Ye(n.connection.revivableContext), e.rejectRemoteValue(/* @__PURE__ */ Error("osra: peer closed the connection"));
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
if (t.remoteUuid !== e.getUuid()) return;
|
|
1617
|
+
let r = e.connectionContexts.get(t.uuid);
|
|
1618
|
+
r && r.eventTarget.dispatchEvent(new CustomEvent("message", { detail: t }));
|
|
1619
|
+
}), e.presetRemoteUuid !== void 0) {
|
|
1620
|
+
let t = e.presetRemoteUuid, n = e.createConnectionEventTarget(), r, i;
|
|
1621
|
+
try {
|
|
1622
|
+
i = { abort: () => e.abortConnection(t) };
|
|
1623
|
+
let a = e.valueFor(i);
|
|
1624
|
+
if (e.claimPendingAbort(t)) {
|
|
1625
|
+
e.sendMessage({
|
|
1626
|
+
type: "close",
|
|
1627
|
+
remoteUuid: t
|
|
1628
|
+
});
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
r = Ur({
|
|
1632
|
+
transport: e.transport,
|
|
1633
|
+
value: a,
|
|
1634
|
+
remoteUuid: e.presetRemoteUuid,
|
|
1635
|
+
eventTarget: n,
|
|
1636
|
+
send: (t) => e.sendMessage(t),
|
|
1637
|
+
revivableModules: e.revivableModules
|
|
1638
|
+
});
|
|
1639
|
+
} catch (n) {
|
|
1640
|
+
e.sendMessage({
|
|
1641
|
+
type: "close",
|
|
1642
|
+
remoteUuid: t
|
|
1643
|
+
}), e.rejectRemoteValue(n);
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
let a = {
|
|
1647
|
+
type: "bidirectional",
|
|
1648
|
+
eventTarget: n,
|
|
1649
|
+
connection: r
|
|
1650
|
+
};
|
|
1651
|
+
e.connectionContexts.set(e.presetRemoteUuid, a), a.connection.remoteValue.then((t) => e.addConnection(i, t), (t) => e.rejectRemoteValue(t));
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
let t = 50, n, r = () => {
|
|
1655
|
+
if (!(e.unregisterSignal?.aborted || e.connectionContexts.size > 0)) {
|
|
1656
|
+
try {
|
|
1657
|
+
e.sendMessage({ type: "announce" }, "*");
|
|
1658
|
+
} catch {}
|
|
1659
|
+
n = setTimeout(r, t), t = Math.min(t * 2, 1e3);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
e.unregisterSignal?.addEventListener("abort", () => clearTimeout(n), { once: !0 }), r();
|
|
1663
|
+
}, Gr = () => new EventTarget(), Kr = (e) => {
|
|
1664
|
+
let t = pe(e), n = t ? e.emit : e, r = t ? e.receive : e;
|
|
1665
|
+
return {
|
|
1666
|
+
isJson: t && "isJson" in e && e.isJson !== void 0 ? e.isJson : n !== void 0 && O(n) || r !== void 0 && O(r),
|
|
1667
|
+
...n === void 0 ? {} : { emit: n },
|
|
1668
|
+
...r === void 0 ? {} : { receive: r }
|
|
1669
|
+
};
|
|
1670
|
+
}, qr = (e) => e ? e(Dr) : Dr, Jr = 32, Yr = () => {
|
|
1671
|
+
let e = [], t = /* @__PURE__ */ new Set(), n = !1, r = () => ({
|
|
1672
|
+
value: void 0,
|
|
1673
|
+
done: !0
|
|
1674
|
+
});
|
|
1675
|
+
return {
|
|
1676
|
+
push: (r) => {
|
|
1677
|
+
if (!n) {
|
|
1678
|
+
if (t.size === 0) {
|
|
1679
|
+
e.push(r), e.length > Jr && e.shift();
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
for (let e of t) {
|
|
1683
|
+
let t = e.wake;
|
|
1684
|
+
if (t) {
|
|
1685
|
+
e.wake = void 0, t({
|
|
1686
|
+
value: r,
|
|
1687
|
+
done: !1
|
|
1688
|
+
});
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1691
|
+
e.buffered.push(r);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
close: () => {
|
|
1696
|
+
n = !0;
|
|
1697
|
+
for (let e of t) {
|
|
1698
|
+
let t = e.wake;
|
|
1699
|
+
e.wake = void 0, t?.(r());
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1702
|
+
iterate: () => {
|
|
1703
|
+
let i = { buffered: [...e] };
|
|
1704
|
+
t.add(i);
|
|
1705
|
+
let a = !1;
|
|
1706
|
+
return {
|
|
1707
|
+
[Symbol.asyncIterator]() {
|
|
1708
|
+
return this;
|
|
1709
|
+
},
|
|
1710
|
+
next: () => {
|
|
1711
|
+
if (a) return Promise.resolve(r());
|
|
1712
|
+
let e = i.buffered.shift();
|
|
1713
|
+
return e ? Promise.resolve({
|
|
1714
|
+
value: e,
|
|
1715
|
+
done: !1
|
|
1716
|
+
}) : n ? Promise.resolve(r()) : new Promise((e) => {
|
|
1717
|
+
i.wake = e;
|
|
1718
|
+
});
|
|
1719
|
+
},
|
|
1720
|
+
return: () => {
|
|
1721
|
+
a = !0, t.delete(i);
|
|
1722
|
+
let e = i.wake;
|
|
1723
|
+
return i.wake = void 0, e?.(r()), Promise.resolve(r());
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
}, Xr = (e, t, n) => {
|
|
1729
|
+
let r = e.then(n);
|
|
1730
|
+
r.catch(() => {});
|
|
1731
|
+
let i = () => {
|
|
1732
|
+
let e = t.iterate();
|
|
1733
|
+
return {
|
|
1734
|
+
[Symbol.asyncIterator]() {
|
|
1735
|
+
return this;
|
|
1736
|
+
},
|
|
1737
|
+
next: () => e.next().then((e) => e.done ? {
|
|
1738
|
+
value: void 0,
|
|
1739
|
+
done: !0
|
|
1740
|
+
} : {
|
|
1741
|
+
value: n(e.value),
|
|
1742
|
+
done: !1
|
|
1743
|
+
}),
|
|
1744
|
+
return: () => e.return?.() ?? Promise.resolve({
|
|
1745
|
+
value: void 0,
|
|
1746
|
+
done: !0
|
|
1747
|
+
})
|
|
1748
|
+
};
|
|
1749
|
+
};
|
|
1750
|
+
return Object.assign(r, { [Symbol.asyncIterator]: i });
|
|
1751
|
+
}, Zr = Symbol.for("osra.context"), Qr = (e) => typeof e == "object" && !!e && Zr in e, $r = (e, t, { key: n = r, origin: i = "*", originA: a = i, originB: o = i, nameA: s, nameB: c, unregisterSignal: u } = {}) => {
|
|
1752
|
+
let d = Kr(e), p = Kr(t), m = (e, t, r, i, a) => {
|
|
1753
|
+
!A(e) || !k(t) || l({
|
|
1754
|
+
transport: e,
|
|
1755
|
+
key: n,
|
|
1756
|
+
remoteName: a,
|
|
1757
|
+
origin: r,
|
|
1758
|
+
unregisterSignal: u,
|
|
1759
|
+
listener: (e) => {
|
|
1760
|
+
f(t, e, i, L(e));
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
};
|
|
1764
|
+
m(d, p, a, o, s), m(p, d, o, a, c);
|
|
1765
|
+
}, ei = [Vr], ti = (e, { transport: t, name: i, remoteName: a, key: o = r, origin: s = "*", unregisterSignal: c, revivableModules: u, uuid: d, remoteUuid: p, connection: m = ({ value: e }) => e }) => {
|
|
1766
|
+
let h = m, g = Kr(t);
|
|
1767
|
+
if (!(k(g) && A(g))) {
|
|
1768
|
+
let e = Yr();
|
|
1769
|
+
e.close();
|
|
1770
|
+
let t = Promise.reject(/* @__PURE__ */ Error("osra: transport must be able to both emit and receive to establish a connection; pass a bidirectional platform transport or a custom { emit, receive } pair"));
|
|
1771
|
+
return t.catch(() => {}), Xr(t, e, h);
|
|
1772
|
+
}
|
|
1773
|
+
let ee = qr(u), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set(), y = Yr(), { promise: b, resolve: te, reject: x } = Promise.withResolvers();
|
|
1774
|
+
b.catch(() => {});
|
|
1775
|
+
let S = d ?? globalThis.crypto.randomUUID(), C = (e, t = s) => {
|
|
1776
|
+
let r = {
|
|
1777
|
+
[n]: o,
|
|
1778
|
+
name: i,
|
|
1779
|
+
uuid: S,
|
|
1780
|
+
...e
|
|
1781
|
+
}, a = L(r);
|
|
1782
|
+
f(g, r, t, a), G(a);
|
|
1783
|
+
}, ne = (e, t) => {
|
|
1784
|
+
c?.aborted || C(e, t);
|
|
1785
|
+
}, w = Gr(), re = {
|
|
1786
|
+
transport: g,
|
|
1787
|
+
valueFor: (t) => Qr(e) ? e[Zr](t) : e,
|
|
1788
|
+
revivableModules: ee,
|
|
1789
|
+
connectionContexts: _,
|
|
1790
|
+
getUuid: () => S,
|
|
1791
|
+
presetRemoteUuid: p,
|
|
1792
|
+
sendMessage: ne,
|
|
1793
|
+
protocolEventTarget: w,
|
|
1794
|
+
rejectRemoteValue: x,
|
|
1795
|
+
abortConnection: (e) => {
|
|
1796
|
+
let t = _.get(e);
|
|
1797
|
+
if (!t) {
|
|
1798
|
+
v.add(e);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
_.delete(e), C({
|
|
1802
|
+
type: "close",
|
|
1803
|
+
remoteUuid: e
|
|
1804
|
+
}), Ye(t.connection.revivableContext), x(/* @__PURE__ */ Error("osra: connection aborted"));
|
|
1805
|
+
},
|
|
1806
|
+
claimPendingAbort: (e) => v.delete(e),
|
|
1807
|
+
addConnection: (e, t) => {
|
|
1808
|
+
let n = {
|
|
1809
|
+
value: t,
|
|
1810
|
+
context: e
|
|
1811
|
+
};
|
|
1812
|
+
te(n), y.push(n);
|
|
1813
|
+
},
|
|
1814
|
+
createConnectionEventTarget: Gr,
|
|
1815
|
+
unregisterSignal: c
|
|
1816
|
+
};
|
|
1817
|
+
if (l({
|
|
1818
|
+
listener: (e, t) => {
|
|
1819
|
+
e.uuid !== S && w.dispatchEvent(new CustomEvent("message", { detail: {
|
|
1820
|
+
message: e,
|
|
1821
|
+
peer: () => ({
|
|
1822
|
+
...t.origin ? { origin: t.origin } : {},
|
|
1823
|
+
...t.source ? { source: t.source } : {},
|
|
1824
|
+
...t.port ? { port: t.port } : {},
|
|
1825
|
+
...t.sender ? { sender: t.sender } : {}
|
|
1826
|
+
})
|
|
1827
|
+
} }));
|
|
1828
|
+
},
|
|
1829
|
+
transport: g,
|
|
1830
|
+
remoteName: a,
|
|
1831
|
+
key: o,
|
|
1832
|
+
origin: s,
|
|
1833
|
+
unregisterSignal: c
|
|
1834
|
+
}), c?.aborted) return x(c.reason), y.close(), Xr(b, y, h);
|
|
1835
|
+
c?.addEventListener("abort", () => {
|
|
1836
|
+
for (let [e, t] of _) C({
|
|
1837
|
+
type: "close",
|
|
1838
|
+
remoteUuid: e
|
|
1839
|
+
}), Ye(t.connection.revivableContext);
|
|
1840
|
+
_.clear(), y.close(), x(c.reason);
|
|
1841
|
+
}, { once: !0 });
|
|
1842
|
+
for (let e of ei) e.init(re);
|
|
1843
|
+
return Xr(b, y, h);
|
|
1844
|
+
}, ni = (e, t) => ti(e, t);
|
|
1845
|
+
//#endregion
|
|
1846
|
+
export { ni as a, Q as i, Gr as n, $r as o, j as r, $ as t };
|