@fkn/lib 0.9.18 → 0.9.20

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 (51) hide show
  1. package/{api-BPnL3UKE.d.ts → api-CyWF0RUj.d.ts} +39 -39
  2. package/cloud/fetch.d.ts +1 -1
  3. package/cloud/fs.cjs +1 -1
  4. package/cloud/fs.d.ts +2 -2
  5. package/cloud/fs.js +1 -1
  6. package/cloud/net.d.ts +1 -1
  7. package/cloud-C8jfO0iJ.cjs +1 -0
  8. package/{cloud-BoteCXb4.d.ts → cloud-CQVtRvcI.d.ts} +4 -4
  9. package/cloud-C_1Dt_tR.js +209 -0
  10. package/cloud.cjs +1 -1
  11. package/cloud.d.ts +4 -4
  12. package/cloud.js +1 -1
  13. package/dgram.d.ts +1 -1
  14. package/extension-B3nD2u7c.cjs +1 -0
  15. package/{extension-CN9oFZ0Q.d.ts → extension-CMPZjuaV.d.ts} +1 -1
  16. package/{extension-DVO10P3i.js → extension-jRuNpBs3.js} +42 -42
  17. package/extension.cjs +1 -1
  18. package/extension.d.ts +2 -2
  19. package/extension.js +3 -3
  20. package/fs/promises.cjs +1 -1
  21. package/fs/promises.js +1 -1
  22. package/fs-BW5mVMmu.js +340 -0
  23. package/{fs-D5LFP4_n.d.ts → fs-CUmugp10.d.ts} +1 -1
  24. package/fs-DJm0bhjg.cjs +1 -0
  25. package/fs.cjs +1 -1
  26. package/fs.js +1 -1
  27. package/http.d.ts +1 -1
  28. package/{index-DLaonjpx.d.ts → index-DY8WjklJ.d.ts} +82 -0
  29. package/index.cjs +1 -1
  30. package/index.d.ts +37 -6
  31. package/index.js +41 -30
  32. package/lib-DbiVHPXE.cjs +53 -0
  33. package/{lib-CegQxwDI.js → lib-k3lstfa4.js} +178 -131
  34. package/{net-5t6B2LnQ.d.ts → net-ByL9yG7X.d.ts} +1 -1
  35. package/net.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/{packages-vX-1yfRK.d.ts → packages-Cn8S-Hkn.d.ts} +20 -20
  38. package/packages.d.ts +1 -1
  39. package/{proxy-DcALGZ-U.d.ts → proxy-RU8sbq68.d.ts} +1 -1
  40. package/storage-BW-jDLUL.cjs +1 -0
  41. package/storage-C8hBot2f.js +51 -0
  42. package/storage-qxXFLgTM.d.ts +44 -0
  43. package/cloud-BQoppUw4.cjs +0 -1
  44. package/cloud-C8CeqUht.js +0 -130
  45. package/extension-4BM5hKrn.cjs +0 -1
  46. package/fs-Br0pOpNu.js +0 -315
  47. package/fs-fyR-J9up.cjs +0 -1
  48. package/lib-ulyxIbTr.cjs +0 -53
  49. package/storage-B1stLxSc.js +0 -37
  50. package/storage-BNQlgGqF.cjs +0 -1
  51. package/storage-CXIXrIxB.d.ts +0 -38
@@ -1,4 +1,4 @@
1
- import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-BPnL3UKE.js";
1
+ import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-CyWF0RUj.js";
2
2
  import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
3
3
  import { DuplexOptions, Stream } from "stream";
4
4
  import { EventEmitter } from "events";
package/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-5t6B2LnQ.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-ByL9yG7X.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fkn/lib",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
@@ -1,5 +1,24 @@
1
1
  import { Remote } from "osra";
2
2
 
3
+ //#region src/api/packages/identity.d.ts
4
+ /**
5
+ * A connection's identity. `id` is the normalized package uri when the other end runs on a sandbox
6
+ * tenant origin (e.g. 'npm:@banou/stub'), otherwise its plain page origin. Version-pinned tenant
7
+ * origins normalize to the version-free id, so a package keeps one identity (and one set of install
8
+ * records) across its own updates, for every handler rather than only for npm.
9
+ */
10
+ type Caller = {
11
+ id: string;
12
+ origin: string; /** a package's display name, when provenance knew it. Attribution only, never an identity. */
13
+ name?: string;
14
+ /**
15
+ * Set when PROVENANCE established this caller is a package, which is the only way to know it for a
16
+ * connection whose `origin` is this realm's own (a broker nested inside a tenant we mounted). Every
17
+ * other package caller is recognised from its browser-set tenant origin instead.
18
+ */
19
+ isPackage?: boolean;
20
+ };
21
+ //#endregion
3
22
  //#region src/api/packages/types.d.ts
4
23
  type PackageQuery = {
5
24
  /** package kind, e.g. 'plugin' - becomes the keyword `fkn-type:<type>` */type: string; /** host app scope, e.g. 'stub' - becomes the keyword `fkn-<type>--<id>` */
@@ -61,25 +80,6 @@ type PackagesFail = {
61
80
  message: string;
62
81
  };
63
82
  //#endregion
64
- //#region src/api/packages/identity.d.ts
65
- /**
66
- * A connection's identity. `id` is the normalized package uri when the other end runs on a sandbox
67
- * tenant origin (e.g. 'npm:@banou/stub'), otherwise its plain page origin. Version-pinned tenant
68
- * origins normalize to the version-free id, so a package keeps one identity (and one set of install
69
- * records) across its own updates, for every handler rather than only for npm.
70
- */
71
- type Caller = {
72
- id: string;
73
- origin: string; /** a package's display name, when provenance knew it. Attribution only, never an identity. */
74
- name?: string;
75
- /**
76
- * Set when PROVENANCE established this caller is a package, which is the only way to know it for a
77
- * connection whose `origin` is this realm's own (a broker nested inside a tenant we mounted). Every
78
- * other package caller is recognised from its browser-set tenant origin instead.
79
- */
80
- isPackage?: boolean;
81
- };
82
- //#endregion
83
83
  //#region src/api/packages/host.d.ts
84
84
  type MountDescriptor = {
85
85
  /** where to point the iframe: the tenant origin plus the package's path */url: string; /** the tenant origin alone, which is what a `postMessage` to that frame must target */
@@ -214,4 +214,4 @@ declare const onVisibilityChange: (handler: (visible: boolean) => void) => {
214
214
  unsubscribe: () => void;
215
215
  };
216
216
  //#endregion
217
- export { InstallOptions as A, pick as C, MountDescriptor as D, uninstall as E, PackagesFail as F, PickOptions as I, Placement as L, PackageQuery as M, PackageResult as N, Caller as O, PackagesErrorCode as P, Radii as R, packages_d_exports as S, show as T, isVisible as _, IncomingConnectionInfo as a, onConnect as b, PackageConnection as c, RawPackageConnection as d, ShowOptions as f, install as g, hide as h, IncomingConnection as i, InstalledPackage as j, ConnectOptions as k, PackageView as l, connect as m, Connect as n, MountOptions as o, attach as p, ConnectPayload as r, MountedPackage as s, AppConnectOptions as t, PackagesError as u, list as v, search as w, onVisibilityChange as x, mount as y, SurfaceRect as z };
217
+ export { InstalledPackage as A, pick as C, MountDescriptor as D, uninstall as E, PickOptions as F, Placement as I, Radii as L, PackageResult as M, PackagesErrorCode as N, ConnectOptions as O, PackagesFail as P, SurfaceRect as R, packages_d_exports as S, show as T, isVisible as _, IncomingConnectionInfo as a, onConnect as b, PackageConnection as c, RawPackageConnection as d, ShowOptions as f, install as g, hide as h, IncomingConnection as i, PackageQuery as j, InstallOptions as k, PackageView as l, connect as m, Connect as n, MountOptions as o, attach as p, ConnectPayload as r, MountedPackage as s, AppConnectOptions as t, PackagesError as u, list as v, search as w, onVisibilityChange as x, mount as y, Caller as z };
package/packages.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as InstallOptions, C as pick, E as uninstall, I as PickOptions, L as Placement, M as PackageQuery, N as PackageResult, P as PackagesErrorCode, R as Radii, T as show, _ as isVisible, a as IncomingConnectionInfo, b as onConnect, c as PackageConnection, d as RawPackageConnection, f as ShowOptions, g as install, h as hide, i as IncomingConnection, j as InstalledPackage, k as ConnectOptions, l as PackageView, m as connect, n as Connect, o as MountOptions, p as attach, r as ConnectPayload, s as MountedPackage, t as AppConnectOptions, u as PackagesError, v as list, w as search, x as onVisibilityChange, y as mount, z as SurfaceRect } from "./packages-vX-1yfRK.js";
1
+ import { A as InstalledPackage, C as pick, E as uninstall, F as PickOptions, I as Placement, L as Radii, M as PackageResult, N as PackagesErrorCode, O as ConnectOptions, R as SurfaceRect, T as show, _ as isVisible, a as IncomingConnectionInfo, b as onConnect, c as PackageConnection, d as RawPackageConnection, f as ShowOptions, g as install, h as hide, i as IncomingConnection, j as PackageQuery, k as InstallOptions, l as PackageView, m as connect, n as Connect, o as MountOptions, p as attach, r as ConnectPayload, s as MountedPackage, t as AppConnectOptions, u as PackagesError, v as list, w as search, x as onVisibilityChange, y as mount } from "./packages-Cn8S-Hkn.js";
2
2
  export { AppConnectOptions, Connect, type ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, type InstallOptions, type InstalledPackage, MountOptions, MountedPackage, PackageConnection, type PackageQuery, type PackageResult, PackageView, PackagesError, type PackagesErrorCode, type PickOptions, type Placement, type Radii, RawPackageConnection, ShowOptions, type SurfaceRect, attach, connect, hide, install, isVisible, list, mount, onConnect, onVisibilityChange, pick, search, show, uninstall };
@@ -1,4 +1,4 @@
1
- import { t as Resolvers } from "./api-BPnL3UKE.js";
1
+ import { t as Resolvers } from "./api-CyWF0RUj.js";
2
2
 
3
3
  //#region src/lib/proxy.d.ts
4
4
  type ProxyFetch = Resolvers['cloud']['fetch'];
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-kHMHDGar.cjs");var n=`FKN_STORAGE_NOT_FOUND`,r=e.t({StorageLockedError:()=>i,StorageNotFoundError:()=>a,availability:()=>p,available:()=>c,encryption:()=>y,isNotFound:()=>o,list:()=>m,quota:()=>h,readFile:()=>g,remove:()=>v,unlock:()=>b,writeFile:()=>_}),i=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: this account stores encrypted data, unlock it from the FKN card or unlock()`)}},a=class extends Error{code=n;constructor(e=`storage: no object at that path`){super(e)}},o=e=>e?.code===n,s=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new i:o(e)||e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new a(e.message):e},c=()=>t.t.then(e=>e.cloud.fs.available()).catch(()=>!1),l=8e3,u=1e3,d=!1,f=async()=>{let e=(await t.t).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},p=async()=>{let e=d?u:l,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);f().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(d=!0,`unknown`):(d=!1,t)},m=()=>t.t.then(e=>e.cloud.fs.list()),h=()=>t.t.then(e=>e.cloud.fs.quota()),g=async e=>{let n=await(await t.t).cloud.fs.readFile(e).catch(s);return new Blob([n])},_=async(e,n,r)=>{let i=await t.t,a=n instanceof Blob?new Uint8Array(await n.arrayBuffer()):n;await i.cloud.fs.writeFile(e,a,r?.contentType??null).catch(s)},v=e=>t.t.then(t=>t.cloud.fs.remove(e)).then(()=>void 0),y=()=>t.t.then(e=>e.cloud.fs.encryption()),b=()=>t.t.then(e=>e.cloud.fs.unlock());Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return r}});
@@ -0,0 +1,51 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { t } from "./api-DQ-V4Lls.js";
3
+ //#endregion
4
+ //#region src/api/storage.ts
5
+ var n = "FKN_STORAGE_NOT_FOUND", r = /* @__PURE__ */ e({
6
+ StorageLockedError: () => i,
7
+ StorageNotFoundError: () => a,
8
+ availability: () => p,
9
+ available: () => c,
10
+ encryption: () => y,
11
+ isNotFound: () => o,
12
+ list: () => m,
13
+ quota: () => h,
14
+ readFile: () => g,
15
+ remove: () => v,
16
+ unlock: () => b,
17
+ writeFile: () => _
18
+ }), i = class extends Error {
19
+ code = "FKN_E2E_LOCKED";
20
+ constructor() {
21
+ super("storage locked: this account stores encrypted data, unlock it from the FKN card or unlock()");
22
+ }
23
+ }, a = class extends Error {
24
+ code = n;
25
+ constructor(e = "storage: no object at that path") {
26
+ super(e);
27
+ }
28
+ }, o = (e) => e?.code === n, s = (e) => {
29
+ throw e instanceof Error && e.message.startsWith("fkn:e2e-locked") ? new i() : o(e) || e instanceof Error && (/^not found$/i.test(e.message) || /\(404\)$/.test(e.message)) ? new a(e.message) : e;
30
+ }, c = () => t.then((e) => e.cloud.fs.available()).catch(() => !1), l = 8e3, u = 1e3, d = !1, f = async () => {
31
+ let e = (await t).cloud.fs;
32
+ return typeof e.availability == "function" ? e.availability() : await e.available() ? "connected" : "disconnected";
33
+ }, p = async () => {
34
+ let e = d ? u : l, t = await new Promise((t) => {
35
+ let n = setTimeout(() => t("timeout"), e);
36
+ f().then((e) => {
37
+ clearTimeout(n), t(e);
38
+ }, () => {
39
+ clearTimeout(n), t("unknown");
40
+ });
41
+ });
42
+ return t === "timeout" ? (d = !0, "unknown") : (d = !1, t);
43
+ }, m = () => t.then((e) => e.cloud.fs.list()), h = () => t.then((e) => e.cloud.fs.quota()), g = async (e) => {
44
+ let n = await (await t).cloud.fs.readFile(e).catch(s);
45
+ return new Blob([n]);
46
+ }, _ = async (e, n, r) => {
47
+ let i = await t, a = n instanceof Blob ? new Uint8Array(await n.arrayBuffer()) : n;
48
+ await i.cloud.fs.writeFile(e, a, r?.contentType ?? null).catch(s);
49
+ }, v = (e) => t.then((t) => t.cloud.fs.remove(e)).then(() => void 0), y = () => t.then((e) => e.cloud.fs.encryption()), b = () => t.then((e) => e.cloud.fs.unlock());
50
+ //#endregion
51
+ export { o as a, g as c, b as d, _ as f, y as i, v as l, a as n, m as o, n as p, p as r, h as s, i as t, r as u };
@@ -0,0 +1,44 @@
1
+ //#region src/api/storage.d.ts
2
+ type StorageEntry = {
3
+ path: string;
4
+ size: number;
5
+ contentType: string | null;
6
+ updatedAt: string;
7
+ encryption: string | null;
8
+ };
9
+ type StorageQuota = {
10
+ usedBytes: number;
11
+ limitBytes: number;
12
+ remaining: number;
13
+ objects: number;
14
+ maxObjects: number;
15
+ };
16
+ type WriteData = ArrayBuffer | Uint8Array | string;
17
+ type StorageReadResult = {
18
+ bytes: Uint8Array;
19
+ encryption: string | null;
20
+ appOrigin: string;
21
+ };
22
+ type KeyState = {
23
+ keyEpoch: number | null;
24
+ keyFingerprint: string | null;
25
+ storageEncrypted: boolean;
26
+ };
27
+ /**
28
+ * "There is no object at this path", as a thing a caller can TEST rather than parse.
29
+ *
30
+ * osra's error boxer ships name, message, stack and cause ONLY, so this code survives same-realm
31
+ * hops but NOT the SharedWorker boundary; the message fallback in src/lib/storage.ts's rethrow is
32
+ * what carries absence across that hop and re-mints the coded error for apps. The message does not
33
+ * survive being reworded, which is the problem this exists to end: absence arrives in two
34
+ * completely different sentences depending on which half of the read failed, and every consumer
35
+ * was left regex-matching both. Ripple got one of them and missed the other, and a library quietly
36
+ * went un-backed-up for a day because a missing backup read as a transient error.
37
+ */
38
+ declare const STORAGE_NOT_FOUND = "FKN_STORAGE_NOT_FOUND";
39
+ type SealedGeneration = {
40
+ epoch: number;
41
+ fingerprint: string;
42
+ };
43
+ //#endregion
44
+ export { StorageQuota as a, StorageEntry as i, STORAGE_NOT_FOUND as n, StorageReadResult as o, SealedGeneration as r, WriteData as s, KeyState as t };
@@ -1 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-kHMHDGar.cjs"),r=require("./proxy-B0gNjT8-.cjs"),i=require("./dns.cjs"),a=require("./cloud/fs.cjs"),o=require("./net-COzDDBnS.cjs"),s=require("./dgram-D2Or5f2e.cjs"),c=require("./http.cjs");let l=require("osra");var u=e=>e,d=`autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write`,f=2e4,p=65e3,m=3e4,h=5e3,g=new Set,_=()=>`https://fkn.app`,v=e=>!e||e===`about:blank`,y=e=>e?``:`incognito-${crypto.randomUUID()}`,b=({target:e,session:t})=>{let n=new URL(`/attach-frame`,_());return e&&n.searchParams.set(`url`,e),t&&n.searchParams.set(`session`,t),n.href},x=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(n)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},S=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{(!e.isConnected||e.parentNode!==r)&&(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},C=()=>Object.assign(Error(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),{name:t.h}),w=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},T=[300,1200,4e3],E=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of T)setTimeout(t,e)},D=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},O=async({iframe:e,domains:n=[],syncCookies:r=!0,lockdown:i=!1})=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(i)throw Error(`cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame`);if(!e.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);D(e);let a=e.getAttribute(`src`)??``,o=(()=>{if(v(a))return null;try{return new URL(e.src||a,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${a}`)}})();if(o){let e=new URL(`/attach-frame`,_());if(o.origin===e.origin&&o.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`)}let s=o?.href??``;s&&t.s(s);let c=s,T=y(r),O=new AbortController,k=e.referrerPolicy,A=e.allow;if(e.referrerPolicy=`origin`,e.allow=w(d,e.allow),e.src=b({target:s,session:T}),!e.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let n=await x((0,l.expose)({},{key:`fkn-attach-frame`,origin:_(),transport:{receive:window,emit:e.contentWindow},unregisterSignal:O.signal,revivableModules:u(t.L)}),f,`cloud.attachFrame: timed out connecting to the render proxy page`);await x(n.ready(),p,`cloud.attachFrame: the render proxy never became ready`),s&&E(e),S(e,()=>O.abort());let r=e.contentWindow,i=()=>{if(!(!O.signal.aborted&&e.isConnected&&e.contentWindow===r))throw O.abort(),C()};return t.a({executor:{execute:(e,r,a)=>g.has(r)?Promise.reject(t.f(r,`cloud`)):(i(),n.executeLocator(e,r,a)),highlight:async()=>{}},goto:async(t,r={})=>{let a=new URL(t,location.href).href;i();let{timeoutMs:o}=r;await x(n.goto(a,r),(o??m)+h,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`),c=a,E(e)},url:()=>c})}catch(t){throw O.abort(),e.referrerPolicy=k,e.allow=A,e.src=s||`about:blank`,t}},k=()=>typeof window<`u`&&!0,A=async()=>{let e=await n.t.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},j=e.t({attachFrame:()=>O,available:()=>M,dgram:()=>s.i,dns:()=>i.t,fetch:()=>r.t,fs:()=>a.t,http:()=>c.t,net:()=>o.s,quota:()=>A}),M=()=>n.r;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return M}});
package/cloud-C8CeqUht.js DELETED
@@ -1,130 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { L as t, a as n, f as r, h as i, s as a } from "./lib-CegQxwDI.js";
3
- import { r as o, t as s } from "./api-DQ-V4Lls.js";
4
- import { t as c } from "./proxy-BpqvCJmA.js";
5
- import { t as l } from "./dns.js";
6
- import { t as u } from "./cloud/fs.js";
7
- import { s as d } from "./net-BbmQeMpt.js";
8
- import { i as f } from "./dgram-DlGl_ho1.js";
9
- import { t as p } from "./http.js";
10
- import { expose as m } from "osra";
11
- //#region src/lib/cloud/frame.ts
12
- var h = (e) => e, g = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", _ = 2e4, v = 65e3, y = 3e4, b = 5e3, x = /* @__PURE__ */ new Set(), S = () => "https://fkn.app", C = (e) => !e || e === "about:blank", w = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, T = ({ target: e, session: t }) => {
13
- let n = new URL("/attach-frame", S());
14
- return e && n.searchParams.set("url", e), t && n.searchParams.set("session", t), n.href;
15
- }, E = (e, t, n) => {
16
- let r, i = new Promise((e, i) => {
17
- r = setTimeout(() => i(Error(n)), t);
18
- });
19
- return Promise.race([e, i]).finally(() => clearTimeout(r));
20
- }, D = (e, t) => {
21
- let n = () => {
22
- a(), t();
23
- }, r = e.parentNode, i = new MutationObserver(() => {
24
- (!e.isConnected || e.parentNode !== r) && (a(), t());
25
- }), a = () => {
26
- window.removeEventListener("pagehide", n), i.disconnect();
27
- };
28
- window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
29
- }, O = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: i }), k = (e, t) => {
30
- let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
31
- return [...new Set(n)].join("; ");
32
- }, A = [
33
- 300,
34
- 1200,
35
- 4e3
36
- ], j = (e) => {
37
- let t = () => {
38
- if (!e.isConnected) return;
39
- let t = e.style.height, n = e.getBoundingClientRect();
40
- n.height && (e.style.height = `${n.height - 1}px`, setTimeout(() => {
41
- e.style.height = t;
42
- }, 50));
43
- };
44
- t();
45
- for (let e of A) setTimeout(t, e);
46
- }, M = (e) => {
47
- let t = e.getAttribute("sandbox");
48
- if (t === null) return;
49
- let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
50
- if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
51
- }, N = async ({ iframe: e, domains: i = [], syncCookies: o = !0, lockdown: s = !1 }) => {
52
- if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
53
- if (s) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
54
- if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
55
- M(e);
56
- let c = e.getAttribute("src") ?? "", l = (() => {
57
- if (C(c)) return null;
58
- try {
59
- return new URL(e.src || c, location.href);
60
- } catch {
61
- throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${c}`);
62
- }
63
- })();
64
- if (l) {
65
- let e = new URL("/attach-frame", S());
66
- if (l.origin === e.origin && l.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");
67
- }
68
- let u = l?.href ?? "";
69
- u && a(u);
70
- let d = u, f = w(o), p = new AbortController(), A = e.referrerPolicy, N = e.allow;
71
- if (e.referrerPolicy = "origin", e.allow = k(g, e.allow), e.src = T({
72
- target: u,
73
- session: f
74
- }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
75
- try {
76
- let i = await E(m({}, {
77
- key: "fkn-attach-frame",
78
- origin: S(),
79
- transport: {
80
- receive: window,
81
- emit: e.contentWindow
82
- },
83
- unregisterSignal: p.signal,
84
- revivableModules: h(t)
85
- }), _, "cloud.attachFrame: timed out connecting to the render proxy page");
86
- await E(i.ready(), v, "cloud.attachFrame: the render proxy never became ready"), u && j(e), D(e, () => p.abort());
87
- let a = e.contentWindow, o = () => {
88
- if (!(!p.signal.aborted && e.isConnected && e.contentWindow === a)) throw p.abort(), O();
89
- };
90
- return n({
91
- executor: {
92
- execute: (e, t, n) => x.has(t) ? Promise.reject(r(t, "cloud")) : (o(), i.executeLocator(e, t, n)),
93
- highlight: async () => {}
94
- },
95
- goto: async (t, n = {}) => {
96
- let r = new URL(t, location.href).href;
97
- o();
98
- let { timeoutMs: a } = n;
99
- await E(i.goto(r, n), (a ?? y) + b, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), d = r, j(e);
100
- },
101
- url: () => d
102
- });
103
- } catch (t) {
104
- throw p.abort(), e.referrerPolicy = A, e.allow = N, e.src = u || "about:blank", t;
105
- }
106
- }, P = () => typeof window < "u" && !0, F = async () => {
107
- let e = await s.then((e) => e.cloud.quota());
108
- return {
109
- premium: e.premium,
110
- overQuota: e.overQuota,
111
- throttled: e.overQuota && !e.premium,
112
- usedBytes: e.usedBytes,
113
- limitBytes: e.limitBytes,
114
- remainingBytes: e.remaining,
115
- bytesPerSecond: e.bytesPerSecond,
116
- bitsPerSecond: e.bytesPerSecond * 8
117
- };
118
- }, I = /* @__PURE__ */ e({
119
- attachFrame: () => N,
120
- available: () => L,
121
- dgram: () => f,
122
- dns: () => l,
123
- fetch: () => c,
124
- fs: () => u,
125
- http: () => p,
126
- net: () => d,
127
- quota: () => F
128
- }), L = () => o;
129
- //#endregion
130
- export { P as a, N as i, I as n, F as r, L as t };
@@ -1 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-kHMHDGar.cjs"),r=require("./proxy-B0gNjT8-.cjs"),i=require("./desktop.cjs");var a=async e=>{if(typeof window>`u`)return!1;if(t.P())return!0;let r=await n.t,i=null,a=new Promise(e=>{i=()=>{t.P()&&e(!0)},t.N.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.N.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},o=null;t.F(()=>(o||=a().then(()=>void 0).finally(()=>{o=null}),o));var s=()=>typeof document<`u`&&t.P(),c=async(e,n)=>{if(r.n(e),n?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.C(e,n)}return s()?t.C(e,{...n,credentials:`omit`}):i.available()?i.fetch(e,n):r.t(e,n)},l=e.t({ATTACH_FRAME_EVENT_KEY:()=>t.n,FORGEABLE_HEADERS:()=>t.k,LOCATOR_DENIED:()=>t.g,LOCATOR_ERROR:()=>t.u,LOCATOR_UNSUPPORTED:()=>t.h,assertAttachableFrameUrl:()=>t.s,assertFetchableUrl:()=>t.S,assertForgeableHeaders:()=>t.A,assertLockdownApplicable:()=>t.c,assertOneCookieIdentity:()=>t.j,attachFrame:()=>t.r,attachFramePermission:()=>t.i,available:()=>s,box:()=>t.R,cookies:()=>t.b,createFrame:()=>t.a,createVideoElementHandle:()=>t.z,events:()=>t.N,extension:()=>t.N,fetch:()=>t.C,fetchCredentialedPermission:()=>t.w,fetchLocalPermission:()=>t.T,fetchPermission:()=>t.E,gotoPermission:()=>t.o,handleRevivableModules:()=>t.L,hasForgedCookie:()=>t.M,isBlockedFetchUrl:()=>t.D,isBlockedFrameUrl:()=>t.l,isExtensionExposed:()=>t.P,isLocalNetworkUrl:()=>t.O,isLocatorDenied:()=>t.d,isLocatorUnsupported:()=>t.m,isTerminalError:()=>t.p,isType:()=>t.B,modifyRequestHeadersPermission:()=>t._,permissions:()=>t.t,promptInstall:()=>a,readCookiePermission:()=>t.x,removeRequestHeaderRule:()=>t.v,revive:()=>t.V,setMissingExtensionHandler:()=>t.F,setRequestHeaderRule:()=>t.y,type:()=>t.H,waitForExtensionExposure:()=>t.I});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
package/fs-Br0pOpNu.js DELETED
@@ -1,315 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "./node-fs-DKfokOlh.js";
3
- import { c as n, f as r, l as i, o as a, r as o } from "./storage-B1stLxSc.js";
4
- import { a as s, i as c, n as l, o as u, t as d } from "./opfs-BibrNGF0.js";
5
- //#region src/lib/fs/hybrid.ts
6
- var f = /* @__PURE__ */ e({
7
- adopt: () => F,
8
- adoptable: () => I,
9
- available: () => te,
10
- list: () => ie,
11
- onConflict: () => N,
12
- pending: () => D,
13
- pendingDeletes: () => O,
14
- pull: () => ce,
15
- readFile: () => ae,
16
- remove: () => se,
17
- replicating: () => k,
18
- writeFile: () => oe
19
- }), ee, p = async () => await (ee ??= d().catch(() => !1)) ? !0 : (ee = void 0, !1), m = () => o().catch(() => !1), te = async () => await p() || await m(), h = "fkn:fs:pending", g = "fkn:fs:pending-delete", _ = "fkn:fs:adopt-declined", v = !0, y = /* @__PURE__ */ new Map(), b = (e) => {
20
- try {
21
- let t = localStorage.getItem(e);
22
- if (!t) return {};
23
- let n = JSON.parse(t);
24
- return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
25
- } catch {
26
- return {};
27
- }
28
- }, x = (e, t) => {
29
- try {
30
- Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
31
- } catch {}
32
- }, S = () => b(h), C = (e) => {
33
- let t = S();
34
- e in t || (t[e] = y.get(e) ?? null, x(h, t));
35
- }, w = (e) => {
36
- let t = S();
37
- e in t && (delete t[e], x(h, t));
38
- }, T = () => b(g), ne = (e) => {
39
- let t = T();
40
- e in t || (t[e] = y.get(e) ?? null, x(g, t));
41
- }, E = (e) => {
42
- let t = T();
43
- e in t && (delete t[e], x(g, t));
44
- }, D = () => Object.keys(S()), O = () => Object.keys(T()), k = () => v, A = null, re = null, j = () => re ??= import("./api-DQ-V4Lls.js").then((e) => e.n).then((e) => e.apiPromise), ie = async () => {
45
- me();
46
- let e = await m(), [t, n] = await Promise.all([p().then((e) => e ? l() : []).catch(() => []), e ? a().then((e) => ({
47
- ok: !0,
48
- entries: e
49
- })).catch(() => ({
50
- ok: !1,
51
- entries: []
52
- })) : Promise.resolve({
53
- ok: !0,
54
- entries: []
55
- })]);
56
- v = n.ok, n.ok && (y = new Map(n.entries.map((e) => [e.path, e.updatedAt])));
57
- let r = /* @__PURE__ */ new Map(), i = (e) => {
58
- let t = Date.parse(e.updatedAt ?? "");
59
- return Number.isFinite(t) ? t : 0;
60
- }, o = (e) => {
61
- let t = r.get(e.path);
62
- (!t || i(e) >= i(t)) && r.set(e.path, e);
63
- };
64
- for (let e of t) o(e);
65
- for (let e of n.entries) o(e);
66
- if (n.ok && e) {
67
- pe(t, n.entries).catch(() => {});
68
- let e = Object.keys(S()).length || Object.keys(T()).length;
69
- e && !A ? A = P(!1).catch(() => {}).finally(() => {
70
- A = null;
71
- }) : e || R({
72
- local: t,
73
- remote: n.entries
74
- }).catch(() => {});
75
- }
76
- return [...r.values()];
77
- }, ae = async (e) => {
78
- if (await p()) try {
79
- return await c(e);
80
- } catch (e) {
81
- if (e?.name !== "NotFoundError") throw e;
82
- }
83
- let t = await n(e);
84
- return await p() && u(e, t).catch(() => {}), t;
85
- }, oe = async (e, t, n) => {
86
- let i = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
87
- if (await p()) {
88
- if (await u(e, i, n), !await m()) return;
89
- if (!v) {
90
- C(e);
91
- return;
92
- }
93
- r(e, i, n).then(() => w(e)).catch((t) => {
94
- C(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
95
- });
96
- return;
97
- }
98
- if (await m()) return r(e, i, n);
99
- throw Error("fs: no storage backend available");
100
- }, se = async (e) => {
101
- let t = [];
102
- await p() && t.push(s(e).catch(() => {}));
103
- let n = await m();
104
- if (n && t.push(i(e).then(() => E(e)).catch((t) => {
105
- ne(e), console.warn("fs: cloud delete failed, queued for retry", t);
106
- })), !t.length) throw Error("fs: no storage backend available");
107
- n && w(e), await Promise.all(t);
108
- }, ce = async (e) => {
109
- let t = await n(e);
110
- return await p() && await u(e, t), t;
111
- }, M = null, N = (e) => (M = e, () => {
112
- M === e && (M = null);
113
- }), le = async (e) => (await j()).cloud.fs.promptConflict({
114
- path: e.path,
115
- local: e.local,
116
- cloud: e.cloud
117
- }).catch(() => null), ue = async (e) => {
118
- if (M) try {
119
- return await M(e);
120
- } catch {
121
- return null;
122
- }
123
- return le(e);
124
- }, P = async (e) => {
125
- let t = {
126
- uploaded: [],
127
- kept: [],
128
- resolved: [],
129
- unresolved: [],
130
- deleted: [],
131
- failed: []
132
- };
133
- if (!await m()) throw Error("fs: this needs a signed-in account");
134
- if (!await p()) return t;
135
- let [o, s] = await Promise.all([l(), a()]), d = new Map(s.map((e) => [e.path, e])), f = S();
136
- for (let [e, n] of Object.entries(T())) {
137
- let r = d.get(e);
138
- if (!r) {
139
- E(e);
140
- continue;
141
- }
142
- if (o.some((t) => t.path === e)) {
143
- E(e);
144
- continue;
145
- }
146
- if (r.updatedAt !== n) {
147
- E(e);
148
- continue;
149
- }
150
- try {
151
- await i(e), E(e), t.deleted.push(e);
152
- } catch (n) {
153
- t.failed.push({
154
- path: e,
155
- error: n instanceof Error ? n.message : String(n)
156
- });
157
- }
158
- }
159
- for (let i of o) {
160
- let a = d.get(i.path), o = i.path in f;
161
- if (!o && (a || !e)) {
162
- a && t.kept.push(i.path);
163
- continue;
164
- }
165
- if (o && a && a.updatedAt !== f[i.path]) {
166
- let e = await ue({
167
- path: i.path,
168
- local: {
169
- size: i.size,
170
- updatedAt: i.updatedAt
171
- },
172
- cloud: {
173
- size: a.size,
174
- updatedAt: a.updatedAt
175
- },
176
- readLocal: () => c(i.path),
177
- readCloud: () => n(i.path)
178
- });
179
- if (!e) {
180
- t.unresolved.push(i.path);
181
- continue;
182
- }
183
- try {
184
- if (e === "cloud") await u(i.path, await n(i.path));
185
- else {
186
- let t = e === "local" ? await c(i.path) : e.merged;
187
- await r(i.path, t, i.contentType ? { contentType: i.contentType } : void 0), e !== "local" && await u(i.path, t);
188
- }
189
- w(i.path), t.resolved.push({
190
- path: i.path,
191
- choice: e === "local" || e === "cloud" ? e : "merged"
192
- });
193
- } catch (e) {
194
- if (e?.code === "FKN_E2E_LOCKED") throw e;
195
- t.failed.push({
196
- path: i.path,
197
- error: e instanceof Error ? e.message : String(e)
198
- });
199
- }
200
- continue;
201
- }
202
- try {
203
- let e = await c(i.path);
204
- await r(i.path, e, i.contentType ? { contentType: i.contentType } : void 0), w(i.path), t.uploaded.push(i.path);
205
- } catch (e) {
206
- if (C(i.path), e?.code === "FKN_E2E_LOCKED") throw e;
207
- t.failed.push({
208
- path: i.path,
209
- error: e instanceof Error ? e.message : String(e)
210
- });
211
- }
212
- }
213
- return t;
214
- }, F = () => P(!0), I = async () => {
215
- if (!await m() || !await p()) return {
216
- paths: [],
217
- bytes: 0
218
- };
219
- let [e, t] = await Promise.all([l(), a()]), n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path));
220
- return {
221
- paths: r.map((e) => e.path),
222
- bytes: r.reduce((e, t) => e + t.size, 0)
223
- };
224
- }, de = () => new Set(Object.keys(b(_))), fe = (e) => {
225
- let t = b(_);
226
- for (let n of e) t[n] = null;
227
- x(_, t);
228
- }, L = null, R = (e) => L || (L = (async () => {
229
- if (!await m()) return;
230
- let t = e ?? (await p() ? {
231
- local: await l(),
232
- remote: await a()
233
- } : null);
234
- if (!t) return;
235
- let n = new Set(t.remote.map((e) => e.path)), r = de(), i = t.local.filter((e) => !n.has(e.path) && !r.has(e.path));
236
- if (!i.length) return;
237
- let o = await j(), s = i.reduce((e, t) => e + t.size, 0);
238
- if (!await o.cloud.fs.promptAdopt({
239
- files: i.length,
240
- bytes: s
241
- }).catch(() => !1)) {
242
- fe(i.map((e) => e.path));
243
- return;
244
- }
245
- await F();
246
- })().catch(() => {}).finally(() => {
247
- L = null;
248
- }), L), pe = async (e, t) => {
249
- let n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path)), i = await j(), a = async () => {
250
- await F().catch(() => {});
251
- let e = await I().catch(() => ({
252
- paths: [],
253
- bytes: 0
254
- }));
255
- await i.cloud.fs.setAdoptSource({
256
- files: e.paths.length,
257
- bytes: e.bytes
258
- }, a).catch(() => {});
259
- };
260
- await i.cloud.fs.setAdoptSource({
261
- files: r.length,
262
- bytes: r.reduce((e, t) => e + t.size, 0)
263
- }, a);
264
- }, z = !1, me = () => {
265
- z || typeof window > "u" || (z = !0, import("./account.js").then((e) => e.onChange(() => {
266
- R().catch(() => {});
267
- })).catch(() => {}));
268
- }, he = /* @__PURE__ */ e({
269
- adopt: () => J,
270
- adoptable: () => Y,
271
- appendFile: () => Ee,
272
- appendFileSync: () => W,
273
- available: () => V,
274
- default: () => Le,
275
- exists: () => Ne,
276
- existsSync: () => G,
277
- flush: () => Fe,
278
- lstatSync: () => _e,
279
- mkdir: () => ke,
280
- mkdirSync: () => ye,
281
- mount: () => K,
282
- onConflict: () => $,
283
- pending: () => X,
284
- pendingDeletes: () => Z,
285
- promises: () => Pe,
286
- pull: () => q,
287
- readFile: () => we,
288
- readFileSync: () => H,
289
- readdir: () => Oe,
290
- readdirSync: () => ve,
291
- remount: () => Ie,
292
- rename: () => Me,
293
- renameSync: () => Ce,
294
- replicating: () => Q,
295
- rm: () => Ae,
296
- rmSync: () => be,
297
- rmdirSync: () => xe,
298
- stat: () => De,
299
- statSync: () => ge,
300
- unlink: () => je,
301
- unlinkSync: () => Se,
302
- writeFile: () => Te,
303
- writeFileSync: () => U
304
- }), B = t(f, { memfs: !0 }), { available: V, readFileSync: H, writeFileSync: U, appendFileSync: W, existsSync: G, statSync: ge, lstatSync: _e, readdirSync: ve, mkdirSync: ye, rmSync: be, rmdirSync: xe, unlinkSync: Se, renameSync: Ce, readFile: we, writeFile: Te, appendFile: Ee, stat: De, readdir: Oe, mkdir: ke, rm: Ae, unlink: je, rename: Me, exists: Ne, promises: Pe, mount: K, flush: Fe, remount: Ie } = B, q = ce, J = F, Y = I, X = D, Z = O, Q = k, $ = N, Le = {
305
- ...B,
306
- pull: q,
307
- adopt: J,
308
- adoptable: Y,
309
- pending: X,
310
- pendingDeletes: Z,
311
- replicating: Q,
312
- onConflict: $
313
- };
314
- //#endregion
315
- export { xe as A, ve as C, Q as D, Ce as E, Te as F, U as I, ge as M, je as N, Ae as O, Se as P, Oe as S, Me as T, Z as _, V as a, we as b, Fe as c, _e as d, ke as f, X as g, $ as h, W as i, De as j, be as k, Le as l, K as m, Y as n, Ne as o, ye as p, Ee as r, G as s, J as t, he as u, Pe as v, Ie as w, H as x, q as y };