osra 0.2.8 → 0.2.9
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/index.d.ts +73 -109
- package/build/index.js +266 -282
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const C = "__OSRA_KEY__", de = "__OSRA_DEFAULT_KEY__", M = "__OSRA_BOX__", m = {
|
|
2
2
|
[M]: "revivable",
|
|
3
3
|
type: ""
|
|
4
|
-
},
|
|
5
|
-
...b,
|
|
6
|
-
type: q
|
|
7
|
-
}), Ae = (e, t) => t.messageContext ?? {}, he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8
|
-
__proto__: null,
|
|
9
|
-
OSRA_CONTEXT: be,
|
|
10
|
-
box: ue,
|
|
11
|
-
isType: me,
|
|
12
|
-
revive: Ae,
|
|
13
|
-
type: q
|
|
14
|
-
}, Symbol.toStringTag, { value: "Module" })), we = () => {
|
|
4
|
+
}, le = (e, t) => e && typeof e == "object" && M in e && e[M] === "revivable", pe = () => {
|
|
15
5
|
const e = /* @__PURE__ */ new Map(), t = {
|
|
16
6
|
getUniqueUuid: () => {
|
|
17
7
|
let r = globalThis.crypto.randomUUID();
|
|
@@ -43,48 +33,48 @@ const P = "__OSRA_KEY__", pe = "__OSRA_DEFAULT_KEY__", M = "__OSRA_BOX__", b = {
|
|
|
43
33
|
}
|
|
44
34
|
};
|
|
45
35
|
return t;
|
|
46
|
-
},
|
|
36
|
+
}, K = (e, t) => ue(e) && e[C] === t, ge = ({ listener: e, transport: t, remoteName: r, key: n = C, unregisterSignal: a }) => {
|
|
47
37
|
const s = (o) => {
|
|
48
38
|
if (typeof o == "function")
|
|
49
39
|
o(e);
|
|
50
40
|
else if (O(o) || R(o) || $(o)) {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
41
|
+
const i = (c, y) => {
|
|
42
|
+
const l = (p, f) => {
|
|
43
|
+
K(p, n) && (r && p.name !== r || e(p, { port: y, sender: f }));
|
|
54
44
|
};
|
|
55
|
-
|
|
45
|
+
c.addListener(l), a && a.addEventListener(
|
|
56
46
|
"abort",
|
|
57
|
-
() =>
|
|
47
|
+
() => c.removeListener(l)
|
|
58
48
|
);
|
|
59
49
|
};
|
|
60
50
|
if (R(o)) {
|
|
61
|
-
const
|
|
62
|
-
|
|
51
|
+
const c = (y) => {
|
|
52
|
+
i(y.onMessage, y);
|
|
63
53
|
};
|
|
64
|
-
o.addListener(
|
|
54
|
+
o.addListener(c), a && a.addEventListener(
|
|
65
55
|
"abort",
|
|
66
|
-
() => o.removeListener(
|
|
56
|
+
() => o.removeListener(c)
|
|
67
57
|
);
|
|
68
|
-
} else $(o) ?
|
|
58
|
+
} else $(o) ? i(o) : i(o.onMessage);
|
|
69
59
|
} else {
|
|
70
|
-
const
|
|
71
|
-
|
|
60
|
+
const i = (c) => {
|
|
61
|
+
K(c.data, n) && (r && c.data.name !== r || e(c.data, { receiveTransport: o, source: c.source }));
|
|
72
62
|
};
|
|
73
|
-
o.addEventListener("message",
|
|
63
|
+
o.addEventListener("message", i), a && a.addEventListener(
|
|
74
64
|
"abort",
|
|
75
|
-
() => o.removeEventListener("message",
|
|
65
|
+
() => o.removeEventListener("message", i)
|
|
76
66
|
);
|
|
77
67
|
}
|
|
78
68
|
};
|
|
79
69
|
J(t) ? s(t.receive) : s(t);
|
|
80
|
-
},
|
|
70
|
+
}, be = (e, t, r = "*", n = []) => {
|
|
81
71
|
const a = (s) => {
|
|
82
72
|
typeof s == "function" ? s(t, n) : O(s) ? s.postMessage(t) : z(s) ? s.postMessage(t, r, n) : k(s) ? s.send(JSON.stringify(t)) : D(s) ? s.port.postMessage(t, n) : s.postMessage(t, n);
|
|
83
73
|
};
|
|
84
74
|
J(e) ? a(e.emit) : a(e);
|
|
85
75
|
};
|
|
86
76
|
new Int8Array(), new Uint8Array(), new Uint8ClampedArray(), new Int16Array(), new Uint16Array(), new Int32Array(), new Uint32Array(), new Float16Array(), new Float32Array(), new Float64Array(), new BigInt64Array(), new BigUint64Array();
|
|
87
|
-
const k = (e) => e instanceof WebSocket,
|
|
77
|
+
const k = (e) => e instanceof WebSocket, Y = (e) => globalThis.ServiceWorkerContainer && e instanceof ServiceWorkerContainer, G = (e) => globalThis.Worker && e instanceof Worker, H = (e) => globalThis.DedicatedWorkerGlobalScope && e instanceof DedicatedWorkerGlobalScope, D = (e) => globalThis.SharedWorker && e instanceof SharedWorker, X = (e) => e instanceof MessagePort, ue = (e) => !!(e && typeof e == "object" && e[C]), me = (e) => !!(globalThis.SharedArrayBuffer && e instanceof globalThis.SharedArrayBuffer), Ae = (e) => globalThis.ArrayBuffer && e instanceof globalThis.ArrayBuffer || globalThis.MessagePort && e instanceof globalThis.MessagePort || globalThis.ReadableStream && e instanceof globalThis.ReadableStream || globalThis.WritableStream && e instanceof globalThis.WritableStream || globalThis.TransformStream && e instanceof globalThis.TransformStream ? !0 : !!(globalThis.ImageBitmap && e instanceof globalThis.ImageBitmap), O = (e, t = !1) => !!(e && typeof e == "object" && !(globalThis.Window && e instanceof globalThis.Window) && "name" in e && "disconnect" in e && "postMessage" in e && (!t || "sender" in e && "onMessage" in e && "onDisconnect" in e)), R = (e) => !!(e && typeof e == "object" && !(globalThis.Window && e instanceof globalThis.Window) && e.addListener && e.hasListener && e.removeListener), $ = (e) => !!(e && typeof e == "object" && !(globalThis.Window && e instanceof globalThis.Window) && e.addListener && e.hasListener && e.removeListener), z = (e) => {
|
|
88
78
|
if (!e || typeof e != "object") return !1;
|
|
89
79
|
try {
|
|
90
80
|
return e.window === e;
|
|
@@ -96,44 +86,44 @@ const k = (e) => e instanceof WebSocket, X = (e) => globalThis.ServiceWorkerCont
|
|
|
96
86
|
return !1;
|
|
97
87
|
}
|
|
98
88
|
}
|
|
99
|
-
},
|
|
100
|
-
const t = [], r = (n) =>
|
|
89
|
+
}, v = (e) => k(e) || O(e), x = (e) => k(e) || O(e) || R(e) || $(e), S = (e) => "isJson" in e && e.isJson === !0 || v(e) || x(e), B = (e) => z(e) || v(e) || Y(e) || G(e) || H(e) || D(e) || X(e) || Q(e), W = (e) => z(e) || x(e) || Y(e) || G(e) || H(e) || D(e) || X(e) || Z(e), Q = (e) => !!(e && typeof e == "object" && !(globalThis.Window && e instanceof globalThis.Window) && "emit" in e && (B(e.emit) || typeof e.emit == "function")), Z = (e) => !!(e && typeof e == "object" && !(globalThis.Window && e instanceof globalThis.Window) && "receive" in e && (W(e.receive) || typeof e.receive == "function")), J = (e) => Q(e) || Z(e), w = (e) => {
|
|
90
|
+
const t = [], r = (n) => me(n) ? void 0 : Ae(n) ? t.push(n) : Array.isArray(n) ? n.map(r) : n && typeof n == "object" ? Object.values(n).map(r) : void 0;
|
|
101
91
|
return r(e), t;
|
|
102
|
-
},
|
|
92
|
+
}, I = (e, t = !1) => {
|
|
103
93
|
const { port1: r, port2: n } = new MessageChannel(), a = new Promise(
|
|
104
94
|
(s) => r.addEventListener(
|
|
105
95
|
"message",
|
|
106
96
|
(o) => s(o.data)
|
|
107
97
|
)
|
|
108
98
|
);
|
|
109
|
-
return r.start(), n.postMessage(e, t ?
|
|
110
|
-
},
|
|
99
|
+
return r.start(), n.postMessage(e, t ? w(e) : []), a;
|
|
100
|
+
}, he = async () => {
|
|
111
101
|
const { port1: e } = new MessageChannel();
|
|
112
|
-
return await
|
|
113
|
-
},
|
|
102
|
+
return await I(e, !0) instanceof MessagePort;
|
|
103
|
+
}, we = async () => {
|
|
114
104
|
const e = new ArrayBuffer(1);
|
|
115
|
-
return await
|
|
116
|
-
},
|
|
105
|
+
return await I(e) instanceof ArrayBuffer;
|
|
106
|
+
}, Ue = async () => {
|
|
117
107
|
const e = new ArrayBuffer(1);
|
|
118
|
-
return await
|
|
119
|
-
},
|
|
108
|
+
return await I(e, !0) instanceof ArrayBuffer;
|
|
109
|
+
}, Te = async () => {
|
|
120
110
|
const e = new ReadableStream({
|
|
121
111
|
start(r) {
|
|
122
112
|
r.enqueue(new Uint8Array(1)), r.close();
|
|
123
113
|
}
|
|
124
114
|
});
|
|
125
|
-
return await
|
|
126
|
-
},
|
|
115
|
+
return await I(e, !0) instanceof ReadableStream;
|
|
116
|
+
}, Me = async () => {
|
|
127
117
|
const [
|
|
128
118
|
e,
|
|
129
119
|
t,
|
|
130
120
|
r,
|
|
131
121
|
n
|
|
132
122
|
] = await Promise.all([
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
he().catch(() => !1),
|
|
124
|
+
we().catch(() => !1),
|
|
125
|
+
Ue().catch(() => !1),
|
|
126
|
+
Te().catch(() => !1)
|
|
137
127
|
]);
|
|
138
128
|
return {
|
|
139
129
|
jsonOnly: !e && !t && !r && !n,
|
|
@@ -142,48 +132,48 @@ const k = (e) => e instanceof WebSocket, X = (e) => globalThis.ServiceWorkerCont
|
|
|
142
132
|
transferable: r,
|
|
143
133
|
transferableStream: n
|
|
144
134
|
};
|
|
145
|
-
},
|
|
146
|
-
...
|
|
147
|
-
type:
|
|
135
|
+
}, N = "arrayBuffer", _e = (e) => e instanceof ArrayBuffer, Be = (e, t) => ({
|
|
136
|
+
...m,
|
|
137
|
+
type: N,
|
|
148
138
|
...S(t.transport) ? { base64Buffer: new Uint8Array(e).toBase64() } : { arrayBuffer: e }
|
|
149
|
-
}),
|
|
139
|
+
}), Pe = (e, t) => "arrayBuffer" in e ? e.arrayBuffer : Uint8Array.fromBase64(e.base64Buffer).buffer, Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
150
140
|
__proto__: null,
|
|
151
|
-
box:
|
|
152
|
-
isType:
|
|
153
|
-
revive:
|
|
154
|
-
type:
|
|
155
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
156
|
-
...
|
|
157
|
-
type:
|
|
141
|
+
box: Be,
|
|
142
|
+
isType: _e,
|
|
143
|
+
revive: Pe,
|
|
144
|
+
type: N
|
|
145
|
+
}, Symbol.toStringTag, { value: "Module" })), ee = "date", Oe = (e) => e instanceof Date, Se = (e, t) => ({
|
|
146
|
+
...m,
|
|
147
|
+
type: ee,
|
|
158
148
|
ISOString: e.toISOString()
|
|
159
|
-
}),
|
|
149
|
+
}), Ie = (e, t) => new Date(e.ISOString), Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
160
150
|
__proto__: null,
|
|
161
|
-
box:
|
|
162
|
-
isType:
|
|
163
|
-
revive:
|
|
164
|
-
type:
|
|
165
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
166
|
-
...
|
|
167
|
-
type:
|
|
151
|
+
box: Se,
|
|
152
|
+
isType: Oe,
|
|
153
|
+
revive: Ie,
|
|
154
|
+
type: ee
|
|
155
|
+
}, Symbol.toStringTag, { value: "Module" })), te = "headers", Le = (e) => e instanceof Headers, je = (e, t) => ({
|
|
156
|
+
...m,
|
|
157
|
+
type: te,
|
|
168
158
|
entries: [...e.entries()]
|
|
169
|
-
}),
|
|
159
|
+
}), Re = (e, t) => new Headers(e.entries), $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
170
160
|
__proto__: null,
|
|
171
|
-
box:
|
|
172
|
-
isType:
|
|
173
|
-
revive:
|
|
174
|
-
type:
|
|
175
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
176
|
-
...
|
|
177
|
-
type:
|
|
161
|
+
box: je,
|
|
162
|
+
isType: Le,
|
|
163
|
+
revive: Re,
|
|
164
|
+
type: te
|
|
165
|
+
}, Symbol.toStringTag, { value: "Module" })), re = "error", We = (e) => e instanceof Error, Fe = (e, t) => ({
|
|
166
|
+
...m,
|
|
167
|
+
type: re,
|
|
178
168
|
message: e.message,
|
|
179
169
|
stack: e.stack || e.toString()
|
|
180
|
-
}),
|
|
170
|
+
}), ke = (e, t) => new Error(e.message, { cause: e.stack }), De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
181
171
|
__proto__: null,
|
|
182
|
-
box:
|
|
183
|
-
isType:
|
|
184
|
-
revive:
|
|
185
|
-
type:
|
|
186
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
172
|
+
box: Fe,
|
|
173
|
+
isType: We,
|
|
174
|
+
revive: ke,
|
|
175
|
+
type: re
|
|
176
|
+
}, Symbol.toStringTag, { value: "Module" })), ne = "typedArray", ze = [
|
|
187
177
|
Int8Array,
|
|
188
178
|
Uint8Array,
|
|
189
179
|
Uint8ClampedArray,
|
|
@@ -198,155 +188,153 @@ const k = (e) => e instanceof WebSocket, X = (e) => globalThis.ServiceWorkerCont
|
|
|
198
188
|
BigUint64Array
|
|
199
189
|
];
|
|
200
190
|
new Int8Array(), new Uint8Array(), new Uint8ClampedArray(), new Int16Array(), new Uint16Array(), new Int32Array(), new Uint32Array(), new Float16Array(), new Float32Array(), new Float64Array(), new BigInt64Array(), new BigUint64Array();
|
|
201
|
-
const
|
|
191
|
+
const se = (e) => {
|
|
202
192
|
const t = e instanceof Int8Array ? "Int8Array" : e instanceof Uint8Array ? "Uint8Array" : e instanceof Uint8ClampedArray ? "Uint8ClampedArray" : e instanceof Int16Array ? "Int16Array" : e instanceof Uint16Array ? "Uint16Array" : e instanceof Int32Array ? "Int32Array" : e instanceof Uint32Array ? "Uint32Array" : e instanceof Float16Array ? "Float16Array" : e instanceof Float32Array ? "Float32Array" : e instanceof Float64Array ? "Float64Array" : e instanceof BigInt64Array ? "BigInt64Array" : e instanceof BigUint64Array ? "BigUint64Array" : void 0;
|
|
203
193
|
if (t === void 0) throw new Error("Unknown typed array type");
|
|
204
194
|
return t;
|
|
205
|
-
},
|
|
195
|
+
}, oe = (e) => {
|
|
206
196
|
const t = e === "Int8Array" ? Int8Array : e === "Uint8Array" ? Uint8Array : e === "Uint8ClampedArray" ? Uint8ClampedArray : e === "Int16Array" ? Int16Array : e === "Uint16Array" ? Uint16Array : e === "Int32Array" ? Int32Array : e === "Uint32Array" ? Uint32Array : e === "Float16Array" ? Float16Array : e === "Float32Array" ? Float32Array : e === "Float64Array" ? Float64Array : e === "BigInt64Array" ? BigInt64Array : e === "BigUint64Array" ? BigUint64Array : void 0;
|
|
207
197
|
if (t === void 0) throw new Error("Unknown typed array type");
|
|
208
198
|
return t;
|
|
209
|
-
},
|
|
210
|
-
...
|
|
211
|
-
type:
|
|
212
|
-
typedArrayType:
|
|
199
|
+
}, Je = (e) => ze.some((t) => e instanceof t), Ve = (e, t) => ({
|
|
200
|
+
...m,
|
|
201
|
+
type: ne,
|
|
202
|
+
typedArrayType: se(e),
|
|
213
203
|
...S(t.transport) ? { base64Buffer: new Uint8Array(e.buffer).toBase64() } : { arrayBuffer: e.buffer }
|
|
214
|
-
}),
|
|
215
|
-
const r =
|
|
204
|
+
}), qe = (e, t) => {
|
|
205
|
+
const r = oe(e.typedArrayType), n = "arrayBuffer" in e ? e.arrayBuffer : Uint8Array.fromBase64(e.base64Buffer).buffer;
|
|
216
206
|
return new r(n);
|
|
217
|
-
},
|
|
207
|
+
}, Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
218
208
|
__proto__: null,
|
|
219
|
-
box:
|
|
220
|
-
isType:
|
|
221
|
-
revive:
|
|
222
|
-
type:
|
|
223
|
-
typedArrayToType:
|
|
224
|
-
typedArrayTypeToTypedArrayConstructor:
|
|
225
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
209
|
+
box: Ve,
|
|
210
|
+
isType: Je,
|
|
211
|
+
revive: qe,
|
|
212
|
+
type: ne,
|
|
213
|
+
typedArrayToType: se,
|
|
214
|
+
typedArrayTypeToTypedArrayConstructor: oe
|
|
215
|
+
}, Symbol.toStringTag, { value: "Module" })), P = new FinalizationRegistry((e) => {
|
|
226
216
|
e.sendMessage({
|
|
227
217
|
type: "message-port-close",
|
|
228
218
|
remoteUuid: e.remoteUuid,
|
|
229
219
|
portId: e.portId
|
|
230
220
|
}), e.cleanup();
|
|
231
|
-
}), F = "messagePort",
|
|
221
|
+
}), F = "messagePort", Ye = (e) => e instanceof MessagePort, ae = (e) => e !== null && typeof e == "object" && M in e && e[M] === "revivable", E = (e, t) => {
|
|
232
222
|
if (S(t.transport)) {
|
|
233
|
-
let n = function({ data:
|
|
223
|
+
let n = function({ data: y }) {
|
|
234
224
|
t.sendMessage({
|
|
235
225
|
type: "message",
|
|
236
226
|
remoteUuid: t.remoteUuid,
|
|
237
|
-
data:
|
|
227
|
+
data: ae(y) ? y : b(y, t),
|
|
238
228
|
portId: s
|
|
239
229
|
});
|
|
240
230
|
};
|
|
241
|
-
const a = e, s = t.messageChannels.getUniqueUuid(), o = new WeakRef(a),
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (f.portId !== s) return;
|
|
231
|
+
const a = e, s = t.messageChannels.getUniqueUuid(), o = new WeakRef(a), i = ({ detail: y }) => {
|
|
232
|
+
if (y.type === "message-port-close") {
|
|
233
|
+
if (y.portId !== s) return;
|
|
245
234
|
t.messageChannels.free(s);
|
|
246
|
-
const
|
|
247
|
-
|
|
235
|
+
const p = o.deref();
|
|
236
|
+
p && (P.unregister(p), p.close()), t.eventTarget.removeEventListener("message", i);
|
|
248
237
|
return;
|
|
249
238
|
}
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
253
|
-
t.eventTarget.removeEventListener("message",
|
|
239
|
+
if (y.type !== "message" || y.portId !== s) return;
|
|
240
|
+
const l = o.deref();
|
|
241
|
+
if (!l) {
|
|
242
|
+
t.eventTarget.removeEventListener("message", i);
|
|
254
243
|
return;
|
|
255
244
|
}
|
|
256
|
-
|
|
245
|
+
l.postMessage(y.data, w(y.data));
|
|
257
246
|
};
|
|
258
|
-
return
|
|
247
|
+
return P.register(o.deref(), {
|
|
259
248
|
sendMessage: t.sendMessage,
|
|
260
249
|
remoteUuid: t.remoteUuid,
|
|
261
250
|
portId: s,
|
|
262
251
|
cleanup: () => {
|
|
263
|
-
t.messageChannels.free(s), t.eventTarget.removeEventListener("message",
|
|
252
|
+
t.messageChannels.free(s), t.eventTarget.removeEventListener("message", i), o.deref()?.removeEventListener("message", n), o.deref()?.close();
|
|
264
253
|
}
|
|
265
|
-
}, o.deref()), o.deref()?.addEventListener("message", n), o.deref()?.start(), t.eventTarget.addEventListener("message",
|
|
266
|
-
...
|
|
254
|
+
}, o.deref()), o.deref()?.addEventListener("message", n), o.deref()?.start(), t.eventTarget.addEventListener("message", i), {
|
|
255
|
+
...m,
|
|
267
256
|
type: F,
|
|
268
257
|
portId: s
|
|
269
258
|
};
|
|
270
259
|
}
|
|
271
260
|
return {
|
|
272
|
-
...
|
|
261
|
+
...m,
|
|
273
262
|
type: F,
|
|
274
263
|
port: e
|
|
275
264
|
};
|
|
276
|
-
},
|
|
265
|
+
}, L = (e, t) => {
|
|
277
266
|
if ("portId" in e) {
|
|
278
|
-
let r = function({ data:
|
|
267
|
+
let r = function({ data: f }) {
|
|
279
268
|
t.sendMessage({
|
|
280
269
|
type: "message",
|
|
281
270
|
remoteUuid: t.remoteUuid,
|
|
282
|
-
data:
|
|
271
|
+
data: ae(f) ? f : b(f, t),
|
|
283
272
|
portId: n
|
|
284
273
|
});
|
|
285
274
|
};
|
|
286
|
-
const { portId: n } = e, { port1: a, port2: s } = new MessageChannel(), o = t.messageChannels.get(e.portId), { port1:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (!u) {
|
|
275
|
+
const { portId: n } = e, { port1: a, port2: s } = new MessageChannel(), o = t.messageChannels.get(e.portId), { port1: i } = o || t.messageChannels.alloc(e.portId), c = new WeakRef(a), y = ({ detail: f }) => {
|
|
276
|
+
if (f.type !== "message-port-close" || f.portId !== n) return;
|
|
277
|
+
const h = c.deref();
|
|
278
|
+
h && P.unregister(h), p();
|
|
279
|
+
}, l = ({ data: f }) => {
|
|
280
|
+
if (f.type !== "message" || f.portId !== n) return;
|
|
281
|
+
const h = c.deref();
|
|
282
|
+
if (!h) {
|
|
295
283
|
p();
|
|
296
284
|
return;
|
|
297
285
|
}
|
|
298
|
-
if (t.messagePorts.has(
|
|
299
|
-
s.postMessage(
|
|
286
|
+
if (t.messagePorts.has(h))
|
|
287
|
+
s.postMessage(f.data);
|
|
300
288
|
else {
|
|
301
|
-
const
|
|
302
|
-
s.postMessage(
|
|
289
|
+
const _ = A(f.data, t);
|
|
290
|
+
s.postMessage(_, w(_));
|
|
303
291
|
}
|
|
304
292
|
}, p = () => {
|
|
305
|
-
t.eventTarget.removeEventListener("message",
|
|
306
|
-
const
|
|
307
|
-
|
|
293
|
+
t.eventTarget.removeEventListener("message", y), i.removeEventListener("message", l), s.removeEventListener("message", r), s.close();
|
|
294
|
+
const f = t.messageChannels.get(n);
|
|
295
|
+
f && (f.port1.close(), f.port2 && f.port2.close()), t.messageChannels.free(n);
|
|
308
296
|
};
|
|
309
|
-
return
|
|
297
|
+
return P.register(a, {
|
|
310
298
|
sendMessage: t.sendMessage,
|
|
311
299
|
remoteUuid: t.remoteUuid,
|
|
312
300
|
portId: n,
|
|
313
301
|
cleanup: p
|
|
314
|
-
}, a), s.addEventListener("message", r), s.start(), t.eventTarget.addEventListener("message",
|
|
302
|
+
}, a), s.addEventListener("message", r), s.start(), t.eventTarget.addEventListener("message", y), i.addEventListener("message", l), i.start(), a;
|
|
315
303
|
}
|
|
316
304
|
return e.port;
|
|
317
|
-
},
|
|
305
|
+
}, Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
318
306
|
__proto__: null,
|
|
319
|
-
box:
|
|
320
|
-
isType:
|
|
321
|
-
revive:
|
|
307
|
+
box: E,
|
|
308
|
+
isType: Ye,
|
|
309
|
+
revive: L,
|
|
322
310
|
type: F
|
|
323
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
311
|
+
}, Symbol.toStringTag, { value: "Module" })), ie = "promise", He = (e) => e instanceof Promise, Xe = (e, t) => {
|
|
324
312
|
const r = e, { port1: n, port2: a } = new MessageChannel();
|
|
325
313
|
t.messagePorts.add(a);
|
|
326
314
|
const s = (o) => {
|
|
327
|
-
const
|
|
328
|
-
n.postMessage(
|
|
315
|
+
const i = b(o, t);
|
|
316
|
+
n.postMessage(i, w(i)), n.close(), t.messagePorts.delete(a);
|
|
329
317
|
};
|
|
330
318
|
return r.then((o) => s({ type: "resolve", data: o })).catch((o) => s({ type: "reject", error: o?.stack ?? String(o) })), {
|
|
331
|
-
...
|
|
332
|
-
type:
|
|
333
|
-
port:
|
|
319
|
+
...m,
|
|
320
|
+
type: ie,
|
|
321
|
+
port: E(a, t)
|
|
334
322
|
};
|
|
335
|
-
},
|
|
336
|
-
const r =
|
|
323
|
+
}, ve = (e, t) => {
|
|
324
|
+
const r = L(e.port, t);
|
|
337
325
|
return t.messagePorts.add(r), new Promise((n, a) => {
|
|
338
326
|
r.addEventListener("message", (s) => {
|
|
339
|
-
const o = s.data,
|
|
340
|
-
|
|
327
|
+
const o = s.data, i = A(o, t);
|
|
328
|
+
i.type === "resolve" ? n(i.data) : a(i.error), t.messagePorts.delete(r), r.close();
|
|
341
329
|
}, { once: !0 }), r.start();
|
|
342
330
|
});
|
|
343
|
-
},
|
|
331
|
+
}, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
344
332
|
__proto__: null,
|
|
345
|
-
box:
|
|
346
|
-
isType:
|
|
347
|
-
revive:
|
|
348
|
-
type:
|
|
349
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
333
|
+
box: Xe,
|
|
334
|
+
isType: He,
|
|
335
|
+
revive: ve,
|
|
336
|
+
type: ie
|
|
337
|
+
}, Symbol.toStringTag, { value: "Module" })), ce = "function", Qe = new FinalizationRegistry((e) => {
|
|
350
338
|
try {
|
|
351
339
|
e.port.postMessage({ __osra_close__: !0 });
|
|
352
340
|
} catch {
|
|
@@ -355,7 +343,7 @@ const ae = (e) => {
|
|
|
355
343
|
e.port.close();
|
|
356
344
|
} catch {
|
|
357
345
|
}
|
|
358
|
-
}),
|
|
346
|
+
}), Ze = (e) => typeof e == "function", Ne = (e, t) => {
|
|
359
347
|
const { port1: r, port2: n } = new MessageChannel();
|
|
360
348
|
t.messagePorts.add(n);
|
|
361
349
|
const a = () => {
|
|
@@ -366,268 +354,264 @@ const ae = (e) => {
|
|
|
366
354
|
a();
|
|
367
355
|
return;
|
|
368
356
|
}
|
|
369
|
-
const [o,
|
|
370
|
-
o.postMessage(
|
|
357
|
+
const [o, i] = A(s, t), c = (async () => e(...i))(), y = b(c, t);
|
|
358
|
+
o.postMessage(y, w(y));
|
|
371
359
|
}), r.start(), {
|
|
372
|
-
...
|
|
373
|
-
type:
|
|
360
|
+
...m,
|
|
361
|
+
type: ce,
|
|
374
362
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
375
|
-
port:
|
|
363
|
+
port: E(n, t)
|
|
376
364
|
};
|
|
377
|
-
},
|
|
378
|
-
const r =
|
|
379
|
-
const { port1:
|
|
380
|
-
t.messagePorts.add(
|
|
381
|
-
const
|
|
382
|
-
r.postMessage(
|
|
383
|
-
|
|
384
|
-
|
|
365
|
+
}, et = (e, t) => {
|
|
366
|
+
const r = L(e.port, t), n = (...a) => new Promise((s, o) => {
|
|
367
|
+
const { port1: i, port2: c } = new MessageChannel();
|
|
368
|
+
t.messagePorts.add(c);
|
|
369
|
+
const y = b([c, a], t);
|
|
370
|
+
r.postMessage(y, w(y)), t.messagePorts.delete(c), i.addEventListener("message", ({ data: l }) => {
|
|
371
|
+
A(l, t).then(s).catch(o).finally(() => {
|
|
372
|
+
i.close();
|
|
385
373
|
});
|
|
386
|
-
}, { once: !0 }),
|
|
374
|
+
}, { once: !0 }), i.start();
|
|
387
375
|
});
|
|
388
|
-
return
|
|
389
|
-
},
|
|
376
|
+
return Qe.register(n, { port: r }, n), n;
|
|
377
|
+
}, tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
390
378
|
__proto__: null,
|
|
391
|
-
box:
|
|
392
|
-
isType:
|
|
393
|
-
revive:
|
|
394
|
-
type:
|
|
395
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
379
|
+
box: Ne,
|
|
380
|
+
isType: Ze,
|
|
381
|
+
revive: et,
|
|
382
|
+
type: ce
|
|
383
|
+
}, Symbol.toStringTag, { value: "Module" })), ye = "readableStream", rt = (e) => e instanceof ReadableStream, nt = (e, t) => {
|
|
396
384
|
const { port1: r, port2: n } = new MessageChannel();
|
|
397
385
|
t.messagePorts.add(n);
|
|
398
386
|
const a = e.getReader();
|
|
399
387
|
return r.addEventListener("message", async ({ data: s }) => {
|
|
400
|
-
const { type: o } =
|
|
388
|
+
const { type: o } = A(s, t);
|
|
401
389
|
if (o === "pull") {
|
|
402
|
-
const
|
|
403
|
-
r.postMessage(
|
|
390
|
+
const i = a.read(), c = b(i, t);
|
|
391
|
+
r.postMessage(c, w(c));
|
|
404
392
|
} else
|
|
405
393
|
a.cancel(), r.close();
|
|
406
394
|
}), r.start(), {
|
|
407
|
-
...
|
|
408
|
-
type:
|
|
409
|
-
port:
|
|
395
|
+
...m,
|
|
396
|
+
type: ye,
|
|
397
|
+
port: E(n, t)
|
|
410
398
|
};
|
|
411
|
-
},
|
|
412
|
-
const r =
|
|
399
|
+
}, st = (e, t) => {
|
|
400
|
+
const r = L(e.port, t);
|
|
413
401
|
return t.messagePorts.add(r), r.start(), new ReadableStream({
|
|
414
402
|
start(n) {
|
|
415
403
|
},
|
|
416
404
|
pull(n) {
|
|
417
405
|
return new Promise((a, s) => {
|
|
418
406
|
r.addEventListener("message", async ({ data: o }) => {
|
|
419
|
-
|
|
420
|
-
|
|
407
|
+
A(o, t).then((c) => {
|
|
408
|
+
c.done ? n.close() : n.enqueue(c.value), a();
|
|
421
409
|
}).catch(s);
|
|
422
|
-
}, { once: !0 }), r.postMessage(
|
|
410
|
+
}, { once: !0 }), r.postMessage(b({ type: "pull" }, t));
|
|
423
411
|
});
|
|
424
412
|
},
|
|
425
413
|
cancel() {
|
|
426
|
-
r.postMessage(
|
|
414
|
+
r.postMessage(b({ type: "cancel" }, t)), r.close();
|
|
427
415
|
}
|
|
428
416
|
});
|
|
429
|
-
},
|
|
417
|
+
}, ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
430
418
|
__proto__: null,
|
|
431
|
-
box:
|
|
432
|
-
isType:
|
|
433
|
-
revive:
|
|
434
|
-
type:
|
|
435
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
419
|
+
box: nt,
|
|
420
|
+
isType: rt,
|
|
421
|
+
revive: st,
|
|
422
|
+
type: ye
|
|
423
|
+
}, Symbol.toStringTag, { value: "Module" })), at = [
|
|
424
|
+
Ce,
|
|
425
|
+
Ee,
|
|
426
|
+
$e,
|
|
427
|
+
De,
|
|
440
428
|
Ke,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
], m = (e, t) => {
|
|
429
|
+
xe,
|
|
430
|
+
tt,
|
|
431
|
+
Ge,
|
|
432
|
+
ot
|
|
433
|
+
], b = (e, t) => {
|
|
447
434
|
const r = t.revivableModules.find((n) => n.isType(e));
|
|
448
|
-
return r?.isType(e) ? r.box(e, t) : Array.isArray(e) ? e.map((n) =>
|
|
435
|
+
return r?.isType(e) ? r.box(e, t) : Array.isArray(e) ? e.map((n) => b(n, t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(
|
|
449
436
|
Object.entries(e).map(([n, a]) => [
|
|
450
437
|
n,
|
|
451
|
-
|
|
438
|
+
b(a, t)
|
|
452
439
|
])
|
|
453
440
|
) : e;
|
|
454
|
-
},
|
|
455
|
-
if (
|
|
441
|
+
}, A = (e, t) => {
|
|
442
|
+
if (le(e)) {
|
|
456
443
|
const r = t.revivableModules.find((n) => n.type === e.type);
|
|
457
444
|
if (r)
|
|
458
445
|
return r.revive(e, t);
|
|
459
446
|
}
|
|
460
|
-
return Array.isArray(e) ? e.map((r) =>
|
|
447
|
+
return Array.isArray(e) ? e.map((r) => A(r, t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(
|
|
461
448
|
Object.entries(e).map(([r, n]) => [
|
|
462
449
|
r,
|
|
463
|
-
|
|
450
|
+
A(n, t)
|
|
464
451
|
])
|
|
465
452
|
) : e;
|
|
466
|
-
},
|
|
467
|
-
const
|
|
453
|
+
}, it = ({ transport: e, value: t, uuid: r, remoteUuid: n, platformCapabilities: a, eventTarget: s, send: o, close: i }) => {
|
|
454
|
+
const c = {
|
|
468
455
|
platformCapabilities: a,
|
|
469
456
|
transport: e,
|
|
470
457
|
remoteUuid: n,
|
|
471
458
|
messagePorts: /* @__PURE__ */ new Set(),
|
|
472
|
-
messageChannels:
|
|
459
|
+
messageChannels: pe(),
|
|
473
460
|
sendMessage: o,
|
|
474
461
|
eventTarget: s,
|
|
475
|
-
revivableModules:
|
|
476
|
-
messageContext: void 0
|
|
462
|
+
revivableModules: at
|
|
477
463
|
};
|
|
478
|
-
let
|
|
479
|
-
const
|
|
480
|
-
|
|
464
|
+
let y;
|
|
465
|
+
const l = new Promise((p, f) => {
|
|
466
|
+
y = p;
|
|
481
467
|
});
|
|
482
468
|
return s.addEventListener("message", ({ detail: p }) => {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
l({ message: i, messageContext: u });
|
|
469
|
+
if (p.type === "init") {
|
|
470
|
+
y(p);
|
|
486
471
|
return;
|
|
487
|
-
} else
|
|
472
|
+
} else p.type === "message" && c.messageChannels.getOrAlloc(p.portId).port2?.postMessage(p);
|
|
488
473
|
}), o({
|
|
489
474
|
type: "init",
|
|
490
475
|
remoteUuid: n,
|
|
491
|
-
data:
|
|
476
|
+
data: b(t, c)
|
|
492
477
|
}), {
|
|
493
|
-
revivableContext:
|
|
478
|
+
revivableContext: c,
|
|
494
479
|
close: () => {
|
|
495
480
|
},
|
|
496
|
-
remoteValue:
|
|
481
|
+
remoteValue: l.then((p) => A(p.data, c))
|
|
497
482
|
};
|
|
498
|
-
},
|
|
483
|
+
}, ct = ({ value: e, uuid: t, platformCapabilities: r, send: n, close: a }) => ({
|
|
499
484
|
close: () => {
|
|
500
485
|
},
|
|
501
486
|
remoteValueProxy: new Proxy(
|
|
502
487
|
new Function(),
|
|
503
488
|
{
|
|
504
|
-
apply: (s, o,
|
|
489
|
+
apply: (s, o, i) => {
|
|
505
490
|
},
|
|
506
491
|
get: (s, o) => {
|
|
507
492
|
}
|
|
508
493
|
}
|
|
509
494
|
)
|
|
510
495
|
});
|
|
511
|
-
var
|
|
496
|
+
var yt = class extends EventTarget {
|
|
512
497
|
dispatchTypedEvent(e, t) {
|
|
513
498
|
return super.dispatchEvent(t);
|
|
514
499
|
}
|
|
515
500
|
};
|
|
516
|
-
const
|
|
501
|
+
const ft = async (e, {
|
|
517
502
|
transport: t,
|
|
518
503
|
name: r,
|
|
519
504
|
remoteName: n,
|
|
520
|
-
key: a =
|
|
505
|
+
key: a = de,
|
|
521
506
|
origin: s = "*",
|
|
522
507
|
unregisterSignal: o,
|
|
523
|
-
platformCapabilities:
|
|
524
|
-
transferAll:
|
|
525
|
-
logger:
|
|
508
|
+
platformCapabilities: i,
|
|
509
|
+
transferAll: c,
|
|
510
|
+
logger: y
|
|
526
511
|
}) => {
|
|
527
|
-
const
|
|
512
|
+
const l = {
|
|
528
513
|
isJson: "isJson" in t && t.isJson !== void 0 ? t.isJson : S(t),
|
|
529
514
|
...J(t) ? t : {
|
|
530
515
|
emit: t,
|
|
531
516
|
receive: t
|
|
532
517
|
}
|
|
533
|
-
}, p =
|
|
534
|
-
let
|
|
535
|
-
const
|
|
536
|
-
|
|
518
|
+
}, p = i ?? await Me(), f = /* @__PURE__ */ new Map();
|
|
519
|
+
let h;
|
|
520
|
+
const _ = new Promise((d) => {
|
|
521
|
+
h = d;
|
|
537
522
|
});
|
|
538
|
-
let
|
|
523
|
+
let u = globalThis.crypto.randomUUID(), V = !1;
|
|
539
524
|
o && o.addEventListener("abort", () => {
|
|
540
|
-
|
|
525
|
+
V = !0;
|
|
541
526
|
});
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
const g =
|
|
545
|
-
|
|
527
|
+
const U = (d, T) => {
|
|
528
|
+
if (V) return;
|
|
529
|
+
const g = w(T);
|
|
530
|
+
be(
|
|
546
531
|
d,
|
|
547
532
|
{
|
|
548
|
-
[
|
|
533
|
+
[C]: a,
|
|
549
534
|
name: r,
|
|
550
|
-
uuid:
|
|
551
|
-
...
|
|
535
|
+
uuid: u,
|
|
536
|
+
...T
|
|
552
537
|
},
|
|
553
538
|
s,
|
|
554
539
|
g
|
|
555
540
|
);
|
|
556
|
-
},
|
|
557
|
-
if (d.uuid !==
|
|
558
|
-
if (!
|
|
541
|
+
}, fe = async (d, T) => {
|
|
542
|
+
if (d.uuid !== u) {
|
|
543
|
+
if (!B(l))
|
|
559
544
|
throw new Error("Unidirectional receiving mode not implemented");
|
|
560
545
|
if (d.type === "announce") {
|
|
561
546
|
if (!d.remoteUuid) {
|
|
562
|
-
|
|
547
|
+
U(l, { type: "announce", remoteUuid: d.uuid });
|
|
563
548
|
return;
|
|
564
549
|
}
|
|
565
|
-
if (d.remoteUuid !==
|
|
550
|
+
if (d.remoteUuid !== u || f.has(d.uuid))
|
|
566
551
|
return;
|
|
567
|
-
|
|
568
|
-
const g = new
|
|
552
|
+
U(l, { type: "announce", remoteUuid: d.uuid });
|
|
553
|
+
const g = new yt(), q = {
|
|
569
554
|
type: "bidirectional",
|
|
570
555
|
eventTarget: g,
|
|
571
|
-
connection:
|
|
572
|
-
transport:
|
|
556
|
+
connection: it({
|
|
557
|
+
transport: l,
|
|
573
558
|
value: e,
|
|
574
|
-
uuid:
|
|
559
|
+
uuid: u,
|
|
575
560
|
remoteUuid: d.uuid,
|
|
576
561
|
platformCapabilities: p,
|
|
577
562
|
eventTarget: g,
|
|
578
|
-
send: (
|
|
579
|
-
close: () => void
|
|
563
|
+
send: (j) => U(l, j),
|
|
564
|
+
close: () => void f.delete(d.uuid)
|
|
580
565
|
})
|
|
581
566
|
};
|
|
582
|
-
|
|
583
|
-
(
|
|
567
|
+
f.set(d.uuid, q), q.connection.remoteValue.then(
|
|
568
|
+
(j) => h(j)
|
|
584
569
|
);
|
|
585
570
|
} else if (d.type === "reject-uuid-taken") {
|
|
586
|
-
if (d.remoteUuid !==
|
|
587
|
-
|
|
571
|
+
if (d.remoteUuid !== u) return;
|
|
572
|
+
u = globalThis.crypto.randomUUID(), U(l, { type: "announce" });
|
|
588
573
|
} else if (d.type === "close") {
|
|
589
|
-
if (d.remoteUuid !==
|
|
590
|
-
const g =
|
|
574
|
+
if (d.remoteUuid !== u) return;
|
|
575
|
+
const g = f.get(d.uuid);
|
|
591
576
|
if (!g) {
|
|
592
577
|
console.warn(`Connection not found for remoteUuid: ${d.uuid}`);
|
|
593
578
|
return;
|
|
594
579
|
}
|
|
595
|
-
g.connection.close(),
|
|
580
|
+
g.connection.close(), f.delete(d.uuid);
|
|
596
581
|
} else {
|
|
597
|
-
if (d.remoteUuid !==
|
|
598
|
-
const g =
|
|
582
|
+
if (d.remoteUuid !== u) return;
|
|
583
|
+
const g = f.get(d.uuid);
|
|
599
584
|
if (!g) {
|
|
600
585
|
console.warn(`Connection not found for remoteUuid: ${d.uuid}`);
|
|
601
586
|
return;
|
|
602
587
|
}
|
|
603
588
|
g.type !== "unidirectional-emitting" && g.eventTarget.dispatchTypedEvent(
|
|
604
589
|
"message",
|
|
605
|
-
new CustomEvent("message", { detail:
|
|
590
|
+
new CustomEvent("message", { detail: d })
|
|
606
591
|
);
|
|
607
592
|
}
|
|
608
593
|
}
|
|
609
594
|
};
|
|
610
|
-
if (W(
|
|
611
|
-
listener:
|
|
612
|
-
transport:
|
|
595
|
+
if (W(l) && ge({
|
|
596
|
+
listener: fe,
|
|
597
|
+
transport: l,
|
|
613
598
|
remoteName: n,
|
|
614
599
|
key: a,
|
|
615
600
|
unregisterSignal: o
|
|
616
|
-
}),
|
|
617
|
-
const { remoteValueProxy: d } =
|
|
601
|
+
}), B(l) && U(l, { type: "announce" }), B(l) && !W(l)) {
|
|
602
|
+
const { remoteValueProxy: d } = ct({
|
|
618
603
|
value: e,
|
|
619
|
-
uuid:
|
|
604
|
+
uuid: u,
|
|
620
605
|
platformCapabilities: p,
|
|
621
|
-
send: (
|
|
622
|
-
close: () =>
|
|
606
|
+
send: (T) => U(l, T),
|
|
607
|
+
close: () => f.delete(u)
|
|
623
608
|
});
|
|
624
609
|
return d;
|
|
625
610
|
}
|
|
626
|
-
return
|
|
611
|
+
return _;
|
|
627
612
|
};
|
|
628
613
|
export {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
ut as expose
|
|
614
|
+
m as BoxBase,
|
|
615
|
+
ft as expose
|
|
632
616
|
};
|
|
633
617
|
//# sourceMappingURL=index.js.map
|