@fkn/lib 0.5.5 → 0.6.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.
Files changed (116) hide show
  1. package/account.cjs +1 -1
  2. package/account.d.ts +9 -11
  3. package/account.js +2 -2
  4. package/api-BYUraih6.d.ts +524 -0
  5. package/{api-CDb2pv7C.cjs → api-DD5v1qP9.cjs} +1 -1
  6. package/{background-DvQm1JHR.js → background-BVBbBOmL.js} +41 -68
  7. package/background-B_VgpARk.cjs +1 -0
  8. package/cloud/dgram.cjs +1 -1
  9. package/cloud/dgram.d.ts +2 -541
  10. package/cloud/dgram.js +1 -3
  11. package/cloud/dns.cjs +1 -1
  12. package/cloud/dns.d.ts +3 -12
  13. package/cloud/dns.js +0 -1
  14. package/cloud/fs/promises.cjs +1 -1
  15. package/cloud/fs/promises.d.ts +7 -43
  16. package/cloud/fs/promises.js +0 -3
  17. package/cloud/fs.cjs +1 -1
  18. package/cloud/fs.d.ts +3 -75
  19. package/cloud/fs.js +3 -4
  20. package/cloud/http.cjs +1 -1
  21. package/cloud/http.d.ts +2 -767
  22. package/cloud/http.js +0 -3
  23. package/cloud/net.cjs +1 -1
  24. package/cloud/net.d.ts +2 -606
  25. package/cloud/net.js +2 -3
  26. package/cloud-5o7yJHeX.cjs +1 -0
  27. package/cloud-BFyf2uC7.js +112 -0
  28. package/cloud-gklfa4ZN.d.ts +41 -0
  29. package/cloud.cjs +1 -1
  30. package/cloud.d.ts +7 -1053
  31. package/cloud.js +8 -12
  32. package/{connect-button-poDZVmq2.cjs → connect-button-BBEjXzB3.cjs} +1 -1
  33. package/connect-button-D8KXSL6s.d.ts +4 -0
  34. package/desktop.cjs +1 -1
  35. package/desktop.d.ts +37 -34
  36. package/desktop.js +1 -1
  37. package/dgram-CE43gJq9.cjs +1 -0
  38. package/{dgram-c_Xk7ckJ.js → dgram-wtjARbt0.js} +3 -3
  39. package/dgram.cjs +1 -1
  40. package/dgram.d.ts +83 -533
  41. package/dgram.js +1 -3
  42. package/dns.cjs +1 -1
  43. package/dns.d.ts +9 -9
  44. package/dns.js +2 -2
  45. package/extension-3pxUYwrA.d.ts +16 -0
  46. package/extension-CPj10qwa.js +67 -0
  47. package/extension-D-NUXxzF.cjs +1 -0
  48. package/extension.cjs +1 -1
  49. package/extension.d.ts +3 -859
  50. package/extension.js +3 -5
  51. package/fs/promises.cjs +1 -1
  52. package/fs/promises.d.ts +8 -63
  53. package/fs/promises.js +1 -4
  54. package/fs-BfmfMBiw.cjs +1 -0
  55. package/{fs-BQs-x3_j.js → fs-D6nNf1mR.js} +4 -4
  56. package/fs-K7ROdxDx.d.ts +41 -0
  57. package/fs.cjs +1 -1
  58. package/fs.d.ts +81 -131
  59. package/fs.js +1 -4
  60. package/http.cjs +2 -2
  61. package/http.d.ts +152 -733
  62. package/http.js +7 -7
  63. package/index-BJztAQIP.d.ts +721 -0
  64. package/index-C6ZoDJg8.d.ts +31 -0
  65. package/index.cjs +1 -1
  66. package/index.d.ts +25 -2313
  67. package/index.js +23 -26
  68. package/lookup-BtwWaCZJ.d.ts +7 -0
  69. package/net-BDW1AVX1.d.ts +140 -0
  70. package/net-CpuAhaQC.cjs +1 -0
  71. package/{net-Bl6_W3bd.js → net-DKMWPXb_.js} +3 -3
  72. package/net.cjs +1 -1
  73. package/net.d.ts +2 -606
  74. package/net.js +2 -3
  75. package/{node-fs-DQn1TGJz.cjs → node-fs-C0eKnboT.cjs} +1 -1
  76. package/{node-fs-CdKPXPtW.js → node-fs-Dbf93qP7.js} +1 -1
  77. package/opfs/promises.cjs +1 -1
  78. package/opfs/promises.d.ts +8 -63
  79. package/opfs/promises.js +0 -1
  80. package/{opfs-BfcYLPGb.js → opfs-7_GmzQ93.js} +1 -1
  81. package/opfs-uClkgnb5.cjs +1 -0
  82. package/opfs.cjs +1 -1
  83. package/opfs.d.ts +80 -130
  84. package/opfs.js +3 -3
  85. package/package.json +6 -1
  86. package/packages-D36R2vBv.d.ts +108 -0
  87. package/packages.cjs +1 -0
  88. package/packages.d.ts +2 -0
  89. package/packages.js +150 -0
  90. package/{locator-9s7jNIA2.js → proxy-C8SG1Beo.js} +542 -344
  91. package/proxy-bPaU3-Cz.cjs +53 -0
  92. package/react.cjs +1 -1
  93. package/react.d.ts +11 -9
  94. package/react.js +1 -1
  95. package/{chunk-CPXzm0be.js → rolldown-runtime-DF993M8W.js} +1 -1
  96. package/rolldown-runtime-Doa5O59j.cjs +1 -0
  97. package/storage-OkwsFLN1.cjs +1 -0
  98. package/{storage-BcJfnkm3.js → storage-TmeyhZGt.js} +2 -2
  99. package/{utils-BsNRWMfl.cjs → utils-CoimMjf9.cjs} +1 -1
  100. package/background-CbU8TkWo.cjs +0 -1
  101. package/chunk-B6C_zzib.cjs +0 -1
  102. package/cloud-CWg9zCWm.cjs +0 -1
  103. package/cloud-eLyGYzbA.js +0 -33
  104. package/dgram-B3WC4VdJ.cjs +0 -1
  105. package/extension-BLkZiaAP.js +0 -253
  106. package/extension-DAiRg5ny.cjs +0 -1
  107. package/fs-DI1maxcZ.cjs +0 -1
  108. package/locator-CHfEe3Jv.cjs +0 -53
  109. package/net-C5kWnI4C.cjs +0 -1
  110. package/opfs-Dsi4FkJU.cjs +0 -1
  111. package/proxy-A9UvWUaF.cjs +0 -1
  112. package/proxy-wiZN4eTR.js +0 -14
  113. package/storage-C2-_-bTO.cjs +0 -1
  114. /package/{api-ByfayMm1.js → api--bnCFd4w.js} +0 -0
  115. /package/{connect-button-B_63ldmg.js → connect-button-Ds9KpXHe.js} +0 -0
  116. /package/{utils-CNydj3OT.js → utils-DPtyxGQu.js} +0 -0
@@ -0,0 +1,112 @@
1
+ import { n as e } from "./rolldown-runtime-DF993M8W.js";
2
+ import { l as t, s as n, t as r, v as i, y as a } from "./proxy-C8SG1Beo.js";
3
+ import { n as o, t as s } from "./api--bnCFd4w.js";
4
+ import { t as c } from "./dns.js";
5
+ import { t as l } from "./cloud/fs.js";
6
+ import { s as u } from "./net-DKMWPXb_.js";
7
+ import { i as d } from "./dgram-wtjARbt0.js";
8
+ import { t as f } from "./http.js";
9
+ import { expose as p } from "osra";
10
+ //#region src/lib/cloud/frame.ts
11
+ var m = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", h = 2e4, g = 65e3, _ = 3e4, v = 5e3, y = /* @__PURE__ */ new Set(["videoElement"]), b = () => "https://fkn.app", x = (e) => !e || e === "about:blank", S = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, C = ({ target: e, session: t }) => {
12
+ let n = new URL("/attach-frame", b());
13
+ return e && n.searchParams.set("url", e), t && n.searchParams.set("session", t), n.href;
14
+ }, w = (e, t, n) => {
15
+ let r, i = new Promise((e, i) => {
16
+ r = setTimeout(() => i(Error(n)), t);
17
+ });
18
+ return Promise.race([e, i]).finally(() => clearTimeout(r));
19
+ }, T = (e, t) => {
20
+ let n = () => {
21
+ a(), t();
22
+ }, r = e.parentNode, i = new MutationObserver(() => {
23
+ (!e.isConnected || e.parentNode !== r) && (a(), t());
24
+ }), a = () => {
25
+ window.removeEventListener("pagehide", n), i.disconnect();
26
+ };
27
+ window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
28
+ }, E = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: i }), D = (e, t) => {
29
+ let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
30
+ return [...new Set(n)].join("; ");
31
+ }, O = (e) => {
32
+ let t = e.getAttribute("sandbox");
33
+ if (t === null) return;
34
+ let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
35
+ if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
36
+ }, k = async ({ iframe: e, domains: r = [], syncCookies: i = !0, lockdown: o = !1 }) => {
37
+ if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
38
+ if (o) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
39
+ if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
40
+ O(e);
41
+ let s = e.getAttribute("src") ?? "", c = (() => {
42
+ if (x(s)) return null;
43
+ try {
44
+ return new URL(e.src || s, location.href);
45
+ } catch {
46
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${s}`);
47
+ }
48
+ })();
49
+ if (c) {
50
+ let e = new URL("/attach-frame", b());
51
+ if (c.origin === e.origin && c.pathname === e.pathname) throw Error("cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe");
52
+ }
53
+ let l = c?.href ?? "";
54
+ l && t(l);
55
+ let u = l, d = S(i), f = new AbortController();
56
+ if (e.referrerPolicy = "origin", e.allow = D(m, e.allow), e.src = C({
57
+ target: l,
58
+ session: d
59
+ }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
60
+ try {
61
+ let t = await w(p({}, {
62
+ key: "fkn-attach-frame",
63
+ origin: b(),
64
+ transport: {
65
+ receive: window,
66
+ emit: e.contentWindow
67
+ },
68
+ unregisterSignal: f.signal
69
+ }), h, "cloud.attachFrame: timed out connecting to the render proxy page");
70
+ await w(t.ready(), g, "cloud.attachFrame: the render proxy never became ready"), T(e, () => f.abort());
71
+ let r = e.contentWindow, i = () => {
72
+ if (!(!f.signal.aborted && e.isConnected && e.contentWindow === r)) throw f.abort(), E();
73
+ };
74
+ return n({
75
+ executeLocator: (e, n, r) => y.has(n) ? Promise.reject(a(n, "cloud")) : (i(), t.executeLocator(e, n, r)),
76
+ ensurePermission: async () => {},
77
+ goto: async (e, n = {}) => {
78
+ let r = new URL(e, location.href).href;
79
+ i();
80
+ let { timeoutMs: a } = n;
81
+ await w(t.goto(r, n), (a ?? _) + v, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), u = r;
82
+ },
83
+ url: () => u
84
+ });
85
+ } catch (t) {
86
+ throw f.abort(), e.src = l || "about:blank", t;
87
+ }
88
+ }, A = async () => {
89
+ let e = await s.then((e) => e.cloud.quota());
90
+ return {
91
+ premium: e.premium,
92
+ overQuota: e.overQuota,
93
+ throttled: e.overQuota && !e.premium,
94
+ usedBytes: e.usedBytes,
95
+ limitBytes: e.limitBytes,
96
+ remainingBytes: e.remaining,
97
+ bytesPerSecond: e.bytesPerSecond,
98
+ bitsPerSecond: e.bytesPerSecond * 8
99
+ };
100
+ }, j = /* @__PURE__ */ e({
101
+ attachFrame: () => k,
102
+ available: () => M,
103
+ dgram: () => d,
104
+ dns: () => c,
105
+ fetch: () => r,
106
+ fs: () => l,
107
+ http: () => f,
108
+ net: () => u,
109
+ quota: () => A
110
+ }), M = () => o;
111
+ //#endregion
112
+ export { k as i, j as n, A as r, M as t };
@@ -0,0 +1,41 @@
1
+ import { t as Resolvers } from "./api-BYUraih6.js";
2
+ import { b as Frame, y as AttachFrameOptions } from "./index-BJztAQIP.js";
3
+ import { t as dns_d_exports } from "./dns.js";
4
+ import { n as fs_d_exports } from "./fs-K7ROdxDx.js";
5
+ import { s as net_d_exports } from "./net-BDW1AVX1.js";
6
+ import { t as dgram_d_exports } from "./dgram.js";
7
+ import { t as http_d_exports } from "./http.js";
8
+
9
+ //#region src/lib/proxy.d.ts
10
+ type ProxyFetch = Resolvers['cloud']['fetch'];
11
+ type FetchParameters = Parameters<ProxyFetch>;
12
+ declare const cloudFetch: (input: FetchParameters[0], init?: FetchParameters[1]) => Promise<Response>;
13
+ //#endregion
14
+ //#region src/lib/cloud/frame.d.ts
15
+ declare const attachFrame: ({
16
+ iframe,
17
+ domains,
18
+ syncCookies,
19
+ lockdown
20
+ }: AttachFrameOptions) => Promise<Frame>;
21
+ //#endregion
22
+ //#region src/lib/quota.d.ts
23
+ type QuotaStatus = {
24
+ /** the user has a paid subscription, throttle never applies */premium: boolean; /** today's free-tier volume is spent (true even for premium, see `throttled`) */
25
+ overQuota: boolean; /** transfers are actually being rate-limited right now (overQuota and not premium) */
26
+ throttled: boolean;
27
+ /** bytes egressed through FKN relays today (per anonymized IP), saturates at limitBytes:
28
+ * consumption past the free-tier volume is private and never reported */
29
+ usedBytes: number; /** free-tier daily volume before throttling kicks in */
30
+ limitBytes: number; /** bytes of free-tier volume left today */
31
+ remainingBytes: number; /** current effective egress rate cap, bytes per second */
32
+ bytesPerSecond: number; /** current effective egress rate cap, bits per second (for display) */
33
+ bitsPerSecond: number;
34
+ };
35
+ declare const quota: () => Promise<QuotaStatus>;
36
+ declare namespace cloud_d_exports {
37
+ export { QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
38
+ }
39
+ declare const available: () => boolean;
40
+ //#endregion
41
+ export { attachFrame as a, quota as i, cloud_d_exports as n, cloudFetch as o, QuotaStatus as r, available as t };
package/cloud.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./api-CDb2pv7C.cjs`);const e=require(`./proxy-A9UvWUaF.cjs`),t=require(`./cloud-CWg9zCWm.cjs`),n=require(`./dns.cjs`);require(`./node-fs-DQn1TGJz.cjs`),require(`./storage-C2-_-bTO.cjs`);const r=require(`./cloud/fs.cjs`);require(`./utils-BsNRWMfl.cjs`);const i=require(`./net-C5kWnI4C.cjs`),a=require(`./dgram-B3WC4VdJ.cjs`),o=require(`./http.cjs`);exports.available=t.t,Object.defineProperty(exports,`dgram`,{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,`dns`,{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,`fs`,{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,`http`,{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,`net`,{enumerable:!0,get:function(){return i.s}}),exports.quota=t.r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-bPaU3-Cz.cjs"),t=require("./cloud-5o7yJHeX.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-CpuAhaQC.cjs"),a=require("./dgram-CE43gJq9.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),exports.quota=t.r;