@fkn/lib 0.0.1 → 0.0.3
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 +2 -4
- package/build/index.js +43 -48
- package/package.json +2 -1
package/build/dom.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export declare const isWorker: boolean;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const iframe: HTMLIFrameElement | undefined;
|
|
5
|
-
export declare const targetWindow: Window | null | undefined;
|
|
2
|
+
export declare const iframe: HTMLIFrameElement;
|
|
3
|
+
export declare const targetWindow: Window | null;
|
package/build/index.js
CHANGED
|
@@ -1,76 +1,71 @@
|
|
|
1
|
-
import { call as
|
|
2
|
-
let f,
|
|
3
|
-
const
|
|
1
|
+
import { call as d } from "osra";
|
|
2
|
+
let f, o;
|
|
3
|
+
const h = () => (o = new Promise((e, t) => {
|
|
4
4
|
f = e;
|
|
5
|
-
}),
|
|
6
|
-
e ===
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
5
|
+
}), o), T = h(), m = async (e) => {
|
|
6
|
+
e === T && h(), f(await e);
|
|
7
|
+
}, g = "https://fkn.app", b = globalThis.window === void 0, c = globalThis?.document.querySelector(`iframe[src="${g}/sandbox-api"]`), a = globalThis.document?.createElement("iframe");
|
|
8
|
+
!c && a && (a.src = `${g}/sandbox-api`, a.style.display = "none", document.body.appendChild(a));
|
|
9
|
+
const y = c || a, p = y?.contentWindow, k = (e) => m(e), w = () => o, u = async () => d(await w(), { key: "fkn-sandbox-api" })("API_PORT", {});
|
|
10
|
+
if (b) {
|
|
11
11
|
let e = !1;
|
|
12
|
-
|
|
12
|
+
o.then(() => {
|
|
13
13
|
e = !0;
|
|
14
14
|
}), setTimeout(() => {
|
|
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 (!y)
|
|
19
|
+
throw new Error("Missing appended iframe");
|
|
20
|
+
const e = setInterval(
|
|
21
|
+
() => d(p, { key: "fkn-sandbox" })("APP_READY", {}).then(() => {
|
|
22
|
+
m(p), clearInterval(e);
|
|
23
|
+
}).catch(() => {
|
|
24
|
+
console.warn("Failed to connect to sandbox, trying again in 10ms");
|
|
25
|
+
}),
|
|
26
|
+
10
|
|
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, r = t, { body: i, ...n } = await l("SERVER_PROXY_FETCH", { input: s, init: r });
|
|
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: r }) => {
|
|
46
|
+
const { body: i, ...n } = await l("TORRENT", { magnet: e, path: t, offset: s, end: r });
|
|
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
|
+
}, I = 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
|
-
|
|
65
|
+
w as getApiTarget,
|
|
66
|
+
u as getApiTargetPort,
|
|
67
|
+
E as serverProxyFetch,
|
|
73
68
|
k as setApiTarget,
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
P as torrent,
|
|
70
|
+
I as torrentFile
|
|
76
71
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkn/lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"dev": "concurrently \"vite build --watch --mode development\" \"tsc --watch\"",
|
|
19
19
|
"build": "vite build && tsc",
|
|
20
|
+
"build-watch": "vite build --watch --mode production && tsc",
|
|
20
21
|
"build-dev": "vite build --mode development && tsc",
|
|
21
22
|
"dev-watch": "vite build --watch --mode development",
|
|
22
23
|
"build-types": "tsc"
|