osra 0.0.10 → 0.0.12
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/call.d.ts +6 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +201 -68
- package/build/register.d.ts +3 -2
- package/build/types.d.ts +1 -1
- package/build/utils.d.ts +4 -0
- package/build/webextension.d.ts +137 -0
- package/package.json +5 -2
- package/build/iterator.d.ts +0 -0
- package/build/promise.d.ts +0 -0
- package/build/pull.d.ts +0 -0
- package/build/send.d.ts +0 -0
package/build/call.d.ts
CHANGED
|
@@ -9,3 +9,9 @@ export declare const call: <T2 extends Resolvers>(target: Target, { key }?: {
|
|
|
9
9
|
* Make a listener for a call
|
|
10
10
|
*/
|
|
11
11
|
export declare const makeCallListener: <T extends (data: any, extra: ApiResolverOptions) => unknown>(func: T) => T;
|
|
12
|
+
/**
|
|
13
|
+
* Make a listener for a call
|
|
14
|
+
*/
|
|
15
|
+
export declare const makeProxyCallListener: <T extends (data: any, extra: ApiResolverOptions) => unknown>(target: Target, { key }?: {
|
|
16
|
+
key?: string | undefined;
|
|
17
|
+
}) => T;
|
package/build/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ import type { ApiMessageData, ApiResolverOptions, Resolvers, StructuredCloneTran
|
|
|
2
2
|
export type { ApiMessageData, ApiResolverOptions, Resolvers, StructuredCloneTransferableObject, StructuredCloneTransferableType, StructuredCloneObject, StructuredCloneType, Target, TransferableObject };
|
|
3
3
|
export * from './register';
|
|
4
4
|
export * from './call';
|
|
5
|
+
export * from './webextension';
|
|
6
|
+
export * from './utils';
|
package/build/index.js
CHANGED
|
@@ -1,89 +1,222 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) => {
|
|
8
|
-
const a = (e) => {
|
|
9
|
-
if (!e.data || typeof e.data != "object" || e.data?.source !== n || o && !o(e))
|
|
10
|
-
return;
|
|
11
|
-
const { type: c, data: b, port: g } = e.data, i = s[c];
|
|
12
|
-
if (!i)
|
|
13
|
-
throw new Error(`Osra received a message of type "${String(c)}" but no resolver was found for type.`);
|
|
14
|
-
t ? i(...t(b, { event: e, type: c, port: g })) : i(b, { event: e, type: c, port: g });
|
|
15
|
-
};
|
|
16
|
-
return r.addEventListener("message", a), {
|
|
17
|
-
listener: a,
|
|
18
|
-
resolvers: s
|
|
19
|
-
};
|
|
20
|
-
}, y = (r) => !!(globalThis.SharedArrayBuffer && r instanceof globalThis.SharedArrayBuffer), h = (r) => globalThis.ArrayBuffer && r instanceof globalThis.ArrayBuffer || globalThis.MessagePort && r instanceof globalThis.MessagePort || globalThis.ReadableStream && r instanceof globalThis.ReadableStream || globalThis.WritableStream && r instanceof globalThis.WritableStream || globalThis.TransformStream && r instanceof globalThis.TransformStream ? !0 : !!(globalThis.ImageBitmap && r instanceof globalThis.ImageBitmap), p = (r) => {
|
|
21
|
-
const s = [], o = (t) => y(t) ? void 0 : h(t) ? s.push(t) : Array.isArray(t) ? t.map(o) : t && typeof t == "object" ? Object.values(t).map(o) : void 0;
|
|
22
|
-
return o(r), s;
|
|
23
|
-
}, l = "__proxyFunctionPort__", O = (r) => {
|
|
24
|
-
const { port1: s, port2: o } = new MessageChannel();
|
|
25
|
-
return s.addEventListener("message", async (t) => {
|
|
1
|
+
const f = "osra-message", P = (t) => !!(globalThis.SharedArrayBuffer && t instanceof globalThis.SharedArrayBuffer), h = (t) => globalThis.ArrayBuffer && t instanceof globalThis.ArrayBuffer || globalThis.MessagePort && t instanceof globalThis.MessagePort || globalThis.ReadableStream && t instanceof globalThis.ReadableStream || globalThis.WritableStream && t instanceof globalThis.WritableStream || globalThis.TransformStream && t instanceof globalThis.TransformStream ? !0 : !!(globalThis.ImageBitmap && t instanceof globalThis.ImageBitmap), b = (t) => {
|
|
2
|
+
const e = [], s = (r) => P(r) ? void 0 : h(r) ? e.push(r) : Array.isArray(r) ? r.map(s) : r && typeof r == "object" ? Object.values(r).map(s) : void 0;
|
|
3
|
+
return s(t), e;
|
|
4
|
+
}, p = "__proxyFunctionPort__", L = "__proxyMessageChannelPort__", A = (t) => {
|
|
5
|
+
const { port1: e, port2: s } = new MessageChannel();
|
|
6
|
+
return e.addEventListener("message", async (r) => {
|
|
26
7
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
8
|
+
const a = await t(...r.data), n = m(a), o = b(n);
|
|
9
|
+
e.postMessage({ result: n }, { transfer: o });
|
|
10
|
+
} catch (a) {
|
|
11
|
+
e.postMessage({ error: a });
|
|
31
12
|
}
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
Object.entries(
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
}), e.start(), s;
|
|
14
|
+
}, m = (t) => P(t) || h(t) ? t : typeof t == "function" ? { [p]: A(t) } : Array.isArray(t) ? t.map(m) : t && typeof t == "object" ? Object.fromEntries(
|
|
15
|
+
Object.entries(t).map(([e, s]) => [
|
|
16
|
+
e,
|
|
17
|
+
m(s)
|
|
37
18
|
])
|
|
38
|
-
) :
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
Object.entries(
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
) : t, _ = (t) => (...e) => new Promise((s, r) => {
|
|
20
|
+
const a = m(e), n = b(a), o = (c) => {
|
|
21
|
+
c.data.error ? r(c.data.error) : s(M(c.data.result)), t.removeEventListener("message", o);
|
|
22
|
+
};
|
|
23
|
+
t.addEventListener("message", o), t.start(), t.postMessage(a, { transfer: n });
|
|
24
|
+
}), M = (t) => P(t) || h(t) ? t : t && typeof t == "object" && t[p] ? _(t[p]) : Array.isArray(t) ? t.map(m) : t && typeof t == "object" ? Object.fromEntries(
|
|
25
|
+
Object.entries(t).map(([e, s]) => [
|
|
26
|
+
e,
|
|
27
|
+
M(s)
|
|
47
28
|
])
|
|
48
|
-
) :
|
|
49
|
-
|
|
50
|
-
e
|
|
29
|
+
) : t, C = ({
|
|
30
|
+
target: t,
|
|
31
|
+
resolvers: e,
|
|
32
|
+
filter: s,
|
|
33
|
+
map: r,
|
|
34
|
+
key: a = f,
|
|
35
|
+
proxyTarget: n
|
|
36
|
+
}) => {
|
|
37
|
+
const o = (c) => {
|
|
38
|
+
if (!c.data || typeof c.data != "object" || c.data?.source !== a || s && !s(c))
|
|
39
|
+
return;
|
|
40
|
+
if (n) {
|
|
41
|
+
const { type: l, data: O, port: T } = c.data, x = b(O);
|
|
42
|
+
n.postMessage(
|
|
43
|
+
{
|
|
44
|
+
source: a,
|
|
45
|
+
type: l,
|
|
46
|
+
data: O,
|
|
47
|
+
port: T
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
targetOrigin: "*",
|
|
51
|
+
transfer: [T, ...x ?? []]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { type: i, data: d, port: g } = c.data, y = e[i];
|
|
57
|
+
if (!y)
|
|
58
|
+
throw new Error(`Osra received a message of type "${String(i)}" but no resolver was found for type.`);
|
|
59
|
+
r ? y(...r(d, { event: c, type: i, port: g })) : y(d, { event: c, type: i, port: g });
|
|
60
|
+
};
|
|
61
|
+
return t.addEventListener("message", o), {
|
|
62
|
+
listener: o,
|
|
63
|
+
resolvers: e
|
|
64
|
+
};
|
|
65
|
+
}, R = (t, { key: e = f } = { key: f }) => (s, r) => new Promise((a, n) => {
|
|
66
|
+
const { port1: o, port2: c } = new MessageChannel();
|
|
67
|
+
o.addEventListener(
|
|
51
68
|
"message",
|
|
52
|
-
({ data:
|
|
53
|
-
if (
|
|
54
|
-
|
|
69
|
+
({ data: g }) => {
|
|
70
|
+
if (g.error)
|
|
71
|
+
n(g.error);
|
|
55
72
|
else {
|
|
56
|
-
const
|
|
57
|
-
|
|
73
|
+
const y = M(g.result);
|
|
74
|
+
a(y);
|
|
58
75
|
}
|
|
59
|
-
|
|
76
|
+
o.close(), c.close();
|
|
60
77
|
},
|
|
61
78
|
{ once: !0 }
|
|
62
|
-
),
|
|
63
|
-
const
|
|
64
|
-
|
|
79
|
+
), o.start();
|
|
80
|
+
const i = m(r), d = b(i);
|
|
81
|
+
t.postMessage(
|
|
65
82
|
{
|
|
66
|
-
source:
|
|
67
|
-
type:
|
|
68
|
-
data:
|
|
83
|
+
source: e,
|
|
84
|
+
type: s,
|
|
85
|
+
data: i,
|
|
69
86
|
port: c
|
|
70
87
|
},
|
|
71
88
|
{
|
|
72
89
|
targetOrigin: "*",
|
|
73
|
-
transfer: [c, ...
|
|
90
|
+
transfer: [c, ...d ?? []]
|
|
74
91
|
}
|
|
75
92
|
);
|
|
76
|
-
}),
|
|
77
|
-
const { port:
|
|
93
|
+
}), D = (t) => async (e, s) => {
|
|
94
|
+
const { port: r } = s, a = M(e);
|
|
78
95
|
try {
|
|
79
|
-
const
|
|
80
|
-
return
|
|
81
|
-
} catch (
|
|
82
|
-
throw
|
|
96
|
+
const n = await t(a, s), o = m(n), c = b(o);
|
|
97
|
+
return r.postMessage({ result: o }, { transfer: c }), r.close(), n;
|
|
98
|
+
} catch (n) {
|
|
99
|
+
throw r.postMessage({ error: n }), r.close(), n;
|
|
83
100
|
}
|
|
101
|
+
}, $ = (t, { key: e = f } = { key: f }) => (s, r) => {
|
|
102
|
+
const { type: a, port: n } = r, o = b(s);
|
|
103
|
+
t.postMessage(
|
|
104
|
+
{
|
|
105
|
+
source: e,
|
|
106
|
+
type: a,
|
|
107
|
+
data: s,
|
|
108
|
+
port: n
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
targetOrigin: "*",
|
|
112
|
+
transfer: [n, ...o ?? []]
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}, j = ({ key: t = f }) => {
|
|
116
|
+
const e = /* @__PURE__ */ new Map(), s = async (a) => e.get(a) ?? new Promise((n, o) => {
|
|
117
|
+
let c = !1;
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
c || o(new Error(`Osra getPort for "${a}" timed out`));
|
|
120
|
+
}, 1e3), chrome.runtime.onConnect.addListener((i) => {
|
|
121
|
+
i.name === `${t}:${a}` && (e.set(a, i), n(i), c = !0);
|
|
122
|
+
});
|
|
123
|
+
}), r = {
|
|
124
|
+
addPort: (a, n) => e.set(a, n),
|
|
125
|
+
proxyPort: (a) => {
|
|
126
|
+
const n = self.crypto.randomUUID(), o = chrome.runtime.connect({ name: `${t}:${n}` });
|
|
127
|
+
return e.set(n, o), o.onDisconnect.addListener(() => {
|
|
128
|
+
e.delete(n);
|
|
129
|
+
}), o.onMessage.addListener((c) => {
|
|
130
|
+
a.postMessage(c);
|
|
131
|
+
}), a.addEventListener("message", async (c) => {
|
|
132
|
+
o.postMessage(c.data);
|
|
133
|
+
}), a.addEventListener("close", () => {
|
|
134
|
+
o.disconnect();
|
|
135
|
+
}), {
|
|
136
|
+
[L]: n
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
proxiedPort: async ({ [L]: a }) => {
|
|
140
|
+
const { port1: n, port2: o } = new MessageChannel(), c = await s(a);
|
|
141
|
+
c.onMessage.addListener((d) => {
|
|
142
|
+
n.postMessage(d);
|
|
143
|
+
}), c.onDisconnect.addListener(() => {
|
|
144
|
+
n.close();
|
|
145
|
+
}), n.addEventListener("close", () => {
|
|
146
|
+
c.disconnect();
|
|
147
|
+
}), n.addEventListener("message", async (d) => {
|
|
148
|
+
c.postMessage(d.data);
|
|
149
|
+
}), n.start(), o.addEventListener("message", async (d) => {
|
|
150
|
+
c.postMessage(d.data);
|
|
151
|
+
}), o.start();
|
|
152
|
+
const i = S(r, o);
|
|
153
|
+
return i.uuid = a, i;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return r;
|
|
157
|
+
}, E = (t, e) => e instanceof MessagePort ? t.proxyPort(e) : P(e) || h(e) ? e : typeof e == "object" && p in e ? { [p]: t.proxyPort(e[p]) } : Array.isArray(e) ? e.map((s) => E(t, s)) : e && typeof e == "object" ? Object.fromEntries(
|
|
158
|
+
Object.entries(e).map(([s, r]) => [
|
|
159
|
+
s,
|
|
160
|
+
E(t, r)
|
|
161
|
+
])
|
|
162
|
+
) : e, w = async (t, e) => P(e) || h(e) ? e : typeof e == "object" && L in e ? await t.proxiedPort(e) : typeof e == "object" && p in e ? { [p]: await t.proxiedPort(e[p]) } : Array.isArray(e) ? await Promise.all(e.map((s) => w(t, s))) : e && typeof e == "object" ? Object.fromEntries(
|
|
163
|
+
await Promise.all(
|
|
164
|
+
Object.entries(e).map(async ([s, r]) => [
|
|
165
|
+
s,
|
|
166
|
+
await w(t, r)
|
|
167
|
+
])
|
|
168
|
+
)
|
|
169
|
+
) : e, S = (t, e) => {
|
|
170
|
+
const s = e.postMessage;
|
|
171
|
+
return e.postMessage = (r) => {
|
|
172
|
+
s.apply(e, [E(t, r)]);
|
|
173
|
+
}, e;
|
|
174
|
+
}, B = ({
|
|
175
|
+
target: t,
|
|
176
|
+
key: e = f
|
|
177
|
+
}) => {
|
|
178
|
+
const s = j({ key: e });
|
|
179
|
+
return {
|
|
180
|
+
...t,
|
|
181
|
+
postMessage: (r) => {
|
|
182
|
+
t.runtime.sendMessage(E(s, r));
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}, F = ({
|
|
186
|
+
target: t,
|
|
187
|
+
key: e = f
|
|
188
|
+
}) => {
|
|
189
|
+
const s = j({ key: e });
|
|
190
|
+
return {
|
|
191
|
+
...t,
|
|
192
|
+
addEventListener: (r, a, n) => {
|
|
193
|
+
if (r !== "message")
|
|
194
|
+
return t.addEventListener(r, a, n);
|
|
195
|
+
chrome.runtime.onMessage.addListener((o, c, i) => {
|
|
196
|
+
w(s, o).then((d) => a({ data: d }));
|
|
197
|
+
}), chrome.runtime.onConnect.addListener((o) => {
|
|
198
|
+
o.name.startsWith(`${e}:`) && s.addPort(o.name.split(":")[1], o);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
};
|
|
84
202
|
};
|
|
85
203
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
204
|
+
p as PROXY_FUNCTION_PROPERTY,
|
|
205
|
+
L as PROXY_MESSAGE_CHANNEL_PROPERTY,
|
|
206
|
+
R as call,
|
|
207
|
+
b as getTransferableObjects,
|
|
208
|
+
P as isClonable,
|
|
209
|
+
h as isTransferable,
|
|
210
|
+
D as makeCallListener,
|
|
211
|
+
M as makeObjectProxiedFunctions,
|
|
212
|
+
_ as makeProxiedFunction,
|
|
213
|
+
$ as makeProxyCallListener,
|
|
214
|
+
A as makeProxyFunction,
|
|
215
|
+
m as proxyObjectFunctions,
|
|
216
|
+
C as registerListener,
|
|
217
|
+
w as replaceProxied,
|
|
218
|
+
E as replaceProxies,
|
|
219
|
+
B as wrapExtensionTarget,
|
|
220
|
+
F as wrapListenerExtensionTarget,
|
|
221
|
+
S as wrapPort
|
|
89
222
|
};
|
package/build/register.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ApiMessageData, ApiResolverOptions, Resolvers, ValidateResolvers } from './types';
|
|
2
|
-
export declare const registerListener: <T extends Record<PropertyKey, (data: any, extra: ApiResolverOptions) => unknown>>({ target, resolvers, filter, map, key }: {
|
|
1
|
+
import type { ApiMessageData, ApiResolverOptions, Resolvers, Target, ValidateResolvers } from './types';
|
|
2
|
+
export declare const registerListener: <T extends Record<PropertyKey, (data: any, extra: ApiResolverOptions) => unknown>>({ target, resolvers, filter, map, key, proxyTarget }: {
|
|
3
3
|
target: WindowEventHandlers | ServiceWorkerContainer | Worker | SharedWorker;
|
|
4
4
|
resolvers: ValidateResolvers<T>;
|
|
5
5
|
filter?: ((event: MessageEvent<any>) => boolean) | undefined;
|
|
@@ -13,6 +13,7 @@ export declare const registerListener: <T extends Record<PropertyKey, (data: any
|
|
|
13
13
|
port: MessagePort;
|
|
14
14
|
}]) | undefined;
|
|
15
15
|
key?: string | undefined;
|
|
16
|
+
proxyTarget?: Target | undefined;
|
|
16
17
|
}) => {
|
|
17
18
|
listener: (event: MessageEvent<ApiMessageData<Resolvers>>) => void;
|
|
18
19
|
resolvers: ValidateResolvers<T>;
|
package/build/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type StructuredCloneTransferableObject = {
|
|
|
8
8
|
};
|
|
9
9
|
export type ProxiedType = (...args: StructuredCloneTransferableType[]) => StructuredCloneTransferableType | Promise<StructuredCloneTransferableType>;
|
|
10
10
|
export type StructuredCloneTransferableType = StructuredCloneType | TransferableObject | Array<StructuredCloneTransferableType> | StructuredCloneTransferableObject | Map<StructuredCloneTransferableType, StructuredCloneTransferableType> | Set<StructuredCloneTransferableType> | ProxiedType;
|
|
11
|
-
export type Target = Window | ServiceWorker | Worker;
|
|
11
|
+
export type Target = Window | ServiceWorker | Worker | MessagePort;
|
|
12
12
|
type NormalizeRecord<T> = T extends Record<any, any> ? {
|
|
13
13
|
[K in keyof T]: NormalizeRecord<T[K]>;
|
|
14
14
|
} : T;
|
package/build/utils.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TransferableObject } from './types';
|
|
2
|
+
export declare const isClonable: (value: any) => boolean;
|
|
3
|
+
export declare const isTransferable: (value: any) => boolean;
|
|
2
4
|
export declare const getTransferableObjects: (value: any) => TransferableObject[];
|
|
5
|
+
export declare const PROXY_FUNCTION_PROPERTY = "__proxyFunctionPort__";
|
|
6
|
+
export declare const PROXY_MESSAGE_CHANNEL_PROPERTY = "__proxyMessageChannelPort__";
|
|
3
7
|
export declare const makeProxyFunction: (func: any) => MessagePort;
|
|
4
8
|
export declare const proxyObjectFunctions: (value: any) => any;
|
|
5
9
|
export declare const makeProxiedFunction: (port: MessagePort) => (...args: any[]) => Promise<unknown>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type browser from 'webextension-polyfill';
|
|
2
|
+
import { PROXY_MESSAGE_CHANNEL_PROPERTY } from './utils';
|
|
3
|
+
type PortManager = ReturnType<typeof makePortManager>;
|
|
4
|
+
declare const makePortManager: ({ key }: {
|
|
5
|
+
key?: string | undefined;
|
|
6
|
+
}) => {
|
|
7
|
+
addPort: (name: string, port: browser.Runtime.Port) => Map<string, browser.Runtime.Port>;
|
|
8
|
+
proxyPort: (messagePort: MessagePort) => {
|
|
9
|
+
__proxyMessageChannelPort__: string;
|
|
10
|
+
};
|
|
11
|
+
proxiedPort: ({ [PROXY_MESSAGE_CHANNEL_PROPERTY]: uuid }: {
|
|
12
|
+
[PROXY_MESSAGE_CHANNEL_PROPERTY]: string;
|
|
13
|
+
}) => Promise<MessagePort>;
|
|
14
|
+
};
|
|
15
|
+
export declare const replaceProxies: (portManager: PortManager, value: any) => any;
|
|
16
|
+
export declare const replaceProxied: (portManager: PortManager, value: any) => any;
|
|
17
|
+
export declare const wrapPort: (portManager: any, port: MessagePort) => MessagePort;
|
|
18
|
+
export declare const wrapExtensionTarget: ({ target, key }: {
|
|
19
|
+
target: browser.Browser;
|
|
20
|
+
key?: string | undefined;
|
|
21
|
+
}) => {
|
|
22
|
+
postMessage: (message: any) => void;
|
|
23
|
+
activityLog: browser.ActivityLog.Static;
|
|
24
|
+
alarms: browser.Alarms.Static;
|
|
25
|
+
bookmarks: browser.Bookmarks.Static;
|
|
26
|
+
action: browser.Action.Static;
|
|
27
|
+
browserAction: browser.BrowserAction.Static;
|
|
28
|
+
browserSettings: browser.BrowserSettings.Static;
|
|
29
|
+
browsingData: browser.BrowsingData.Static;
|
|
30
|
+
captivePortal: browser.CaptivePortal.Static;
|
|
31
|
+
clipboard: browser.Clipboard.Static;
|
|
32
|
+
commands: browser.Commands.Static;
|
|
33
|
+
contentScripts: browser.ContentScripts.Static;
|
|
34
|
+
contextualIdentities: browser.ContextualIdentities.Static;
|
|
35
|
+
cookies: browser.Cookies.Static;
|
|
36
|
+
declarativeNetRequest: browser.DeclarativeNetRequest.Static;
|
|
37
|
+
devtools: browser.Devtools.Static;
|
|
38
|
+
dns: browser.Dns.Static;
|
|
39
|
+
downloads: browser.Downloads.Static;
|
|
40
|
+
events: browser.Events.Static;
|
|
41
|
+
experiments: browser.Experiments.Static;
|
|
42
|
+
extension: browser.Extension.Static;
|
|
43
|
+
extensionTypes: browser.ExtensionTypes.Static;
|
|
44
|
+
find: browser.Find.Static;
|
|
45
|
+
geckoProfiler: browser.GeckoProfiler.Static;
|
|
46
|
+
history: browser.History.Static;
|
|
47
|
+
i18n: browser.I18n.Static;
|
|
48
|
+
identity: browser.Identity.Static;
|
|
49
|
+
idle: browser.Idle.Static;
|
|
50
|
+
management: browser.Management.Static;
|
|
51
|
+
manifest: browser.Manifest.Static;
|
|
52
|
+
contextMenus: browser.ContextMenus.Static;
|
|
53
|
+
menus: browser.Menus.Static;
|
|
54
|
+
networkStatus: browser.NetworkStatus.Static;
|
|
55
|
+
normandyAddonStudy: browser.NormandyAddonStudy.Static;
|
|
56
|
+
notifications: browser.Notifications.Static;
|
|
57
|
+
omnibox: browser.Omnibox.Static;
|
|
58
|
+
pageAction: browser.PageAction.Static;
|
|
59
|
+
permissions: browser.Permissions.Static;
|
|
60
|
+
pkcs11: browser.Pkcs11.Static;
|
|
61
|
+
privacy: browser.Privacy.Static;
|
|
62
|
+
proxy: browser.Proxy.Static;
|
|
63
|
+
runtime: browser.Runtime.Static;
|
|
64
|
+
scripting: browser.Scripting.Static;
|
|
65
|
+
search: browser.Search.Static;
|
|
66
|
+
sessions: browser.Sessions.Static;
|
|
67
|
+
sidebarAction: browser.SidebarAction.Static;
|
|
68
|
+
storage: browser.Storage.Static;
|
|
69
|
+
tabs: browser.Tabs.Static;
|
|
70
|
+
theme: browser.Theme.Static;
|
|
71
|
+
topSites: browser.TopSites.Static;
|
|
72
|
+
types: browser.Types.Static;
|
|
73
|
+
urlbar: browser.Urlbar.Static;
|
|
74
|
+
userScripts: browser.UserScripts.Static;
|
|
75
|
+
webNavigation: browser.WebNavigation.Static;
|
|
76
|
+
webRequest: browser.WebRequest.Static;
|
|
77
|
+
windows: browser.Windows.Static;
|
|
78
|
+
};
|
|
79
|
+
export declare const wrapListenerExtensionTarget: ({ target, key }: {
|
|
80
|
+
target: WindowEventHandlers | ServiceWorkerContainer | Worker | SharedWorker;
|
|
81
|
+
key?: string | undefined;
|
|
82
|
+
}) => {
|
|
83
|
+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
84
|
+
onafterprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
85
|
+
onbeforeprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
86
|
+
onbeforeunload: ((this: WindowEventHandlers, ev: BeforeUnloadEvent) => any) | null;
|
|
87
|
+
ongamepadconnected: ((this: WindowEventHandlers, ev: GamepadEvent) => any) | null;
|
|
88
|
+
ongamepaddisconnected: ((this: WindowEventHandlers, ev: GamepadEvent) => any) | null;
|
|
89
|
+
onhashchange: ((this: WindowEventHandlers, ev: HashChangeEvent) => any) | null;
|
|
90
|
+
onlanguagechange: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
91
|
+
onmessage: ((this: WindowEventHandlers, ev: MessageEvent<any>) => any) | null;
|
|
92
|
+
onmessageerror: ((this: WindowEventHandlers, ev: MessageEvent<any>) => any) | null;
|
|
93
|
+
onoffline: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
94
|
+
ononline: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
95
|
+
onpagehide: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null;
|
|
96
|
+
onpageshow: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null;
|
|
97
|
+
onpopstate: ((this: WindowEventHandlers, ev: PopStateEvent) => any) | null;
|
|
98
|
+
onrejectionhandled: ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | null;
|
|
99
|
+
onstorage: ((this: WindowEventHandlers, ev: StorageEvent) => any) | null;
|
|
100
|
+
onunhandledrejection: ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | null;
|
|
101
|
+
onunload: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
102
|
+
removeEventListener<K extends keyof WindowEventHandlersEventMap>(type: K, listener: (this: WindowEventHandlers, ev: WindowEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
103
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
104
|
+
} | {
|
|
105
|
+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
106
|
+
controller: ServiceWorker | null;
|
|
107
|
+
oncontrollerchange: ((this: ServiceWorkerContainer, ev: Event) => any) | null;
|
|
108
|
+
onmessage: ((this: ServiceWorkerContainer, ev: MessageEvent<any>) => any) | null;
|
|
109
|
+
onmessageerror: ((this: ServiceWorkerContainer, ev: MessageEvent<any>) => any) | null;
|
|
110
|
+
ready: Promise<ServiceWorkerRegistration>;
|
|
111
|
+
getRegistration(clientURL?: string | URL | undefined): Promise<ServiceWorkerRegistration | undefined>;
|
|
112
|
+
getRegistrations(): Promise<readonly ServiceWorkerRegistration[]>;
|
|
113
|
+
register(scriptURL: string | URL, options?: RegistrationOptions | undefined): Promise<ServiceWorkerRegistration>;
|
|
114
|
+
startMessages(): void;
|
|
115
|
+
removeEventListener<K_1 extends keyof ServiceWorkerContainerEventMap>(type: K_1, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K_1]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
116
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
117
|
+
dispatchEvent(event: Event): boolean;
|
|
118
|
+
} | {
|
|
119
|
+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
120
|
+
port: MessagePort;
|
|
121
|
+
removeEventListener<K_2 extends "error">(type: K_2, listener: (this: SharedWorker, ev: AbstractWorkerEventMap[K_2]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
122
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
123
|
+
dispatchEvent(event: Event): boolean;
|
|
124
|
+
onerror: ((this: AbstractWorker, ev: ErrorEvent) => any) | null;
|
|
125
|
+
} | {
|
|
126
|
+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
127
|
+
onmessage: ((this: Worker, ev: MessageEvent<any>) => any) | null;
|
|
128
|
+
onmessageerror: ((this: Worker, ev: MessageEvent<any>) => any) | null;
|
|
129
|
+
postMessage(message: any, transfer: Transferable[]): void;
|
|
130
|
+
postMessage(message: any, options?: StructuredSerializeOptions | undefined): void;
|
|
131
|
+
terminate(): void;
|
|
132
|
+
removeEventListener<K_3 extends keyof WorkerEventMap>(type: K_3, listener: (this: Worker, ev: WorkerEventMap[K_3]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
133
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
134
|
+
dispatchEvent(event: Event): boolean;
|
|
135
|
+
onerror: ((this: AbstractWorker, ev: ErrorEvent) => any) | null;
|
|
136
|
+
};
|
|
137
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osra",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Easy communication between workers",
|
|
5
5
|
"files": [
|
|
6
6
|
"build"
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"homepage": "https://github.com/Banou26/osra#readme",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/chai-as-promised": "^7.1.5",
|
|
34
|
+
"@types/chrome": "^0.0.237",
|
|
34
35
|
"@types/node": "^18.11.18",
|
|
36
|
+
"@types/webextension-polyfill": "^0.10.0",
|
|
35
37
|
"chai": "^4.3.6",
|
|
36
38
|
"chai-as-promised": "^7.1.1",
|
|
37
39
|
"concurrently": "^7.0.0",
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
"epk": "^0.16.0",
|
|
40
42
|
"mime": "^3.0.0",
|
|
41
43
|
"typescript": "^4.9.4",
|
|
42
|
-
"vite": "^4.0.4"
|
|
44
|
+
"vite": "^4.0.4",
|
|
45
|
+
"webextension-polyfill": "^0.10.0"
|
|
43
46
|
}
|
|
44
47
|
}
|
package/build/iterator.d.ts
DELETED
|
File without changes
|
package/build/promise.d.ts
DELETED
|
File without changes
|
package/build/pull.d.ts
DELETED
|
File without changes
|
package/build/send.d.ts
DELETED
|
File without changes
|