Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,14 @@
import type nodeHttp from "node:http";
import { EventEmitter } from "node:events";
export declare class Agent extends EventEmitter implements nodeHttp.Agent {
__unenv__: {};
maxFreeSockets: number;
maxSockets: number;
maxTotalSockets: number;
readonly freeSockets: {};
readonly sockets: {};
readonly requests: {};
readonly options: nodeHttp.AgentOptions;
constructor(opts?: nodeHttp.AgentOptions);
destroy(): void;
}

View file

@ -0,0 +1,16 @@
import { EventEmitter } from "node:events";
export class Agent extends EventEmitter {
__unenv__ = {};
maxFreeSockets = 256;
maxSockets = Infinity;
maxTotalSockets = Infinity;
freeSockets = {};
sockets = {};
requests = {};
options;
constructor(opts = {}) {
super();
this.options = opts;
}
destroy() {}
}

View file

@ -0,0 +1,67 @@
export declare const METHODS: unknown;
export declare const STATUS_CODES: {
100: string;
101: string;
102: string;
103: string;
200: string;
201: string;
202: string;
203: string;
204: string;
205: string;
206: string;
207: string;
208: string;
226: string;
300: string;
301: string;
302: string;
303: string;
304: string;
305: string;
307: string;
308: string;
400: string;
401: string;
402: string;
403: string;
404: string;
405: string;
406: string;
407: string;
408: string;
409: string;
410: string;
411: string;
412: string;
413: string;
414: string;
415: string;
416: string;
417: string;
418: string;
421: string;
422: string;
423: string;
424: string;
425: string;
426: string;
428: string;
429: string;
431: string;
451: string;
500: string;
501: string;
502: string;
503: string;
504: string;
505: string;
506: string;
507: string;
508: string;
509: string;
510: string;
511: string;
};
export declare const maxHeaderSize = 16384;

View file

@ -0,0 +1,103 @@
export const METHODS = [
"ACL",
"BIND",
"CHECKOUT",
"CONNECT",
"COPY",
"DELETE",
"GET",
"HEAD",
"LINK",
"LOCK",
"M-SEARCH",
"MERGE",
"MKACTIVITY",
"MKCALENDAR",
"MKCOL",
"MOVE",
"NOTIFY",
"OPTIONS",
"PATCH",
"POST",
"PRI",
"PROPFIND",
"PROPPATCH",
"PURGE",
"PUT",
"REBIND",
"REPORT",
"SEARCH",
"SOURCE",
"SUBSCRIBE",
"TRACE",
"UNBIND",
"UNLINK",
"UNLOCK",
"UNSUBSCRIBE"
];
export const STATUS_CODES = {
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"
};
export const maxHeaderSize = 16384;

View file

@ -0,0 +1,31 @@
import type NodeHttp from "node:http";
import { Socket } from "node:net";
import { Readable } from "node:stream";
// Docs: https://nodejs.org/api/http.html#http_class_http_incomingmessage
// Implementation: https://github.com/nodejs/node/blob/master/lib/_http_incoming.js
export declare class IncomingMessage extends Readable implements NodeHttp.IncomingMessage {
__unenv__: {};
aborted: boolean;
httpVersion: string;
httpVersionMajor: number;
httpVersionMinor: number;
complete: boolean;
connection: Socket;
socket: Socket;
headers: NodeHttp.IncomingHttpHeaders;
trailers: {};
method: string;
url: string;
statusCode: number;
statusMessage: string;
closed: boolean;
errored: Error | null;
readable: boolean;
constructor(socket?: Socket);
get rawHeaders();
get rawTrailers(): unknown;
setTimeout(_msecs: number, _callback?: () => void);
get headersDistinct();
get trailersDistinct();
_read();
}

View file

@ -0,0 +1,53 @@
import { Socket } from "node:net";
import { Readable } from "node:stream";
import { rawHeaders } from "../../../_internal/utils.mjs";
// Docs: https://nodejs.org/api/http.html#http_class_http_incomingmessage
// Implementation: https://github.com/nodejs/node/blob/master/lib/_http_incoming.js
export class IncomingMessage extends Readable {
__unenv__ = {};
aborted = false;
httpVersion = "1.1";
httpVersionMajor = 1;
httpVersionMinor = 1;
complete = true;
connection;
socket;
headers = {};
trailers = {};
method = "GET";
url = "/";
statusCode = 200;
statusMessage = "";
closed = false;
errored = null;
readable = false;
constructor(socket) {
super();
this.socket = this.connection = socket || new Socket();
}
get rawHeaders() {
return rawHeaders(this.headers);
}
get rawTrailers() {
return [];
}
setTimeout(_msecs, _callback) {
return this;
}
get headersDistinct() {
return _distinct(this.headers);
}
get trailersDistinct() {
return _distinct(this.trailers);
}
_read() {}
}
function _distinct(obj) {
const d = {};
for (const [key, value] of Object.entries(obj)) {
if (key) {
d[key] = (Array.isArray(value) ? value : [value]).filter(Boolean);
}
}
return d;
}

View file

@ -0,0 +1,42 @@
import type nodeHttp from "node:http";
import type { Socket } from "node:net";
import type { Callback } from "../../../_internal/types.mjs";
import { Writable } from "node:stream";
// Docs: https://nodejs.org/api/http.html#http_class_http_serverresponse
// Implementation: https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
export declare class ServerResponse extends Writable implements nodeHttp.ServerResponse {
readonly __unenv__: true;
statusCode: number;
statusMessage: string;
upgrading: boolean;
chunkedEncoding: boolean;
shouldKeepAlive: boolean;
useChunkedEncodingByDefault: boolean;
sendDate: boolean;
finished: boolean;
headersSent: boolean;
strictContentLength: boolean;
connection: Socket | null;
socket: Socket | null;
req: nodeHttp.IncomingMessage;
_headers: Record<string, number | string | string[] | undefined>;
constructor(req: nodeHttp.IncomingMessage);
assignSocket(socket: Socket): void;
_flush();
detachSocket(_socket: Socket): void;
writeContinue(_callback?: Callback): void;
writeHead(statusCode: number, arg1?: string | nodeHttp.OutgoingHttpHeaders | nodeHttp.OutgoingHttpHeader[], arg2?: nodeHttp.OutgoingHttpHeaders | nodeHttp.OutgoingHttpHeader[]);
writeProcessing(): void;
setTimeout(_msecs: number, _callback?: Callback): this;
appendHeader(name: string, value: string | string[]);
setHeader(name: string, value: number | string | readonly string[]): this;
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
getHeader(name: string): number | string | string[] | undefined;
getHeaders(): nodeHttp.OutgoingHttpHeaders;
getHeaderNames(): string[];
hasHeader(name: string): boolean;
removeHeader(name: string): void;
addTrailers(_headers: nodeHttp.OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
flushHeaders(): void;
writeEarlyHints(_headers: nodeHttp.OutgoingHttpHeaders, cb: () => void): void;
}

View file

@ -0,0 +1,101 @@
import { Writable } from "node:stream";
// Docs: https://nodejs.org/api/http.html#http_class_http_serverresponse
// Implementation: https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
export class ServerResponse extends Writable {
__unenv__ = true;
statusCode = 200;
statusMessage = "";
upgrading = false;
chunkedEncoding = false;
shouldKeepAlive = false;
useChunkedEncodingByDefault = false;
sendDate = false;
finished = false;
headersSent = false;
strictContentLength = false;
connection = null;
socket = null;
req;
_headers = {};
constructor(req) {
super();
this.req = req;
}
assignSocket(socket) {
// @ts-ignore
socket._httpMessage = this;
// socket.on('close', onServerResponseClose)
this.socket = socket;
this.connection = socket;
this.emit("socket", socket);
this._flush();
}
_flush() {
this.flushHeaders();
}
detachSocket(_socket) {}
writeContinue(_callback) {}
writeHead(statusCode, arg1, arg2) {
if (statusCode) {
this.statusCode = statusCode;
}
if (typeof arg1 === "string") {
this.statusMessage = arg1;
arg1 = undefined;
}
const headers = arg2 || arg1;
if (headers) {
if (Array.isArray(headers)) {} else {
for (const key in headers) {
// @ts-ignore
this.setHeader(key, headers[key]);
}
}
}
this.headersSent = true;
return this;
}
writeProcessing() {}
setTimeout(_msecs, _callback) {
return this;
}
appendHeader(name, value) {
name = name.toLowerCase();
const current = this._headers[name];
const all = [...Array.isArray(current) ? current : [current], ...Array.isArray(value) ? value : [value]].filter(Boolean);
this._headers[name] = all.length > 1 ? all : all[0];
return this;
}
setHeader(name, value) {
this._headers[name.toLowerCase()] = Array.isArray(value) ? [...value] : value;
return this;
}
setHeaders(headers) {
for (const [key, value] of headers.entries()) {
this.setHeader(key, value);
}
return this;
}
getHeader(name) {
return this._headers[name.toLowerCase()];
}
getHeaders() {
return this._headers;
}
getHeaderNames() {
return Object.keys(this._headers);
}
hasHeader(name) {
return name.toLowerCase() in this._headers;
}
removeHeader(name) {
delete this._headers[name.toLowerCase()];
}
addTrailers(_headers) {}
flushHeaders() {}
writeEarlyHints(_headers, cb) {
if (typeof cb === "function") {
cb();
}
}
}