@fkn/lib 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{api-CLpsJzJy.d.ts → api-BFqrrvzI.d.ts} +7 -0
- package/cloud/net.d.ts +1 -1
- package/{cloud-7C3sOMF_.d.ts → cloud-CzMjj2Ne.d.ts} +2 -2
- package/cloud.d.ts +2 -2
- package/dgram.d.ts +1 -1
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/fs-BrBsBqRz.cjs +1 -0
- package/fs-_59wCBU2.js +315 -0
- package/fs.cjs +1 -1
- package/fs.d.ts +2 -2
- package/fs.js +2 -2
- package/http.d.ts +1 -1
- package/{index-Bt2VAVEC.d.ts → index-BIZeEsNu.d.ts} +5 -2
- package/index.cjs +1 -1
- package/index.d.ts +3 -3
- package/index.js +1 -1
- package/{net--o3_puH-.d.ts → net-MbSFrO35.d.ts} +1 -1
- package/net.d.ts +1 -1
- package/package.json +1 -1
- package/fs-B8Rc1zRI.cjs +0 -1
- package/fs-CvCcDnzN.js +0 -260
|
@@ -33,6 +33,12 @@ type ConflictRequest = {
|
|
|
33
33
|
};
|
|
34
34
|
type ConflictChoice = 'local' | 'cloud' | null;
|
|
35
35
|
//#endregion
|
|
36
|
+
//#region src/api/adopt-state.d.ts
|
|
37
|
+
type AdoptState = {
|
|
38
|
+
files: number;
|
|
39
|
+
bytes: number;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
36
42
|
//#region src/api/webvpn/packets/tcp.d.ts
|
|
37
43
|
declare const parseServerMetadataTcpSocketConnectedPacket: (offset: number, buffer: ArrayBuffer, view: DataView) => {
|
|
38
44
|
readonly _type: 'ServerMetadataTcpSocketConnectedPacket';
|
|
@@ -434,6 +440,7 @@ declare const resolvers: {
|
|
|
434
440
|
readonly unlock: () => Promise<boolean>;
|
|
435
441
|
readonly promptAdopt: (request: AdoptRequest) => Promise<boolean>;
|
|
436
442
|
readonly promptConflict: (request: ConflictRequest) => Promise<ConflictChoice>;
|
|
443
|
+
readonly setAdoptSource: (next: AdoptState | null, run: (() => Promise<void>) | null) => void;
|
|
437
444
|
};
|
|
438
445
|
readonly webvpn: {
|
|
439
446
|
readonly tcpSocket: ({
|
package/cloud/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
|
|
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-MbSFrO35.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as Resolvers } from "./api-
|
|
1
|
+
import { t as Resolvers } from "./api-BFqrrvzI.js";
|
|
2
2
|
import { b as Frame, y as AttachFrameOptions } from "./index-BJztAQIP.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs-DTmSCXwa.js";
|
|
5
|
-
import { s as net_d_exports } from "./net
|
|
5
|
+
import { s as net_d_exports } from "./net-MbSFrO35.js";
|
|
6
6
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
7
7
|
import { t as http_d_exports } from "./http.js";
|
|
8
8
|
|
package/cloud.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as attachFrame, i as quota, o as cloudFetch, r as QuotaStatus, t as available } from "./cloud-
|
|
1
|
+
import { a as attachFrame, i as quota, o as cloudFetch, r as QuotaStatus, t as available } from "./cloud-CzMjj2Ne.js";
|
|
2
2
|
import { t as dns_d_exports } from "./dns.js";
|
|
3
3
|
import { n as fs_d_exports } from "./fs-DTmSCXwa.js";
|
|
4
|
-
import { s as net_d_exports } from "./net
|
|
4
|
+
import { s as net_d_exports } from "./net-MbSFrO35.js";
|
|
5
5
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
6
6
|
import { t as http_d_exports } from "./http.js";
|
|
7
7
|
export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
|
package/dgram.d.ts
CHANGED
package/fs/promises.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-BrBsBqRz.cjs");var{readFile:t,writeFile:n,appendFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:l,stat:u,lstat:d,access:f}=e.v,p=e.v;exports.access=f,exports.appendFile=r,exports.default=p,exports.lstat=d,exports.mkdir=s,exports.readFile=t,exports.readdir=o,exports.rename=a,exports.rm=c,exports.rmdir=l,exports.stat=u,exports.unlink=i,exports.writeFile=n;
|
package/fs/promises.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as Stats, i as ReadOptions, o as WriteData, r as MakeOptions, s as WriteOptions } from "../index-CJ0vHTcS.js";
|
|
2
|
-
import {
|
|
2
|
+
import { v as promises } from "../index-BIZeEsNu.js";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/fs/promises.d.ts
|
|
5
5
|
declare const readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>, writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>, appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>, unlink: (path: import("node:fs").PathLike) => Promise<void>, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>, readdir: (path: import("node:fs").PathLike) => Promise<string[]>, mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>, rm: (path: import("node:fs").PathLike, options?: {
|
package/fs/promises.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as e } from "../fs-_59wCBU2.js";
|
|
2
2
|
//#region src/lib/fs/promises.ts
|
|
3
3
|
var { readFile: t, writeFile: n, appendFile: r, unlink: i, rename: a, readdir: o, mkdir: s, rm: c, rmdir: l, stat: u, lstat: d, access: f } = e, p = e;
|
|
4
4
|
//#endregion
|
package/fs-BrBsBqRz.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./node-fs-BMR2yCEt.cjs"),n=require("./storage-C1BT8jwJ.cjs"),r=require("./opfs-uClkgnb5.cjs");var i=e.n({adopt:()=>E,adoptable:()=>D,available:()=>c,list:()=>ie,onConflict:()=>le,pending:()=>te,pendingDeletes:()=>ne,pull:()=>ce,readFile:()=>ae,remove:()=>se,replicating:()=>x,writeFile:()=>oe}),a,o=async()=>await(a??=r.t().catch(()=>!1))?!0:(a=void 0,!1),s=()=>n.n().catch(()=>!1),c=async()=>await o()||await s(),l=`fkn:fs:pending`,u=`fkn:fs:pending-delete`,d=`fkn:fs:adopt-declined`,f=!0,p=new Map,m=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{}}},h=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},g=()=>m(l),_=e=>{let t=g();e in t||(t[e]=p.get(e)??null,h(l,t))},v=e=>{let t=g();e in t&&(delete t[e],h(l,t))},y=()=>m(u),ee=e=>{let t=y();e in t||(t[e]=p.get(e)??null,h(u,t))},b=e=>{let t=y();e in t&&(delete t[e],h(u,t))},te=()=>Object.keys(g()),ne=()=>Object.keys(y()),x=()=>f,S=null,re=null,C=()=>re??=Promise.resolve().then(()=>require("./api-BwrS6P0x.cjs")).then(e=>e.n).then(e=>e.apiPromise),ie=async()=>{he();let e=await s(),[t,i]=await Promise.all([o().then(e=>e?r.n():[]).catch(()=>[]),e?n.i().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:!0,entries:[]})]);f=i.ok,i.ok&&(p=new Map(i.entries.map(e=>[e.path,e.updatedAt])));let a=new Map,c=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},l=e=>{let t=a.get(e.path);(!t||c(e)>=c(t))&&a.set(e.path,e)};for(let e of t)l(e);for(let e of i.entries)l(e);if(i.ok&&e){me(t,i.entries).catch(()=>{});let e=Object.keys(g()).length||Object.keys(y()).length;e&&!S?S=T(!1).catch(()=>{}).finally(()=>{S=null}):e||k({local:t,remote:i.entries}).catch(()=>{})}return[...a.values()]},ae=async e=>{if(await o())try{return await r.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await n.o(e);return await o()&&r.o(e,t).catch(()=>{}),t},oe=async(e,t,i)=>{let a=t instanceof Blob?t:new Blob([t],i?.contentType?{type:i.contentType}:void 0);if(await o()){if(await r.o(e,a,i),!await s())return;if(!f){_(e);return}n.u(e,a,i).then(()=>v(e)).catch(t=>{_(e),console.warn(`fs: cloud replicate failed, queued for adopt()`,t)});return}if(await s())return n.u(e,a,i);throw Error(`fs: no storage backend available`)},se=async e=>{let t=[];await o()&&t.push(r.a(e).catch(()=>{}));let i=await s();if(i&&t.push(n.s(e).then(()=>b(e)).catch(t=>{ee(e),console.warn(`fs: cloud delete failed, queued for retry`,t)})),!t.length)throw Error(`fs: no storage backend available`);i&&v(e),await Promise.all(t)},ce=async e=>{let t=await n.o(e);return await o()&&await r.o(e,t),t},w=null,le=e=>(w=e,()=>{w===e&&(w=null)}),ue=async e=>(await C()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null),de=async e=>{if(w)try{return await w(e)}catch{return null}return ue(e)},T=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]};if(!await s())throw Error(`fs: this needs a signed-in account`);if(!await o())return t;let[i,a]=await Promise.all([r.n(),n.i()]),c=new Map(a.map(e=>[e.path,e])),l=g();for(let[e,r]of Object.entries(y())){let a=c.get(e);if(!a){b(e);continue}if(i.some(t=>t.path===e)){b(e);continue}if(a.updatedAt!==r){b(e);continue}try{await n.s(e),b(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let a of i){let i=c.get(a.path),o=a.path in l;if(!o&&(i||!e)){i&&t.kept.push(a.path);continue}if(o&&i&&i.updatedAt!==l[a.path]){let e=await de({path:a.path,local:{size:a.size,updatedAt:a.updatedAt},cloud:{size:i.size,updatedAt:i.updatedAt},readLocal:()=>r.i(a.path),readCloud:()=>n.o(a.path)});if(!e){t.unresolved.push(a.path);continue}try{if(e===`cloud`)await r.o(a.path,await n.o(a.path));else{let t=e===`local`?await r.i(a.path):e.merged;await n.u(a.path,t,a.contentType?{contentType:a.contentType}:void 0),e!==`local`&&await r.o(a.path,t)}v(a.path),t.resolved.push({path:a.path,choice:e===`local`||e===`cloud`?e:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await r.i(a.path);await n.u(a.path,e,a.contentType?{contentType:a.contentType}:void 0),v(a.path),t.uploaded.push(a.path)}catch(e){if(_(a.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}}return t},E=()=>T(!0),D=async()=>{if(!await s()||!await o())return{paths:[],bytes:0};let[e,t]=await Promise.all([r.n(),n.i()]),i=new Set(t.map(e=>e.path)),a=e.filter(e=>!i.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},fe=()=>new Set(Object.keys(m(d))),pe=e=>{let t=m(d);for(let n of e)t[n]=null;h(d,t)},O=null,k=e=>O||(O=(async()=>{if(!await s())return;let t=e??(await o()?{local:await r.n(),remote:await n.i()}:null);if(!t)return;let i=new Set(t.remote.map(e=>e.path)),a=fe(),c=t.local.filter(e=>!i.has(e.path)&&!a.has(e.path));if(!c.length)return;let l=await C(),u=c.reduce((e,t)=>e+t.size,0);if(!await l.cloud.fs.promptAdopt({files:c.length,bytes:u}).catch(()=>!1)){pe(c.map(e=>e.path));return}await E()})().catch(()=>{}).finally(()=>{O=null}),O),me=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await C(),a=async()=>{await E().catch(()=>{});let e=await D().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})};await i.cloud.fs.setAdoptSource({files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)},a)},A=!1,he=()=>{A||typeof window>`u`||(A=!0,Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{k().catch(()=>{})})).catch(()=>{}))},ge=e.n({adopt:()=>q,adoptable:()=>J,appendFile:()=>ye,appendFileSync:()=>F,available:()=>M,default:()=>$,exists:()=>Ee,existsSync:()=>I,flush:()=>G,lstatSync:()=>R,mkdir:()=>Se,mkdirSync:()=>B,mount:()=>Oe,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>De,pull:()=>K,readFile:()=>W,readFileSync:()=>N,readdir:()=>xe,readdirSync:()=>z,remount:()=>ke,rename:()=>Te,renameSync:()=>U,replicating:()=>Z,rm:()=>Ce,rmSync:()=>V,rmdirSync:()=>_e,stat:()=>be,statSync:()=>L,unlink:()=>we,unlinkSync:()=>H,writeFile:()=>ve,writeFileSync:()=>P}),j=t.t(i,{memfs:!0}),{available:M,readFileSync:N,writeFileSync:P,appendFileSync:F,existsSync:I,statSync:L,lstatSync:R,readdirSync:z,mkdirSync:B,rmSync:V,rmdirSync:_e,unlinkSync:H,renameSync:U,readFile:W,writeFile:ve,appendFile:ye,stat:be,readdir:xe,mkdir:Se,rm:Ce,unlink:we,rename:Te,exists:Ee,promises:De,mount:Oe,flush:G,remount:ke}=j,K=ce,q=E,J=D,Y=te,X=ne,Z=x,Q=le,$={...j,pull:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return W}}),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 Se}}),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 F}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return K}});
|
package/fs-_59wCBU2.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
|
+
import { t } from "./node-fs-DKfokOlh.js";
|
|
3
|
+
import { i as n, n as r, o as i, s as a, u as o } from "./storage-InqJHrkf.js";
|
|
4
|
+
import { a as s, i as c, n as l, o as u, t as d } from "./opfs-7_GmzQ93.js";
|
|
5
|
+
//#region src/lib/fs/hybrid.ts
|
|
6
|
+
var f = /* @__PURE__ */ e({
|
|
7
|
+
adopt: () => F,
|
|
8
|
+
adoptable: () => I,
|
|
9
|
+
available: () => te,
|
|
10
|
+
list: () => ie,
|
|
11
|
+
onConflict: () => N,
|
|
12
|
+
pending: () => D,
|
|
13
|
+
pendingDeletes: () => O,
|
|
14
|
+
pull: () => ce,
|
|
15
|
+
readFile: () => ae,
|
|
16
|
+
remove: () => se,
|
|
17
|
+
replicating: () => k,
|
|
18
|
+
writeFile: () => oe
|
|
19
|
+
}), ee, p = async () => await (ee ??= d().catch(() => !1)) ? !0 : (ee = void 0, !1), m = () => r().catch(() => !1), te = async () => await p() || await m(), h = "fkn:fs:pending", g = "fkn:fs:pending-delete", _ = "fkn:fs:adopt-declined", v = !0, y = /* @__PURE__ */ new Map(), b = (e) => {
|
|
20
|
+
try {
|
|
21
|
+
let t = localStorage.getItem(e);
|
|
22
|
+
if (!t) return {};
|
|
23
|
+
let n = JSON.parse(t);
|
|
24
|
+
return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
|
|
25
|
+
} catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}, x = (e, t) => {
|
|
29
|
+
try {
|
|
30
|
+
Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
|
|
31
|
+
} catch {}
|
|
32
|
+
}, S = () => b(h), C = (e) => {
|
|
33
|
+
let t = S();
|
|
34
|
+
e in t || (t[e] = y.get(e) ?? null, x(h, t));
|
|
35
|
+
}, w = (e) => {
|
|
36
|
+
let t = S();
|
|
37
|
+
e in t && (delete t[e], x(h, t));
|
|
38
|
+
}, T = () => b(g), ne = (e) => {
|
|
39
|
+
let t = T();
|
|
40
|
+
e in t || (t[e] = y.get(e) ?? null, x(g, t));
|
|
41
|
+
}, E = (e) => {
|
|
42
|
+
let t = T();
|
|
43
|
+
e in t && (delete t[e], x(g, t));
|
|
44
|
+
}, D = () => Object.keys(S()), O = () => Object.keys(T()), k = () => v, A = null, re = null, j = () => re ??= import("./api-CAZo3BT0.js").then((e) => e.n).then((e) => e.apiPromise), ie = async () => {
|
|
45
|
+
me();
|
|
46
|
+
let e = await m(), [t, r] = await Promise.all([p().then((e) => e ? l() : []).catch(() => []), e ? n().then((e) => ({
|
|
47
|
+
ok: !0,
|
|
48
|
+
entries: e
|
|
49
|
+
})).catch(() => ({
|
|
50
|
+
ok: !1,
|
|
51
|
+
entries: []
|
|
52
|
+
})) : Promise.resolve({
|
|
53
|
+
ok: !0,
|
|
54
|
+
entries: []
|
|
55
|
+
})]);
|
|
56
|
+
v = r.ok, r.ok && (y = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
|
|
57
|
+
let i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
58
|
+
let t = Date.parse(e.updatedAt ?? "");
|
|
59
|
+
return Number.isFinite(t) ? t : 0;
|
|
60
|
+
}, o = (e) => {
|
|
61
|
+
let t = i.get(e.path);
|
|
62
|
+
(!t || a(e) >= a(t)) && i.set(e.path, e);
|
|
63
|
+
};
|
|
64
|
+
for (let e of t) o(e);
|
|
65
|
+
for (let e of r.entries) o(e);
|
|
66
|
+
if (r.ok && e) {
|
|
67
|
+
pe(t, r.entries).catch(() => {});
|
|
68
|
+
let e = Object.keys(S()).length || Object.keys(T()).length;
|
|
69
|
+
e && !A ? A = P(!1).catch(() => {}).finally(() => {
|
|
70
|
+
A = null;
|
|
71
|
+
}) : e || R({
|
|
72
|
+
local: t,
|
|
73
|
+
remote: r.entries
|
|
74
|
+
}).catch(() => {});
|
|
75
|
+
}
|
|
76
|
+
return [...i.values()];
|
|
77
|
+
}, ae = async (e) => {
|
|
78
|
+
if (await p()) try {
|
|
79
|
+
return await c(e);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
82
|
+
}
|
|
83
|
+
let t = await i(e);
|
|
84
|
+
return await p() && u(e, t).catch(() => {}), t;
|
|
85
|
+
}, oe = async (e, t, n) => {
|
|
86
|
+
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
87
|
+
if (await p()) {
|
|
88
|
+
if (await u(e, r, n), !await m()) return;
|
|
89
|
+
if (!v) {
|
|
90
|
+
C(e);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
o(e, r, n).then(() => w(e)).catch((t) => {
|
|
94
|
+
C(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (await m()) return o(e, r, n);
|
|
99
|
+
throw Error("fs: no storage backend available");
|
|
100
|
+
}, se = async (e) => {
|
|
101
|
+
let t = [];
|
|
102
|
+
await p() && t.push(s(e).catch(() => {}));
|
|
103
|
+
let n = await m();
|
|
104
|
+
if (n && t.push(a(e).then(() => E(e)).catch((t) => {
|
|
105
|
+
ne(e), console.warn("fs: cloud delete failed, queued for retry", t);
|
|
106
|
+
})), !t.length) throw Error("fs: no storage backend available");
|
|
107
|
+
n && w(e), await Promise.all(t);
|
|
108
|
+
}, ce = async (e) => {
|
|
109
|
+
let t = await i(e);
|
|
110
|
+
return await p() && await u(e, t), t;
|
|
111
|
+
}, M = null, N = (e) => (M = e, () => {
|
|
112
|
+
M === e && (M = null);
|
|
113
|
+
}), le = async (e) => (await j()).cloud.fs.promptConflict({
|
|
114
|
+
path: e.path,
|
|
115
|
+
local: e.local,
|
|
116
|
+
cloud: e.cloud
|
|
117
|
+
}).catch(() => null), ue = async (e) => {
|
|
118
|
+
if (M) try {
|
|
119
|
+
return await M(e);
|
|
120
|
+
} catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return le(e);
|
|
124
|
+
}, P = async (e) => {
|
|
125
|
+
let t = {
|
|
126
|
+
uploaded: [],
|
|
127
|
+
kept: [],
|
|
128
|
+
resolved: [],
|
|
129
|
+
unresolved: [],
|
|
130
|
+
deleted: [],
|
|
131
|
+
failed: []
|
|
132
|
+
};
|
|
133
|
+
if (!await m()) throw Error("fs: this needs a signed-in account");
|
|
134
|
+
if (!await p()) return t;
|
|
135
|
+
let [r, s] = await Promise.all([l(), n()]), d = new Map(s.map((e) => [e.path, e])), f = S();
|
|
136
|
+
for (let [e, n] of Object.entries(T())) {
|
|
137
|
+
let i = d.get(e);
|
|
138
|
+
if (!i) {
|
|
139
|
+
E(e);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (r.some((t) => t.path === e)) {
|
|
143
|
+
E(e);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (i.updatedAt !== n) {
|
|
147
|
+
E(e);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
await a(e), E(e), t.deleted.push(e);
|
|
152
|
+
} catch (n) {
|
|
153
|
+
t.failed.push({
|
|
154
|
+
path: e,
|
|
155
|
+
error: n instanceof Error ? n.message : String(n)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (let n of r) {
|
|
160
|
+
let r = d.get(n.path), a = n.path in f;
|
|
161
|
+
if (!a && (r || !e)) {
|
|
162
|
+
r && t.kept.push(n.path);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (a && r && r.updatedAt !== f[n.path]) {
|
|
166
|
+
let e = await ue({
|
|
167
|
+
path: n.path,
|
|
168
|
+
local: {
|
|
169
|
+
size: n.size,
|
|
170
|
+
updatedAt: n.updatedAt
|
|
171
|
+
},
|
|
172
|
+
cloud: {
|
|
173
|
+
size: r.size,
|
|
174
|
+
updatedAt: r.updatedAt
|
|
175
|
+
},
|
|
176
|
+
readLocal: () => c(n.path),
|
|
177
|
+
readCloud: () => i(n.path)
|
|
178
|
+
});
|
|
179
|
+
if (!e) {
|
|
180
|
+
t.unresolved.push(n.path);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
if (e === "cloud") await u(n.path, await i(n.path));
|
|
185
|
+
else {
|
|
186
|
+
let t = e === "local" ? await c(n.path) : e.merged;
|
|
187
|
+
await o(n.path, t, n.contentType ? { contentType: n.contentType } : void 0), e !== "local" && await u(n.path, t);
|
|
188
|
+
}
|
|
189
|
+
w(n.path), t.resolved.push({
|
|
190
|
+
path: n.path,
|
|
191
|
+
choice: e === "local" || e === "cloud" ? e : "merged"
|
|
192
|
+
});
|
|
193
|
+
} catch (e) {
|
|
194
|
+
if (e?.code === "FKN_E2E_LOCKED") throw e;
|
|
195
|
+
t.failed.push({
|
|
196
|
+
path: n.path,
|
|
197
|
+
error: e instanceof Error ? e.message : String(e)
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
let e = await c(n.path);
|
|
204
|
+
await o(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), w(n.path), t.uploaded.push(n.path);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
if (C(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
207
|
+
t.failed.push({
|
|
208
|
+
path: n.path,
|
|
209
|
+
error: e instanceof Error ? e.message : String(e)
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return t;
|
|
214
|
+
}, F = () => P(!0), I = async () => {
|
|
215
|
+
if (!await m() || !await p()) return {
|
|
216
|
+
paths: [],
|
|
217
|
+
bytes: 0
|
|
218
|
+
};
|
|
219
|
+
let [e, t] = await Promise.all([l(), n()]), r = new Set(t.map((e) => e.path)), i = e.filter((e) => !r.has(e.path));
|
|
220
|
+
return {
|
|
221
|
+
paths: i.map((e) => e.path),
|
|
222
|
+
bytes: i.reduce((e, t) => e + t.size, 0)
|
|
223
|
+
};
|
|
224
|
+
}, de = () => new Set(Object.keys(b(_))), fe = (e) => {
|
|
225
|
+
let t = b(_);
|
|
226
|
+
for (let n of e) t[n] = null;
|
|
227
|
+
x(_, t);
|
|
228
|
+
}, L = null, R = (e) => L || (L = (async () => {
|
|
229
|
+
if (!await m()) return;
|
|
230
|
+
let t = e ?? (await p() ? {
|
|
231
|
+
local: await l(),
|
|
232
|
+
remote: await n()
|
|
233
|
+
} : null);
|
|
234
|
+
if (!t) return;
|
|
235
|
+
let r = new Set(t.remote.map((e) => e.path)), i = de(), a = t.local.filter((e) => !r.has(e.path) && !i.has(e.path));
|
|
236
|
+
if (!a.length) return;
|
|
237
|
+
let o = await j(), s = a.reduce((e, t) => e + t.size, 0);
|
|
238
|
+
if (!await o.cloud.fs.promptAdopt({
|
|
239
|
+
files: a.length,
|
|
240
|
+
bytes: s
|
|
241
|
+
}).catch(() => !1)) {
|
|
242
|
+
fe(a.map((e) => e.path));
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
await F();
|
|
246
|
+
})().catch(() => {}).finally(() => {
|
|
247
|
+
L = null;
|
|
248
|
+
}), L), pe = async (e, t) => {
|
|
249
|
+
let n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path)), i = await j(), a = async () => {
|
|
250
|
+
await F().catch(() => {});
|
|
251
|
+
let e = await I().catch(() => ({
|
|
252
|
+
paths: [],
|
|
253
|
+
bytes: 0
|
|
254
|
+
}));
|
|
255
|
+
await i.cloud.fs.setAdoptSource({
|
|
256
|
+
files: e.paths.length,
|
|
257
|
+
bytes: e.bytes
|
|
258
|
+
}, a).catch(() => {});
|
|
259
|
+
};
|
|
260
|
+
await i.cloud.fs.setAdoptSource({
|
|
261
|
+
files: r.length,
|
|
262
|
+
bytes: r.reduce((e, t) => e + t.size, 0)
|
|
263
|
+
}, a);
|
|
264
|
+
}, z = !1, me = () => {
|
|
265
|
+
z || typeof window > "u" || (z = !0, import("./account.js").then((e) => e.onChange(() => {
|
|
266
|
+
R().catch(() => {});
|
|
267
|
+
})).catch(() => {}));
|
|
268
|
+
}, he = /* @__PURE__ */ e({
|
|
269
|
+
adopt: () => J,
|
|
270
|
+
adoptable: () => Y,
|
|
271
|
+
appendFile: () => Ee,
|
|
272
|
+
appendFileSync: () => W,
|
|
273
|
+
available: () => V,
|
|
274
|
+
default: () => Le,
|
|
275
|
+
exists: () => Ne,
|
|
276
|
+
existsSync: () => G,
|
|
277
|
+
flush: () => Fe,
|
|
278
|
+
lstatSync: () => _e,
|
|
279
|
+
mkdir: () => ke,
|
|
280
|
+
mkdirSync: () => ye,
|
|
281
|
+
mount: () => K,
|
|
282
|
+
onConflict: () => $,
|
|
283
|
+
pending: () => X,
|
|
284
|
+
pendingDeletes: () => Z,
|
|
285
|
+
promises: () => Pe,
|
|
286
|
+
pull: () => q,
|
|
287
|
+
readFile: () => we,
|
|
288
|
+
readFileSync: () => H,
|
|
289
|
+
readdir: () => Oe,
|
|
290
|
+
readdirSync: () => ve,
|
|
291
|
+
remount: () => Ie,
|
|
292
|
+
rename: () => Me,
|
|
293
|
+
renameSync: () => Ce,
|
|
294
|
+
replicating: () => Q,
|
|
295
|
+
rm: () => Ae,
|
|
296
|
+
rmSync: () => be,
|
|
297
|
+
rmdirSync: () => xe,
|
|
298
|
+
stat: () => De,
|
|
299
|
+
statSync: () => ge,
|
|
300
|
+
unlink: () => je,
|
|
301
|
+
unlinkSync: () => Se,
|
|
302
|
+
writeFile: () => Te,
|
|
303
|
+
writeFileSync: () => U
|
|
304
|
+
}), B = t(f, { memfs: !0 }), { available: V, readFileSync: H, writeFileSync: U, appendFileSync: W, existsSync: G, statSync: ge, lstatSync: _e, readdirSync: ve, mkdirSync: ye, rmSync: be, rmdirSync: xe, unlinkSync: Se, renameSync: Ce, readFile: we, writeFile: Te, appendFile: Ee, stat: De, readdir: Oe, mkdir: ke, rm: Ae, unlink: je, rename: Me, exists: Ne, promises: Pe, mount: K, flush: Fe, remount: Ie } = B, q = ce, J = F, Y = I, X = D, Z = O, Q = k, $ = N, Le = {
|
|
305
|
+
...B,
|
|
306
|
+
pull: q,
|
|
307
|
+
adopt: J,
|
|
308
|
+
adoptable: Y,
|
|
309
|
+
pending: X,
|
|
310
|
+
pendingDeletes: Z,
|
|
311
|
+
replicating: Q,
|
|
312
|
+
onConflict: $
|
|
313
|
+
};
|
|
314
|
+
//#endregion
|
|
315
|
+
export { xe as A, ve as C, Q as D, Ce as E, Te as F, U as I, ge as M, je as N, Ae as O, Se as P, Oe as S, Me as T, Z as _, V as a, we as b, Fe as c, _e as d, ke as f, X as g, $ as h, W as i, De as j, be as k, Le as l, K as m, Y as n, Ne as o, ye as p, Ee as r, G as s, J as t, he as u, Pe as v, Ie as w, H as x, q as y };
|
package/fs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-BrBsBqRz.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;
|
package/fs.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as Stats } from "./index-CJ0vHTcS.js";
|
|
2
|
-
import { A as
|
|
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, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
|
|
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-BIZeEsNu.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 };
|
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,
|
|
2
|
-
export {
|
|
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-_59wCBU2.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 };
|
package/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Socket, t as Server$1 } from "./net
|
|
1
|
+
import { n as Socket, t as Server$1 } from "./net-MbSFrO35.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { Stream } from "stream";
|
|
4
4
|
import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
|
|
@@ -9,6 +9,7 @@ type AdoptSummary = {
|
|
|
9
9
|
choice: 'local' | 'cloud' | 'merged';
|
|
10
10
|
}[];
|
|
11
11
|
unresolved: string[];
|
|
12
|
+
deleted: string[];
|
|
12
13
|
failed: {
|
|
13
14
|
path: string;
|
|
14
15
|
error: string;
|
|
@@ -30,7 +31,7 @@ type ConflictChoice = 'local' | 'cloud' | {
|
|
|
30
31
|
} | null;
|
|
31
32
|
type ConflictResolver = (conflict: FileConflict) => Promise<ConflictChoice> | ConflictChoice;
|
|
32
33
|
declare namespace index_d_exports {
|
|
33
|
-
export { AdoptSummary, ConflictChoice, ConflictResolver, ConflictSide, FileConflict, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
|
|
34
|
+
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 };
|
|
34
35
|
}
|
|
35
36
|
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?: {
|
|
36
37
|
recursive?: boolean;
|
|
@@ -66,6 +67,7 @@ declare const adoptable: () => Promise<{
|
|
|
66
67
|
bytes: number;
|
|
67
68
|
}>;
|
|
68
69
|
declare const pending: () => string[];
|
|
70
|
+
declare const pendingDeletes: () => string[];
|
|
69
71
|
declare const replicating: () => boolean;
|
|
70
72
|
declare const onConflict: (next: ConflictResolver) => (() => void);
|
|
71
73
|
declare const _default: {
|
|
@@ -129,8 +131,9 @@ declare const _default: {
|
|
|
129
131
|
bytes: number;
|
|
130
132
|
}>;
|
|
131
133
|
pending: () => string[];
|
|
134
|
+
pendingDeletes: () => string[];
|
|
132
135
|
replicating: () => boolean;
|
|
133
136
|
onConflict: (next: ConflictResolver) => (() => void);
|
|
134
137
|
};
|
|
135
138
|
//#endregion
|
|
136
|
-
export {
|
|
139
|
+
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 };
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-g2yknq7C.cjs"),t=require("./api-BwrS6P0x.cjs"),n=require("./cloud-BcpPsNs3.cjs"),r=require("./dns.cjs"),i=require("./net-BOyLJ3mh.cjs"),a=require("./dgram-pCNllfov.cjs"),o=require("./http.cjs"),s=require("./extension-CjJNj5Yl.cjs"),c=require("./desktop.cjs"),l=require("./fs-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-g2yknq7C.cjs"),t=require("./api-BwrS6P0x.cjs"),n=require("./cloud-BcpPsNs3.cjs"),r=require("./dns.cjs"),i=require("./net-BOyLJ3mh.cjs"),a=require("./dgram-pCNllfov.cjs"),o=require("./http.cjs"),s=require("./extension-CjJNj5Yl.cjs"),c=require("./desktop.cjs"),l=require("./fs-BrBsBqRz.cjs"),u=require("./opfs.cjs"),d=require("./packages.cjs"),f=require("./account.cjs"),p=require("./connect-button-BBEjXzB3.cjs");let m=require("osra");var h=1e4,g=150,_=()=>new Promise(t=>{if(e.P())return t(!0);let n,r=setTimeout(()=>i(e.P()),h),i=e=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),t(e)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(e.P()),g)},o=new MutationObserver(()=>{e.P()&&i(!0)}),s=()=>{document.readyState===`complete`&&!e.P()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),v=async t=>s.r()||t.lockdown||!n.a()||await _()?e.a(t):n.i(t),y=`https://fkn.app`,b=(e,n)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);if(!t.i?.contentWindow)throw Error(`FKN @fkn/lib: relayWorker called before the FKN iframe was injected`);(0,m.relay)({receive:window,emit:t.i.contentWindow},e,{key:`fkn-api`,originA:n?.originA??y,originB:n?.originB??`*`,unregisterSignal:n?.unregisterSignal})},x=async()=>typeof window>`u`?!1:(await t.t).connect.prompt(location.origin).catch(()=>!1),S=async()=>typeof window>`u`?null:(await t.t).relay.prompt().catch(()=>null);exports.ATTACH_FRAME_EVENT_KEY=e.i,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return f.t}}),exports.assertAttachableFrameUrl=e.l,exports.assertFetchableUrl=e.E,exports.assertLockdownApplicable=e.u,exports.attachFrame=v,exports.attachFramePermission=e.o,exports.box=e.R,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return n.n}}),exports.connect=x,exports.connectButtonUrl=p.t,exports.cookies=e.w,exports.createFrame=e.s,exports.createVideoElementHandle=e.z,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return c.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return s.t}}),exports.fetch=s.n,exports.fetchCredentialedPermission=e.O,exports.fetchLocalPermission=e.k,exports.fetchPermission=e.A,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return l.u}}),exports.gotoPermission=e.c,exports.handleRevivableModules=e.L,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),exports.isBlockedFetchUrl=e.j,exports.isBlockedFrameUrl=e.d,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.M,exports.isType=e.B,exports.modifyRequestHeadersPermission=e.x,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return d.t}}),exports.permissions=e.r,exports.promptInstall=s.i,exports.promptRelay=S,exports.readCookiePermission=e.T,exports.relayWorker=b,exports.removeRequestHeaderRule=e.S,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.C,exports.type=e.H,exports.waitForExtensionExposure=e.I;
|
package/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as account_d_exports } from "./account.js";
|
|
2
2
|
import { m as packages_d_exports } from "./packages-CErlrrLB.js";
|
|
3
|
-
import { n as cloud_d_exports } from "./cloud-
|
|
3
|
+
import { n as cloud_d_exports } from "./cloud-CzMjj2Ne.js";
|
|
4
4
|
import { A as RequestHeaderRule, B as assertFetchableUrl, C as attachFramePermission, D as assertLockdownApplicable, E as assertAttachableFrameUrl, F as SiteCookie, G as isBlockedFetchUrl, H as fetchCredentialedPermission, I as cookies, K as isLocalNetworkUrl, L as readCookiePermission, M as removeRequestHeaderRule, N as setRequestHeaderRule, O as isBlockedFrameUrl, P as CookieDetails, R as FetchInit, S as GotoOptions, T as gotoPermission, U as fetchLocalPermission, W as fetchPermission, _ as ATTACH_FRAME_EVENT_KEY, a as handleRevivableModules, b as Frame, c as VideoElementState, d as isType, f as revive, g as permissions, h as PermissionRequest, i as waitForExtensionExposure, j as modifyRequestHeadersPermission, k as HeaderOperation, l as box, m as PermissionGrant, n as isExtensionExposed, o as BoxedVideoElement, p as type, r as setMissingExtensionHandler, s as RemoteVideoElement, u as createVideoElementHandle, w as createFrame, x as FrameBackend, y as AttachFrameOptions, z as ProxyFetchRequest } from "./index-BJztAQIP.js";
|
|
5
5
|
import { t as dns_d_exports } from "./dns.js";
|
|
6
|
-
import { s as net_d_exports } from "./net
|
|
6
|
+
import { s as net_d_exports } from "./net-MbSFrO35.js";
|
|
7
7
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
8
8
|
import { t as http_d_exports } from "./http.js";
|
|
9
9
|
import { t as desktop_d_exports } from "./desktop.js";
|
|
10
10
|
import { i as promptInstall, n as fetch, t as extension_d_exports } from "./extension-3pxUYwrA.js";
|
|
11
|
-
import { u as index_d_exports } from "./index-
|
|
11
|
+
import { u as index_d_exports } from "./index-BIZeEsNu.js";
|
|
12
12
|
import { t as index_d_exports$1 } from "./opfs.js";
|
|
13
13
|
import { t as connectButtonUrl } from "./connect-button-D8KXSL6s.js";
|
|
14
14
|
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { i as F } from "./dgram-C1yYxLEI.js";
|
|
|
7
7
|
import { t as I } from "./http.js";
|
|
8
8
|
import { i as L, n as R, r as z, t as B } from "./extension-Qs02HPzR.js";
|
|
9
9
|
import { t as V } from "./desktop.js";
|
|
10
|
-
import { u as H } from "./fs-
|
|
10
|
+
import { u as H } from "./fs-_59wCBU2.js";
|
|
11
11
|
import { t as U } from "./opfs.js";
|
|
12
12
|
import { t as W } from "./packages.js";
|
|
13
13
|
import { t as G } from "./account.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-
|
|
1
|
+
import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-BFqrrvzI.js";
|
|
2
2
|
import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
|
|
3
3
|
import { DuplexOptions, Stream } from "stream";
|
|
4
4
|
import { EventEmitter } from "events";
|
package/net.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net
|
|
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-MbSFrO35.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
package/package.json
CHANGED
package/fs-B8Rc1zRI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./node-fs-BMR2yCEt.cjs"),n=require("./storage-C1BT8jwJ.cjs"),r=require("./opfs-uClkgnb5.cjs");var i=e.n({adopt:()=>S,adoptable:()=>C,available:()=>c,list:()=>te,onConflict:()=>oe,pending:()=>ee,pull:()=>ae,readFile:()=>ne,remove:()=>ie,replicating:()=>v,writeFile:()=>re}),a,o=async()=>await(a??=r.t().catch(()=>!1))?!0:(a=void 0,!1),s=()=>n.n().catch(()=>!1),c=async()=>await o()||await s(),l=`fkn:fs:pending`,u=`fkn:fs:adopt-declined`,d=!0,f=new Map,p=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{}}},m=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},h=()=>p(l),g=e=>{let t=h();e in t||(t[e]=f.get(e)??null,m(l,t))},_=e=>{let t=h();e in t&&(delete t[e],m(l,t))},ee=()=>Object.keys(h()),v=()=>d,y=null,te=async()=>{de();let e=await s(),[t,i]=await Promise.all([o().then(e=>e?r.n():[]).catch(()=>[]),e?n.i().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:!0,entries:[]})]);d=i.ok,i.ok&&(f=new Map(i.entries.map(e=>[e.path,e.updatedAt])));let a=new Map,c=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},l=e=>{let t=a.get(e.path);(!t||c(e)>=c(t))&&a.set(e.path,e)};for(let e of t)l(e);for(let e of i.entries)l(e);return i.ok&&e&&!y&&(Object.keys(h()).length?y=x(!1).catch(()=>{}).finally(()=>{y=null}):T({local:t,remote:i.entries}).catch(()=>{})),[...a.values()]},ne=async e=>{if(await o())try{return await r.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await n.o(e);return await o()&&r.o(e,t).catch(()=>{}),t},re=async(e,t,i)=>{let a=t instanceof Blob?t:new Blob([t],i?.contentType?{type:i.contentType}:void 0);if(await o()){if(await r.o(e,a,i),!await s())return;if(!d){g(e);return}n.u(e,a,i).then(()=>_(e)).catch(t=>{g(e),console.warn(`fs: cloud replicate failed, queued for adopt()`,t)});return}if(await s())return n.u(e,a,i);throw Error(`fs: no storage backend available`)},ie=async e=>{let t=[];if(await o()&&t.push(r.a(e).catch(()=>{})),await s()&&t.push(n.s(e).catch(()=>{})),!t.length)throw Error(`fs: no storage backend available`);await Promise.all(t)},ae=async e=>{let t=await n.o(e);return await o()&&await r.o(e,t),t},b=null,oe=e=>(b=e,()=>{b===e&&(b=null)}),se=async e=>{let{apiPromise:t}=await Promise.resolve().then(()=>require("./api-BwrS6P0x.cjs")).then(e=>e.n);return(await t).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null)},ce=async e=>{if(b)try{return await b(e)}catch{return null}return se(e)},x=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],failed:[]};if(!await s())throw Error(`fs: this needs a signed-in account`);if(!await o())return t;let[i,a]=await Promise.all([r.n(),n.i()]),c=new Map(a.map(e=>[e.path,e])),l=h();for(let a of i){let i=c.get(a.path),o=a.path in l;if(!o&&(i||!e)){i&&t.kept.push(a.path);continue}if(o&&i&&i.updatedAt!==l[a.path]){let e=await ce({path:a.path,local:{size:a.size,updatedAt:a.updatedAt},cloud:{size:i.size,updatedAt:i.updatedAt},readLocal:()=>r.i(a.path),readCloud:()=>n.o(a.path)});if(!e){t.unresolved.push(a.path);continue}try{if(e===`cloud`)await r.o(a.path,await n.o(a.path));else{let t=e===`local`?await r.i(a.path):e.merged;await n.u(a.path,t,a.contentType?{contentType:a.contentType}:void 0),e!==`local`&&await r.o(a.path,t)}_(a.path),t.resolved.push({path:a.path,choice:e===`local`||e===`cloud`?e:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await r.i(a.path);await n.u(a.path,e,a.contentType?{contentType:a.contentType}:void 0),_(a.path),t.uploaded.push(a.path)}catch(e){if(g(a.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}}return t},S=()=>x(!0),C=async()=>{if(!await s()||!await o())return{paths:[],bytes:0};let[e,t]=await Promise.all([r.n(),n.i()]),i=new Set(t.map(e=>e.path)),a=e.filter(e=>!i.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},le=()=>new Set(Object.keys(p(u))),ue=e=>{let t=p(u);for(let n of e)t[n]=null;m(u,t)},w=null,T=e=>w||(w=(async()=>{if(!await s())return;let t=e??(await o()?{local:await r.n(),remote:await n.i()}:null);if(!t)return;let i=new Set(t.remote.map(e=>e.path)),a=le(),c=t.local.filter(e=>!i.has(e.path)&&!a.has(e.path));if(!c.length)return;let{apiPromise:l}=await Promise.resolve().then(()=>require("./api-BwrS6P0x.cjs")).then(e=>e.n),u=await l,d=c.reduce((e,t)=>e+t.size,0);if(!await u.cloud.fs.promptAdopt({files:c.length,bytes:d}).catch(()=>!1)){ue(c.map(e=>e.path));return}await S()})().catch(()=>{}).finally(()=>{w=null}),w),E=!1,de=()=>{E||typeof window>`u`||(E=!0,Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{T().catch(()=>{})})).catch(()=>{}))},fe=e.n({adopt:()=>J,adoptable:()=>Y,appendFile:()=>H,appendFileSync:()=>j,available:()=>O,default:()=>$,exists:()=>_e,existsSync:()=>M,flush:()=>be,lstatSync:()=>P,mkdir:()=>G,mkdirSync:()=>F,mount:()=>ye,onConflict:()=>Q,pending:()=>X,promises:()=>ve,pull:()=>q,readFile:()=>B,readFileSync:()=>k,readdir:()=>W,readdirSync:()=>pe,remount:()=>K,rename:()=>ge,renameSync:()=>z,replicating:()=>Z,rm:()=>me,rmSync:()=>I,rmdirSync:()=>L,stat:()=>U,statSync:()=>N,unlink:()=>he,unlinkSync:()=>R,writeFile:()=>V,writeFileSync:()=>A}),D=t.t(i,{memfs:!0}),{available:O,readFileSync:k,writeFileSync:A,appendFileSync:j,existsSync:M,statSync:N,lstatSync:P,readdirSync:pe,mkdirSync:F,rmSync:I,rmdirSync:L,unlinkSync:R,renameSync:z,readFile:B,writeFile:V,appendFile:H,stat:U,readdir:W,mkdir:G,rm:me,unlink:he,rename:ge,exists:_e,promises:ve,mount:ye,flush:be,remount:K}=D,q=ae,J=S,Y=C,X=ee,Z=v,Q=oe,$={...D,pull:q,adopt:J,adoptable:Y,pending:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return B}});
|
package/fs-CvCcDnzN.js
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
|
-
import { t } from "./node-fs-DKfokOlh.js";
|
|
3
|
-
import { i as n, n as r, o as i, s as a, u as o } from "./storage-InqJHrkf.js";
|
|
4
|
-
import { a as s, i as c, n as l, o as u, t as d } from "./opfs-7_GmzQ93.js";
|
|
5
|
-
//#region src/lib/fs/hybrid.ts
|
|
6
|
-
var ee = /* @__PURE__ */ e({
|
|
7
|
-
adopt: () => O,
|
|
8
|
-
adoptable: () => k,
|
|
9
|
-
available: () => ne,
|
|
10
|
-
list: () => ae,
|
|
11
|
-
onConflict: () => E,
|
|
12
|
-
pending: () => re,
|
|
13
|
-
pull: () => w,
|
|
14
|
-
readFile: () => oe,
|
|
15
|
-
remove: () => ce,
|
|
16
|
-
replicating: () => ie,
|
|
17
|
-
writeFile: () => se
|
|
18
|
-
}), te, f = async () => await (te ??= d().catch(() => !1)) ? !0 : (te = void 0, !1), p = () => r().catch(() => !1), ne = async () => await f() || await p(), m = "fkn:fs:pending", h = "fkn:fs:adopt-declined", g = !0, _ = /* @__PURE__ */ new Map(), v = (e) => {
|
|
19
|
-
try {
|
|
20
|
-
let t = localStorage.getItem(e);
|
|
21
|
-
if (!t) return {};
|
|
22
|
-
let n = JSON.parse(t);
|
|
23
|
-
return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
|
|
24
|
-
} catch {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
}, y = (e, t) => {
|
|
28
|
-
try {
|
|
29
|
-
Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
|
|
30
|
-
} catch {}
|
|
31
|
-
}, b = () => v(m), x = (e) => {
|
|
32
|
-
let t = b();
|
|
33
|
-
e in t || (t[e] = _.get(e) ?? null, y(m, t));
|
|
34
|
-
}, S = (e) => {
|
|
35
|
-
let t = b();
|
|
36
|
-
e in t && (delete t[e], y(m, t));
|
|
37
|
-
}, re = () => Object.keys(b()), ie = () => g, C = null, ae = async () => {
|
|
38
|
-
pe();
|
|
39
|
-
let e = await p(), [t, r] = await Promise.all([f().then((e) => e ? l() : []).catch(() => []), e ? n().then((e) => ({
|
|
40
|
-
ok: !0,
|
|
41
|
-
entries: e
|
|
42
|
-
})).catch(() => ({
|
|
43
|
-
ok: !1,
|
|
44
|
-
entries: []
|
|
45
|
-
})) : Promise.resolve({
|
|
46
|
-
ok: !0,
|
|
47
|
-
entries: []
|
|
48
|
-
})]);
|
|
49
|
-
g = r.ok, r.ok && (_ = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
|
|
50
|
-
let i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
51
|
-
let t = Date.parse(e.updatedAt ?? "");
|
|
52
|
-
return Number.isFinite(t) ? t : 0;
|
|
53
|
-
}, o = (e) => {
|
|
54
|
-
let t = i.get(e.path);
|
|
55
|
-
(!t || a(e) >= a(t)) && i.set(e.path, e);
|
|
56
|
-
};
|
|
57
|
-
for (let e of t) o(e);
|
|
58
|
-
for (let e of r.entries) o(e);
|
|
59
|
-
return r.ok && e && !C && (Object.keys(b()).length ? C = D(!1).catch(() => {}).finally(() => {
|
|
60
|
-
C = null;
|
|
61
|
-
}) : j({
|
|
62
|
-
local: t,
|
|
63
|
-
remote: r.entries
|
|
64
|
-
}).catch(() => {})), [...i.values()];
|
|
65
|
-
}, oe = async (e) => {
|
|
66
|
-
if (await f()) try {
|
|
67
|
-
return await c(e);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
if (e?.name !== "NotFoundError") throw e;
|
|
70
|
-
}
|
|
71
|
-
let t = await i(e);
|
|
72
|
-
return await f() && u(e, t).catch(() => {}), t;
|
|
73
|
-
}, se = async (e, t, n) => {
|
|
74
|
-
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
75
|
-
if (await f()) {
|
|
76
|
-
if (await u(e, r, n), !await p()) return;
|
|
77
|
-
if (!g) {
|
|
78
|
-
x(e);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
o(e, r, n).then(() => S(e)).catch((t) => {
|
|
82
|
-
x(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (await p()) return o(e, r, n);
|
|
87
|
-
throw Error("fs: no storage backend available");
|
|
88
|
-
}, ce = async (e) => {
|
|
89
|
-
let t = [];
|
|
90
|
-
if (await f() && t.push(s(e).catch(() => {})), await p() && t.push(a(e).catch(() => {})), !t.length) throw Error("fs: no storage backend available");
|
|
91
|
-
await Promise.all(t);
|
|
92
|
-
}, w = async (e) => {
|
|
93
|
-
let t = await i(e);
|
|
94
|
-
return await f() && await u(e, t), t;
|
|
95
|
-
}, T = null, E = (e) => (T = e, () => {
|
|
96
|
-
T === e && (T = null);
|
|
97
|
-
}), le = async (e) => {
|
|
98
|
-
let { apiPromise: t } = await import("./api-CAZo3BT0.js").then((e) => e.n);
|
|
99
|
-
return (await t).cloud.fs.promptConflict({
|
|
100
|
-
path: e.path,
|
|
101
|
-
local: e.local,
|
|
102
|
-
cloud: e.cloud
|
|
103
|
-
}).catch(() => null);
|
|
104
|
-
}, ue = async (e) => {
|
|
105
|
-
if (T) try {
|
|
106
|
-
return await T(e);
|
|
107
|
-
} catch {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return le(e);
|
|
111
|
-
}, D = async (e) => {
|
|
112
|
-
let t = {
|
|
113
|
-
uploaded: [],
|
|
114
|
-
kept: [],
|
|
115
|
-
resolved: [],
|
|
116
|
-
unresolved: [],
|
|
117
|
-
failed: []
|
|
118
|
-
};
|
|
119
|
-
if (!await p()) throw Error("fs: this needs a signed-in account");
|
|
120
|
-
if (!await f()) return t;
|
|
121
|
-
let [r, a] = await Promise.all([l(), n()]), s = new Map(a.map((e) => [e.path, e])), d = b();
|
|
122
|
-
for (let n of r) {
|
|
123
|
-
let r = s.get(n.path), a = n.path in d;
|
|
124
|
-
if (!a && (r || !e)) {
|
|
125
|
-
r && t.kept.push(n.path);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (a && r && r.updatedAt !== d[n.path]) {
|
|
129
|
-
let e = await ue({
|
|
130
|
-
path: n.path,
|
|
131
|
-
local: {
|
|
132
|
-
size: n.size,
|
|
133
|
-
updatedAt: n.updatedAt
|
|
134
|
-
},
|
|
135
|
-
cloud: {
|
|
136
|
-
size: r.size,
|
|
137
|
-
updatedAt: r.updatedAt
|
|
138
|
-
},
|
|
139
|
-
readLocal: () => c(n.path),
|
|
140
|
-
readCloud: () => i(n.path)
|
|
141
|
-
});
|
|
142
|
-
if (!e) {
|
|
143
|
-
t.unresolved.push(n.path);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
try {
|
|
147
|
-
if (e === "cloud") await u(n.path, await i(n.path));
|
|
148
|
-
else {
|
|
149
|
-
let t = e === "local" ? await c(n.path) : e.merged;
|
|
150
|
-
await o(n.path, t, n.contentType ? { contentType: n.contentType } : void 0), e !== "local" && await u(n.path, t);
|
|
151
|
-
}
|
|
152
|
-
S(n.path), t.resolved.push({
|
|
153
|
-
path: n.path,
|
|
154
|
-
choice: e === "local" || e === "cloud" ? e : "merged"
|
|
155
|
-
});
|
|
156
|
-
} catch (e) {
|
|
157
|
-
if (e?.code === "FKN_E2E_LOCKED") throw e;
|
|
158
|
-
t.failed.push({
|
|
159
|
-
path: n.path,
|
|
160
|
-
error: e instanceof Error ? e.message : String(e)
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
try {
|
|
166
|
-
let e = await c(n.path);
|
|
167
|
-
await o(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), S(n.path), t.uploaded.push(n.path);
|
|
168
|
-
} catch (e) {
|
|
169
|
-
if (x(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
170
|
-
t.failed.push({
|
|
171
|
-
path: n.path,
|
|
172
|
-
error: e instanceof Error ? e.message : String(e)
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return t;
|
|
177
|
-
}, O = () => D(!0), k = async () => {
|
|
178
|
-
if (!await p() || !await f()) return {
|
|
179
|
-
paths: [],
|
|
180
|
-
bytes: 0
|
|
181
|
-
};
|
|
182
|
-
let [e, t] = await Promise.all([l(), n()]), r = new Set(t.map((e) => e.path)), i = e.filter((e) => !r.has(e.path));
|
|
183
|
-
return {
|
|
184
|
-
paths: i.map((e) => e.path),
|
|
185
|
-
bytes: i.reduce((e, t) => e + t.size, 0)
|
|
186
|
-
};
|
|
187
|
-
}, de = () => new Set(Object.keys(v(h))), fe = (e) => {
|
|
188
|
-
let t = v(h);
|
|
189
|
-
for (let n of e) t[n] = null;
|
|
190
|
-
y(h, t);
|
|
191
|
-
}, A = null, j = (e) => A || (A = (async () => {
|
|
192
|
-
if (!await p()) return;
|
|
193
|
-
let t = e ?? (await f() ? {
|
|
194
|
-
local: await l(),
|
|
195
|
-
remote: await n()
|
|
196
|
-
} : null);
|
|
197
|
-
if (!t) return;
|
|
198
|
-
let r = new Set(t.remote.map((e) => e.path)), i = de(), a = t.local.filter((e) => !r.has(e.path) && !i.has(e.path));
|
|
199
|
-
if (!a.length) return;
|
|
200
|
-
let { apiPromise: o } = await import("./api-CAZo3BT0.js").then((e) => e.n), s = await o, c = a.reduce((e, t) => e + t.size, 0);
|
|
201
|
-
if (!await s.cloud.fs.promptAdopt({
|
|
202
|
-
files: a.length,
|
|
203
|
-
bytes: c
|
|
204
|
-
}).catch(() => !1)) {
|
|
205
|
-
fe(a.map((e) => e.path));
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
await O();
|
|
209
|
-
})().catch(() => {}).finally(() => {
|
|
210
|
-
A = null;
|
|
211
|
-
}), A), M = !1, pe = () => {
|
|
212
|
-
M || typeof window > "u" || (M = !0, import("./account.js").then((e) => e.onChange(() => {
|
|
213
|
-
j().catch(() => {});
|
|
214
|
-
})).catch(() => {}));
|
|
215
|
-
}, me = /* @__PURE__ */ e({
|
|
216
|
-
adopt: () => J,
|
|
217
|
-
adoptable: () => Y,
|
|
218
|
-
appendFile: () => ve,
|
|
219
|
-
appendFileSync: () => L,
|
|
220
|
-
available: () => P,
|
|
221
|
-
default: () => $,
|
|
222
|
-
exists: () => Te,
|
|
223
|
-
existsSync: () => R,
|
|
224
|
-
flush: () => K,
|
|
225
|
-
lstatSync: () => B,
|
|
226
|
-
mkdir: () => xe,
|
|
227
|
-
mkdirSync: () => he,
|
|
228
|
-
mount: () => De,
|
|
229
|
-
onConflict: () => Q,
|
|
230
|
-
pending: () => X,
|
|
231
|
-
promises: () => Ee,
|
|
232
|
-
pull: () => q,
|
|
233
|
-
readFile: () => ge,
|
|
234
|
-
readFileSync: () => F,
|
|
235
|
-
readdir: () => be,
|
|
236
|
-
readdirSync: () => V,
|
|
237
|
-
remount: () => Oe,
|
|
238
|
-
rename: () => we,
|
|
239
|
-
renameSync: () => G,
|
|
240
|
-
replicating: () => Z,
|
|
241
|
-
rm: () => Se,
|
|
242
|
-
rmSync: () => H,
|
|
243
|
-
rmdirSync: () => U,
|
|
244
|
-
stat: () => ye,
|
|
245
|
-
statSync: () => z,
|
|
246
|
-
unlink: () => Ce,
|
|
247
|
-
unlinkSync: () => W,
|
|
248
|
-
writeFile: () => _e,
|
|
249
|
-
writeFileSync: () => I
|
|
250
|
-
}), N = t(ee, { memfs: !0 }), { available: P, readFileSync: F, writeFileSync: I, appendFileSync: L, existsSync: R, statSync: z, lstatSync: B, readdirSync: V, mkdirSync: he, rmSync: H, rmdirSync: U, unlinkSync: W, renameSync: G, readFile: ge, writeFile: _e, appendFile: ve, stat: ye, readdir: be, mkdir: xe, rm: Se, unlink: Ce, rename: we, exists: Te, promises: Ee, mount: De, flush: K, remount: Oe } = N, q = w, J = O, Y = k, X = re, Z = ie, Q = E, $ = {
|
|
251
|
-
...N,
|
|
252
|
-
pull: q,
|
|
253
|
-
adopt: J,
|
|
254
|
-
adoptable: Y,
|
|
255
|
-
pending: X,
|
|
256
|
-
replicating: Z,
|
|
257
|
-
onConflict: Q
|
|
258
|
-
};
|
|
259
|
-
//#endregion
|
|
260
|
-
export { ye as A, Oe as C, Se as D, Z as E, I as F, Ce as M, W as N, H as O, _e as P, V as S, G as T, Ee as _, P as a, F as b, K as c, B as d, xe as f, X as g, Q as h, L as i, z as j, U as k, $ as l, De as m, Y as n, Te as o, he as p, ve as r, R as s, J as t, me as u, q as v, we as w, be as x, ge as y };
|