@fkn/lib 0.9.25 → 0.9.27

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 (50) hide show
  1. package/{api-CesI0aMl.d.ts → api-Dv7Fy_CF.d.ts} +9 -1
  2. package/api.d.ts +2 -2
  3. package/cloud/dns.d.ts +1 -1
  4. package/cloud/fetch.d.ts +1 -1
  5. package/cloud/fs/promises.d.ts +1 -1
  6. package/cloud/fs.cjs +1 -1
  7. package/cloud/fs.d.ts +3 -2
  8. package/cloud/fs.js +20 -19
  9. package/cloud/net.d.ts +1 -1
  10. package/{cloud-B7pI3pp1.d.ts → cloud-ZRqclRzO.d.ts} +3 -3
  11. package/cloud.d.ts +4 -4
  12. package/connect-button-BpXDs7tw.cjs +1 -0
  13. package/connect-button-Cp0NS95-.d.ts +4 -0
  14. package/connect-button-DtsN3X1J.js +4 -0
  15. package/{contract-D6ksmIm6.d.ts → contract-BergoFCw.d.ts} +12 -0
  16. package/contract.d.ts +1 -1
  17. package/dgram.d.ts +2 -2
  18. package/dns.d.ts +1 -1
  19. package/fs/promises.cjs +1 -1
  20. package/fs/promises.d.ts +1 -1
  21. package/fs/promises.js +1 -1
  22. package/fs-CBVaShOR.d.ts +27 -0
  23. package/fs-Cvx2NT6o.js +360 -0
  24. package/fs-J5h3i5eg.cjs +1 -0
  25. package/fs.cjs +1 -1
  26. package/fs.d.ts +3 -2
  27. package/fs.js +2 -2
  28. package/http.d.ts +1 -1
  29. package/{index-CGJTVju4.d.ts → index-Cg6y_FTi.d.ts} +22 -6
  30. package/index.cjs +1 -1
  31. package/index.d.ts +4 -4
  32. package/index.js +2 -2
  33. package/{net-DAOcF3Eb.d.ts → net-C9Me0zVw.d.ts} +2 -2
  34. package/net.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/packages.d.ts +1 -1
  37. package/{proxy-BubvP9sg.d.ts → proxy-DkuZfeI4.d.ts} +2 -2
  38. package/react.cjs +1 -1
  39. package/react.d.ts +1 -1
  40. package/react.js +1 -1
  41. package/{storage-BjGr_vC4.js → storage-BL8vxHlW.js} +23 -7
  42. package/storage-Dr5F1jil.cjs +1 -0
  43. package/storage-WZEvw3KN.d.ts +69 -0
  44. package/connect-button-BBEjXzB3.cjs +0 -1
  45. package/connect-button-CN4ZJwT6.js +0 -7
  46. package/connect-button-DdoEikEd.d.ts +0 -4
  47. package/fs-DYP7utdw.cjs +0 -1
  48. package/fs-DlGE0ZNu.d.ts +0 -73
  49. package/fs-d2ANVBkm.js +0 -347
  50. package/storage-DLB4ciMf.cjs +0 -1
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./busy-Dv8wzE5M.cjs"),n=require("./node-fs-DZPGCYWg.cjs"),r=require("./storage-Dr5F1jil.cjs"),i=require("./opfs-CXMESVLc.cjs");var a=e.t({adopt:()=>I,adoptable:()=>L,available:()=>u,list:()=>re,onConflict:()=>le,pending:()=>C,pendingDeletes:()=>w,pull:()=>ce,readFile:()=>ie,readFileSealed:()=>ae,remove:()=>se,replicating:()=>T,writeFile:()=>oe}),o,s=async()=>await(o??=i.t().catch(()=>!1))?!0:(o=void 0,!1),c=()=>r.r().catch(()=>`unknown`),l=async()=>await c()===`connected`,u=async()=>await s()||await l(),d=`fkn:fs:pending`,f=`fkn:fs:pending-delete`,p=`fkn:fs:adopt-declined`,m=!0,h=new Map,g=e=>{try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return Array.isArray(n)?Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,null])):n&&typeof n==`object`?n:{}}catch{return{}}},_=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},v=()=>g(d),y=(e,t)=>{let n=v();e in n||(n[e]=t===void 0?h.get(e)??null:t,_(d,n))},b=e=>{let t=v();e in t&&(delete t[e],_(d,t),D()||(k=O))},x=()=>g(f),ee=e=>{let t=x();e in t||(t[e]=h.get(e)??null,_(f,t))},S=e=>{let t=x();e in t&&(delete t[e],_(f,t),D()||(k=O))},C=()=>Object.keys(v()),w=()=>Object.keys(x()),T=()=>m,E=null;t.r(`storage replication`,()=>E!==null||R!==null);var D=()=>Object.keys(v()).length>0||Object.keys(x()).length>0,O=6e4,te=6e5,k=O,A=null,j=()=>{A||typeof window>`u`||!D()||(A=setTimeout(()=>{A=null,M()},k),k=Math.min(k*2,te))},M=()=>{E||!D()||(E=F(!1).then(e=>{if(!D()){k=O;return}e.failed.length&&j()}).catch(()=>{j()}).finally(()=>{E=null}))},ne=null,N=()=>ne??=Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.apiPromise),re=async()=>{U();let e=await c(),t=e===`connected`,[n,a]=await Promise.all([s().then(e=>e?i.n():[]).catch(()=>[]),t?r.o().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:e===`disconnected`,entries:[]})]);e!==`unknown`&&(m=a.ok),a.ok&&e!==`unknown`&&(h=new Map(a.entries.map(e=>[e.path,e.updatedAt])));let o=new Map,l=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},u=e=>{let t=o.get(e.path);(!t||l(e)>=l(t))&&o.set(e.path,e)};for(let e of n)u(e);for(let e of a.entries)u(e);return a.ok&&t&&(me(n,a.entries).catch(()=>{}),D()?M():z({local:n,remote:a.entries}).catch(()=>{})),[...o.values()]},ie=async e=>{if(await s())try{return await i.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await r.c(e);return await s()&&i.o(e,t).catch(()=>{}),t},ae=async e=>{if(await s())try{let t=await i.i(e);return{data:new Uint8Array(await t.arrayBuffer()),sealedAt:null}}catch(e){if(e?.name!==`NotFoundError`)throw e}return r.l(e)},oe=async(e,t,n)=>{let a=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);if(await s()){await i.o(e,a,n),U();let t=h.get(e)??null,o=await c();if(o===`disconnected`)return;if(o===`unknown`||!m){y(e,t),j();return}r.p(e,a,n).then(()=>b(e)).catch(n=>{y(e,t),j(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let o=await c();if(o===`connected`)return r.p(e,a,n);throw Error(o===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},se=async e=>{U();let t=[];await s()&&t.push(i.a(e).catch(()=>{}));let n=await c();if(n===`connected`?t.push(r.u(e).then(()=>S(e)).catch(t=>{ee(e),j(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):n===`unknown`&&t.length&&h.has(e)&&(ee(e),j()),!t.length)throw Error(n===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);b(e),await Promise.all(t)},ce=async e=>{let t=await r.c(e);return await s()&&await i.o(e,t),t},P=null,le=e=>(P=e,()=>{P===e&&(P=null)}),ue=async e=>{let t=await(await N()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null);return t===`local`?e.readLocal():t===`cloud`?e.readCloud():null},de=async e=>{if(P)try{return await P(e)}catch{return null}return ue(e)},F=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},n=await c();if(n===`unknown`)throw Error(`fs: cloud unreachable`);if(n!==`connected`)throw Error(`fs: this needs a signed-in account`);let a=await s(),[o,l]=await Promise.all([a?i.n():Promise.resolve([]),r.o()]),u=new Map(l.map(e=>[e.path,e])),d=v();if(a)for(let e of Object.keys(d))o.some(t=>t.path===e)||b(e);for(let[e,n]of Object.entries(x())){let i=u.get(e);if(!i){S(e);continue}if(o.some(t=>t.path===e)){S(e);continue}if(i.updatedAt!==n){S(e);continue}try{await r.u(e),S(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let n of o){let a=u.get(n.path),o=n.path in d;if(!o&&(a||!e)){a&&t.kept.push(n.path);continue}if(o&&a&&a.updatedAt!==d[n.path]){let e=null,o=null,s=await de({path:n.path,local:{size:n.size,updatedAt:n.updatedAt},cloud:{size:a.size,updatedAt:a.updatedAt},readLocal:()=>e??=i.i(n.path),readCloud:()=>o??=r.c(n.path)});if(s==null){t.unresolved.push(n.path);continue}try{let a=e!==null&&s===await e,c=o!==null&&s===await o;c||await r.p(n.path,s,n.contentType?{contentType:n.contentType}:void 0),a||await i.o(n.path,s),b(n.path),t.resolved.push({path:n.path,choice:a?`local`:c?`cloud`:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await i.i(n.path);await r.p(n.path,e,n.contentType?{contentType:n.contentType}:void 0),b(n.path),t.uploaded.push(n.path)}catch(e){if(y(n.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}}return t},I=async()=>{for(;E;)await E;let e=F(!0);E=e.then(()=>{},()=>{});try{return await e}finally{E=null}},L=async()=>{if(!await l()||!await s())return{paths:[],bytes:0};let[e,t]=await Promise.all([i.n(),r.o()]),n=new Set(t.map(e=>e.path)),a=e.filter(e=>!n.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},fe=()=>new Set(Object.keys(g(p))),pe=e=>{let t=g(p);for(let n of e)t[n]=null;_(p,t)},R=null,z=e=>R||(R=(async()=>{if(!await l())return;let t=e??(await s()?{local:await i.n(),remote:await r.o()}:null);if(!t)return;let n=new Set(t.remote.map(e=>e.path)),a=fe(),o=t.local.filter(e=>!n.has(e.path)&&!a.has(e.path));if(!o.length)return;let c=await N(),u=o.reduce((e,t)=>e+t.size,0);if(!await c.cloud.fs.promptAdopt({files:o.length,bytes:u}).catch(()=>!1)){pe(o.map(e=>e.path));return}await I()})().catch(()=>{}).finally(()=>{R=null}),R),B=null,V=!1,me=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await N(),a=async()=>{await I().catch(()=>{});let e=await L().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})},o={files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)};B=()=>{i.cloud.fs.setAdoptSource(o,a).catch(()=>{})},V||(V=!0,Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.onApiEpoch((e,t)=>{t>1&&B?.()})).catch(()=>{})),await i.cloud.fs.setAdoptSource(o,a)},H=!1,U=()=>{H||typeof window>`u`||(H=!0,window.addEventListener(`online`,()=>{M()}),Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{z().catch(()=>{}),M()})).catch(()=>{}))},he=e.t({adopt:()=>q,adoptable:()=>J,appendFile:()=>je,appendFileSync:()=>be,available:()=>_e,default:()=>$,exists:()=>Re,existsSync:()=>xe,flush:()=>Ve,lstatSync:()=>Ce,mkdir:()=>Pe,mkdirSync:()=>we,mount:()=>Be,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>ze,pull:()=>G,readFile:()=>ke,readFileSealed:()=>K,readFileSync:()=>ve,readdir:()=>Ne,readdirSync:()=>W,remount:()=>He,rename:()=>Le,renameSync:()=>Oe,replicating:()=>Z,rm:()=>Fe,rmSync:()=>Te,rmdirSync:()=>Ee,stat:()=>Me,statSync:()=>Se,unlink:()=>Ie,unlinkSync:()=>De,writeFile:()=>Ae,writeFileSync:()=>ye}),ge=n.t(a,{memfs:!0}),{available:_e,readFileSync:ve,writeFileSync:ye,appendFileSync:be,existsSync:xe,statSync:Se,lstatSync:Ce,readdirSync:W,mkdirSync:we,rmSync:Te,rmdirSync:Ee,unlinkSync:De,renameSync:Oe,readFile:ke,writeFile:Ae,appendFile:je,stat:Me,readdir:Ne,mkdir:Pe,rm:Fe,unlink:Ie,rename:Le,exists:Re,promises:ze,mount:Be,flush:Ve,remount:He}=ge,G=ce,K=ae,q=I,J=L,Y=C,X=w,Z=T,Q=le,$={...ge,pull:G,readFileSealed:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return G}});
package/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-DYP7utdw.cjs");exports.adopt=e.t,exports.adoptable=e.n,exports.appendFile=e.r,exports.appendFileSync=e.i,exports.available=e.a,exports.default=e.l,exports.exists=e.o,exports.existsSync=e.s,exports.flush=e.c,exports.lstatSync=e.d,exports.mkdir=e.f,exports.mkdirSync=e.p,exports.mount=e.m,exports.onConflict=e.h,exports.pending=e.g,exports.pendingDeletes=e._,exports.promises=e.v,exports.pull=e.y,exports.readFile=e.b,exports.readFileSync=e.x,exports.readdir=e.S,exports.readdirSync=e.C,exports.remount=e.w,exports.rename=e.T,exports.renameSync=e.E,exports.replicating=e.D,exports.rm=e.O,exports.rmSync=e.k,exports.rmdirSync=e.A,exports.stat=e.j,exports.statSync=e.M,exports.unlink=e.N,exports.unlinkSync=e.P,exports.writeFile=e.F,exports.writeFileSync=e.I;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-J5h3i5eg.cjs");exports.adopt=e.t,exports.adoptable=e.n,exports.appendFile=e.r,exports.appendFileSync=e.i,exports.available=e.a,exports.default=e.l,exports.exists=e.o,exports.existsSync=e.s,exports.flush=e.c,exports.lstatSync=e.d,exports.mkdir=e.f,exports.mkdirSync=e.p,exports.mount=e.m,exports.onConflict=e.h,exports.pending=e.g,exports.pendingDeletes=e._,exports.promises=e.v,exports.pull=e.y,exports.readFile=e.b,exports.readFileSealed=e.x,exports.readFileSync=e.S,exports.readdir=e.C,exports.readdirSync=e.w,exports.remount=e.T,exports.rename=e.E,exports.renameSync=e.D,exports.replicating=e.O,exports.rm=e.k,exports.rmSync=e.A,exports.rmdirSync=e.j,exports.stat=e.M,exports.statSync=e.N,exports.unlink=e.P,exports.unlinkSync=e.F,exports.writeFile=e.I,exports.writeFileSync=e.L;
package/fs.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { i as Stats } from "./index-BQgZVQl7.js";
2
- import { A as rmdirSync, B as ConflictSide, C as readdirSync, D as replicating, E as renameSync, F as writeFile, I as writeFileSync, L as AdoptSummary, M as statSync, N as unlink, O as rm, P as unlinkSync, R as ConflictChoice, S as readdir, T as rename, V as FileConflict, _ as pendingDeletes, a as appendFileSync, b as readFile, c as existsSync, d as lstatSync, f as mkdir, g as pending, h as onConflict, i as appendFile, j as stat, k as rmSync, l as flush, m as mount, n as adopt, o as available, p as mkdirSync, r as adoptable, s as exists, t as _default, v as promises, w as remount, x as readFileSync, y as pull, z as ConflictResolver } from "./index-CGJTVju4.js";
3
- export { type AdoptSummary, type ConflictChoice, type ConflictResolver, type ConflictSide, type FileConflict, type Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
2
+ import { A as rmSync, B as ConflictResolver, C as readdir, D as renameSync, E as rename, F as unlinkSync, H as FileConflict, I as writeFile, L as writeFileSync, M as stat, N as statSync, O as replicating, P as unlink, R as AdoptSummary, S as readFileSync, T as remount, V as ConflictSide, _ as pendingDeletes, a as appendFileSync, b as readFile, c as existsSync, d as lstatSync, f as mkdir, g as pending, h as onConflict, i as appendFile, j as rmdirSync, k as rm, l as flush, m as mount, n as adopt, o as available, p as mkdirSync, r as adoptable, s as exists, t as _default, v as promises, w as readdirSync, x as readFileSealed, y as pull, z as ConflictResolution } from "./index-Cg6y_FTi.js";
3
+ import { r as SealedRead } from "./storage-WZEvw3KN.js";
4
+ export { type AdoptSummary, type ConflictResolution, type ConflictResolver, type ConflictSide, type FileConflict, type SealedRead, type Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSealed, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
package/fs.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, v as j, w as M, x as N, y as P } from "./fs-d2ANVBkm.js";
2
- export { A as adopt, T as adoptable, O as appendFile, b as appendFileSync, p as available, C as default, E as exists, k as existsSync, h as flush, g as lstatSync, _ as mkdir, D as mkdirSync, w as mount, y as onConflict, v as pending, f as pendingDeletes, j as promises, P as pull, m as readFile, N as readFileSync, u as readdir, t as readdirSync, M as remount, d as rename, r as renameSync, n as replicating, c as rm, S as rmSync, e as rmdirSync, x as stat, o as statSync, s as unlink, l as unlinkSync, i as writeFile, a as writeFileSync };
1
+ import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, S as d, T as f, _ as p, a as m, b as h, c as g, d as _, f as v, g as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, v as M, w as N, x as P, y as F } from "./fs-Cvx2NT6o.js";
2
+ export { j as adopt, E as adoptable, k as appendFile, x as appendFileSync, m as available, w as default, D as exists, A as existsSync, g as flush, _ as lstatSync, v as mkdir, O as mkdirSync, T as mount, b as onConflict, y as pending, p as pendingDeletes, M as promises, F as pull, h as readFile, P as readFileSealed, d as readFileSync, t as readdir, N as readdirSync, f as remount, r as rename, n as renameSync, l as replicating, C as rm, e as rmSync, S as rmdirSync, s as stat, c as statSync, u as unlink, i as unlinkSync, a as writeFile, o as writeFileSync };
package/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as Socket, t as Server$1 } from "./net-DAOcF3Eb.js";
1
+ import { n as Socket, t as Server$1 } from "./net-C9Me0zVw.js";
2
2
  import { Buffer } from "buffer";
3
3
  import { Stream } from "stream";
4
4
  import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
@@ -1,4 +1,5 @@
1
1
  import { a as WriteData$1, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-BQgZVQl7.js";
2
+ import { r as SealedRead } from "./storage-WZEvw3KN.js";
2
3
  //#region src/fs/types.d.ts
3
4
  type WriteData = Blob | ArrayBuffer | Uint8Array | string;
4
5
  //#endregion
@@ -6,6 +7,7 @@ type WriteData = Blob | ArrayBuffer | Uint8Array | string;
6
7
  declare const pending$1: () => string[];
7
8
  declare const pendingDeletes$1: () => string[];
8
9
  declare const replicating$1: () => boolean;
10
+ declare const readFileSealed$1: (path: string) => Promise<SealedRead>;
9
11
  declare const pull$1: (path: string) => Promise<Blob>;
10
12
  type AdoptSummary = {
11
13
  uploaded: string[];
@@ -32,10 +34,22 @@ type FileConflict = {
32
34
  readLocal: () => Promise<Blob>;
33
35
  readCloud: () => Promise<Blob>;
34
36
  };
35
- type ConflictChoice = 'local' | 'cloud' | {
36
- merged: WriteData;
37
- } | null;
38
- type ConflictResolver = (conflict: FileConflict) => Promise<ConflictChoice> | ConflictChoice;
37
+ /**
38
+ * What should be at that path. Return one side's bytes, or anything else as a merge; null leaves the
39
+ * file alone and the summary reports it unresolved.
40
+ *
41
+ * There is no vocabulary to learn: whatever comes back is what wins. Returning the very Blob that
42
+ * `readLocal()` or `readCloud()` handed you is recognised by identity, so picking a side costs one
43
+ * write rather than two.
44
+ *
45
+ * That identity is sound only because the resolver runs in THIS realm: the reads are memoized here,
46
+ * so the object the app holds is the object compared. A value that crosses osra arrives as a
47
+ * different object with equal content, in both directions, which `tests/osra-identity.browser.test.ts`
48
+ * pins against a real channel. So a resolver whose answer ever crossed a realm would simply read as a
49
+ * merge: one redundant write, never a wrong file.
50
+ */
51
+ type ConflictResolution = WriteData | null;
52
+ type ConflictResolver = (conflict: FileConflict) => Promise<ConflictResolution> | ConflictResolution;
39
53
  declare const onConflict$1: (next: ConflictResolver) => (() => void);
40
54
  declare const adopt$1: () => Promise<AdoptSummary>;
41
55
  declare const adoptable$1: () => Promise<{
@@ -43,7 +57,7 @@ declare const adoptable$1: () => Promise<{
43
57
  bytes: number;
44
58
  }>;
45
59
  declare namespace index_d_exports {
46
- export { AdoptSummary, ConflictChoice, ConflictResolver, ConflictSide, FileConflict, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
60
+ export { AdoptSummary, ConflictResolution, ConflictResolver, ConflictSide, FileConflict, SealedRead, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSealed, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
47
61
  }
48
62
  declare const available: () => Promise<boolean>, readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string, writeFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void, appendFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void, existsSync: (path: import("node:fs").PathLike) => boolean, statSync: (path: import("node:fs").PathLike) => Stats, lstatSync: (path: import("node:fs").PathLike) => Stats, readdirSync: (path: import("node:fs").PathLike) => string[], mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void, rmSync: (path: import("node:fs").PathLike, options?: {
49
63
  recursive?: boolean;
@@ -73,6 +87,7 @@ declare const available: () => Promise<boolean>, readFileSync: (path: import("no
73
87
  access: (path: import("node:fs").PathLike) => Promise<void>;
74
88
  }, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
75
89
  declare const pull: typeof pull$1;
90
+ declare const readFileSealed: typeof readFileSealed$1;
76
91
  declare const adopt: typeof adopt$1;
77
92
  declare const adoptable: typeof adoptable$1;
78
93
  declare const pending: typeof pending$1;
@@ -134,6 +149,7 @@ declare const _default: {
134
149
  flush: () => Promise<void>;
135
150
  remount: () => Promise<void>;
136
151
  pull: typeof pull$1;
152
+ readFileSealed: typeof readFileSealed$1;
137
153
  adopt: typeof adopt$1;
138
154
  adoptable: typeof adoptable$1;
139
155
  pending: typeof pending$1;
@@ -142,4 +158,4 @@ declare const _default: {
142
158
  onConflict: typeof onConflict$1;
143
159
  };
144
160
  //#endregion
145
- export { rmdirSync as A, ConflictSide as B, readdirSync as C, replicating as D, renameSync as E, writeFile as F, writeFileSync as I, AdoptSummary as L, statSync as M, unlink as N, rm as O, unlinkSync as P, ConflictChoice as R, readdir as S, rename as T, FileConflict as V, pendingDeletes as _, appendFileSync as a, readFile as b, existsSync as c, lstatSync as d, mkdir as f, pending as g, onConflict as h, appendFile as i, stat as j, rmSync as k, flush as l, mount as m, adopt as n, available as o, mkdirSync as p, adoptable as r, exists as s, _default as t, index_d_exports as u, promises as v, remount as w, readFileSync as x, pull as y, ConflictResolver as z };
161
+ export { rmSync as A, ConflictResolver as B, readdir as C, renameSync as D, rename as E, unlinkSync as F, FileConflict as H, writeFile as I, writeFileSync as L, stat as M, statSync as N, replicating as O, unlink as P, AdoptSummary as R, readFileSync as S, remount as T, ConflictSide as V, pendingDeletes as _, appendFileSync as a, readFile as b, existsSync as c, lstatSync as d, mkdir as f, pending as g, onConflict as h, appendFile as i, rmdirSync as j, rm as k, flush as l, mount as m, adopt as n, available as o, mkdirSync as p, adoptable as r, exists as s, _default as t, index_d_exports as u, promises as v, readdirSync as w, readFileSealed as x, pull as y, ConflictResolution as z };
package/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-DLM2M3_i.cjs"),n=require("./api-BCJO3EWi.cjs"),r=require("./busy-Dv8wzE5M.cjs"),i=require("./cloud-B2ZG-0MF.cjs"),a=require("./dns.cjs"),o=require("./net.cjs"),s=require("./dgram.cjs"),c=require("./http.cjs"),l=require("./extension-DBazc3ff.cjs"),u=require("./desktop.cjs"),d=require("./fs-DYP7utdw.cjs"),f=require("./opfs.cjs"),p=require("./packages.cjs"),m=require("./account.cjs"),h=require("./connect-button-BBEjXzB3.cjs");let g=require("osra");var _=1e4,v=150,y=()=>new Promise(e=>{if(t.F())return e(!0);let n,r=setTimeout(()=>i(t.F()),_),i=t=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),e(t)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(t.F()),v)},o=new MutationObserver(()=>{t.F()&&i(!0)}),s=()=>{document.readyState===`complete`&&!t.F()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),b=async e=>l.r()||e.lockdown||!i.a()||await y()?t.r(e):i.i(e),x=`https://fkn.app`,S=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let i=await n.u;if(!i)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);let a=r.t(`relayed worker`);t?.unregisterSignal?.aborted?a():t?.unregisterSignal?.addEventListener(`abort`,a,{once:!0});let o=i.emit instanceof MessagePort?{}:{originA:t?.originA??x,originB:t?.originB??`*`};(0,g.relay)(i,e,{key:`fkn-api`,...o,unregisterSignal:t?.unregisterSignal})},C=async()=>typeof window>`u`?!1:(await n.a).connect.prompt(location.origin).catch(()=>!1),w=async()=>typeof window>`u`?null:(await n.a).relay.prompt().catch(()=>null),T=new Set,E=e=>(T.add(e),()=>{T.delete(e)}),D=()=>{if(T.size===0)return!1;for(let e of[...T])try{e()}catch{}return!0},O=(e,t)=>{if(typeof e?.onUpdateTaken==`function`)return Promise.resolve(e.onUpdateTaken(t))},k=e.t({applyUpdate:()=>H,busyReasons:()=>V,onUpdate:()=>I,onUpdateTaken:()=>L,updateReady:()=>A}),A=async()=>typeof window>`u`?!1:n.a.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),j=new Set,M=!1,N=()=>{M=!0;for(let e of[...j])try{e()}catch{}},P=0,F=()=>{let e=n.s();!e||j.size===0||P===e.epoch||(P=e.epoch,M=!1,Promise.resolve(e.remote.shell?.onUpdate(N)).catch(()=>{P===e.epoch&&(P=0)}))};typeof window<`u`&&n.l(F);var I=async e=>{if(typeof window>`u`)return()=>{};if(j.add(e),M)try{e()}catch{}return F(),()=>{j.delete(e)}},L=e=>typeof window>`u`?()=>{}:E(e),R=0,z=!1,B=()=>{if(!D()&&!z){z=!0;try{location.reload()}catch{}}};typeof window<`u`&&n.l(()=>{let e=n.s();if(!e||R===e.epoch)return;R=e.epoch;let t=O(e.remote.shell,B);if(!t){R=0;return}t.catch(()=>{R===e.epoch&&(R=0)})});var V=()=>r.n(),H=async()=>typeof window>`u`?!1:n.a.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1);exports.ATTACH_FRAME_EVENT_KEY=t.n,exports.EXTENSION_ABI=t.z,exports.ExtensionOperationUnsupportedError=t.B,exports.ExtensionOutdatedError=t.V,exports.FORGEABLE_HEADERS=t.A,exports.LOCATOR_DENIED=t.p,exports.LOCATOR_ERROR=t.g,exports.LOCATOR_UNSUPPORTED=t.u,exports.REQUIRED_EXTENSION_ABI=t.H,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return m.t}}),exports.assertAttachableFrameUrl=t.s,exports.assertFetchableUrl=t.C,exports.assertForgeableHeaders=t.j,exports.assertLockdownApplicable=t.c,exports.assertOneCookieIdentity=t.M,exports.attachFrame=b,exports.attachFramePermission=t.i,exports.box=t.G,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return i.n}}),exports.connect=C,exports.connectButtonUrl=h.t,exports.cookies=t.x,exports.createFrame=t.a,exports.createVideoElementHandle=t.K,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return s.t}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return l.t}}),exports.fetch=l.n,exports.fetchCredentialedPermission=t.T,exports.fetchLocalPermission=t.E,exports.fetchPermission=t.D,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return d.u}}),exports.gotoPermission=t.o,exports.handleRevivableModules=t.W,exports.hasForgedCookie=t.N,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return c.t}}),exports.isBlockedFetchUrl=t.O,exports.isBlockedFrameUrl=t.l,exports.isExtensionExposed=t.F,exports.isLocalNetworkUrl=t.k,exports.isLocatorDenied=t.h,exports.isLocatorUnsupported=t._,exports.isTerminalError=t.f,exports.isType=t.q,exports.modifyRequestHeadersPermission=t.v,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return f.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return p.t}}),exports.permissions=t.t,exports.promptInstall=l.i,exports.promptRelay=w,exports.readCookiePermission=t.S,exports.readExtensionHandshake=t.I,exports.relayWorker=S,exports.removeRequestHeaderRule=t.y,exports.revive=t.J,exports.setMissingExtensionHandler=t.L,exports.setRequestHeaderRule=t.b,Object.defineProperty(exports,"shell",{enumerable:!0,get:function(){return k}}),exports.supportsOperation=t.U,exports.type=t.Y,exports.waitForExtensionExposure=t.R;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-DLM2M3_i.cjs"),n=require("./api-BCJO3EWi.cjs"),r=require("./busy-Dv8wzE5M.cjs"),i=require("./cloud-B2ZG-0MF.cjs"),a=require("./dns.cjs"),o=require("./net.cjs"),s=require("./dgram.cjs"),c=require("./http.cjs"),l=require("./extension-DBazc3ff.cjs"),u=require("./desktop.cjs"),d=require("./fs-J5h3i5eg.cjs"),f=require("./opfs.cjs"),p=require("./packages.cjs"),m=require("./account.cjs"),h=require("./connect-button-BpXDs7tw.cjs");let g=require("osra");var _=1e4,v=150,y=()=>new Promise(e=>{if(t.F())return e(!0);let n,r=setTimeout(()=>i(t.F()),_),i=t=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),e(t)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(t.F()),v)},o=new MutationObserver(()=>{t.F()&&i(!0)}),s=()=>{document.readyState===`complete`&&!t.F()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),b=async e=>l.r()||e.lockdown||!i.a()||await y()?t.r(e):i.i(e),x=`https://fkn.app`,S=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let i=await n.u;if(!i)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);let a=r.t(`relayed worker`);t?.unregisterSignal?.aborted?a():t?.unregisterSignal?.addEventListener(`abort`,a,{once:!0});let o=i.emit instanceof MessagePort?{}:{originA:t?.originA??x,originB:t?.originB??`*`};(0,g.relay)(i,e,{key:`fkn-api`,...o,unregisterSignal:t?.unregisterSignal})},C=async()=>typeof window>`u`?!1:(await n.a).connect.prompt(location.origin).catch(()=>!1),w=async()=>typeof window>`u`?null:(await n.a).relay.prompt().catch(()=>null),T=new Set,E=e=>(T.add(e),()=>{T.delete(e)}),D=()=>{if(T.size===0)return!1;for(let e of[...T])try{e()}catch{}return!0},O=(e,t)=>{if(typeof e?.onUpdateTaken==`function`)return Promise.resolve(e.onUpdateTaken(t))},k=e.t({applyUpdate:()=>H,busyReasons:()=>V,onUpdate:()=>I,onUpdateTaken:()=>L,updateReady:()=>A}),A=async()=>typeof window>`u`?!1:n.a.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),j=new Set,M=!1,N=()=>{M=!0;for(let e of[...j])try{e()}catch{}},P=0,F=()=>{let e=n.s();!e||j.size===0||P===e.epoch||(P=e.epoch,M=!1,Promise.resolve(e.remote.shell?.onUpdate(N)).catch(()=>{P===e.epoch&&(P=0)}))};typeof window<`u`&&n.l(F);var I=async e=>{if(typeof window>`u`)return()=>{};if(j.add(e),M)try{e()}catch{}return F(),()=>{j.delete(e)}},L=e=>typeof window>`u`?()=>{}:E(e),R=0,z=!1,B=()=>{if(!D()&&!z){z=!0;try{location.reload()}catch{}}};typeof window<`u`&&n.l(()=>{let e=n.s();if(!e||R===e.epoch)return;R=e.epoch;let t=O(e.remote.shell,B);if(!t){R=0;return}t.catch(()=>{R===e.epoch&&(R=0)})});var V=()=>r.n(),H=async()=>typeof window>`u`?!1:n.a.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1);exports.ATTACH_FRAME_EVENT_KEY=t.n,exports.EXTENSION_ABI=t.z,exports.ExtensionOperationUnsupportedError=t.B,exports.ExtensionOutdatedError=t.V,exports.FORGEABLE_HEADERS=t.A,exports.LOCATOR_DENIED=t.p,exports.LOCATOR_ERROR=t.g,exports.LOCATOR_UNSUPPORTED=t.u,exports.REQUIRED_EXTENSION_ABI=t.H,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return m.t}}),exports.assertAttachableFrameUrl=t.s,exports.assertFetchableUrl=t.C,exports.assertForgeableHeaders=t.j,exports.assertLockdownApplicable=t.c,exports.assertOneCookieIdentity=t.M,exports.attachFrame=b,exports.attachFramePermission=t.i,exports.box=t.G,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return i.n}}),exports.connect=C,exports.connectButtonUrl=h.t,exports.cookies=t.x,exports.createFrame=t.a,exports.createVideoElementHandle=t.K,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return s.t}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return l.t}}),exports.fetch=l.n,exports.fetchCredentialedPermission=t.T,exports.fetchLocalPermission=t.E,exports.fetchPermission=t.D,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return d.u}}),exports.gotoPermission=t.o,exports.handleRevivableModules=t.W,exports.hasForgedCookie=t.N,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return c.t}}),exports.isBlockedFetchUrl=t.O,exports.isBlockedFrameUrl=t.l,exports.isExtensionExposed=t.F,exports.isLocalNetworkUrl=t.k,exports.isLocatorDenied=t.h,exports.isLocatorUnsupported=t._,exports.isTerminalError=t.f,exports.isType=t.q,exports.modifyRequestHeadersPermission=t.v,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return f.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return p.t}}),exports.permissions=t.t,exports.promptInstall=l.i,exports.promptRelay=w,exports.readCookiePermission=t.S,exports.readExtensionHandshake=t.I,exports.relayWorker=S,exports.removeRequestHeaderRule=t.y,exports.revive=t.J,exports.setMissingExtensionHandler=t.L,exports.setRequestHeaderRule=t.b,Object.defineProperty(exports,"shell",{enumerable:!0,get:function(){return k}}),exports.supportsOperation=t.U,exports.type=t.Y,exports.waitForExtensionExposure=t.R;
package/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { t as account_d_exports } from "./account.js";
2
2
  import { A as modifyRequestHeadersPermission, C as LOCATOR_ERROR, D as isTerminalError, E as isLocatorUnsupported, F as cookies, G as isLocalNetworkUrl, H as fetchLocalPermission, I as readCookiePermission, J as assertOneCookieIdentity, K as FORGEABLE_HEADERS, L as FetchInit, M as setRequestHeaderRule, N as CookieDetails, O as HeaderOperation, P as SiteCookie, R as ProxyFetchRequest, S as LOCATOR_DENIED, T as isLocatorDenied, U as fetchPermission, V as fetchCredentialedPermission, W as isBlockedFetchUrl, Y as hasForgedCookie, _ as PermissionRequest, b as assertLockdownApplicable, c as setMissingExtensionHandler, d as ExtensionHandshake, f as ExtensionOperationUnsupportedError, g as PermissionGrant, h as supportsOperation, i as promptInstall, j as removeRequestHeaderRule, k as RequestHeaderRule, l as waitForExtensionExposure, m as REQUIRED_EXTENSION_ABI, n as fetch, o as isExtensionExposed, p as ExtensionOutdatedError, q as assertForgeableHeaders, s as readExtensionHandshake, t as extension_d_exports, u as EXTENSION_ABI, v as permissions, w as LOCATOR_UNSUPPORTED, x as isBlockedFrameUrl, y as assertAttachableFrameUrl, z as assertFetchableUrl } from "./extension-CJUeVRXf.js";
3
3
  import { C as OperationRequest, S as GateTools, _ as isType, a as FrameBackend, b as Executor, c as attachFramePermission, d as handleRevivableModules, f as BoxedVideoElement, g as createVideoElementHandle, h as box, i as Frame, l as createFrame, m as VideoElementState, o as GotoOptions, p as RemoteVideoElement, r as AttachFrameOptions, s as Locator, t as ATTACH_FRAME_EVENT_KEY, u as gotoPermission, v as revive, w as SelectorPart, x as Gate, y as type } from "./index-BhO-wymH.js";
4
- import { n as cloud_d_exports } from "./cloud-B7pI3pp1.js";
4
+ import { n as cloud_d_exports } from "./cloud-ZRqclRzO.js";
5
5
  import { t as dns_d_exports } from "./dns.js";
6
- import { u as index_d_exports } from "./index-CGJTVju4.js";
7
- import { s as net_d_exports } from "./net-DAOcF3Eb.js";
6
+ import { u as index_d_exports } from "./index-Cg6y_FTi.js";
7
+ import { s as net_d_exports } from "./net-C9Me0zVw.js";
8
8
  import { t as dgram_d_exports } from "./dgram.js";
9
9
  import { t as http_d_exports } from "./http.js";
10
10
  import { t as desktop_d_exports } from "./desktop.js";
11
11
  import { t as index_d_exports$1 } from "./opfs.js";
12
12
  import { t as packages_d_exports } from "./packages.js";
13
- import { t as connectButtonUrl } from "./connect-button-DdoEikEd.js";
13
+ import { t as connectButtonUrl } from "./connect-button-Cp0NS95-.js";
14
14
  //#region src/frame.d.ts
15
15
  declare const attachFrame: (options: AttachFrameOptions) => Promise<Frame>;
16
16
  //#endregion
package/index.js CHANGED
@@ -9,11 +9,11 @@ import { t as ue } from "./dgram.js";
9
9
  import { t as de } from "./http.js";
10
10
  import { i as fe, n as pe, r as me, t as he } from "./extension-Dw9gzvei.js";
11
11
  import { t as ge } from "./desktop.js";
12
- import { u as _e } from "./fs-d2ANVBkm.js";
12
+ import { u as _e } from "./fs-Cvx2NT6o.js";
13
13
  import { t as ve } from "./opfs.js";
14
14
  import { t as ye } from "./packages.js";
15
15
  import { t as be } from "./account.js";
16
- import { t as xe } from "./connect-button-CN4ZJwT6.js";
16
+ import { t as xe } from "./connect-button-DtsN3X1J.js";
17
17
  import { relay as Se } from "osra";
18
18
  //#region src/frame.ts
19
19
  var Ce = 1e4, we = 150, Te = () => new Promise((e) => {
@@ -1,6 +1,6 @@
1
1
  import { o as TcpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { B as TcpSocketListenerResult, H as TcpSocketResult, P as Resolvers } from "./contract-D6ksmIm6.js";
3
- import "./api-CesI0aMl.js";
2
+ import { B as TcpSocketListenerResult, H as TcpSocketResult, P as Resolvers } from "./contract-BergoFCw.js";
3
+ import "./api-Dv7Fy_CF.js";
4
4
  import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
5
5
  import { DuplexOptions, Stream } from "stream";
6
6
  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-DAOcF3Eb.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-C9Me0zVw.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.25",
3
+ "version": "0.9.27",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
package/packages.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as PackageQuery, D as PickOptions, N as Radii, O as Placement, R as SurfaceRect, T as PackagesErrorCode, _ as InstallOptions, l as ConnectOptions, v as InstalledPackage, w as PackageResult } from "./contract-D6ksmIm6.js";
1
+ import { C as PackageQuery, D as PickOptions, N as Radii, O as Placement, R as SurfaceRect, T as PackagesErrorCode, _ as InstallOptions, l as ConnectOptions, v as InstalledPackage, w as PackageResult } from "./contract-BergoFCw.js";
2
2
  import { Remote } from "osra";
3
3
  declare namespace packages_d_exports {
4
4
  export { AppConnectOptions, Connect, ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, InstallOptions, InstalledPackage, MountOptions, MountedPackage, PackageConnection, PackageQuery, PackageResult, PackageView, PackagesError, PackagesErrorCode, PickOptions, Placement, Radii, RawPackageConnection, ShowOptions, SurfaceRect, attach, connect, hide, install, isVisible, list, mount, onConnect, onVisibilityChange, pick, search, show, uninstall };
@@ -1,5 +1,5 @@
1
- import { P as Resolvers } from "./contract-D6ksmIm6.js";
2
- import "./api-CesI0aMl.js";
1
+ import { P as Resolvers } from "./contract-BergoFCw.js";
2
+ import "./api-Dv7Fy_CF.js";
3
3
  //#region src/proxy.d.ts
4
4
  type ProxyFetch = Resolvers['cloud']['fetch'];
5
5
  type FetchParameters = Parameters<ProxyFetch>;
package/react.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./connect-button-BBEjXzB3.cjs");let t=require("react");var n=({className:n,style:r}={})=>(0,t.createElement)(`iframe`,{src:e.t(),title:`Connect your FKN account`,className:n,style:{border:`none`,width:150,height:40,background:`transparent`,colorScheme:`normal`,...r}});exports.ConnectButton=n,exports.connectButtonUrl=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./connect-button-BpXDs7tw.cjs");let t=require("react");var n=({className:n,style:r}={})=>(0,t.createElement)(`iframe`,{src:e.t(),title:`Connect your FKN account`,className:n,style:{border:`none`,width:150,height:40,background:`transparent`,colorScheme:`normal`,...r}});exports.ConnectButton=n,exports.connectButtonUrl=e.t;
package/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as connectButtonUrl } from "./connect-button-DdoEikEd.js";
1
+ import { t as connectButtonUrl } from "./connect-button-Cp0NS95-.js";
2
2
  import { CSSProperties, ReactElement } from "react";
3
3
  //#region src/react.d.ts
4
4
  type ConnectButtonProps = {
package/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./connect-button-CN4ZJwT6.js";
1
+ import { t as e } from "./connect-button-DtsN3X1J.js";
2
2
  import { createElement as t } from "react";
3
3
  //#region src/react.ts
4
4
  var n = ({ className: n, style: r } = {}) => t("iframe", {
@@ -7,14 +7,15 @@ var r = /* @__PURE__ */ e({
7
7
  StorageNotFoundError: () => a,
8
8
  availability: () => p,
9
9
  available: () => c,
10
- encryption: () => y,
10
+ encryption: () => x,
11
11
  isNotFound: () => o,
12
12
  list: () => m,
13
13
  quota: () => h,
14
14
  readFile: () => g,
15
- remove: () => v,
16
- unlock: () => b,
17
- writeFile: () => _
15
+ readFileSealed: () => v,
16
+ remove: () => b,
17
+ unlock: () => S,
18
+ writeFile: () => y
18
19
  }), i = class extends Error {
19
20
  code = "FKN_E2E_LOCKED";
20
21
  constructor() {
@@ -43,9 +44,24 @@ var r = /* @__PURE__ */ e({
43
44
  }, m = () => t.then((e) => e.cloud.fs.list()), h = () => t.then((e) => e.cloud.fs.quota()), g = async (e) => {
44
45
  let n = await (await t).cloud.fs.readFile(e).catch(s);
45
46
  return new Blob([n]);
46
- }, _ = async (e, n, r) => {
47
+ }, _ = (e) => {
48
+ if (e === null || !Number.isFinite(e)) return null;
49
+ let t = new Date(e);
50
+ return Number.isNaN(t.getTime()) ? null : t.toISOString();
51
+ }, v = async (e) => {
52
+ let n = (await t).cloud.fs;
53
+ if (typeof n.readFileSealed != "function") return {
54
+ data: await n.readFile(e).catch(s),
55
+ sealedAt: null
56
+ };
57
+ let r = await n.readFileSealed(e).catch(s);
58
+ return {
59
+ data: r.bytes,
60
+ sealedAt: _(r.sealedAt)
61
+ };
62
+ }, y = async (e, n, r) => {
47
63
  let i = await t, a = n instanceof Blob ? new Uint8Array(await n.arrayBuffer()) : n;
48
64
  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());
65
+ }, b = (e) => t.then((t) => t.cloud.fs.remove(e)).then(() => void 0), x = () => t.then((e) => e.cloud.fs.encryption()), S = () => t.then((e) => e.cloud.fs.unlock());
50
66
  //#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, p as r, h as s, i as t, r as u };
67
+ export { o as a, g as c, r as d, S as f, x as i, v as l, a as n, m as o, y as p, p as r, h as s, i as t, b as u };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-BCJO3EWi.cjs"),n=require("./messages.cjs");var r=e.t({StorageLockedError:()=>i,StorageNotFoundError:()=>a,availability:()=>p,available:()=>c,encryption:()=>x,isNotFound:()=>o,list:()=>m,quota:()=>h,readFile:()=>g,readFileSealed:()=>v,remove:()=>b,unlock:()=>S,writeFile:()=>y}),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.STORAGE_NOT_FOUND;constructor(e=`storage: no object at that path`){super(e)}},o=e=>e?.code===n.STORAGE_NOT_FOUND,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.a.then(e=>e.cloud.fs.available()).catch(()=>!1),l=8e3,u=1e3,d=!1,f=async()=>{let e=(await t.a).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.a.then(e=>e.cloud.fs.list()),h=()=>t.a.then(e=>e.cloud.fs.quota()),g=async e=>{let n=await(await t.a).cloud.fs.readFile(e).catch(s);return new Blob([n])},_=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},v=async e=>{let n=(await t.a).cloud.fs;if(typeof n.readFileSealed!=`function`)return{data:await n.readFile(e).catch(s),sealedAt:null};let r=await n.readFileSealed(e).catch(s);return{data:r.bytes,sealedAt:_(r.sealedAt)}},y=async(e,n,r)=>{let i=await t.a,a=n instanceof Blob?new Uint8Array(await n.arrayBuffer()):n;await i.cloud.fs.writeFile(e,a,r?.contentType??null).catch(s)},b=e=>t.a.then(t=>t.cloud.fs.remove(e)).then(()=>void 0),x=()=>t.a.then(e=>e.cloud.fs.encryption()),S=()=>t.a.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 r}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return x}}),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 y}}),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 b}});
@@ -0,0 +1,69 @@
1
+ //#region src/storage.d.ts
2
+ type FileEntry = {
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 EncryptionStatus = {
17
+ unlocked: boolean;
18
+ enrolled: boolean;
19
+ keyEpoch: number | null;
20
+ };
21
+ declare class StorageLockedError extends Error {
22
+ code: string;
23
+ constructor();
24
+ }
25
+ /**
26
+ * There is no object at this path. Test `err.code === STORAGE_NOT_FOUND`, never the message.
27
+ *
28
+ * Absence arrives from two places that word it completely differently: the api refusing to presign
29
+ * a path with no committed row says "Not found", and a presign that succeeded followed by an object
30
+ * fetch that 404s says "storage: read failed (404)". Neither is a fault, both mean the same thing,
31
+ * and matching either by hand means matching both. Ripple matched only the first, so a missing
32
+ * backup read as a transient failure, retried forever, and a library went un-backed-up for a day
33
+ * without a single error anywhere.
34
+ *
35
+ * The distinction matters more than it sounds. "There is nothing here" is safe to overwrite;
36
+ * "I could not tell you" is not, and a caller that confuses them either never writes a first
37
+ * backup or destroys a real one.
38
+ */
39
+ declare class StorageNotFoundError extends Error {
40
+ code: string;
41
+ constructor(message?: string);
42
+ }
43
+ /** Whether an error from this module means the path is empty, as opposed to unreadable. */
44
+ declare const isNotFound: (error: unknown) => boolean;
45
+ declare const quota: () => Promise<StorageQuota>;
46
+ /** The bytes of a cloud object and the seal time they carry, as an ISO string or null. */
47
+ type SealedRead = {
48
+ data: Uint8Array;
49
+ sealedAt: string | null;
50
+ };
51
+ /**
52
+ * A cloud read that also reports when the copy was sealed.
53
+ *
54
+ * `sealedAt` is an ISO string, or null when the envelope carries no such field (one written before
55
+ * the seal time existed) or when the data plane is older than this call. The value is
56
+ * AUTHENTICATED, so the server can neither forge nor alter it, and it is the WRITER's own claim
57
+ * about when it sealed, so on its own it does not prove this copy is the newest one: an older but
58
+ * perfectly authentic copy of the same path is still authentic. An app that needs that answer keeps
59
+ * a high-water mark per path and compares. Do not confuse it with the `updatedAt` on a listing,
60
+ * which is the server's hint and is fine for display and nothing else.
61
+ *
62
+ * The bytes and the stamp come from ONE read of ONE envelope, which is what makes the stamp
63
+ * describe the bytes returned beside it. `readFile` is unchanged and unaffected.
64
+ */
65
+ declare const readFileSealed: (path: string) => Promise<SealedRead>;
66
+ declare const encryption: () => Promise<EncryptionStatus>;
67
+ declare const unlock: () => Promise<boolean>;
68
+ //#endregion
69
+ export { StorageNotFoundError as a, isNotFound as c, unlock as d, StorageLockedError as i, quota as l, FileEntry as n, StorageQuota as o, SealedRead as r, encryption as s, EncryptionStatus as t, readFileSealed as u };
@@ -1 +0,0 @@
1
- var e=`https://fkn.app`,t=t=>{let n=t??(typeof location<`u`?location.origin:void 0);return n?`${e}/connect-button?origin=${encodeURIComponent(n)}`:`${e}/connect-button`};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
@@ -1,7 +0,0 @@
1
- //#region src/connect-button.ts
2
- var e = "https://fkn.app", t = (t) => {
3
- let n = t ?? (typeof location < "u" ? location.origin : void 0);
4
- return n ? `${e}/connect-button?origin=${encodeURIComponent(n)}` : `${e}/connect-button`;
5
- };
6
- //#endregion
7
- export { t };
@@ -1,4 +0,0 @@
1
- //#region src/connect-button.d.ts
2
- declare const connectButtonUrl: (origin?: string) => string;
3
- //#endregion
4
- export { connectButtonUrl as t };
package/fs-DYP7utdw.cjs DELETED
@@ -1 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./busy-Dv8wzE5M.cjs"),n=require("./node-fs-DZPGCYWg.cjs"),r=require("./storage-DLB4ciMf.cjs"),i=require("./opfs-CXMESVLc.cjs");var a=e.t({adopt:()=>I,adoptable:()=>L,available:()=>u,list:()=>re,onConflict:()=>ce,pending:()=>w,pendingDeletes:()=>ee,pull:()=>se,readFile:()=>ie,remove:()=>oe,replicating:()=>T,writeFile:()=>ae}),o,s=async()=>await(o??=i.t().catch(()=>!1))?!0:(o=void 0,!1),c=()=>r.r().catch(()=>`unknown`),l=async()=>await c()===`connected`,u=async()=>await s()||await l(),d=`fkn:fs:pending`,f=`fkn:fs:pending-delete`,p=`fkn:fs:adopt-declined`,m=!0,h=new Map,g=e=>{try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return Array.isArray(n)?Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,null])):n&&typeof n==`object`?n:{}}catch{return{}}},_=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},v=()=>g(d),y=(e,t)=>{let n=v();e in n||(n[e]=t===void 0?h.get(e)??null:t,_(d,n))},b=e=>{let t=v();e in t&&(delete t[e],_(d,t),D()||(k=O))},x=()=>g(f),S=e=>{let t=x();e in t||(t[e]=h.get(e)??null,_(f,t))},C=e=>{let t=x();e in t&&(delete t[e],_(f,t),D()||(k=O))},w=()=>Object.keys(v()),ee=()=>Object.keys(x()),T=()=>m,E=null;t.r(`storage replication`,()=>E!==null||R!==null);var D=()=>Object.keys(v()).length>0||Object.keys(x()).length>0,O=6e4,te=6e5,k=O,A=null,j=()=>{A||typeof window>`u`||!D()||(A=setTimeout(()=>{A=null,M()},k),k=Math.min(k*2,te))},M=()=>{E||!D()||(E=F(!1).then(e=>{if(!D()){k=O;return}e.failed.length&&j()}).catch(()=>{j()}).finally(()=>{E=null}))},ne=null,N=()=>ne??=Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.apiPromise),re=async()=>{U();let e=await c(),t=e===`connected`,[n,a]=await Promise.all([s().then(e=>e?i.n():[]).catch(()=>[]),t?r.o().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:e===`disconnected`,entries:[]})]);e!==`unknown`&&(m=a.ok),a.ok&&e!==`unknown`&&(h=new Map(a.entries.map(e=>[e.path,e.updatedAt])));let o=new Map,l=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},u=e=>{let t=o.get(e.path);(!t||l(e)>=l(t))&&o.set(e.path,e)};for(let e of n)u(e);for(let e of a.entries)u(e);return a.ok&&t&&(pe(n,a.entries).catch(()=>{}),D()?M():z({local:n,remote:a.entries}).catch(()=>{})),[...o.values()]},ie=async e=>{if(await s())try{return await i.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await r.c(e);return await s()&&i.o(e,t).catch(()=>{}),t},ae=async(e,t,n)=>{let a=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);if(await s()){await i.o(e,a,n),U();let t=h.get(e)??null,o=await c();if(o===`disconnected`)return;if(o===`unknown`||!m){y(e,t),j();return}r.f(e,a,n).then(()=>b(e)).catch(n=>{y(e,t),j(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let o=await c();if(o===`connected`)return r.f(e,a,n);throw Error(o===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},oe=async e=>{U();let t=[];await s()&&t.push(i.a(e).catch(()=>{}));let n=await c();if(n===`connected`?t.push(r.l(e).then(()=>C(e)).catch(t=>{S(e),j(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):n===`unknown`&&t.length&&h.has(e)&&(S(e),j()),!t.length)throw Error(n===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);b(e),await Promise.all(t)},se=async e=>{let t=await r.c(e);return await s()&&await i.o(e,t),t},P=null,ce=e=>(P=e,()=>{P===e&&(P=null)}),le=async e=>(await N()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null),ue=async e=>{if(P)try{return await P(e)}catch{return null}return le(e)},F=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},n=await c();if(n===`unknown`)throw Error(`fs: cloud unreachable`);if(n!==`connected`)throw Error(`fs: this needs a signed-in account`);let a=await s(),[o,l]=await Promise.all([a?i.n():Promise.resolve([]),r.o()]),u=new Map(l.map(e=>[e.path,e])),d=v();if(a)for(let e of Object.keys(d))o.some(t=>t.path===e)||b(e);for(let[e,n]of Object.entries(x())){let i=u.get(e);if(!i){C(e);continue}if(o.some(t=>t.path===e)){C(e);continue}if(i.updatedAt!==n){C(e);continue}try{await r.l(e),C(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let n of o){let a=u.get(n.path),o=n.path in d;if(!o&&(a||!e)){a&&t.kept.push(n.path);continue}if(o&&a&&a.updatedAt!==d[n.path]){let e=await ue({path:n.path,local:{size:n.size,updatedAt:n.updatedAt},cloud:{size:a.size,updatedAt:a.updatedAt},readLocal:()=>i.i(n.path),readCloud:()=>r.c(n.path)});if(!e){t.unresolved.push(n.path);continue}try{if(e===`cloud`)await i.o(n.path,await r.c(n.path));else{let t=e===`local`?await i.i(n.path):e.merged;await r.f(n.path,t,n.contentType?{contentType:n.contentType}:void 0),e!==`local`&&await i.o(n.path,t)}b(n.path),t.resolved.push({path:n.path,choice:e===`local`||e===`cloud`?e:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await i.i(n.path);await r.f(n.path,e,n.contentType?{contentType:n.contentType}:void 0),b(n.path),t.uploaded.push(n.path)}catch(e){if(y(n.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}}return t},I=async()=>{for(;E;)await E;let e=F(!0);E=e.then(()=>{},()=>{});try{return await e}finally{E=null}},L=async()=>{if(!await l()||!await s())return{paths:[],bytes:0};let[e,t]=await Promise.all([i.n(),r.o()]),n=new Set(t.map(e=>e.path)),a=e.filter(e=>!n.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},de=()=>new Set(Object.keys(g(p))),fe=e=>{let t=g(p);for(let n of e)t[n]=null;_(p,t)},R=null,z=e=>R||(R=(async()=>{if(!await l())return;let t=e??(await s()?{local:await i.n(),remote:await r.o()}:null);if(!t)return;let n=new Set(t.remote.map(e=>e.path)),a=de(),o=t.local.filter(e=>!n.has(e.path)&&!a.has(e.path));if(!o.length)return;let c=await N(),u=o.reduce((e,t)=>e+t.size,0);if(!await c.cloud.fs.promptAdopt({files:o.length,bytes:u}).catch(()=>!1)){fe(o.map(e=>e.path));return}await I()})().catch(()=>{}).finally(()=>{R=null}),R),B=null,V=!1,pe=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await N(),a=async()=>{await I().catch(()=>{});let e=await L().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})},o={files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)};B=()=>{i.cloud.fs.setAdoptSource(o,a).catch(()=>{})},V||(V=!0,Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.onApiEpoch((e,t)=>{t>1&&B?.()})).catch(()=>{})),await i.cloud.fs.setAdoptSource(o,a)},H=!1,U=()=>{H||typeof window>`u`||(H=!0,window.addEventListener(`online`,()=>{M()}),Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{z().catch(()=>{}),M()})).catch(()=>{}))},me=e.t({adopt:()=>q,adoptable:()=>J,appendFile:()=>ke,appendFileSync:()=>ve,available:()=>he,default:()=>$,exists:()=>Ie,existsSync:()=>ye,flush:()=>ze,lstatSync:()=>xe,mkdir:()=>Me,mkdirSync:()=>Se,mount:()=>Re,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>Le,pull:()=>K,readFile:()=>De,readFileSync:()=>ge,readdir:()=>je,readdirSync:()=>G,remount:()=>Be,rename:()=>Fe,renameSync:()=>Ee,replicating:()=>Z,rm:()=>Ne,rmSync:()=>Ce,rmdirSync:()=>we,stat:()=>Ae,statSync:()=>be,unlink:()=>Pe,unlinkSync:()=>Te,writeFile:()=>Oe,writeFileSync:()=>_e}),W=n.t(a,{memfs:!0}),{available:he,readFileSync:ge,writeFileSync:_e,appendFileSync:ve,existsSync:ye,statSync:be,lstatSync:xe,readdirSync:G,mkdirSync:Se,rmSync:Ce,rmdirSync:we,unlinkSync:Te,renameSync:Ee,readFile:De,writeFile:Oe,appendFile:ke,stat:Ae,readdir:je,mkdir:Me,rm:Ne,unlink:Pe,rename:Fe,exists:Ie,promises:Le,mount:Re,flush:ze,remount:Be}=W,K=se,q=I,J=L,Y=w,X=ee,Z=T,Q=ce,$={...W,pull:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return K}});
package/fs-DlGE0ZNu.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-BQgZVQl7.js";
2
- import { i as STORAGE_NOT_FOUND } from "./messages-DvpKMTsY.js";
3
- //#region src/storage.d.ts
4
- type FileEntry = {
5
- path: string;
6
- size: number;
7
- contentType: string | null;
8
- updatedAt: string;
9
- encryption: string | null;
10
- };
11
- type StorageQuota = {
12
- usedBytes: number;
13
- limitBytes: number;
14
- remaining: number;
15
- objects: number;
16
- maxObjects: number;
17
- };
18
- type EncryptionStatus = {
19
- unlocked: boolean;
20
- enrolled: boolean;
21
- keyEpoch: number | null;
22
- };
23
- declare class StorageLockedError extends Error {
24
- code: string;
25
- constructor();
26
- }
27
- /**
28
- * There is no object at this path. Test `err.code === STORAGE_NOT_FOUND`, never the message.
29
- *
30
- * Absence arrives from two places that word it completely differently: the api refusing to presign
31
- * a path with no committed row says "Not found", and a presign that succeeded followed by an object
32
- * fetch that 404s says "storage: read failed (404)". Neither is a fault, both mean the same thing,
33
- * and matching either by hand means matching both. Ripple matched only the first, so a missing
34
- * backup read as a transient failure, retried forever, and a library went un-backed-up for a day
35
- * without a single error anywhere.
36
- *
37
- * The distinction matters more than it sounds. "There is nothing here" is safe to overwrite;
38
- * "I could not tell you" is not, and a caller that confuses them either never writes a first
39
- * backup or destroys a real one.
40
- */
41
- declare class StorageNotFoundError extends Error {
42
- code: string;
43
- constructor(message?: string);
44
- }
45
- /** Whether an error from this module means the path is empty, as opposed to unreadable. */
46
- declare const isNotFound: (error: unknown) => boolean;
47
- declare const quota: () => Promise<StorageQuota>;
48
- declare const encryption: () => Promise<EncryptionStatus>;
49
- declare const unlock: () => Promise<boolean>;
50
- declare namespace fs_d_exports {
51
- export { EncryptionStatus, FileEntry, STORAGE_NOT_FOUND, Stats, StorageLockedError, StorageNotFoundError, StorageQuota, available, encryption, isNotFound, mkdir, promises, quota, readFile, readdir, rename, rm, stat, unlink, unlock, writeFile };
52
- }
53
- declare const available: () => Promise<boolean>, readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void, writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void, readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void, mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void, rm: (path: import("node:fs").PathLike, a: {
54
- recursive?: boolean;
55
- } | Callback<void>, b?: Callback<void>) => void, stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void, promises: {
56
- readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
57
- writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
58
- unlink: (path: import("node:fs").PathLike) => Promise<void>;
59
- rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
60
- readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
61
- mkdir: (_path?: import("node:fs").PathLike, _options?: MakeOptions) => Promise<void>;
62
- rm: (path: import("node:fs").PathLike, options?: {
63
- recursive?: boolean;
64
- }) => Promise<void>;
65
- rmdir: (path: import("node:fs").PathLike, options?: {
66
- recursive?: boolean;
67
- }) => Promise<void>;
68
- stat: (path: import("node:fs").PathLike) => Promise<Stats>;
69
- lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
70
- access: (path: import("node:fs").PathLike) => Promise<void>;
71
- };
72
- //#endregion
73
- export { encryption as _, readFile as a, unlock as b, rm as c, writeFile as d, EncryptionStatus as f, StorageQuota as g, StorageNotFoundError as h, promises as i, stat as l, StorageLockedError as m, fs_d_exports as n, readdir as o, FileEntry as p, mkdir as r, rename as s, available as t, unlink as u, isNotFound as v, quota as y };