@fkn/lib 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.cjs +1 -1
- package/account.d.ts +9 -11
- package/account.js +2 -2
- package/api-BYUraih6.d.ts +524 -0
- package/{api-CDb2pv7C.cjs → api-DD5v1qP9.cjs} +1 -1
- package/{background-DvQm1JHR.js → background-BVBbBOmL.js} +41 -68
- package/background-B_VgpARk.cjs +1 -0
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.d.ts +2 -541
- package/cloud/dgram.js +1 -3
- package/cloud/dns.cjs +1 -1
- package/cloud/dns.d.ts +3 -12
- package/cloud/dns.js +0 -1
- package/cloud/fs/promises.cjs +1 -1
- package/cloud/fs/promises.d.ts +7 -43
- package/cloud/fs/promises.js +0 -3
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +3 -75
- package/cloud/fs.js +3 -4
- package/cloud/http.cjs +1 -1
- package/cloud/http.d.ts +2 -767
- package/cloud/http.js +0 -3
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +2 -606
- package/cloud/net.js +2 -3
- package/cloud-5o7yJHeX.cjs +1 -0
- package/cloud-BFyf2uC7.js +112 -0
- package/cloud-gklfa4ZN.d.ts +41 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +7 -1053
- package/cloud.js +8 -12
- package/{connect-button-poDZVmq2.cjs → connect-button-BBEjXzB3.cjs} +1 -1
- package/connect-button-D8KXSL6s.d.ts +4 -0
- package/desktop.cjs +1 -1
- package/desktop.d.ts +37 -34
- package/desktop.js +1 -1
- package/dgram-CE43gJq9.cjs +1 -0
- package/{dgram-c_Xk7ckJ.js → dgram-wtjARbt0.js} +3 -3
- package/dgram.cjs +1 -1
- package/dgram.d.ts +83 -533
- package/dgram.js +1 -3
- package/dns.cjs +1 -1
- package/dns.d.ts +9 -9
- package/dns.js +2 -2
- package/extension-3pxUYwrA.d.ts +16 -0
- package/extension-CPj10qwa.js +67 -0
- package/extension-D-NUXxzF.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +3 -859
- package/extension.js +3 -5
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +8 -63
- package/fs/promises.js +1 -4
- package/fs-BfmfMBiw.cjs +1 -0
- package/{fs-BQs-x3_j.js → fs-D6nNf1mR.js} +4 -4
- package/fs-K7ROdxDx.d.ts +41 -0
- package/fs.cjs +1 -1
- package/fs.d.ts +81 -131
- package/fs.js +1 -4
- package/http.cjs +2 -2
- package/http.d.ts +152 -733
- package/http.js +7 -7
- package/index-BJztAQIP.d.ts +721 -0
- package/index-C6ZoDJg8.d.ts +31 -0
- package/index.cjs +1 -1
- package/index.d.ts +25 -2313
- package/index.js +23 -26
- package/lookup-BtwWaCZJ.d.ts +7 -0
- package/net-BDW1AVX1.d.ts +140 -0
- package/net-CpuAhaQC.cjs +1 -0
- package/{net-Bl6_W3bd.js → net-DKMWPXb_.js} +3 -3
- package/net.cjs +1 -1
- package/net.d.ts +2 -606
- package/net.js +2 -3
- package/{node-fs-DQn1TGJz.cjs → node-fs-C0eKnboT.cjs} +1 -1
- package/{node-fs-CdKPXPtW.js → node-fs-Dbf93qP7.js} +1 -1
- package/opfs/promises.cjs +1 -1
- package/opfs/promises.d.ts +8 -63
- package/opfs/promises.js +0 -1
- package/{opfs-BfcYLPGb.js → opfs-7_GmzQ93.js} +1 -1
- package/opfs-uClkgnb5.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.d.ts +80 -130
- package/opfs.js +3 -3
- package/package.json +6 -1
- package/packages-D36R2vBv.d.ts +108 -0
- package/packages.cjs +1 -0
- package/packages.d.ts +2 -0
- package/packages.js +150 -0
- package/{locator-9s7jNIA2.js → proxy-C8SG1Beo.js} +542 -344
- package/proxy-bPaU3-Cz.cjs +53 -0
- package/react.cjs +1 -1
- package/react.d.ts +11 -9
- package/react.js +1 -1
- package/{chunk-CPXzm0be.js → rolldown-runtime-DF993M8W.js} +1 -1
- package/rolldown-runtime-Doa5O59j.cjs +1 -0
- package/storage-OkwsFLN1.cjs +1 -0
- package/{storage-BcJfnkm3.js → storage-TmeyhZGt.js} +2 -2
- package/{utils-BsNRWMfl.cjs → utils-CoimMjf9.cjs} +1 -1
- package/background-CbU8TkWo.cjs +0 -1
- package/chunk-B6C_zzib.cjs +0 -1
- package/cloud-CWg9zCWm.cjs +0 -1
- package/cloud-eLyGYzbA.js +0 -33
- package/dgram-B3WC4VdJ.cjs +0 -1
- package/extension-BLkZiaAP.js +0 -253
- package/extension-DAiRg5ny.cjs +0 -1
- package/fs-DI1maxcZ.cjs +0 -1
- package/locator-CHfEe3Jv.cjs +0 -53
- package/net-C5kWnI4C.cjs +0 -1
- package/opfs-Dsi4FkJU.cjs +0 -1
- package/proxy-A9UvWUaF.cjs +0 -1
- package/proxy-wiZN4eTR.js +0 -14
- package/storage-C2-_-bTO.cjs +0 -1
- /package/{api-ByfayMm1.js → api--bnCFd4w.js} +0 -0
- /package/{connect-button-B_63ldmg.js → connect-button-Ds9KpXHe.js} +0 -0
- /package/{utils-CNydj3OT.js → utils-DPtyxGQu.js} +0 -0
package/opfs/promises.d.ts
CHANGED
|
@@ -1,67 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions } from "../index-C6ZoDJg8.js";
|
|
2
|
+
import { promises } from "../opfs.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
flag?: string;
|
|
6
|
-
} | null | undefined;
|
|
7
|
-
type WriteOptions = BufferEncoding | {
|
|
8
|
-
encoding?: BufferEncoding | null;
|
|
9
|
-
mode?: number;
|
|
10
|
-
flag?: string;
|
|
11
|
-
contentType?: string;
|
|
12
|
-
} | null | undefined;
|
|
13
|
-
type WriteData = string | Uint8Array | ArrayBuffer | DataView;
|
|
14
|
-
type MakeOptions = {
|
|
15
|
-
recursive?: boolean;
|
|
16
|
-
} | number | null | undefined;
|
|
17
|
-
type Stats = {
|
|
18
|
-
size: number;
|
|
19
|
-
mtimeMs: number;
|
|
20
|
-
mtime: Date;
|
|
21
|
-
atimeMs: number;
|
|
22
|
-
ctimeMs: number;
|
|
23
|
-
mode: number;
|
|
24
|
-
isFile: () => boolean;
|
|
25
|
-
isDirectory: () => boolean;
|
|
26
|
-
isSymbolicLink: () => boolean;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
declare const promises: {
|
|
30
|
-
readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
31
|
-
writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
32
|
-
appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
33
|
-
stat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
34
|
-
lstat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
35
|
-
readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
36
|
-
mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
37
|
-
rm: (path: node_fs.PathLike, options?: {
|
|
38
|
-
recursive?: boolean;
|
|
39
|
-
force?: boolean;
|
|
40
|
-
}) => Promise<void>;
|
|
41
|
-
rmdir: (path: node_fs.PathLike, options?: {
|
|
42
|
-
recursive?: boolean;
|
|
43
|
-
}) => Promise<void>;
|
|
44
|
-
unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
45
|
-
rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
46
|
-
access: (path: node_fs.PathLike) => Promise<void>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
declare const readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
50
|
-
declare const writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
51
|
-
declare const appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
52
|
-
declare const unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
53
|
-
declare const rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
54
|
-
declare const readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
55
|
-
declare const mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
56
|
-
declare const rm: (path: node_fs.PathLike, options?: {
|
|
4
|
+
//#region src/lib/opfs/promises.d.ts
|
|
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?: {
|
|
57
6
|
recursive?: boolean;
|
|
58
7
|
force?: boolean;
|
|
59
|
-
}) => Promise<void
|
|
60
|
-
declare const rmdir: (path: node_fs.PathLike, options?: {
|
|
8
|
+
}) => Promise<void>, rmdir: (path: import("node:fs").PathLike, options?: {
|
|
61
9
|
recursive?: boolean;
|
|
62
|
-
}) => Promise<void>;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
declare const access: (path: node_fs.PathLike) => Promise<void>;
|
|
66
|
-
|
|
67
|
-
export { access, appendFile, promises as default, lstat, mkdir, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile };
|
|
10
|
+
}) => Promise<void>, stat: (path: import("node:fs").PathLike) => Promise<Stats>, lstat: (path: import("node:fs").PathLike) => Promise<Stats>, access: (path: import("node:fs").PathLike) => Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { access, appendFile, promises as default, lstat, mkdir, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile };
|
package/opfs/promises.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require("./rolldown-runtime-Doa5O59j.cjs").n({available:()=>i,list:()=>c,readFile:()=>o,remove:()=>s,writeFile:()=>a}),t=()=>navigator.storage.getDirectory(),n=e=>{let t=e.split(`/`).filter(e=>e&&e!==`.`);if(t.some(e=>e===`..`)||!t.length)throw Error(`opfs: invalid path`);return t},r=async(e,n)=>{let r=await t();for(let t of e)r=await r.getDirectoryHandle(t,{create:n});return r},i=async()=>{try{return typeof navigator<`u`&&!!navigator.storage?.getDirectory&&!!await t()}catch{return!1}},a=async(e,t,i)=>{let a=n(e),o=a.pop(),s=await(await(await r(a,!0)).getFileHandle(o,{create:!0})).createWritable({keepExistingData:!1});try{let e=t instanceof Blob?t:new Blob([t],i?.contentType?{type:i.contentType}:void 0);await s.write(e)}finally{await s.close()}},o=async e=>{let t=n(e),i=t.pop();return(await(await r(t,!1)).getFileHandle(i)).getFile()},s=async e=>{let t=n(e),i=t.pop();await(await r(t,!1)).removeEntry(i,{recursive:!0})},c=async()=>{let e=[],n=async(t,r)=>{for await(let[i,a]of t.entries()){let t=r?`${r}/${i}`:i;if(a.kind===`file`){let n=await a.getFile();e.push({path:t,size:n.size,contentType:n.type||null,updatedAt:new Date(n.lastModified).toISOString()})}else await n(a,t)}};return await n(await t(),``),e};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/opfs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./node-fs-C0eKnboT.cjs"),n=require("./opfs-uClkgnb5.cjs");var r=e.n({appendFile:()=>b,appendFileSync:()=>c,available:()=>a,default:()=>i,exists:()=>D,existsSync:()=>l,flush:()=>A,lstatSync:()=>d,mkdir:()=>C,mkdirSync:()=>p,mount:()=>k,promises:()=>O,readFile:()=>v,readFileSync:()=>o,readdir:()=>S,readdirSync:()=>f,remount:()=>j,rename:()=>E,renameSync:()=>_,rm:()=>w,rmSync:()=>m,rmdirSync:()=>h,stat:()=>x,statSync:()=>u,unlink:()=>T,unlinkSync:()=>g,writeFile:()=>y,writeFileSync:()=>s}),i=t.t(n.r,{memfs:!0}),{available:a,readFileSync:o,writeFileSync:s,appendFileSync:c,existsSync:l,statSync:u,lstatSync:d,readdirSync:f,mkdirSync:p,rmSync:m,rmdirSync:h,unlinkSync:g,renameSync:_,readFile:v,writeFile:y,appendFile:b,stat:x,readdir:S,mkdir:C,rm:w,unlink:T,rename:E,exists:D,promises:O,mount:k,flush:A,remount:j}=i;exports.appendFile=b,exports.appendFileSync=c,exports.available=a,exports.default=i,exports.exists=D,exports.existsSync=l,exports.flush=A,exports.lstatSync=d,exports.mkdir=C,exports.mkdirSync=p,exports.mount=k,exports.promises=O,exports.readFile=v,exports.readFileSync=o,exports.readdir=S,exports.readdirSync=f,exports.remount=j,exports.rename=E,exports.renameSync=_,exports.rm=w,exports.rmSync=m,exports.rmdirSync=h,exports.stat=x,exports.statSync=u,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}}),exports.unlink=T,exports.unlinkSync=g,exports.writeFile=y,exports.writeFileSync=s;
|
package/opfs.d.ts
CHANGED
|
@@ -1,140 +1,90 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
type ReadOptions = BufferEncoding | {
|
|
4
|
-
encoding?: BufferEncoding | null;
|
|
5
|
-
flag?: string;
|
|
6
|
-
} | null | undefined;
|
|
7
|
-
type WriteOptions = BufferEncoding | {
|
|
8
|
-
encoding?: BufferEncoding | null;
|
|
9
|
-
mode?: number;
|
|
10
|
-
flag?: string;
|
|
11
|
-
contentType?: string;
|
|
12
|
-
} | null | undefined;
|
|
13
|
-
type WriteData = string | Uint8Array | ArrayBuffer | DataView;
|
|
14
|
-
type MakeOptions = {
|
|
15
|
-
recursive?: boolean;
|
|
16
|
-
} | number | null | undefined;
|
|
17
|
-
type Callback<R> = (error: NodeJS.ErrnoException | null, result?: R) => void;
|
|
18
|
-
type Stats = {
|
|
19
|
-
size: number;
|
|
20
|
-
mtimeMs: number;
|
|
21
|
-
mtime: Date;
|
|
22
|
-
atimeMs: number;
|
|
23
|
-
ctimeMs: number;
|
|
24
|
-
mode: number;
|
|
25
|
-
isFile: () => boolean;
|
|
26
|
-
isDirectory: () => boolean;
|
|
27
|
-
isSymbolicLink: () => boolean;
|
|
28
|
-
};
|
|
1
|
+
import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-C6ZoDJg8.js";
|
|
29
2
|
|
|
3
|
+
//#region src/lib/opfs/index.d.ts
|
|
4
|
+
declare namespace index_d_exports {
|
|
5
|
+
export { Stats, appendFile, appendFileSync, available, fs as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, promises, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
|
|
6
|
+
}
|
|
30
7
|
declare const fs: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
recursive?: boolean;
|
|
42
|
-
force?: boolean;
|
|
43
|
-
}) => void;
|
|
44
|
-
rmdirSync: (path: node_fs.PathLike, options?: {
|
|
45
|
-
recursive?: boolean;
|
|
46
|
-
}) => void;
|
|
47
|
-
unlinkSync: (path: node_fs.PathLike) => void;
|
|
48
|
-
renameSync: (from: node_fs.PathLike, to: node_fs.PathLike) => void;
|
|
49
|
-
readFile: (path: node_fs.PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
|
|
50
|
-
writeFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
51
|
-
appendFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
52
|
-
stat: (path: node_fs.PathLike, callback: Callback<Stats>) => void;
|
|
53
|
-
readdir: (path: node_fs.PathLike, a: unknown, b?: Callback<string[]>) => void;
|
|
54
|
-
mkdir: (path: node_fs.PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
|
|
55
|
-
rm: (path: node_fs.PathLike, a: {
|
|
56
|
-
recursive?: boolean;
|
|
57
|
-
force?: boolean;
|
|
58
|
-
} | Callback<void>, b?: Callback<void>) => void;
|
|
59
|
-
unlink: (path: node_fs.PathLike, callback: Callback<void>) => void;
|
|
60
|
-
rename: (from: node_fs.PathLike, to: node_fs.PathLike, callback: Callback<void>) => void;
|
|
61
|
-
exists: (path: node_fs.PathLike, callback: (exists: boolean) => void) => void;
|
|
62
|
-
promises: {
|
|
63
|
-
readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
64
|
-
writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
65
|
-
appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
66
|
-
stat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
67
|
-
lstat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
68
|
-
readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
69
|
-
mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
70
|
-
rm: (path: node_fs.PathLike, options?: {
|
|
71
|
-
recursive?: boolean;
|
|
72
|
-
force?: boolean;
|
|
73
|
-
}) => Promise<void>;
|
|
74
|
-
rmdir: (path: node_fs.PathLike, options?: {
|
|
75
|
-
recursive?: boolean;
|
|
76
|
-
}) => Promise<void>;
|
|
77
|
-
unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
78
|
-
rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
79
|
-
access: (path: node_fs.PathLike) => Promise<void>;
|
|
80
|
-
};
|
|
81
|
-
mount: () => Promise<void>;
|
|
82
|
-
flush: () => Promise<void>;
|
|
83
|
-
remount: () => Promise<void>;
|
|
84
|
-
};
|
|
85
|
-
declare const available: () => Promise<boolean>;
|
|
86
|
-
declare const readFileSync: (path: node_fs.PathLike, options?: ReadOptions) => Buffer | string;
|
|
87
|
-
declare const writeFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
88
|
-
declare const appendFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
89
|
-
declare const existsSync: (path: node_fs.PathLike) => boolean;
|
|
90
|
-
declare const statSync: (path: node_fs.PathLike) => Stats;
|
|
91
|
-
declare const lstatSync: (path: node_fs.PathLike) => Stats;
|
|
92
|
-
declare const readdirSync: (path: node_fs.PathLike) => string[];
|
|
93
|
-
declare const mkdirSync: (path: node_fs.PathLike, options?: MakeOptions) => void;
|
|
94
|
-
declare const rmSync: (path: node_fs.PathLike, options?: {
|
|
8
|
+
available: () => Promise<boolean>;
|
|
9
|
+
readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string;
|
|
10
|
+
writeFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
11
|
+
appendFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
12
|
+
existsSync: (path: import("node:fs").PathLike) => boolean;
|
|
13
|
+
statSync: (path: import("node:fs").PathLike) => Stats;
|
|
14
|
+
lstatSync: (path: import("node:fs").PathLike) => Stats;
|
|
15
|
+
readdirSync: (path: import("node:fs").PathLike) => string[];
|
|
16
|
+
mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void;
|
|
17
|
+
rmSync: (path: import("node:fs").PathLike, options?: {
|
|
95
18
|
recursive?: boolean;
|
|
96
19
|
force?: boolean;
|
|
97
|
-
}) => void;
|
|
98
|
-
|
|
20
|
+
}) => void;
|
|
21
|
+
rmdirSync: (path: import("node:fs").PathLike, options?: {
|
|
99
22
|
recursive?: boolean;
|
|
100
|
-
}) => void;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
23
|
+
}) => void;
|
|
24
|
+
unlinkSync: (path: import("node:fs").PathLike) => void;
|
|
25
|
+
renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void;
|
|
26
|
+
readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
|
|
27
|
+
writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
28
|
+
appendFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
29
|
+
stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void;
|
|
30
|
+
readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void;
|
|
31
|
+
mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
|
|
32
|
+
rm: (path: import("node:fs").PathLike, a: {
|
|
110
33
|
recursive?: boolean;
|
|
111
34
|
force?: boolean;
|
|
112
|
-
} | Callback<void>, b?: Callback<void>) => void;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
readFile: (path:
|
|
118
|
-
writeFile: (path:
|
|
119
|
-
appendFile: (path:
|
|
120
|
-
stat: (path:
|
|
121
|
-
lstat: (path:
|
|
122
|
-
readdir: (path:
|
|
123
|
-
mkdir: (path:
|
|
124
|
-
rm: (path:
|
|
125
|
-
|
|
126
|
-
|
|
35
|
+
} | Callback<void>, b?: Callback<void>) => void;
|
|
36
|
+
unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void;
|
|
37
|
+
rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void;
|
|
38
|
+
exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void;
|
|
39
|
+
promises: {
|
|
40
|
+
readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
41
|
+
writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
42
|
+
appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
43
|
+
stat: (path: import("node:fs").PathLike) => Promise<Stats>;
|
|
44
|
+
lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
|
|
45
|
+
readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
|
|
46
|
+
mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
|
|
47
|
+
rm: (path: import("node:fs").PathLike, options?: {
|
|
48
|
+
recursive?: boolean;
|
|
49
|
+
force?: boolean;
|
|
127
50
|
}) => Promise<void>;
|
|
128
|
-
rmdir: (path:
|
|
129
|
-
|
|
51
|
+
rmdir: (path: import("node:fs").PathLike, options?: {
|
|
52
|
+
recursive?: boolean;
|
|
130
53
|
}) => Promise<void>;
|
|
131
|
-
unlink: (path:
|
|
132
|
-
rename: (from:
|
|
133
|
-
access: (path:
|
|
54
|
+
unlink: (path: import("node:fs").PathLike) => Promise<void>;
|
|
55
|
+
rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
|
|
56
|
+
access: (path: import("node:fs").PathLike) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
mount: () => Promise<void>;
|
|
59
|
+
flush: () => Promise<void>;
|
|
60
|
+
remount: () => Promise<void>;
|
|
134
61
|
};
|
|
135
|
-
declare const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
62
|
+
declare const available: () => Promise<boolean>, readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string, writeFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void, appendFileSync: (path: import("node:fs").PathLike, data: WriteData, 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?: {
|
|
63
|
+
recursive?: boolean;
|
|
64
|
+
force?: boolean;
|
|
65
|
+
}) => void, rmdirSync: (path: import("node:fs").PathLike, options?: {
|
|
66
|
+
recursive?: boolean;
|
|
67
|
+
}) => void, unlinkSync: (path: import("node:fs").PathLike) => void, renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void, 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, appendFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => 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: {
|
|
68
|
+
recursive?: boolean;
|
|
69
|
+
force?: boolean;
|
|
70
|
+
} | 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, exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void, promises: {
|
|
71
|
+
readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
72
|
+
writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
73
|
+
appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
74
|
+
stat: (path: import("node:fs").PathLike) => Promise<Stats>;
|
|
75
|
+
lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
|
|
76
|
+
readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
|
|
77
|
+
mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
|
|
78
|
+
rm: (path: import("node:fs").PathLike, options?: {
|
|
79
|
+
recursive?: boolean;
|
|
80
|
+
force?: boolean;
|
|
81
|
+
}) => Promise<void>;
|
|
82
|
+
rmdir: (path: import("node:fs").PathLike, options?: {
|
|
83
|
+
recursive?: boolean;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
unlink: (path: import("node:fs").PathLike) => Promise<void>;
|
|
86
|
+
rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
|
|
87
|
+
access: (path: import("node:fs").PathLike) => Promise<void>;
|
|
88
|
+
}, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { type Stats, appendFile, appendFileSync, available, fs as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, promises, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, rm, rmSync, rmdirSync, stat, statSync, index_d_exports as t, unlink, unlinkSync, writeFile, writeFileSync };
|
package/opfs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as e } from "./
|
|
2
|
-
import { t } from "./node-fs-
|
|
3
|
-
import { r as n } from "./opfs-
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
|
+
import { t } from "./node-fs-Dbf93qP7.js";
|
|
3
|
+
import { r as n } from "./opfs-7_GmzQ93.js";
|
|
4
4
|
//#region src/lib/opfs/index.ts
|
|
5
5
|
var r = /* @__PURE__ */ e({
|
|
6
6
|
appendFile: () => b,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkn/lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -100,6 +100,11 @@
|
|
|
100
100
|
"import": "./account.js",
|
|
101
101
|
"require": "./account.cjs"
|
|
102
102
|
},
|
|
103
|
+
"./packages": {
|
|
104
|
+
"types": "./packages.d.ts",
|
|
105
|
+
"import": "./packages.js",
|
|
106
|
+
"require": "./packages.cjs"
|
|
107
|
+
},
|
|
103
108
|
"./react": {
|
|
104
109
|
"types": "./react.d.ts",
|
|
105
110
|
"import": "./react.js",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Remote } from "osra";
|
|
2
|
+
|
|
3
|
+
//#region src/api/packages/types.d.ts
|
|
4
|
+
type PackageQuery = {
|
|
5
|
+
/** package kind, e.g. 'plugin' - becomes the keyword `fkn-type:<type>` */type: string; /** host app scope, e.g. 'stub' - becomes the keyword `fkn-<type>--<id>` */
|
|
6
|
+
id?: string; /** package source; npm is the only origin implemented */
|
|
7
|
+
origin?: 'npm'; /** free text mixed into the registry query */
|
|
8
|
+
text?: string; /** result count, clamped to 1..100 */
|
|
9
|
+
size?: number;
|
|
10
|
+
};
|
|
11
|
+
type PackageResult = {
|
|
12
|
+
/** canonical version-free uri, e.g. 'npm:@banou/stub-plugin-foo' */uri: string;
|
|
13
|
+
origin: 'npm';
|
|
14
|
+
name: string; /** latest version per the search index - display only, install re-resolves from the packument */
|
|
15
|
+
version: string;
|
|
16
|
+
description: string;
|
|
17
|
+
keywords: string[];
|
|
18
|
+
publisher: string | null;
|
|
19
|
+
downloadsMonthly: number | null;
|
|
20
|
+
links: {
|
|
21
|
+
npm?: string;
|
|
22
|
+
homepage?: string;
|
|
23
|
+
repository?: string;
|
|
24
|
+
}; /** installed by the calling app */
|
|
25
|
+
installed: boolean;
|
|
26
|
+
};
|
|
27
|
+
type InstalledPackage = {
|
|
28
|
+
uri: string;
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
installedAt: number;
|
|
32
|
+
};
|
|
33
|
+
type PickOptions = {
|
|
34
|
+
/** untrusted, rendered as text in the picker header */title?: string;
|
|
35
|
+
multiple?: boolean;
|
|
36
|
+
};
|
|
37
|
+
type InstallOptions = {
|
|
38
|
+
/** exact version to pin; defaults to the packument's latest dist-tag */version?: string;
|
|
39
|
+
};
|
|
40
|
+
type ConnectOptions = {
|
|
41
|
+
/** opaque contract tag delivered to the package's onConnect, e.g. 'stub-source@1' */protocol?: string;
|
|
42
|
+
};
|
|
43
|
+
type PackagesErrorCode = 'invalid' | 'not-installed' | 'unaddressable' | 'timeout' | 'unavailable' | 'denied';
|
|
44
|
+
type PackagesFail = {
|
|
45
|
+
error: PackagesErrorCode;
|
|
46
|
+
message: string;
|
|
47
|
+
};
|
|
48
|
+
declare namespace packages_d_exports {
|
|
49
|
+
export { AppConnectOptions, ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, InstallOptions, InstalledPackage, PackageConnection, PackageQuery, PackageResult, PackagesError, PackagesErrorCode, PickOptions, RawPackageConnection, attach, connect, install, list, onConnect, pick, search, uninstall };
|
|
50
|
+
}
|
|
51
|
+
type PackagesError = Error & {
|
|
52
|
+
code: PackagesErrorCode;
|
|
53
|
+
};
|
|
54
|
+
/** Search npm for FKN packages, e.g. `search({ type: 'plugin', id: 'stub' })`. */
|
|
55
|
+
declare const search: (query: PackageQuery) => Promise<PackageResult[]>;
|
|
56
|
+
/** FKN-rendered picker over the same search; resolves the user's selection, already installed. [] on cancel. */
|
|
57
|
+
declare const pick: (query: PackageQuery, options?: PickOptions) => Promise<PackageResult[]>;
|
|
58
|
+
/** Install a package for this app behind an FKN-rendered confirm. Resolves null when the user declines. */
|
|
59
|
+
declare const install: (uri: string, options?: InstallOptions) => Promise<InstalledPackage | null>;
|
|
60
|
+
/** The packages installed by this app. */
|
|
61
|
+
declare const list: () => Promise<InstalledPackage[]>;
|
|
62
|
+
/** Uninstall a package from this app; its frames and connections are torn down. */
|
|
63
|
+
declare const uninstall: (uri: string) => Promise<void>;
|
|
64
|
+
type PackageConnection<T = unknown> = {
|
|
65
|
+
/** the package's exposed payload */remote: Remote<T>; /** settles when the package side of the connection dies (uninstall, reload, crash) - reconnect by calling connect() again */
|
|
66
|
+
closed: Promise<void>; /** the raw channel under `remote`, for direct messaging (osra envelopes ride it too - filter by your own message shape) */
|
|
67
|
+
port: MessagePort;
|
|
68
|
+
};
|
|
69
|
+
type AppConnectOptions = ConnectOptions & {
|
|
70
|
+
/** exposed to the package as ITS `remote` */payload?: unknown;
|
|
71
|
+
signal?: AbortSignal; /** skip the osra handshake and hand back the untouched port - e.g. to transfer it into a worker and attach() there */
|
|
72
|
+
raw?: boolean;
|
|
73
|
+
};
|
|
74
|
+
type RawPackageConnection = Omit<PackageConnection<never>, 'remote'>;
|
|
75
|
+
type Connect = {
|
|
76
|
+
<T = unknown>(uri: string, options?: AppConnectOptions & {
|
|
77
|
+
raw?: false;
|
|
78
|
+
}): Promise<PackageConnection<T>>;
|
|
79
|
+
(uri: string, options: AppConnectOptions & {
|
|
80
|
+
raw: true;
|
|
81
|
+
}): Promise<RawPackageConnection>;
|
|
82
|
+
};
|
|
83
|
+
/** Connect to an installed package. Throws a PackagesError with code 'not-installed' when it is not. */
|
|
84
|
+
declare const connect: Connect;
|
|
85
|
+
/** Run this end of an already-brokered connection port, e.g. after transferring it into a worker. */
|
|
86
|
+
declare const attach: <T = unknown>(port: MessagePort, payload?: unknown, options?: {
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}) => Promise<Remote<T>>;
|
|
89
|
+
type IncomingConnectionInfo = {
|
|
90
|
+
/** the connecting app's identity: its package uri when it runs on a sandbox origin, else its page origin */from: string; /** the contract tag the app passed to connect(), e.g. 'stub-source@1' */
|
|
91
|
+
protocol: string | null; /** this package's canonical uri per the connecting app's install record, e.g. 'npm:@banou/stub-source-example' */
|
|
92
|
+
uri: string; /** this package's npm name */
|
|
93
|
+
name: string; /** the exact version this frame runs - the pin is encoded into the sandbox origin, immutable per version */
|
|
94
|
+
version: string;
|
|
95
|
+
};
|
|
96
|
+
type IncomingConnection<T = unknown> = IncomingConnectionInfo & PackageConnection<T>;
|
|
97
|
+
/** produces the payload exposed to a connecting app - called once per incoming connection */
|
|
98
|
+
type ConnectPayload = (info: IncomingConnectionInfo) => unknown;
|
|
99
|
+
/**
|
|
100
|
+
* Serve connections from apps that installed this package. The first argument is called once per
|
|
101
|
+
* incoming connection with the connection info and returns the payload exposed to that app (its
|
|
102
|
+
* `remote`). The latest registration receives new connections; existing connections are unaffected.
|
|
103
|
+
*/
|
|
104
|
+
declare const onConnect: <T = unknown>(createPayload: ConnectPayload, handler?: (connection: IncomingConnection<T>) => void) => {
|
|
105
|
+
unsubscribe: () => void;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
export { PackagesFail as C, PackagesErrorCode as S, ConnectOptions as _, PackageConnection as a, PackageQuery as b, attach as c, list as d, onConnect as f, uninstall as g, search as h, IncomingConnectionInfo as i, connect as l, pick as m, ConnectPayload as n, PackagesError as o, packages_d_exports as p, IncomingConnection as r, RawPackageConnection as s, AppConnectOptions as t, install as u, InstallOptions as v, PickOptions as w, PackageResult as x, InstalledPackage as y };
|
package/packages.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./api-DD5v1qP9.cjs");let n=require("osra");var r=e.n({attach:()=>_,connect:()=>g,install:()=>p,list:()=>m,onConnect:()=>O,pick:()=>f,search:()=>d,uninstall:()=>h}),i=`https://fkn.app`,a=`fkn-packages-connection`,o=3e4,s=(e,t)=>Object.assign(Error(t),{code:e}),c=async()=>{if(!t.n)throw s(`unavailable`,`packages: no FKN transport in this realm - use relayWorker to bridge workers`);return t.t},l=(e,t,r)=>(0,n.expose)(e??{},{transport:t,key:a,unregisterSignal:r}),u=async(e,t,n={})=>{let{signal:r,closed:i}=n;if(r?.aborted)throw s(`unavailable`,`packages.connect: aborted before connecting`);let a=new AbortController;r&&r.addEventListener(`abort`,()=>a.abort(r.reason),{once:!0});let c=new AbortController,u=new Promise((e,n)=>{let a=setTimeout(()=>n(s(`timeout`,`packages.connect: the package did not complete the connection`)),o);c.signal.addEventListener(`abort`,()=>clearTimeout(a),{once:!0}),t.addEventListener(`message`,e=>{if(e.data?.type===`fkn-packages-nack`){let t=e.data.message;n(s(`unavailable`,typeof t==`string`&&t?t:`packages.connect: the package refused the connection`))}},{signal:c.signal}),t.start(),r&&r.addEventListener(`abort`,()=>n(s(`unavailable`,`packages.connect: aborted before connecting`)),{once:!0,signal:c.signal}),i?.then(()=>n(s(`unavailable`,`packages.connect: the package closed before connecting`)))});try{return await Promise.race([l(e,t,a.signal),u])}catch(e){a.abort(e);try{t.close()}catch{}throw e}finally{c.abort()}},d=async e=>{let t=await(await c()).packages.search(e);if(`error`in t)throw s(t.error,t.message);return t.results},f=async(e,t)=>{let n=await(await c()).packages.pick(e,t);if(`error`in n)throw s(n.error,n.message);return`declined`in n?[]:n.results},p=async(e,t)=>{let n=await(await c()).packages.install(e,t);if(`error`in n)throw s(n.error,n.message);return`declined`in n?null:n.installed},m=async()=>(await(await c()).packages.list()).results,h=async e=>{let t=await(await c()).packages.uninstall(e);if(`error`in t)throw s(t.error,t.message)},g=(async(e,t={})=>{let n=await(await c()).packages.connect(e,{protocol:t.protocol});if(`error`in n)throw s(n.error,n.message);let{port:r,closed:i}=n;if(t.raw)return{closed:i,port:r};let a=await u(t.payload,r,{signal:t.signal,closed:i});return t.signal&&t.signal.addEventListener(`abort`,()=>{try{r.postMessage({type:`fkn-packages-disconnect`})}catch{}},{once:!0}),{remote:a,closed:i,port:r}}),_=(e,t,n)=>u(t,e,{signal:n?.signal}),v=null,y=[],b=new Map,x=!1,S=!1,C=e=>{let t=b.get(e);t&&(b.delete(e),t())},w=(e,t)=>{try{e.postMessage({type:`fkn-packages-nack`,message:t})}catch{}try{e.close()}catch{}},T=async(e,t)=>{let{port:n,...r}=e;e.port.addEventListener(`message`,t=>{t.data?.type===`fkn-packages-disconnect`&&C(e.port)});let i;try{i=await t.createPayload(r)}catch(t){throw w(e.port,t instanceof Error?t.message:`the package failed to produce a connection`),t}let a=new Promise(t=>b.set(e.port,t)),o=await l(i,e.port);t.handler?.({...r,remote:o,closed:a,port:e.port})},E=()=>{x||typeof window>`u`||window.parent===window||(x=!0,window.addEventListener(`message`,e=>{if(e.source!==window.parent||e.origin!==i)return;let t=e.data;if(t?.type===`fkn-packages-port`){let n=e.ports[0];if(!n)return;let r={port:n,from:typeof t.from==`string`?t.from:``,protocol:typeof t.protocol==`string`?t.protocol:null,uri:typeof t.uri==`string`?t.uri:``,name:typeof t.name==`string`?t.name:``,version:typeof t.version==`string`?t.version:``};v?T(r,v).catch(e=>console.warn(`packages.onConnect:`,e)):y.push(r)}if(t?.type===`fkn-packages-close`)for(let e of[...b.keys()])C(e)}))},D=()=>{S||typeof window>`u`||window.parent===window||(S=!0,window.parent.postMessage({type:`fkn-packages-ready`},i))},O=(e,t)=>{if(typeof window>`u`)return{unsubscribe:()=>{}};E();let n={createPayload:e,handler:t};for(v=n,D();y.length&&v===n;)T(y.shift(),n).catch(e=>console.warn(`packages.onConnect:`,e));return{unsubscribe:()=>{v===n&&(v=null)}}};exports.attach=_,exports.connect=g,exports.install=p,exports.list=m,exports.onConnect=O,exports.pick=f,exports.search=d,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}}),exports.uninstall=h;
|
package/packages.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { S as PackagesErrorCode, _ as ConnectOptions, a as PackageConnection, b as PackageQuery, c as attach, d as list, f as onConnect, g as uninstall, h as search, i as IncomingConnectionInfo, l as connect, m as pick, n as ConnectPayload, o as PackagesError, r as IncomingConnection, s as RawPackageConnection, t as AppConnectOptions, u as install, v as InstallOptions, w as PickOptions, x as PackageResult, y as InstalledPackage } from "./packages-D36R2vBv.js";
|
|
2
|
+
export { AppConnectOptions, type ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, type InstallOptions, type InstalledPackage, PackageConnection, type PackageQuery, type PackageResult, PackagesError, type PackagesErrorCode, type PickOptions, RawPackageConnection, attach, connect, install, list, onConnect, pick, search, uninstall };
|
package/packages.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
|
+
import { n as t, t as n } from "./api--bnCFd4w.js";
|
|
3
|
+
import { expose as r } from "osra";
|
|
4
|
+
//#region src/lib/packages.ts
|
|
5
|
+
var i = /* @__PURE__ */ e({
|
|
6
|
+
attach: () => v,
|
|
7
|
+
connect: () => _,
|
|
8
|
+
install: () => m,
|
|
9
|
+
list: () => h,
|
|
10
|
+
onConnect: () => k,
|
|
11
|
+
pick: () => p,
|
|
12
|
+
search: () => f,
|
|
13
|
+
uninstall: () => g
|
|
14
|
+
}), a = "https://fkn.app", o = "fkn-packages-connection", s = 3e4, c = (e, t) => Object.assign(Error(t), { code: e }), l = async () => {
|
|
15
|
+
if (!t) throw c("unavailable", "packages: no FKN transport in this realm - use relayWorker to bridge workers");
|
|
16
|
+
return n;
|
|
17
|
+
}, u = (e, t, n) => r(e ?? {}, {
|
|
18
|
+
transport: t,
|
|
19
|
+
key: o,
|
|
20
|
+
unregisterSignal: n
|
|
21
|
+
}), d = async (e, t, n = {}) => {
|
|
22
|
+
let { signal: r, closed: i } = n;
|
|
23
|
+
if (r?.aborted) throw c("unavailable", "packages.connect: aborted before connecting");
|
|
24
|
+
let a = new AbortController();
|
|
25
|
+
r && r.addEventListener("abort", () => a.abort(r.reason), { once: !0 });
|
|
26
|
+
let o = new AbortController(), l = new Promise((e, n) => {
|
|
27
|
+
let a = setTimeout(() => n(c("timeout", "packages.connect: the package did not complete the connection")), s);
|
|
28
|
+
o.signal.addEventListener("abort", () => clearTimeout(a), { once: !0 }), t.addEventListener("message", (e) => {
|
|
29
|
+
if (e.data?.type === "fkn-packages-nack") {
|
|
30
|
+
let t = e.data.message;
|
|
31
|
+
n(c("unavailable", typeof t == "string" && t ? t : "packages.connect: the package refused the connection"));
|
|
32
|
+
}
|
|
33
|
+
}, { signal: o.signal }), t.start(), r && r.addEventListener("abort", () => n(c("unavailable", "packages.connect: aborted before connecting")), {
|
|
34
|
+
once: !0,
|
|
35
|
+
signal: o.signal
|
|
36
|
+
}), i?.then(() => n(c("unavailable", "packages.connect: the package closed before connecting")));
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
return await Promise.race([u(e, t, a.signal), l]);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
a.abort(e);
|
|
42
|
+
try {
|
|
43
|
+
t.close();
|
|
44
|
+
} catch {}
|
|
45
|
+
throw e;
|
|
46
|
+
} finally {
|
|
47
|
+
o.abort();
|
|
48
|
+
}
|
|
49
|
+
}, f = async (e) => {
|
|
50
|
+
let t = await (await l()).packages.search(e);
|
|
51
|
+
if ("error" in t) throw c(t.error, t.message);
|
|
52
|
+
return t.results;
|
|
53
|
+
}, p = async (e, t) => {
|
|
54
|
+
let n = await (await l()).packages.pick(e, t);
|
|
55
|
+
if ("error" in n) throw c(n.error, n.message);
|
|
56
|
+
return "declined" in n ? [] : n.results;
|
|
57
|
+
}, m = async (e, t) => {
|
|
58
|
+
let n = await (await l()).packages.install(e, t);
|
|
59
|
+
if ("error" in n) throw c(n.error, n.message);
|
|
60
|
+
return "declined" in n ? null : n.installed;
|
|
61
|
+
}, h = async () => (await (await l()).packages.list()).results, g = async (e) => {
|
|
62
|
+
let t = await (await l()).packages.uninstall(e);
|
|
63
|
+
if ("error" in t) throw c(t.error, t.message);
|
|
64
|
+
}, _ = (async (e, t = {}) => {
|
|
65
|
+
let n = await (await l()).packages.connect(e, { protocol: t.protocol });
|
|
66
|
+
if ("error" in n) throw c(n.error, n.message);
|
|
67
|
+
let { port: r, closed: i } = n;
|
|
68
|
+
if (t.raw) return {
|
|
69
|
+
closed: i,
|
|
70
|
+
port: r
|
|
71
|
+
};
|
|
72
|
+
let a = await d(t.payload, r, {
|
|
73
|
+
signal: t.signal,
|
|
74
|
+
closed: i
|
|
75
|
+
});
|
|
76
|
+
return t.signal && t.signal.addEventListener("abort", () => {
|
|
77
|
+
try {
|
|
78
|
+
r.postMessage({ type: "fkn-packages-disconnect" });
|
|
79
|
+
} catch {}
|
|
80
|
+
}, { once: !0 }), {
|
|
81
|
+
remote: a,
|
|
82
|
+
closed: i,
|
|
83
|
+
port: r
|
|
84
|
+
};
|
|
85
|
+
}), v = (e, t, n) => d(t, e, { signal: n?.signal }), y = null, b = [], x = /* @__PURE__ */ new Map(), S = !1, C = !1, w = (e) => {
|
|
86
|
+
let t = x.get(e);
|
|
87
|
+
t && (x.delete(e), t());
|
|
88
|
+
}, T = (e, t) => {
|
|
89
|
+
try {
|
|
90
|
+
e.postMessage({
|
|
91
|
+
type: "fkn-packages-nack",
|
|
92
|
+
message: t
|
|
93
|
+
});
|
|
94
|
+
} catch {}
|
|
95
|
+
try {
|
|
96
|
+
e.close();
|
|
97
|
+
} catch {}
|
|
98
|
+
}, E = async (e, t) => {
|
|
99
|
+
let { port: n, ...r } = e;
|
|
100
|
+
e.port.addEventListener("message", (t) => {
|
|
101
|
+
t.data?.type === "fkn-packages-disconnect" && w(e.port);
|
|
102
|
+
});
|
|
103
|
+
let i;
|
|
104
|
+
try {
|
|
105
|
+
i = await t.createPayload(r);
|
|
106
|
+
} catch (t) {
|
|
107
|
+
throw T(e.port, t instanceof Error ? t.message : "the package failed to produce a connection"), t;
|
|
108
|
+
}
|
|
109
|
+
let a = new Promise((t) => x.set(e.port, t)), o = await u(i, e.port);
|
|
110
|
+
t.handler?.({
|
|
111
|
+
...r,
|
|
112
|
+
remote: o,
|
|
113
|
+
closed: a,
|
|
114
|
+
port: e.port
|
|
115
|
+
});
|
|
116
|
+
}, D = () => {
|
|
117
|
+
S || typeof window > "u" || window.parent === window || (S = !0, window.addEventListener("message", (e) => {
|
|
118
|
+
if (e.source !== window.parent || e.origin !== a) return;
|
|
119
|
+
let t = e.data;
|
|
120
|
+
if (t?.type === "fkn-packages-port") {
|
|
121
|
+
let n = e.ports[0];
|
|
122
|
+
if (!n) return;
|
|
123
|
+
let r = {
|
|
124
|
+
port: n,
|
|
125
|
+
from: typeof t.from == "string" ? t.from : "",
|
|
126
|
+
protocol: typeof t.protocol == "string" ? t.protocol : null,
|
|
127
|
+
uri: typeof t.uri == "string" ? t.uri : "",
|
|
128
|
+
name: typeof t.name == "string" ? t.name : "",
|
|
129
|
+
version: typeof t.version == "string" ? t.version : ""
|
|
130
|
+
};
|
|
131
|
+
y ? E(r, y).catch((e) => console.warn("packages.onConnect:", e)) : b.push(r);
|
|
132
|
+
}
|
|
133
|
+
if (t?.type === "fkn-packages-close") for (let e of [...x.keys()]) w(e);
|
|
134
|
+
}));
|
|
135
|
+
}, O = () => {
|
|
136
|
+
C || typeof window > "u" || window.parent === window || (C = !0, window.parent.postMessage({ type: "fkn-packages-ready" }, a));
|
|
137
|
+
}, k = (e, t) => {
|
|
138
|
+
if (typeof window > "u") return { unsubscribe: () => {} };
|
|
139
|
+
D();
|
|
140
|
+
let n = {
|
|
141
|
+
createPayload: e,
|
|
142
|
+
handler: t
|
|
143
|
+
};
|
|
144
|
+
for (y = n, O(); b.length && y === n;) E(b.shift(), n).catch((e) => console.warn("packages.onConnect:", e));
|
|
145
|
+
return { unsubscribe: () => {
|
|
146
|
+
y === n && (y = null);
|
|
147
|
+
} };
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
export { v as attach, _ as connect, m as install, h as list, k as onConnect, p as pick, f as search, i as t, g as uninstall };
|