@banou/ripple 0.0.1 → 0.0.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/README.md +3 -27
- package/build/app.webmanifest +65 -0
- package/build/assets/index-be95001c.js +211 -0
- package/build/assets/index-d5b720ec.js +109 -0
- package/build/assets/io-worker-bde41815.js +17681 -0
- package/build/assets/logo.png +0 -0
- package/build/assets/logo.svg +1 -0
- package/build/index-3576f032.js +14881 -0
- package/build/index-65b2197a.js +116 -0
- package/build/index.html +2 -0
- package/build/index.js +33826 -1
- package/build/io-worker-190cc8d7.js +2862 -0
- package/build/libav-worker.js +1 -1
- package/build/libav.wasm +0 -0
- package/build/shared-worker.js +13 -1
- package/build/worker.js +38 -1
- package/package.json +12 -8
- package/build/index-8227e1be.js +0 -121
- package/build/io-worker-67a3c2ed.js +0 -3
- package/build/settings-bc96f65e.js +0 -28
- package/build/shared-worker-05e72720.js +0 -1404
package/README.md
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Currently, two official plugins are available:
|
|
6
|
-
|
|
7
|
-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
-
|
|
10
|
-
## Expanding the ESLint configuration
|
|
11
|
-
|
|
12
|
-
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
13
|
-
|
|
14
|
-
- Configure the top-level `parserOptions` property like this:
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
parserOptions: {
|
|
18
|
-
ecmaVersion: 'latest',
|
|
19
|
-
sourceType: 'module',
|
|
20
|
-
project: ['./tsconfig.json', './tsconfig.node.json'],
|
|
21
|
-
tsconfigRootDir: __dirname,
|
|
22
|
-
},
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
|
26
|
-
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
|
27
|
-
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
|
1
|
+
# Ripple, the torrent app that respect your privacy
|
|
2
|
+
|
|
3
|
+
THE app that allows you to download torrents and stream video files from the safety of your browser!
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "Ripple",
|
|
3
|
+
"name": "Ripple - A torrent web app",
|
|
4
|
+
"description": "A torrent app on the web",
|
|
5
|
+
"icons": [
|
|
6
|
+
{
|
|
7
|
+
"src": "./assets/logo.png",
|
|
8
|
+
"sizes": "512x512",
|
|
9
|
+
"type": "image/png"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"id": "/?source=pwa",
|
|
13
|
+
"start_url": "/?source=pwa",
|
|
14
|
+
"background_color": "#3367D6",
|
|
15
|
+
"display": "standalone",
|
|
16
|
+
"scope": "/",
|
|
17
|
+
"theme_color": "#3367D6",
|
|
18
|
+
"shortcuts": [
|
|
19
|
+
{
|
|
20
|
+
"name": "Pause all torrents",
|
|
21
|
+
"short_name": "Pause all",
|
|
22
|
+
"description": "Pause all currently downloading torrents",
|
|
23
|
+
"url": "/?source=pwa&pauseAll=true"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"protocol_handlers": [
|
|
27
|
+
{
|
|
28
|
+
"protocol": "magnet",
|
|
29
|
+
"url": "/protocol-handler?magnet=%s"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"file_handlers": [
|
|
33
|
+
{
|
|
34
|
+
"action": "/file-handler",
|
|
35
|
+
"accept": {
|
|
36
|
+
"application/x-bittorrent": [".torrent"],
|
|
37
|
+
"x-scheme-handler/magnet": ["magnet:?xt=urn:btih:"]
|
|
38
|
+
},
|
|
39
|
+
"icons": [
|
|
40
|
+
{
|
|
41
|
+
"src": "csv-icon.png",
|
|
42
|
+
"sizes": "256x256",
|
|
43
|
+
"type": "image/png"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"share_target": {
|
|
49
|
+
"action": "/share-target",
|
|
50
|
+
"method": "POST",
|
|
51
|
+
"enctype": "multipart/form-data",
|
|
52
|
+
"params": {
|
|
53
|
+
"files": [
|
|
54
|
+
{
|
|
55
|
+
"name": "file",
|
|
56
|
+
"accept": [
|
|
57
|
+
"application/vnd.ripple+json",
|
|
58
|
+
"application/json",
|
|
59
|
+
".ripple"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var x = "osra-message", O = (e) => !!(globalThis.SharedArrayBuffer && e instanceof globalThis.SharedArrayBuffer), j = (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), u = (e) => {
|
|
2
|
+
const r = [], t = (s) => O(s) ? void 0 : j(s) ? r.push(s) : Array.isArray(s) ? s.map(t) : s && typeof s == "object" ? Object.values(s).map(t) : void 0;
|
|
3
|
+
return t(e), r;
|
|
4
|
+
}, T = "__proxyFunctionPort__", N = (e) => {
|
|
5
|
+
const { port1: r, port2: t } = new MessageChannel();
|
|
6
|
+
return r.addEventListener("message", async (s) => {
|
|
7
|
+
try {
|
|
8
|
+
const o = await e(...s.data), a = d(o), n = u(a);
|
|
9
|
+
r.postMessage({ result: a }, { transfer: n });
|
|
10
|
+
} catch (o) {
|
|
11
|
+
r.postMessage({ error: o });
|
|
12
|
+
}
|
|
13
|
+
}), r.start(), t;
|
|
14
|
+
}, d = (e) => O(e) || j(e) ? e : typeof e == "function" ? { [T]: N(e) } : Array.isArray(e) ? e.map(d) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).map(([r, t]) => [
|
|
15
|
+
r,
|
|
16
|
+
d(t)
|
|
17
|
+
])) : e, Y = (e) => (...r) => new Promise((t, s) => {
|
|
18
|
+
const o = d(r), a = u(o);
|
|
19
|
+
e.addEventListener("message", (n) => {
|
|
20
|
+
n.data.error ? s(n.data.error) : t(P(n.data.result));
|
|
21
|
+
}), e.start(), e.postMessage(o, { transfer: a });
|
|
22
|
+
}), P = (e) => O(e) || j(e) ? e : e && typeof e == "object" && e[T] ? Y(e[T]) : Array.isArray(e) ? e.map(d) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).map(([r, t]) => [
|
|
23
|
+
r,
|
|
24
|
+
P(t)
|
|
25
|
+
])) : e, L = (e, { key: r = x } = { key: x }) => (t, s) => new Promise((o, a) => {
|
|
26
|
+
const { port1: n, port2: i } = new MessageChannel();
|
|
27
|
+
n.addEventListener("message", ({ data: f }) => {
|
|
28
|
+
if (f.error)
|
|
29
|
+
a(f.error);
|
|
30
|
+
else {
|
|
31
|
+
const l = P(f.result);
|
|
32
|
+
o(l);
|
|
33
|
+
}
|
|
34
|
+
n.close(), i.close();
|
|
35
|
+
}, { once: !0 }), n.start();
|
|
36
|
+
const c = d(s), g = u(c);
|
|
37
|
+
e.postMessage({
|
|
38
|
+
source: r,
|
|
39
|
+
type: t,
|
|
40
|
+
data: c,
|
|
41
|
+
port: i
|
|
42
|
+
}, {
|
|
43
|
+
targetOrigin: "*",
|
|
44
|
+
transfer: [i, ...g ?? []]
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
let C, y;
|
|
48
|
+
const F = () => (y = new Promise((e, r) => {
|
|
49
|
+
C = e;
|
|
50
|
+
}), y), U = F(), I = async (e) => {
|
|
51
|
+
e === U && F(), C(await e);
|
|
52
|
+
}, G = "https://fkn.app", K = globalThis.window === void 0, b = globalThis.document?.createElement("iframe");
|
|
53
|
+
b && (b.src = `${G}/sandbox-api`, b.style.display = "none", document.body.appendChild(b));
|
|
54
|
+
const w = b, _ = w?.contentWindow, X = (e) => I(e), q = () => y;
|
|
55
|
+
if (K) {
|
|
56
|
+
let e = !1;
|
|
57
|
+
y.then(() => {
|
|
58
|
+
e = !0;
|
|
59
|
+
}), setTimeout(() => {
|
|
60
|
+
e || console.warn("@fkn/lib's api target has not resolved after 250ms while in a worker, make sure to call `setApiTarget(messagePort)`");
|
|
61
|
+
}, 250);
|
|
62
|
+
} else {
|
|
63
|
+
if (!w)
|
|
64
|
+
throw new Error("Missing appended iframe");
|
|
65
|
+
w.addEventListener("load", () => {
|
|
66
|
+
const e = setInterval(
|
|
67
|
+
() => L(_, { key: "fkn-sandbox" })("APP_READY", {}).then(() => {
|
|
68
|
+
I(_), clearInterval(e);
|
|
69
|
+
}),
|
|
70
|
+
10
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const $ = (e, r) => q().then(
|
|
75
|
+
(t) => L(t, { key: "fkn-sandbox-api" })(e, r)
|
|
76
|
+
), Q = async ({ magnet: e, path: r, offset: t, end: s }) => {
|
|
77
|
+
const { body: o, ...a } = await $("TORRENT", { magnet: e, path: r, offset: t, end: s });
|
|
78
|
+
return new Response(
|
|
79
|
+
o,
|
|
80
|
+
{
|
|
81
|
+
...a,
|
|
82
|
+
headers: Object.fromEntries(a.headers)
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}, V = async ({ magnet: e }) => {
|
|
86
|
+
const { body: r, ...t } = await $("TORRENT_FILE", { magnet: e });
|
|
87
|
+
return new Response(
|
|
88
|
+
r,
|
|
89
|
+
{
|
|
90
|
+
...t,
|
|
91
|
+
headers: Object.fromEntries(t.headers)
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}, E = "osra-message", M = (e) => !!(globalThis.SharedArrayBuffer && e instanceof globalThis.SharedArrayBuffer), k = (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), m = (e) => {
|
|
95
|
+
const r = [], t = (s) => M(s) ? void 0 : k(s) ? r.push(s) : Array.isArray(s) ? s.map(t) : s && typeof s == "object" ? Object.values(s).map(t) : void 0;
|
|
96
|
+
return t(e), r;
|
|
97
|
+
}, A = "__proxyFunctionPort__", v = (e) => {
|
|
98
|
+
const { port1: r, port2: t } = new MessageChannel();
|
|
99
|
+
return r.addEventListener("message", async (s) => {
|
|
100
|
+
try {
|
|
101
|
+
const o = await e(...s.data), a = p(o), n = m(a);
|
|
102
|
+
r.postMessage({ result: a }, { transfer: n });
|
|
103
|
+
} catch (o) {
|
|
104
|
+
r.postMessage({ error: o });
|
|
105
|
+
}
|
|
106
|
+
}), r.start(), t;
|
|
107
|
+
}, p = (e) => M(e) || k(e) ? e : typeof e == "function" ? { [A]: v(e) } : Array.isArray(e) ? e.map(p) : e && typeof e == "object" ? Object.fromEntries(
|
|
108
|
+
Object.entries(e).map(([r, t]) => [
|
|
109
|
+
r,
|
|
110
|
+
p(t)
|
|
111
|
+
])
|
|
112
|
+
) : e, z = (e) => (...r) => new Promise((t, s) => {
|
|
113
|
+
const o = p(r), a = m(o), n = (i) => {
|
|
114
|
+
i.data.error ? s(i.data.error) : t(h(i.data.result)), e.removeEventListener("message", n);
|
|
115
|
+
};
|
|
116
|
+
e.addEventListener("message", n), e.start(), e.postMessage(o, { transfer: a });
|
|
117
|
+
}), h = (e) => M(e) || k(e) ? e : e && typeof e == "object" && e[A] ? z(e[A]) : Array.isArray(e) ? e.map(p) : e && typeof e == "object" ? Object.fromEntries(
|
|
118
|
+
Object.entries(e).map(([r, t]) => [
|
|
119
|
+
r,
|
|
120
|
+
h(t)
|
|
121
|
+
])
|
|
122
|
+
) : e, H = ({
|
|
123
|
+
target: e,
|
|
124
|
+
resolvers: r,
|
|
125
|
+
filter: t,
|
|
126
|
+
map: s,
|
|
127
|
+
key: o = E,
|
|
128
|
+
proxyTarget: a
|
|
129
|
+
}) => {
|
|
130
|
+
const n = (i) => {
|
|
131
|
+
if (!i.data || typeof i.data != "object" || i.data?.source !== o || t && !t(i))
|
|
132
|
+
return;
|
|
133
|
+
if (a) {
|
|
134
|
+
const { type: W, data: S, port: R } = i.data, D = m(S);
|
|
135
|
+
a.postMessage(
|
|
136
|
+
{
|
|
137
|
+
source: o,
|
|
138
|
+
type: W,
|
|
139
|
+
data: S,
|
|
140
|
+
port: R
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
targetOrigin: "*",
|
|
144
|
+
transfer: [R, ...D ?? []]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const { type: c, data: g, port: f } = i.data, l = r[c];
|
|
150
|
+
if (!l)
|
|
151
|
+
throw new Error(`Osra received a message of type "${String(c)}" but no resolver was found for type.`);
|
|
152
|
+
s ? l(...s(g, { event: i, type: c, port: f })) : l(g, { event: i, type: c, port: f });
|
|
153
|
+
};
|
|
154
|
+
return e.addEventListener("message", n), {
|
|
155
|
+
listener: n,
|
|
156
|
+
resolvers: r
|
|
157
|
+
};
|
|
158
|
+
}, J = (e, { key: r = E } = { key: E }) => (t, s) => new Promise((o, a) => {
|
|
159
|
+
const { port1: n, port2: i } = new MessageChannel();
|
|
160
|
+
n.addEventListener(
|
|
161
|
+
"message",
|
|
162
|
+
({ data: f }) => {
|
|
163
|
+
if (f.error)
|
|
164
|
+
a(f.error);
|
|
165
|
+
else {
|
|
166
|
+
const l = h(f.result);
|
|
167
|
+
o(l);
|
|
168
|
+
}
|
|
169
|
+
n.close(), i.close();
|
|
170
|
+
},
|
|
171
|
+
{ once: !0 }
|
|
172
|
+
), n.start();
|
|
173
|
+
const c = p(s), g = m(c);
|
|
174
|
+
e.postMessage(
|
|
175
|
+
{
|
|
176
|
+
source: r,
|
|
177
|
+
type: t,
|
|
178
|
+
data: c,
|
|
179
|
+
port: i
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
targetOrigin: "*",
|
|
183
|
+
transfer: [i, ...g ?? []]
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}), Z = (e) => async (r, t) => {
|
|
187
|
+
const { port: s } = t, o = h(r);
|
|
188
|
+
try {
|
|
189
|
+
const a = await e(o, t), n = p(a), i = m(n);
|
|
190
|
+
return s.postMessage({ result: n }, { transfer: i }), s.close(), a;
|
|
191
|
+
} catch (a) {
|
|
192
|
+
throw s.postMessage({ error: a }), s.close(), a;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
let B;
|
|
196
|
+
globalThis.addEventListener("connect", async (e) => {
|
|
197
|
+
const { resolvers: r } = await import("./io-worker-bde41815.js"), { ports: [t] } = e;
|
|
198
|
+
H({
|
|
199
|
+
key: "shared-worker-fkn-api",
|
|
200
|
+
target: t,
|
|
201
|
+
resolvers: r
|
|
202
|
+
}), t.start(), B || J(t, { key: "shared-worker-fkn-port" })("getApiTargetPort").then((s) => {
|
|
203
|
+
X(s), B = s;
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
export {
|
|
207
|
+
Z as D,
|
|
208
|
+
Q as P,
|
|
209
|
+
J as R,
|
|
210
|
+
V as u
|
|
211
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const j = "osra-message", u = (e) => !!(globalThis.SharedArrayBuffer && e instanceof globalThis.SharedArrayBuffer), h = (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), y = (e) => {
|
|
2
|
+
const t = [], r = (a) => u(a) ? void 0 : h(a) ? t.push(a) : Array.isArray(a) ? a.map(r) : a && typeof a == "object" ? Object.values(a).map(r) : void 0;
|
|
3
|
+
return r(e), t;
|
|
4
|
+
}, w = "__proxyFunctionPort__", F = (e) => {
|
|
5
|
+
const { port1: t, port2: r } = new MessageChannel();
|
|
6
|
+
return t.addEventListener("message", async (a) => {
|
|
7
|
+
try {
|
|
8
|
+
const l = await e(...a.data), o = d(l), n = y(o);
|
|
9
|
+
t.postMessage({ result: o }, { transfer: n });
|
|
10
|
+
} catch (l) {
|
|
11
|
+
t.postMessage({ error: l });
|
|
12
|
+
}
|
|
13
|
+
}), t.start(), r;
|
|
14
|
+
}, d = (e) => u(e) || h(e) ? e : typeof e == "function" ? { [w]: F(e) } : Array.isArray(e) ? e.map(d) : e && typeof e == "object" ? Object.fromEntries(
|
|
15
|
+
Object.entries(e).map(([t, r]) => [
|
|
16
|
+
t,
|
|
17
|
+
d(r)
|
|
18
|
+
])
|
|
19
|
+
) : e, O = (e) => (...t) => new Promise((r, a) => {
|
|
20
|
+
const l = d(t), o = y(l), n = (s) => {
|
|
21
|
+
s.data.error ? a(s.data.error) : r(T(s.data.result)), e.removeEventListener("message", n);
|
|
22
|
+
};
|
|
23
|
+
e.addEventListener("message", n), e.start(), e.postMessage(l, { transfer: o });
|
|
24
|
+
}), T = (e) => u(e) || h(e) ? e : e && typeof e == "object" && e[w] ? O(e[w]) : Array.isArray(e) ? e.map(d) : e && typeof e == "object" ? Object.fromEntries(
|
|
25
|
+
Object.entries(e).map(([t, r]) => [
|
|
26
|
+
t,
|
|
27
|
+
T(r)
|
|
28
|
+
])
|
|
29
|
+
) : e, B = ({
|
|
30
|
+
target: e,
|
|
31
|
+
resolvers: t,
|
|
32
|
+
filter: r,
|
|
33
|
+
map: a,
|
|
34
|
+
key: l = j,
|
|
35
|
+
proxyTarget: o
|
|
36
|
+
}) => {
|
|
37
|
+
const n = (s) => {
|
|
38
|
+
if (!s.data || typeof s.data != "object" || s.data?.source !== l || r && !r(s))
|
|
39
|
+
return;
|
|
40
|
+
if (o) {
|
|
41
|
+
const { type: S, data: v, port: H } = s.data, M = y(v);
|
|
42
|
+
o.postMessage(
|
|
43
|
+
{
|
|
44
|
+
source: l,
|
|
45
|
+
type: S,
|
|
46
|
+
data: v,
|
|
47
|
+
port: H
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
targetOrigin: "*",
|
|
51
|
+
transfer: [H, ...M ?? []]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { type: i, data: c, port: g } = s.data, p = t[i];
|
|
57
|
+
if (!p)
|
|
58
|
+
throw new Error(`Osra received a message of type "${String(i)}" but no resolver was found for type.`);
|
|
59
|
+
a ? p(...a(c, { event: s, type: i, port: g })) : p(c, { event: s, type: i, port: g });
|
|
60
|
+
};
|
|
61
|
+
return e.addEventListener("message", n), {
|
|
62
|
+
listener: n,
|
|
63
|
+
resolvers: t
|
|
64
|
+
};
|
|
65
|
+
}, f = (e) => async (t, r) => {
|
|
66
|
+
const { port: a } = r, l = T(t);
|
|
67
|
+
try {
|
|
68
|
+
const o = await e(l, r), n = d(o), s = y(n);
|
|
69
|
+
return a.postMessage({ result: n }, { transfer: s }), a.close(), o;
|
|
70
|
+
} catch (o) {
|
|
71
|
+
throw a.postMessage({ error: o }), a.close(), o;
|
|
72
|
+
}
|
|
73
|
+
}, E = await navigator.storage.getDirectory(), A = await E.getDirectoryHandle("torrents", { create: !0 }), b = async (e, t = 0) => e.createSyncAccessHandle().catch(async (r) => {
|
|
74
|
+
if (t > 20)
|
|
75
|
+
throw r;
|
|
76
|
+
return await new Promise((a) => setTimeout(a, 100)), b(e, t + 1);
|
|
77
|
+
}), m = /* @__PURE__ */ new Map();
|
|
78
|
+
B({
|
|
79
|
+
resolvers: {
|
|
80
|
+
ping: f(async () => "pong"),
|
|
81
|
+
openWriteStream: f(async ({ filePath: e, offset: t = 0, size: r }) => {
|
|
82
|
+
let a = t;
|
|
83
|
+
const o = await (await e.split("/").slice(0, -1).reduce(
|
|
84
|
+
async (i, c) => (await i).getDirectoryHandle(c, { create: !0 }),
|
|
85
|
+
Promise.resolve(A)
|
|
86
|
+
)).getFileHandle(e.split("/").slice(-1)[0], { create: !0 }), n = await o.getFile(), s = await b(o);
|
|
87
|
+
return m.set(e, s), r !== n.size && await s.truncate(r), {
|
|
88
|
+
seek: async (i) => {
|
|
89
|
+
a = i;
|
|
90
|
+
},
|
|
91
|
+
write: async (i) => {
|
|
92
|
+
await s.write(i, { at: a }), a += i.byteLength;
|
|
93
|
+
},
|
|
94
|
+
close: async () => {
|
|
95
|
+
m.delete(e), await s.close();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}),
|
|
99
|
+
readTorrentFile: f(async ({ infoHash: e, filePath: t, offset: r, size: a }) => {
|
|
100
|
+
const o = await (await t.split("/").slice(0, -1).reduce(
|
|
101
|
+
async (c, g) => (await c).getDirectoryHandle(g),
|
|
102
|
+
Promise.resolve(await A.getDirectoryHandle(e))
|
|
103
|
+
)).getFileHandle(t.split("/").slice(-1)[0]), n = m.get(`${e}/${t}`), s = n ?? await b(o), i = new ArrayBuffer(a);
|
|
104
|
+
return await s.read(i, { at: r }), n || await s.close(), i;
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
target: globalThis,
|
|
108
|
+
key: "io-worker"
|
|
109
|
+
});
|