osra 0.2.13 → 0.3.0
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/LICENSE +21 -21
- package/README.md +319 -304
- package/build/connections/bidirectional.d.ts +53 -0
- package/build/connections/index.d.ts +20 -0
- package/build/connections/utils.d.ts +31 -0
- package/build/index.d.ts +16 -630
- package/build/index.js +918 -634
- package/build/index.js.map +1 -1
- package/build/revivables/abort-signal.d.ts +20 -0
- package/build/revivables/array-buffer.d.ts +12 -0
- package/build/revivables/bigint.d.ts +14 -0
- package/build/revivables/date.d.ts +9 -0
- package/build/revivables/error.d.ts +10 -0
- package/build/revivables/event-target.d.ts +29 -0
- package/build/revivables/function.d.ts +29 -0
- package/build/revivables/headers.d.ts +9 -0
- package/build/revivables/identity.d.ts +39 -0
- package/build/revivables/index.d.ts +39 -0
- package/build/revivables/map.d.ts +11 -0
- package/build/revivables/message-port.d.ts +83 -0
- package/build/revivables/promise.d.ts +34 -0
- package/build/revivables/readable-stream.d.ts +18 -0
- package/build/revivables/request.d.ts +23 -0
- package/build/revivables/response.d.ts +18 -0
- package/build/revivables/set.d.ts +11 -0
- package/build/revivables/transfer.d.ts +37 -0
- package/build/revivables/typed-array.d.ts +15 -0
- package/build/revivables/utils.d.ts +59 -0
- package/build/types.d.ts +45 -0
- package/build/utils/capable-check.d.ts +44 -0
- package/build/utils/event-channel.d.ts +27 -0
- package/build/utils/index.d.ts +11 -0
- package/build/utils/replace.d.ts +25 -0
- package/build/utils/transferable.d.ts +20 -0
- package/build/utils/transport.d.ts +56 -0
- package/build/utils/type-guards.d.ts +58 -0
- package/build/utils/type.d.ts +2 -0
- package/build/utils/typed-event-target.d.ts +16 -0
- package/build/utils/typed-message-channel.d.ts +19 -0
- package/package.json +60 -67
package/build/index.js
CHANGED
|
@@ -1,636 +1,920 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
1
|
+
//#region \0rolldown/runtime.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 = {
|
|
10
|
+
Int8Array,
|
|
11
|
+
Uint8Array,
|
|
12
|
+
Uint8ClampedArray,
|
|
13
|
+
Int16Array,
|
|
14
|
+
Uint16Array,
|
|
15
|
+
Int32Array,
|
|
16
|
+
Uint32Array,
|
|
17
|
+
Float16Array,
|
|
18
|
+
Float32Array,
|
|
19
|
+
Float64Array,
|
|
20
|
+
BigInt64Array,
|
|
21
|
+
BigUint64Array
|
|
22
|
+
}, o = Object.values(a), s = (e) => {
|
|
23
|
+
let t = e.constructor.name;
|
|
24
|
+
if (!(t in a)) throw Error("Unknown typed array type");
|
|
25
|
+
return t;
|
|
26
|
+
}, c = (e) => {
|
|
27
|
+
let t = a[e];
|
|
28
|
+
if (!t) throw Error("Unknown typed array type");
|
|
29
|
+
return t;
|
|
30
|
+
}, l = (e) => o.some((t) => e instanceof t), u = (e) => e instanceof WebSocket, d = (e) => !!globalThis.ServiceWorkerContainer && e instanceof ServiceWorkerContainer, f = (e) => !!globalThis.Worker && e instanceof Worker, p = (e) => !!globalThis.DedicatedWorkerGlobalScope && e instanceof DedicatedWorkerGlobalScope, m = (e) => !!globalThis.SharedWorker && e instanceof SharedWorker, h = (e) => e instanceof MessagePort, g = (e) => !!e && typeof e == "object" && "__OSRA_KEY__" in e && !!e.__OSRA_KEY__, _ = (e, t) => {
|
|
31
|
+
for (let n of t) if (n && e instanceof n) return !0;
|
|
32
|
+
return !1;
|
|
33
|
+
}, v = (e) => _(e, [globalThis.SharedArrayBuffer]), ee = (e) => _(e, [
|
|
34
|
+
globalThis.ArrayBuffer,
|
|
35
|
+
globalThis.MessagePort,
|
|
36
|
+
globalThis.ReadableStream,
|
|
37
|
+
globalThis.WritableStream,
|
|
38
|
+
globalThis.TransformStream,
|
|
39
|
+
globalThis.ImageBitmap
|
|
40
|
+
]), y = (e) => {
|
|
41
|
+
let t = se();
|
|
42
|
+
return t ? e === t : !1;
|
|
43
|
+
}, b = (e, t = !1) => !e || typeof e != "object" || C(e) || !("name" in e) || !("disconnect" in e) || !("postMessage" in e) ? !1 : t ? "sender" in e && "onMessage" in e && "onDisconnect" in e : !0, te = (e) => !!e && typeof e == "object" && !C(e) && "addListener" in e && "hasListener" in e && "removeListener" in e, x = (e) => te(e), S = (e) => te(e), C = (e) => {
|
|
44
|
+
if (!e || typeof e != "object") return !1;
|
|
45
|
+
try {
|
|
46
|
+
return "window" in e && e.window === e;
|
|
47
|
+
} catch {
|
|
48
|
+
try {
|
|
49
|
+
return "closed" in e && typeof e.closed == "boolean" && "close" in e && typeof e.close == "function";
|
|
50
|
+
} catch {
|
|
51
|
+
return !1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, w = (e) => u(e) || b(e) || y(e), T = (e) => u(e) || b(e) || x(e) || S(e) || y(e), E = (e) => !!e && typeof e == "object" && "isJson" in e && e.isJson === !0 || w(e) || T(e), D = (e) => C(e) || w(e) || d(e) || f(e) || p(e) || m(e) || h(e) || ie(e);
|
|
55
|
+
function ne(e) {
|
|
56
|
+
if (!D(e)) throw Error("Transport is not emitable");
|
|
57
|
+
}
|
|
58
|
+
var O = (e) => C(e) || T(e) || d(e) || f(e) || p(e) || m(e) || h(e) || k(e);
|
|
59
|
+
function re(e) {
|
|
60
|
+
if (!O(e)) throw Error("Transport is not receiveable");
|
|
61
|
+
}
|
|
62
|
+
var ie = (e) => !e || typeof e != "object" || C(e) || !("emit" in e) ? !1 : D(e.emit) || typeof e.emit == "function", k = (e) => !e || typeof e != "object" || C(e) || !("receive" in e) ? !1 : O(e.receive) || typeof e.receive == "function", A = (e) => ie(e) || k(e), ae = (e) => D(e) || O(e) || A(e) || E(e), oe = () => globalThis.browser ?? globalThis.chrome, se = () => oe()?.runtime, j = (e, t) => g(e) && e.__OSRA_KEY__ === t, M = (e, t) => e?.addEventListener("abort", t, { once: !0 }), ce = ({ listener: e, transport: t, remoteName: r, key: i = n, unregisterSignal: a }) => {
|
|
63
|
+
let o = A(t) ? t.receive : t;
|
|
64
|
+
if (typeof o == "function") {
|
|
65
|
+
o((t, n) => {
|
|
66
|
+
j(t, i) && (r && t.name !== r || e(t, n));
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (y(o) || b(o) || x(o) || S(o)) {
|
|
71
|
+
let t = (t, n) => {
|
|
72
|
+
let o = (t, a) => {
|
|
73
|
+
j(t, i) && (r && t.name !== r || e(t, {
|
|
74
|
+
port: n,
|
|
75
|
+
sender: a
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
78
|
+
t.addListener(o), M(a, () => t.removeListener(o));
|
|
79
|
+
};
|
|
80
|
+
if (y(o)) t(o.onMessage);
|
|
81
|
+
else if (x(o)) {
|
|
82
|
+
let e = (e) => t(e.onMessage, e);
|
|
83
|
+
o.addListener(e), M(a, () => o.removeListener(e));
|
|
84
|
+
} else S(o) ? t(o) : t(o.onMessage);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let s = (t) => {
|
|
88
|
+
j(t.data, i) && (r && t.data.name !== r || e(t.data, {
|
|
89
|
+
receiveTransport: o,
|
|
90
|
+
source: t.source
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
o.addEventListener("message", s), M(a, () => o.removeEventListener("message", s));
|
|
94
|
+
}, le = (e, t, n = "*", r = []) => {
|
|
95
|
+
let i = A(e) ? e.emit : e;
|
|
96
|
+
typeof i == "function" ? i(t, r) : C(i) ? i.postMessage(t, n, r) : b(i) ? i.postMessage(t) : y(i) ? i.sendMessage(t) : u(i) ? i.send(JSON.stringify(t)) : m(i) ? i.port.postMessage(t, r) : i.postMessage(t, r);
|
|
97
|
+
}, N = { [i]: "revivable" }, P = (e) => !!e && typeof e == "object" && "__OSRA_BOX__" in e && e.__OSRA_BOX__ === "revivable", F = (e) => e instanceof Error ? e.stack ?? String(e) : String(e), ue = (e, t) => E(t.transport) ? { base64Buffer: new Uint8Array(e).toBase64() } : { arrayBuffer: e }, de = (e) => "arrayBuffer" in e ? e.arrayBuffer : Uint8Array.fromBase64(e.base64Buffer).buffer, fe = /* @__PURE__ */ t({
|
|
98
|
+
box: () => he,
|
|
99
|
+
isType: () => me,
|
|
100
|
+
revive: () => ge,
|
|
101
|
+
type: () => pe
|
|
102
|
+
}), pe = "arrayBuffer", me = (e) => e instanceof ArrayBuffer, he = (e, t) => ({
|
|
103
|
+
...N,
|
|
104
|
+
type: pe,
|
|
105
|
+
...ue(e, t)
|
|
106
|
+
}), ge = (e, t) => de(e), _e = /* @__PURE__ */ t({
|
|
107
|
+
box: () => be,
|
|
108
|
+
isType: () => ye,
|
|
109
|
+
revive: () => xe,
|
|
110
|
+
type: () => ve
|
|
111
|
+
}), ve = "date", ye = (e) => e instanceof Date, be = (e, t) => ({
|
|
112
|
+
...N,
|
|
113
|
+
type: ve,
|
|
114
|
+
ISOString: e.toISOString()
|
|
115
|
+
}), xe = (e, t) => new Date(e.ISOString), Se = /* @__PURE__ */ t({
|
|
116
|
+
box: () => Te,
|
|
117
|
+
isType: () => we,
|
|
118
|
+
revive: () => I,
|
|
119
|
+
type: () => Ce
|
|
120
|
+
}), Ce = "headers", we = (e) => e instanceof Headers, Te = (e, t) => ({
|
|
121
|
+
...N,
|
|
122
|
+
type: Ce,
|
|
123
|
+
entries: [...e.entries()]
|
|
124
|
+
}), I = (e, t) => new Headers(e.entries), Ee = /* @__PURE__ */ t({
|
|
125
|
+
box: () => ke,
|
|
126
|
+
isType: () => Oe,
|
|
127
|
+
revive: () => Ae,
|
|
128
|
+
type: () => De
|
|
129
|
+
}), De = "error", Oe = (e) => e instanceof Error, ke = (e, t) => ({
|
|
130
|
+
...N,
|
|
131
|
+
type: De,
|
|
132
|
+
message: e.message,
|
|
133
|
+
stack: e.stack || e.toString()
|
|
134
|
+
}), Ae = (e, t) => Error(e.message, { cause: e.stack }), je = /* @__PURE__ */ t({
|
|
135
|
+
box: () => Pe,
|
|
136
|
+
isType: () => Ne,
|
|
137
|
+
revive: () => Fe,
|
|
138
|
+
type: () => Me
|
|
139
|
+
}), Me = "typedArray", Ne = l, Pe = (e, t) => ({
|
|
140
|
+
...N,
|
|
141
|
+
type: Me,
|
|
142
|
+
typedArrayType: s(e),
|
|
143
|
+
...ue(e.buffer, t)
|
|
144
|
+
}), Fe = (e, t) => new (c(e.typedArrayType))(de(e)), L = class extends EventTarget {
|
|
145
|
+
addEventListener(e, t, n) {
|
|
146
|
+
super.addEventListener(e, t, n);
|
|
147
|
+
}
|
|
148
|
+
removeEventListener(e, t, n) {
|
|
149
|
+
super.removeEventListener(e, t, n);
|
|
150
|
+
}
|
|
151
|
+
_peer;
|
|
152
|
+
_queue = [];
|
|
153
|
+
_started = !1;
|
|
154
|
+
_closed = !1;
|
|
155
|
+
_onClose;
|
|
156
|
+
_onmessage = null;
|
|
157
|
+
get onmessage() {
|
|
158
|
+
return this._onmessage;
|
|
159
|
+
}
|
|
160
|
+
set onmessage(e) {
|
|
161
|
+
this._onmessage = e, e !== null && this.start();
|
|
162
|
+
}
|
|
163
|
+
onmessageerror = null;
|
|
164
|
+
dispatchEvent(e) {
|
|
165
|
+
return e.type === "message" ? this._onmessage?.call(this, e) : e.type === "messageerror" && this.onmessageerror?.call(this, e), super.dispatchEvent(e);
|
|
166
|
+
}
|
|
167
|
+
postMessage(e, t) {
|
|
168
|
+
let n = this._peer;
|
|
169
|
+
!n || n._closed || queueMicrotask(() => {
|
|
170
|
+
if (n._closed) return;
|
|
171
|
+
let t = new MessageEvent("message", { data: e });
|
|
172
|
+
n._started ? n.dispatchEvent(t) : n._queue.push(t);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
start() {
|
|
176
|
+
if (!this._started) {
|
|
177
|
+
this._started = !0;
|
|
178
|
+
for (let e of this._queue.splice(0)) this.dispatchEvent(e);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
close() {
|
|
182
|
+
this._closed || (this._closed = !0, this._queue.length = 0, this._onClose?.());
|
|
183
|
+
}
|
|
184
|
+
}, R = class {
|
|
185
|
+
port1;
|
|
186
|
+
port2;
|
|
187
|
+
constructor() {
|
|
188
|
+
let e = new L(), t = new L();
|
|
189
|
+
e._peer = t, t._peer = e, this.port1 = e, this.port2 = t;
|
|
190
|
+
}
|
|
191
|
+
}, Ie = /* @__PURE__ */ t({
|
|
192
|
+
box: () => V,
|
|
193
|
+
createRevivableChannel: () => U,
|
|
194
|
+
init: () => ze,
|
|
195
|
+
isType: () => Be,
|
|
196
|
+
revive: () => H,
|
|
197
|
+
type: () => B
|
|
198
|
+
}), z = new FinalizationRegistry((e) => {
|
|
199
|
+
e.sendMessage({
|
|
200
|
+
type: "message-port-close",
|
|
201
|
+
remoteUuid: e.remoteUuid,
|
|
202
|
+
portId: e.portId
|
|
203
|
+
}), e.cleanup();
|
|
204
|
+
}), B = "messagePort", Le = /* @__PURE__ */ new WeakMap(), Re = (e) => {
|
|
205
|
+
let t = Le.get(e);
|
|
206
|
+
if (!t) throw Error("osra message-port: connection state missing; did init() run?");
|
|
207
|
+
return t;
|
|
208
|
+
}, ze = (e) => {
|
|
209
|
+
let t = { portHandlers: /* @__PURE__ */ new Map() };
|
|
210
|
+
Le.set(e, t), e.eventTarget.addEventListener("message", ({ detail: e }) => {
|
|
211
|
+
e.type !== "message" && e.type !== "message-port-close" || t.portHandlers.get(e.portId)?.(e);
|
|
212
|
+
});
|
|
213
|
+
}, Be = (e) => e instanceof MessagePort || e instanceof L, V = (e, t, n) => {
|
|
214
|
+
let r = e instanceof L;
|
|
215
|
+
if (r || E(t.transport)) {
|
|
216
|
+
let { portHandlers: n } = Re(t), i = e, a = globalThis.crypto.randomUUID(), o = !1, s = () => {
|
|
217
|
+
o || (o = !0, n.delete(a), z.unregister(i), i.removeEventListener("message", l));
|
|
218
|
+
}, c = (e) => {
|
|
219
|
+
if (e.type === "message-port-close") {
|
|
220
|
+
s(), i.close();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
let n = Q(e.data, t);
|
|
224
|
+
i.postMessage(n, $(n));
|
|
225
|
+
};
|
|
226
|
+
function l({ data: e }) {
|
|
227
|
+
t.sendMessage({
|
|
228
|
+
type: "message",
|
|
229
|
+
remoteUuid: t.remoteUuid,
|
|
230
|
+
data: Z(e, t),
|
|
231
|
+
portId: a
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return z.register(i, {
|
|
235
|
+
sendMessage: t.sendMessage,
|
|
236
|
+
remoteUuid: t.remoteUuid,
|
|
237
|
+
portId: a,
|
|
238
|
+
cleanup: s
|
|
239
|
+
}, i), i.addEventListener("message", l), i.start(), i instanceof L && (i._onClose = () => {
|
|
240
|
+
o || (t.sendMessage({
|
|
241
|
+
type: "message-port-close",
|
|
242
|
+
remoteUuid: t.remoteUuid,
|
|
243
|
+
portId: a
|
|
244
|
+
}), s());
|
|
245
|
+
}), n.set(a, c), {
|
|
246
|
+
...N,
|
|
247
|
+
type: B,
|
|
248
|
+
portId: a,
|
|
249
|
+
synthetic: r
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
...N,
|
|
254
|
+
type: B,
|
|
255
|
+
port: e,
|
|
256
|
+
...n?.autoBox ? { autoBox: !0 } : {}
|
|
257
|
+
};
|
|
258
|
+
}, H = (e, t) => "port" in e ? e.autoBox ? Ve(e.port, t) : e.port : He(e.portId, t, e.synthetic), Ve = (e, t) => {
|
|
259
|
+
let n = new EventTarget(), r = ({ data: e }) => {
|
|
260
|
+
n.dispatchEvent(new MessageEvent("message", { data: Q(e, t) }));
|
|
261
|
+
};
|
|
262
|
+
return e.addEventListener("message", r), n.postMessage = (n, r) => {
|
|
263
|
+
let i = Z(n, t), a = $(i), o = Array.isArray(r) ? r : [];
|
|
264
|
+
e.postMessage(i, o.length ? [...a, ...o] : a);
|
|
265
|
+
}, n.start = () => e.start(), n.close = () => {
|
|
266
|
+
e.removeEventListener("message", r), e.close();
|
|
267
|
+
}, n;
|
|
268
|
+
}, U = (e) => {
|
|
269
|
+
if (E(e.transport)) {
|
|
270
|
+
let { port1: t, port2: n } = new R();
|
|
271
|
+
return {
|
|
272
|
+
localPort: t,
|
|
273
|
+
boxedRemote: V(n, e)
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
let { port1: t, port2: n } = new MessageChannel();
|
|
277
|
+
return {
|
|
278
|
+
localPort: Ve(t, e),
|
|
279
|
+
boxedRemote: V(n, e, { autoBox: !0 })
|
|
280
|
+
};
|
|
281
|
+
}, He = (e, t, n) => {
|
|
282
|
+
let { portHandlers: r } = Re(t), { port1: i, port2: a } = n ? new R() : new MessageChannel(), o = new WeakRef(i), s = !1, c = () => {
|
|
283
|
+
if (s) return;
|
|
284
|
+
s = !0, r.delete(e), a.removeEventListener("message", u), a.close();
|
|
285
|
+
let t = o.deref();
|
|
286
|
+
t && z.unregister(t);
|
|
287
|
+
}, l = (e) => {
|
|
288
|
+
if (e.type === "message-port-close") {
|
|
289
|
+
c(), o.deref()?.close();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!o.deref()) {
|
|
293
|
+
c();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
let r = Q(e.data, t);
|
|
297
|
+
n ? a.postMessage(r) : a.postMessage(r, $(r));
|
|
298
|
+
}, u = ({ data: n }) => {
|
|
299
|
+
t.sendMessage({
|
|
300
|
+
type: "message",
|
|
301
|
+
remoteUuid: t.remoteUuid,
|
|
302
|
+
data: Z(n, t),
|
|
303
|
+
portId: e
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
return z.register(i, {
|
|
307
|
+
sendMessage: t.sendMessage,
|
|
308
|
+
remoteUuid: t.remoteUuid,
|
|
309
|
+
portId: e,
|
|
310
|
+
cleanup: c
|
|
311
|
+
}, i), i instanceof L && (i._onClose = () => {
|
|
312
|
+
s || (t.sendMessage({
|
|
313
|
+
type: "message-port-close",
|
|
314
|
+
remoteUuid: t.remoteUuid,
|
|
315
|
+
portId: e
|
|
316
|
+
}), c());
|
|
317
|
+
}), a.addEventListener("message", u), a.start(), r.set(e, l), i;
|
|
318
|
+
}, Ue = /* @__PURE__ */ t({
|
|
319
|
+
box: () => Je,
|
|
320
|
+
isType: () => qe,
|
|
321
|
+
revive: () => Ye,
|
|
322
|
+
type: () => We
|
|
323
|
+
}), We = "promise", Ge = (e) => e instanceof Promise, Ke = /* @__PURE__ */ new Set(), qe = (e) => e instanceof Promise, Je = (e, t) => {
|
|
324
|
+
if (!Ge(e)) throw TypeError("Expected Promise");
|
|
325
|
+
let n = e, { localPort: r, boxedRemote: i } = U(t), a = (e) => {
|
|
326
|
+
r.postMessage(e), r.close();
|
|
327
|
+
};
|
|
328
|
+
return n.then((e) => a({
|
|
329
|
+
type: "resolve",
|
|
330
|
+
data: e
|
|
331
|
+
})).catch((e) => a({
|
|
332
|
+
type: "reject",
|
|
333
|
+
error: F(e)
|
|
334
|
+
})), {
|
|
335
|
+
...N,
|
|
336
|
+
type: We,
|
|
337
|
+
port: i
|
|
338
|
+
};
|
|
339
|
+
}, Ye = (e, t) => {
|
|
340
|
+
let n = H(e.port, t);
|
|
341
|
+
return Ke.add(n), new Promise((e, t) => {
|
|
342
|
+
n.addEventListener("message", ({ data: r }) => {
|
|
343
|
+
r.type === "resolve" ? e(r.data) : t(r.error), n.close(), Ke.delete(n);
|
|
344
|
+
}, { once: !0 }), n.start();
|
|
345
|
+
});
|
|
346
|
+
}, Xe = /* @__PURE__ */ t({
|
|
347
|
+
box: () => et,
|
|
348
|
+
isType: () => $e,
|
|
349
|
+
revive: () => tt,
|
|
350
|
+
type: () => Ze
|
|
351
|
+
}), Ze = "function", Qe = new FinalizationRegistry((e) => {
|
|
352
|
+
try {
|
|
353
|
+
e.port.postMessage({ __osra_close__: !0 });
|
|
354
|
+
} catch {}
|
|
355
|
+
try {
|
|
356
|
+
e.port.close();
|
|
357
|
+
} catch {}
|
|
358
|
+
for (let { returnLocal: t, reject: n } of e.inFlight) {
|
|
359
|
+
try {
|
|
360
|
+
n(/* @__PURE__ */ Error("osra function was garbage collected before result arrived"));
|
|
361
|
+
} catch {}
|
|
362
|
+
W.delete(t);
|
|
363
|
+
try {
|
|
364
|
+
t.close();
|
|
365
|
+
} catch {}
|
|
366
|
+
}
|
|
367
|
+
e.inFlight.clear();
|
|
368
|
+
}), W = /* @__PURE__ */ new Set(), $e = (e) => typeof e == "function", et = (e, t) => {
|
|
369
|
+
let { localPort: n, boxedRemote: r } = U(t), i = () => {
|
|
370
|
+
n.close();
|
|
371
|
+
};
|
|
372
|
+
return n.addEventListener("message", ({ data: t }) => {
|
|
373
|
+
if (!Array.isArray(t)) {
|
|
374
|
+
i();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
let [n, r] = t;
|
|
378
|
+
(async () => e(...r))().then((e) => {
|
|
379
|
+
try {
|
|
380
|
+
n.postMessage({
|
|
381
|
+
__osra_ok__: !0,
|
|
382
|
+
value: e
|
|
383
|
+
});
|
|
384
|
+
} catch (e) {
|
|
385
|
+
try {
|
|
386
|
+
n.postMessage({
|
|
387
|
+
__osra_err__: !0,
|
|
388
|
+
error: F(e)
|
|
389
|
+
});
|
|
390
|
+
} catch {}
|
|
391
|
+
}
|
|
392
|
+
}, (e) => {
|
|
393
|
+
try {
|
|
394
|
+
n.postMessage({
|
|
395
|
+
__osra_err__: !0,
|
|
396
|
+
error: F(e)
|
|
397
|
+
});
|
|
398
|
+
} catch {}
|
|
399
|
+
}).finally(() => {
|
|
400
|
+
queueMicrotask(() => n.close());
|
|
401
|
+
});
|
|
402
|
+
}), n.start(), {
|
|
403
|
+
...N,
|
|
404
|
+
type: Ze,
|
|
405
|
+
port: r
|
|
406
|
+
};
|
|
366
407
|
}, tt = (e, t) => {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
},
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
408
|
+
let n = H(e.port, t), r = /* @__PURE__ */ new Set(), i = (...e) => new Promise((i, a) => {
|
|
409
|
+
let { localPort: o, boxedRemote: s } = U(t);
|
|
410
|
+
W.add(o);
|
|
411
|
+
let c = {
|
|
412
|
+
returnLocal: o,
|
|
413
|
+
reject: a
|
|
414
|
+
};
|
|
415
|
+
r.add(c), o.addEventListener("message", ({ data: e }) => {
|
|
416
|
+
"__osra_ok__" in e ? i(e.value) : a(e.error), o.close(), W.delete(o), r.delete(c);
|
|
417
|
+
}, { once: !0 }), o.start();
|
|
418
|
+
try {
|
|
419
|
+
n.postMessage([s, e]);
|
|
420
|
+
} catch (e) {
|
|
421
|
+
W.delete(o), r.delete(c);
|
|
422
|
+
try {
|
|
423
|
+
o.close();
|
|
424
|
+
} catch {}
|
|
425
|
+
a(e);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
return Qe.register(i, {
|
|
429
|
+
port: n,
|
|
430
|
+
inFlight: r
|
|
431
|
+
}, i), i;
|
|
432
|
+
}, nt = /* @__PURE__ */ t({
|
|
433
|
+
box: () => G,
|
|
434
|
+
isType: () => it,
|
|
435
|
+
revive: () => K,
|
|
436
|
+
type: () => rt
|
|
437
|
+
}), rt = "readableStream", it = (e) => e instanceof ReadableStream, G = (e, t) => {
|
|
438
|
+
let { localPort: n, boxedRemote: r } = U(t), i = e.getReader();
|
|
439
|
+
return n.addEventListener("message", ({ data: e }) => {
|
|
440
|
+
"type" in e && e.type === "pull" ? n.postMessage(i.read()) : (i.cancel(), n.close());
|
|
441
|
+
}), n.start(), {
|
|
442
|
+
...N,
|
|
443
|
+
type: rt,
|
|
444
|
+
port: r
|
|
445
|
+
};
|
|
446
|
+
}, K = (e, t) => {
|
|
447
|
+
let n = H(e.port, t);
|
|
448
|
+
return n.start(), new ReadableStream({
|
|
449
|
+
pull: (e) => new Promise((t, r) => {
|
|
450
|
+
n.addEventListener("message", ({ data: n }) => {
|
|
451
|
+
n instanceof Promise && n.then((n) => {
|
|
452
|
+
n.done ? e.close() : e.enqueue(n.value), t();
|
|
453
|
+
}).catch(r);
|
|
454
|
+
}, { once: !0 }), n.postMessage({ type: "pull" });
|
|
455
|
+
}),
|
|
456
|
+
cancel: () => {
|
|
457
|
+
n.postMessage({ type: "cancel" }), queueMicrotask(() => n.close());
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}, at = /* @__PURE__ */ t({
|
|
461
|
+
box: () => ct,
|
|
462
|
+
isType: () => st,
|
|
463
|
+
revive: () => lt,
|
|
464
|
+
type: () => ot
|
|
465
|
+
}), ot = "abortSignal", st = (e) => e instanceof AbortSignal, ct = (e, t) => {
|
|
466
|
+
let { localPort: n, boxedRemote: r } = U(t);
|
|
467
|
+
return e.aborted ? n.close() : e.addEventListener("abort", () => {
|
|
468
|
+
n.postMessage({
|
|
469
|
+
type: "abort",
|
|
470
|
+
reason: e.reason
|
|
471
|
+
}), n.close();
|
|
472
|
+
}, { once: !0 }), {
|
|
473
|
+
...N,
|
|
474
|
+
type: ot,
|
|
475
|
+
aborted: e.aborted,
|
|
476
|
+
reason: e.aborted ? Z(e.reason, t) : void 0,
|
|
477
|
+
port: r
|
|
478
|
+
};
|
|
437
479
|
}, lt = (e, t) => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
})
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
480
|
+
let n = new AbortController();
|
|
481
|
+
if (e.aborted) return n.abort(Q(e.reason, t)), n.signal;
|
|
482
|
+
let r = H(e.port, t);
|
|
483
|
+
return r.start(), r.addEventListener("message", ({ data: e }) => {
|
|
484
|
+
e.type === "abort" && (n.abort(Q(e.reason, t)), r.close());
|
|
485
|
+
}), n.signal;
|
|
486
|
+
}, ut = /* @__PURE__ */ t({
|
|
487
|
+
box: () => pt,
|
|
488
|
+
isType: () => ft,
|
|
489
|
+
revive: () => mt,
|
|
490
|
+
type: () => dt
|
|
491
|
+
}), dt = "response", ft = (e) => e instanceof Response, pt = (e, t) => ({
|
|
492
|
+
...N,
|
|
493
|
+
type: dt,
|
|
494
|
+
status: e.status,
|
|
495
|
+
statusText: e.statusText,
|
|
496
|
+
headers: Te(e.headers, t),
|
|
497
|
+
body: e.body ? G(e.body, t) : null,
|
|
498
|
+
url: e.url,
|
|
499
|
+
redirected: e.redirected
|
|
500
|
+
}), mt = (e, t) => {
|
|
501
|
+
let n = I(e.headers, t), r = e.body ? K(e.body, t) : null;
|
|
502
|
+
return new Response(r, {
|
|
503
|
+
status: e.status,
|
|
504
|
+
statusText: e.statusText,
|
|
505
|
+
headers: n
|
|
506
|
+
});
|
|
507
|
+
}, ht = /* @__PURE__ */ t({
|
|
508
|
+
box: () => vt,
|
|
509
|
+
isType: () => _t,
|
|
510
|
+
revive: () => yt,
|
|
511
|
+
type: () => gt
|
|
512
|
+
}), gt = "request", _t = (e) => e instanceof Request, vt = (e, t) => ({
|
|
513
|
+
...N,
|
|
514
|
+
type: gt,
|
|
515
|
+
method: e.method,
|
|
516
|
+
url: e.url,
|
|
517
|
+
headers: Te(e.headers, t),
|
|
518
|
+
body: e.body ? G(e.body, t) : null,
|
|
519
|
+
credentials: e.credentials,
|
|
520
|
+
cache: e.cache,
|
|
521
|
+
redirect: e.redirect,
|
|
522
|
+
referrer: e.referrer,
|
|
523
|
+
referrerPolicy: e.referrerPolicy,
|
|
524
|
+
integrity: e.integrity,
|
|
525
|
+
keepalive: e.keepalive
|
|
526
|
+
}), yt = (e, t) => {
|
|
527
|
+
let n = I(e.headers, t), r = e.body ? K(e.body, t) : null;
|
|
528
|
+
return new Request(e.url, {
|
|
529
|
+
method: e.method,
|
|
530
|
+
headers: n,
|
|
531
|
+
body: r,
|
|
532
|
+
credentials: e.credentials,
|
|
533
|
+
cache: e.cache,
|
|
534
|
+
redirect: e.redirect,
|
|
535
|
+
referrer: e.referrer,
|
|
536
|
+
referrerPolicy: e.referrerPolicy,
|
|
537
|
+
integrity: e.integrity,
|
|
538
|
+
keepalive: e.keepalive,
|
|
539
|
+
duplex: "half"
|
|
540
|
+
});
|
|
541
|
+
}, bt = /* @__PURE__ */ t({
|
|
542
|
+
box: () => kt,
|
|
543
|
+
identity: () => wt,
|
|
544
|
+
isType: () => Ot,
|
|
545
|
+
revive: () => At,
|
|
546
|
+
type: () => q
|
|
547
|
+
}), q = "identity", J = Symbol.for("osra.identity"), Y = (e) => e !== null && (typeof e == "object" || typeof e == "function"), xt = (e) => Y(e) && J in e && e[J] === !0, St = /* @__PURE__ */ new WeakMap(), Ct = (e) => {
|
|
548
|
+
if (xt(e)) return e;
|
|
549
|
+
let t = St.get(e);
|
|
550
|
+
if (t) return t;
|
|
551
|
+
let n = {
|
|
552
|
+
[J]: !0,
|
|
553
|
+
value: e
|
|
554
|
+
};
|
|
555
|
+
return St.set(e, n), n;
|
|
556
|
+
}, wt = (e) => Y(e) ? Ct(e) : e, Tt = /* @__PURE__ */ new WeakMap(), Et = (e) => {
|
|
557
|
+
let t = Tt.get(e);
|
|
558
|
+
if (t) return t;
|
|
559
|
+
let n = {
|
|
560
|
+
sendIds: /* @__PURE__ */ new WeakMap(),
|
|
561
|
+
sendRegistry: new FinalizationRegistry((t) => {
|
|
562
|
+
try {
|
|
563
|
+
e.sendMessage({
|
|
564
|
+
type: "identity-dispose",
|
|
565
|
+
remoteUuid: e.remoteUuid,
|
|
566
|
+
id: t
|
|
567
|
+
});
|
|
568
|
+
} catch {}
|
|
569
|
+
}),
|
|
570
|
+
receiveCache: /* @__PURE__ */ new Map(),
|
|
571
|
+
listenerInstalled: !1
|
|
572
|
+
};
|
|
573
|
+
return Tt.set(e, n), Dt(e, n), n;
|
|
574
|
+
}, Dt = (e, t) => {
|
|
575
|
+
t.listenerInstalled || (t.listenerInstalled = !0, e.eventTarget.addEventListener("message", ({ detail: e }) => {
|
|
576
|
+
e?.type === "identity-dispose" && t.receiveCache.delete(e.id);
|
|
577
|
+
}));
|
|
578
|
+
}, Ot = (e) => xt(e), kt = (e, t) => {
|
|
579
|
+
let n = Et(t), r = e.value, i = Y(r) ? r : void 0;
|
|
580
|
+
if (i !== void 0) {
|
|
581
|
+
let e = n.sendIds.get(i);
|
|
582
|
+
if (e !== void 0) return {
|
|
583
|
+
...N,
|
|
584
|
+
type: q,
|
|
585
|
+
id: e
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
let a = globalThis.crypto.randomUUID(), o = Z(r, t);
|
|
589
|
+
return i !== void 0 && (n.sendIds.set(i, a), n.sendRegistry.register(i, a)), {
|
|
590
|
+
...N,
|
|
591
|
+
type: q,
|
|
592
|
+
id: a,
|
|
593
|
+
inner: o
|
|
594
|
+
};
|
|
595
|
+
}, At = (e, t) => {
|
|
596
|
+
let n = Et(t), r = n.receiveCache.get(e.id);
|
|
597
|
+
if (r !== void 0) return r;
|
|
598
|
+
if (!("inner" in e) || e.inner === void 0) throw Error(`osra identity: received id=${e.id} with no inner payload and no cached value`);
|
|
599
|
+
let i = Q(e.inner, t);
|
|
600
|
+
return n.receiveCache.set(e.id, i), i;
|
|
601
|
+
}, jt = /* @__PURE__ */ t({
|
|
602
|
+
box: () => Rt,
|
|
603
|
+
isType: () => Lt,
|
|
604
|
+
revive: () => zt,
|
|
605
|
+
transfer: () => It,
|
|
606
|
+
type: () => Mt
|
|
607
|
+
}), Mt = "transfer", X = Symbol.for("osra.transfer"), Nt = (e) => typeof e == "object" && !!e, Pt = (e) => Nt(e) && X in e && e[X] === !0, Ft = (e) => Nt(e) ? ArrayBuffer.isView(e) ? !0 : _(e, [
|
|
608
|
+
globalThis.ArrayBuffer,
|
|
609
|
+
globalThis.MessagePort,
|
|
610
|
+
globalThis.ReadableStream,
|
|
611
|
+
globalThis.WritableStream,
|
|
612
|
+
globalThis.TransformStream,
|
|
613
|
+
globalThis.ImageBitmap,
|
|
614
|
+
globalThis.OffscreenCanvas
|
|
615
|
+
]) : !1, It = (e) => Ft(e) ? {
|
|
616
|
+
[X]: !0,
|
|
617
|
+
value: e
|
|
618
|
+
} : e, Lt = (e) => Pt(e), Rt = (e, t) => {
|
|
619
|
+
let n = e.value, r = Z(n, t);
|
|
620
|
+
return {
|
|
621
|
+
...N,
|
|
622
|
+
type: Mt,
|
|
623
|
+
inner: r,
|
|
624
|
+
degraded: E(t.transport)
|
|
625
|
+
};
|
|
626
|
+
}, zt = (e, t) => Q(e.inner, t), Bt = /* @__PURE__ */ t({
|
|
627
|
+
box: () => Ht,
|
|
628
|
+
isType: () => Vt,
|
|
629
|
+
revive: () => Ut,
|
|
630
|
+
type: () => "map"
|
|
631
|
+
}), Vt = (e) => e instanceof Map, Ht = (e, t) => ({
|
|
632
|
+
...N,
|
|
633
|
+
type: "map",
|
|
634
|
+
entries: Array.from(e, ([e, n]) => [Z(e, t), Z(n, t)])
|
|
635
|
+
}), Ut = (e, t) => new Map(e.entries.map(([e, n]) => [Q(e, t), Q(n, t)])), Wt = /* @__PURE__ */ t({
|
|
636
|
+
box: () => Kt,
|
|
637
|
+
isType: () => Gt,
|
|
638
|
+
revive: () => qt,
|
|
639
|
+
type: () => "set"
|
|
640
|
+
}), Gt = (e) => e instanceof Set, Kt = (e, t) => ({
|
|
641
|
+
...N,
|
|
642
|
+
type: "set",
|
|
643
|
+
values: Array.from(e, (e) => Z(e, t))
|
|
644
|
+
}), qt = (e, t) => new Set(e.values.map((e) => Q(e, t))), Jt = /* @__PURE__ */ t({
|
|
645
|
+
box: () => Zt,
|
|
646
|
+
isType: () => Xt,
|
|
647
|
+
revive: () => Qt,
|
|
648
|
+
type: () => Yt
|
|
649
|
+
}), Yt = "bigint", Xt = (e) => typeof e == "bigint", Zt = (e, t) => ({
|
|
650
|
+
...N,
|
|
651
|
+
type: Yt,
|
|
652
|
+
value: e.toString()
|
|
653
|
+
}), Qt = (e, t) => BigInt(e.value), $t = /* @__PURE__ */ t({
|
|
654
|
+
box: () => rn,
|
|
655
|
+
isType: () => nn,
|
|
656
|
+
revive: () => un,
|
|
657
|
+
type: () => en
|
|
658
|
+
}), en = "eventTarget", tn = new FinalizationRegistry((e) => {
|
|
659
|
+
try {
|
|
660
|
+
e.port.postMessage({ kind: "close" });
|
|
661
|
+
} catch {}
|
|
662
|
+
}), nn = (e) => e instanceof EventTarget, rn = (e, t) => {
|
|
663
|
+
let { localPort: n, boxedRemote: r } = U(t), i = /* @__PURE__ */ new Map(), a = () => {
|
|
664
|
+
for (let [t, n] of i) e.removeEventListener(t, n);
|
|
665
|
+
i.clear(), n.removeEventListener("message", o), n.close();
|
|
666
|
+
}, o = ({ data: t }) => {
|
|
667
|
+
if (t.kind === "close") {
|
|
668
|
+
a();
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
if (t.kind === "subscribe") {
|
|
672
|
+
if (i.has(t.eventType)) return;
|
|
673
|
+
let r = (e) => {
|
|
674
|
+
let r = {
|
|
675
|
+
kind: "event",
|
|
676
|
+
eventType: t.eventType,
|
|
677
|
+
bubbles: e.bubbles,
|
|
678
|
+
cancelable: e.cancelable,
|
|
679
|
+
composed: e.composed
|
|
680
|
+
};
|
|
681
|
+
e instanceof CustomEvent && (r.detail = e.detail), n.postMessage(r);
|
|
682
|
+
};
|
|
683
|
+
e.addEventListener(t.eventType, r), i.set(t.eventType, r);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (t.kind === "unsubscribe") {
|
|
687
|
+
let n = i.get(t.eventType);
|
|
688
|
+
if (!n) return;
|
|
689
|
+
e.removeEventListener(t.eventType, n), i.delete(t.eventType);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
return n.addEventListener("message", o), n.start(), {
|
|
693
|
+
...N,
|
|
694
|
+
type: en,
|
|
695
|
+
port: r
|
|
696
|
+
};
|
|
697
|
+
}, an = (e) => typeof e == "boolean" ? e : !!e?.capture, on = (e) => typeof e == "object" && !!e && !!e.once, sn = (e, t, n, r) => {
|
|
698
|
+
let i = e.get(t);
|
|
699
|
+
if (!i) return !1;
|
|
700
|
+
let a = i.get(n);
|
|
701
|
+
return !a || !a.delete(r) || (a.size === 0 && i.delete(n), i.size > 0) ? !1 : (e.delete(t), !0);
|
|
702
|
+
}, cn = (e, t) => {
|
|
703
|
+
e.addEventListener("message", ({ data: e }) => {
|
|
704
|
+
if (e.kind !== "event") return;
|
|
705
|
+
let n = t.deref();
|
|
706
|
+
if (!n) return;
|
|
707
|
+
let r = {
|
|
708
|
+
bubbles: e.bubbles,
|
|
709
|
+
cancelable: e.cancelable,
|
|
710
|
+
composed: e.composed
|
|
711
|
+
}, i = "detail" in e ? new CustomEvent(e.eventType, {
|
|
712
|
+
...r,
|
|
713
|
+
detail: e.detail
|
|
714
|
+
}) : new Event(e.eventType, r);
|
|
715
|
+
n.dispatchEvent(i);
|
|
716
|
+
});
|
|
717
|
+
}, ln = (e, t, n) => {
|
|
718
|
+
let r = EventTarget.prototype.addEventListener.bind(e), i = EventTarget.prototype.removeEventListener.bind(e);
|
|
719
|
+
Object.defineProperty(e, "addEventListener", { value: (e, i, a) => {
|
|
720
|
+
if (i === null) return;
|
|
721
|
+
let o = an(a), s = on(a), c = n.get(e), l = !c;
|
|
722
|
+
c || (c = /* @__PURE__ */ new Map(), n.set(e, c));
|
|
723
|
+
let u = c.get(i);
|
|
724
|
+
if (u || (u = /* @__PURE__ */ new Map(), c.set(i, u)), u.has(o)) return;
|
|
725
|
+
let d = s ? (r) => {
|
|
726
|
+
sn(n, e, i, o) && t.postMessage({
|
|
727
|
+
kind: "unsubscribe",
|
|
728
|
+
eventType: e
|
|
729
|
+
}), typeof i == "function" ? i(r) : i.handleEvent(r);
|
|
730
|
+
} : i;
|
|
731
|
+
u.set(o, d), l && t.postMessage({
|
|
732
|
+
kind: "subscribe",
|
|
733
|
+
eventType: e
|
|
734
|
+
}), r(e, d, a);
|
|
735
|
+
} }), Object.defineProperty(e, "removeEventListener", { value: (e, r, a) => {
|
|
736
|
+
if (r === null) return;
|
|
737
|
+
let o = an(a), s = n.get(e)?.get(r)?.get(o);
|
|
738
|
+
s && (i(e, s, a), sn(n, e, r, o) && t.postMessage({
|
|
739
|
+
kind: "unsubscribe",
|
|
740
|
+
eventType: e
|
|
741
|
+
}));
|
|
742
|
+
} });
|
|
743
|
+
}, un = (e, t) => {
|
|
744
|
+
let n = H(e.port, t);
|
|
745
|
+
n.start();
|
|
746
|
+
let r = new EventTarget(), i = /* @__PURE__ */ new Map();
|
|
747
|
+
return cn(n, new WeakRef(r)), ln(r, n, i), tn.register(r, { port: n }, r), r;
|
|
748
|
+
}, dn = [
|
|
749
|
+
jt,
|
|
750
|
+
bt,
|
|
751
|
+
fe,
|
|
752
|
+
_e,
|
|
753
|
+
Se,
|
|
754
|
+
Ee,
|
|
755
|
+
je,
|
|
756
|
+
Ue,
|
|
757
|
+
Xe,
|
|
758
|
+
Ie,
|
|
759
|
+
nt,
|
|
760
|
+
at,
|
|
761
|
+
ut,
|
|
762
|
+
ht,
|
|
763
|
+
Bt,
|
|
764
|
+
Wt,
|
|
765
|
+
Jt,
|
|
766
|
+
$t
|
|
767
|
+
], fn = (e, t) => t.find((t) => t.isType(e)), pn = (e, t) => t.find((t) => t.type === e.type), mn = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, hn = (e, t) => Array.isArray(e) ? e.map((e) => t(e)) : mn(e) ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, t(n)])) : e, gn = (e, t) => {
|
|
768
|
+
let n = fn(e, t.revivableModules);
|
|
769
|
+
return n ? n.box(e, t) : e;
|
|
770
|
+
}, Z = (e, t) => {
|
|
771
|
+
if (P(e)) return e;
|
|
772
|
+
let n = fn(e, t.revivableModules);
|
|
773
|
+
return n ? n.box(e, t) : hn(e, (e) => Z(e, t));
|
|
774
|
+
}, _n = (e, t) => {
|
|
775
|
+
if (!P(e)) return e;
|
|
776
|
+
let n = pn(e, t.revivableModules);
|
|
777
|
+
return n ? n.revive(e, t) : e;
|
|
778
|
+
}, Q = (e, t) => {
|
|
779
|
+
if (P(e)) {
|
|
780
|
+
let n = pn(e, t.revivableModules);
|
|
781
|
+
if (n) return n.revive(e, t);
|
|
782
|
+
}
|
|
783
|
+
return hn(e, (e) => Q(e, t));
|
|
784
|
+
}, vn = /* @__PURE__ */ t({
|
|
785
|
+
init: () => xn,
|
|
786
|
+
startBidirectionalConnection: () => bn,
|
|
787
|
+
type: () => yn
|
|
788
|
+
}), yn = "bidirectional", bn = ({ transport: e, value: t, remoteUuid: n, eventTarget: r, send: i, revivableModules: a }) => {
|
|
789
|
+
let o = {
|
|
790
|
+
transport: e,
|
|
791
|
+
remoteUuid: n,
|
|
792
|
+
sendMessage: i,
|
|
793
|
+
eventTarget: r,
|
|
794
|
+
revivableModules: a
|
|
795
|
+
};
|
|
796
|
+
for (let e of a) e.init?.(o);
|
|
797
|
+
let { promise: s, resolve: c } = Promise.withResolvers();
|
|
798
|
+
return r.addEventListener("message", function e({ detail: t }) {
|
|
799
|
+
t.type === "init" && (c(t.data), r.removeEventListener("message", e));
|
|
800
|
+
}), i({
|
|
801
|
+
type: "init",
|
|
802
|
+
remoteUuid: n,
|
|
803
|
+
data: Z(t, o)
|
|
804
|
+
}), {
|
|
805
|
+
revivableContext: o,
|
|
806
|
+
remoteValue: s.then((e) => Q(e, o))
|
|
807
|
+
};
|
|
808
|
+
}, xn = (e) => {
|
|
809
|
+
D(e.transport) && O(e.transport) && (e.protocolEventTarget.addEventListener("message", ({ detail: t }) => {
|
|
810
|
+
if (t.type === "announce") {
|
|
811
|
+
if (!t.remoteUuid) {
|
|
812
|
+
e.sendMessage({
|
|
813
|
+
type: "announce",
|
|
814
|
+
remoteUuid: t.uuid
|
|
815
|
+
});
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (t.remoteUuid !== e.getUuid() || e.connectionContexts.has(t.uuid)) return;
|
|
819
|
+
e.sendMessage({
|
|
820
|
+
type: "announce",
|
|
821
|
+
remoteUuid: t.uuid
|
|
822
|
+
});
|
|
823
|
+
let n = e.createConnectionEventTarget(), r = {
|
|
824
|
+
type: "bidirectional",
|
|
825
|
+
eventTarget: n,
|
|
826
|
+
connection: bn({
|
|
827
|
+
transport: e.transport,
|
|
828
|
+
value: e.value,
|
|
829
|
+
remoteUuid: t.uuid,
|
|
830
|
+
eventTarget: n,
|
|
831
|
+
send: (t) => e.sendMessage(t),
|
|
832
|
+
revivableModules: e.revivableModules
|
|
833
|
+
})
|
|
834
|
+
};
|
|
835
|
+
e.connectionContexts.set(t.uuid, r), r.connection.remoteValue.then((t) => e.resolveRemoteValue(t));
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (t.type === "close") {
|
|
839
|
+
if (t.remoteUuid !== e.getUuid()) return;
|
|
840
|
+
e.connectionContexts.delete(t.uuid);
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (t.remoteUuid !== e.getUuid()) return;
|
|
844
|
+
let n = e.connectionContexts.get(t.uuid);
|
|
845
|
+
n && n.eventTarget.dispatchEvent(new CustomEvent("message", { detail: t }));
|
|
846
|
+
}), e.sendMessage({ type: "announce" }));
|
|
847
|
+
}, Sn = () => new EventTarget(), Cn = (e) => _(e, [
|
|
848
|
+
globalThis.MessagePort,
|
|
849
|
+
globalThis.ReadableStream,
|
|
850
|
+
globalThis.WritableStream,
|
|
851
|
+
globalThis.TransformStream,
|
|
852
|
+
globalThis.OffscreenCanvas
|
|
853
|
+
]), wn = (e) => P(e) && e.type === "transfer", $ = (e) => {
|
|
854
|
+
let t = [], n = /* @__PURE__ */ new WeakSet(), r = (e, i) => {
|
|
855
|
+
if (!(!e || typeof e != "object") && !n.has(e) && (n.add(e), !v(e))) {
|
|
856
|
+
if (wn(e)) {
|
|
857
|
+
r(e.inner, i || !e.degraded);
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
if (Cn(e)) {
|
|
861
|
+
t.push(e);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
if (ee(e)) {
|
|
865
|
+
i && t.push(e);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (!ArrayBuffer.isView(e)) {
|
|
869
|
+
if (Array.isArray(e)) {
|
|
870
|
+
for (let t of e) r(t, i);
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
for (let t of Object.values(e)) r(t, i);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
return r(e, !1), t;
|
|
878
|
+
}, Tn = (e) => ({
|
|
879
|
+
isJson: "isJson" in e && e.isJson !== void 0 ? e.isJson : E(e),
|
|
880
|
+
...A(e) ? e : {
|
|
881
|
+
emit: e,
|
|
882
|
+
receive: e
|
|
883
|
+
}
|
|
884
|
+
}), En = (e) => [...dn.filter((t) => !(e ?? []).some((e) => e.type === t.type)), ...e ?? []], Dn = [vn], On = (e, { transport: t, name: i, remoteName: a, key: o = r, origin: s = "*", unregisterSignal: c, revivableModules: l }) => {
|
|
885
|
+
let u = Tn(t), d = En(l), f = /* @__PURE__ */ new Map(), { promise: p, resolve: m } = Promise.withResolvers(), h = globalThis.crypto.randomUUID(), g = (e) => {
|
|
886
|
+
if (c?.aborted || !D(u)) return;
|
|
887
|
+
let t = {
|
|
888
|
+
[n]: o,
|
|
889
|
+
name: i,
|
|
890
|
+
uuid: h,
|
|
891
|
+
...e
|
|
892
|
+
};
|
|
893
|
+
le(u, t, s, $(t));
|
|
894
|
+
}, _ = Sn(), v = {
|
|
895
|
+
transport: u,
|
|
896
|
+
value: e,
|
|
897
|
+
revivableModules: d,
|
|
898
|
+
connectionContexts: f,
|
|
899
|
+
getUuid: () => h,
|
|
900
|
+
sendMessage: g,
|
|
901
|
+
protocolEventTarget: _,
|
|
902
|
+
resolveRemoteValue: m,
|
|
903
|
+
createConnectionEventTarget: Sn
|
|
904
|
+
};
|
|
905
|
+
O(u) && ce({
|
|
906
|
+
listener: (e, t) => {
|
|
907
|
+
e.uuid !== h && _.dispatchEvent(new CustomEvent("message", { detail: e }));
|
|
908
|
+
},
|
|
909
|
+
transport: u,
|
|
910
|
+
remoteName: a,
|
|
911
|
+
key: o,
|
|
912
|
+
unregisterSignal: c
|
|
913
|
+
});
|
|
914
|
+
for (let e of Dn) e.init(v);
|
|
915
|
+
return p;
|
|
916
|
+
}, kn = async (e, t) => On(e, t);
|
|
917
|
+
//#endregion
|
|
918
|
+
export { N as BoxBase, R as EventChannel, L as EventPort, i as OSRA_BOX, r as OSRA_DEFAULT_KEY, n as OSRA_KEY, ne as assertEmitTransport, re as assertReceiveTransport, gn as box, ue as boxBuffer, j as checkOsraMessageKey, Dn as connections, Sn as createTypedEventTarget, dn as defaultRevivableModules, kn as expose, $ as getTransferableObjects, oe as getWebExtensionGlobal, se as getWebExtensionRuntime, wt as identity, xn as init, _ as instanceOfAny, v as isClonable, ie as isCustomEmitTransport, k as isCustomReceiveTransport, A as isCustomTransport, p as isDedicatedWorker, w as isEmitJsonOnlyTransport, D as isEmitTransport, E as isJsonOnlyTransport, g as isOsraMessage, T as isReceiveJsonOnlyTransport, O as isReceiveTransport, P as isRevivableBox, d as isServiceWorkerContainer, m as isSharedWorker, ee as isTransferable, ae as isTransport, l as isTypedArray, x as isWebExtensionOnConnect, S as isWebExtensionOnMessage, b as isWebExtensionPort, y as isWebExtensionRuntime, u as isWebSocket, C as isWindow, f as isWorker, En as mergeRevivableModules, Tn as normalizeTransport, Z as recursiveBox, Q as recursiveRevive, ce as registerOsraMessageListener, _n as revive, de as reviveBuffer, le as sendOsraMessage, F as serializeError, bn as startBidirectionalConnection, On as startConnections, It as transfer, yn as type, s as typedArrayToType, c as typedArrayTypeToTypedArrayConstructor };
|
|
919
|
+
|
|
920
|
+
//# sourceMappingURL=index.js.map
|