@fkn/lib 0.9.53 → 0.9.55

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 (75) hide show
  1. package/{account-generation-BgiEc3fw.js → account-generation-CTB1J33G.js} +4 -3
  2. package/account-generation-DOuApHq5.cjs +1 -0
  3. package/{account-storage-IAVrRXTF.cjs → account-storage-CL0wLuQw.cjs} +1 -1
  4. package/{account-storage-DHl6bXdb.d.ts → account-storage-Co9IvkPr.d.ts} +3 -3
  5. package/{account-storage-DptsMWKl.js → account-storage-D1RiskV6.js} +2 -2
  6. package/account.cjs +1 -1
  7. package/account.d.ts +21 -11
  8. package/account.js +2 -2
  9. package/{api-mHRuM_Sd.d.ts → api-BSpQkgnM.d.ts} +1198 -30
  10. package/{api-CX9w35R2.js → api-BYtMzj8u.js} +1 -1
  11. package/{api-6wTec7WK.cjs → api-Csb5b8dE.cjs} +1 -1
  12. package/api.cjs +1 -1
  13. package/api.d.ts +2 -2
  14. package/api.js +1 -1
  15. package/cloud/dns.d.ts +1 -1
  16. package/cloud/fetch.cjs +1 -1
  17. package/cloud/fetch.d.ts +1 -1
  18. package/cloud/fetch.js +1 -1
  19. package/cloud/fs/promises.d.ts +1 -1
  20. package/cloud/fs.cjs +1 -1
  21. package/cloud/fs.d.ts +2 -2
  22. package/cloud/fs.js +1 -1
  23. package/cloud/net.d.ts +1 -1
  24. package/{cloud-CMEnCSBw.js → cloud-8sJ1Sg8n.js} +3 -3
  25. package/{cloud-Dykm74YZ.d.ts → cloud-BslRIoKs.d.ts} +3 -3
  26. package/{cloud-kg1hOpPJ.cjs → cloud-CI6WMBPa.cjs} +1 -1
  27. package/cloud.cjs +1 -1
  28. package/cloud.d.ts +4 -4
  29. package/cloud.js +2 -2
  30. package/{contract-BN0cD-Oq.d.ts → contract-DFycgFJK.d.ts} +160 -8
  31. package/contract.d.ts +2 -2
  32. package/dgram.cjs +1 -1
  33. package/dgram.d.ts +2 -2
  34. package/dgram.js +1 -1
  35. package/dns.cjs +1 -1
  36. package/dns.d.ts +1 -1
  37. package/dns.js +1 -1
  38. package/{extension-BdAR-wQ0.cjs → extension-BXI3MVXw.cjs} +1 -1
  39. package/{extension-DiyykwoW.js → extension-BmqjgSIQ.js} +3 -3
  40. package/extension.cjs +1 -1
  41. package/extension.js +2 -2
  42. package/fs/promises.cjs +1 -1
  43. package/fs/promises.d.ts +1 -1
  44. package/fs/promises.js +1 -1
  45. package/{fs-CPsnX6ti.cjs → fs-CPU00CI3.cjs} +1 -1
  46. package/{fs-BZv2djbS.d.ts → fs-DCJAYoYy.d.ts} +1 -1
  47. package/{fs-Cd1HK3C3.js → fs-ohcMNiu2.js} +2 -2
  48. package/fs.cjs +1 -1
  49. package/fs.d.ts +2 -2
  50. package/fs.js +2 -2
  51. package/http.d.ts +1 -1
  52. package/{index-DawD_N1P.d.ts → index-57lTXnoe.d.ts} +1 -1
  53. package/index.cjs +1 -1
  54. package/index.d.ts +4 -4
  55. package/index.js +5 -5
  56. package/{lib-C5N2rmbj.js → lib-BGAmzIcU.js} +1 -1
  57. package/{lib-C0xyv8BQ.cjs → lib-BiQ6cOZ7.cjs} +1 -1
  58. package/{net-Dq1KyRP0.d.ts → net-eEjhJ0AE.d.ts} +2 -2
  59. package/net.cjs +1 -1
  60. package/net.d.ts +1 -1
  61. package/net.js +1 -1
  62. package/package.json +1 -1
  63. package/packages.cjs +1 -1
  64. package/packages.d.ts +15 -2
  65. package/packages.js +114 -113
  66. package/{proxy-Cer0Iarp.d.ts → proxy-8hIHeEHD.d.ts} +2 -2
  67. package/{proxy-DhalpZoN.cjs → proxy-CL8j00ao.cjs} +1 -1
  68. package/{proxy-v_Z5aPh2.js → proxy-vAsYHMIa.js} +1 -1
  69. package/rooms.cjs +1 -1
  70. package/rooms.d.ts +43 -9
  71. package/rooms.js +167 -94
  72. package/storage.cjs +1 -1
  73. package/storage.d.ts +1 -1
  74. package/storage.js +3 -3
  75. package/account-generation-C5rMCyt1.cjs +0 -1
@@ -1,9 +1,10 @@
1
- import { c as e, l as t, u as n } from "./api-CX9w35R2.js";
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 && (r += 1, o &&= (clearTimeout(o.timer), null));
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-6wTec7WK.cjs"),n=require("./messages.cjs"),r=require("./account-generation-C5rMCyt1.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}});
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 pin is captured in that same
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
- * The notification also fires when the connection is renewed without a switch, so this can be thrown
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-CX9w35R2.js";
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-BgiEc3fw.js";
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-6wTec7WK.cjs"),n=require("./account-generation-C5rMCyt1.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}});
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-DFycgFJK.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: a switch, a sign-in or a
19
- * sign-out, in this tab or another. It carries no data, so re-read what you need. Works in a window and
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
- * Storage moves to the new account BEFORE any callback runs. Calls made before this page learned of a
23
- * switch never land in the new account (they are refused with `StorageAccountChangedError`). Work the
24
- * app started before the notification and resumes after it is the app's to check: keep a counter this
25
- * callback bumps, and compare it synchronously right before the storage call, which captures the
26
- * account in the same synchronous step, so the check and the call are atomic.
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-CX9w35R2.js";
3
- import { i as r } from "./account-generation-BgiEc3fw.js";
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,