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