@fkn/lib 0.9.63 → 0.9.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +34 -0
  2. package/account-Bm7uIcQo.d.ts +39 -0
  3. package/account-Uh0-1Cbp.js +22 -0
  4. package/{account-generation-B0cJrpDx.cjs → account-generation-ACCBzaI-.cjs} +1 -1
  5. package/{account-generation-u31dhamM.js → account-generation-BKHNe-jL.js} +2 -3
  6. package/account-m2iCmNui.cjs +1 -0
  7. package/{account-storage-ZkzqZp3A.js → account-storage-BmCVutNL.js} +4 -5
  8. package/{account-storage-Co9IvkPr.d.ts → account-storage-UmSfF63A.d.ts} +1 -66
  9. package/{account-storage-BnohkyMJ.cjs → account-storage-dYWDpqsr.cjs} +1 -1
  10. package/account.cjs +1 -1
  11. package/account.d.ts +3 -40
  12. package/account.js +1 -23
  13. package/{api-xh6lzApn.d.ts → api-0Yp9uZcV.d.ts} +3 -7
  14. package/{api-Di2Ff3jS.js → api-DRglK7ft.js} +115 -156
  15. package/api-DrvhPN56.cjs +3 -0
  16. package/api.cjs +1 -1
  17. package/api.d.ts +2 -2
  18. package/api.js +1 -2
  19. package/attach-policy.d.ts +0 -4
  20. package/attach-policy.js +2 -3
  21. package/broker-frame-CF4-yXtj.cjs +9 -0
  22. package/broker-frame-vjSpBa8d.js +51 -0
  23. package/broker-frame.cjs +1 -0
  24. package/broker-frame.d.ts +12 -0
  25. package/broker-frame.js +1 -0
  26. package/{busy-DsMWrSzc.js → busy-C1JPjoZ_.js} +1 -2
  27. package/cloud/dgram.cjs +1 -1
  28. package/cloud/dgram.d.ts +1 -1
  29. package/cloud/dgram.js +1 -2
  30. package/cloud/dns.cjs +1 -1
  31. package/cloud/dns.d.ts +2 -2
  32. package/cloud/dns.js +1 -2
  33. package/cloud/fetch.cjs +1 -1
  34. package/cloud/fetch.d.ts +1 -1
  35. package/cloud/fetch.js +1 -2
  36. package/cloud/fs/promises.cjs +1 -1
  37. package/cloud/fs/promises.d.ts +3 -5
  38. package/cloud/fs/promises.js +2 -3
  39. package/cloud/fs.cjs +1 -1
  40. package/cloud/fs.d.ts +4 -4
  41. package/cloud/fs.js +4 -34
  42. package/cloud/http.cjs +1 -1
  43. package/cloud/http.d.ts +1 -1
  44. package/cloud/http.js +1 -2
  45. package/cloud/net.cjs +1 -1
  46. package/cloud/net.d.ts +1 -1
  47. package/cloud/net.js +3 -3
  48. package/{cloud-CI7FFRMC.d.ts → cloud-BoH54gaM.d.ts} +7 -11
  49. package/{cloud-C6rG_aod.js → cloud-C7StNncS.js} +17 -17
  50. package/cloud-TN0eDUy3.cjs +1 -0
  51. package/cloud.cjs +1 -1
  52. package/cloud.d.ts +7 -7
  53. package/cloud.js +7 -7
  54. package/connect-button-2FmOM8ai.d.ts +2 -0
  55. package/{connect-button-DtsN3X1J.js → connect-button-C1wKkIhh.js} +1 -2
  56. package/{contract-BGMJVvTg.d.ts → contract-0rua6Wsh.d.ts} +11 -6
  57. package/contract.d.ts +3 -3
  58. package/contract.js +1 -2
  59. package/desktop-DOubT4ES.d.ts +57 -0
  60. package/desktop-vXKU4wEK.cjs +1 -0
  61. package/desktop-xTT7ciGX.js +50 -0
  62. package/desktop.cjs +1 -1
  63. package/desktop.d.ts +2 -58
  64. package/desktop.js +1 -51
  65. package/dgram-BBbLokVF.js +397 -0
  66. package/dgram-BYk-QDHW.d.ts +118 -0
  67. package/dgram-D9ljiUFh.cjs +1 -0
  68. package/dgram.cjs +1 -1
  69. package/dgram.d.ts +2 -119
  70. package/dgram.js +1 -410
  71. package/dns-2v96zoEh.cjs +1 -0
  72. package/dns-DyB4K2oE.d.ts +9 -0
  73. package/dns-o8DLFjP1.js +5 -0
  74. package/dns.cjs +1 -1
  75. package/dns.d.ts +3 -10
  76. package/dns.js +1 -6
  77. package/extension-BXBjpypy.cjs +1 -0
  78. package/{extension-C3_aJX7C.js → extension-D5UMnEmQ.js} +11 -12
  79. package/{extension-C1bcizcn.d.ts → extension-D98KM8W7.d.ts} +1 -27
  80. package/extension.cjs +1 -1
  81. package/extension.d.ts +2 -2
  82. package/extension.js +2 -2
  83. package/fs/promises.cjs +1 -1
  84. package/fs/promises.d.ts +2 -4
  85. package/fs/promises.js +2 -3
  86. package/fs--MLHvMW-.cjs +1 -0
  87. package/fs-BX_ghRy0.cjs +1 -0
  88. package/fs-BnWXGRik.js +33 -0
  89. package/{fs-DCJAYoYy.d.ts → fs-ChOYC6VD.d.ts} +3 -4
  90. package/{fs-DgdN2HPt.js → fs-Cw7CcUhx.js} +17 -41
  91. package/fs.cjs +1 -1
  92. package/fs.d.ts +4 -4
  93. package/fs.js +2 -2
  94. package/{hosts-t7CKGTRz.js → hosts-HUfgMimI.js} +1 -2
  95. package/http-BE3UBktN.cjs +9 -0
  96. package/http-CDhG4bUc.d.ts +187 -0
  97. package/http-DIDjdm08.js +523 -0
  98. package/http.cjs +1 -9
  99. package/http.d.ts +2 -188
  100. package/http.js +1 -542
  101. package/index-CUWTpQKP.d.ts +87 -0
  102. package/{index-BQgZVQl7.d.ts → index-CcVwh9yz.d.ts} +0 -2
  103. package/{index-C5DdoMGo.d.ts → index-Cu5EcdK0.d.ts} +0 -59
  104. package/{index-57lTXnoe.d.ts → index-D6GPJ4Ow.d.ts} +29 -26
  105. package/index.cjs +1 -1
  106. package/index.d.ts +17 -25
  107. package/index.js +22 -27
  108. package/lib-Bs-g5jyp.cjs +53 -0
  109. package/{lib-BrsqpUkv.js → lib-CtJaID_y.js} +7 -31
  110. package/{messages-AdPfdoLV.d.ts → messages-B9dOXntM.d.ts} +0 -2
  111. package/messages.d.ts +1 -1
  112. package/messages.js +1 -2
  113. package/net-COkJw8lV.js +286 -0
  114. package/net-Dk2kqtgE.cjs +1 -0
  115. package/{net-BpyIeQ8r.d.ts → net-mVAYXs8e.d.ts} +5 -7
  116. package/net.cjs +1 -1
  117. package/net.d.ts +1 -1
  118. package/net.js +3 -323
  119. package/{node-fs-DY2fO5zd.js → node-fs-B4pY08Kc.js} +3 -10
  120. package/node-fs-DN0ejGTL.cjs +1 -0
  121. package/opfs/promises.cjs +1 -1
  122. package/opfs/promises.d.ts +2 -4
  123. package/opfs/promises.js +2 -3
  124. package/{opfs-D0goLAQW.js → opfs-CzCfVam3.js} +2 -3
  125. package/opfs-D3pYzYRc.js +35 -0
  126. package/opfs-DuXvTgIl.cjs +1 -0
  127. package/opfs.cjs +1 -1
  128. package/opfs.d.ts +3 -88
  129. package/opfs.js +1 -36
  130. package/package.json +6 -1
  131. package/packages-BEadIy_h.d.ts +155 -0
  132. package/packages-Cws_rcgf.js +346 -0
  133. package/packages-DT8vPB5_.cjs +1 -0
  134. package/packages.cjs +1 -1
  135. package/packages.d.ts +3 -156
  136. package/packages.js +1 -347
  137. package/{proxy-tsVhjcl-.js → proxy-BBAQxJmP.js} +13 -13
  138. package/{proxy-Dz60YyYy.d.ts → proxy-BP40IXYD.d.ts} +2 -4
  139. package/proxy-DVgGp6A8.cjs +1 -0
  140. package/react.cjs +1 -1
  141. package/react.d.ts +16 -4
  142. package/react.js +96 -7
  143. package/{relay-choice-BGwXRC5d.js → relay-choice-Bb3oP2gw.js} +1 -2
  144. package/{relay-choice-5yUPI-tJ.d.ts → relay-choice-DOUttUnL.d.ts} +2 -4
  145. package/{rolldown-runtime-Dy4uBu1J.js → rolldown-runtime-CGnMp29N.js} +1 -2
  146. package/rooms-C6mbannC.d.ts +227 -0
  147. package/rooms-DHFS9cwA.cjs +1 -0
  148. package/rooms-DP5stTEr.js +300 -0
  149. package/rooms.cjs +1 -1
  150. package/rooms.d.ts +3 -228
  151. package/rooms.js +1 -301
  152. package/storage-BCjYihUO.cjs +1 -0
  153. package/storage-BhfImh_2.js +136 -0
  154. package/storage-DpCLksAa.d.ts +68 -0
  155. package/storage.cjs +1 -1
  156. package/storage.d.ts +3 -69
  157. package/storage.js +1 -137
  158. package/{utils-Cyq8uJiy.js → utils-DtWP-E9x.js} +1 -2
  159. package/{wire-Fk5pJaoy.d.ts → wire-DhmLnYEU.d.ts} +0 -2
  160. package/wire.d.ts +1 -1
  161. package/wire.js +1 -2
  162. package/api-BSk3dc_X.cjs +0 -3
  163. package/cloud-BoiHKoRZ.cjs +0 -1
  164. package/connect-button-Cp0NS95-.d.ts +0 -4
  165. package/extension-Crv4aUAm.cjs +0 -1
  166. package/fs-CjQTj3FA.cjs +0 -1
  167. package/lib-C_X3WR4G.cjs +0 -53
  168. package/node-fs-vsWuoMGa.cjs +0 -1
  169. package/proxy-BA92hkId.cjs +0 -1
package/http.js CHANGED
@@ -1,542 +1 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { Server as t, Socket as n } from "./net.js";
3
- import { Buffer as r } from "buffer";
4
- import { Stream as i } from "stream";
5
- //#region src/webvpn/http.ts
6
- var a = /* @__PURE__ */ e({
7
- Agent: () => T,
8
- ClientRequest: () => C,
9
- HTTPParser: () => _,
10
- IncomingMessage: () => y,
11
- METHODS: () => s,
12
- STATUS_CODES: () => c,
13
- Server: () => w,
14
- ServerResponse: () => x,
15
- _default: () => A,
16
- createServer: () => k,
17
- default: () => A,
18
- get: () => O,
19
- globalAgent: () => E,
20
- request: () => D
21
- }), o = new TextDecoder("latin1"), s = /* @__PURE__ */ "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("."), c = {
22
- 100: "Continue",
23
- 101: "Switching Protocols",
24
- 102: "Processing",
25
- 103: "Early Hints",
26
- 200: "OK",
27
- 201: "Created",
28
- 202: "Accepted",
29
- 203: "Non-Authoritative Information",
30
- 204: "No Content",
31
- 205: "Reset Content",
32
- 206: "Partial Content",
33
- 207: "Multi-Status",
34
- 208: "Already Reported",
35
- 226: "IM Used",
36
- 300: "Multiple Choices",
37
- 301: "Moved Permanently",
38
- 302: "Found",
39
- 303: "See Other",
40
- 304: "Not Modified",
41
- 305: "Use Proxy",
42
- 307: "Temporary Redirect",
43
- 308: "Permanent Redirect",
44
- 400: "Bad Request",
45
- 401: "Unauthorized",
46
- 402: "Payment Required",
47
- 403: "Forbidden",
48
- 404: "Not Found",
49
- 405: "Method Not Allowed",
50
- 406: "Not Acceptable",
51
- 407: "Proxy Authentication Required",
52
- 408: "Request Timeout",
53
- 409: "Conflict",
54
- 410: "Gone",
55
- 411: "Length Required",
56
- 412: "Precondition Failed",
57
- 413: "Payload Too Large",
58
- 414: "URI Too Long",
59
- 415: "Unsupported Media Type",
60
- 416: "Range Not Satisfiable",
61
- 417: "Expectation Failed",
62
- 418: "I'm a Teapot",
63
- 421: "Misdirected Request",
64
- 422: "Unprocessable Entity",
65
- 423: "Locked",
66
- 424: "Failed Dependency",
67
- 425: "Too Early",
68
- 426: "Upgrade Required",
69
- 428: "Precondition Required",
70
- 429: "Too Many Requests",
71
- 431: "Request Header Fields Too Large",
72
- 451: "Unavailable For Legal Reasons",
73
- 500: "Internal Server Error",
74
- 501: "Not Implemented",
75
- 502: "Bad Gateway",
76
- 503: "Service Unavailable",
77
- 504: "Gateway Timeout",
78
- 505: "HTTP Version Not Supported",
79
- 506: "Variant Also Negotiates",
80
- 507: "Insufficient Storage",
81
- 508: "Loop Detected",
82
- 509: "Bandwidth Limit Exceeded",
83
- 510: "Not Extended",
84
- 511: "Network Authentication Required"
85
- }, l = /* @__PURE__ */ new Set([
86
- "content-type",
87
- "content-length",
88
- "user-agent",
89
- "referer",
90
- "host",
91
- "authorization",
92
- "proxy-authorization",
93
- "if-modified-since",
94
- "if-unmodified-since",
95
- "from",
96
- "location",
97
- "max-forwards",
98
- "retry-after",
99
- "etag",
100
- "last-modified",
101
- "server",
102
- "age",
103
- "expires"
104
- ]), u = 13, d = 10, f = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, p = (e, t) => (e.code = t, e), m = (e, t) => {
105
- if (e.length === 0) return t;
106
- if (t.length === 0) return e;
107
- let n = new Uint8Array(e.length + t.length);
108
- return n.set(e, 0), n.set(t, e.length), n;
109
- }, h = (e, t) => {
110
- for (let n = t; n + 1 < e.length; n++) if (e[n] === u && e[n + 1] === d) return n;
111
- return -1;
112
- }, g = (e) => {
113
- for (let t = 0; t + 3 < e.length; t++) if (e[t] === u && e[t + 1] === d && e[t + 2] === u && e[t + 3] === d) return t;
114
- return -1;
115
- }, _ = class {
116
- mode;
117
- handlers;
118
- buf = /* @__PURE__ */ new Uint8Array();
119
- state = "HEAD";
120
- framing = "none";
121
- bodyRemaining = 0;
122
- chunkState = "size";
123
- skipBody = !1;
124
- constructor(e, t) {
125
- this.mode = e, this.handlers = t;
126
- }
127
- execute(e) {
128
- this.buf = m(this.buf, e);
129
- let t = !0;
130
- for (; t;) if (t = !1, this.state === "HEAD") {
131
- let e = g(this.buf);
132
- if (e === -1) return;
133
- let n = this.buf.subarray(0, e);
134
- this.buf = this.buf.subarray(e + 4);
135
- let r = this.parseHead(n);
136
- 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);
137
- } else this.consumeBody() && (this.handlers.onComplete(), this.reset(), t = this.buf.length > 0);
138
- }
139
- finish() {
140
- this.state === "BODY" && this.framing === "eof" && (this.handlers.onComplete(), this.reset());
141
- }
142
- reset() {
143
- this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
144
- }
145
- parseHead(e) {
146
- let t = o.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
147
- for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
148
- let i = [], a = {};
149
- for (let e of r) {
150
- if (!e) continue;
151
- let t = e.indexOf(":");
152
- if (t === -1) continue;
153
- let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
154
- i.push(n, r), this.addHeader(a, n, r);
155
- }
156
- let s = {
157
- httpVersionMajor: 1,
158
- httpVersionMinor: 1,
159
- httpVersion: "1.1",
160
- headers: a,
161
- rawHeaders: i
162
- };
163
- if (this.mode === "request") {
164
- let [e, t, r] = n.split(" ");
165
- s.method = (e ?? "GET").toUpperCase(), s.url = t ?? "/", this.applyVersion(s, r);
166
- } else {
167
- 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);
168
- s.statusCode = parseInt(a, 10) || 0, s.statusMessage = i === -1 ? "" : r.slice(i + 1), this.applyVersion(s, t);
169
- }
170
- return s;
171
- }
172
- applyVersion(e, t) {
173
- let n = /HTTP\/(\d)\.(\d)/i.exec(t ?? "");
174
- n && (e.httpVersionMajor = parseInt(n[1], 10), e.httpVersionMinor = parseInt(n[2], 10), e.httpVersion = `${e.httpVersionMajor}.${e.httpVersionMinor}`);
175
- }
176
- addHeader(e, t, n) {
177
- let r = t.toLowerCase();
178
- if (r === "set-cookie") {
179
- let t = e["set-cookie"];
180
- Array.isArray(t) ? t.push(n) : e["set-cookie"] = [n];
181
- return;
182
- }
183
- let i = e[r];
184
- i === void 0 ? e[r] = n : l.has(r) || (e[r] = `${i}, ${n}`);
185
- }
186
- setupBody(e) {
187
- if (this.skipBody) {
188
- this.framing = "none";
189
- return;
190
- }
191
- let t = e.headers["transfer-encoding"];
192
- if (typeof t == "string" && t.toLowerCase().includes("chunked")) {
193
- this.framing = "chunked", this.chunkState = "size";
194
- return;
195
- }
196
- let n = e.headers["content-length"];
197
- if (typeof n == "string" && n !== "") {
198
- let e = parseInt(n, 10);
199
- e > 0 ? (this.framing = "length", this.bodyRemaining = e) : this.framing = "none";
200
- return;
201
- }
202
- if (this.mode === "response") {
203
- let t = e.statusCode ?? 0;
204
- this.framing = t >= 100 && t < 200 || t === 204 || t === 304 ? "none" : "eof";
205
- } else this.framing = "none";
206
- }
207
- consumeBody() {
208
- if (this.framing === "length") {
209
- if (this.buf.length === 0) return !1;
210
- let e = Math.min(this.bodyRemaining, this.buf.length);
211
- return this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0;
212
- }
213
- return this.framing === "eof" ? (this.buf.length > 0 && (this.handlers.onBody(this.buf), this.buf = /* @__PURE__ */ new Uint8Array()), !1) : this.framing !== "chunked" || this.consumeChunked();
214
- }
215
- consumeChunked() {
216
- for (;;) if (this.chunkState === "size") {
217
- let e = h(this.buf, 0);
218
- if (e === -1) return !1;
219
- let t = o.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
220
- if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
221
- n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
222
- } else if (this.chunkState === "data") {
223
- if (this.buf.length === 0) return !1;
224
- let e = Math.min(this.bodyRemaining, this.buf.length);
225
- this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0 && (this.chunkState = "dataCRLF");
226
- } else if (this.chunkState === "dataCRLF") {
227
- if (this.buf.length < 2) return !1;
228
- this.buf = this.buf.subarray(2), this.chunkState = "size";
229
- } else {
230
- let e = h(this.buf, 0);
231
- if (e === -1) return !1;
232
- let t = e === 0;
233
- if (this.buf = this.buf.subarray(e + 2), t) return !0;
234
- }
235
- }
236
- }, v = (e, t) => r.isBuffer(e) ? e : typeof e == "string" ? r.from(e, t ?? "utf8") : e instanceof Uint8Array ? r.from(e) : e instanceof ArrayBuffer ? r.from(new Uint8Array(e)) : r.from(String(e)), y = class extends i.Readable {
237
- httpVersion = "1.1";
238
- httpVersionMajor = 1;
239
- httpVersionMinor = 1;
240
- headers = {};
241
- rawHeaders = [];
242
- trailers = {};
243
- rawTrailers = [];
244
- method;
245
- url;
246
- statusCode;
247
- statusMessage;
248
- complete = !1;
249
- socket;
250
- constructor(e) {
251
- super(), this.socket = e;
252
- }
253
- get connection() {
254
- return this.socket;
255
- }
256
- _applyHead(e) {
257
- 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;
258
- }
259
- _read() {}
260
- setTimeout(e, t) {
261
- return this.socket.setTimeout(e, t), this;
262
- }
263
- }, b = class extends i.Writable {
264
- _headerStore = /* @__PURE__ */ new Map();
265
- headersSent = !1;
266
- chunkedEncoding = !1;
267
- finished = !1;
268
- _bodyWritten = !1;
269
- setHeader(e, t) {
270
- if (this.headersSent) throw p(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
271
- if (typeof e != "string" || !f.test(e)) throw p(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
272
- if (t === void 0) throw p(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
273
- return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
274
- }
275
- getHeader(e) {
276
- return this._headerStore.get(e.toLowerCase())?.[1];
277
- }
278
- getHeaderNames() {
279
- return [...this._headerStore.values()].map(([e]) => e);
280
- }
281
- getHeaders() {
282
- let e = {};
283
- for (let [t, n] of this._headerStore.values()) e[t] = n;
284
- return e;
285
- }
286
- hasHeader(e) {
287
- return this._headerStore.has(e.toLowerCase());
288
- }
289
- removeHeader(e) {
290
- if (this.headersSent) throw Error("Cannot remove headers after they are sent to the client");
291
- this._headerStore.delete(e.toLowerCase());
292
- }
293
- _storeHeader(e) {
294
- let t = this.hasHeader("content-length"), n = this.getHeader("transfer-encoding");
295
- typeof n == "string" && n.toLowerCase().includes("chunked") ? this.chunkedEncoding = !0 : !t && this._shouldSendBody() && (this.chunkedEncoding = !0, this.setHeader("Transfer-Encoding", "chunked"));
296
- let r = e + "\r\n";
297
- for (let [e, t] of this._headerStore.values()) if (Array.isArray(t)) for (let n of t) r += `${e}: ${n}\r\n`;
298
- else r += `${e}: ${t}\r\n`;
299
- return r += "\r\n", r;
300
- }
301
- _writeToSocket(e, t) {
302
- if (!this.socket) {
303
- t(/* @__PURE__ */ Error("Socket is not available"));
304
- return;
305
- }
306
- this.socket.write(e, t);
307
- }
308
- write(e, t, n) {
309
- return this._bodyWritten = !0, super.write(e, t, n);
310
- }
311
- _write(e, t, n) {
312
- let i = v(e), a = [];
313
- if (this.headersSent ||= (this._implicitHeader(), a.push(r.from(this._headBlock, "latin1")), !0), this.chunkedEncoding ? i.length > 0 && (a.push(r.from(`${i.length.toString(16)}\r\n`, "latin1")), a.push(i), a.push(r.from("\r\n", "latin1"))) : a.push(i), a.length === 0) {
314
- n();
315
- return;
316
- }
317
- this._writeToSocket(r.concat(a), n);
318
- }
319
- _final(e) {
320
- let t = [];
321
- if (this.headersSent ||= (!this.chunkedEncoding && !this.hasHeader("content-length") && this.setHeader("Content-Length", 0), this._implicitHeader(), t.push(r.from(this._headBlock, "latin1")), !0), this.chunkedEncoding && t.push(r.from("0\r\n\r\n", "latin1")), this.finished = !0, t.length === 0) {
322
- e();
323
- return;
324
- }
325
- this._writeToSocket(r.concat(t), e);
326
- }
327
- end(e, t, n) {
328
- if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
329
- let n = typeof t == "string" ? t : void 0;
330
- this.setHeader("Content-Length", v(e, n).length);
331
- }
332
- return super.end(e, t, n);
333
- }
334
- _headBlock;
335
- }, x = class extends b {
336
- statusCode = 200;
337
- statusMessage;
338
- _writeHeadCalled = !1;
339
- sendDate = !0;
340
- req;
341
- socket;
342
- _keepAlive = !0;
343
- constructor(e) {
344
- super(), this.req = e, this.socket = e.socket;
345
- }
346
- _shouldSendBody() {
347
- if (this.req.method === "HEAD") return !1;
348
- let e = this.statusCode;
349
- return !(e >= 100 && e < 200 || e === 204 || e === 304);
350
- }
351
- writeHead(e, t, n) {
352
- if (this._writeHeadCalled || this.headersSent) throw p(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
353
- this._writeHeadCalled = !0, this.statusCode = e;
354
- let r = n;
355
- if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
356
- let e = Array.isArray(r[0]) ? r : Array.from({ length: Math.floor(r.length / 2) }, (e, t) => [r[t * 2], r[t * 2 + 1]]);
357
- for (let [t, n] of e) n !== void 0 && this._appendHeader(t, n);
358
- } else if (r) for (let [e, t] of Object.entries(r)) t !== void 0 && this.setHeader(e, t);
359
- return this;
360
- }
361
- _appendHeader(e, t) {
362
- let n = this.getHeader(e);
363
- if (n === void 0) this.setHeader(e, t);
364
- else {
365
- let r = [...Array.isArray(n) ? n : [n], ...Array.isArray(t) ? t : [t]].map(String);
366
- this.setHeader(e, r);
367
- }
368
- }
369
- _implicitHeader() {
370
- let e = this.statusMessage ?? c[this.statusCode] ?? "unknown";
371
- this.sendDate && !this.hasHeader("date") && this.setHeader("Date", (/* @__PURE__ */ new Date()).toUTCString()), this.hasHeader("connection") || this.setHeader("Connection", this._keepAlive ? "keep-alive" : "close"), this._headBlock = this._storeHeader(`HTTP/1.1 ${this.statusCode} ${e}`);
372
- }
373
- writeContinue() {
374
- this._writeToSocket(r.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
375
- }
376
- setTimeout(e, t) {
377
- return this.socket?.setTimeout(e, t), this;
378
- }
379
- }, S = (...e) => {
380
- let t = {}, n = {}, r, i = [...e], a = i.shift();
381
- if (typeof a == "string" || a instanceof URL) {
382
- let e = typeof a == "string" ? new URL(a) : a;
383
- t = {
384
- protocol: e.protocol,
385
- hostname: e.hostname,
386
- host: e.hostname,
387
- port: e.port,
388
- path: `${e.pathname}${e.search}`,
389
- auth: e.username ? `${e.username}:${e.password}` : void 0
390
- };
391
- let o = i.shift();
392
- typeof o == "function" ? r = o : o && typeof o == "object" && (n = o, r = i.shift());
393
- } else a && typeof a == "object" && (n = a, r = i.shift());
394
- return {
395
- options: {
396
- ...t,
397
- ...n
398
- },
399
- callback: r
400
- };
401
- }, C = class extends b {
402
- method;
403
- path;
404
- host;
405
- protocol;
406
- socket;
407
- get connection() {
408
- return this.socket;
409
- }
410
- res = null;
411
- aborted = !1;
412
- _aborted = !1;
413
- constructor(e, t) {
414
- super(), this.method = (e.method ?? "GET").toUpperCase(), this.path = e.path ?? "/", this.protocol = e.protocol ?? "http:";
415
- let i = e.hostname ?? e.host ?? "localhost";
416
- this.host = i;
417
- let a = Number(e.port ?? (this.protocol === "https:" ? 443 : 80));
418
- if (t && this.once("response", t), e.headers) for (let [t, n] of Object.entries(e.headers)) n !== void 0 && this.setHeader(t, n);
419
- if (!this.hasHeader("host")) {
420
- let e = this.protocol === "https:" && a === 443 || this.protocol !== "https:" && a === 80;
421
- this.setHeader("Host", e ? i : `${i}:${a}`);
422
- }
423
- e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${r.from(e.auth).toString("base64")}`), this.socket = new n(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
424
- this._aborted || this.emit("error", e);
425
- }), this._attachResponseParser(), this.socket.connect({
426
- host: i,
427
- port: a,
428
- relay: e.relay
429
- }, () => {
430
- this.emit("connect");
431
- });
432
- }
433
- _shouldSendBody() {
434
- return this.method !== "GET" && this.method !== "HEAD" && this.method !== "DELETE";
435
- }
436
- _implicitHeader() {
437
- this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
438
- }
439
- _attachResponseParser() {
440
- let e = new y(this.socket), t = new _("response", {
441
- onHeaders: (n) => {
442
- e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
443
- },
444
- onBody: (t) => {
445
- e.push(r.from(t));
446
- },
447
- onComplete: () => {
448
- e.complete = !0, e.push(null);
449
- }
450
- });
451
- this.socket.on("data", (e) => {
452
- this._aborted || t.execute(e);
453
- }), this.socket.on("end", () => {
454
- t.finish();
455
- }), this.socket.on("close", () => {
456
- this.emit("close");
457
- });
458
- }
459
- abort() {
460
- this._aborted || (this._aborted = !0, this.aborted = !0, this.emit("abort"), this.socket.destroy());
461
- }
462
- destroy(e) {
463
- return this._aborted ? this : (this._aborted = !0, this.socket.destroy(e), super.destroy(e), this);
464
- }
465
- end(e, t, n) {
466
- return this._aborted ? this : super.end(e, t, n);
467
- }
468
- _writeToSocket(e, t) {
469
- if (this._aborted) {
470
- t();
471
- return;
472
- }
473
- super._writeToSocket(e, t);
474
- }
475
- setTimeout(e, t) {
476
- return this.socket.setTimeout(e, t), this;
477
- }
478
- setNoDelay(e) {
479
- this.socket.setNoDelay(e);
480
- }
481
- setSocketKeepAlive(e, t) {
482
- this.socket.setKeepAlive(e, t);
483
- }
484
- }, w = new Proxy(class extends t {
485
- constructor(e, t) {
486
- let n = {}, r = t;
487
- typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
488
- }
489
- _handleConnection(e) {
490
- let t = null, n = new _("request", {
491
- onHeaders: (r) => {
492
- t = new y(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
493
- let i = new x(t), a = String(r.headers.connection ?? "").toLowerCase();
494
- i._keepAlive = r.httpVersionMinor >= 1 ? a !== "close" : a === "keep-alive", i.on("finish", () => {
495
- i._keepAlive || e.end();
496
- }), this.emit("request", t, i);
497
- },
498
- onBody: (e) => {
499
- t?.push(r.from(e));
500
- },
501
- onComplete: () => {
502
- t && (t.complete = !0, t.push(null)), t = null;
503
- }
504
- });
505
- e.on("data", (e) => n.execute(e)), e.on("end", () => {
506
- n.finish(), t && t.push(null);
507
- }), e.on("error", (t) => this.emit("clientError", t, e));
508
- }
509
- }, { apply: (e, t, n) => new e(...n) }), T = class {
510
- maxSockets;
511
- maxFreeSockets;
512
- keepAlive;
513
- options;
514
- constructor(e = {}) {
515
- this.options = e, this.keepAlive = !!e.keepAlive, this.maxSockets = e.maxSockets ?? Infinity, this.maxFreeSockets = e.maxFreeSockets ?? 256;
516
- }
517
- getName(e = {}) {
518
- return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
519
- }
520
- destroy() {}
521
- }, E = new T(), D = (...e) => {
522
- let { options: t, callback: n } = S(...e);
523
- return new C(t, n);
524
- }, O = (...e) => {
525
- let t = D(...e);
526
- return t.end(), t;
527
- }, k = (e, t) => new w(e, t), A = {
528
- METHODS: s,
529
- STATUS_CODES: c,
530
- Agent: T,
531
- globalAgent: E,
532
- Server: w,
533
- ServerResponse: x,
534
- IncomingMessage: y,
535
- ClientRequest: C,
536
- OutgoingMessage: b,
537
- createServer: k,
538
- request: D,
539
- get: O
540
- };
541
- //#endregion
542
- export { T as Agent, C as ClientRequest, _ as HTTPParser, y as IncomingMessage, s as METHODS, c as STATUS_CODES, w as Server, x as ServerResponse, A as _default, A as default, k as createServer, O as get, E as globalAgent, D as request, a as t };
1
+ export { t as Agent, n as ClientRequest, r as HTTPParser, i as IncomingMessage, a as METHODS, o as STATUS_CODES, s as Server, c as ServerResponse, l as _default, l as default, u as createServer, d as get, f as globalAgent, m as request } from "./http-DIDjdm08.js";
@@ -0,0 +1,87 @@
1
+ import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-CcVwh9yz.js";
2
+ declare namespace index_d_exports {
3
+ 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 };
4
+ }
5
+ declare const fs: {
6
+ available: () => Promise<boolean>;
7
+ readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string;
8
+ writeFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
9
+ appendFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
10
+ existsSync: (path: import("node:fs").PathLike) => boolean;
11
+ statSync: (path: import("node:fs").PathLike) => Stats;
12
+ lstatSync: (path: import("node:fs").PathLike) => Stats;
13
+ readdirSync: (path: import("node:fs").PathLike) => string[];
14
+ mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void;
15
+ rmSync: (path: import("node:fs").PathLike, options?: {
16
+ recursive?: boolean;
17
+ force?: boolean;
18
+ }) => void;
19
+ rmdirSync: (path: import("node:fs").PathLike, options?: {
20
+ recursive?: boolean;
21
+ }) => void;
22
+ unlinkSync: (path: import("node:fs").PathLike) => void;
23
+ renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void;
24
+ readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
25
+ writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
26
+ appendFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
27
+ stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void;
28
+ readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void;
29
+ mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
30
+ rm: (path: import("node:fs").PathLike, a: {
31
+ recursive?: boolean;
32
+ force?: boolean;
33
+ } | Callback<void>, b?: Callback<void>) => void;
34
+ unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void;
35
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void;
36
+ exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void;
37
+ promises: {
38
+ readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
39
+ writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
40
+ appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
41
+ stat: (path: import("node:fs").PathLike) => Promise<Stats>;
42
+ lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
43
+ readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
44
+ mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
45
+ rm: (path: import("node:fs").PathLike, options?: {
46
+ recursive?: boolean;
47
+ force?: boolean;
48
+ }) => Promise<void>;
49
+ rmdir: (path: import("node:fs").PathLike, options?: {
50
+ recursive?: boolean;
51
+ }) => Promise<void>;
52
+ unlink: (path: import("node:fs").PathLike) => Promise<void>;
53
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
54
+ access: (path: import("node:fs").PathLike) => Promise<void>;
55
+ };
56
+ mount: () => Promise<void>;
57
+ flush: () => Promise<void>;
58
+ remount: () => Promise<void>;
59
+ };
60
+ 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?: {
61
+ recursive?: boolean;
62
+ force?: boolean;
63
+ }) => void, rmdirSync: (path: import("node:fs").PathLike, options?: {
64
+ recursive?: boolean;
65
+ }) => 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: {
66
+ recursive?: boolean;
67
+ force?: boolean;
68
+ } | 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: {
69
+ readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
70
+ writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
71
+ appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
72
+ stat: (path: import("node:fs").PathLike) => Promise<Stats>;
73
+ lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
74
+ readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
75
+ mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
76
+ rm: (path: import("node:fs").PathLike, options?: {
77
+ recursive?: boolean;
78
+ force?: boolean;
79
+ }) => Promise<void>;
80
+ rmdir: (path: import("node:fs").PathLike, options?: {
81
+ recursive?: boolean;
82
+ }) => Promise<void>;
83
+ unlink: (path: import("node:fs").PathLike) => Promise<void>;
84
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
85
+ access: (path: import("node:fs").PathLike) => Promise<void>;
86
+ }, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
87
+ export { rmdirSync as C, unlinkSync as D, unlink as E, writeFile as O, rmSync as S, statSync as T, readdirSync as _, existsSync as a, renameSync as b, index_d_exports as c, mkdirSync as d, mount as f, readdir as g, readFileSync as h, exists as i, writeFileSync as k, lstatSync as l, readFile as m, appendFileSync as n, flush as o, promises as p, available as r, fs as s, appendFile as t, mkdir as u, remount as v, stat as w, rm as x, rename as y };
@@ -1,6 +1,5 @@
1
1
  import "fs";
2
2
  import { Buffer as Buffer$1 } from "buffer";
3
- //#region src/node-fs/shared.d.ts
4
3
  type ReadOptions = BufferEncoding | {
5
4
  encoding?: BufferEncoding | null;
6
5
  flag?: string;
@@ -27,5 +26,4 @@ type Stats = {
27
26
  isDirectory: () => boolean;
28
27
  isSymbolicLink: () => boolean;
29
28
  };
30
- //#endregion
31
29
  export { WriteData as a, Stats as i, MakeOptions as n, WriteOptions as o, ReadOptions as r, Callback as t };