@fkn/lib 0.4.9 → 0.5.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 -0
- package/account.d.ts +17 -0
- package/account.js +28 -0
- package/api-ByfayMm1.js +67 -0
- package/api-CDb2pv7C.cjs +1 -0
- package/background-Dk_vaVP1.cjs +1 -0
- package/{background-CTsVv_a0.js → background-TtzKw6g0.js} +5 -4
- package/chunk-B6C_zzib.cjs +1 -0
- package/chunk-CPXzm0be.js +11 -0
- package/cloud/dgram.cjs +1 -0
- package/cloud/dgram.d.ts +537 -0
- package/cloud/dgram.js +4 -0
- package/cloud/dns.cjs +1 -0
- package/cloud/dns.d.ts +12 -0
- package/cloud/dns.js +3 -0
- package/cloud/fs/promises.cjs +1 -0
- package/cloud/fs/promises.d.ts +45 -0
- package/cloud/fs/promises.js +8 -0
- package/cloud/fs.cjs +1 -0
- package/cloud/fs.d.ts +75 -0
- package/cloud/fs.js +20 -0
- package/cloud/http.cjs +1 -0
- package/cloud/http.d.ts +767 -0
- package/cloud/http.js +5 -0
- package/cloud/net.cjs +1 -0
- package/cloud/net.d.ts +606 -0
- package/cloud/net.js +4 -0
- package/cloud-BrY9dKwV.cjs +1 -0
- package/cloud-C-LK4DWa.js +33 -0
- package/cloud.cjs +1 -0
- package/cloud.d.ts +1053 -0
- package/cloud.js +12 -0
- package/desktop.cjs +1 -0
- package/desktop.d.ts +49 -0
- package/desktop.js +51 -0
- package/dgram-C5rGcbej.cjs +1 -0
- package/dgram-DS5_yPc5.js +330 -0
- package/dgram.cjs +1 -0
- package/dgram.d.ts +541 -0
- package/dgram.js +4 -0
- package/dns.cjs +1 -0
- package/dns.d.ts +12 -0
- package/dns.js +6 -0
- package/extension-9Uv_0HdS.cjs +1 -0
- package/extension-Dgz0UTy0.js +245 -0
- package/extension.cjs +1 -0
- package/extension.d.ts +853 -0
- package/extension.js +5 -0
- package/fs/promises.cjs +1 -0
- package/fs/promises.d.ts +65 -0
- package/fs/promises.js +8 -0
- package/fs-BiS_UsCn.js +82 -0
- package/fs-CmgWrokB.cjs +1 -0
- package/fs.cjs +1 -0
- package/fs.d.ts +138 -0
- package/fs.js +5 -0
- package/http.cjs +9 -0
- package/http.d.ts +767 -0
- package/http.js +541 -0
- package/index.cjs +1 -9
- package/index.d.ts +261 -146
- package/index.js +27 -1879
- package/locator-Cf7M3QKN.cjs +53 -0
- package/{locator-Q5m8i40Z.js → locator-DxAsGV_o.js} +331 -337
- package/net-Bl6_W3bd.js +275 -0
- package/net-C5kWnI4C.cjs +1 -0
- package/net.cjs +1 -0
- package/net.d.ts +606 -0
- package/net.js +4 -0
- package/node-fs-Bd_UUx1m.js +361 -0
- package/node-fs-lrlD_zqB.cjs +1 -0
- package/opfs/promises.cjs +1 -0
- package/opfs/promises.d.ts +46 -0
- package/opfs/promises.js +6 -0
- package/opfs-BfcYLPGb.js +55 -0
- package/opfs-Dsi4FkJU.cjs +1 -0
- package/opfs.cjs +1 -0
- package/opfs.d.ts +83 -0
- package/opfs.js +35 -0
- package/package.json +91 -1
- package/proxy-A9UvWUaF.cjs +1 -0
- package/proxy-wiZN4eTR.js +14 -0
- package/storage-BadvHtv0.cjs +1 -0
- package/storage-z0q3iena.js +13 -0
- package/utils-BsNRWMfl.cjs +1 -0
- package/utils-CNydj3OT.js +52 -0
- package/background-BqRFQggD.cjs +0 -1
- package/locator-Cjl21Nkt.cjs +0 -53
package/extension.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { d as e, f as t, l as n, m as r, p as i, u as a } from "./locator-DxAsGV_o.js";
|
|
2
|
+
import { C as o, D as s, E as c, O 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, l as x, m as S, o as C, p as w, r as T, s as E, u as D, v as O, w as k, x as A, y as j } from "./extension-Dgz0UTy0.js";
|
|
3
|
+
import "./api-ByfayMm1.js";
|
|
4
|
+
import "./proxy-wiZN4eTR.js";
|
|
5
|
+
export { C as ATTACH_FRAME_EVENT_KEY, E as assertAttachableFrameUrl, O as assertFetchableUrl, h as attachFrame, x as attachFramePermission, T as available, a as box, v as cookies, e as createVideoElementHandle, D as evaluatePermission, d as events, d as extension, j as fetch, m as fetchCredentialedPermission, A as fetchLocalPermission, u as fetchPermission, g as gotoPermission, n as handleRevivableModules, o as isBlockedFetchUrl, _ as isBlockedFrameUrl, c as isExtensionExposed, k as isLocalNetworkUrl, t as isType, w as modifyRequestHeadersPermission, p as permissions, b as promptInstall, f as readCookiePermission, S as removeRequestHeaderRule, i as revive, s as setMissingExtensionHandler, y as setRequestHeaderRule, r as type, l as waitForExtensionExposure };
|
package/fs/promises.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../api-CDb2pv7C.cjs`),require(`../node-fs-lrlD_zqB.cjs`),require(`../storage-BadvHtv0.cjs`);const e=require(`../fs-CmgWrokB.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.p,p=e.p;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
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as node_fs from 'node:fs';
|
|
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 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
|
+
}) => Promise<void>;
|
|
40
|
+
rmdir: (path: node_fs.PathLike, options?: {
|
|
41
|
+
recursive?: boolean;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
44
|
+
rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
45
|
+
access: (path: node_fs.PathLike) => Promise<void>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
declare const readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
49
|
+
declare const writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
50
|
+
declare const appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
51
|
+
declare const unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
52
|
+
declare const rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
53
|
+
declare const readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
54
|
+
declare const mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
55
|
+
declare const rm: (path: node_fs.PathLike, options?: {
|
|
56
|
+
recursive?: boolean;
|
|
57
|
+
}) => Promise<void>;
|
|
58
|
+
declare const rmdir: (path: node_fs.PathLike, options?: {
|
|
59
|
+
recursive?: boolean;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
declare const stat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
62
|
+
declare const lstat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
63
|
+
declare const access: (path: node_fs.PathLike) => Promise<void>;
|
|
64
|
+
|
|
65
|
+
export { access, appendFile, promises as default, lstat, mkdir, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile };
|
package/fs/promises.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../api-ByfayMm1.js";
|
|
2
|
+
import "../node-fs-Bd_UUx1m.js";
|
|
3
|
+
import "../storage-z0q3iena.js";
|
|
4
|
+
import { p as e } from "../fs-BiS_UsCn.js";
|
|
5
|
+
//#region src/lib/fs/promises.ts
|
|
6
|
+
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;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { f as access, r as appendFile, p as default, d as lstat, s as mkdir, t as readFile, o as readdir, a as rename, c as rm, l as rmdir, u as stat, i as unlink, n as writeFile };
|
package/fs-BiS_UsCn.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { n as e } from "./chunk-CPXzm0be.js";
|
|
2
|
+
import { t } from "./node-fs-Bd_UUx1m.js";
|
|
3
|
+
import { a as n, i as r, n as i, s as a, t as o } from "./storage-z0q3iena.js";
|
|
4
|
+
import { a as s, i as c, n as l, o as u, t as d } from "./opfs-BfcYLPGb.js";
|
|
5
|
+
//#region src/lib/fs/hybrid.ts
|
|
6
|
+
var f = /* @__PURE__ */ e({
|
|
7
|
+
available: () => g,
|
|
8
|
+
list: () => _,
|
|
9
|
+
pull: () => x,
|
|
10
|
+
readFile: () => v,
|
|
11
|
+
remove: () => b,
|
|
12
|
+
writeFile: () => y
|
|
13
|
+
}), p, m = async () => await (p ??= d().catch(() => !1)) ? !0 : (p = void 0, !1), h = () => o().catch(() => !1), g = async () => await m() || await h(), _ = async () => {
|
|
14
|
+
let [e, t] = await Promise.all([m().then((e) => e ? l() : []).catch(() => []), h().then((e) => e ? i() : []).catch(() => [])]), n = /* @__PURE__ */ new Map(), r = (e) => {
|
|
15
|
+
let t = Date.parse(e.updatedAt ?? "");
|
|
16
|
+
return Number.isFinite(t) ? t : 0;
|
|
17
|
+
}, a = (e) => {
|
|
18
|
+
let t = n.get(e.path);
|
|
19
|
+
(!t || r(e) >= r(t)) && n.set(e.path, e);
|
|
20
|
+
};
|
|
21
|
+
for (let t of e) a(t);
|
|
22
|
+
for (let e of t) a(e);
|
|
23
|
+
return [...n.values()];
|
|
24
|
+
}, v = async (e) => {
|
|
25
|
+
if (await m()) try {
|
|
26
|
+
return await c(e);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
29
|
+
}
|
|
30
|
+
let t = await r(e);
|
|
31
|
+
return await m() && u(e, t).catch(() => {}), t;
|
|
32
|
+
}, y = async (e, t, n) => {
|
|
33
|
+
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
34
|
+
if (await m()) {
|
|
35
|
+
await u(e, r, n), await h() && a(e, r, n).catch((e) => console.warn("fs: cloud replicate failed", e));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (await h()) return a(e, r, n);
|
|
39
|
+
throw Error("fs: no storage backend available");
|
|
40
|
+
}, b = async (e) => {
|
|
41
|
+
let t = [];
|
|
42
|
+
if (await m() && t.push(s(e).catch(() => {})), await h() && t.push(n(e).catch(() => {})), !t.length) throw Error("fs: no storage backend available");
|
|
43
|
+
await Promise.all(t);
|
|
44
|
+
}, x = async (e) => {
|
|
45
|
+
let t = await r(e);
|
|
46
|
+
return await m() && await u(e, t), t;
|
|
47
|
+
}, S = /* @__PURE__ */ e({
|
|
48
|
+
appendFile: () => z,
|
|
49
|
+
appendFileSync: () => D,
|
|
50
|
+
available: () => w,
|
|
51
|
+
default: () => Q,
|
|
52
|
+
exists: () => K,
|
|
53
|
+
existsSync: () => O,
|
|
54
|
+
flush: () => Y,
|
|
55
|
+
lstatSync: () => A,
|
|
56
|
+
mkdir: () => H,
|
|
57
|
+
mkdirSync: () => M,
|
|
58
|
+
mount: () => J,
|
|
59
|
+
promises: () => q,
|
|
60
|
+
pull: () => Z,
|
|
61
|
+
readFile: () => L,
|
|
62
|
+
readFileSync: () => T,
|
|
63
|
+
readdir: () => V,
|
|
64
|
+
readdirSync: () => j,
|
|
65
|
+
remount: () => X,
|
|
66
|
+
rename: () => G,
|
|
67
|
+
renameSync: () => I,
|
|
68
|
+
rm: () => U,
|
|
69
|
+
rmSync: () => N,
|
|
70
|
+
rmdirSync: () => P,
|
|
71
|
+
stat: () => B,
|
|
72
|
+
statSync: () => k,
|
|
73
|
+
unlink: () => W,
|
|
74
|
+
unlinkSync: () => F,
|
|
75
|
+
writeFile: () => R,
|
|
76
|
+
writeFileSync: () => E
|
|
77
|
+
}), C = t(f, { memfs: !0 }), { available: w, readFileSync: T, writeFileSync: E, appendFileSync: D, existsSync: O, statSync: k, lstatSync: A, readdirSync: j, mkdirSync: M, rmSync: N, rmdirSync: P, unlinkSync: F, renameSync: I, readFile: L, writeFile: R, appendFile: z, stat: B, readdir: V, mkdir: H, rm: U, unlink: W, rename: G, exists: K, promises: q, mount: J, flush: Y, remount: X } = C, Z = x, Q = {
|
|
78
|
+
...C,
|
|
79
|
+
pull: Z
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { E as A, N as C, W as D, k as E, F as O, U as S, B as T, V as _, O as a, G as b, S as c, M as d, J as f, T as g, L as h, K as i, R as k, A as l, Z as m, D as n, Y as o, q as p, w as r, Q as s, z as t, H as u, j as v, P as w, I as x, X as y };
|
package/fs-CmgWrokB.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk-B6C_zzib.cjs`),t=require(`./node-fs-lrlD_zqB.cjs`),n=require(`./storage-BadvHtv0.cjs`),r=require(`./opfs-Dsi4FkJU.cjs`);var i=e.n({available:()=>c,list:()=>l,pull:()=>p,readFile:()=>u,remove:()=>f,writeFile:()=>d}),a,o=async()=>await(a??=r.t().catch(()=>!1))?!0:(a=void 0,!1),s=()=>n.t().catch(()=>!1),c=async()=>await o()||await s(),l=async()=>{let[e,t]=await Promise.all([o().then(e=>e?r.n():[]).catch(()=>[]),s().then(e=>e?n.n():[]).catch(()=>[])]),i=new Map,a=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},c=e=>{let t=i.get(e.path);(!t||a(e)>=a(t))&&i.set(e.path,e)};for(let t of e)c(t);for(let e of t)c(e);return[...i.values()]},u=async e=>{if(await o())try{return await r.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await n.i(e);return await o()&&r.o(e,t).catch(()=>{}),t},d=async(e,t,i)=>{let a=t instanceof Blob?t:new Blob([t],i?.contentType?{type:i.contentType}:void 0);if(await o()){await r.o(e,a,i),await s()&&n.s(e,a,i).catch(e=>console.warn(`fs: cloud replicate failed`,e));return}if(await s())return n.s(e,a,i);throw Error(`fs: no storage backend available`)},f=async e=>{let t=[];if(await o()&&t.push(r.a(e).catch(()=>{})),await s()&&t.push(n.a(e).catch(()=>{})),!t.length)throw Error(`fs: no storage backend available`);await Promise.all(t)},p=async e=>{let t=await n.i(e);return await o()&&await r.o(e,t),t},m=e.n({appendFile:()=>j,appendFileSync:()=>y,available:()=>g,default:()=>W,exists:()=>R,existsSync:()=>b,flush:()=>V,lstatSync:()=>S,mkdir:()=>P,mkdirSync:()=>w,mount:()=>B,promises:()=>z,pull:()=>U,readFile:()=>k,readFileSync:()=>_,readdir:()=>N,readdirSync:()=>C,remount:()=>H,rename:()=>L,renameSync:()=>O,rm:()=>F,rmSync:()=>T,rmdirSync:()=>E,stat:()=>M,statSync:()=>x,unlink:()=>I,unlinkSync:()=>D,writeFile:()=>A,writeFileSync:()=>v}),h=t.t(i,{memfs:!0}),{available:g,readFileSync:_,writeFileSync:v,appendFileSync:y,existsSync:b,statSync:x,lstatSync:S,readdirSync:C,mkdirSync:w,rmSync:T,rmdirSync:E,unlinkSync:D,renameSync:O,readFile:k,writeFile:A,appendFile:j,stat:M,readdir:N,mkdir:P,rm:F,unlink:I,rename:L,exists:R,promises:z,mount:B,flush:V,remount:H}=h,U=p,W={...h,pull:U};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return H}});
|
package/fs.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`./api-CDb2pv7C.cjs`),require(`./node-fs-lrlD_zqB.cjs`),require(`./storage-BadvHtv0.cjs`);const e=require(`./fs-CmgWrokB.cjs`);exports.appendFile=e.t,exports.appendFileSync=e.n,exports.available=e.r,exports.default=e.s,exports.exists=e.i,exports.existsSync=e.a,exports.flush=e.o,exports.lstatSync=e.l,exports.mkdir=e.u,exports.mkdirSync=e.d,exports.mount=e.f,exports.promises=e.p,exports.pull=e.m,exports.readFile=e.h,exports.readFileSync=e.g,exports.readdir=e._,exports.readdirSync=e.v,exports.remount=e.y,exports.rename=e.b,exports.renameSync=e.x,exports.rm=e.S,exports.rmSync=e.C,exports.rmdirSync=e.w,exports.stat=e.T,exports.statSync=e.E,exports.unlink=e.D,exports.unlinkSync=e.O,exports.writeFile=e.k,exports.writeFileSync=e.A;
|
package/fs.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as node_fs from 'node:fs';
|
|
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
|
+
};
|
|
29
|
+
|
|
30
|
+
declare const available: () => Promise<boolean>;
|
|
31
|
+
declare const readFileSync: (path: node_fs.PathLike, options?: ReadOptions) => Buffer | string;
|
|
32
|
+
declare const writeFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
33
|
+
declare const appendFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
34
|
+
declare const existsSync: (path: node_fs.PathLike) => boolean;
|
|
35
|
+
declare const statSync: (path: node_fs.PathLike) => Stats;
|
|
36
|
+
declare const lstatSync: (path: node_fs.PathLike) => Stats;
|
|
37
|
+
declare const readdirSync: (path: node_fs.PathLike) => string[];
|
|
38
|
+
declare const mkdirSync: (path: node_fs.PathLike, options?: MakeOptions) => void;
|
|
39
|
+
declare const rmSync: (path: node_fs.PathLike, options?: {
|
|
40
|
+
recursive?: boolean;
|
|
41
|
+
force?: boolean;
|
|
42
|
+
}) => void;
|
|
43
|
+
declare const rmdirSync: (path: node_fs.PathLike, options?: {
|
|
44
|
+
recursive?: boolean;
|
|
45
|
+
}) => void;
|
|
46
|
+
declare const unlinkSync: (path: node_fs.PathLike) => void;
|
|
47
|
+
declare const renameSync: (from: node_fs.PathLike, to: node_fs.PathLike) => void;
|
|
48
|
+
declare const readFile: (path: node_fs.PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
|
|
49
|
+
declare const writeFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
50
|
+
declare const appendFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
51
|
+
declare const stat: (path: node_fs.PathLike, callback: Callback<Stats>) => void;
|
|
52
|
+
declare const readdir: (path: node_fs.PathLike, a: unknown, b?: Callback<string[]>) => void;
|
|
53
|
+
declare const mkdir: (path: node_fs.PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
|
|
54
|
+
declare const rm: (path: node_fs.PathLike, a: {
|
|
55
|
+
recursive?: boolean;
|
|
56
|
+
} | Callback<void>, b?: Callback<void>) => void;
|
|
57
|
+
declare const unlink: (path: node_fs.PathLike, callback: Callback<void>) => void;
|
|
58
|
+
declare const rename: (from: node_fs.PathLike, to: node_fs.PathLike, callback: Callback<void>) => void;
|
|
59
|
+
declare const exists: (path: node_fs.PathLike, callback: (exists: boolean) => void) => void;
|
|
60
|
+
declare const promises: {
|
|
61
|
+
readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
62
|
+
writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
63
|
+
appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
64
|
+
stat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
65
|
+
lstat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
66
|
+
readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
67
|
+
mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
68
|
+
rm: (path: node_fs.PathLike, options?: {
|
|
69
|
+
recursive?: boolean;
|
|
70
|
+
}) => Promise<void>;
|
|
71
|
+
rmdir: (path: node_fs.PathLike, options?: {
|
|
72
|
+
recursive?: boolean;
|
|
73
|
+
}) => Promise<void>;
|
|
74
|
+
unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
75
|
+
rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
76
|
+
access: (path: node_fs.PathLike) => Promise<void>;
|
|
77
|
+
};
|
|
78
|
+
declare const mount: () => Promise<void>;
|
|
79
|
+
declare const flush: () => Promise<void>;
|
|
80
|
+
declare const remount: () => Promise<void>;
|
|
81
|
+
declare const pull: (path: string) => Promise<Blob>;
|
|
82
|
+
declare const _default: {
|
|
83
|
+
pull: (path: string) => Promise<Blob>;
|
|
84
|
+
available: () => Promise<boolean>;
|
|
85
|
+
readFileSync: (path: node_fs.PathLike, options?: ReadOptions) => Buffer | string;
|
|
86
|
+
writeFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
87
|
+
appendFileSync: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => void;
|
|
88
|
+
existsSync: (path: node_fs.PathLike) => boolean;
|
|
89
|
+
statSync: (path: node_fs.PathLike) => Stats;
|
|
90
|
+
lstatSync: (path: node_fs.PathLike) => Stats;
|
|
91
|
+
readdirSync: (path: node_fs.PathLike) => string[];
|
|
92
|
+
mkdirSync: (path: node_fs.PathLike, options?: MakeOptions) => void;
|
|
93
|
+
rmSync: (path: node_fs.PathLike, options?: {
|
|
94
|
+
recursive?: boolean;
|
|
95
|
+
force?: boolean;
|
|
96
|
+
}) => void;
|
|
97
|
+
rmdirSync: (path: node_fs.PathLike, options?: {
|
|
98
|
+
recursive?: boolean;
|
|
99
|
+
}) => void;
|
|
100
|
+
unlinkSync: (path: node_fs.PathLike) => void;
|
|
101
|
+
renameSync: (from: node_fs.PathLike, to: node_fs.PathLike) => void;
|
|
102
|
+
readFile: (path: node_fs.PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
|
|
103
|
+
writeFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
104
|
+
appendFile: (path: node_fs.PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
|
|
105
|
+
stat: (path: node_fs.PathLike, callback: Callback<Stats>) => void;
|
|
106
|
+
readdir: (path: node_fs.PathLike, a: unknown, b?: Callback<string[]>) => void;
|
|
107
|
+
mkdir: (path: node_fs.PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
|
|
108
|
+
rm: (path: node_fs.PathLike, a: {
|
|
109
|
+
recursive?: boolean;
|
|
110
|
+
} | Callback<void>, b?: Callback<void>) => void;
|
|
111
|
+
unlink: (path: node_fs.PathLike, callback: Callback<void>) => void;
|
|
112
|
+
rename: (from: node_fs.PathLike, to: node_fs.PathLike, callback: Callback<void>) => void;
|
|
113
|
+
exists: (path: node_fs.PathLike, callback: (exists: boolean) => void) => void;
|
|
114
|
+
promises: {
|
|
115
|
+
readFile: (path: node_fs.PathLike, options?: ReadOptions) => Promise<Buffer | string>;
|
|
116
|
+
writeFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
117
|
+
appendFile: (path: node_fs.PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
|
|
118
|
+
stat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
119
|
+
lstat: (path: node_fs.PathLike) => Promise<Stats>;
|
|
120
|
+
readdir: (path: node_fs.PathLike) => Promise<string[]>;
|
|
121
|
+
mkdir: (path: node_fs.PathLike, options?: MakeOptions) => Promise<void>;
|
|
122
|
+
rm: (path: node_fs.PathLike, options?: {
|
|
123
|
+
recursive?: boolean;
|
|
124
|
+
}) => Promise<void>;
|
|
125
|
+
rmdir: (path: node_fs.PathLike, options?: {
|
|
126
|
+
recursive?: boolean;
|
|
127
|
+
}) => Promise<void>;
|
|
128
|
+
unlink: (path: node_fs.PathLike) => Promise<void>;
|
|
129
|
+
rename: (from: node_fs.PathLike, to: node_fs.PathLike) => Promise<void>;
|
|
130
|
+
access: (path: node_fs.PathLike) => Promise<void>;
|
|
131
|
+
};
|
|
132
|
+
mount: () => Promise<void>;
|
|
133
|
+
flush: () => Promise<void>;
|
|
134
|
+
remount: () => Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export { appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
|
|
138
|
+
export type { Stats };
|
package/fs.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./api-ByfayMm1.js";
|
|
2
|
+
import "./node-fs-Bd_UUx1m.js";
|
|
3
|
+
import "./storage-z0q3iena.js";
|
|
4
|
+
import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, _ as s, a as c, b as l, d as u, f as d, g as f, h as p, i as m, k as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, t as C, u as w, v as T, w as E, x as D, y as O } from "./fs-BiS_UsCn.js";
|
|
5
|
+
export { C as appendFile, v as appendFileSync, x as available, S as default, m as exists, c as existsSync, y as flush, g as lstatSync, w as mkdir, u as mkdirSync, d as mount, b as promises, _ as pull, p as readFile, f as readFileSync, s as readdir, T as readdirSync, O as remount, l as rename, D as renameSync, a as rm, t as rmSync, E as rmdirSync, o as stat, r as statSync, n as unlink, i as unlinkSync, h as writeFile, e as writeFileSync };
|
package/http.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./chunk-B6C_zzib.cjs`);require(`./api-CDb2pv7C.cjs`),require(`./utils-BsNRWMfl.cjs`);const t=require(`./net-C5kWnI4C.cjs`);let n=require(`buffer`),r=require(`stream`);var i=e.n({Agent:()=>T,ClientRequest:()=>S,HTTPParser:()=>g,IncomingMessage:()=>v,METHODS:()=>o,STATUS_CODES:()=>s,Server:()=>w,ServerResponse:()=>b,_default:()=>A,createServer:()=>k,default:()=>A,get:()=>O,globalAgent:()=>E,request:()=>D}),a=new TextDecoder(`latin1`),o=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),s={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},c=new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),l=13,u=10,d=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,f=(e,t)=>(e.code=t,e),p=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},m=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===l&&e[n+1]===u)return n;return-1},h=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===l&&e[t+1]===u&&e[t+2]===l&&e[t+3]===u)return t;return-1},g=class{buf=new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=p(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=h(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=a.decode(e).split(`\r
|
|
2
|
+
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],o={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(o,n,r)}let s={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:o,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);s.method=(e??`GET`).toUpperCase(),s.url=t??`/`,this.applyVersion(s,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);s.statusCode=parseInt(a,10)||0,s.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(s,t)}return s}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:c.has(r)||(e[r]=`${i}, ${n}`)}setupBody(e){if(this.skipBody){this.framing=`none`;return}let t=e.headers[`transfer-encoding`];if(typeof t==`string`&&t.toLowerCase().includes(`chunked`)){this.framing=`chunked`,this.chunkState=`size`;return}let n=e.headers[`content-length`];if(typeof n==`string`&&n!==``){let e=parseInt(n,10);e>0?(this.framing=`length`,this.bodyRemaining=e):this.framing=`none`;return}if(this.mode===`response`){let t=e.statusCode??0;t>=100&&t<200||t===204||t===304?this.framing=`none`:this.framing=`eof`}else this.framing=`none`}consumeBody(){if(this.framing===`length`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);return this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0}return this.framing===`eof`?(this.buf.length>0&&(this.handlers.onBody(this.buf),this.buf=new Uint8Array),!1):this.framing===`chunked`?this.consumeChunked():!0}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=m(this.buf,0);if(e===-1)return!1;let t=a.decode(this.buf.subarray(0,e)),n=parseInt(t.split(`;`)[0].trim(),16);if(this.buf=this.buf.subarray(e+2),Number.isNaN(n))return!0;n===0?this.chunkState=`trailer`:(this.bodyRemaining=n,this.chunkState=`data`)}else if(this.chunkState===`data`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0&&(this.chunkState=`dataCRLF`)}else if(this.chunkState===`dataCRLF`){if(this.buf.length<2)return!1;this.buf=this.buf.subarray(2),this.chunkState=`size`}else{let e=m(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},_=(e,t)=>n.Buffer.isBuffer(e)?e:typeof e==`string`?n.Buffer.from(e,t??`utf8`):e instanceof Uint8Array?n.Buffer.from(e):e instanceof ArrayBuffer?n.Buffer.from(new Uint8Array(e)):n.Buffer.from(String(e)),v=class extends r.Stream.Readable{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];trailers={};rawTrailers=[];method;url;statusCode;statusMessage;complete=!1;socket;constructor(e){super(),this.socket=e}get connection(){return this.socket}_applyHead(e){this.httpVersion=e.httpVersion,this.httpVersionMajor=e.httpVersionMajor,this.httpVersionMinor=e.httpVersionMinor,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.method=e.method,this.url=e.url,this.statusCode=e.statusCode,this.statusMessage=e.statusMessage}_read(){}setTimeout(e,t){return this.socket.setTimeout(e,t),this}},y=class extends r.Stream.Writable{_headerStore=new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw f(Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!d.test(e))throw f(TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw f(TypeError(`Invalid value "undefined" for header "${e}"`),`ERR_HTTP_INVALID_HEADER_VALUE`);return this._headerStore.set(e.toLowerCase(),[e,Array.isArray(t)?[...t]:t]),this}getHeader(e){return this._headerStore.get(e.toLowerCase())?.[1]}getHeaderNames(){return[...this._headerStore.values()].map(([e])=>e)}getHeaders(){let e={};for(let[t,n]of this._headerStore.values())e[t]=n;return e}hasHeader(e){return this._headerStore.has(e.toLowerCase())}removeHeader(e){if(this.headersSent)throw Error(`Cannot remove headers after they are sent to the client`);this._headerStore.delete(e.toLowerCase())}_storeHeader(e){let t=this.hasHeader(`content-length`),n=this.getHeader(`transfer-encoding`);typeof n==`string`&&n.toLowerCase().includes(`chunked`)?this.chunkedEncoding=!0:!t&&this._shouldSendBody()&&(this.chunkedEncoding=!0,this.setHeader(`Transfer-Encoding`,`chunked`));let r=e+`\r
|
|
3
|
+
`;for(let[e,t]of this._headerStore.values())if(Array.isArray(t))for(let n of t)r+=`${e}: ${n}\r\n`;else r+=`${e}: ${t}\r\n`;return r+=`\r
|
|
4
|
+
`,r}_writeToSocket(e,t){if(!this.socket){t(Error(`Socket is not available`));return}this.socket.write(e,t)}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,r){let i=_(e),a=[];if(this.headersSent||=(this._implicitHeader(),a.push(n.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?i.length>0&&(a.push(n.Buffer.from(`${i.length.toString(16)}\r\n`,`latin1`)),a.push(i),a.push(n.Buffer.from(`\r
|
|
5
|
+
`,`latin1`))):a.push(i),a.length===0){r();return}this._writeToSocket(n.Buffer.concat(a),r)}_final(e){let t=[];if(this.headersSent||=(!this.chunkedEncoding&&!this.hasHeader(`content-length`)&&this.setHeader(`Content-Length`,0),this._implicitHeader(),t.push(n.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding&&t.push(n.Buffer.from(`0\r
|
|
6
|
+
\r
|
|
7
|
+
`,`latin1`)),this.finished=!0,t.length===0){e();return}this._writeToSocket(n.Buffer.concat(t),e)}end(e,t,n){if(e!=null&&typeof e!=`function`&&!this._bodyWritten&&!this.headersSent&&!this.chunkedEncoding&&!this.hasHeader(`content-length`)){let n=typeof t==`string`?t:void 0;this.setHeader(`Content-Length`,_(e,n).length)}return super.end(e,t,n)}_headBlock},b=class extends y{statusCode=200;statusMessage;_writeHeadCalled=!1;sendDate=!0;req;socket;_keepAlive=!0;constructor(e){super(),this.req=e,this.socket=e.socket}_shouldSendBody(){if(this.req.method===`HEAD`)return!1;let e=this.statusCode;return!(e>=100&&e<200||e===204||e===304)}writeHead(e,t,n){if(this._writeHeadCalled||this.headersSent)throw f(Error(`Cannot render headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);this._writeHeadCalled=!0,this.statusCode=e;let r=n;if(typeof t==`string`?this.statusMessage=t:t!=null&&(r=t),Array.isArray(r)){let e=Array.isArray(r[0])?r:Array.from({length:Math.floor(r.length/2)},(e,t)=>[r[t*2],r[t*2+1]]);for(let[t,n]of e)n!==void 0&&this._appendHeader(t,n)}else if(r)for(let[e,t]of Object.entries(r))t!==void 0&&this.setHeader(e,t);return this}_appendHeader(e,t){let n=this.getHeader(e);if(n===void 0)this.setHeader(e,t);else{let r=[...Array.isArray(n)?n:[n],...Array.isArray(t)?t:[t]].map(String);this.setHeader(e,r)}}_implicitHeader(){let e=this.statusMessage??s[this.statusCode]??`unknown`;this.sendDate&&!this.hasHeader(`date`)&&this.setHeader(`Date`,new Date().toUTCString()),this.hasHeader(`connection`)||this.setHeader(`Connection`,this._keepAlive?`keep-alive`:`close`),this._headBlock=this._storeHeader(`HTTP/1.1 ${this.statusCode} ${e}`)}writeContinue(){this._writeToSocket(n.Buffer.from(`HTTP/1.1 100 Continue\r
|
|
8
|
+
\r
|
|
9
|
+
`,`latin1`),()=>{})}setTimeout(e,t){return this.socket?.setTimeout(e,t),this}},x=(...e)=>{let t={},n={},r,i=[...e],a=i.shift();if(typeof a==`string`||a instanceof URL){let e=typeof a==`string`?new URL(a):a;t={protocol:e.protocol,hostname:e.hostname,host:e.hostname,port:e.port,path:`${e.pathname}${e.search}`,auth:e.username?`${e.username}:${e.password}`:void 0};let o=i.shift();typeof o==`function`?r=o:o&&typeof o==`object`&&(n=o,r=i.shift())}else a&&typeof a==`object`&&(n=a,r=i.shift());return{options:{...t,...n},callback:r}},S=class extends y{method;path;host;protocol;socket;get connection(){return this.socket}res=null;aborted=!1;_aborted=!1;constructor(e,r){super(),this.method=(e.method??`GET`).toUpperCase(),this.path=e.path??`/`,this.protocol=e.protocol??`http:`;let i=e.hostname??e.host??`localhost`;this.host=i;let a=Number(e.port??(this.protocol===`https:`?443:80));if(r&&this.once(`response`,r),e.headers)for(let[t,n]of Object.entries(e.headers))n!==void 0&&this.setHeader(t,n);if(!this.hasHeader(`host`)){let e=this.protocol===`https:`&&a===443||this.protocol!==`https:`&&a===80;this.setHeader(`Host`,e?i:`${i}:${a}`)}e.auth&&!this.hasHeader(`authorization`)&&this.setHeader(`Authorization`,`Basic ${n.Buffer.from(e.auth).toString(`base64`)}`),this.socket=new t.n,this.emit(`socket`,this.socket),this.socket.on(`error`,e=>{this._aborted||this.emit(`error`,e)}),this._attachResponseParser(),this.socket.connect({host:i,port:a},()=>{this.emit(`connect`)})}_shouldSendBody(){return this.method!==`GET`&&this.method!==`HEAD`&&this.method!==`DELETE`}_implicitHeader(){this._headBlock=this._storeHeader(`${this.method} ${this.path} HTTP/1.1`)}_attachResponseParser(){let e=new v(this.socket),t=new g(`response`,{onHeaders:n=>{e._applyHead(n),this.method===`HEAD`&&(t.skipBody=!0),this.res=e,this.emit(`response`,e)},onBody:t=>{e.push(n.Buffer.from(t))},onComplete:()=>{e.complete=!0,e.push(null)}});this.socket.on(`data`,e=>{this._aborted||t.execute(e)}),this.socket.on(`end`,()=>{t.finish()}),this.socket.on(`close`,()=>{this.emit(`close`)})}abort(){this._aborted||(this._aborted=!0,this.aborted=!0,this.emit(`abort`),this.socket.destroy())}destroy(e){return this._aborted?this:(this._aborted=!0,this.socket.destroy(e),super.destroy(e),this)}end(e,t,n){return this._aborted?this:super.end(e,t,n)}_writeToSocket(e,t){if(this._aborted){t();return}super._writeToSocket(e,t)}setTimeout(e,t){return this.socket.setTimeout(e,t),this}setNoDelay(e){this.socket.setNoDelay(e)}setSocketKeepAlive(e,t){this.socket.setKeepAlive(e,t)}},C=class extends t.t{constructor(e,t){let n={},r=t;typeof e==`function`?r=e:e&&(n=e),super(n),r&&this.on(`request`,r),this.on(`connection`,e=>this._handleConnection(e))}_handleConnection(e){let t=null,r=new g(`request`,{onHeaders:n=>{t=new v(e),t._applyHead(n),n.method===`HEAD`&&(r.skipBody=!0);let i=new b(t),a=String(n.headers.connection??``).toLowerCase();i._keepAlive=n.httpVersionMinor>=1?a!==`close`:a===`keep-alive`,i.on(`finish`,()=>{i._keepAlive||e.end()}),this.emit(`request`,t,i)},onBody:e=>{t?.push(n.Buffer.from(e))},onComplete:()=>{t&&(t.complete=!0,t.push(null)),t=null}});e.on(`data`,e=>r.execute(e)),e.on(`end`,()=>{r.finish(),t&&t.push(null)}),e.on(`error`,t=>this.emit(`clientError`,t,e))}},w=new Proxy(C,{apply:(e,t,n)=>new e(...n)}),T=class{maxSockets;maxFreeSockets;keepAlive;options;constructor(e={}){this.options=e,this.keepAlive=!!e.keepAlive,this.maxSockets=e.maxSockets??1/0,this.maxFreeSockets=e.maxFreeSockets??256}getName(e={}){return`${e.host??`localhost`}:${e.port??``}:${e.localAddress??``}`}destroy(){}},E=new T,D=(...e)=>{let{options:t,callback:n}=x(...e);return new S(t,n)},O=(...e)=>{let t=D(...e);return t.end(),t},k=(e,t)=>new w(e,t),A={METHODS:o,STATUS_CODES:s,Agent:T,globalAgent:E,Server:w,ServerResponse:b,IncomingMessage:v,ClientRequest:S,OutgoingMessage:y,createServer:k,request:D,get:O};exports.Agent=T,exports.ClientRequest=S,exports.HTTPParser=g,exports.IncomingMessage=v,exports.METHODS=o,exports.STATUS_CODES=s,exports.Server=w,exports.ServerResponse=b,exports._default=A,exports.default=A,exports.createServer=k,exports.get=O,exports.globalAgent=E,exports.request=D,Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|