osra 0.2.0 → 0.2.1
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/README.md +284 -34
- package/build/extension/background.js +2 -0
- package/build/extension/background.js.map +1 -0
- package/build/extension/chunks/index.js +2 -0
- package/build/extension/chunks/index.js.map +1 -0
- package/build/extension/content.js +2 -0
- package/build/extension/content.js.map +1 -0
- package/build/extension/manifest.json +21 -0
- package/build/extension/popup.html +120 -0
- package/build/extension/popup.js +2 -0
- package/build/extension/popup.js.map +1 -0
- package/build/extension-test/background.js +753 -0
- package/build/extension-test/background.js.map +1 -0
- package/build/extension-test/content.js +4585 -0
- package/build/extension-test/content.js.map +1 -0
- package/build/extension-test/manifest.json +22 -0
- package/build/extension-test/popup.html +106 -0
- package/build/extension-test/popup.js +4610 -0
- package/build/extension-test/popup.js.map +1 -0
- package/build/extension-test-firefox/background.js +5464 -0
- package/build/extension-test-firefox/background.js.map +1 -0
- package/build/extension-test-firefox/content.js +5286 -0
- package/build/extension-test-firefox/content.js.map +1 -0
- package/build/extension-test-firefox/manifest.json +27 -0
- package/build/extension-test-firefox/popup.html +106 -0
- package/build/extension-test-firefox/popup.js +5213 -0
- package/build/extension-test-firefox/popup.js.map +1 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +30 -30
- package/build/index.js.map +1 -1
- package/build/test.js +24987 -0
- package/build/test.js.map +1 -0
- package/package.json +9 -4
package/build/index.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ declare type Transport = PlatformTransport | CustomTransport;
|
|
|
131
131
|
|
|
132
132
|
declare type TypedArray = typeof typedArrays[number];
|
|
133
133
|
|
|
134
|
-
declare const typedArrays: (BigInt64Array<ArrayBuffer> | BigUint64Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Float64Array<ArrayBuffer> |
|
|
134
|
+
declare const typedArrays: (BigInt64Array<ArrayBuffer> | BigUint64Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Float64Array<ArrayBuffer> | Uint8ClampedArray<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float16Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Uint8Array<ArrayBuffer>)[];
|
|
135
135
|
|
|
136
136
|
declare type UnidirectionalConnectionMessage = {
|
|
137
137
|
type: 'message';
|
package/build/index.js
CHANGED
|
@@ -32,17 +32,17 @@ const M = "__OSRA_KEY__", oe = "__OSRA_DEFAULT_KEY__", E = "__OSRA_BOX__", ae =
|
|
|
32
32
|
const s = (a) => {
|
|
33
33
|
if (typeof a == "function")
|
|
34
34
|
a(e);
|
|
35
|
-
else if (I(a) ||
|
|
35
|
+
else if (I(a) || O(a) || L(a)) {
|
|
36
36
|
const c = (i, l) => {
|
|
37
|
-
const f = (d,
|
|
38
|
-
$(d, n) && (t && d.name !== t || e(d, { port: l, sender:
|
|
37
|
+
const f = (d, g) => {
|
|
38
|
+
$(d, n) && (t && d.name !== t || e(d, { port: l, sender: g }));
|
|
39
39
|
};
|
|
40
40
|
i.addListener(f), o && o.addEventListener(
|
|
41
41
|
"abort",
|
|
42
42
|
() => i.removeListener(f)
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
-
if (
|
|
45
|
+
if (O(a)) {
|
|
46
46
|
const i = (l) => {
|
|
47
47
|
c(l.onMessage, l);
|
|
48
48
|
};
|
|
@@ -90,8 +90,8 @@ const fe = (e) => {
|
|
|
90
90
|
const r = 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;
|
|
91
91
|
if (r === void 0) throw new Error("Unknown typed array type");
|
|
92
92
|
return r;
|
|
93
|
-
}, j = (e) => ye.some((r) => e instanceof r), k = (e) => e instanceof WebSocket, H = (e) => globalThis.ServiceWorkerContainer && e instanceof ServiceWorkerContainer, Q = (e) => e instanceof Worker, Z = (e) => globalThis.DedicatedWorkerGlobalScope && e instanceof DedicatedWorkerGlobalScope, W = (e) => globalThis.SharedWorker && e instanceof SharedWorker, C = (e) => e instanceof MessagePort, D = (e) => e instanceof Promise, _ = (e) => typeof e == "function",
|
|
94
|
-
const r = [], t = (n) =>
|
|
93
|
+
}, j = (e) => ye.some((r) => e instanceof r), k = (e) => e instanceof WebSocket, H = (e) => globalThis.ServiceWorkerContainer && e instanceof ServiceWorkerContainer, Q = (e) => globalThis.Worker && e instanceof Worker, Z = (e) => globalThis.DedicatedWorkerGlobalScope && e instanceof DedicatedWorkerGlobalScope, W = (e) => globalThis.SharedWorker && e instanceof SharedWorker, C = (e) => e instanceof MessagePort, D = (e) => e instanceof Promise, _ = (e) => typeof e == "function", T = (e) => e instanceof ArrayBuffer, B = (e) => e instanceof ReadableStream, V = (e) => e instanceof Date, J = (e) => e instanceof Error, pe = (e) => _(e) || D(e) || j(e) || V(e) || J(e), le = (e) => !!(e && typeof e == "object" && e[M]), ge = (e) => !!(globalThis.SharedArrayBuffer && e instanceof globalThis.SharedArrayBuffer), N = (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), I = (e, r = !1) => !!(e && typeof e == "object" && e.name && e.disconnect && e.postMessage && (!r || e.sender && e.onMessage && e.onDisconnect)), O = (e) => !!(e && typeof e == "object" && e.addListener && e.hasListener && e.removeListener), L = (e) => !!(e && typeof e == "object" && e.addListener && e.hasListener && e.removeListener), q = (e) => !!(e && typeof e == "object" && e.document && e.location && e.navigator && e.screen && e.history), x = (e) => k(e) || I(e), v = (e) => k(e) || I(e) || O(e) || L(e), Ae = (e) => x(e) || v(e), P = (e) => x(e) || q(e) || H(e) || Q(e) || Z(e) || W(e) || C(e) || ee(e), F = (e) => v(e) || q(e) || H(e) || Q(e) || Z(e) || W(e) || C(e) || re(e), ee = (e) => !!(e && typeof e == "object" && "emit" in e && (P(e.emit) || typeof e.emit == "function")), re = (e) => !!(e && typeof e == "object" && "receive" in e && (F(e.receive) || typeof e.receive == "function")), K = (e) => ee(e) || re(e), te = (e) => C(e) || _(e) || D(e) || j(e) || T(e) || B(e) || V(e) || J(e), p = (e) => e && typeof e == "object" && E in e && e[E] === "revivable", me = (e) => p(e) && e.type === "messagePort", Y = (e) => p(e) && e.type === "promise", be = (e) => p(e) && e.type === "function", he = (e) => p(e) && e.type === "typedArray", ue = (e) => p(e) && e.type === "arrayBuffer", we = (e) => p(e) && e.type === "readableStream", Ue = (e) => p(e) && e.type === "error", Be = (e) => p(e) && e.type === "date", u = (e) => {
|
|
94
|
+
const r = [], t = (n) => ge(n) ? void 0 : N(n) ? r.push(n) : Array.isArray(n) ? n.map(t) : n && typeof n == "object" ? Object.values(n).map(t) : void 0;
|
|
95
95
|
return t(e), r;
|
|
96
96
|
}, S = (e, r = !1) => {
|
|
97
97
|
const { port1: t, port2: n } = new MessageChannel(), o = new Promise(
|
|
@@ -181,7 +181,7 @@ const fe = (e) => {
|
|
|
181
181
|
n.postMessage(i, u(i));
|
|
182
182
|
}
|
|
183
183
|
}), s.start(), t;
|
|
184
|
-
},
|
|
184
|
+
}, Te = (e, r) => {
|
|
185
185
|
const { port1: t, port2: n } = new MessageChannel();
|
|
186
186
|
r.messagePorts.add(n);
|
|
187
187
|
const o = (s) => {
|
|
@@ -192,7 +192,7 @@ const fe = (e) => {
|
|
|
192
192
|
type: "promise",
|
|
193
193
|
port: n
|
|
194
194
|
};
|
|
195
|
-
},
|
|
195
|
+
}, Oe = (e, r) => (r.messagePorts.add(e.port), new Promise((t, n) => {
|
|
196
196
|
e.port.addEventListener("message", ({ data: o }) => {
|
|
197
197
|
const s = h(o, r);
|
|
198
198
|
s.type === "resolve" ? t(s.data) : n(s.error), e.port.close();
|
|
@@ -264,11 +264,11 @@ const fe = (e) => {
|
|
|
264
264
|
ISOString: e.toISOString()
|
|
265
265
|
}), Ke = (e, r) => new Date(e.ISOString), Ye = (e, r) => pe(e) || B(e) && !r.platformCapabilities.transferableStream ? {
|
|
266
266
|
[E]: "revivable",
|
|
267
|
-
..._(e) ? Le(e, r) : D(e) ?
|
|
267
|
+
..._(e) ? Le(e, r) : D(e) ? Te(e, r) : j(e) ? je(e) : B(e) ? z(e, r) : V(e) ? qe(e) : J(e) ? _e(e) : e
|
|
268
268
|
} : {
|
|
269
269
|
[E]: "revivable",
|
|
270
|
-
..."isJson" in r.transport && r.transport.isJson ? C(e) ? Se(e, r) :
|
|
271
|
-
type: C(e) ? "messagePort" :
|
|
270
|
+
..."isJson" in r.transport && r.transport.isJson ? C(e) ? Se(e, r) : T(e) ? We(e) : B(e) ? z(e, r) : { type: "unknown", value: e } : {
|
|
271
|
+
type: C(e) ? "messagePort" : T(e) ? "arrayBuffer" : B(e) ? "readableStream" : "unknown",
|
|
272
272
|
value: e
|
|
273
273
|
}
|
|
274
274
|
}, m = (e, r) => {
|
|
@@ -279,7 +279,7 @@ const fe = (e) => {
|
|
|
279
279
|
p(t) && t.type === "messagePort" && t.value instanceof MessagePort || p(t) && t.type === "arrayBuffer" && t.value instanceof ArrayBuffer || p(t) && t.type === "readableStream" && t.value instanceof ReadableStream ? o : m(o, r)
|
|
280
280
|
])
|
|
281
281
|
) : t;
|
|
282
|
-
}, Ge = (e, r) => te(e.value) ? e.value : me(e) ? Re(e, r) : be(e) ? Fe(e, r) : Y(e) ?
|
|
282
|
+
}, Ge = (e, r) => te(e.value) ? e.value : me(e) ? Re(e, r) : be(e) ? Fe(e, r) : Y(e) ? Oe(e, r) : Ue(e) ? Ve(e) : he(e) ? ke(e) : ue(e) ? De(e) : we(e) ? Je(e, r) : Be(e) ? Ke(e) : e, h = (e, r) => {
|
|
283
283
|
const t = N(e) ? e : Array.isArray(e) ? e.map((n) => h(n, r)) : e && typeof e == "object" ? Object.fromEntries(
|
|
284
284
|
Object.entries(e).map(([n, o]) => [
|
|
285
285
|
n,
|
|
@@ -298,7 +298,7 @@ const fe = (e) => {
|
|
|
298
298
|
eventTarget: s
|
|
299
299
|
};
|
|
300
300
|
let l;
|
|
301
|
-
const f = new Promise((d,
|
|
301
|
+
const f = new Promise((d, g) => {
|
|
302
302
|
l = d;
|
|
303
303
|
});
|
|
304
304
|
return s.addEventListener("message", ({ detail: d }) => {
|
|
@@ -346,19 +346,19 @@ const He = async (e, {
|
|
|
346
346
|
logger: l
|
|
347
347
|
}) => {
|
|
348
348
|
const f = {
|
|
349
|
-
isJson: "isJson" in r && r.isJson !== void 0 ? r.isJson :
|
|
349
|
+
isJson: "isJson" in r && r.isJson !== void 0 ? r.isJson : Ae(r),
|
|
350
350
|
...K(r) ? r : {
|
|
351
351
|
emit: r,
|
|
352
352
|
receive: r
|
|
353
353
|
}
|
|
354
|
-
}, d = c ?? await Ie(),
|
|
354
|
+
}, d = c ?? await Ie(), g = /* @__PURE__ */ new Map();
|
|
355
355
|
let G;
|
|
356
356
|
const ne = new Promise((y) => {
|
|
357
357
|
G = y;
|
|
358
358
|
});
|
|
359
359
|
let b = globalThis.crypto.randomUUID();
|
|
360
360
|
const w = (y, U) => {
|
|
361
|
-
const
|
|
361
|
+
const A = u(U);
|
|
362
362
|
ce(
|
|
363
363
|
y,
|
|
364
364
|
{
|
|
@@ -368,7 +368,7 @@ const He = async (e, {
|
|
|
368
368
|
...U
|
|
369
369
|
},
|
|
370
370
|
s,
|
|
371
|
-
|
|
371
|
+
A
|
|
372
372
|
);
|
|
373
373
|
}, se = async (y, U) => {
|
|
374
374
|
if (y.uuid !== b) {
|
|
@@ -380,28 +380,28 @@ const He = async (e, {
|
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
382
382
|
if (y.remoteUuid !== b) return;
|
|
383
|
-
if (
|
|
383
|
+
if (g.has(y.uuid)) {
|
|
384
384
|
w(
|
|
385
385
|
f,
|
|
386
386
|
{ type: "reject-uuid-taken", remoteUuid: y.uuid }
|
|
387
387
|
);
|
|
388
388
|
return;
|
|
389
389
|
}
|
|
390
|
-
const
|
|
390
|
+
const A = new ze(), X = {
|
|
391
391
|
type: "bidirectional",
|
|
392
|
-
eventTarget:
|
|
392
|
+
eventTarget: A,
|
|
393
393
|
connection: Xe({
|
|
394
394
|
transport: f,
|
|
395
395
|
value: e,
|
|
396
396
|
uuid: b,
|
|
397
397
|
remoteUuid: y.uuid,
|
|
398
398
|
platformCapabilities: d,
|
|
399
|
-
eventTarget:
|
|
399
|
+
eventTarget: A,
|
|
400
400
|
send: (R) => w(f, R),
|
|
401
|
-
close: () => void
|
|
401
|
+
close: () => void g.delete(y.uuid)
|
|
402
402
|
})
|
|
403
403
|
};
|
|
404
|
-
|
|
404
|
+
g.set(y.uuid, X), X.connection.remoteValue.then(
|
|
405
405
|
(R) => G(R)
|
|
406
406
|
);
|
|
407
407
|
} else if (y.type === "reject-uuid-taken") {
|
|
@@ -409,20 +409,20 @@ const He = async (e, {
|
|
|
409
409
|
b = globalThis.crypto.randomUUID(), w(f, { type: "announce" });
|
|
410
410
|
} else if (y.type === "close") {
|
|
411
411
|
if (y.remoteUuid !== b) return;
|
|
412
|
-
const
|
|
413
|
-
if (!
|
|
412
|
+
const A = g.get(y.uuid);
|
|
413
|
+
if (!A) {
|
|
414
414
|
console.warn(`Connection not found for remoteUuid: ${y.uuid}`);
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
|
-
|
|
417
|
+
A.connection.close(), g.delete(y.uuid);
|
|
418
418
|
} else {
|
|
419
419
|
if (y.remoteUuid !== b) return;
|
|
420
|
-
const
|
|
421
|
-
if (!
|
|
420
|
+
const A = g.get(y.uuid);
|
|
421
|
+
if (!A) {
|
|
422
422
|
console.warn(`Connection not found for remoteUuid: ${y.uuid}`);
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
|
|
425
|
+
A.type !== "unidirectional-emitting" && A.eventTarget.dispatchTypedEvent(
|
|
426
426
|
"message",
|
|
427
427
|
new CustomEvent("message", { detail: y })
|
|
428
428
|
);
|
|
@@ -441,7 +441,7 @@ const He = async (e, {
|
|
|
441
441
|
uuid: b,
|
|
442
442
|
platformCapabilities: d,
|
|
443
443
|
send: (U) => w(f, U),
|
|
444
|
-
close: () =>
|
|
444
|
+
close: () => g.delete(b)
|
|
445
445
|
});
|
|
446
446
|
return y;
|
|
447
447
|
}
|