elit 3.6.6 → 3.6.7
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -19
- package/dist/build.js +420 -330
- package/dist/build.mjs +420 -330
- package/dist/chokidar.cjs +219 -182
- package/dist/chokidar.d.ts +25 -10
- package/dist/chokidar.js +217 -182
- package/dist/chokidar.mjs +218 -183
- package/dist/cli.cjs +22439 -21563
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +24113 -23252
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +17 -245
- package/dist/config.js +520 -515
- package/dist/config.mjs +346 -341
- package/dist/contracts-BeW9k0yZ.d.ts +54 -0
- package/dist/contracts-D7KIS-TK.d.ts +36 -0
- package/dist/coverage.cjs +448 -485
- package/dist/coverage.d.ts +13 -62
- package/dist/coverage.js +447 -484
- package/dist/coverage.mjs +447 -484
- package/dist/database.cjs +819 -828
- package/dist/database.d.ts +8 -24
- package/dist/database.js +818 -829
- package/dist/database.mjs +818 -829
- package/dist/desktop-auto-render.cjs +1700 -1523
- package/dist/desktop-auto-render.d.ts +4 -12
- package/dist/desktop-auto-render.js +1695 -1518
- package/dist/desktop-auto-render.mjs +1696 -1519
- package/dist/desktop.cjs +3 -1
- package/dist/desktop.d.ts +4 -1
- package/dist/desktop.js +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/dev-build.cjs +830 -0
- package/dist/dev-build.d.ts +53 -0
- package/dist/dev-build.js +3318 -0
- package/dist/dev-build.mjs +797 -0
- package/dist/dom.cjs +717 -591
- package/dist/dom.d.ts +2 -17
- package/dist/dom.js +714 -588
- package/dist/dom.mjs +716 -590
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -12
- package/dist/el.js +60 -52
- package/dist/el.mjs +60 -52
- package/dist/fs.cjs +72 -63
- package/dist/fs.d.ts +22 -19
- package/dist/fs.js +71 -62
- package/dist/fs.mjs +71 -62
- package/dist/hmr.cjs +40 -14
- package/dist/hmr.d.ts +11 -23
- package/dist/hmr.js +38 -14
- package/dist/hmr.mjs +38 -14
- package/dist/http.cjs +251 -99
- package/dist/http.d.ts +38 -104
- package/dist/http.js +249 -99
- package/dist/http.mjs +249 -99
- package/dist/https.cjs +524 -228
- package/dist/https.d.ts +44 -36
- package/dist/https.js +520 -226
- package/dist/https.mjs +522 -228
- package/dist/index.cjs +7502 -7691
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7486 -7677
- package/dist/index.mjs +7497 -7687
- package/dist/mime-types.cjs +10 -4
- package/dist/mime-types.d.ts +8 -11
- package/dist/mime-types.js +9 -3
- package/dist/mime-types.mjs +9 -3
- package/dist/native.cjs +8616 -8870
- package/dist/native.d.ts +7 -10
- package/dist/native.js +8682 -8936
- package/dist/native.mjs +8615 -8869
- package/dist/path.cjs +83 -77
- package/dist/path.d.ts +29 -29
- package/dist/path.js +82 -76
- package/dist/path.mjs +82 -76
- package/dist/pm.cjs +3300 -0
- package/dist/pm.d.ts +256 -0
- package/dist/pm.js +5638 -0
- package/dist/pm.mjs +3196 -0
- package/dist/preview-build.cjs +712 -0
- package/dist/preview-build.d.ts +59 -0
- package/dist/preview-build.js +3194 -0
- package/dist/preview-build.mjs +676 -0
- package/dist/render-context.cjs +13 -2
- package/dist/render-context.d.ts +9 -34
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -646
- package/dist/router.d.ts +8 -14
- package/dist/router.js +786 -645
- package/dist/router.mjs +786 -645
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3254 -2684
- package/dist/server.d.ts +47 -5
- package/dist/server.js +3427 -2859
- package/dist/server.mjs +3397 -2829
- package/dist/smtp-server.cjs +16 -3
- package/dist/smtp-server.d.ts +12 -26
- package/dist/smtp-server.js +18 -5
- package/dist/smtp-server.mjs +16 -3
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -659
- package/dist/state.d.ts +11 -71
- package/dist/state.js +760 -651
- package/dist/state.mjs +767 -658
- package/dist/style.cjs +1011 -968
- package/dist/style.d.ts +13 -127
- package/dist/style.js +1009 -970
- package/dist/style.mjs +1011 -971
- package/dist/test-reporter.cjs +332 -316
- package/dist/test-reporter.d.ts +28 -33
- package/dist/test-reporter.js +328 -312
- package/dist/test-reporter.mjs +328 -312
- package/dist/test-runtime.cjs +927 -968
- package/dist/test-runtime.d.ts +24 -99
- package/dist/test-runtime.js +922 -965
- package/dist/test-runtime.mjs +922 -965
- package/dist/test.cjs +4428 -4273
- package/dist/test.d.ts +2 -8
- package/dist/test.js +4307 -4154
- package/dist/test.mjs +4419 -4267
- package/dist/types-BONVzPtp.d.ts +59 -0
- package/dist/types-BR4wMiVx.d.ts +32 -0
- package/dist/types-C4gKykuG.d.ts +23 -0
- package/dist/types-CIhpN1-K.d.ts +64 -0
- package/dist/types-Ckj8md_j.d.ts +84 -0
- package/dist/types-CpjQTAkX.d.ts +24 -0
- package/dist/types-D0LjrYjS.d.ts +14 -0
- package/dist/types-DAisuVr5.d.ts +75 -0
- package/dist/types-tJn88E1N.d.ts +242 -0
- package/dist/types.d.ts +50 -237
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -7
- package/dist/universal.js +1 -1
- package/dist/universal.mjs +1 -1
- package/dist/websocket-XfyK23zD.d.ts +119 -0
- package/dist/ws.cjs +129 -108
- package/dist/ws.d.ts +21 -131
- package/dist/ws.js +128 -109
- package/dist/ws.mjs +128 -109
- package/dist/wss.cjs +757 -479
- package/dist/wss.d.ts +31 -28
- package/dist/wss.js +755 -479
- package/dist/wss.mjs +758 -482
- package/package.json +8 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-uMQvZAll.d.ts +0 -458
package/dist/https.js
CHANGED
|
@@ -27,41 +27,78 @@
|
|
|
27
27
|
};
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
31
|
-
var runtime, isNode, isBun, isDeno;
|
|
32
|
-
var init_runtime = __esm({
|
|
33
|
-
"src/runtime.ts"() {
|
|
34
|
-
"use strict";
|
|
35
|
-
runtime = (() => {
|
|
36
|
-
if (typeof Deno !== "undefined") return "deno";
|
|
37
|
-
if (typeof Bun !== "undefined") return "bun";
|
|
38
|
-
return "node";
|
|
39
|
-
})();
|
|
40
|
-
isNode = runtime === "node";
|
|
41
|
-
isBun = runtime === "bun";
|
|
42
|
-
isDeno = runtime === "deno";
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// src/http.ts
|
|
47
|
-
var http_exports = {};
|
|
48
|
-
__export(http_exports, {
|
|
49
|
-
Agent: () => Agent,
|
|
50
|
-
ClientRequest: () => ClientRequest,
|
|
51
|
-
IncomingMessage: () => IncomingMessage,
|
|
52
|
-
METHODS: () => METHODS,
|
|
53
|
-
STATUS_CODES: () => STATUS_CODES,
|
|
54
|
-
Server: () => Server,
|
|
55
|
-
ServerResponse: () => ServerResponse,
|
|
56
|
-
createServer: () => createServer,
|
|
57
|
-
default: () => http_default,
|
|
58
|
-
get: () => get,
|
|
59
|
-
getRuntime: () => getRuntime,
|
|
60
|
-
request: () => request
|
|
61
|
-
});
|
|
30
|
+
// src/server/http/utils.ts
|
|
62
31
|
function queueCallback(callback) {
|
|
63
32
|
if (callback) queueMicrotask(callback);
|
|
64
33
|
}
|
|
34
|
+
function getRequestPath(url) {
|
|
35
|
+
if (!url) return "";
|
|
36
|
+
try {
|
|
37
|
+
const urlObj = new URL(url);
|
|
38
|
+
return urlObj.pathname + urlObj.search;
|
|
39
|
+
} catch {
|
|
40
|
+
return url;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function headersToRecord(headers) {
|
|
44
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
45
|
+
headers.forEach((value, key) => {
|
|
46
|
+
result[key] = value;
|
|
47
|
+
});
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function headersToRawHeaders(headers) {
|
|
51
|
+
const rawHeaders = [];
|
|
52
|
+
headers.forEach((value, key) => {
|
|
53
|
+
rawHeaders.push(key, value);
|
|
54
|
+
});
|
|
55
|
+
return rawHeaders;
|
|
56
|
+
}
|
|
57
|
+
function normalizeRequestBodyChunk(chunk, encoding = "utf8") {
|
|
58
|
+
if (typeof chunk === "string") {
|
|
59
|
+
if (encoding !== "utf8" && typeof Buffer !== "undefined") {
|
|
60
|
+
return Buffer.from(chunk, encoding);
|
|
61
|
+
}
|
|
62
|
+
return chunk;
|
|
63
|
+
}
|
|
64
|
+
if (chunk instanceof Uint8Array) {
|
|
65
|
+
return chunk;
|
|
66
|
+
}
|
|
67
|
+
if (chunk instanceof ArrayBuffer) {
|
|
68
|
+
return new Uint8Array(chunk);
|
|
69
|
+
}
|
|
70
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
71
|
+
return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
72
|
+
}
|
|
73
|
+
return new TextEncoder().encode(String(chunk));
|
|
74
|
+
}
|
|
75
|
+
function buildRequestBody(chunks) {
|
|
76
|
+
if (chunks.length === 0) {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
if (chunks.length === 1) {
|
|
80
|
+
return chunks[0];
|
|
81
|
+
}
|
|
82
|
+
if (chunks.every((chunk) => typeof chunk === "string")) {
|
|
83
|
+
return chunks.join("");
|
|
84
|
+
}
|
|
85
|
+
const encoder = new TextEncoder();
|
|
86
|
+
const bodyParts = chunks.map((chunk) => typeof chunk === "string" ? encoder.encode(chunk) : chunk);
|
|
87
|
+
const totalLength = bodyParts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
88
|
+
const body = new Uint8Array(totalLength);
|
|
89
|
+
let offset = 0;
|
|
90
|
+
for (const part of bodyParts) {
|
|
91
|
+
body.set(part, offset);
|
|
92
|
+
offset += part.byteLength;
|
|
93
|
+
}
|
|
94
|
+
return body;
|
|
95
|
+
}
|
|
96
|
+
function isFetchResponse(value) {
|
|
97
|
+
return typeof value?.status === "number" && typeof value?.statusText === "string" && typeof value?.headers?.forEach === "function";
|
|
98
|
+
}
|
|
99
|
+
function isNodeIncomingMessage(value) {
|
|
100
|
+
return typeof value?.on === "function" && typeof value?.headers === "object" && (typeof value?.httpVersion === "string" || value?.socket !== void 0);
|
|
101
|
+
}
|
|
65
102
|
function headersToInit(headers) {
|
|
66
103
|
const result = {};
|
|
67
104
|
for (const key in headers) {
|
|
@@ -86,69 +123,119 @@
|
|
|
86
123
|
server.emit("close");
|
|
87
124
|
if (callback) queueMicrotask(() => callback());
|
|
88
125
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const incomingMessage = new IncomingMessage(fetchRequest);
|
|
120
|
-
incomingMessage.statusCode = response.status;
|
|
121
|
-
incomingMessage.statusMessage = response.statusText;
|
|
122
|
-
if (callback) callback(incomingMessage);
|
|
123
|
-
req.emit("response", incomingMessage);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
req.emit("error", error);
|
|
126
|
+
var init_utils = __esm({
|
|
127
|
+
"src/server/http/utils.ts"() {
|
|
128
|
+
"use strict";
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// src/shares/runtime.ts
|
|
133
|
+
var runtime, isNode, isBun, isDeno;
|
|
134
|
+
var init_runtime = __esm({
|
|
135
|
+
"src/shares/runtime.ts"() {
|
|
136
|
+
"use strict";
|
|
137
|
+
runtime = (() => {
|
|
138
|
+
if (typeof Deno !== "undefined") return "deno";
|
|
139
|
+
if (typeof Bun !== "undefined") return "bun";
|
|
140
|
+
return "node";
|
|
141
|
+
})();
|
|
142
|
+
isNode = runtime === "node";
|
|
143
|
+
isBun = runtime === "bun";
|
|
144
|
+
isDeno = runtime === "deno";
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// src/server/http/agent.ts
|
|
149
|
+
var Agent2;
|
|
150
|
+
var init_agent = __esm({
|
|
151
|
+
"src/server/http/agent.ts"() {
|
|
152
|
+
"use strict";
|
|
153
|
+
Agent2 = class {
|
|
154
|
+
constructor(options) {
|
|
155
|
+
this.options = options;
|
|
126
156
|
}
|
|
127
|
-
}
|
|
157
|
+
};
|
|
128
158
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return runtime;
|
|
136
|
-
}
|
|
137
|
-
var import_node_events, http, https, METHODS, STATUS_CODES, IncomingMessage, ServerResponse, Server, ClientRequest, Agent, http_default;
|
|
138
|
-
var init_http = __esm({
|
|
139
|
-
"src/http.ts"() {
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// src/server/http/client-request.ts
|
|
162
|
+
var import_node_events2, ClientRequest2;
|
|
163
|
+
var init_client_request = __esm({
|
|
164
|
+
"src/server/http/client-request.ts"() {
|
|
140
165
|
"use strict";
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
http = __require("http");
|
|
149
|
-
https = __require("https");
|
|
166
|
+
import_node_events2 = __require("events");
|
|
167
|
+
init_utils();
|
|
168
|
+
ClientRequest2 = class extends import_node_events2.EventEmitter {
|
|
169
|
+
constructor(_url, _options = {}) {
|
|
170
|
+
super();
|
|
171
|
+
this._bodyChunks = [];
|
|
172
|
+
this._ended = false;
|
|
150
173
|
}
|
|
151
|
-
|
|
174
|
+
_setNativeRequest(nativeRequest) {
|
|
175
|
+
this._nativeRequest = nativeRequest;
|
|
176
|
+
}
|
|
177
|
+
_setExecutor(executor) {
|
|
178
|
+
this._executor = executor;
|
|
179
|
+
}
|
|
180
|
+
write(chunk, encoding, callback) {
|
|
181
|
+
if (this._ended) {
|
|
182
|
+
throw new Error("Cannot write after end");
|
|
183
|
+
}
|
|
184
|
+
if (typeof encoding === "function") {
|
|
185
|
+
callback = encoding;
|
|
186
|
+
encoding = void 0;
|
|
187
|
+
}
|
|
188
|
+
if (this._nativeRequest) {
|
|
189
|
+
const actualEncoding2 = typeof encoding === "string" ? encoding : void 0;
|
|
190
|
+
return this._nativeRequest.write(chunk, actualEncoding2, callback);
|
|
191
|
+
}
|
|
192
|
+
const actualEncoding = typeof encoding === "string" ? encoding : "utf8";
|
|
193
|
+
this._bodyChunks.push(normalizeRequestBodyChunk(chunk, actualEncoding));
|
|
194
|
+
queueCallback(callback);
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
end(chunk, encoding, callback) {
|
|
198
|
+
if (typeof chunk === "function") {
|
|
199
|
+
callback = chunk;
|
|
200
|
+
chunk = void 0;
|
|
201
|
+
encoding = void 0;
|
|
202
|
+
} else if (typeof encoding === "function") {
|
|
203
|
+
callback = encoding;
|
|
204
|
+
encoding = void 0;
|
|
205
|
+
}
|
|
206
|
+
if (this._ended) {
|
|
207
|
+
queueCallback(callback);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
this._ended = true;
|
|
211
|
+
if (this._nativeRequest) {
|
|
212
|
+
const actualEncoding = typeof encoding === "string" ? encoding : void 0;
|
|
213
|
+
if (chunk !== void 0) {
|
|
214
|
+
this._nativeRequest.end(chunk, actualEncoding, callback);
|
|
215
|
+
} else {
|
|
216
|
+
this._nativeRequest.end(callback);
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (chunk !== void 0) {
|
|
221
|
+
this._bodyChunks.push(normalizeRequestBodyChunk(chunk, typeof encoding === "string" ? encoding : "utf8"));
|
|
222
|
+
}
|
|
223
|
+
const executor = this._executor;
|
|
224
|
+
const body = buildRequestBody(this._bodyChunks);
|
|
225
|
+
if (executor) {
|
|
226
|
+
Promise.resolve().then(() => executor(body)).catch((error) => this.emit("error", error));
|
|
227
|
+
}
|
|
228
|
+
queueCallback(callback);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// src/server/http/constants.ts
|
|
235
|
+
var METHODS, STATUS_CODES;
|
|
236
|
+
var init_constants = __esm({
|
|
237
|
+
"src/server/http/constants.ts"() {
|
|
238
|
+
"use strict";
|
|
152
239
|
METHODS = [
|
|
153
240
|
"GET",
|
|
154
241
|
"POST",
|
|
@@ -216,13 +303,30 @@
|
|
|
216
303
|
510: "Not Extended",
|
|
217
304
|
511: "Network Authentication Required"
|
|
218
305
|
};
|
|
219
|
-
|
|
220
|
-
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// src/server/http/incoming-message.ts
|
|
310
|
+
var import_node_events3, IncomingMessage;
|
|
311
|
+
var init_incoming_message = __esm({
|
|
312
|
+
"src/server/http/incoming-message.ts"() {
|
|
313
|
+
"use strict";
|
|
314
|
+
import_node_events3 = __require("events");
|
|
315
|
+
init_utils();
|
|
316
|
+
IncomingMessage = class extends import_node_events3.EventEmitter {
|
|
317
|
+
constructor(req, requestMethod) {
|
|
221
318
|
super();
|
|
222
319
|
this.httpVersion = "1.1";
|
|
223
320
|
this.rawHeaders = [];
|
|
224
321
|
this._req = req;
|
|
225
|
-
if (
|
|
322
|
+
if (isFetchResponse(req)) {
|
|
323
|
+
this.method = requestMethod || "GET";
|
|
324
|
+
this.url = getRequestPath(req.url);
|
|
325
|
+
this.headers = headersToRecord(req.headers);
|
|
326
|
+
this.statusCode = req.status;
|
|
327
|
+
this.statusMessage = req.statusText;
|
|
328
|
+
this.rawHeaders = headersToRawHeaders(req.headers);
|
|
329
|
+
} else if (isNodeIncomingMessage(req)) {
|
|
226
330
|
this.method = req.method;
|
|
227
331
|
this.url = req.url;
|
|
228
332
|
this.headers = req.headers;
|
|
@@ -233,14 +337,13 @@
|
|
|
233
337
|
this.socket = req.socket;
|
|
234
338
|
} else {
|
|
235
339
|
this.method = req.method;
|
|
236
|
-
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
239
|
-
this.rawHeaders = [];
|
|
340
|
+
this.url = getRequestPath(req.url);
|
|
341
|
+
this.headers = headersToRecord(req.headers);
|
|
342
|
+
this.rawHeaders = headersToRawHeaders(req.headers);
|
|
240
343
|
}
|
|
241
344
|
}
|
|
242
345
|
async text() {
|
|
243
|
-
if (
|
|
346
|
+
if (isNodeIncomingMessage(this._req)) {
|
|
244
347
|
return new Promise((resolve, reject) => {
|
|
245
348
|
const chunks = [];
|
|
246
349
|
this._req.on("data", (chunk) => chunks.push(chunk));
|
|
@@ -251,14 +354,92 @@
|
|
|
251
354
|
return this._req.text();
|
|
252
355
|
}
|
|
253
356
|
async json() {
|
|
254
|
-
if (
|
|
357
|
+
if (isNodeIncomingMessage(this._req)) {
|
|
255
358
|
const text = await this.text();
|
|
256
359
|
return JSON.parse(text);
|
|
257
360
|
}
|
|
258
361
|
return this._req.json();
|
|
259
362
|
}
|
|
260
363
|
};
|
|
261
|
-
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
// src/server/http/node-modules.ts
|
|
368
|
+
var http, https;
|
|
369
|
+
var init_node_modules = __esm({
|
|
370
|
+
"src/server/http/node-modules.ts"() {
|
|
371
|
+
"use strict";
|
|
372
|
+
init_runtime();
|
|
373
|
+
if (isNode && typeof process !== "undefined") {
|
|
374
|
+
try {
|
|
375
|
+
http = __require("http");
|
|
376
|
+
https = __require("https");
|
|
377
|
+
} catch {
|
|
378
|
+
http = __require("http");
|
|
379
|
+
https = __require("https");
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// src/server/http/request-api.ts
|
|
386
|
+
function request(url, options, callback) {
|
|
387
|
+
const urlString = typeof url === "string" ? url : url.toString();
|
|
388
|
+
const req = new ClientRequest2(urlString, options);
|
|
389
|
+
if (isNode) {
|
|
390
|
+
const urlObj = new URL(urlString);
|
|
391
|
+
const client = urlObj.protocol === "https:" ? https : http;
|
|
392
|
+
const nodeReq = client.request(urlString, {
|
|
393
|
+
method: options?.method || "GET",
|
|
394
|
+
headers: options?.headers,
|
|
395
|
+
timeout: options?.timeout,
|
|
396
|
+
signal: options?.signal
|
|
397
|
+
}, (res) => {
|
|
398
|
+
const incomingMessage = new IncomingMessage(res);
|
|
399
|
+
if (callback) callback(incomingMessage);
|
|
400
|
+
req.emit("response", incomingMessage);
|
|
401
|
+
});
|
|
402
|
+
req._setNativeRequest(nodeReq);
|
|
403
|
+
nodeReq.on("error", (error) => req.emit("error", error));
|
|
404
|
+
} else {
|
|
405
|
+
req._setExecutor(async (body) => {
|
|
406
|
+
const response = await fetch(urlString, {
|
|
407
|
+
method: options?.method || "GET",
|
|
408
|
+
headers: options?.headers,
|
|
409
|
+
body,
|
|
410
|
+
signal: options?.signal
|
|
411
|
+
});
|
|
412
|
+
const incomingMessage = new IncomingMessage(response, options?.method || "GET");
|
|
413
|
+
if (callback) callback(incomingMessage);
|
|
414
|
+
req.emit("response", incomingMessage);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
return req;
|
|
418
|
+
}
|
|
419
|
+
function get(url, options, callback) {
|
|
420
|
+
const req = request(url, { ...options, method: "GET" }, callback);
|
|
421
|
+
req.end();
|
|
422
|
+
return req;
|
|
423
|
+
}
|
|
424
|
+
var init_request_api = __esm({
|
|
425
|
+
"src/server/http/request-api.ts"() {
|
|
426
|
+
"use strict";
|
|
427
|
+
init_runtime();
|
|
428
|
+
init_client_request();
|
|
429
|
+
init_incoming_message();
|
|
430
|
+
init_node_modules();
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// src/server/http/response.ts
|
|
435
|
+
var import_node_events4, ServerResponse;
|
|
436
|
+
var init_response = __esm({
|
|
437
|
+
"src/server/http/response.ts"() {
|
|
438
|
+
"use strict";
|
|
439
|
+
import_node_events4 = __require("events");
|
|
440
|
+
init_runtime();
|
|
441
|
+
init_utils();
|
|
442
|
+
ServerResponse = class extends import_node_events4.EventEmitter {
|
|
262
443
|
constructor(_req, nodeRes) {
|
|
263
444
|
super();
|
|
264
445
|
this.statusCode = 200;
|
|
@@ -391,7 +572,6 @@
|
|
|
391
572
|
_setResolver(resolve) {
|
|
392
573
|
this._resolve = resolve;
|
|
393
574
|
}
|
|
394
|
-
// Express.js-like methods
|
|
395
575
|
json(data, statusCode = 200) {
|
|
396
576
|
if (!this.headersSent) {
|
|
397
577
|
this.setHeader("Content-Type", "application/json");
|
|
@@ -415,7 +595,35 @@
|
|
|
415
595
|
return this;
|
|
416
596
|
}
|
|
417
597
|
};
|
|
418
|
-
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// src/server/http/runtime.ts
|
|
602
|
+
function getRuntime() {
|
|
603
|
+
return runtime;
|
|
604
|
+
}
|
|
605
|
+
var init_runtime2 = __esm({
|
|
606
|
+
"src/server/http/runtime.ts"() {
|
|
607
|
+
"use strict";
|
|
608
|
+
init_runtime();
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// src/server/http/server-runtime.ts
|
|
613
|
+
function createServer(optionsOrListener, requestListener) {
|
|
614
|
+
return new Server(typeof optionsOrListener === "function" ? optionsOrListener : requestListener);
|
|
615
|
+
}
|
|
616
|
+
var import_node_events5, Server;
|
|
617
|
+
var init_server_runtime = __esm({
|
|
618
|
+
"src/server/http/server-runtime.ts"() {
|
|
619
|
+
"use strict";
|
|
620
|
+
import_node_events5 = __require("events");
|
|
621
|
+
init_runtime();
|
|
622
|
+
init_node_modules();
|
|
623
|
+
init_incoming_message();
|
|
624
|
+
init_response();
|
|
625
|
+
init_utils();
|
|
626
|
+
Server = class extends import_node_events5.EventEmitter {
|
|
419
627
|
constructor(requestListener) {
|
|
420
628
|
super();
|
|
421
629
|
this._bunWebSocketServers = /* @__PURE__ */ new Set();
|
|
@@ -490,6 +698,8 @@
|
|
|
490
698
|
const urlObj = new URL(req.url);
|
|
491
699
|
const pathname = urlObj.pathname;
|
|
492
700
|
const requestUrl = urlObj.pathname + urlObj.search;
|
|
701
|
+
const incomingHeaders = headersToRecord(req.headers);
|
|
702
|
+
const rawHeaders = headersToRawHeaders(req.headers);
|
|
493
703
|
const upgradeHeader = req.headers.get("upgrade");
|
|
494
704
|
if (upgradeHeader && upgradeHeader.toLowerCase() === "websocket") {
|
|
495
705
|
const matchingWebSocketServer = Array.from(this._bunWebSocketServers).find((wsServer) => {
|
|
@@ -526,9 +736,9 @@
|
|
|
526
736
|
const incomingMessage = {
|
|
527
737
|
method: req.method,
|
|
528
738
|
url: requestUrl,
|
|
529
|
-
headers:
|
|
739
|
+
headers: incomingHeaders,
|
|
530
740
|
httpVersion: "1.1",
|
|
531
|
-
rawHeaders
|
|
741
|
+
rawHeaders,
|
|
532
742
|
_req: req,
|
|
533
743
|
text: () => req.text(),
|
|
534
744
|
json: () => req.json()
|
|
@@ -587,6 +797,8 @@
|
|
|
587
797
|
};
|
|
588
798
|
if (self.requestListener) {
|
|
589
799
|
self.requestListener(incomingMessage, serverResponse);
|
|
800
|
+
} else {
|
|
801
|
+
self.emit("request", incomingMessage, serverResponse);
|
|
590
802
|
}
|
|
591
803
|
if (responseReady) {
|
|
592
804
|
return new Response(body, {
|
|
@@ -661,9 +873,11 @@
|
|
|
661
873
|
return createAddress(0, addr, "unix");
|
|
662
874
|
}
|
|
663
875
|
return addr;
|
|
664
|
-
}
|
|
876
|
+
}
|
|
877
|
+
if (isBun) {
|
|
665
878
|
return createAddress(this.nativeServer.port, this.nativeServer.hostname);
|
|
666
|
-
}
|
|
879
|
+
}
|
|
880
|
+
if (isDeno) {
|
|
667
881
|
const addr = this.nativeServer.addr;
|
|
668
882
|
return createAddress(addr.port, addr.hostname);
|
|
669
883
|
}
|
|
@@ -673,22 +887,45 @@
|
|
|
673
887
|
return this._listening;
|
|
674
888
|
}
|
|
675
889
|
};
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
// src/server/http/index.ts
|
|
894
|
+
var http_exports = {};
|
|
895
|
+
__export(http_exports, {
|
|
896
|
+
Agent: () => Agent2,
|
|
897
|
+
ClientRequest: () => ClientRequest2,
|
|
898
|
+
IncomingMessage: () => IncomingMessage,
|
|
899
|
+
METHODS: () => METHODS,
|
|
900
|
+
STATUS_CODES: () => STATUS_CODES,
|
|
901
|
+
Server: () => Server,
|
|
902
|
+
ServerResponse: () => ServerResponse,
|
|
903
|
+
createServer: () => createServer,
|
|
904
|
+
default: () => http_default,
|
|
905
|
+
get: () => get,
|
|
906
|
+
getRuntime: () => getRuntime,
|
|
907
|
+
request: () => request
|
|
908
|
+
});
|
|
909
|
+
var http_default;
|
|
910
|
+
var init_http = __esm({
|
|
911
|
+
"src/server/http/index.ts"() {
|
|
912
|
+
"use strict";
|
|
913
|
+
init_agent();
|
|
914
|
+
init_client_request();
|
|
915
|
+
init_constants();
|
|
916
|
+
init_incoming_message();
|
|
917
|
+
init_request_api();
|
|
918
|
+
init_response();
|
|
919
|
+
init_runtime2();
|
|
920
|
+
init_server_runtime();
|
|
921
|
+
init_agent();
|
|
922
|
+
init_client_request();
|
|
923
|
+
init_constants();
|
|
924
|
+
init_incoming_message();
|
|
925
|
+
init_request_api();
|
|
926
|
+
init_response();
|
|
927
|
+
init_runtime2();
|
|
928
|
+
init_server_runtime();
|
|
692
929
|
http_default = {
|
|
693
930
|
createServer,
|
|
694
931
|
request,
|
|
@@ -696,8 +933,8 @@
|
|
|
696
933
|
Server,
|
|
697
934
|
IncomingMessage,
|
|
698
935
|
ServerResponse,
|
|
699
|
-
Agent,
|
|
700
|
-
ClientRequest,
|
|
936
|
+
Agent: Agent2,
|
|
937
|
+
ClientRequest: ClientRequest2,
|
|
701
938
|
METHODS,
|
|
702
939
|
STATUS_CODES,
|
|
703
940
|
getRuntime
|
|
@@ -705,28 +942,83 @@
|
|
|
705
942
|
}
|
|
706
943
|
});
|
|
707
944
|
|
|
708
|
-
// src/https.ts
|
|
709
|
-
var
|
|
945
|
+
// src/server/https/agent.ts
|
|
946
|
+
var Agent = class {
|
|
947
|
+
constructor(options) {
|
|
948
|
+
this.options = options;
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
// src/server/https/client-request.ts
|
|
953
|
+
var import_node_events = __require("events");
|
|
954
|
+
init_utils();
|
|
955
|
+
var ClientRequest = class extends import_node_events.EventEmitter {
|
|
956
|
+
constructor(_url, _options = {}) {
|
|
957
|
+
super();
|
|
958
|
+
this._bodyChunks = [];
|
|
959
|
+
this._ended = false;
|
|
960
|
+
}
|
|
961
|
+
_setNativeRequest(nativeRequest) {
|
|
962
|
+
this._nativeRequest = nativeRequest;
|
|
963
|
+
}
|
|
964
|
+
_setExecutor(executor) {
|
|
965
|
+
this._executor = executor;
|
|
966
|
+
}
|
|
967
|
+
write(chunk, encoding, callback) {
|
|
968
|
+
if (this._ended) {
|
|
969
|
+
throw new Error("Cannot write after end");
|
|
970
|
+
}
|
|
971
|
+
if (typeof encoding === "function") {
|
|
972
|
+
callback = encoding;
|
|
973
|
+
encoding = void 0;
|
|
974
|
+
}
|
|
975
|
+
if (this._nativeRequest) {
|
|
976
|
+
const actualEncoding = typeof encoding === "string" ? encoding : void 0;
|
|
977
|
+
return this._nativeRequest.write(chunk, actualEncoding, callback);
|
|
978
|
+
}
|
|
979
|
+
this._bodyChunks.push(normalizeRequestBodyChunk(chunk, typeof encoding === "string" ? encoding : "utf8"));
|
|
980
|
+
queueCallback(callback);
|
|
981
|
+
return true;
|
|
982
|
+
}
|
|
983
|
+
end(chunk, encoding, callback) {
|
|
984
|
+
if (typeof chunk === "function") {
|
|
985
|
+
callback = chunk;
|
|
986
|
+
chunk = void 0;
|
|
987
|
+
encoding = void 0;
|
|
988
|
+
} else if (typeof encoding === "function") {
|
|
989
|
+
callback = encoding;
|
|
990
|
+
encoding = void 0;
|
|
991
|
+
}
|
|
992
|
+
if (this._ended) {
|
|
993
|
+
queueCallback(callback);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
this._ended = true;
|
|
997
|
+
if (this._nativeRequest) {
|
|
998
|
+
const actualEncoding = typeof encoding === "string" ? encoding : void 0;
|
|
999
|
+
if (chunk !== void 0) {
|
|
1000
|
+
this._nativeRequest.end(chunk, actualEncoding, callback);
|
|
1001
|
+
} else {
|
|
1002
|
+
this._nativeRequest.end(callback);
|
|
1003
|
+
}
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
if (chunk !== void 0) {
|
|
1007
|
+
this._bodyChunks.push(normalizeRequestBodyChunk(chunk, typeof encoding === "string" ? encoding : "utf8"));
|
|
1008
|
+
}
|
|
1009
|
+
const executor = this._executor;
|
|
1010
|
+
const body = buildRequestBody(this._bodyChunks);
|
|
1011
|
+
if (executor) {
|
|
1012
|
+
Promise.resolve().then(() => executor(body)).catch((error) => this.emit("error", error));
|
|
1013
|
+
}
|
|
1014
|
+
queueCallback(callback);
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
// src/server/https/request-api.ts
|
|
710
1019
|
init_runtime();
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
function createErrorResponse2() {
|
|
715
|
-
return new Response("Internal Server Error", { status: 500 });
|
|
716
|
-
}
|
|
717
|
-
function createAddress2(port, address, family = "IPv4") {
|
|
718
|
-
return { port, family, address };
|
|
719
|
-
}
|
|
720
|
-
function emitListeningWithCallback2(server, callback) {
|
|
721
|
-
server._listening = true;
|
|
722
|
-
server.emit("listening");
|
|
723
|
-
queueCallback2(callback);
|
|
724
|
-
}
|
|
725
|
-
function closeAndEmit2(server, callback) {
|
|
726
|
-
server._listening = false;
|
|
727
|
-
server.emit("close");
|
|
728
|
-
if (callback) queueMicrotask(() => callback());
|
|
729
|
-
}
|
|
1020
|
+
|
|
1021
|
+
// src/server/https/http-classes.ts
|
|
730
1022
|
function loadHttpClasses() {
|
|
731
1023
|
const httpModule = (init_http(), __toCommonJS(http_exports));
|
|
732
1024
|
return {
|
|
@@ -734,9 +1026,70 @@
|
|
|
734
1026
|
ServerResponse: httpModule.ServerResponse
|
|
735
1027
|
};
|
|
736
1028
|
}
|
|
1029
|
+
|
|
1030
|
+
// src/server/https/node-modules.ts
|
|
1031
|
+
init_runtime();
|
|
737
1032
|
var https2;
|
|
738
|
-
|
|
739
|
-
|
|
1033
|
+
if (isNode && typeof process !== "undefined") {
|
|
1034
|
+
try {
|
|
1035
|
+
https2 = __require("https");
|
|
1036
|
+
} catch {
|
|
1037
|
+
https2 = __require("https");
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// src/server/https/request-api.ts
|
|
1042
|
+
function request2(url, options, callback) {
|
|
1043
|
+
const urlString = typeof url === "string" ? url : url.toString();
|
|
1044
|
+
const req = new ClientRequest(urlString, options);
|
|
1045
|
+
if (isNode) {
|
|
1046
|
+
const { IncomingMessage: IncomingMessage2 } = loadHttpClasses();
|
|
1047
|
+
const nodeReq = https2.request(urlString, {
|
|
1048
|
+
method: options?.method || "GET",
|
|
1049
|
+
headers: options?.headers,
|
|
1050
|
+
timeout: options?.timeout,
|
|
1051
|
+
signal: options?.signal
|
|
1052
|
+
}, (res) => {
|
|
1053
|
+
const incomingMessage = new IncomingMessage2(res);
|
|
1054
|
+
if (callback) callback(incomingMessage);
|
|
1055
|
+
req.emit("response", incomingMessage);
|
|
1056
|
+
});
|
|
1057
|
+
req._setNativeRequest(nodeReq);
|
|
1058
|
+
nodeReq.on("error", (error) => req.emit("error", error));
|
|
1059
|
+
} else {
|
|
1060
|
+
const { IncomingMessage: IncomingMessage2 } = loadHttpClasses();
|
|
1061
|
+
req._setExecutor(async (body) => {
|
|
1062
|
+
const response = await fetch(urlString, {
|
|
1063
|
+
method: options?.method || "GET",
|
|
1064
|
+
headers: options?.headers,
|
|
1065
|
+
body,
|
|
1066
|
+
signal: options?.signal
|
|
1067
|
+
});
|
|
1068
|
+
const incomingMessage = new IncomingMessage2(response, options?.method || "GET");
|
|
1069
|
+
if (callback) callback(incomingMessage);
|
|
1070
|
+
req.emit("response", incomingMessage);
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
return req;
|
|
1074
|
+
}
|
|
1075
|
+
function get2(url, options, callback) {
|
|
1076
|
+
const req = request2(url, { ...options, method: "GET" }, callback);
|
|
1077
|
+
req.end();
|
|
1078
|
+
return req;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// src/server/https/runtime.ts
|
|
1082
|
+
init_runtime();
|
|
1083
|
+
function getRuntime2() {
|
|
1084
|
+
return runtime;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// src/server/https/server-runtime.ts
|
|
1088
|
+
var import_node_events6 = __require("events");
|
|
1089
|
+
init_runtime();
|
|
1090
|
+
init_utils();
|
|
1091
|
+
var Server2 = class extends import_node_events6.EventEmitter {
|
|
1092
|
+
constructor(options = {}, requestListener) {
|
|
740
1093
|
super();
|
|
741
1094
|
this._listening = false;
|
|
742
1095
|
this.options = options;
|
|
@@ -764,7 +1117,6 @@
|
|
|
764
1117
|
const self = this;
|
|
765
1118
|
if (isNode) {
|
|
766
1119
|
const { IncomingMessage: IncomingMessage2, ServerResponse: ServerResponse2 } = loadHttpClasses();
|
|
767
|
-
if (!https2) https2 = __require("https");
|
|
768
1120
|
this.nativeServer = https2.createServer(this.options, (req, res) => {
|
|
769
1121
|
const incomingMessage = new IncomingMessage2(req);
|
|
770
1122
|
const serverResponse = new ServerResponse2(incomingMessage, res);
|
|
@@ -803,7 +1155,7 @@
|
|
|
803
1155
|
},
|
|
804
1156
|
error: (error) => {
|
|
805
1157
|
this.emit("error", error);
|
|
806
|
-
return
|
|
1158
|
+
return createErrorResponse();
|
|
807
1159
|
}
|
|
808
1160
|
};
|
|
809
1161
|
if (this.options.key || this.options.cert) {
|
|
@@ -817,7 +1169,7 @@
|
|
|
817
1169
|
tlsOptions.tls = this.options.tls;
|
|
818
1170
|
}
|
|
819
1171
|
this.nativeServer = Bun.serve(tlsOptions);
|
|
820
|
-
|
|
1172
|
+
emitListeningWithCallback(this, callback);
|
|
821
1173
|
} else if (isDeno) {
|
|
822
1174
|
const { IncomingMessage: IncomingMessage2, ServerResponse: ServerResponse2 } = loadHttpClasses();
|
|
823
1175
|
const serveOptions = {
|
|
@@ -837,7 +1189,7 @@
|
|
|
837
1189
|
},
|
|
838
1190
|
onError: (error) => {
|
|
839
1191
|
this.emit("error", error);
|
|
840
|
-
return
|
|
1192
|
+
return createErrorResponse();
|
|
841
1193
|
}
|
|
842
1194
|
};
|
|
843
1195
|
if (this.options.key && this.options.cert) {
|
|
@@ -845,23 +1197,23 @@
|
|
|
845
1197
|
serveOptions.key = this.options.key;
|
|
846
1198
|
}
|
|
847
1199
|
this.nativeServer = Deno.serve(serveOptions);
|
|
848
|
-
|
|
1200
|
+
emitListeningWithCallback(this, callback);
|
|
849
1201
|
}
|
|
850
1202
|
return this;
|
|
851
1203
|
}
|
|
852
1204
|
close(callback) {
|
|
853
1205
|
if (!this.nativeServer) {
|
|
854
|
-
if (callback)
|
|
1206
|
+
if (callback) queueCallback(() => callback());
|
|
855
1207
|
return this;
|
|
856
1208
|
}
|
|
857
1209
|
if (isNode) {
|
|
858
1210
|
this.nativeServer.close(callback);
|
|
859
1211
|
} else if (isBun) {
|
|
860
1212
|
this.nativeServer.stop();
|
|
861
|
-
|
|
1213
|
+
closeAndEmit(this, callback);
|
|
862
1214
|
} else if (isDeno) {
|
|
863
1215
|
this.nativeServer.shutdown();
|
|
864
|
-
|
|
1216
|
+
closeAndEmit(this, callback);
|
|
865
1217
|
}
|
|
866
1218
|
return this;
|
|
867
1219
|
}
|
|
@@ -871,14 +1223,16 @@
|
|
|
871
1223
|
const addr = this.nativeServer.address();
|
|
872
1224
|
if (!addr) return null;
|
|
873
1225
|
if (typeof addr === "string") {
|
|
874
|
-
return
|
|
1226
|
+
return createAddress(0, addr, "unix");
|
|
875
1227
|
}
|
|
876
1228
|
return addr;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
|
|
1229
|
+
}
|
|
1230
|
+
if (isBun) {
|
|
1231
|
+
return createAddress(this.nativeServer.port, this.nativeServer.hostname);
|
|
1232
|
+
}
|
|
1233
|
+
if (isDeno) {
|
|
880
1234
|
const addr = this.nativeServer.addr;
|
|
881
|
-
return
|
|
1235
|
+
return createAddress(addr.port, addr.hostname);
|
|
882
1236
|
}
|
|
883
1237
|
return null;
|
|
884
1238
|
}
|
|
@@ -886,78 +1240,18 @@
|
|
|
886
1240
|
return this._listening;
|
|
887
1241
|
}
|
|
888
1242
|
};
|
|
889
|
-
|
|
890
|
-
constructor(_url, _options = {}) {
|
|
891
|
-
super();
|
|
892
|
-
}
|
|
893
|
-
write(_chunk) {
|
|
894
|
-
return true;
|
|
895
|
-
}
|
|
896
|
-
end(callback) {
|
|
897
|
-
queueCallback2(callback);
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
var Agent2 = class {
|
|
901
|
-
constructor(options) {
|
|
902
|
-
this.options = options;
|
|
903
|
-
}
|
|
904
|
-
};
|
|
905
|
-
function createServer2(options, requestListener) {
|
|
1243
|
+
function createServer2(options = {}, requestListener) {
|
|
906
1244
|
return new Server2(options, requestListener);
|
|
907
1245
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
const req = new ClientRequest2(urlString, options);
|
|
911
|
-
if (isNode) {
|
|
912
|
-
const { IncomingMessage: IncomingMessage2 } = loadHttpClasses();
|
|
913
|
-
if (!https2) https2 = __require("https");
|
|
914
|
-
const nodeReq = https2.request(urlString, {
|
|
915
|
-
method: options?.method || "GET",
|
|
916
|
-
headers: options?.headers,
|
|
917
|
-
timeout: options?.timeout,
|
|
918
|
-
signal: options?.signal
|
|
919
|
-
}, (res) => {
|
|
920
|
-
const incomingMessage = new IncomingMessage2(res);
|
|
921
|
-
if (callback) callback(incomingMessage);
|
|
922
|
-
req.emit("response", incomingMessage);
|
|
923
|
-
});
|
|
924
|
-
nodeReq.on("error", (error) => req.emit("error", error));
|
|
925
|
-
nodeReq.end();
|
|
926
|
-
} else {
|
|
927
|
-
const { IncomingMessage: IncomingMessage2 } = loadHttpClasses();
|
|
928
|
-
queueMicrotask(async () => {
|
|
929
|
-
try {
|
|
930
|
-
const response = await fetch(urlString, {
|
|
931
|
-
method: options?.method || "GET",
|
|
932
|
-
headers: options?.headers,
|
|
933
|
-
signal: options?.signal
|
|
934
|
-
});
|
|
935
|
-
const fetchRequest = new Request(urlString);
|
|
936
|
-
const incomingMessage = new IncomingMessage2(fetchRequest);
|
|
937
|
-
incomingMessage.statusCode = response.status;
|
|
938
|
-
incomingMessage.statusMessage = response.statusText;
|
|
939
|
-
if (callback) callback(incomingMessage);
|
|
940
|
-
req.emit("response", incomingMessage);
|
|
941
|
-
} catch (error) {
|
|
942
|
-
req.emit("error", error);
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
return req;
|
|
947
|
-
}
|
|
948
|
-
function get2(url, options, callback) {
|
|
949
|
-
return request2(url, { ...options, method: "GET" }, callback);
|
|
950
|
-
}
|
|
951
|
-
function getRuntime2() {
|
|
952
|
-
return runtime;
|
|
953
|
-
}
|
|
1246
|
+
|
|
1247
|
+
// src/server/https/index.ts
|
|
954
1248
|
var https_default = {
|
|
955
1249
|
createServer: createServer2,
|
|
956
1250
|
request: request2,
|
|
957
1251
|
get: get2,
|
|
958
1252
|
Server: Server2,
|
|
959
|
-
Agent
|
|
960
|
-
ClientRequest
|
|
1253
|
+
Agent,
|
|
1254
|
+
ClientRequest,
|
|
961
1255
|
getRuntime: getRuntime2
|
|
962
1256
|
};
|
|
963
1257
|
})();
|