@fkn/lib 0.0.1 → 0.0.2
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/dom.d.ts +4 -4
- package/build/index.js +44 -49
- package/package.json +1 -1
package/build/dom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const isWorker: boolean;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const iframe: HTMLIFrameElement
|
|
5
|
-
export declare const targetWindow: Window | null
|
|
2
|
+
export declare const createdIframe: HTMLIFrameElement;
|
|
3
|
+
export declare const foundIframe: HTMLIFrameElement;
|
|
4
|
+
export declare const iframe: HTMLIFrameElement;
|
|
5
|
+
export declare const targetWindow: Window | null;
|
package/build/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { call as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
}), a),
|
|
6
|
-
e ===
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
const c =
|
|
10
|
-
if (
|
|
1
|
+
import { call as d } from "osra";
|
|
2
|
+
let h, a;
|
|
3
|
+
const f = () => (a = new Promise((e, t) => {
|
|
4
|
+
h = e;
|
|
5
|
+
}), a), y = f(), m = async (e) => {
|
|
6
|
+
e === y && f(), h(await e);
|
|
7
|
+
}, g = "https://fkn.app", T = globalThis.window === void 0, r = globalThis.document?.createElement("iframe");
|
|
8
|
+
r && (r.src = `${g}/sandbox-api`, r.style.display = "none", document.body.appendChild(r));
|
|
9
|
+
const c = r, p = c?.contentWindow, b = (e) => m(e), w = () => a, k = async () => d(await w(), { key: "fkn-sandbox-api" })("API_PORT", {});
|
|
10
|
+
if (T) {
|
|
11
11
|
let e = !1;
|
|
12
12
|
a.then(() => {
|
|
13
13
|
e = !0;
|
|
@@ -15,62 +15,57 @@ if (y) {
|
|
|
15
15
|
e || console.warn("@fkn/lib's api target has not resolved after 250ms while in a worker, make sure to call `setApiTarget(messagePort)`");
|
|
16
16
|
}, 250);
|
|
17
17
|
} else {
|
|
18
|
-
if (!
|
|
19
|
-
throw new Error("Missing
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
10
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
} else
|
|
32
|
-
l(r);
|
|
18
|
+
if (!c)
|
|
19
|
+
throw new Error("Missing appended iframe");
|
|
20
|
+
c.addEventListener("load", () => {
|
|
21
|
+
const e = setInterval(
|
|
22
|
+
() => d(p, { key: "fkn-sandbox" })("APP_READY", {}).then(() => {
|
|
23
|
+
m(p), clearInterval(e);
|
|
24
|
+
}),
|
|
25
|
+
10
|
|
26
|
+
);
|
|
27
|
+
});
|
|
33
28
|
}
|
|
34
|
-
const
|
|
35
|
-
(
|
|
36
|
-
),
|
|
37
|
-
const
|
|
29
|
+
const l = (e, t) => w().then(
|
|
30
|
+
(s) => d(s, { key: "fkn-sandbox-api" })(e, t)
|
|
31
|
+
), E = async (e, t) => {
|
|
32
|
+
const s = e, o = t, { body: i, ...n } = await l("SERVER_PROXY_FETCH", { input: s, init: o });
|
|
38
33
|
return new Response(
|
|
39
|
-
|
|
34
|
+
i,
|
|
40
35
|
{
|
|
41
|
-
...
|
|
36
|
+
...n,
|
|
42
37
|
headers: {
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
-
setCookie:
|
|
38
|
+
...n.headers,
|
|
39
|
+
...n.headers && {
|
|
40
|
+
setCookie: n.headers["set-cookie"]
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
44
|
);
|
|
50
|
-
},
|
|
51
|
-
const { body:
|
|
45
|
+
}, P = async ({ magnet: e, path: t, offset: s, end: o }) => {
|
|
46
|
+
const { body: i, ...n } = await l("TORRENT", { magnet: e, path: t, offset: s, end: o });
|
|
52
47
|
return new Response(
|
|
53
|
-
|
|
48
|
+
i,
|
|
54
49
|
{
|
|
55
|
-
...
|
|
56
|
-
headers: Object.fromEntries(
|
|
50
|
+
...n,
|
|
51
|
+
headers: Object.fromEntries(n.headers)
|
|
57
52
|
}
|
|
58
53
|
);
|
|
59
|
-
},
|
|
60
|
-
const { body: t, ...
|
|
54
|
+
}, u = async ({ magnet: e }) => {
|
|
55
|
+
const { body: t, ...s } = await l("TORRENT_FILE", { magnet: e });
|
|
61
56
|
return new Response(
|
|
62
57
|
t,
|
|
63
58
|
{
|
|
64
|
-
...
|
|
65
|
-
headers: Object.fromEntries(
|
|
59
|
+
...s,
|
|
60
|
+
headers: Object.fromEntries(s.headers)
|
|
66
61
|
}
|
|
67
62
|
);
|
|
68
63
|
};
|
|
69
64
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
w as getApiTarget,
|
|
66
|
+
k as getApiTargetPort,
|
|
67
|
+
E as serverProxyFetch,
|
|
68
|
+
b as setApiTarget,
|
|
69
|
+
P as torrent,
|
|
70
|
+
u as torrentFile
|
|
76
71
|
};
|