@fkn/lib 0.9.52 → 0.9.54
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/{account-generation-BZ_gXQoZ.js → account-generation-CTB1J33G.js} +4 -3
- package/account-generation-DOuApHq5.cjs +1 -0
- package/{account-storage-BT2pPuWs.cjs → account-storage-CL0wLuQw.cjs} +1 -1
- package/{account-storage-DHl6bXdb.d.ts → account-storage-Co9IvkPr.d.ts} +3 -3
- package/{account-storage-C38Ydzh-.js → account-storage-D1RiskV6.js} +2 -2
- package/account.cjs +1 -1
- package/account.d.ts +21 -11
- package/account.js +2 -2
- package/{api-BrqGe-Yz.js → api-BYtMzj8u.js} +43 -63
- package/{api-eOIMGYAJ.d.ts → api-C-VvG5P-.d.ts} +833 -1
- package/api-Csb5b8dE.cjs +3 -0
- package/api.cjs +1 -1
- package/api.d.ts +2 -2
- package/api.js +1 -1
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +2 -2
- package/cloud/fs.js +1 -1
- package/cloud/net.d.ts +1 -1
- package/{cloud-DyXqlXh9.js → cloud-8sJ1Sg8n.js} +3 -3
- package/{cloud-CCMu_LZl.cjs → cloud-CI6WMBPa.cjs} +1 -1
- package/{cloud-DrgnsG8_.d.ts → cloud-S8hQywqV.d.ts} +3 -3
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +2 -2
- package/{contract-De1rQSCD.d.ts → contract-CMQOic3K.d.ts} +34 -4
- package/contract.d.ts +1 -1
- package/dgram.cjs +1 -1
- package/dgram.d.ts +2 -2
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.d.ts +1 -1
- package/dns.js +1 -1
- package/{extension-D-MgH488.cjs → extension-BXI3MVXw.cjs} +1 -1
- package/{extension-Cqd8OFr3.js → extension-BmqjgSIQ.js} +3 -3
- package/extension.cjs +1 -1
- package/extension.js +2 -2
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/{fs-BUf_-umC.cjs → fs-CPU00CI3.cjs} +1 -1
- package/{fs-BZv2djbS.d.ts → fs-DCJAYoYy.d.ts} +1 -1
- package/{fs-BaZ7k_5D.js → fs-ohcMNiu2.js} +2 -2
- package/fs.cjs +1 -1
- package/fs.d.ts +2 -2
- package/fs.js +2 -2
- package/http.d.ts +1 -1
- package/{index-DawD_N1P.d.ts → index-57lTXnoe.d.ts} +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +4 -4
- package/index.js +5 -5
- package/{lib-ERmfLvVp.js → lib-BGAmzIcU.js} +1 -23
- package/{lib-B3BXMegM.cjs → lib-BiQ6cOZ7.cjs} +1 -1
- package/{net-2q-K92j1.d.ts → net-B8YQuB9E.d.ts} +2 -2
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.d.ts +15 -2
- package/packages.js +114 -113
- package/{proxy-CKNx2dKf.cjs → proxy-CL8j00ao.cjs} +1 -1
- package/{proxy-CjxVIiz2.d.ts → proxy-ClDBa5il.d.ts} +2 -2
- package/{proxy-Bwr-0XVF.js → proxy-vAsYHMIa.js} +1 -1
- package/rooms.cjs +1 -1
- package/rooms.d.ts +11 -11
- package/rooms.js +99 -89
- package/storage.cjs +1 -1
- package/storage.d.ts +1 -1
- package/storage.js +3 -3
- package/account-generation-D8wbg2Lb.cjs +0 -1
- package/api-2ecr7axy.cjs +0 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { c as e, l as t, u as n } from "./api-
|
|
1
|
+
import { c as e, l as t, u as n } from "./api-BYtMzj8u.js";
|
|
2
2
|
//#region src/account-generation.ts
|
|
3
3
|
var r = 0, i = /* @__PURE__ */ new Set(), a = 2e3, o = null, s = (e) => {
|
|
4
|
-
e?.switched !== !1
|
|
4
|
+
let t = e?.switched !== !1;
|
|
5
|
+
t && (r += 1, o &&= (clearTimeout(o.timer), null));
|
|
5
6
|
for (let e of [...i]) try {
|
|
6
|
-
e();
|
|
7
|
+
e({ switched: t });
|
|
7
8
|
} catch {}
|
|
8
9
|
}, c = !1, l = 0, u = () => {
|
|
9
10
|
let t = e();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./api-Csb5b8dE.cjs");var t=0,n=new Set,r=2e3,i=null,a=e=>{let r=e?.switched!==!1;r&&(t+=1,i&&=(clearTimeout(i.timer),null));for(let e of[...n])try{e({switched:r})}catch{}},o=!1,s=0,c=()=>{let t=e.c();t&&s!==t.epoch&&(s=t.epoch,Promise.resolve(t.remote.account.onChange(a)).catch(()=>{s===t.epoch&&(s=0)}))},l=()=>{!o&&e.l&&(o=!0,e.u(c))},u=()=>t,d=e=>(n.add(e),l(),()=>{n.delete(e)}),f=e=>{if(e!==t||i?.generation===e)return;let n=setTimeout(()=>{i?.timer===n&&(i=null,t===e&&a({switched:!0}))},r);i={generation:e,timer:n}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-Csb5b8dE.cjs"),n=require("./messages.cjs"),r=require("./account-generation-DOuApHq5.cjs");var i=e.t({StorageAccountChangedError:()=>c,StorageAccountPinUnsupportedError:()=>l,StorageLockedError:()=>a,StorageNotFoundError:()=>o,availability:()=>k,available:()=>w,captureAccount:()=>p,encryption:()=>L,isAccountChanged:()=>u,isInvalidPin:()=>d,isNotFound:()=>s,knownPin:()=>y,list:()=>A,pinFor:()=>b,quota:()=>j,readFile:()=>M,readFileSealed:()=>P,remove:()=>I,unlock:()=>R,writeFile:()=>F}),a=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},o=class extends Error{code=n.STORAGE_NOT_FOUND;constructor(e=`storage: no object at that path`){super(e)}},s=e=>e?.code===n.STORAGE_NOT_FOUND,c=class extends Error{code=n.STORAGE_ACCOUNT_CHANGED;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},l=class extends Error{code=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},u=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),d=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),f=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new a:s(e)?new o(e.message):u(e)?new c:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new l:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new o(e.message):e},p=()=>(r.n(),{generation:r.t()}),m=new Map,h=null,g=e=>typeof e?.accountPin==`function`,_=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return r.t()===e&&m.set(e,t),t});return h={generation:e,pin:n},n.catch(()=>{h?.pin===n&&(h=null)}),n},v=async(e,t)=>{let n=m.get(e.generation);if(n!==void 0)return n;if(e.generation!==r.t())throw new c;let i=await(h?.generation===e.generation?h.pin:_(e.generation,t)).catch(f);if(e.generation!==r.t())throw new c;return i},y=e=>m.get(e.generation),b=async e=>{let n=(await t.o).cloud.fs;if(!g(n))throw new l;return v(e,n)},x=e=>{for(let[t,n]of m)if(n===e)return t},S=e=>e?.pin??p(),C=async(e,n)=>{let i=(await t.o).cloud.fs;if(!g(i))throw new l;let a=`pin`in e?e.pin:await v(e,i);if(!g(i))throw new l;return n(i,{accountPin:a}).catch(t=>{if(u(t)){let t=`generation`in e?e.generation:x(a);t!==void 0&&r.r(t)}return f(t)})},w=()=>t.o.then(e=>e.cloud.fs.available()).catch(()=>!1),T=8e3,E=1e3,D=!1,O=async()=>{let e=(await t.o).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},k=async()=>{let e=D?E:T,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);O().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(D=!0,`unknown`):(D=!1,t)},A=e=>C(S(e),(e,t)=>e.list(t)),j=()=>t.o.then(e=>e.cloud.fs.quota()),M=async(e,t)=>{let n=await C(S(t),(t,n)=>t.readFile(e,n));return new Blob([n])},N=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},P=async(e,t)=>C(S(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:N(i.sealedAt)}}),F=async(e,t,n)=>{let r=S(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await C(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},I=async(e,t)=>{await C(S(t),(t,n)=>t.remove(e,n))},L=()=>t.o.then(e=>e.cloud.fs.encryption()),R=()=>t.o.then(e=>e.cloud.fs.unlock());Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return R}});
|
|
@@ -82,10 +82,10 @@ declare const isNotFound: (error: unknown) => boolean;
|
|
|
82
82
|
*
|
|
83
83
|
* What stays the app's to check is work it started before the notification and resumes after it (an
|
|
84
84
|
* await between reading state and writing it back). Keep a counter that an `account.onChange` handler
|
|
85
|
-
* bumps and compare it synchronously right before the storage call: the
|
|
86
|
-
* synchronous step, so the check and the call are atomic.
|
|
85
|
+
* bumps when `change.switched` is true and compare it synchronously right before the storage call: the
|
|
86
|
+
* pin is captured in that same synchronous step, so the check and the call are atomic.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
88
|
+
* An fkn.app older than 2026-10-02 counts every notification as a switch, so there this can be thrown
|
|
89
89
|
* for a call that would have landed in the same account. Either way the answer is the same: re-read
|
|
90
90
|
* what the app is acting on, then call again.
|
|
91
91
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { o as t } from "./api-
|
|
2
|
+
import { o as t } from "./api-BYtMzj8u.js";
|
|
3
3
|
import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "./messages.js";
|
|
4
|
-
import { n as a, r as o, t as s } from "./account-generation-
|
|
4
|
+
import { n as a, r as o, t as s } from "./account-generation-CTB1J33G.js";
|
|
5
5
|
//#region src/account-storage.ts
|
|
6
6
|
var c = /* @__PURE__ */ e({
|
|
7
7
|
StorageAccountChangedError: () => f,
|
package/account.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-Csb5b8dE.cjs"),n=require("./account-generation-DOuApHq5.cjs");var r=e.t({info:()=>o,login:()=>i,logout:()=>a,onChange:()=>s}),i=async()=>typeof window>`u`?!1:(await t.o).account.login(location.origin).catch(()=>!1),a=async()=>{typeof window<`u`&&await(await t.o).account.logout().catch(()=>{})},o=async()=>{if(typeof window>`u`)return null;let e=await t.o.then(e=>e.account.info()).catch(()=>null);return e?{name:e.name,image:e.image,premium:e.premium,premiumUntil:e.premiumUntil?Date.parse(e.premiumUntil):null}:null},s=async e=>t.l?n.i(e):()=>{};exports.info=o,exports.login=i,exports.logout=a,exports.onChange=s,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
package/account.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { a as AccountChange } from "./contract-CMQOic3K.js";
|
|
1
2
|
declare namespace account_d_exports {
|
|
2
|
-
export { AccountInfo, info, login, logout, onChange };
|
|
3
|
+
export { AccountChange, AccountInfo, info, login, logout, onChange };
|
|
3
4
|
}
|
|
4
5
|
export type AccountInfo = {
|
|
5
6
|
/** the account's display name (a username, not necessarily a real name) */
|
|
@@ -15,16 +16,25 @@ export declare const login: () => Promise<boolean>;
|
|
|
15
16
|
export declare const logout: () => Promise<void>;
|
|
16
17
|
export declare const info: () => Promise<AccountInfo | null>;
|
|
17
18
|
/**
|
|
18
|
-
* Calls `callback` whenever the account this page acts as may have changed
|
|
19
|
-
* sign-out, in this tab or another
|
|
20
|
-
* in a worker bridged with `relayWorker`; resolves to a no-op where there is no FKN transport at all.
|
|
19
|
+
* Calls `callback` whenever the account this page acts as may have changed (a switch, a sign-in or a
|
|
20
|
+
* sign-out, in this tab or another), and when the connection is renewed without one. Works in a window
|
|
21
|
+
* and in a worker bridged with `relayWorker`; resolves to a no-op where there is no FKN transport at all.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* `change.switched` says which. True: this page may now act as another account, or as none, so drop
|
|
24
|
+
* what the old account put in memory (its lists, any open work) and read again; a storage call made
|
|
25
|
+
* before this callback never lands in the new account (it is refused with `StorageAccountChangedError`).
|
|
26
|
+
* It is also true when fkn.app is too old to tell (before 2026-10-02) and when the library moved on its
|
|
27
|
+
* own after a refusal, so treating true as a switch is always safe. False: fkn.app saw the same account.
|
|
28
|
+
* Its connect token was renewed, or an app in this browser signed in or out of FKN on its own, this one
|
|
29
|
+
* included, so read `info()` again to learn whether this page is still signed in. Calls made before it
|
|
30
|
+
* still land. A switch fkn.app could not see, because its document was replaced in between, reaches you
|
|
31
|
+
* as true once a storage call is refused for it.
|
|
32
|
+
*
|
|
33
|
+
* Storage moves to the new account BEFORE any callback runs. Work the app started before a switch and
|
|
34
|
+
* resumes after it is the app's to check: keep a counter this callback bumps when `switched` is true,
|
|
35
|
+
* and compare it synchronously right before the storage call, which captures the account in the same
|
|
36
|
+
* synchronous step, so the check and the call are atomic.
|
|
27
37
|
*/
|
|
28
|
-
export declare const onChange: (callback: () => void) => Promise<() => void>;
|
|
38
|
+
export declare const onChange: (callback: (change: AccountChange) => void) => Promise<() => void>;
|
|
29
39
|
//#endregion
|
|
30
|
-
export { account_d_exports as t };
|
|
40
|
+
export { type AccountChange, account_d_exports as t };
|
package/account.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { l as t, o as n } from "./api-
|
|
3
|
-
import { i as r } from "./account-generation-
|
|
2
|
+
import { l as t, o as n } from "./api-BYtMzj8u.js";
|
|
3
|
+
import { i as r } from "./account-generation-CTB1J33G.js";
|
|
4
4
|
//#region src/account.ts
|
|
5
5
|
var i = /* @__PURE__ */ e({
|
|
6
6
|
info: () => s,
|
|
@@ -161,29 +161,7 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
161
161
|
if (!v) return;
|
|
162
162
|
let t = b(v), n = E(e, t);
|
|
163
163
|
n && (D = e, C(v, n, t), pe(n.hidden));
|
|
164
|
-
}, ye = [
|
|
165
|
-
"fkn.app",
|
|
166
|
-
"fkn.dev",
|
|
167
|
-
"sdbx.app",
|
|
168
|
-
"fkn.cloudflareaccess.com",
|
|
169
|
-
"horionsoftware.com",
|
|
170
|
-
"62e9d4fbf21d90ebd4342e54b4babbd3.r2.cloudflarestorage.com",
|
|
171
|
-
"web-b3z.pages.dev",
|
|
172
|
-
"fkn-console.pages.dev",
|
|
173
|
-
"dev-dms.pages.dev",
|
|
174
|
-
"fkn-www.pages.dev",
|
|
175
|
-
"fkn-homepage.pages.dev",
|
|
176
|
-
"fkn-sandbox.pages.dev",
|
|
177
|
-
"internal-3ar.pages.dev",
|
|
178
|
-
"stub-ben.pages.dev",
|
|
179
|
-
"ripple-3t3.pages.dev",
|
|
180
|
-
"media-player-e3s.pages.dev",
|
|
181
|
-
"youtube-3c4.pages.dev",
|
|
182
|
-
"horionsoftware.pages.dev",
|
|
183
|
-
"container-ckf.pages.dev",
|
|
184
|
-
"stub-plugin.pages.dev",
|
|
185
|
-
"stub.plugins.banou.dev"
|
|
186
|
-
], be = (e) => e.replace(/\.+$/, ""), xe = ["79.127.204.69", "152.233.49.59"], Se = (e) => {
|
|
164
|
+
}, ye = /* @__PURE__ */ "fkn.app,fkn.dev,sdbx.app,horionsoftware.com,webvpn.dev,fknmail.app,clairv.app,fkn.cloudflareaccess.com,me-62e.workers.dev,62e9d4fbf21d90ebd4342e54b4babbd3.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.eu.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.fedramp.r2.cloudflarestorage.com,pub-8a3dc68041874c7e9c9a54bde972605a.r2.dev,pub-3d97d79220b94243812e60b0e742f2c5.r2.dev,pub-f8bd4876cc3c4b4a951715da5958e49c.r2.dev,web-b3z.pages.dev,fkn-console.pages.dev,dev-dms.pages.dev,fkn-www.pages.dev,fkn-homepage.pages.dev,fkn-sandbox.pages.dev,internal-3ar.pages.dev,stub-ben.pages.dev,ripple-3t3.pages.dev,media-player-e3s.pages.dev,youtube-3c4.pages.dev,horionsoftware.pages.dev,container-ckf.pages.dev,stub-plugin.pages.dev,social-3n2.pages.dev,plugins.banou.dev".split(","), k = (e) => e.toLowerCase().replace(/\.+$/, ""), be = ["79.127.204.69", "152.233.49.59"], xe = (e) => {
|
|
187
165
|
let t;
|
|
188
166
|
try {
|
|
189
167
|
t = new URL(`http://${e.includes(":") && !e.startsWith("[") ? `[${e}]` : e}/`).hostname;
|
|
@@ -201,11 +179,13 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
201
179
|
].join(".");
|
|
202
180
|
}
|
|
203
181
|
return /^\d+\.\d+\.\d+\.\d+$/.test(t) ? t : void 0;
|
|
182
|
+
}, Se = (e) => {
|
|
183
|
+
let t = k(e);
|
|
184
|
+
return ye.some((e) => t === e || t.endsWith(`.${e}`));
|
|
204
185
|
}, Ce = (e) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return n !== void 0 && xe.includes(n);
|
|
186
|
+
if (Se(e)) return !0;
|
|
187
|
+
let t = xe(k(e));
|
|
188
|
+
return t !== void 0 && be.includes(t);
|
|
209
189
|
}, we = (e) => {
|
|
210
190
|
let t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, n;
|
|
211
191
|
try {
|
|
@@ -214,14 +194,14 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
214
194
|
return;
|
|
215
195
|
}
|
|
216
196
|
if (Ce(n.hostname)) throw Error(`fetch refuses FKN platform domains (${n.hostname})`);
|
|
217
|
-
},
|
|
197
|
+
}, Te = /* @__PURE__ */ "autoplay.fullscreen.picture-in-picture.encrypted-media.screen-wake-lock.speaker-selection.captured-surface-control.camera.microphone.display-capture.geolocation.midi.usb.serial.hid.bluetooth.gamepad.keyboard-map.xr-spatial-tracking.accelerometer.gyroscope.magnetometer.ambient-light-sensor.compute-pressure.clipboard-read.clipboard-write.storage-access.window-management.local-fonts.idle-detection.web-share.sync-xhr.unload.payment.publickey-credentials-get.publickey-credentials-create.otp-credentials.identity-credentials-get.digital-credentials-get.local-network.local-network-access.loopback-network".split("."), Ee = () => {
|
|
218
198
|
try {
|
|
219
199
|
let e = globalThis.document?.featurePolicy?.features?.();
|
|
220
200
|
return e === void 0 ? void 0 : new Set(e);
|
|
221
201
|
} catch {
|
|
222
202
|
return;
|
|
223
203
|
}
|
|
224
|
-
}, A = (e = !0, t =
|
|
204
|
+
}, A = (e = !0, t = Ee()) => [...Te, ...e ? ["cross-origin-isolated"] : []].filter((e) => t === void 0 || t.has(e)).join("; "), j = "https://fkn.app", M = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, N = typeof globalThis < "u" && globalThis.crossOriginIsolated === !0, P = `${j}/api${N ? "?coi=1" : ""}`, F = "fkn-api-port", De = "fkn-api-port-ack", Oe = 2e3, ke = () => {
|
|
225
205
|
if (!M || typeof window > "u" || window.parent === window) return Promise.resolve(void 0);
|
|
226
206
|
let e;
|
|
227
207
|
try {
|
|
@@ -241,21 +221,21 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
241
221
|
}, a = setTimeout(() => r(void 0), Oe);
|
|
242
222
|
t.port1.addEventListener("message", i), t.port1.start();
|
|
243
223
|
try {
|
|
244
|
-
e.postMessage({ type:
|
|
224
|
+
e.postMessage({ type: F }, j, [t.port2]);
|
|
245
225
|
} catch {
|
|
246
226
|
r(void 0);
|
|
247
227
|
}
|
|
248
228
|
});
|
|
249
|
-
},
|
|
250
|
-
if (
|
|
229
|
+
}, I, Ae = () => {
|
|
230
|
+
if (I || !M) return I;
|
|
251
231
|
let e = M.querySelector(`iframe[src="${P}"]`);
|
|
252
|
-
if (e)
|
|
232
|
+
if (e) I = e;
|
|
253
233
|
else {
|
|
254
234
|
let e = M.createElement("iframe");
|
|
255
|
-
e.setAttribute("allow", A(N)), e.src = P, M.body.appendChild(e),
|
|
235
|
+
e.setAttribute("allow", A(N)), e.src = P, M.body.appendChild(e), I = e;
|
|
256
236
|
}
|
|
257
|
-
return _e(
|
|
258
|
-
},
|
|
237
|
+
return _e(I), I;
|
|
238
|
+
}, L = (async () => {
|
|
259
239
|
if (!M) return;
|
|
260
240
|
let e = await ke();
|
|
261
241
|
if (e) return {
|
|
@@ -346,33 +326,33 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
346
326
|
i = !0, n = void 0, p();
|
|
347
327
|
}
|
|
348
328
|
};
|
|
349
|
-
},
|
|
350
|
-
if (!
|
|
351
|
-
|
|
352
|
-
for (let e of [...
|
|
329
|
+
}, R = !1, z = /* @__PURE__ */ new Set(), B = () => R, Me = () => {
|
|
330
|
+
if (!R) {
|
|
331
|
+
R = !0;
|
|
332
|
+
for (let e of [...z]) try {
|
|
353
333
|
e();
|
|
354
334
|
} catch {}
|
|
355
|
-
|
|
335
|
+
z.clear();
|
|
356
336
|
}
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
}, Ne = typeof window < "u" || typeof self < "u",
|
|
360
|
-
if (typeof window < "u") return
|
|
337
|
+
}, V = (e) => {
|
|
338
|
+
R ? e() : z.add(e);
|
|
339
|
+
}, Ne = typeof window < "u" || typeof self < "u", H = async () => {
|
|
340
|
+
if (typeof window < "u") return L;
|
|
361
341
|
if (typeof self < "u") return {
|
|
362
342
|
receive: self,
|
|
363
343
|
emit: self
|
|
364
344
|
};
|
|
365
|
-
},
|
|
366
|
-
let e = await
|
|
345
|
+
}, U = "fkn-api", Pe = "fkn-api-window", Fe = { async *[Symbol.asyncIterator]() {
|
|
346
|
+
let e = await H();
|
|
367
347
|
if (!e) {
|
|
368
348
|
await new Promise(() => {});
|
|
369
349
|
return;
|
|
370
350
|
}
|
|
371
|
-
if (!
|
|
351
|
+
if (!B()) {
|
|
372
352
|
let n = new AbortController();
|
|
373
|
-
|
|
353
|
+
V(() => n.abort());
|
|
374
354
|
for await (let r of t({}, {
|
|
375
|
-
key:
|
|
355
|
+
key: U,
|
|
376
356
|
transport: e,
|
|
377
357
|
unregisterSignal: n.signal
|
|
378
358
|
})) {
|
|
@@ -384,15 +364,15 @@ var n = 1e4, r = 16, i = (e) => {
|
|
|
384
364
|
key: Pe,
|
|
385
365
|
transport: e
|
|
386
366
|
});
|
|
387
|
-
} },
|
|
367
|
+
} }, W = !1, G = H().then((t) => new Promise((n) => {
|
|
388
368
|
if (!t) return;
|
|
389
369
|
let { receive: r } = t, i = (t) => {
|
|
390
|
-
e(t.data,
|
|
370
|
+
e(t.data, U) && (r.removeEventListener("message", i), W = !0, n());
|
|
391
371
|
};
|
|
392
372
|
r.addEventListener("message", i);
|
|
393
|
-
})),
|
|
394
|
-
|
|
395
|
-
var
|
|
373
|
+
})), K = je(Fe, { boundRetired: (e) => Promise.race([e, G.then(() => Q(e, () => new Z()))]) });
|
|
374
|
+
V(() => K.retire());
|
|
375
|
+
var q = Promise.race([K.first, new Promise((e) => V(e))]).then(() => K.facade), J = 8e3, Ie = 1e3, Y = !1, X = class extends Error {
|
|
396
376
|
constructor(e, t) {
|
|
397
377
|
super(`@fkn/lib: no broker connection within ${t}ms, so ${e} could not be requested`), this.name = "BrokerUnreachableError";
|
|
398
378
|
}
|
|
@@ -401,20 +381,20 @@ var K = Promise.race([G.first, new Promise((e) => B(e))]).then(() => G.facade),
|
|
|
401
381
|
super("FKN @fkn/lib: this page relays its FKN channel to a worker, and the FKN page it reached predates a channel of the page's own; reload"), this.name = "OwnChannelUnavailableError";
|
|
402
382
|
}
|
|
403
383
|
}, Q = (e, t) => {
|
|
404
|
-
let n = Y ?
|
|
384
|
+
let n = Y ? Ie : J;
|
|
405
385
|
return Promise.race([e, new Promise((e, r) => setTimeout(() => {
|
|
406
386
|
Y = !0, r(t(n));
|
|
407
387
|
}, n))]);
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
let e = setTimeout(() => console.error(new Z()),
|
|
412
|
-
|
|
388
|
+
}, Le = (e) => B() ? Q(K.routable().then(() => K.facade), (t) => W ? new Z() : new X(e, t)) : Q(q, (t) => new X(e, t));
|
|
389
|
+
V(() => {
|
|
390
|
+
G.then(() => {
|
|
391
|
+
let e = setTimeout(() => console.error(new Z()), J);
|
|
392
|
+
K.routable().then(() => clearTimeout(e));
|
|
413
393
|
});
|
|
414
394
|
});
|
|
415
|
-
var $ =
|
|
395
|
+
var $ = K.onEpoch, Re = K.current, ze = K.lastCall, Be = K.inFlight;
|
|
416
396
|
$((e) => {
|
|
417
397
|
me() && e.overlay.setHost(ve, { exactClips: p() }).catch(() => {});
|
|
418
398
|
});
|
|
419
399
|
//#endregion
|
|
420
|
-
export {
|
|
400
|
+
export { ze as a, Re as c, Me as d, L as f, Be as i, Ne as l, A as m, X as n, q as o, we as p, Z as r, Le as s, J as t, $ as u };
|