add websocket server to this dir. fix stuff for client
This commit is contained in:
parent
f8152c6db8
commit
4886bc5b1f
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,6 +4,7 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
*/node_modules
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
@ -35,6 +36,7 @@ yarn-error.log*
|
|||||||
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
|
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
|
||||||
.env
|
.env
|
||||||
.env*.local
|
.env*.local
|
||||||
|
*/.env
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
@ -43,4 +45,4 @@ yarn-error.log*
|
|||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
# idea files
|
# idea files
|
||||||
.idea
|
.idea
|
||||||
|
@ -18,3 +18,75 @@ $$;
|
|||||||
CREATE TRIGGER message_insert_trigger
|
CREATE TRIGGER message_insert_trigger
|
||||||
AFTER INSERT ON messages
|
AFTER INSERT ON messages
|
||||||
FOR EACH ROW EXECUTE FUNCTION notify_new_message();
|
FOR EACH ROW EXECUTE FUNCTION notify_new_message();
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION notify_countdown_update()
|
||||||
|
RETURNS trigger LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
PERFORM pg_notify(
|
||||||
|
'countdown_update',
|
||||||
|
json_build_object(
|
||||||
|
'id', NEW.id,
|
||||||
|
'relationshipId', NEW.relationship_id,
|
||||||
|
'title', NEW.title,
|
||||||
|
'date', NEW.date
|
||||||
|
)::text
|
||||||
|
);
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE TRIGGER countdown_update_trigger
|
||||||
|
AFTER INSERT OR UPDATE ON countdowns
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION notify_countdown_update();
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION notify_relationship_status_change()
|
||||||
|
RETURNS trigger LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
|
||||||
|
PERFORM pg_notify(
|
||||||
|
'relationship_status_change',
|
||||||
|
json_build_object(
|
||||||
|
'id', NEW.id,
|
||||||
|
'relationshipId', NEW.id,
|
||||||
|
'status', NEW.is_accepted
|
||||||
|
)::text
|
||||||
|
);
|
||||||
|
ELSIF (TG_OP = 'DELETE') THEN
|
||||||
|
PERFORM pg_notify(
|
||||||
|
'relationship_status_change',
|
||||||
|
json_build_object(
|
||||||
|
'id', OLD.id,
|
||||||
|
'relationshipId', OLD.id,
|
||||||
|
'status', 'deleted'
|
||||||
|
)::text
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE TRIGGER relationship_status_change_trigger
|
||||||
|
AFTER INSERT OR UPDATE OR DELETE ON relationships
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION notify_relationship_status_change();
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION notify_profile_picture_update()
|
||||||
|
RETURNS trigger LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
PERFORM pg_notify(
|
||||||
|
'profile_picture_update',
|
||||||
|
json_build_object(
|
||||||
|
'id', NEW.id,
|
||||||
|
'userId', NEW.id,
|
||||||
|
'pictureUrl', NEW.pfp_url
|
||||||
|
)::text
|
||||||
|
);
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE TRIGGER profile_picture_update_trigger
|
||||||
|
AFTER UPDATE OF pfp_url ON users
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION notify_profile_picture_update();
|
||||||
|
BIN
public/uploads/profile-pictures/3_1729898560745.jpg
Normal file
BIN
public/uploads/profile-pictures/3_1729898560745.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -2,7 +2,8 @@ import 'server-only';
|
|||||||
import { db } from '~/server/db';
|
import { db } from '~/server/db';
|
||||||
import * as schema from '~/server/db/schema';
|
import * as schema from '~/server/db/schema';
|
||||||
import { eq, and, or, like, not, desc, sql } from 'drizzle-orm';
|
import { eq, and, or, like, not, desc, sql } from 'drizzle-orm';
|
||||||
import { User,
|
import type {
|
||||||
|
User,
|
||||||
Relationship,
|
Relationship,
|
||||||
UserRelationship,
|
UserRelationship,
|
||||||
RelationshipData,
|
RelationshipData,
|
||||||
@ -279,6 +280,8 @@ export const updateRelationshipStatus = async (
|
|||||||
} else if (status === 'rejected') {
|
} else if (status === 'rejected') {
|
||||||
await db.delete(schema.userRelationships)
|
await db.delete(schema.userRelationships)
|
||||||
.where(eq(schema.userRelationships.relationshipId, relationship.id));
|
.where(eq(schema.userRelationships.relationshipId, relationship.id));
|
||||||
|
await db.delete(schema.countdowns)
|
||||||
|
.where(eq(schema.countdowns.relationshipId, relationship.id));
|
||||||
await db.delete(schema.relationships)
|
await db.delete(schema.relationships)
|
||||||
.where(eq(schema.relationships.id, relationship.id));
|
.where(eq(schema.relationships.id, relationship.id));
|
||||||
return null;
|
return null;
|
||||||
|
102
websocket_server/dist/server.js
vendored
Normal file
102
websocket_server/dist/server.js
vendored
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const express_1 = __importDefault(require("express"));
|
||||||
|
const socket_io_1 = require("socket.io");
|
||||||
|
const http_1 = require("http");
|
||||||
|
const pg_1 = require("pg");
|
||||||
|
const dotenv_1 = __importDefault(require("dotenv"));
|
||||||
|
dotenv_1.default.config();
|
||||||
|
const app = (0, express_1.default)();
|
||||||
|
const httpServer = (0, http_1.createServer)(app);
|
||||||
|
// Create new Socket.IO server
|
||||||
|
const io = new socket_io_1.Server(httpServer);
|
||||||
|
const PORT = process.env.PORT || 3030;
|
||||||
|
const pgClient = new pg_1.Client({
|
||||||
|
connectionString: process.env.DATABASE_URL,
|
||||||
|
});
|
||||||
|
const handleNotification = (msg) => {
|
||||||
|
var _a;
|
||||||
|
const payload = JSON.parse((_a = msg.payload) !== null && _a !== void 0 ? _a : '{}');
|
||||||
|
switch (msg.channel) {
|
||||||
|
case 'new_message':
|
||||||
|
handleNewMessage(payload);
|
||||||
|
break;
|
||||||
|
case 'countdown_update':
|
||||||
|
handleCountdownUpdate(payload);
|
||||||
|
break;
|
||||||
|
case 'relationship_status_change':
|
||||||
|
handleRelationshipStatusChange(payload);
|
||||||
|
break;
|
||||||
|
case 'profile_picture_update':
|
||||||
|
handleProfilePictureUpdate(payload);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('Unhandled notification:', msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleNewMessage = (payload) => {
|
||||||
|
const { receiverId, text, id } = payload;
|
||||||
|
io.to(`user:${receiverId}`).emit('new_message', payload);
|
||||||
|
console.log(`Message sent to room ${receiverId} with text: "${text}"`);
|
||||||
|
};
|
||||||
|
const handleCountdownUpdate = (payload) => {
|
||||||
|
const { relationshipId, countdown } = payload;
|
||||||
|
io.to(`relationship:${relationshipId}`).emit('countdown_update', countdown);
|
||||||
|
console.log(`Countdown update sent to room ${relationshipId}`);
|
||||||
|
};
|
||||||
|
const handleRelationshipStatusChange = (payload) => {
|
||||||
|
const { relationshipId, status } = payload;
|
||||||
|
io.to(`relationship:${relationshipId}`).emit('relationship_status_change', status);
|
||||||
|
console.log(`Relationship status change sent to room ${relationshipId}, status: ${status}`);
|
||||||
|
};
|
||||||
|
const handleProfilePictureUpdate = (payload) => {
|
||||||
|
const { userId, profilePictureUrl } = payload;
|
||||||
|
io.to(`user:${userId}`).emit('profile_picture_update', profilePictureUrl);
|
||||||
|
console.log(`Profile picture update sent to room ${userId}`);
|
||||||
|
};
|
||||||
|
// Connect the PostgreSQL client
|
||||||
|
pgClient.connect()
|
||||||
|
.then(() => {
|
||||||
|
console.log('Connected to PostgreSQL');
|
||||||
|
// Listen for NOTIFY events on the 'new_message' channel
|
||||||
|
pgClient.query('LISTEN new_message');
|
||||||
|
pgClient.query('LISTEN countdown_update');
|
||||||
|
pgClient.query('LISTEN relationship_status_change');
|
||||||
|
pgClient.query('LISTEN profile_picture_update');
|
||||||
|
pgClient.on('notification', handleNotification);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Failed to connect to PostgreSQL:', err);
|
||||||
|
});
|
||||||
|
// Handle WebSocket connections
|
||||||
|
io.on('connection', (socket) => {
|
||||||
|
console.log('WebSocket client connected:', socket.id);
|
||||||
|
socket.on('join', (roomInfo) => {
|
||||||
|
//console.log('Attempting to join room:', roomInfo);
|
||||||
|
if (typeof roomInfo === 'object') {
|
||||||
|
if (roomInfo.userId) {
|
||||||
|
socket.join(`user:${roomInfo.userId}`);
|
||||||
|
console.log(`User ${roomInfo.userId} joined room`);
|
||||||
|
}
|
||||||
|
else if (roomInfo.relationshipId) {
|
||||||
|
socket.join(`relationship:${roomInfo.relationshipId}`);
|
||||||
|
console.log(`Relationship ${roomInfo.relationshipId} joined room`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log('Socket object at connection:', socket);
|
||||||
|
});
|
||||||
|
socket.on('error', (error) => {
|
||||||
|
console.error('WebSocket error:', error);
|
||||||
|
});
|
||||||
|
// Handle disconnection of WebSocket clients
|
||||||
|
socket.on('disconnect', () => {
|
||||||
|
console.log('WebSocket client disconnected:', socket.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Start the WebSocket server
|
||||||
|
httpServer.listen(PORT, () => {
|
||||||
|
console.log(`WebSocket server is running on port ${PORT}`);
|
||||||
|
});
|
17
websocket_server/node_modules/.bin/mime
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/mime
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/mime/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/mime/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mime/cli.js" "$@"
|
||||||
|
fi
|
17
websocket_server/node_modules/.bin/node-which
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/node-which
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/which/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/which/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/which/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/which/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../which/bin/node-which" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../which/bin/node-which" "$@"
|
||||||
|
fi
|
17
websocket_server/node_modules/.bin/ps-tree
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/ps-tree
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/ps-tree/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/ps-tree/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/ps-tree/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/ps-tree/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules:/home/gib/Documents/Web/wavelength/node_modules:/home/gib/Documents/Web/node_modules:/home/gib/Documents/node_modules:/home/gib/node_modules:/home/node_modules:/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../ps-tree/bin/ps-tree.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../ps-tree/bin/ps-tree.js" "$@"
|
||||||
|
fi
|
17
websocket_server/node_modules/.bin/tsc
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/tsc
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../typescript/bin/tsc" "$@"
|
||||||
|
fi
|
17
websocket_server/node_modules/.bin/tsc-watch
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/tsc-watch
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/dist/lib/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/dist/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/dist/lib/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/dist/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules/tsc-watch/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/tsc-watch@6.2.0_typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../tsc-watch/dist/lib/tsc-watch.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../tsc-watch/dist/lib/tsc-watch.js" "$@"
|
||||||
|
fi
|
17
websocket_server/node_modules/.bin/tsserver
generated
vendored
Executable file
17
websocket_server/node_modules/.bin/tsserver
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$NODE_PATH" ]; then
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules"
|
||||||
|
else
|
||||||
|
export NODE_PATH="/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/bin/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/typescript@5.6.3/node_modules:/home/gib/Documents/Web/wavelength/websocket-server/node_modules/.pnpm/node_modules:$NODE_PATH"
|
||||||
|
fi
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
||||||
|
fi
|
21
websocket_server/node_modules/.ignored/@types/cors/LICENSE
generated
vendored
Normal file
21
websocket_server/node_modules/.ignored/@types/cors/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
75
websocket_server/node_modules/.ignored/@types/cors/README.md
generated
vendored
Normal file
75
websocket_server/node_modules/.ignored/@types/cors/README.md
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/cors`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for cors (https://github.com/expressjs/cors/).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors.
|
||||||
|
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors/index.d.ts)
|
||||||
|
````ts
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import { IncomingHttpHeaders } from "http";
|
||||||
|
|
||||||
|
type StaticOrigin = boolean | string | RegExp | Array<boolean | string | RegExp>;
|
||||||
|
|
||||||
|
type CustomOrigin = (
|
||||||
|
requestOrigin: string | undefined,
|
||||||
|
callback: (err: Error | null, origin?: StaticOrigin) => void,
|
||||||
|
) => void;
|
||||||
|
|
||||||
|
declare namespace e {
|
||||||
|
interface CorsRequest {
|
||||||
|
method?: string | undefined;
|
||||||
|
headers: IncomingHttpHeaders;
|
||||||
|
}
|
||||||
|
interface CorsOptions {
|
||||||
|
/**
|
||||||
|
* @default '*''
|
||||||
|
*/
|
||||||
|
origin?: StaticOrigin | CustomOrigin | undefined;
|
||||||
|
/**
|
||||||
|
* @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
|
||||||
|
*/
|
||||||
|
methods?: string | string[] | undefined;
|
||||||
|
allowedHeaders?: string | string[] | undefined;
|
||||||
|
exposedHeaders?: string | string[] | undefined;
|
||||||
|
credentials?: boolean | undefined;
|
||||||
|
maxAge?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
preflightContinue?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* @default 204
|
||||||
|
*/
|
||||||
|
optionsSuccessStatus?: number | undefined;
|
||||||
|
}
|
||||||
|
type CorsOptionsDelegate<T extends CorsRequest = CorsRequest> = (
|
||||||
|
req: T,
|
||||||
|
callback: (err: Error | null, options?: CorsOptions) => void,
|
||||||
|
) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function e<T extends e.CorsRequest = e.CorsRequest>(
|
||||||
|
options?: e.CorsOptions | e.CorsOptionsDelegate<T>,
|
||||||
|
): (
|
||||||
|
req: T,
|
||||||
|
res: {
|
||||||
|
statusCode?: number | undefined;
|
||||||
|
setHeader(key: string, value: string): any;
|
||||||
|
end(): any;
|
||||||
|
},
|
||||||
|
next: (err?: any) => any,
|
||||||
|
) => void;
|
||||||
|
export = e;
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
### Additional Details
|
||||||
|
* Last updated: Mon, 20 Nov 2023 23:36:24 GMT
|
||||||
|
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by [Alan Plum](https://github.com/pluma), and [Gaurav Sharma](https://github.com/gtpan77).
|
56
websocket_server/node_modules/.ignored/@types/cors/index.d.ts
generated
vendored
Normal file
56
websocket_server/node_modules/.ignored/@types/cors/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import { IncomingHttpHeaders } from "http";
|
||||||
|
|
||||||
|
type StaticOrigin = boolean | string | RegExp | Array<boolean | string | RegExp>;
|
||||||
|
|
||||||
|
type CustomOrigin = (
|
||||||
|
requestOrigin: string | undefined,
|
||||||
|
callback: (err: Error | null, origin?: StaticOrigin) => void,
|
||||||
|
) => void;
|
||||||
|
|
||||||
|
declare namespace e {
|
||||||
|
interface CorsRequest {
|
||||||
|
method?: string | undefined;
|
||||||
|
headers: IncomingHttpHeaders;
|
||||||
|
}
|
||||||
|
interface CorsOptions {
|
||||||
|
/**
|
||||||
|
* @default '*''
|
||||||
|
*/
|
||||||
|
origin?: StaticOrigin | CustomOrigin | undefined;
|
||||||
|
/**
|
||||||
|
* @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
|
||||||
|
*/
|
||||||
|
methods?: string | string[] | undefined;
|
||||||
|
allowedHeaders?: string | string[] | undefined;
|
||||||
|
exposedHeaders?: string | string[] | undefined;
|
||||||
|
credentials?: boolean | undefined;
|
||||||
|
maxAge?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
preflightContinue?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* @default 204
|
||||||
|
*/
|
||||||
|
optionsSuccessStatus?: number | undefined;
|
||||||
|
}
|
||||||
|
type CorsOptionsDelegate<T extends CorsRequest = CorsRequest> = (
|
||||||
|
req: T,
|
||||||
|
callback: (err: Error | null, options?: CorsOptions) => void,
|
||||||
|
) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function e<T extends e.CorsRequest = e.CorsRequest>(
|
||||||
|
options?: e.CorsOptions | e.CorsOptionsDelegate<T>,
|
||||||
|
): (
|
||||||
|
req: T,
|
||||||
|
res: {
|
||||||
|
statusCode?: number | undefined;
|
||||||
|
setHeader(key: string, value: string): any;
|
||||||
|
end(): any;
|
||||||
|
},
|
||||||
|
next: (err?: any) => any,
|
||||||
|
) => void;
|
||||||
|
export = e;
|
32
websocket_server/node_modules/.ignored/@types/cors/package.json
generated
vendored
Normal file
32
websocket_server/node_modules/.ignored/@types/cors/package.json
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/cors",
|
||||||
|
"version": "2.8.17",
|
||||||
|
"description": "TypeScript definitions for cors",
|
||||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Alan Plum",
|
||||||
|
"githubUsername": "pluma",
|
||||||
|
"url": "https://github.com/pluma"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gaurav Sharma",
|
||||||
|
"githubUsername": "gtpan77",
|
||||||
|
"url": "https://github.com/gtpan77"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/cors"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "04d506dbb23d9e7a142bfb227d59c61102abec00fb40694bb64a8d9fe1f1a3a1",
|
||||||
|
"typeScriptVersion": "4.5"
|
||||||
|
}
|
21
websocket_server/node_modules/.ignored/@types/express/LICENSE
generated
vendored
Normal file
21
websocket_server/node_modules/.ignored/@types/express/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
15
websocket_server/node_modules/.ignored/@types/express/README.md
generated
vendored
Normal file
15
websocket_server/node_modules/.ignored/@types/express/README.md
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/express`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for express (http://expressjs.com).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express.
|
||||||
|
|
||||||
|
### Additional Details
|
||||||
|
* Last updated: Wed, 25 Sep 2024 19:19:36 GMT
|
||||||
|
* Dependencies: [@types/body-parser](https://npmjs.com/package/@types/body-parser), [@types/express-serve-static-core](https://npmjs.com/package/@types/express-serve-static-core), [@types/qs](https://npmjs.com/package/@types/qs), [@types/serve-static](https://npmjs.com/package/@types/serve-static)
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by [Boris Yankov](https://github.com/borisyankov), [China Medical University Hospital](https://github.com/CMUH), [Puneet Arora](https://github.com/puneetar), and [Dylan Frankland](https://github.com/dfrankland).
|
128
websocket_server/node_modules/.ignored/@types/express/index.d.ts
generated
vendored
Normal file
128
websocket_server/node_modules/.ignored/@types/express/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/* =================== USAGE ===================
|
||||||
|
|
||||||
|
import express = require("express");
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
=============================================== */
|
||||||
|
|
||||||
|
/// <reference types="express-serve-static-core" />
|
||||||
|
/// <reference types="serve-static" />
|
||||||
|
|
||||||
|
import * as bodyParser from "body-parser";
|
||||||
|
import * as core from "express-serve-static-core";
|
||||||
|
import * as qs from "qs";
|
||||||
|
import * as serveStatic from "serve-static";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an Express application. The express() function is a top-level function exported by the express module.
|
||||||
|
*/
|
||||||
|
declare function e(): core.Express;
|
||||||
|
|
||||||
|
declare namespace e {
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It parses incoming requests with JSON payloads and is based on body-parser.
|
||||||
|
* @since 4.16.0
|
||||||
|
*/
|
||||||
|
var json: typeof bodyParser.json;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It parses incoming requests with Buffer payloads and is based on body-parser.
|
||||||
|
* @since 4.17.0
|
||||||
|
*/
|
||||||
|
var raw: typeof bodyParser.raw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It parses incoming requests with text payloads and is based on body-parser.
|
||||||
|
* @since 4.17.0
|
||||||
|
*/
|
||||||
|
var text: typeof bodyParser.text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are the exposed prototypes.
|
||||||
|
*/
|
||||||
|
var application: Application;
|
||||||
|
var request: Request;
|
||||||
|
var response: Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It serves static files and is based on serve-static.
|
||||||
|
*/
|
||||||
|
var static: serveStatic.RequestHandlerConstructor<Response>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It parses incoming requests with urlencoded payloads and is based on body-parser.
|
||||||
|
* @since 4.16.0
|
||||||
|
*/
|
||||||
|
var urlencoded: typeof bodyParser.urlencoded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a built-in middleware function in Express. It parses incoming request query parameters.
|
||||||
|
*/
|
||||||
|
export function query(options: qs.IParseOptions | typeof qs.parse): Handler;
|
||||||
|
|
||||||
|
export function Router(options?: RouterOptions): core.Router;
|
||||||
|
|
||||||
|
interface RouterOptions {
|
||||||
|
/**
|
||||||
|
* Enable case sensitivity.
|
||||||
|
*/
|
||||||
|
caseSensitive?: boolean | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preserve the req.params values from the parent router.
|
||||||
|
* If the parent and the child have conflicting param names, the child’s value take precedence.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
mergeParams?: boolean | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable strict routing.
|
||||||
|
*/
|
||||||
|
strict?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Application extends core.Application {}
|
||||||
|
interface CookieOptions extends core.CookieOptions {}
|
||||||
|
interface Errback extends core.Errback {}
|
||||||
|
interface ErrorRequestHandler<
|
||||||
|
P = core.ParamsDictionary,
|
||||||
|
ResBody = any,
|
||||||
|
ReqBody = any,
|
||||||
|
ReqQuery = core.Query,
|
||||||
|
Locals extends Record<string, any> = Record<string, any>,
|
||||||
|
> extends core.ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> {}
|
||||||
|
interface Express extends core.Express {}
|
||||||
|
interface Handler extends core.Handler {}
|
||||||
|
interface IRoute extends core.IRoute {}
|
||||||
|
interface IRouter extends core.IRouter {}
|
||||||
|
interface IRouterHandler<T> extends core.IRouterHandler<T> {}
|
||||||
|
interface IRouterMatcher<T> extends core.IRouterMatcher<T> {}
|
||||||
|
interface MediaType extends core.MediaType {}
|
||||||
|
interface NextFunction extends core.NextFunction {}
|
||||||
|
interface Locals extends core.Locals {}
|
||||||
|
interface Request<
|
||||||
|
P = core.ParamsDictionary,
|
||||||
|
ResBody = any,
|
||||||
|
ReqBody = any,
|
||||||
|
ReqQuery = core.Query,
|
||||||
|
Locals extends Record<string, any> = Record<string, any>,
|
||||||
|
> extends core.Request<P, ResBody, ReqBody, ReqQuery, Locals> {}
|
||||||
|
interface RequestHandler<
|
||||||
|
P = core.ParamsDictionary,
|
||||||
|
ResBody = any,
|
||||||
|
ReqBody = any,
|
||||||
|
ReqQuery = core.Query,
|
||||||
|
Locals extends Record<string, any> = Record<string, any>,
|
||||||
|
> extends core.RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> {}
|
||||||
|
interface RequestParamHandler extends core.RequestParamHandler {}
|
||||||
|
interface Response<
|
||||||
|
ResBody = any,
|
||||||
|
Locals extends Record<string, any> = Record<string, any>,
|
||||||
|
> extends core.Response<ResBody, Locals> {}
|
||||||
|
interface Router extends core.Router {}
|
||||||
|
interface Send extends core.Send {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export = e;
|
45
websocket_server/node_modules/.ignored/@types/express/package.json
generated
vendored
Normal file
45
websocket_server/node_modules/.ignored/@types/express/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/express",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"description": "TypeScript definitions for express",
|
||||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Boris Yankov",
|
||||||
|
"githubUsername": "borisyankov",
|
||||||
|
"url": "https://github.com/borisyankov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "China Medical University Hospital",
|
||||||
|
"githubUsername": "CMUH",
|
||||||
|
"url": "https://github.com/CMUH"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Puneet Arora",
|
||||||
|
"githubUsername": "puneetar",
|
||||||
|
"url": "https://github.com/puneetar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dylan Frankland",
|
||||||
|
"githubUsername": "dfrankland",
|
||||||
|
"url": "https://github.com/dfrankland"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/express"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/body-parser": "*",
|
||||||
|
"@types/express-serve-static-core": "^5.0.0",
|
||||||
|
"@types/qs": "*",
|
||||||
|
"@types/serve-static": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "906f793a5f72703639a36afa9b7c5b41256100f5efc93138ed2551c101aea99f",
|
||||||
|
"typeScriptVersion": "4.8"
|
||||||
|
}
|
21
websocket_server/node_modules/.ignored/@types/node/LICENSE
generated
vendored
Normal file
21
websocket_server/node_modules/.ignored/@types/node/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
15
websocket_server/node_modules/.ignored/@types/node/README.md
generated
vendored
Normal file
15
websocket_server/node_modules/.ignored/@types/node/README.md
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/node`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for node (https://nodejs.org/).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||||
|
|
||||||
|
### Additional Details
|
||||||
|
* Last updated: Tue, 22 Oct 2024 02:30:55 GMT
|
||||||
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
|
1040
websocket_server/node_modules/.ignored/@types/node/assert.d.ts
generated
vendored
Normal file
1040
websocket_server/node_modules/.ignored/@types/node/assert.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
websocket_server/node_modules/.ignored/@types/node/assert/strict.d.ts
generated
vendored
Normal file
8
websocket_server/node_modules/.ignored/@types/node/assert/strict.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
declare module "assert/strict" {
|
||||||
|
import { strict } from "node:assert";
|
||||||
|
export = strict;
|
||||||
|
}
|
||||||
|
declare module "node:assert/strict" {
|
||||||
|
import { strict } from "node:assert";
|
||||||
|
export = strict;
|
||||||
|
}
|
541
websocket_server/node_modules/.ignored/@types/node/async_hooks.d.ts
generated
vendored
Normal file
541
websocket_server/node_modules/.ignored/@types/node/async_hooks.d.ts
generated
vendored
Normal file
@ -0,0 +1,541 @@
|
|||||||
|
/**
|
||||||
|
* We strongly discourage the use of the `async_hooks` API.
|
||||||
|
* Other APIs that can cover most of its use cases include:
|
||||||
|
*
|
||||||
|
* * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v22.x/api/async_context.html#class-asynclocalstorage) tracks async context
|
||||||
|
* * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v22.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
|
||||||
|
*
|
||||||
|
* The `node:async_hooks` module provides an API to track asynchronous resources.
|
||||||
|
* It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import async_hooks from 'node:async_hooks';
|
||||||
|
* ```
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/async_hooks.js)
|
||||||
|
*/
|
||||||
|
declare module "async_hooks" {
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import { executionAsyncId } from 'node:async_hooks';
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
*
|
||||||
|
* console.log(executionAsyncId()); // 1 - bootstrap
|
||||||
|
* const path = '.';
|
||||||
|
* fs.open(path, 'r', (err, fd) => {
|
||||||
|
* console.log(executionAsyncId()); // 6 - open()
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
||||||
|
* causality (which is covered by `triggerAsyncId()`):
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const server = net.createServer((conn) => {
|
||||||
|
* // Returns the ID of the server, not of the new connection, because the
|
||||||
|
* // callback runs in the execution scope of the server's MakeCallback().
|
||||||
|
* async_hooks.executionAsyncId();
|
||||||
|
*
|
||||||
|
* }).listen(port, () => {
|
||||||
|
* // Returns the ID of a TickObject (process.nextTick()) because all
|
||||||
|
* // callbacks passed to .listen() are wrapped in a nextTick().
|
||||||
|
* async_hooks.executionAsyncId();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Promise contexts may not get precise `executionAsyncIds` by default.
|
||||||
|
* See the section on [promise execution tracking](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html#promise-execution-tracking).
|
||||||
|
* @since v8.1.0
|
||||||
|
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
||||||
|
*/
|
||||||
|
function executionAsyncId(): number;
|
||||||
|
/**
|
||||||
|
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||||
|
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||||
|
* on the object is likely to crash your application and should be avoided.
|
||||||
|
*
|
||||||
|
* Using `executionAsyncResource()` in the top-level execution context will
|
||||||
|
* return an empty object as there is no handle or request object to use,
|
||||||
|
* but having an object representing the top-level can be helpful.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { open } from 'node:fs';
|
||||||
|
* import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
||||||
|
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
||||||
|
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This can be used to implement continuation local storage without the
|
||||||
|
* use of a tracking `Map` to store the metadata:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { createServer } from 'node:http';
|
||||||
|
* import {
|
||||||
|
* executionAsyncId,
|
||||||
|
* executionAsyncResource,
|
||||||
|
* createHook,
|
||||||
|
* } from 'node:async_hooks';
|
||||||
|
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||||
|
*
|
||||||
|
* createHook({
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) {
|
||||||
|
* const cr = executionAsyncResource();
|
||||||
|
* if (cr) {
|
||||||
|
* resource[sym] = cr[sym];
|
||||||
|
* }
|
||||||
|
* },
|
||||||
|
* }).enable();
|
||||||
|
*
|
||||||
|
* const server = createServer((req, res) => {
|
||||||
|
* executionAsyncResource()[sym] = { state: req.url };
|
||||||
|
* setTimeout(function() {
|
||||||
|
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
||||||
|
* }, 100);
|
||||||
|
* }).listen(3000);
|
||||||
|
* ```
|
||||||
|
* @since v13.9.0, v12.17.0
|
||||||
|
* @return The resource representing the current execution. Useful to store data within the resource.
|
||||||
|
*/
|
||||||
|
function executionAsyncResource(): object;
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* const server = net.createServer((conn) => {
|
||||||
|
* // The resource that caused (or triggered) this callback to be called
|
||||||
|
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
||||||
|
* // is the asyncId of "conn".
|
||||||
|
* async_hooks.triggerAsyncId();
|
||||||
|
*
|
||||||
|
* }).listen(port, () => {
|
||||||
|
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
||||||
|
* // the callback itself exists because the call to the server's .listen()
|
||||||
|
* // was made. So the return value would be the ID of the server.
|
||||||
|
* async_hooks.triggerAsyncId();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||||
|
* the section on [promise execution tracking](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html#promise-execution-tracking).
|
||||||
|
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||||
|
*/
|
||||||
|
function triggerAsyncId(): number;
|
||||||
|
interface HookCallbacks {
|
||||||
|
/**
|
||||||
|
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||||
|
* @param asyncId A unique ID for the async resource
|
||||||
|
* @param type The type of the async resource
|
||||||
|
* @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
|
||||||
|
* @param resource Reference to the resource representing the async operation, needs to be released during destroy
|
||||||
|
*/
|
||||||
|
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||||
|
/**
|
||||||
|
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||||
|
* The before callback is called just before said callback is executed.
|
||||||
|
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||||
|
*/
|
||||||
|
before?(asyncId: number): void;
|
||||||
|
/**
|
||||||
|
* Called immediately after the callback specified in `before` is completed.
|
||||||
|
*
|
||||||
|
* If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
|
||||||
|
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||||
|
*/
|
||||||
|
after?(asyncId: number): void;
|
||||||
|
/**
|
||||||
|
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||||
|
* as the promise itself.
|
||||||
|
* @param asyncId the unique id for the promise that was resolve()d.
|
||||||
|
*/
|
||||||
|
promiseResolve?(asyncId: number): void;
|
||||||
|
/**
|
||||||
|
* Called after the resource corresponding to asyncId is destroyed
|
||||||
|
* @param asyncId a unique ID for the async resource
|
||||||
|
*/
|
||||||
|
destroy?(asyncId: number): void;
|
||||||
|
}
|
||||||
|
interface AsyncHook {
|
||||||
|
/**
|
||||||
|
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||||
|
*/
|
||||||
|
enable(): this;
|
||||||
|
/**
|
||||||
|
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||||
|
*/
|
||||||
|
disable(): this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Registers functions to be called for different lifetime events of each async
|
||||||
|
* operation.
|
||||||
|
*
|
||||||
|
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
||||||
|
* respective asynchronous event during a resource's lifetime.
|
||||||
|
*
|
||||||
|
* All callbacks are optional. For example, if only resource cleanup needs to
|
||||||
|
* be tracked, then only the `destroy` callback needs to be passed. The
|
||||||
|
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { createHook } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const asyncHook = createHook({
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) { },
|
||||||
|
* destroy(asyncId) { },
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The callbacks will be inherited via the prototype chain:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* class MyAsyncCallbacks {
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) { }
|
||||||
|
* destroy(asyncId) {}
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
||||||
|
* before(asyncId) { }
|
||||||
|
* after(asyncId) { }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Because promises are asynchronous resources whose lifecycle is tracked
|
||||||
|
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
||||||
|
* @since v8.1.0
|
||||||
|
* @param callbacks The `Hook Callbacks` to register
|
||||||
|
* @return Instance used for disabling and enabling hooks
|
||||||
|
*/
|
||||||
|
function createHook(callbacks: HookCallbacks): AsyncHook;
|
||||||
|
interface AsyncResourceOptions {
|
||||||
|
/**
|
||||||
|
* The ID of the execution context that created this async event.
|
||||||
|
* @default executionAsyncId()
|
||||||
|
*/
|
||||||
|
triggerAsyncId?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||||
|
* This usually does not need to be set (even if `emitDestroy` is called
|
||||||
|
* manually), unless the resource's `asyncId` is retrieved and the
|
||||||
|
* sensitive API's `emitDestroy` is called with it.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
requireManualDestroy?: boolean | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The class `AsyncResource` is designed to be extended by the embedder's async
|
||||||
|
* resources. Using this, users can easily trigger the lifetime events of their
|
||||||
|
* own resources.
|
||||||
|
*
|
||||||
|
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
||||||
|
*
|
||||||
|
* The following is an overview of the `AsyncResource` API.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { AsyncResource, executionAsyncId } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* // AsyncResource() is meant to be extended. Instantiating a
|
||||||
|
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||||
|
* // async_hook.executionAsyncId() is used.
|
||||||
|
* const asyncResource = new AsyncResource(
|
||||||
|
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* // Run a function in the execution context of the resource. This will
|
||||||
|
* // * establish the context of the resource
|
||||||
|
* // * trigger the AsyncHooks before callbacks
|
||||||
|
* // * call the provided function `fn` with the supplied arguments
|
||||||
|
* // * trigger the AsyncHooks after callbacks
|
||||||
|
* // * restore the original execution context
|
||||||
|
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
||||||
|
*
|
||||||
|
* // Call AsyncHooks destroy callbacks.
|
||||||
|
* asyncResource.emitDestroy();
|
||||||
|
*
|
||||||
|
* // Return the unique ID assigned to the AsyncResource instance.
|
||||||
|
* asyncResource.asyncId();
|
||||||
|
*
|
||||||
|
* // Return the trigger ID for the AsyncResource instance.
|
||||||
|
* asyncResource.triggerAsyncId();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
class AsyncResource {
|
||||||
|
/**
|
||||||
|
* AsyncResource() is meant to be extended. Instantiating a
|
||||||
|
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||||
|
* async_hook.executionAsyncId() is used.
|
||||||
|
* @param type The type of async event.
|
||||||
|
* @param triggerAsyncId The ID of the execution context that created
|
||||||
|
* this async event (default: `executionAsyncId()`), or an
|
||||||
|
* AsyncResourceOptions object (since v9.3.0)
|
||||||
|
*/
|
||||||
|
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||||
|
/**
|
||||||
|
* Binds the given function to the current execution context.
|
||||||
|
* @since v14.8.0, v12.19.0
|
||||||
|
* @param fn The function to bind to the current execution context.
|
||||||
|
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||||
|
*/
|
||||||
|
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||||
|
fn: Func,
|
||||||
|
type?: string,
|
||||||
|
thisArg?: ThisArg,
|
||||||
|
): Func;
|
||||||
|
/**
|
||||||
|
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||||
|
* @since v14.8.0, v12.19.0
|
||||||
|
* @param fn The function to bind to the current `AsyncResource`.
|
||||||
|
*/
|
||||||
|
bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
||||||
|
/**
|
||||||
|
* Call the provided function with the provided arguments in the execution context
|
||||||
|
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||||
|
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||||
|
* then restore the original execution context.
|
||||||
|
* @since v9.6.0
|
||||||
|
* @param fn The function to call in the execution context of this async resource.
|
||||||
|
* @param thisArg The receiver to be used for the function call.
|
||||||
|
* @param args Optional arguments to pass to the function.
|
||||||
|
*/
|
||||||
|
runInAsyncScope<This, Result>(
|
||||||
|
fn: (this: This, ...args: any[]) => Result,
|
||||||
|
thisArg?: This,
|
||||||
|
...args: any[]
|
||||||
|
): Result;
|
||||||
|
/**
|
||||||
|
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||||
|
* be thrown if it is called more than once. This **must** be manually called. If
|
||||||
|
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||||
|
* never be called.
|
||||||
|
* @return A reference to `asyncResource`.
|
||||||
|
*/
|
||||||
|
emitDestroy(): this;
|
||||||
|
/**
|
||||||
|
* @return The unique `asyncId` assigned to the resource.
|
||||||
|
*/
|
||||||
|
asyncId(): number;
|
||||||
|
/**
|
||||||
|
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
||||||
|
*/
|
||||||
|
triggerAsyncId(): number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This class creates stores that stay coherent through asynchronous operations.
|
||||||
|
*
|
||||||
|
* While you can create your own implementation on top of the `node:async_hooks` module, `AsyncLocalStorage` should be preferred as it is a performant and memory
|
||||||
|
* safe implementation that involves significant optimizations that are non-obvious
|
||||||
|
* to implement.
|
||||||
|
*
|
||||||
|
* The following example uses `AsyncLocalStorage` to build a simple logger
|
||||||
|
* that assigns IDs to incoming HTTP requests and includes them in messages
|
||||||
|
* logged within each request.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import http from 'node:http';
|
||||||
|
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* function logWithId(msg) {
|
||||||
|
* const id = asyncLocalStorage.getStore();
|
||||||
|
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* let idSeq = 0;
|
||||||
|
* http.createServer((req, res) => {
|
||||||
|
* asyncLocalStorage.run(idSeq++, () => {
|
||||||
|
* logWithId('start');
|
||||||
|
* // Imagine any chain of async operations here
|
||||||
|
* setImmediate(() => {
|
||||||
|
* logWithId('finish');
|
||||||
|
* res.end();
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* }).listen(8080);
|
||||||
|
*
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* // Prints:
|
||||||
|
* // 0: start
|
||||||
|
* // 1: start
|
||||||
|
* // 0: finish
|
||||||
|
* // 1: finish
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||||
|
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||||
|
* with each other's data.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
*/
|
||||||
|
class AsyncLocalStorage<T> {
|
||||||
|
/**
|
||||||
|
* Binds the given function to the current execution context.
|
||||||
|
* @since v19.8.0
|
||||||
|
* @experimental
|
||||||
|
* @param fn The function to bind to the current execution context.
|
||||||
|
* @return A new function that calls `fn` within the captured execution context.
|
||||||
|
*/
|
||||||
|
static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
||||||
|
/**
|
||||||
|
* Captures the current execution context and returns a function that accepts a
|
||||||
|
* function as an argument. Whenever the returned function is called, it
|
||||||
|
* calls the function passed to it within the captured context.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||||
|
* const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
|
||||||
|
* const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
|
||||||
|
* console.log(result); // returns 123
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
|
||||||
|
* async context tracking purposes, for example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* class Foo {
|
||||||
|
* #runInAsyncScope = AsyncLocalStorage.snapshot();
|
||||||
|
*
|
||||||
|
* get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const foo = asyncLocalStorage.run(123, () => new Foo());
|
||||||
|
* console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
|
||||||
|
* ```
|
||||||
|
* @since v19.8.0
|
||||||
|
* @experimental
|
||||||
|
* @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
|
||||||
|
*/
|
||||||
|
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
||||||
|
/**
|
||||||
|
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
|
* to `asyncLocalStorage.getStore()` will return `undefined` until `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||||
|
*
|
||||||
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
|
* instance will be exited.
|
||||||
|
*
|
||||||
|
* Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||||
|
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||||
|
* along with the corresponding async resources.
|
||||||
|
*
|
||||||
|
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||||
|
* in the current process.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
disable(): void;
|
||||||
|
/**
|
||||||
|
* Returns the current store.
|
||||||
|
* If called outside of an asynchronous context initialized by
|
||||||
|
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||||
|
* returns `undefined`.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
*/
|
||||||
|
getStore(): T | undefined;
|
||||||
|
/**
|
||||||
|
* Runs a function synchronously within a context and returns its
|
||||||
|
* return value. The store is not accessible outside of the callback function.
|
||||||
|
* The store is accessible to any asynchronous operations created within the
|
||||||
|
* callback.
|
||||||
|
*
|
||||||
|
* The optional `args` are passed to the callback function.
|
||||||
|
*
|
||||||
|
* If the callback function throws an error, the error is thrown by `run()` too.
|
||||||
|
* The stacktrace is not impacted by this call and the context is exited.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 2 };
|
||||||
|
* try {
|
||||||
|
* asyncLocalStorage.run(store, () => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* setTimeout(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* }, 200);
|
||||||
|
* throw new Error();
|
||||||
|
* });
|
||||||
|
* } catch (e) {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* // The error will be caught here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
*/
|
||||||
|
run<R>(store: T, callback: () => R): R;
|
||||||
|
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||||
|
/**
|
||||||
|
* Runs a function synchronously outside of a context and returns its
|
||||||
|
* return value. The store is not accessible within the callback function or
|
||||||
|
* the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
|
||||||
|
*
|
||||||
|
* The optional `args` are passed to the callback function.
|
||||||
|
*
|
||||||
|
* If the callback function throws an error, the error is thrown by `exit()` too.
|
||||||
|
* The stacktrace is not impacted by this call and the context is re-entered.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Within a call to run
|
||||||
|
* try {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object or value
|
||||||
|
* asyncLocalStorage.exit(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* throw new Error();
|
||||||
|
* });
|
||||||
|
* } catch (e) {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object or value
|
||||||
|
* // The error will be caught here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||||
|
/**
|
||||||
|
* Transitions into the context for the remainder of the current
|
||||||
|
* synchronous execution and then persists the store through any following
|
||||||
|
* asynchronous calls.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 1 };
|
||||||
|
* // Replaces previous store with the given store object
|
||||||
|
* asyncLocalStorage.enterWith(store);
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* someAsyncOperation(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This transition will continue for the _entire_ synchronous execution.
|
||||||
|
* This means that if, for example, the context is entered within an event
|
||||||
|
* handler subsequent event handlers will also run within that context unless
|
||||||
|
* specifically bound to another context with an `AsyncResource`. That is why `run()` should be preferred over `enterWith()` unless there are strong reasons
|
||||||
|
* to use the latter method.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 1 };
|
||||||
|
*
|
||||||
|
* emitter.on('my-event', () => {
|
||||||
|
* asyncLocalStorage.enterWith(store);
|
||||||
|
* });
|
||||||
|
* emitter.on('my-event', () => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* emitter.emit('my-event');
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* ```
|
||||||
|
* @since v13.11.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
enterWith(store: T): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:async_hooks" {
|
||||||
|
export * from "async_hooks";
|
||||||
|
}
|
385
websocket_server/node_modules/.ignored/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
385
websocket_server/node_modules/.ignored/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
declare module "buffer" {
|
||||||
|
global {
|
||||||
|
interface BufferConstructor {
|
||||||
|
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {str}.
|
||||||
|
*
|
||||||
|
* @param str String to store in buffer.
|
||||||
|
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||||
|
*/
|
||||||
|
new(str: string, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer of {size} octets.
|
||||||
|
*
|
||||||
|
* @param size count of octets to allocate.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||||
|
*/
|
||||||
|
new(size: number): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {array} of octets.
|
||||||
|
*
|
||||||
|
* @param array The octets to store.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||||
|
*/
|
||||||
|
new(array: Uint8Array): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Produces a Buffer backed by the same allocated memory as
|
||||||
|
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||||
|
*
|
||||||
|
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||||
|
*/
|
||||||
|
new<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(arrayBuffer: TArrayBuffer): Buffer<TArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {array} of octets.
|
||||||
|
*
|
||||||
|
* @param array The octets to store.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||||
|
*/
|
||||||
|
new(array: readonly any[]): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||||
|
*
|
||||||
|
* @param buffer The buffer to copy.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
||||||
|
*/
|
||||||
|
new(buffer: Buffer): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
||||||
|
* Array entries outside that range will be truncated to fit into it.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
||||||
|
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `array` is an `Array`\-like object (that is, one with a `length` property of
|
||||||
|
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
||||||
|
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
||||||
|
* appropriate for `Buffer.from()` variants.
|
||||||
|
*
|
||||||
|
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||||
|
* @since v5.10.0
|
||||||
|
*/
|
||||||
|
from<TArrayBuffer extends ArrayBufferLike>(
|
||||||
|
arrayBuffer: WithImplicitCoercion<TArrayBuffer>,
|
||||||
|
byteOffset?: number,
|
||||||
|
length?: number,
|
||||||
|
): Buffer<TArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer using the passed {data}
|
||||||
|
* @param data data to create a new Buffer
|
||||||
|
*/
|
||||||
|
from(data: Uint8Array | readonly number[]): Buffer<ArrayBuffer>;
|
||||||
|
from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||||
|
* If provided, the {encoding} parameter identifies the character encoding.
|
||||||
|
* If not provided, {encoding} defaults to 'utf8'.
|
||||||
|
*/
|
||||||
|
from(
|
||||||
|
str:
|
||||||
|
| WithImplicitCoercion<string>
|
||||||
|
| {
|
||||||
|
[Symbol.toPrimitive](hint: "string"): string;
|
||||||
|
},
|
||||||
|
encoding?: BufferEncoding,
|
||||||
|
): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer using the passed {data}
|
||||||
|
* @param values to create a new Buffer
|
||||||
|
*/
|
||||||
|
of(...items: number[]): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
||||||
|
*
|
||||||
|
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
||||||
|
*
|
||||||
|
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
||||||
|
* in `list` by adding their lengths.
|
||||||
|
*
|
||||||
|
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
||||||
|
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
||||||
|
* truncated to `totalLength`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
||||||
|
*
|
||||||
|
* const buf1 = Buffer.alloc(10);
|
||||||
|
* const buf2 = Buffer.alloc(14);
|
||||||
|
* const buf3 = Buffer.alloc(18);
|
||||||
|
* const totalLength = buf1.length + buf2.length + buf3.length;
|
||||||
|
*
|
||||||
|
* console.log(totalLength);
|
||||||
|
* // Prints: 42
|
||||||
|
*
|
||||||
|
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
||||||
|
*
|
||||||
|
* console.log(bufA);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 ...>
|
||||||
|
* console.log(bufA.length);
|
||||||
|
* // Prints: 42
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||||
|
* @since v0.7.11
|
||||||
|
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
||||||
|
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
||||||
|
*/
|
||||||
|
concat(list: readonly Uint8Array[], totalLength?: number): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Copies the underlying memory of `view` into a new `Buffer`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const u16 = new Uint16Array([0, 0xffff]);
|
||||||
|
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
||||||
|
* u16[1] = 0;
|
||||||
|
* console.log(buf.length); // 2
|
||||||
|
* console.log(buf[0]); // 255
|
||||||
|
* console.log(buf[1]); // 255
|
||||||
|
* ```
|
||||||
|
* @since v19.8.0
|
||||||
|
* @param view The {TypedArray} to copy.
|
||||||
|
* @param [offset=0] The starting offset within `view`.
|
||||||
|
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
||||||
|
*/
|
||||||
|
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(5);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 00>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||||
|
*
|
||||||
|
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(5, 'a');
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 61 61 61 61 61>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||||
|
* initialized by calling `buf.fill(fill, encoding)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
||||||
|
* contents will never contain sensitive data from previous allocations, including
|
||||||
|
* data that might not have been allocated for `Buffer`s.
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
* @since v5.10.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
||||||
|
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
||||||
|
*/
|
||||||
|
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||||
|
*
|
||||||
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||||
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.allocUnsafe(10);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
||||||
|
*
|
||||||
|
* buf.fill(0);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
*
|
||||||
|
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||||
|
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
||||||
|
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
||||||
|
*
|
||||||
|
* Use of this pre-allocated internal memory pool is a key difference between
|
||||||
|
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||||
|
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
||||||
|
* than or equal to half `Buffer.poolSize`. The
|
||||||
|
* difference is subtle but can be important when an application requires the
|
||||||
|
* additional performance that `Buffer.allocUnsafe()` provides.
|
||||||
|
* @since v5.10.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
*/
|
||||||
|
allocUnsafe(size: number): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
||||||
|
* `size` is 0.
|
||||||
|
*
|
||||||
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||||
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
||||||
|
* such `Buffer` instances with zeroes.
|
||||||
|
*
|
||||||
|
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||||
|
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
||||||
|
* allows applications to avoid the garbage collection overhead of creating many
|
||||||
|
* individually allocated `Buffer` instances. This approach improves both
|
||||||
|
* performance and memory usage by eliminating the need to track and clean up as
|
||||||
|
* many individual `ArrayBuffer` objects.
|
||||||
|
*
|
||||||
|
* However, in the case where a developer may need to retain a small chunk of
|
||||||
|
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||||
|
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
||||||
|
* then copying out the relevant bits.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Need to keep around a few small chunks of memory.
|
||||||
|
* const store = [];
|
||||||
|
*
|
||||||
|
* socket.on('readable', () => {
|
||||||
|
* let data;
|
||||||
|
* while (null !== (data = readable.read())) {
|
||||||
|
* // Allocate for retained data.
|
||||||
|
* const sb = Buffer.allocUnsafeSlow(10);
|
||||||
|
*
|
||||||
|
* // Copy the data into the new allocation.
|
||||||
|
* data.copy(sb, 0, 0, 10);
|
||||||
|
*
|
||||||
|
* store.push(sb);
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
* @since v5.12.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
*/
|
||||||
|
allocUnsafeSlow(size: number): Buffer<ArrayBuffer>;
|
||||||
|
}
|
||||||
|
interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
|
||||||
|
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` that references the same memory as the original, but
|
||||||
|
* offset and cropped by the `start` and `end` indices.
|
||||||
|
*
|
||||||
|
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||||
|
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.from('buffer');
|
||||||
|
*
|
||||||
|
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
||||||
|
* copiedBuf[0]++;
|
||||||
|
* console.log(copiedBuf.toString());
|
||||||
|
* // Prints: cuffer
|
||||||
|
*
|
||||||
|
* console.log(buf.toString());
|
||||||
|
* // Prints: buffer
|
||||||
|
*
|
||||||
|
* // With buf.slice(), the original buffer is modified.
|
||||||
|
* const notReallyCopiedBuf = buf.slice();
|
||||||
|
* notReallyCopiedBuf[0]++;
|
||||||
|
* console.log(notReallyCopiedBuf.toString());
|
||||||
|
* // Prints: cuffer
|
||||||
|
* console.log(buf.toString());
|
||||||
|
* // Also prints: cuffer (!)
|
||||||
|
* ```
|
||||||
|
* @since v0.3.0
|
||||||
|
* @deprecated Use `subarray` instead.
|
||||||
|
* @param [start=0] Where the new `Buffer` will start.
|
||||||
|
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||||
|
*/
|
||||||
|
slice(start?: number, end?: number): Buffer<ArrayBuffer>;
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` that references the same memory as the original, but
|
||||||
|
* offset and cropped by the `start` and `end` indices.
|
||||||
|
*
|
||||||
|
* Specifying `end` greater than `buf.length` will return the same result as
|
||||||
|
* that of `end` equal to `buf.length`.
|
||||||
|
*
|
||||||
|
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
||||||
|
*
|
||||||
|
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
||||||
|
* // from the original `Buffer`.
|
||||||
|
*
|
||||||
|
* const buf1 = Buffer.allocUnsafe(26);
|
||||||
|
*
|
||||||
|
* for (let i = 0; i < 26; i++) {
|
||||||
|
* // 97 is the decimal ASCII value for 'a'.
|
||||||
|
* buf1[i] = i + 97;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const buf2 = buf1.subarray(0, 3);
|
||||||
|
*
|
||||||
|
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||||
|
* // Prints: abc
|
||||||
|
*
|
||||||
|
* buf1[0] = 33;
|
||||||
|
*
|
||||||
|
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||||
|
* // Prints: !bc
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Specifying negative indexes causes the slice to be generated relative to the
|
||||||
|
* end of `buf` rather than the beginning.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.from('buffer');
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-6, -1).toString());
|
||||||
|
* // Prints: buffe
|
||||||
|
* // (Equivalent to buf.subarray(0, 5).)
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-6, -2).toString());
|
||||||
|
* // Prints: buff
|
||||||
|
* // (Equivalent to buf.subarray(0, 4).)
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-5, -2).toString());
|
||||||
|
* // Prints: uff
|
||||||
|
* // (Equivalent to buf.subarray(1, 4).)
|
||||||
|
* ```
|
||||||
|
* @since v3.0.0
|
||||||
|
* @param [start=0] Where the new `Buffer` will start.
|
||||||
|
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||||
|
*/
|
||||||
|
subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1933
websocket_server/node_modules/.ignored/@types/node/buffer.d.ts
generated
vendored
Normal file
1933
websocket_server/node_modules/.ignored/@types/node/buffer.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1549
websocket_server/node_modules/.ignored/@types/node/child_process.d.ts
generated
vendored
Normal file
1549
websocket_server/node_modules/.ignored/@types/node/child_process.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
579
websocket_server/node_modules/.ignored/@types/node/cluster.d.ts
generated
vendored
Normal file
579
websocket_server/node_modules/.ignored/@types/node/cluster.d.ts
generated
vendored
Normal file
@ -0,0 +1,579 @@
|
|||||||
|
/**
|
||||||
|
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
||||||
|
* that can distribute workloads among their application threads. When process isolation
|
||||||
|
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html)
|
||||||
|
* module instead, which allows running multiple application threads within a single Node.js instance.
|
||||||
|
*
|
||||||
|
* The cluster module allows easy creation of child processes that all share
|
||||||
|
* server ports.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
* import http from 'node:http';
|
||||||
|
* import { availableParallelism } from 'node:os';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const numCPUs = availableParallelism();
|
||||||
|
*
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* console.log(`Primary ${process.pid} is running`);
|
||||||
|
*
|
||||||
|
* // Fork workers.
|
||||||
|
* for (let i = 0; i < numCPUs; i++) {
|
||||||
|
* cluster.fork();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* cluster.on('exit', (worker, code, signal) => {
|
||||||
|
* console.log(`worker ${worker.process.pid} died`);
|
||||||
|
* });
|
||||||
|
* } else {
|
||||||
|
* // Workers can share any TCP connection
|
||||||
|
* // In this case it is an HTTP server
|
||||||
|
* http.createServer((req, res) => {
|
||||||
|
* res.writeHead(200);
|
||||||
|
* res.end('hello world\n');
|
||||||
|
* }).listen(8000);
|
||||||
|
*
|
||||||
|
* console.log(`Worker ${process.pid} started`);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Running Node.js will now share port 8000 between the workers:
|
||||||
|
*
|
||||||
|
* ```console
|
||||||
|
* $ node server.js
|
||||||
|
* Primary 3596 is running
|
||||||
|
* Worker 4324 started
|
||||||
|
* Worker 4520 started
|
||||||
|
* Worker 6056 started
|
||||||
|
* Worker 5644 started
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/cluster.js)
|
||||||
|
*/
|
||||||
|
declare module "cluster" {
|
||||||
|
import * as child from "node:child_process";
|
||||||
|
import EventEmitter = require("node:events");
|
||||||
|
import * as net from "node:net";
|
||||||
|
type SerializationType = "json" | "advanced";
|
||||||
|
export interface ClusterSettings {
|
||||||
|
/**
|
||||||
|
* List of string arguments passed to the Node.js executable.
|
||||||
|
* @default process.execArgv
|
||||||
|
*/
|
||||||
|
execArgv?: string[] | undefined;
|
||||||
|
/**
|
||||||
|
* File path to worker file.
|
||||||
|
* @default process.argv[1]
|
||||||
|
*/
|
||||||
|
exec?: string | undefined;
|
||||||
|
/**
|
||||||
|
* String arguments passed to worker.
|
||||||
|
* @default process.argv.slice(2)
|
||||||
|
*/
|
||||||
|
args?: string[] | undefined;
|
||||||
|
/**
|
||||||
|
* Whether or not to send output to parent's stdio.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
silent?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
||||||
|
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v22.x/api/child_process.html#child_processspawncommand-args-options)'s
|
||||||
|
* [`stdio`](https://nodejs.org/docs/latest-v22.x/api/child_process.html#optionsstdio).
|
||||||
|
*/
|
||||||
|
stdio?: any[] | undefined;
|
||||||
|
/**
|
||||||
|
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
||||||
|
*/
|
||||||
|
uid?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
||||||
|
*/
|
||||||
|
gid?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
||||||
|
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
||||||
|
*/
|
||||||
|
inspectPort?: number | (() => number) | undefined;
|
||||||
|
/**
|
||||||
|
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
||||||
|
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v22.x/api/child_process.html#advanced-serialization) for more details.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
serialization?: SerializationType | undefined;
|
||||||
|
/**
|
||||||
|
* Current working directory of the worker process.
|
||||||
|
* @default undefined (inherits from parent process)
|
||||||
|
*/
|
||||||
|
cwd?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Hide the forked processes console window that would normally be created on Windows systems.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
windowsHide?: boolean | undefined;
|
||||||
|
}
|
||||||
|
export interface Address {
|
||||||
|
address: string;
|
||||||
|
port: number;
|
||||||
|
/**
|
||||||
|
* The `addressType` is one of:
|
||||||
|
*
|
||||||
|
* * `4` (TCPv4)
|
||||||
|
* * `6` (TCPv6)
|
||||||
|
* * `-1` (Unix domain socket)
|
||||||
|
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
||||||
|
*/
|
||||||
|
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A `Worker` object contains all public information and method about a worker.
|
||||||
|
* In the primary it can be obtained using `cluster.workers`. In a worker
|
||||||
|
* it can be obtained using `cluster.worker`.
|
||||||
|
* @since v0.7.0
|
||||||
|
*/
|
||||||
|
export class Worker extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* Each new worker is given its own unique id, this id is stored in the `id`.
|
||||||
|
*
|
||||||
|
* While a worker is alive, this is the key that indexes it in `cluster.workers`.
|
||||||
|
* @since v0.8.0
|
||||||
|
*/
|
||||||
|
id: number;
|
||||||
|
/**
|
||||||
|
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v22.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
|
||||||
|
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
||||||
|
*
|
||||||
|
* See: [Child Process module](https://nodejs.org/docs/latest-v22.x/api/child_process.html#child_processforkmodulepath-args-options).
|
||||||
|
*
|
||||||
|
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||||
|
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||||
|
* accidental disconnection.
|
||||||
|
* @since v0.7.0
|
||||||
|
*/
|
||||||
|
process: child.ChildProcess;
|
||||||
|
/**
|
||||||
|
* Send a message to a worker or primary, optionally with a handle.
|
||||||
|
*
|
||||||
|
* In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v22.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
|
||||||
|
*
|
||||||
|
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
|
||||||
|
*
|
||||||
|
* This example will echo back all messages from the primary:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* const worker = cluster.fork();
|
||||||
|
* worker.send('hi there');
|
||||||
|
*
|
||||||
|
* } else if (cluster.isWorker) {
|
||||||
|
* process.on('message', (msg) => {
|
||||||
|
* process.send(msg);
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.7.0
|
||||||
|
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
||||||
|
*/
|
||||||
|
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
||||||
|
send(
|
||||||
|
message: child.Serializable,
|
||||||
|
sendHandle: child.SendHandle,
|
||||||
|
callback?: (error: Error | null) => void,
|
||||||
|
): boolean;
|
||||||
|
send(
|
||||||
|
message: child.Serializable,
|
||||||
|
sendHandle: child.SendHandle,
|
||||||
|
options?: child.MessageOptions,
|
||||||
|
callback?: (error: Error | null) => void,
|
||||||
|
): boolean;
|
||||||
|
/**
|
||||||
|
* This function will kill the worker. In the primary worker, it does this by
|
||||||
|
* disconnecting the `worker.process`, and once disconnected, killing with `signal`. In the worker, it does it by killing the process with `signal`.
|
||||||
|
*
|
||||||
|
* The `kill()` function kills the worker process without waiting for a graceful
|
||||||
|
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||||
|
*
|
||||||
|
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
||||||
|
*
|
||||||
|
* In a worker, `process.kill()` exists, but it is not this function;
|
||||||
|
* it is [`kill()`](https://nodejs.org/docs/latest-v22.x/api/process.html#processkillpid-signal).
|
||||||
|
* @since v0.9.12
|
||||||
|
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
||||||
|
*/
|
||||||
|
kill(signal?: string): void;
|
||||||
|
destroy(signal?: string): void;
|
||||||
|
/**
|
||||||
|
* In a worker, this function will close all servers, wait for the `'close'` event
|
||||||
|
* on those servers, and then disconnect the IPC channel.
|
||||||
|
*
|
||||||
|
* In the primary, an internal message is sent to the worker causing it to call `.disconnect()` on itself.
|
||||||
|
*
|
||||||
|
* Causes `.exitedAfterDisconnect` to be set.
|
||||||
|
*
|
||||||
|
* After a server is closed, it will no longer accept new connections,
|
||||||
|
* but connections may be accepted by any other listening worker. Existing
|
||||||
|
* connections will be allowed to close as usual. When no more connections exist,
|
||||||
|
* see `server.close()`, the IPC channel to the worker will close allowing it
|
||||||
|
* to die gracefully.
|
||||||
|
*
|
||||||
|
* The above applies _only_ to server connections, client connections are not
|
||||||
|
* automatically closed by workers, and disconnect does not wait for them to close
|
||||||
|
* before exiting.
|
||||||
|
*
|
||||||
|
* In a worker, `process.disconnect` exists, but it is not this function;
|
||||||
|
* it is `disconnect()`.
|
||||||
|
*
|
||||||
|
* Because long living server connections may block workers from disconnecting, it
|
||||||
|
* may be useful to send a message, so application specific actions may be taken to
|
||||||
|
* close them. It also may be useful to implement a timeout, killing a worker if
|
||||||
|
* the `'disconnect'` event has not been emitted after some time.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import net from 'node:net';
|
||||||
|
*
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* const worker = cluster.fork();
|
||||||
|
* let timeout;
|
||||||
|
*
|
||||||
|
* worker.on('listening', (address) => {
|
||||||
|
* worker.send('shutdown');
|
||||||
|
* worker.disconnect();
|
||||||
|
* timeout = setTimeout(() => {
|
||||||
|
* worker.kill();
|
||||||
|
* }, 2000);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* worker.on('disconnect', () => {
|
||||||
|
* clearTimeout(timeout);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* } else if (cluster.isWorker) {
|
||||||
|
* const server = net.createServer((socket) => {
|
||||||
|
* // Connections never end
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.listen(8000);
|
||||||
|
*
|
||||||
|
* process.on('message', (msg) => {
|
||||||
|
* if (msg === 'shutdown') {
|
||||||
|
* // Initiate graceful close of any connections to server
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.7.7
|
||||||
|
* @return A reference to `worker`.
|
||||||
|
*/
|
||||||
|
disconnect(): void;
|
||||||
|
/**
|
||||||
|
* This function returns `true` if the worker is connected to its primary via its
|
||||||
|
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
||||||
|
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
||||||
|
* @since v0.11.14
|
||||||
|
*/
|
||||||
|
isConnected(): boolean;
|
||||||
|
/**
|
||||||
|
* This function returns `true` if the worker's process has terminated (either
|
||||||
|
* because of exiting or being signaled). Otherwise, it returns `false`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
* import http from 'node:http';
|
||||||
|
* import { availableParallelism } from 'node:os';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const numCPUs = availableParallelism();
|
||||||
|
*
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* console.log(`Primary ${process.pid} is running`);
|
||||||
|
*
|
||||||
|
* // Fork workers.
|
||||||
|
* for (let i = 0; i < numCPUs; i++) {
|
||||||
|
* cluster.fork();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* cluster.on('fork', (worker) => {
|
||||||
|
* console.log('worker is dead:', worker.isDead());
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* cluster.on('exit', (worker, code, signal) => {
|
||||||
|
* console.log('worker is dead:', worker.isDead());
|
||||||
|
* });
|
||||||
|
* } else {
|
||||||
|
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
||||||
|
* http.createServer((req, res) => {
|
||||||
|
* res.writeHead(200);
|
||||||
|
* res.end(`Current process\n ${process.pid}`);
|
||||||
|
* process.kill(process.pid);
|
||||||
|
* }).listen(8000);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.11.14
|
||||||
|
*/
|
||||||
|
isDead(): boolean;
|
||||||
|
/**
|
||||||
|
* This property is `true` if the worker exited due to `.disconnect()`.
|
||||||
|
* If the worker exited any other way, it is `false`. If the
|
||||||
|
* worker has not exited, it is `undefined`.
|
||||||
|
*
|
||||||
|
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
||||||
|
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
||||||
|
* based on this value.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* cluster.on('exit', (worker, code, signal) => {
|
||||||
|
* if (worker.exitedAfterDisconnect === true) {
|
||||||
|
* console.log('Oh, it was just voluntary – no need to worry');
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // kill worker
|
||||||
|
* worker.kill();
|
||||||
|
* ```
|
||||||
|
* @since v6.0.0
|
||||||
|
*/
|
||||||
|
exitedAfterDisconnect: boolean;
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. disconnect
|
||||||
|
* 2. error
|
||||||
|
* 3. exit
|
||||||
|
* 4. listening
|
||||||
|
* 5. message
|
||||||
|
* 6. online
|
||||||
|
*/
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "disconnect", listener: () => void): this;
|
||||||
|
addListener(event: "error", listener: (error: Error) => void): this;
|
||||||
|
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
|
addListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
|
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
addListener(event: "online", listener: () => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "disconnect"): boolean;
|
||||||
|
emit(event: "error", error: Error): boolean;
|
||||||
|
emit(event: "exit", code: number, signal: string): boolean;
|
||||||
|
emit(event: "listening", address: Address): boolean;
|
||||||
|
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
||||||
|
emit(event: "online"): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "disconnect", listener: () => void): this;
|
||||||
|
on(event: "error", listener: (error: Error) => void): this;
|
||||||
|
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
|
on(event: "listening", listener: (address: Address) => void): this;
|
||||||
|
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
on(event: "online", listener: () => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "disconnect", listener: () => void): this;
|
||||||
|
once(event: "error", listener: (error: Error) => void): this;
|
||||||
|
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
|
once(event: "listening", listener: (address: Address) => void): this;
|
||||||
|
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
once(event: "online", listener: () => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "disconnect", listener: () => void): this;
|
||||||
|
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||||
|
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
|
prependListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
|
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
prependListener(event: "online", listener: () => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "disconnect", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||||
|
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
|
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
|
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
prependOnceListener(event: "online", listener: () => void): this;
|
||||||
|
}
|
||||||
|
export interface Cluster extends EventEmitter {
|
||||||
|
disconnect(callback?: () => void): void;
|
||||||
|
/**
|
||||||
|
* Spawn a new worker process.
|
||||||
|
*
|
||||||
|
* This can only be called from the primary process.
|
||||||
|
* @param env Key/value pairs to add to worker process environment.
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
fork(env?: any): Worker;
|
||||||
|
/** @deprecated since v16.0.0 - use isPrimary. */
|
||||||
|
readonly isMaster: boolean;
|
||||||
|
/**
|
||||||
|
* True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
|
||||||
|
* is undefined, then `isPrimary` is `true`.
|
||||||
|
* @since v16.0.0
|
||||||
|
*/
|
||||||
|
readonly isPrimary: boolean;
|
||||||
|
/**
|
||||||
|
* True if the process is not a primary (it is the negation of `cluster.isPrimary`).
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
readonly isWorker: boolean;
|
||||||
|
/**
|
||||||
|
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
|
||||||
|
* global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clustersetupprimarysettings)
|
||||||
|
* is called, whichever comes first.
|
||||||
|
*
|
||||||
|
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
|
||||||
|
* IOCP handles without incurring a large performance hit.
|
||||||
|
*
|
||||||
|
* `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
|
||||||
|
* @since v0.11.2
|
||||||
|
*/
|
||||||
|
schedulingPolicy: number;
|
||||||
|
/**
|
||||||
|
* After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clustersetupprimarysettings)
|
||||||
|
* (or [`.fork()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clusterforkenv)) this settings object will contain
|
||||||
|
* the settings, including the default values.
|
||||||
|
*
|
||||||
|
* This object is not intended to be changed or set manually.
|
||||||
|
* @since v0.7.1
|
||||||
|
*/
|
||||||
|
readonly settings: ClusterSettings;
|
||||||
|
/** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clustersetupprimarysettings) instead. */
|
||||||
|
setupMaster(settings?: ClusterSettings): void;
|
||||||
|
/**
|
||||||
|
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
|
||||||
|
*
|
||||||
|
* Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clusterforkenv)
|
||||||
|
* and have no effect on workers that are already running.
|
||||||
|
*
|
||||||
|
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
|
||||||
|
* [`.fork()`](https://nodejs.org/docs/latest-v22.x/api/cluster.html#clusterforkenv).
|
||||||
|
*
|
||||||
|
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
|
||||||
|
* `cluster.setupPrimary()` is called.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
*
|
||||||
|
* cluster.setupPrimary({
|
||||||
|
* exec: 'worker.js',
|
||||||
|
* args: ['--use', 'https'],
|
||||||
|
* silent: true,
|
||||||
|
* });
|
||||||
|
* cluster.fork(); // https worker
|
||||||
|
* cluster.setupPrimary({
|
||||||
|
* exec: 'worker.js',
|
||||||
|
* args: ['--use', 'http'],
|
||||||
|
* });
|
||||||
|
* cluster.fork(); // http worker
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This can only be called from the primary process.
|
||||||
|
* @since v16.0.0
|
||||||
|
*/
|
||||||
|
setupPrimary(settings?: ClusterSettings): void;
|
||||||
|
/**
|
||||||
|
* A reference to the current worker object. Not available in the primary process.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
*
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* console.log('I am primary');
|
||||||
|
* cluster.fork();
|
||||||
|
* cluster.fork();
|
||||||
|
* } else if (cluster.isWorker) {
|
||||||
|
* console.log(`I am worker #${cluster.worker.id}`);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.7.0
|
||||||
|
*/
|
||||||
|
readonly worker?: Worker | undefined;
|
||||||
|
/**
|
||||||
|
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
|
||||||
|
*
|
||||||
|
* A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it
|
||||||
|
* is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
*
|
||||||
|
* for (const worker of Object.values(cluster.workers)) {
|
||||||
|
* worker.send('big announcement to all workers');
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.7.0
|
||||||
|
*/
|
||||||
|
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
||||||
|
readonly SCHED_NONE: number;
|
||||||
|
readonly SCHED_RR: number;
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. disconnect
|
||||||
|
* 2. exit
|
||||||
|
* 3. fork
|
||||||
|
* 4. listening
|
||||||
|
* 5. message
|
||||||
|
* 6. online
|
||||||
|
* 7. setup
|
||||||
|
*/
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
|
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
|
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
|
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
|
addListener(
|
||||||
|
event: "message",
|
||||||
|
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
||||||
|
): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
addListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
|
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "disconnect", worker: Worker): boolean;
|
||||||
|
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||||
|
emit(event: "fork", worker: Worker): boolean;
|
||||||
|
emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||||
|
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||||
|
emit(event: "online", worker: Worker): boolean;
|
||||||
|
emit(event: "setup", settings: ClusterSettings): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
|
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
|
on(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
|
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
|
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
on(event: "online", listener: (worker: Worker) => void): this;
|
||||||
|
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
|
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
|
once(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
|
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
|
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
once(event: "online", listener: (worker: Worker) => void): this;
|
||||||
|
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
|
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
|
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
|
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
prependListener(
|
||||||
|
event: "message",
|
||||||
|
listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void,
|
||||||
|
): this;
|
||||||
|
prependListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
|
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
|
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
|
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
|
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
prependOnceListener(
|
||||||
|
event: "message",
|
||||||
|
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
|
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
}
|
||||||
|
const cluster: Cluster;
|
||||||
|
export default cluster;
|
||||||
|
}
|
||||||
|
declare module "node:cluster" {
|
||||||
|
export * from "cluster";
|
||||||
|
export { default as default } from "cluster";
|
||||||
|
}
|
16
websocket_server/node_modules/.ignored/@types/node/compatibility/disposable.d.ts
generated
vendored
Normal file
16
websocket_server/node_modules/.ignored/@types/node/compatibility/disposable.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Polyfills for the explicit resource management types added in TypeScript 5.2.
|
||||||
|
// TODO: remove once this package no longer supports TS 5.1, and replace with a
|
||||||
|
// <reference> to TypeScript's disposable library in index.d.ts.
|
||||||
|
|
||||||
|
interface SymbolConstructor {
|
||||||
|
readonly dispose: unique symbol;
|
||||||
|
readonly asyncDispose: unique symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Disposable {
|
||||||
|
[Symbol.dispose](): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AsyncDisposable {
|
||||||
|
[Symbol.asyncDispose](): PromiseLike<void>;
|
||||||
|
}
|
9
websocket_server/node_modules/.ignored/@types/node/compatibility/index.d.ts
generated
vendored
Normal file
9
websocket_server/node_modules/.ignored/@types/node/compatibility/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Declaration files in this directory contain types relating to TypeScript library features
|
||||||
|
// that are not included in all TypeScript versions supported by DefinitelyTyped, but
|
||||||
|
// which can be made backwards-compatible without needing `typesVersions`.
|
||||||
|
// If adding declarations to this directory, please specify which versions of TypeScript require them,
|
||||||
|
// so that they can be removed when no longer needed.
|
||||||
|
|
||||||
|
/// <reference path="disposable.d.ts" />
|
||||||
|
/// <reference path="indexable.d.ts" />
|
||||||
|
/// <reference path="iterators.d.ts" />
|
23
websocket_server/node_modules/.ignored/@types/node/compatibility/indexable.d.ts
generated
vendored
Normal file
23
websocket_server/node_modules/.ignored/@types/node/compatibility/indexable.d.ts
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Polyfill for ES2022's .at() method on string/array prototypes, added to TypeScript in 4.6.
|
||||||
|
// TODO: these methods are not used within @types/node, and should be removed at the next
|
||||||
|
// major @types/node version; users should include the es2022 TypeScript libraries
|
||||||
|
// if they need these features.
|
||||||
|
|
||||||
|
interface RelativeIndexable<T> {
|
||||||
|
at(index: number): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface String extends RelativeIndexable<string> {}
|
||||||
|
interface Array<T> extends RelativeIndexable<T> {}
|
||||||
|
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
||||||
|
interface Int8Array extends RelativeIndexable<number> {}
|
||||||
|
interface Uint8Array extends RelativeIndexable<number> {}
|
||||||
|
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
||||||
|
interface Int16Array extends RelativeIndexable<number> {}
|
||||||
|
interface Uint16Array extends RelativeIndexable<number> {}
|
||||||
|
interface Int32Array extends RelativeIndexable<number> {}
|
||||||
|
interface Uint32Array extends RelativeIndexable<number> {}
|
||||||
|
interface Float32Array extends RelativeIndexable<number> {}
|
||||||
|
interface Float64Array extends RelativeIndexable<number> {}
|
||||||
|
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
||||||
|
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
21
websocket_server/node_modules/.ignored/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
21
websocket_server/node_modules/.ignored/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Backwards-compatible iterator interfaces, augmented with iterator helper methods by lib.esnext.iterator in TypeScript 5.6.
|
||||||
|
// The IterableIterator interface does not contain these methods, which creates assignability issues in places where IteratorObjects
|
||||||
|
// are expected (eg. DOM-compatible APIs) if lib.esnext.iterator is loaded.
|
||||||
|
// Also ensures that iterators returned by the Node API, which inherit from Iterator.prototype, correctly expose the iterator helper methods
|
||||||
|
// if lib.esnext.iterator is loaded.
|
||||||
|
// TODO: remove once this package no longer supports TS 5.5, and replace NodeJS.BuiltinIteratorReturn with BuiltinIteratorReturn.
|
||||||
|
|
||||||
|
// Placeholders for TS <5.6
|
||||||
|
interface IteratorObject<T, TReturn, TNext> {}
|
||||||
|
interface AsyncIteratorObject<T, TReturn, TNext> {}
|
||||||
|
|
||||||
|
declare namespace NodeJS {
|
||||||
|
// Populate iterator methods for TS <5.6
|
||||||
|
interface Iterator<T, TReturn, TNext> extends globalThis.Iterator<T, TReturn, TNext> {}
|
||||||
|
interface AsyncIterator<T, TReturn, TNext> extends globalThis.AsyncIterator<T, TReturn, TNext> {}
|
||||||
|
|
||||||
|
// Polyfill for TS 5.6's instrinsic BuiltinIteratorReturn type, required for DOM-compatible iterators
|
||||||
|
type BuiltinIteratorReturn = ReturnType<any[][typeof Symbol.iterator]> extends
|
||||||
|
globalThis.Iterator<any, infer TReturn> ? TReturn
|
||||||
|
: any;
|
||||||
|
}
|
452
websocket_server/node_modules/.ignored/@types/node/console.d.ts
generated
vendored
Normal file
452
websocket_server/node_modules/.ignored/@types/node/console.d.ts
generated
vendored
Normal file
@ -0,0 +1,452 @@
|
|||||||
|
/**
|
||||||
|
* The `node:console` module provides a simple debugging console that is similar to
|
||||||
|
* the JavaScript console mechanism provided by web browsers.
|
||||||
|
*
|
||||||
|
* The module exports two specific components:
|
||||||
|
*
|
||||||
|
* * A `Console` class with methods such as `console.log()`, `console.error()`, and `console.warn()` that can be used to write to any Node.js stream.
|
||||||
|
* * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
|
||||||
|
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
|
||||||
|
*
|
||||||
|
* _**Warning**_: The global console object's methods are neither consistently
|
||||||
|
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||||
|
* asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* Example using the global `console`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.log('hello world');
|
||||||
|
* // Prints: hello world, to stdout
|
||||||
|
* console.log('hello %s', 'world');
|
||||||
|
* // Prints: hello world, to stdout
|
||||||
|
* console.error(new Error('Whoops, something bad happened'));
|
||||||
|
* // Prints error message and stack trace to stderr:
|
||||||
|
* // Error: Whoops, something bad happened
|
||||||
|
* // at [eval]:5:15
|
||||||
|
* // at Script.runInThisContext (node:vm:132:18)
|
||||||
|
* // at Object.runInThisContext (node:vm:309:38)
|
||||||
|
* // at node:internal/process/execution:77:19
|
||||||
|
* // at [eval]-wrapper:6:22
|
||||||
|
* // at evalScript (node:internal/process/execution:76:60)
|
||||||
|
* // at node:internal/main/eval_string:23:3
|
||||||
|
*
|
||||||
|
* const name = 'Will Robinson';
|
||||||
|
* console.warn(`Danger ${name}! Danger!`);
|
||||||
|
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example using the `Console` class:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const out = getStreamSomehow();
|
||||||
|
* const err = getStreamSomehow();
|
||||||
|
* const myConsole = new console.Console(out, err);
|
||||||
|
*
|
||||||
|
* myConsole.log('hello world');
|
||||||
|
* // Prints: hello world, to out
|
||||||
|
* myConsole.log('hello %s', 'world');
|
||||||
|
* // Prints: hello world, to out
|
||||||
|
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||||
|
* // Prints: [Error: Whoops, something bad happened], to err
|
||||||
|
*
|
||||||
|
* const name = 'Will Robinson';
|
||||||
|
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||||
|
* // Prints: Danger Will Robinson! Danger!, to err
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/console.js)
|
||||||
|
*/
|
||||||
|
declare module "console" {
|
||||||
|
import console = require("node:console");
|
||||||
|
export = console;
|
||||||
|
}
|
||||||
|
declare module "node:console" {
|
||||||
|
import { InspectOptions } from "node:util";
|
||||||
|
global {
|
||||||
|
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
||||||
|
interface Console {
|
||||||
|
Console: console.ConsoleConstructor;
|
||||||
|
/**
|
||||||
|
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
||||||
|
* writes a message and does not otherwise affect execution. The output always
|
||||||
|
* starts with `"Assertion failed"`. If provided, `message` is formatted using
|
||||||
|
* [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args).
|
||||||
|
*
|
||||||
|
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.assert(true, 'does nothing');
|
||||||
|
*
|
||||||
|
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
||||||
|
* // Assertion failed: Whoops didn't work
|
||||||
|
*
|
||||||
|
* console.assert();
|
||||||
|
* // Assertion failed
|
||||||
|
* ```
|
||||||
|
* @since v0.1.101
|
||||||
|
* @param value The value tested for being truthy.
|
||||||
|
* @param message All arguments besides `value` are used as error message.
|
||||||
|
*/
|
||||||
|
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
||||||
|
* TTY. When `stdout` is not a TTY, this method does nothing.
|
||||||
|
*
|
||||||
|
* The specific operation of `console.clear()` can vary across operating systems
|
||||||
|
* and terminal types. For most Linux operating systems, `console.clear()` operates similarly to the `clear` shell command. On Windows, `console.clear()` will clear only the output in the
|
||||||
|
* current terminal viewport for the Node.js
|
||||||
|
* binary.
|
||||||
|
* @since v8.3.0
|
||||||
|
*/
|
||||||
|
clear(): void;
|
||||||
|
/**
|
||||||
|
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
||||||
|
* number of times `console.count()` has been called with the given `label`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* > console.count()
|
||||||
|
* default: 1
|
||||||
|
* undefined
|
||||||
|
* > console.count('default')
|
||||||
|
* default: 2
|
||||||
|
* undefined
|
||||||
|
* > console.count('abc')
|
||||||
|
* abc: 1
|
||||||
|
* undefined
|
||||||
|
* > console.count('xyz')
|
||||||
|
* xyz: 1
|
||||||
|
* undefined
|
||||||
|
* > console.count('abc')
|
||||||
|
* abc: 2
|
||||||
|
* undefined
|
||||||
|
* > console.count()
|
||||||
|
* default: 3
|
||||||
|
* undefined
|
||||||
|
* >
|
||||||
|
* ```
|
||||||
|
* @since v8.3.0
|
||||||
|
* @param [label='default'] The display label for the counter.
|
||||||
|
*/
|
||||||
|
count(label?: string): void;
|
||||||
|
/**
|
||||||
|
* Resets the internal counter specific to `label`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* > console.count('abc');
|
||||||
|
* abc: 1
|
||||||
|
* undefined
|
||||||
|
* > console.countReset('abc');
|
||||||
|
* undefined
|
||||||
|
* > console.count('abc');
|
||||||
|
* abc: 1
|
||||||
|
* undefined
|
||||||
|
* >
|
||||||
|
* ```
|
||||||
|
* @since v8.3.0
|
||||||
|
* @param [label='default'] The display label for the counter.
|
||||||
|
*/
|
||||||
|
countReset(label?: string): void;
|
||||||
|
/**
|
||||||
|
* The `console.debug()` function is an alias for {@link log}.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
debug(message?: any, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* Uses [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) on `obj` and prints the resulting string to `stdout`.
|
||||||
|
* This function bypasses any custom `inspect()` function defined on `obj`.
|
||||||
|
* @since v0.1.101
|
||||||
|
*/
|
||||||
|
dir(obj: any, options?: InspectOptions): void;
|
||||||
|
/**
|
||||||
|
* This method calls `console.log()` passing it the arguments received.
|
||||||
|
* This method does not produce any XML formatting.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
dirxml(...data: any[]): void;
|
||||||
|
/**
|
||||||
|
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
||||||
|
* first used as the primary message and all additional used as substitution
|
||||||
|
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
||||||
|
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const code = 5;
|
||||||
|
* console.error('error #%d', code);
|
||||||
|
* // Prints: error #5, to stderr
|
||||||
|
* console.error('error', code);
|
||||||
|
* // Prints: error 5, to stderr
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If formatting elements (e.g. `%d`) are not found in the first string then
|
||||||
|
* [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the
|
||||||
|
* resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)
|
||||||
|
* for more information.
|
||||||
|
* @since v0.1.100
|
||||||
|
*/
|
||||||
|
error(message?: any, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* Increases indentation of subsequent lines by spaces for `groupIndentation` length.
|
||||||
|
*
|
||||||
|
* If one or more `label`s are provided, those are printed first without the
|
||||||
|
* additional indentation.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
group(...label: any[]): void;
|
||||||
|
/**
|
||||||
|
* An alias for {@link group}.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
groupCollapsed(...label: any[]): void;
|
||||||
|
/**
|
||||||
|
* Decreases indentation of subsequent lines by spaces for `groupIndentation` length.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
groupEnd(): void;
|
||||||
|
/**
|
||||||
|
* The `console.info()` function is an alias for {@link log}.
|
||||||
|
* @since v0.1.100
|
||||||
|
*/
|
||||||
|
info(message?: any, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
||||||
|
* first used as the primary message and all additional used as substitution
|
||||||
|
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
||||||
|
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const count = 5;
|
||||||
|
* console.log('count: %d', count);
|
||||||
|
* // Prints: count: 5, to stdout
|
||||||
|
* console.log('count:', count);
|
||||||
|
* // Prints: count: 5, to stdout
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
|
||||||
|
* @since v0.1.100
|
||||||
|
*/
|
||||||
|
log(message?: any, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* Try to construct a table with the columns of the properties of `tabularData` (or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
||||||
|
* logging the argument if it can't be parsed as tabular.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // These can't be parsed as tabular data
|
||||||
|
* console.table(Symbol());
|
||||||
|
* // Symbol()
|
||||||
|
*
|
||||||
|
* console.table(undefined);
|
||||||
|
* // undefined
|
||||||
|
*
|
||||||
|
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
||||||
|
* // ┌─────────┬─────┬─────┐
|
||||||
|
* // │ (index) │ a │ b │
|
||||||
|
* // ├─────────┼─────┼─────┤
|
||||||
|
* // │ 0 │ 1 │ 'Y' │
|
||||||
|
* // │ 1 │ 'Z' │ 2 │
|
||||||
|
* // └─────────┴─────┴─────┘
|
||||||
|
*
|
||||||
|
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
||||||
|
* // ┌─────────┬─────┐
|
||||||
|
* // │ (index) │ a │
|
||||||
|
* // ├─────────┼─────┤
|
||||||
|
* // │ 0 │ 1 │
|
||||||
|
* // │ 1 │ 'Z' │
|
||||||
|
* // └─────────┴─────┘
|
||||||
|
* ```
|
||||||
|
* @since v10.0.0
|
||||||
|
* @param properties Alternate properties for constructing the table.
|
||||||
|
*/
|
||||||
|
table(tabularData: any, properties?: readonly string[]): void;
|
||||||
|
/**
|
||||||
|
* Starts a timer that can be used to compute the duration of an operation. Timers
|
||||||
|
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
||||||
|
* suitable time units to `stdout`. For example, if the elapsed
|
||||||
|
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
||||||
|
* @since v0.1.104
|
||||||
|
* @param [label='default']
|
||||||
|
*/
|
||||||
|
time(label?: string): void;
|
||||||
|
/**
|
||||||
|
* Stops a timer that was previously started by calling {@link time} and
|
||||||
|
* prints the result to `stdout`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.time('bunch-of-stuff');
|
||||||
|
* // Do a bunch of stuff.
|
||||||
|
* console.timeEnd('bunch-of-stuff');
|
||||||
|
* // Prints: bunch-of-stuff: 225.438ms
|
||||||
|
* ```
|
||||||
|
* @since v0.1.104
|
||||||
|
* @param [label='default']
|
||||||
|
*/
|
||||||
|
timeEnd(label?: string): void;
|
||||||
|
/**
|
||||||
|
* For a timer that was previously started by calling {@link time}, prints
|
||||||
|
* the elapsed time and other `data` arguments to `stdout`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.time('process');
|
||||||
|
* const value = expensiveProcess1(); // Returns 42
|
||||||
|
* console.timeLog('process', value);
|
||||||
|
* // Prints "process: 365.227ms 42".
|
||||||
|
* doExpensiveProcess2(value);
|
||||||
|
* console.timeEnd('process');
|
||||||
|
* ```
|
||||||
|
* @since v10.7.0
|
||||||
|
* @param [label='default']
|
||||||
|
*/
|
||||||
|
timeLog(label?: string, ...data: any[]): void;
|
||||||
|
/**
|
||||||
|
* Prints to `stderr` the string `'Trace: '`, followed by the [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)
|
||||||
|
* formatted message and stack trace to the current position in the code.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.trace('Show me');
|
||||||
|
* // Prints: (stack trace will vary based on where trace is called)
|
||||||
|
* // Trace: Show me
|
||||||
|
* // at repl:2:9
|
||||||
|
* // at REPLServer.defaultEval (repl.js:248:27)
|
||||||
|
* // at bound (domain.js:287:14)
|
||||||
|
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
||||||
|
* // at REPLServer.<anonymous> (repl.js:412:12)
|
||||||
|
* // at emitOne (events.js:82:20)
|
||||||
|
* // at REPLServer.emit (events.js:169:7)
|
||||||
|
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
||||||
|
* // at REPLServer.Interface._line (readline.js:549:8)
|
||||||
|
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
||||||
|
* ```
|
||||||
|
* @since v0.1.104
|
||||||
|
*/
|
||||||
|
trace(message?: any, ...optionalParams: any[]): void;
|
||||||
|
/**
|
||||||
|
* The `console.warn()` function is an alias for {@link error}.
|
||||||
|
* @since v0.1.100
|
||||||
|
*/
|
||||||
|
warn(message?: any, ...optionalParams: any[]): void;
|
||||||
|
// --- Inspector mode only ---
|
||||||
|
/**
|
||||||
|
* This method does not display anything unless used in the inspector. The `console.profile()`
|
||||||
|
* method starts a JavaScript CPU profile with an optional label until {@link profileEnd}
|
||||||
|
* is called. The profile is then added to the Profile panel of the inspector.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.profile('MyLabel');
|
||||||
|
* // Some code
|
||||||
|
* console.profileEnd('MyLabel');
|
||||||
|
* // Adds the profile 'MyLabel' to the Profiles panel of the inspector.
|
||||||
|
* ```
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
profile(label?: string): void;
|
||||||
|
/**
|
||||||
|
* This method does not display anything unless used in the inspector. Stops the current
|
||||||
|
* JavaScript CPU profiling session if one has been started and prints the report to the
|
||||||
|
* Profiles panel of the inspector. See {@link profile} for an example.
|
||||||
|
*
|
||||||
|
* If this method is called without a label, the most recently started profile is stopped.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
profileEnd(label?: string): void;
|
||||||
|
/**
|
||||||
|
* This method does not display anything unless used in the inspector. The `console.timeStamp()`
|
||||||
|
* method adds an event with the label `'label'` to the Timeline panel of the inspector.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
timeStamp(label?: string): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `console` module provides a simple debugging console that is similar to the
|
||||||
|
* JavaScript console mechanism provided by web browsers.
|
||||||
|
*
|
||||||
|
* The module exports two specific components:
|
||||||
|
*
|
||||||
|
* * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
|
||||||
|
* * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
|
||||||
|
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
|
||||||
|
*
|
||||||
|
* _**Warning**_: The global console object's methods are neither consistently
|
||||||
|
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||||
|
* asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* Example using the global `console`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.log('hello world');
|
||||||
|
* // Prints: hello world, to stdout
|
||||||
|
* console.log('hello %s', 'world');
|
||||||
|
* // Prints: hello world, to stdout
|
||||||
|
* console.error(new Error('Whoops, something bad happened'));
|
||||||
|
* // Prints error message and stack trace to stderr:
|
||||||
|
* // Error: Whoops, something bad happened
|
||||||
|
* // at [eval]:5:15
|
||||||
|
* // at Script.runInThisContext (node:vm:132:18)
|
||||||
|
* // at Object.runInThisContext (node:vm:309:38)
|
||||||
|
* // at node:internal/process/execution:77:19
|
||||||
|
* // at [eval]-wrapper:6:22
|
||||||
|
* // at evalScript (node:internal/process/execution:76:60)
|
||||||
|
* // at node:internal/main/eval_string:23:3
|
||||||
|
*
|
||||||
|
* const name = 'Will Robinson';
|
||||||
|
* console.warn(`Danger ${name}! Danger!`);
|
||||||
|
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example using the `Console` class:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const out = getStreamSomehow();
|
||||||
|
* const err = getStreamSomehow();
|
||||||
|
* const myConsole = new console.Console(out, err);
|
||||||
|
*
|
||||||
|
* myConsole.log('hello world');
|
||||||
|
* // Prints: hello world, to out
|
||||||
|
* myConsole.log('hello %s', 'world');
|
||||||
|
* // Prints: hello world, to out
|
||||||
|
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||||
|
* // Prints: [Error: Whoops, something bad happened], to err
|
||||||
|
*
|
||||||
|
* const name = 'Will Robinson';
|
||||||
|
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||||
|
* // Prints: Danger Will Robinson! Danger!, to err
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/console.js)
|
||||||
|
*/
|
||||||
|
namespace console {
|
||||||
|
interface ConsoleConstructorOptions {
|
||||||
|
stdout: NodeJS.WritableStream;
|
||||||
|
stderr?: NodeJS.WritableStream | undefined;
|
||||||
|
/**
|
||||||
|
* Ignore errors when writing to the underlying streams.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
ignoreErrors?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Set color support for this `Console` instance. Setting to true enables coloring while inspecting
|
||||||
|
* values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color
|
||||||
|
* support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the
|
||||||
|
* respective stream. This option can not be used, if `inspectOptions.colors` is set as well.
|
||||||
|
* @default auto
|
||||||
|
*/
|
||||||
|
colorMode?: boolean | "auto" | undefined;
|
||||||
|
/**
|
||||||
|
* Specifies options that are passed along to
|
||||||
|
* [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options).
|
||||||
|
*/
|
||||||
|
inspectOptions?: InspectOptions | undefined;
|
||||||
|
/**
|
||||||
|
* Set group indentation.
|
||||||
|
* @default 2
|
||||||
|
*/
|
||||||
|
groupIndentation?: number | undefined;
|
||||||
|
}
|
||||||
|
interface ConsoleConstructor {
|
||||||
|
prototype: Console;
|
||||||
|
new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
||||||
|
new(options: ConsoleConstructorOptions): Console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var console: Console;
|
||||||
|
}
|
||||||
|
export = globalThis.console;
|
||||||
|
}
|
19
websocket_server/node_modules/.ignored/@types/node/constants.d.ts
generated
vendored
Normal file
19
websocket_server/node_modules/.ignored/@types/node/constants.d.ts
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||||
|
declare module "constants" {
|
||||||
|
import { constants as osConstants, SignalConstants } from "node:os";
|
||||||
|
import { constants as cryptoConstants } from "node:crypto";
|
||||||
|
import { constants as fsConstants } from "node:fs";
|
||||||
|
|
||||||
|
const exp:
|
||||||
|
& typeof osConstants.errno
|
||||||
|
& typeof osConstants.priority
|
||||||
|
& SignalConstants
|
||||||
|
& typeof cryptoConstants
|
||||||
|
& typeof fsConstants;
|
||||||
|
export = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "node:constants" {
|
||||||
|
import constants = require("constants");
|
||||||
|
export = constants;
|
||||||
|
}
|
4451
websocket_server/node_modules/.ignored/@types/node/crypto.d.ts
generated
vendored
Normal file
4451
websocket_server/node_modules/.ignored/@types/node/crypto.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
596
websocket_server/node_modules/.ignored/@types/node/dgram.d.ts
generated
vendored
Normal file
596
websocket_server/node_modules/.ignored/@types/node/dgram.d.ts
generated
vendored
Normal file
@ -0,0 +1,596 @@
|
|||||||
|
/**
|
||||||
|
* The `node:dgram` module provides an implementation of UDP datagram sockets.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
*
|
||||||
|
* const server = dgram.createSocket('udp4');
|
||||||
|
*
|
||||||
|
* server.on('error', (err) => {
|
||||||
|
* console.error(`server error:\n${err.stack}`);
|
||||||
|
* server.close();
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.on('message', (msg, rinfo) => {
|
||||||
|
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.on('listening', () => {
|
||||||
|
* const address = server.address();
|
||||||
|
* console.log(`server listening ${address.address}:${address.port}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.bind(41234);
|
||||||
|
* // Prints: server listening 0.0.0.0:41234
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/dgram.js)
|
||||||
|
*/
|
||||||
|
declare module "dgram" {
|
||||||
|
import { AddressInfo } from "node:net";
|
||||||
|
import * as dns from "node:dns";
|
||||||
|
import { Abortable, EventEmitter } from "node:events";
|
||||||
|
interface RemoteInfo {
|
||||||
|
address: string;
|
||||||
|
family: "IPv4" | "IPv6";
|
||||||
|
port: number;
|
||||||
|
size: number;
|
||||||
|
}
|
||||||
|
interface BindOptions {
|
||||||
|
port?: number | undefined;
|
||||||
|
address?: string | undefined;
|
||||||
|
exclusive?: boolean | undefined;
|
||||||
|
fd?: number | undefined;
|
||||||
|
}
|
||||||
|
type SocketType = "udp4" | "udp6";
|
||||||
|
interface SocketOptions extends Abortable {
|
||||||
|
type: SocketType;
|
||||||
|
reuseAddr?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
ipv6Only?: boolean | undefined;
|
||||||
|
recvBufferSize?: number | undefined;
|
||||||
|
sendBufferSize?: number | undefined;
|
||||||
|
lookup?:
|
||||||
|
| ((
|
||||||
|
hostname: string,
|
||||||
|
options: dns.LookupOneOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||||
|
) => void)
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
||||||
|
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
||||||
|
* method will bind the socket to the "all interfaces" address on a random port
|
||||||
|
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
||||||
|
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
||||||
|
*
|
||||||
|
* If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.close()` on the socket:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const controller = new AbortController();
|
||||||
|
* const { signal } = controller;
|
||||||
|
* const server = dgram.createSocket({ type: 'udp4', signal });
|
||||||
|
* server.on('message', (msg, rinfo) => {
|
||||||
|
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||||
|
* });
|
||||||
|
* // Later, when you want to close the server.
|
||||||
|
* controller.abort();
|
||||||
|
* ```
|
||||||
|
* @since v0.11.13
|
||||||
|
* @param options Available options are:
|
||||||
|
* @param callback Attached as a listener for `'message'` events. Optional.
|
||||||
|
*/
|
||||||
|
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
|
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
|
/**
|
||||||
|
* Encapsulates the datagram functionality.
|
||||||
|
*
|
||||||
|
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
||||||
|
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
||||||
|
* @since v0.1.99
|
||||||
|
*/
|
||||||
|
class Socket extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* Tells the kernel to join a multicast group at the given `multicastAddress` and `multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the `multicastInterface` argument is not
|
||||||
|
* specified, the operating system will choose
|
||||||
|
* one interface and will add membership to it. To add membership to every
|
||||||
|
* available interface, call `addMembership` multiple times, once per interface.
|
||||||
|
*
|
||||||
|
* When called on an unbound socket, this method will implicitly bind to a random
|
||||||
|
* port, listening on all interfaces.
|
||||||
|
*
|
||||||
|
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import cluster from 'node:cluster';
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
*
|
||||||
|
* if (cluster.isPrimary) {
|
||||||
|
* cluster.fork(); // Works ok.
|
||||||
|
* cluster.fork(); // Fails with EADDRINUSE.
|
||||||
|
* } else {
|
||||||
|
* const s = dgram.createSocket('udp4');
|
||||||
|
* s.bind(1234, () => {
|
||||||
|
* s.addMembership('224.0.0.114');
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.6.9
|
||||||
|
*/
|
||||||
|
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||||
|
/**
|
||||||
|
* Returns an object containing the address information for a socket.
|
||||||
|
* For UDP sockets, this object will contain `address`, `family`, and `port` properties.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
* @since v0.1.99
|
||||||
|
*/
|
||||||
|
address(): AddressInfo;
|
||||||
|
/**
|
||||||
|
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
||||||
|
* messages on a named `port` and optional `address`. If `port` is not
|
||||||
|
* specified or is `0`, the operating system will attempt to bind to a
|
||||||
|
* random port. If `address` is not specified, the operating system will
|
||||||
|
* attempt to listen on all addresses. Once binding is complete, a `'listening'` event is emitted and the optional `callback` function is
|
||||||
|
* called.
|
||||||
|
*
|
||||||
|
* Specifying both a `'listening'` event listener and passing a `callback` to the `socket.bind()` method is not harmful but not very
|
||||||
|
* useful.
|
||||||
|
*
|
||||||
|
* A bound datagram socket keeps the Node.js process running to receive
|
||||||
|
* datagram messages.
|
||||||
|
*
|
||||||
|
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
||||||
|
* attempting to bind with a closed socket), an `Error` may be thrown.
|
||||||
|
*
|
||||||
|
* Example of a UDP server listening on port 41234:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
*
|
||||||
|
* const server = dgram.createSocket('udp4');
|
||||||
|
*
|
||||||
|
* server.on('error', (err) => {
|
||||||
|
* console.error(`server error:\n${err.stack}`);
|
||||||
|
* server.close();
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.on('message', (msg, rinfo) => {
|
||||||
|
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.on('listening', () => {
|
||||||
|
* const address = server.address();
|
||||||
|
* console.log(`server listening ${address.address}:${address.port}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* server.bind(41234);
|
||||||
|
* // Prints: server listening 0.0.0.0:41234
|
||||||
|
* ```
|
||||||
|
* @since v0.1.99
|
||||||
|
* @param callback with no parameters. Called when binding is complete.
|
||||||
|
*/
|
||||||
|
bind(port?: number, address?: string, callback?: () => void): this;
|
||||||
|
bind(port?: number, callback?: () => void): this;
|
||||||
|
bind(callback?: () => void): this;
|
||||||
|
bind(options: BindOptions, callback?: () => void): this;
|
||||||
|
/**
|
||||||
|
* Close the underlying socket and stop listening for data on it. If a callback is
|
||||||
|
* provided, it is added as a listener for the `'close'` event.
|
||||||
|
* @since v0.1.99
|
||||||
|
* @param callback Called when the socket has been closed.
|
||||||
|
*/
|
||||||
|
close(callback?: () => void): this;
|
||||||
|
/**
|
||||||
|
* Associates the `dgram.Socket` to a remote address and port. Every
|
||||||
|
* message sent by this handle is automatically sent to that destination. Also,
|
||||||
|
* the socket will only receive messages from that remote peer.
|
||||||
|
* Trying to call `connect()` on an already connected socket will result
|
||||||
|
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
||||||
|
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
||||||
|
* will be used by default. Once the connection is complete, a `'connect'` event
|
||||||
|
* is emitted and the optional `callback` function is called. In case of failure,
|
||||||
|
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
||||||
|
* @since v12.0.0
|
||||||
|
* @param callback Called when the connection is completed or on error.
|
||||||
|
*/
|
||||||
|
connect(port: number, address?: string, callback?: () => void): void;
|
||||||
|
connect(port: number, callback: () => void): void;
|
||||||
|
/**
|
||||||
|
* A synchronous function that disassociates a connected `dgram.Socket` from
|
||||||
|
* its remote address. Trying to call `disconnect()` on an unbound or already
|
||||||
|
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
||||||
|
* @since v12.0.0
|
||||||
|
*/
|
||||||
|
disconnect(): void;
|
||||||
|
/**
|
||||||
|
* Instructs the kernel to leave a multicast group at `multicastAddress` using the `IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
||||||
|
* kernel when the socket is closed or the process terminates, so most apps will
|
||||||
|
* never have reason to call this.
|
||||||
|
*
|
||||||
|
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||||
|
* drop membership on all valid interfaces.
|
||||||
|
* @since v0.6.9
|
||||||
|
*/
|
||||||
|
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||||
|
/**
|
||||||
|
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||||
|
* @since v8.7.0
|
||||||
|
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
||||||
|
*/
|
||||||
|
getRecvBufferSize(): number;
|
||||||
|
/**
|
||||||
|
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||||
|
* @since v8.7.0
|
||||||
|
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
||||||
|
*/
|
||||||
|
getSendBufferSize(): number;
|
||||||
|
/**
|
||||||
|
* @since v18.8.0, v16.19.0
|
||||||
|
* @return Number of bytes queued for sending.
|
||||||
|
*/
|
||||||
|
getSendQueueSize(): number;
|
||||||
|
/**
|
||||||
|
* @since v18.8.0, v16.19.0
|
||||||
|
* @return Number of send requests currently in the queue awaiting to be processed.
|
||||||
|
*/
|
||||||
|
getSendQueueCount(): number;
|
||||||
|
/**
|
||||||
|
* By default, binding a socket will cause it to block the Node.js process from
|
||||||
|
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
||||||
|
* to exclude the socket from the reference counting that keeps the Node.js
|
||||||
|
* process active. The `socket.ref()` method adds the socket back to the reference
|
||||||
|
* counting and restores the default behavior.
|
||||||
|
*
|
||||||
|
* Calling `socket.ref()` multiples times will have no additional effect.
|
||||||
|
*
|
||||||
|
* The `socket.ref()` method returns a reference to the socket so calls can be
|
||||||
|
* chained.
|
||||||
|
* @since v0.9.1
|
||||||
|
*/
|
||||||
|
ref(): this;
|
||||||
|
/**
|
||||||
|
* Returns an object containing the `address`, `family`, and `port` of the remote
|
||||||
|
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
||||||
|
* if the socket is not connected.
|
||||||
|
* @since v12.0.0
|
||||||
|
*/
|
||||||
|
remoteAddress(): AddressInfo;
|
||||||
|
/**
|
||||||
|
* Broadcasts a datagram on the socket.
|
||||||
|
* For connectionless sockets, the destination `port` and `address` must be
|
||||||
|
* specified. Connected sockets, on the other hand, will use their associated
|
||||||
|
* remote endpoint, so the `port` and `address` arguments must not be set.
|
||||||
|
*
|
||||||
|
* The `msg` argument contains the message to be sent.
|
||||||
|
* Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
|
||||||
|
* any `TypedArray` or a `DataView`,
|
||||||
|
* the `offset` and `length` specify the offset within the `Buffer` where the
|
||||||
|
* message begins and the number of bytes in the message, respectively.
|
||||||
|
* If `msg` is a `String`, then it is automatically converted to a `Buffer` with `'utf8'` encoding. With messages that
|
||||||
|
* contain multi-byte characters, `offset` and `length` will be calculated with
|
||||||
|
* respect to `byte length` and not the character position.
|
||||||
|
* If `msg` is an array, `offset` and `length` must not be specified.
|
||||||
|
*
|
||||||
|
* The `address` argument is a string. If the value of `address` is a host name,
|
||||||
|
* DNS will be used to resolve the address of the host. If `address` is not
|
||||||
|
* provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets) will be used by default.
|
||||||
|
*
|
||||||
|
* If the socket has not been previously bound with a call to `bind`, the socket
|
||||||
|
* is assigned a random port number and is bound to the "all interfaces" address
|
||||||
|
* (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
|
||||||
|
*
|
||||||
|
* An optional `callback` function may be specified to as a way of reporting
|
||||||
|
* DNS errors or for determining when it is safe to reuse the `buf` object.
|
||||||
|
* DNS lookups delay the time to send for at least one tick of the
|
||||||
|
* Node.js event loop.
|
||||||
|
*
|
||||||
|
* The only way to know for sure that the datagram has been sent is by using a `callback`. If an error occurs and a `callback` is given, the error will be
|
||||||
|
* passed as the first argument to the `callback`. If a `callback` is not given,
|
||||||
|
* the error is emitted as an `'error'` event on the `socket` object.
|
||||||
|
*
|
||||||
|
* Offset and length are optional but both _must_ be set if either are used.
|
||||||
|
* They are supported only when the first argument is a `Buffer`, a `TypedArray`,
|
||||||
|
* or a `DataView`.
|
||||||
|
*
|
||||||
|
* This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
|
||||||
|
*
|
||||||
|
* Example of sending a UDP packet to a port on `localhost`;
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const message = Buffer.from('Some bytes');
|
||||||
|
* const client = dgram.createSocket('udp4');
|
||||||
|
* client.send(message, 41234, 'localhost', (err) => {
|
||||||
|
* client.close();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf1 = Buffer.from('Some ');
|
||||||
|
* const buf2 = Buffer.from('bytes');
|
||||||
|
* const client = dgram.createSocket('udp4');
|
||||||
|
* client.send([buf1, buf2], 41234, (err) => {
|
||||||
|
* client.close();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Sending multiple buffers might be faster or slower depending on the
|
||||||
|
* application and operating system. Run benchmarks to
|
||||||
|
* determine the optimal strategy on a case-by-case basis. Generally speaking,
|
||||||
|
* however, sending multiple buffers is faster.
|
||||||
|
*
|
||||||
|
* Example of sending a UDP packet using a socket connected to a port on `localhost`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dgram from 'node:dgram';
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const message = Buffer.from('Some bytes');
|
||||||
|
* const client = dgram.createSocket('udp4');
|
||||||
|
* client.connect(41234, 'localhost', (err) => {
|
||||||
|
* client.send(message, (err) => {
|
||||||
|
* client.close();
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v0.1.99
|
||||||
|
* @param msg Message to be sent.
|
||||||
|
* @param offset Offset in the buffer where the message starts.
|
||||||
|
* @param length Number of bytes in the message.
|
||||||
|
* @param port Destination port.
|
||||||
|
* @param address Destination host name or IP address.
|
||||||
|
* @param callback Called when the message has been sent.
|
||||||
|
*/
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array | readonly any[],
|
||||||
|
port?: number,
|
||||||
|
address?: string,
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array | readonly any[],
|
||||||
|
port?: number,
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array | readonly any[],
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array,
|
||||||
|
offset: number,
|
||||||
|
length: number,
|
||||||
|
port?: number,
|
||||||
|
address?: string,
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array,
|
||||||
|
offset: number,
|
||||||
|
length: number,
|
||||||
|
port?: number,
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
send(
|
||||||
|
msg: string | Uint8Array,
|
||||||
|
offset: number,
|
||||||
|
length: number,
|
||||||
|
callback?: (error: Error | null, bytes: number) => void,
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
||||||
|
* packets may be sent to a local interface's broadcast address.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
* @since v0.6.9
|
||||||
|
*/
|
||||||
|
setBroadcast(flag: boolean): void;
|
||||||
|
/**
|
||||||
|
* _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
||||||
|
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
||||||
|
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
||||||
|
* _or interface number._
|
||||||
|
*
|
||||||
|
* Sets the default outgoing multicast interface of the socket to a chosen
|
||||||
|
* interface or back to system interface selection. The `multicastInterface` must
|
||||||
|
* be a valid string representation of an IP from the socket's family.
|
||||||
|
*
|
||||||
|
* For IPv4 sockets, this should be the IP configured for the desired physical
|
||||||
|
* interface. All packets sent to multicast on the socket will be sent on the
|
||||||
|
* interface determined by the most recent successful use of this call.
|
||||||
|
*
|
||||||
|
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
||||||
|
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
||||||
|
* also use explicit scope in addresses, so only packets sent to a multicast
|
||||||
|
* address without specifying an explicit scope are affected by the most recent
|
||||||
|
* successful use of this call.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
*
|
||||||
|
* #### Example: IPv6 outgoing multicast interface
|
||||||
|
*
|
||||||
|
* On most systems, where scope format uses the interface name:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const socket = dgram.createSocket('udp6');
|
||||||
|
*
|
||||||
|
* socket.bind(1234, () => {
|
||||||
|
* socket.setMulticastInterface('::%eth1');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* On Windows, where scope format uses an interface number:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const socket = dgram.createSocket('udp6');
|
||||||
|
*
|
||||||
|
* socket.bind(1234, () => {
|
||||||
|
* socket.setMulticastInterface('::%2');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* #### Example: IPv4 outgoing multicast interface
|
||||||
|
*
|
||||||
|
* All systems use an IP of the host on the desired physical interface:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const socket = dgram.createSocket('udp4');
|
||||||
|
*
|
||||||
|
* socket.bind(1234, () => {
|
||||||
|
* socket.setMulticastInterface('10.0.0.2');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v8.6.0
|
||||||
|
*/
|
||||||
|
setMulticastInterface(multicastInterface: string): void;
|
||||||
|
/**
|
||||||
|
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
||||||
|
* multicast packets will also be received on the local interface.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
* @since v0.3.8
|
||||||
|
*/
|
||||||
|
setMulticastLoopback(flag: boolean): boolean;
|
||||||
|
/**
|
||||||
|
* Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
||||||
|
* "Time to Live", in this context it specifies the number of IP hops that a
|
||||||
|
* packet is allowed to travel through, specifically for multicast traffic. Each
|
||||||
|
* router or gateway that forwards a packet decrements the TTL. If the TTL is
|
||||||
|
* decremented to 0 by a router, it will not be forwarded.
|
||||||
|
*
|
||||||
|
* The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
* @since v0.3.8
|
||||||
|
*/
|
||||||
|
setMulticastTTL(ttl: number): number;
|
||||||
|
/**
|
||||||
|
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
||||||
|
* in bytes.
|
||||||
|
*
|
||||||
|
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||||
|
* @since v8.7.0
|
||||||
|
*/
|
||||||
|
setRecvBufferSize(size: number): void;
|
||||||
|
/**
|
||||||
|
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
||||||
|
* in bytes.
|
||||||
|
*
|
||||||
|
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||||
|
* @since v8.7.0
|
||||||
|
*/
|
||||||
|
setSendBufferSize(size: number): void;
|
||||||
|
/**
|
||||||
|
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
||||||
|
* in this context it specifies the number of IP hops that a packet is allowed to
|
||||||
|
* travel through. Each router or gateway that forwards a packet decrements the
|
||||||
|
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
||||||
|
* Changing TTL values is typically done for network probes or when multicasting.
|
||||||
|
*
|
||||||
|
* The `ttl` argument may be between 1 and 255\. The default on most systems
|
||||||
|
* is 64.
|
||||||
|
*
|
||||||
|
* This method throws `EBADF` if called on an unbound socket.
|
||||||
|
* @since v0.1.101
|
||||||
|
*/
|
||||||
|
setTTL(ttl: number): number;
|
||||||
|
/**
|
||||||
|
* By default, binding a socket will cause it to block the Node.js process from
|
||||||
|
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
||||||
|
* to exclude the socket from the reference counting that keeps the Node.js
|
||||||
|
* process active, allowing the process to exit even if the socket is still
|
||||||
|
* listening.
|
||||||
|
*
|
||||||
|
* Calling `socket.unref()` multiple times will have no additional effect.
|
||||||
|
*
|
||||||
|
* The `socket.unref()` method returns a reference to the socket so calls can be
|
||||||
|
* chained.
|
||||||
|
* @since v0.9.1
|
||||||
|
*/
|
||||||
|
unref(): this;
|
||||||
|
/**
|
||||||
|
* Tells the kernel to join a source-specific multicast channel at the given `sourceAddress` and `groupAddress`, using the `multicastInterface` with the `IP_ADD_SOURCE_MEMBERSHIP` socket
|
||||||
|
* option. If the `multicastInterface` argument
|
||||||
|
* is not specified, the operating system will choose one interface and will add
|
||||||
|
* membership to it. To add membership to every available interface, call `socket.addSourceSpecificMembership()` multiple times, once per interface.
|
||||||
|
*
|
||||||
|
* When called on an unbound socket, this method will implicitly bind to a random
|
||||||
|
* port, listening on all interfaces.
|
||||||
|
* @since v13.1.0, v12.16.0
|
||||||
|
*/
|
||||||
|
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||||
|
/**
|
||||||
|
* Instructs the kernel to leave a source-specific multicast channel at the given `sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP` socket option. This method is
|
||||||
|
* automatically called by the kernel when the
|
||||||
|
* socket is closed or the process terminates, so most apps will never have
|
||||||
|
* reason to call this.
|
||||||
|
*
|
||||||
|
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||||
|
* drop membership on all valid interfaces.
|
||||||
|
* @since v13.1.0, v12.16.0
|
||||||
|
*/
|
||||||
|
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. close
|
||||||
|
* 2. connect
|
||||||
|
* 3. error
|
||||||
|
* 4. listening
|
||||||
|
* 5. message
|
||||||
|
*/
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "connect", listener: () => void): this;
|
||||||
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
addListener(event: "listening", listener: () => void): this;
|
||||||
|
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "close"): boolean;
|
||||||
|
emit(event: "connect"): boolean;
|
||||||
|
emit(event: "error", err: Error): boolean;
|
||||||
|
emit(event: "listening"): boolean;
|
||||||
|
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "connect", listener: () => void): this;
|
||||||
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
|
on(event: "listening", listener: () => void): this;
|
||||||
|
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "connect", listener: () => void): this;
|
||||||
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
|
once(event: "listening", listener: () => void): this;
|
||||||
|
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "connect", listener: () => void): this;
|
||||||
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
|
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "connect", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
/**
|
||||||
|
* Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
|
||||||
|
* @since v20.5.0
|
||||||
|
*/
|
||||||
|
[Symbol.asyncDispose](): Promise<void>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:dgram" {
|
||||||
|
export * from "dgram";
|
||||||
|
}
|
554
websocket_server/node_modules/.ignored/@types/node/diagnostics_channel.d.ts
generated
vendored
Normal file
554
websocket_server/node_modules/.ignored/@types/node/diagnostics_channel.d.ts
generated
vendored
Normal file
@ -0,0 +1,554 @@
|
|||||||
|
/**
|
||||||
|
* The `node:diagnostics_channel` module provides an API to create named channels
|
||||||
|
* to report arbitrary message data for diagnostics purposes.
|
||||||
|
*
|
||||||
|
* It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* It is intended that a module writer wanting to report diagnostics messages
|
||||||
|
* will create one or many top-level channels to report messages through.
|
||||||
|
* Channels may also be acquired at runtime but it is not encouraged
|
||||||
|
* due to the additional overhead of doing so. Channels may be exported for
|
||||||
|
* convenience, but as long as the name is known it can be acquired anywhere.
|
||||||
|
*
|
||||||
|
* If you intend for your module to produce diagnostics data for others to
|
||||||
|
* consume it is recommended that you include documentation of what named
|
||||||
|
* channels are used along with the shape of the message data. Channel names
|
||||||
|
* should generally include the module name to avoid collisions with data from
|
||||||
|
* other modules.
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/diagnostics_channel.js)
|
||||||
|
*/
|
||||||
|
declare module "diagnostics_channel" {
|
||||||
|
import { AsyncLocalStorage } from "node:async_hooks";
|
||||||
|
/**
|
||||||
|
* Check if there are active subscribers to the named channel. This is helpful if
|
||||||
|
* the message you want to send might be expensive to prepare.
|
||||||
|
*
|
||||||
|
* This API is optional but helpful when trying to publish messages from very
|
||||||
|
* performance-sensitive code.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
||||||
|
* // There are subscribers, prepare and publish message
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @param name The channel name
|
||||||
|
* @return If there are active subscribers
|
||||||
|
*/
|
||||||
|
function hasSubscribers(name: string | symbol): boolean;
|
||||||
|
/**
|
||||||
|
* This is the primary entry-point for anyone wanting to publish to a named
|
||||||
|
* channel. It produces a channel object which is optimized to reduce overhead at
|
||||||
|
* publish time as much as possible.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @param name The channel name
|
||||||
|
* @return The named channel object
|
||||||
|
*/
|
||||||
|
function channel(name: string | symbol): Channel;
|
||||||
|
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
||||||
|
/**
|
||||||
|
* Register a message handler to subscribe to this channel. This message handler
|
||||||
|
* will be run synchronously whenever a message is published to the channel. Any
|
||||||
|
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* diagnostics_channel.subscribe('my-channel', (message, name) => {
|
||||||
|
* // Received data
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v18.7.0, v16.17.0
|
||||||
|
* @param name The channel name
|
||||||
|
* @param onMessage The handler to receive channel messages
|
||||||
|
*/
|
||||||
|
function subscribe(name: string | symbol, onMessage: ChannelListener): void;
|
||||||
|
/**
|
||||||
|
* Remove a message handler previously registered to this channel with {@link subscribe}.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* function onMessage(message, name) {
|
||||||
|
* // Received data
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* diagnostics_channel.subscribe('my-channel', onMessage);
|
||||||
|
*
|
||||||
|
* diagnostics_channel.unsubscribe('my-channel', onMessage);
|
||||||
|
* ```
|
||||||
|
* @since v18.7.0, v16.17.0
|
||||||
|
* @param name The channel name
|
||||||
|
* @param onMessage The previous subscribed handler to remove
|
||||||
|
* @return `true` if the handler was found, `false` otherwise.
|
||||||
|
*/
|
||||||
|
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
||||||
|
/**
|
||||||
|
* Creates a `TracingChannel` wrapper for the given `TracingChannel Channels`. If a name is given, the corresponding tracing
|
||||||
|
* channels will be created in the form of `tracing:${name}:${eventType}` where `eventType` corresponds to the types of `TracingChannel Channels`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channelsByName = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* // or...
|
||||||
|
*
|
||||||
|
* const channelsByCollection = diagnostics_channel.tracingChannel({
|
||||||
|
* start: diagnostics_channel.channel('tracing:my-channel:start'),
|
||||||
|
* end: diagnostics_channel.channel('tracing:my-channel:end'),
|
||||||
|
* asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),
|
||||||
|
* asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),
|
||||||
|
* error: diagnostics_channel.channel('tracing:my-channel:error'),
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param nameOrChannels Channel name or object containing all the `TracingChannel Channels`
|
||||||
|
* @return Collection of channels to trace with
|
||||||
|
*/
|
||||||
|
function tracingChannel<
|
||||||
|
StoreType = unknown,
|
||||||
|
ContextType extends object = StoreType extends object ? StoreType : object,
|
||||||
|
>(
|
||||||
|
nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>,
|
||||||
|
): TracingChannel<StoreType, ContextType>;
|
||||||
|
/**
|
||||||
|
* The class `Channel` represents an individual named channel within the data
|
||||||
|
* pipeline. It is used to track subscribers and to publish messages when there
|
||||||
|
* are subscribers present. It exists as a separate object to avoid channel
|
||||||
|
* lookups at publish time, enabling very fast publish speeds and allowing
|
||||||
|
* for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
|
||||||
|
* with `new Channel(name)` is not supported.
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
*/
|
||||||
|
class Channel<StoreType = unknown, ContextType = StoreType> {
|
||||||
|
readonly name: string | symbol;
|
||||||
|
/**
|
||||||
|
* Check if there are active subscribers to this channel. This is helpful if
|
||||||
|
* the message you want to send might be expensive to prepare.
|
||||||
|
*
|
||||||
|
* This API is optional but helpful when trying to publish messages from very
|
||||||
|
* performance-sensitive code.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* if (channel.hasSubscribers) {
|
||||||
|
* // There are subscribers, prepare and publish message
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
*/
|
||||||
|
readonly hasSubscribers: boolean;
|
||||||
|
private constructor(name: string | symbol);
|
||||||
|
/**
|
||||||
|
* Publish a message to any subscribers to the channel. This will trigger
|
||||||
|
* message handlers synchronously so they will execute within the same context.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* channel.publish({
|
||||||
|
* some: 'message',
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @param message The message to send to the channel subscribers
|
||||||
|
*/
|
||||||
|
publish(message: unknown): void;
|
||||||
|
/**
|
||||||
|
* Register a message handler to subscribe to this channel. This message handler
|
||||||
|
* will be run synchronously whenever a message is published to the channel. Any
|
||||||
|
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* channel.subscribe((message, name) => {
|
||||||
|
* // Received data
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)}
|
||||||
|
* @param onMessage The handler to receive channel messages
|
||||||
|
*/
|
||||||
|
subscribe(onMessage: ChannelListener): void;
|
||||||
|
/**
|
||||||
|
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* function onMessage(message, name) {
|
||||||
|
* // Received data
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* channel.subscribe(onMessage);
|
||||||
|
*
|
||||||
|
* channel.unsubscribe(onMessage);
|
||||||
|
* ```
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)}
|
||||||
|
* @param onMessage The previous subscribed handler to remove
|
||||||
|
* @return `true` if the handler was found, `false` otherwise.
|
||||||
|
*/
|
||||||
|
unsubscribe(onMessage: ChannelListener): void;
|
||||||
|
/**
|
||||||
|
* When `channel.runStores(context, ...)` is called, the given context data
|
||||||
|
* will be applied to any store bound to the channel. If the store has already been
|
||||||
|
* bound the previous `transform` function will be replaced with the new one.
|
||||||
|
* The `transform` function may be omitted to set the given context data as the
|
||||||
|
* context directly.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const store = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* channel.bindStore(store, (data) => {
|
||||||
|
* return { data };
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param store The store to which to bind the context data
|
||||||
|
* @param transform Transform context data before setting the store context
|
||||||
|
*/
|
||||||
|
bindStore(store: AsyncLocalStorage<StoreType>, transform?: (context: ContextType) => StoreType): void;
|
||||||
|
/**
|
||||||
|
* Remove a message handler previously registered to this channel with `channel.bindStore(store)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const store = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* channel.bindStore(store);
|
||||||
|
* channel.unbindStore(store);
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param store The store to unbind from the channel.
|
||||||
|
* @return `true` if the store was found, `false` otherwise.
|
||||||
|
*/
|
||||||
|
unbindStore(store: any): void;
|
||||||
|
/**
|
||||||
|
* Applies the given data to any AsyncLocalStorage instances bound to the channel
|
||||||
|
* for the duration of the given function, then publishes to the channel within
|
||||||
|
* the scope of that data is applied to the stores.
|
||||||
|
*
|
||||||
|
* If a transform function was given to `channel.bindStore(store)` it will be
|
||||||
|
* applied to transform the message data before it becomes the context value for
|
||||||
|
* the store. The prior storage context is accessible from within the transform
|
||||||
|
* function in cases where context linking is required.
|
||||||
|
*
|
||||||
|
* The context applied to the store should be accessible in any async code which
|
||||||
|
* continues from execution which began during the given function, however
|
||||||
|
* there are some situations in which `context loss` may occur.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const store = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* const channel = diagnostics_channel.channel('my-channel');
|
||||||
|
*
|
||||||
|
* channel.bindStore(store, (message) => {
|
||||||
|
* const parent = store.getStore();
|
||||||
|
* return new Span(message, parent);
|
||||||
|
* });
|
||||||
|
* channel.runStores({ some: 'message' }, () => {
|
||||||
|
* store.getStore(); // Span({ some: 'message' })
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param context Message to send to subscribers and bind to stores
|
||||||
|
* @param fn Handler to run within the entered storage context
|
||||||
|
* @param thisArg The receiver to be used for the function call.
|
||||||
|
* @param args Optional arguments to pass to the function.
|
||||||
|
*/
|
||||||
|
runStores(): void;
|
||||||
|
}
|
||||||
|
interface TracingChannelSubscribers<ContextType extends object> {
|
||||||
|
start: (message: ContextType) => void;
|
||||||
|
end: (
|
||||||
|
message: ContextType & {
|
||||||
|
error?: unknown;
|
||||||
|
result?: unknown;
|
||||||
|
},
|
||||||
|
) => void;
|
||||||
|
asyncStart: (
|
||||||
|
message: ContextType & {
|
||||||
|
error?: unknown;
|
||||||
|
result?: unknown;
|
||||||
|
},
|
||||||
|
) => void;
|
||||||
|
asyncEnd: (
|
||||||
|
message: ContextType & {
|
||||||
|
error?: unknown;
|
||||||
|
result?: unknown;
|
||||||
|
},
|
||||||
|
) => void;
|
||||||
|
error: (
|
||||||
|
message: ContextType & {
|
||||||
|
error: unknown;
|
||||||
|
},
|
||||||
|
) => void;
|
||||||
|
}
|
||||||
|
interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> {
|
||||||
|
start: Channel<StoreType, ContextType>;
|
||||||
|
end: Channel<StoreType, ContextType>;
|
||||||
|
asyncStart: Channel<StoreType, ContextType>;
|
||||||
|
asyncEnd: Channel<StoreType, ContextType>;
|
||||||
|
error: Channel<StoreType, ContextType>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The class `TracingChannel` is a collection of `TracingChannel Channels` which
|
||||||
|
* together express a single traceable action. It is used to formalize and
|
||||||
|
* simplify the process of producing events for tracing application flow. {@link tracingChannel} is used to construct a `TracingChannel`. As with `Channel` it is recommended to create and reuse a
|
||||||
|
* single `TracingChannel` at the top-level of the file rather than creating them
|
||||||
|
* dynamically.
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection {
|
||||||
|
start: Channel<StoreType, ContextType>;
|
||||||
|
end: Channel<StoreType, ContextType>;
|
||||||
|
asyncStart: Channel<StoreType, ContextType>;
|
||||||
|
asyncEnd: Channel<StoreType, ContextType>;
|
||||||
|
error: Channel<StoreType, ContextType>;
|
||||||
|
/**
|
||||||
|
* Helper to subscribe a collection of functions to the corresponding channels.
|
||||||
|
* This is the same as calling `channel.subscribe(onMessage)` on each channel
|
||||||
|
* individually.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* channels.subscribe({
|
||||||
|
* start(message) {
|
||||||
|
* // Handle start message
|
||||||
|
* },
|
||||||
|
* end(message) {
|
||||||
|
* // Handle end message
|
||||||
|
* },
|
||||||
|
* asyncStart(message) {
|
||||||
|
* // Handle asyncStart message
|
||||||
|
* },
|
||||||
|
* asyncEnd(message) {
|
||||||
|
* // Handle asyncEnd message
|
||||||
|
* },
|
||||||
|
* error(message) {
|
||||||
|
* // Handle error message
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param subscribers Set of `TracingChannel Channels` subscribers
|
||||||
|
*/
|
||||||
|
subscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
|
||||||
|
/**
|
||||||
|
* Helper to unsubscribe a collection of functions from the corresponding channels.
|
||||||
|
* This is the same as calling `channel.unsubscribe(onMessage)` on each channel
|
||||||
|
* individually.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* channels.unsubscribe({
|
||||||
|
* start(message) {
|
||||||
|
* // Handle start message
|
||||||
|
* },
|
||||||
|
* end(message) {
|
||||||
|
* // Handle end message
|
||||||
|
* },
|
||||||
|
* asyncStart(message) {
|
||||||
|
* // Handle asyncStart message
|
||||||
|
* },
|
||||||
|
* asyncEnd(message) {
|
||||||
|
* // Handle asyncEnd message
|
||||||
|
* },
|
||||||
|
* error(message) {
|
||||||
|
* // Handle error message
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param subscribers Set of `TracingChannel Channels` subscribers
|
||||||
|
* @return `true` if all handlers were successfully unsubscribed, and `false` otherwise.
|
||||||
|
*/
|
||||||
|
unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
|
||||||
|
/**
|
||||||
|
* Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error.
|
||||||
|
* This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||||
|
* events should have any bound stores set to match this trace context.
|
||||||
|
*
|
||||||
|
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||||
|
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* channels.traceSync(() => {
|
||||||
|
* // Do something
|
||||||
|
* }, {
|
||||||
|
* some: 'thing',
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param fn Function to wrap a trace around
|
||||||
|
* @param context Shared object to correlate events through
|
||||||
|
* @param thisArg The receiver to be used for the function call
|
||||||
|
* @param args Optional arguments to pass to the function
|
||||||
|
* @return The return value of the given function
|
||||||
|
*/
|
||||||
|
traceSync<ThisArg = any, Args extends any[] = any[]>(
|
||||||
|
fn: (this: ThisArg, ...args: Args) => any,
|
||||||
|
context?: ContextType,
|
||||||
|
thisArg?: ThisArg,
|
||||||
|
...args: Args
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the
|
||||||
|
* function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also
|
||||||
|
* produce an `error event` if the given function throws an error or the
|
||||||
|
* returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||||
|
* events should have any bound stores set to match this trace context.
|
||||||
|
*
|
||||||
|
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||||
|
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* channels.tracePromise(async () => {
|
||||||
|
* // Do something
|
||||||
|
* }, {
|
||||||
|
* some: 'thing',
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param fn Promise-returning function to wrap a trace around
|
||||||
|
* @param context Shared object to correlate trace events through
|
||||||
|
* @param thisArg The receiver to be used for the function call
|
||||||
|
* @param args Optional arguments to pass to the function
|
||||||
|
* @return Chained from promise returned by the given function
|
||||||
|
*/
|
||||||
|
tracePromise<ThisArg = any, Args extends any[] = any[]>(
|
||||||
|
fn: (this: ThisArg, ...args: Args) => Promise<any>,
|
||||||
|
context?: ContextType,
|
||||||
|
thisArg?: ThisArg,
|
||||||
|
...args: Args
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the
|
||||||
|
* function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or
|
||||||
|
* the returned
|
||||||
|
* promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||||
|
* events should have any bound stores set to match this trace context.
|
||||||
|
*
|
||||||
|
* The `position` will be -1 by default to indicate the final argument should
|
||||||
|
* be used as the callback.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
*
|
||||||
|
* channels.traceCallback((arg1, callback) => {
|
||||||
|
* // Do something
|
||||||
|
* callback(null, 'result');
|
||||||
|
* }, 1, {
|
||||||
|
* some: 'thing',
|
||||||
|
* }, thisArg, arg1, callback);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The callback will also be run with `channel.runStores(context, ...)` which
|
||||||
|
* enables context loss recovery in some cases.
|
||||||
|
*
|
||||||
|
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||||
|
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||||
|
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||||
|
* const myStore = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* // The start channel sets the initial store data to something
|
||||||
|
* // and stores that store data value on the trace context object
|
||||||
|
* channels.start.bindStore(myStore, (data) => {
|
||||||
|
* const span = new Span(data);
|
||||||
|
* data.span = span;
|
||||||
|
* return span;
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Then asyncStart can restore from that data it stored previously
|
||||||
|
* channels.asyncStart.bindStore(myStore, (data) => {
|
||||||
|
* return data.span;
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @experimental
|
||||||
|
* @param fn callback using function to wrap a trace around
|
||||||
|
* @param position Zero-indexed argument position of expected callback
|
||||||
|
* @param context Shared object to correlate trace events through
|
||||||
|
* @param thisArg The receiver to be used for the function call
|
||||||
|
* @param args Optional arguments to pass to the function
|
||||||
|
* @return The return value of the given function
|
||||||
|
*/
|
||||||
|
traceCallback<Fn extends (this: any, ...args: any[]) => any>(
|
||||||
|
fn: Fn,
|
||||||
|
position?: number,
|
||||||
|
context?: ContextType,
|
||||||
|
thisArg?: any,
|
||||||
|
...args: Parameters<Fn>
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:diagnostics_channel" {
|
||||||
|
export * from "diagnostics_channel";
|
||||||
|
}
|
865
websocket_server/node_modules/.ignored/@types/node/dns.d.ts
generated
vendored
Normal file
865
websocket_server/node_modules/.ignored/@types/node/dns.d.ts
generated
vendored
Normal file
@ -0,0 +1,865 @@
|
|||||||
|
/**
|
||||||
|
* The `node:dns` module enables name resolution. For example, use it to look up IP
|
||||||
|
* addresses of host names.
|
||||||
|
*
|
||||||
|
* Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
|
||||||
|
* DNS protocol for lookups. {@link lookup} uses the operating system
|
||||||
|
* facilities to perform name resolution. It may not need to perform any network
|
||||||
|
* communication. To perform name resolution the way other applications on the same
|
||||||
|
* system do, use {@link lookup}.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dns from 'node:dns';
|
||||||
|
*
|
||||||
|
* dns.lookup('example.org', (err, address, family) => {
|
||||||
|
* console.log('address: %j family: IPv%s', address, family);
|
||||||
|
* });
|
||||||
|
* // address: "93.184.216.34" family: IPv4
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* All other functions in the `node:dns` module connect to an actual DNS server to
|
||||||
|
* perform name resolution. They will always use the network to perform DNS
|
||||||
|
* queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
|
||||||
|
* DNS queries, bypassing other name-resolution facilities.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dns from 'node:dns';
|
||||||
|
*
|
||||||
|
* dns.resolve4('archive.org', (err, addresses) => {
|
||||||
|
* if (err) throw err;
|
||||||
|
*
|
||||||
|
* console.log(`addresses: ${JSON.stringify(addresses)}`);
|
||||||
|
*
|
||||||
|
* addresses.forEach((a) => {
|
||||||
|
* dns.reverse(a, (err, hostnames) => {
|
||||||
|
* if (err) {
|
||||||
|
* throw err;
|
||||||
|
* }
|
||||||
|
* console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* See the [Implementation considerations section](https://nodejs.org/docs/latest-v22.x/api/dns.html#implementation-considerations) for more information.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/dns.js)
|
||||||
|
*/
|
||||||
|
declare module "dns" {
|
||||||
|
import * as dnsPromises from "node:dns/promises";
|
||||||
|
// Supported getaddrinfo flags.
|
||||||
|
/**
|
||||||
|
* Limits returned address types to the types of non-loopback addresses configured on the system. For example, IPv4 addresses are
|
||||||
|
* only returned if the current system has at least one IPv4 address configured.
|
||||||
|
*/
|
||||||
|
export const ADDRCONFIG: number;
|
||||||
|
/**
|
||||||
|
* If the IPv6 family was specified, but no IPv6 addresses were found, then return IPv4 mapped IPv6 addresses. It is not supported
|
||||||
|
* on some operating systems (e.g. FreeBSD 10.1).
|
||||||
|
*/
|
||||||
|
export const V4MAPPED: number;
|
||||||
|
/**
|
||||||
|
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
||||||
|
* well as IPv4 mapped IPv6 addresses.
|
||||||
|
*/
|
||||||
|
export const ALL: number;
|
||||||
|
export interface LookupOptions {
|
||||||
|
/**
|
||||||
|
* The record family. Must be `4`, `6`, or `0`. For backward compatibility reasons, `'IPv4'` and `'IPv6'` are interpreted
|
||||||
|
* as `4` and `6` respectively. The value 0 indicates that either an IPv4 or IPv6 address is returned. If the value `0` is used
|
||||||
|
* with `{ all: true } (see below)`, both IPv4 and IPv6 addresses are returned.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
family?: number | "IPv4" | "IPv6" | undefined;
|
||||||
|
/**
|
||||||
|
* One or more [supported `getaddrinfo`](https://nodejs.org/docs/latest-v22.x/api/dns.html#supported-getaddrinfo-flags) flags. Multiple flags may be
|
||||||
|
* passed by bitwise `OR`ing their values.
|
||||||
|
*/
|
||||||
|
hints?: number | undefined;
|
||||||
|
/**
|
||||||
|
* When `true`, the callback returns all resolved addresses in an array. Otherwise, returns a single address.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
all?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
|
||||||
|
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
|
||||||
|
* addresses before IPv4 addresses. Default value is configurable using
|
||||||
|
* {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
|
||||||
|
* @default `verbatim` (addresses are not reordered)
|
||||||
|
* @since v22.1.0
|
||||||
|
*/
|
||||||
|
order?: "ipv4first" | "ipv6first" | "verbatim" | undefined;
|
||||||
|
/**
|
||||||
|
* When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
|
||||||
|
* addresses are placed before IPv6 addresses. This option will be deprecated in favor of `order`. When both are specified,
|
||||||
|
* `order` has higher precedence. New code should only use `order`. Default value is configurable using {@link setDefaultResultOrder}
|
||||||
|
* @default true (addresses are not reordered)
|
||||||
|
* @deprecated Please use `order` option
|
||||||
|
*/
|
||||||
|
verbatim?: boolean | undefined;
|
||||||
|
}
|
||||||
|
export interface LookupOneOptions extends LookupOptions {
|
||||||
|
all?: false | undefined;
|
||||||
|
}
|
||||||
|
export interface LookupAllOptions extends LookupOptions {
|
||||||
|
all: true;
|
||||||
|
}
|
||||||
|
export interface LookupAddress {
|
||||||
|
/**
|
||||||
|
* A string representation of an IPv4 or IPv6 address.
|
||||||
|
*/
|
||||||
|
address: string;
|
||||||
|
/**
|
||||||
|
* `4` or `6`, denoting the family of `address`, or `0` if the address is not an IPv4 or IPv6 address. `0` is a likely indicator of a
|
||||||
|
* bug in the name resolution service used by the operating system.
|
||||||
|
*/
|
||||||
|
family: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
||||||
|
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
||||||
|
* integer, then it must be `4` or `6` – if `options` is `0` or not provided, then
|
||||||
|
* IPv4 and IPv6 addresses are both returned if found.
|
||||||
|
*
|
||||||
|
* With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the
|
||||||
|
* properties `address` and `family`.
|
||||||
|
*
|
||||||
|
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
||||||
|
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||||
|
* the host name does not exist but also when the lookup fails in other ways
|
||||||
|
* such as no available file descriptors.
|
||||||
|
*
|
||||||
|
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
||||||
|
* The implementation uses an operating system facility that can associate names
|
||||||
|
* with addresses and vice versa. This implementation can have subtle but
|
||||||
|
* important consequences on the behavior of any Node.js program. Please take some
|
||||||
|
* time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v22.x/api/dns.html#implementation-considerations)
|
||||||
|
* before using `dns.lookup()`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dns from 'node:dns';
|
||||||
|
* const options = {
|
||||||
|
* family: 6,
|
||||||
|
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||||
|
* };
|
||||||
|
* dns.lookup('example.com', options, (err, address, family) =>
|
||||||
|
* console.log('address: %j family: IPv%s', address, family));
|
||||||
|
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
||||||
|
*
|
||||||
|
* // When options.all is true, the result will be an Array.
|
||||||
|
* options.all = true;
|
||||||
|
* dns.lookup('example.com', options, (err, addresses) =>
|
||||||
|
* console.log('addresses: %j', addresses));
|
||||||
|
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v22.x/api/util.html#utilpromisifyoriginal) ed
|
||||||
|
* version, and `all` is not set to `true`, it returns a `Promise` for an `Object` with `address` and `family` properties.
|
||||||
|
* @since v0.1.90
|
||||||
|
*/
|
||||||
|
export function lookup(
|
||||||
|
hostname: string,
|
||||||
|
family: number,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||||
|
): void;
|
||||||
|
export function lookup(
|
||||||
|
hostname: string,
|
||||||
|
options: LookupOneOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||||
|
): void;
|
||||||
|
export function lookup(
|
||||||
|
hostname: string,
|
||||||
|
options: LookupAllOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void,
|
||||||
|
): void;
|
||||||
|
export function lookup(
|
||||||
|
hostname: string,
|
||||||
|
options: LookupOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void,
|
||||||
|
): void;
|
||||||
|
export function lookup(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||||
|
): void;
|
||||||
|
export namespace lookup {
|
||||||
|
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||||
|
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
||||||
|
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Resolves the given `address` and `port` into a host name and service using
|
||||||
|
* the operating system's underlying `getnameinfo` implementation.
|
||||||
|
*
|
||||||
|
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
||||||
|
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.
|
||||||
|
*
|
||||||
|
* On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object,
|
||||||
|
* where `err.code` is the error code.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dns from 'node:dns';
|
||||||
|
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
||||||
|
* console.log(hostname, service);
|
||||||
|
* // Prints: localhost ssh
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v22.x/api/util.html#utilpromisifyoriginal) ed
|
||||||
|
* version, it returns a `Promise` for an `Object` with `hostname` and `service` properties.
|
||||||
|
* @since v0.11.14
|
||||||
|
*/
|
||||||
|
export function lookupService(
|
||||||
|
address: string,
|
||||||
|
port: number,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void,
|
||||||
|
): void;
|
||||||
|
export namespace lookupService {
|
||||||
|
function __promisify__(
|
||||||
|
address: string,
|
||||||
|
port: number,
|
||||||
|
): Promise<{
|
||||||
|
hostname: string;
|
||||||
|
service: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
export interface ResolveOptions {
|
||||||
|
ttl: boolean;
|
||||||
|
}
|
||||||
|
export interface ResolveWithTtlOptions extends ResolveOptions {
|
||||||
|
ttl: true;
|
||||||
|
}
|
||||||
|
export interface RecordWithTtl {
|
||||||
|
address: string;
|
||||||
|
ttl: number;
|
||||||
|
}
|
||||||
|
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
||||||
|
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||||
|
export interface AnyARecord extends RecordWithTtl {
|
||||||
|
type: "A";
|
||||||
|
}
|
||||||
|
export interface AnyAaaaRecord extends RecordWithTtl {
|
||||||
|
type: "AAAA";
|
||||||
|
}
|
||||||
|
export interface CaaRecord {
|
||||||
|
critical: number;
|
||||||
|
issue?: string | undefined;
|
||||||
|
issuewild?: string | undefined;
|
||||||
|
iodef?: string | undefined;
|
||||||
|
contactemail?: string | undefined;
|
||||||
|
contactphone?: string | undefined;
|
||||||
|
}
|
||||||
|
export interface MxRecord {
|
||||||
|
priority: number;
|
||||||
|
exchange: string;
|
||||||
|
}
|
||||||
|
export interface AnyMxRecord extends MxRecord {
|
||||||
|
type: "MX";
|
||||||
|
}
|
||||||
|
export interface NaptrRecord {
|
||||||
|
flags: string;
|
||||||
|
service: string;
|
||||||
|
regexp: string;
|
||||||
|
replacement: string;
|
||||||
|
order: number;
|
||||||
|
preference: number;
|
||||||
|
}
|
||||||
|
export interface AnyNaptrRecord extends NaptrRecord {
|
||||||
|
type: "NAPTR";
|
||||||
|
}
|
||||||
|
export interface SoaRecord {
|
||||||
|
nsname: string;
|
||||||
|
hostmaster: string;
|
||||||
|
serial: number;
|
||||||
|
refresh: number;
|
||||||
|
retry: number;
|
||||||
|
expire: number;
|
||||||
|
minttl: number;
|
||||||
|
}
|
||||||
|
export interface AnySoaRecord extends SoaRecord {
|
||||||
|
type: "SOA";
|
||||||
|
}
|
||||||
|
export interface SrvRecord {
|
||||||
|
priority: number;
|
||||||
|
weight: number;
|
||||||
|
port: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface AnySrvRecord extends SrvRecord {
|
||||||
|
type: "SRV";
|
||||||
|
}
|
||||||
|
export interface AnyTxtRecord {
|
||||||
|
type: "TXT";
|
||||||
|
entries: string[];
|
||||||
|
}
|
||||||
|
export interface AnyNsRecord {
|
||||||
|
type: "NS";
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
export interface AnyPtrRecord {
|
||||||
|
type: "PTR";
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
export interface AnyCnameRecord {
|
||||||
|
type: "CNAME";
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
export type AnyRecord =
|
||||||
|
| AnyARecord
|
||||||
|
| AnyAaaaRecord
|
||||||
|
| AnyCnameRecord
|
||||||
|
| AnyMxRecord
|
||||||
|
| AnyNaptrRecord
|
||||||
|
| AnyNsRecord
|
||||||
|
| AnyPtrRecord
|
||||||
|
| AnySoaRecord
|
||||||
|
| AnySrvRecord
|
||||||
|
| AnyTxtRecord;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||||
|
* of the resource records. The `callback` function has arguments `(err, records)`. When successful, `records` will be an array of resource
|
||||||
|
* records. The type and structure of individual results varies based on `rrtype`:
|
||||||
|
*
|
||||||
|
* <omitted>
|
||||||
|
*
|
||||||
|
* On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object,
|
||||||
|
* where `err.code` is one of the `DNS error codes`.
|
||||||
|
* @since v0.1.27
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
* @param [rrtype='A'] Resource record type.
|
||||||
|
*/
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "A",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "AAAA",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "ANY",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "CNAME",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "MX",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "NAPTR",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "NS",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "PTR",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "SOA",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "SRV",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: "TXT",
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: string,
|
||||||
|
callback: (
|
||||||
|
err: NodeJS.ErrnoException | null,
|
||||||
|
addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
|
||||||
|
) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolve {
|
||||||
|
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||||
|
function __promisify__(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: string,
|
||||||
|
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||||
|
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||||
|
* @since v0.1.16
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
*/
|
||||||
|
export function resolve4(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve4(
|
||||||
|
hostname: string,
|
||||||
|
options: ResolveWithTtlOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve4(
|
||||||
|
hostname: string,
|
||||||
|
options: ResolveOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolve4 {
|
||||||
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||||
|
* will contain an array of IPv6 addresses.
|
||||||
|
* @since v0.1.16
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
*/
|
||||||
|
export function resolve6(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve6(
|
||||||
|
hostname: string,
|
||||||
|
options: ResolveWithTtlOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
||||||
|
): void;
|
||||||
|
export function resolve6(
|
||||||
|
hostname: string,
|
||||||
|
options: ResolveOptions,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolve6 {
|
||||||
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||||
|
* will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`).
|
||||||
|
* @since v0.3.2
|
||||||
|
*/
|
||||||
|
export function resolveCname(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveCname {
|
||||||
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||||
|
* will contain an array of certification authority authorization records
|
||||||
|
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
||||||
|
* @since v15.0.0, v14.17.0
|
||||||
|
*/
|
||||||
|
export function resolveCaa(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveCaa {
|
||||||
|
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||||
|
* contain an array of objects containing both a `priority` and `exchange` property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||||
|
* @since v0.1.27
|
||||||
|
*/
|
||||||
|
export function resolveMx(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveMx {
|
||||||
|
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of
|
||||||
|
* objects with the following properties:
|
||||||
|
*
|
||||||
|
* * `flags`
|
||||||
|
* * `service`
|
||||||
|
* * `regexp`
|
||||||
|
* * `replacement`
|
||||||
|
* * `order`
|
||||||
|
* * `preference`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* flags: 's',
|
||||||
|
* service: 'SIP+D2U',
|
||||||
|
* regexp: '',
|
||||||
|
* replacement: '_sip._udp.example.com',
|
||||||
|
* order: 30,
|
||||||
|
* preference: 100
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.9.12
|
||||||
|
*/
|
||||||
|
export function resolveNaptr(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveNaptr {
|
||||||
|
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||||
|
* contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||||
|
* @since v0.1.90
|
||||||
|
*/
|
||||||
|
export function resolveNs(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveNs {
|
||||||
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||||
|
* be an array of strings containing the reply records.
|
||||||
|
* @since v6.0.0
|
||||||
|
*/
|
||||||
|
export function resolvePtr(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolvePtr {
|
||||||
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||||
|
* the `hostname`. The `address` argument passed to the `callback` function will
|
||||||
|
* be an object with the following properties:
|
||||||
|
*
|
||||||
|
* * `nsname`
|
||||||
|
* * `hostmaster`
|
||||||
|
* * `serial`
|
||||||
|
* * `refresh`
|
||||||
|
* * `retry`
|
||||||
|
* * `expire`
|
||||||
|
* * `minttl`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* nsname: 'ns.example.com',
|
||||||
|
* hostmaster: 'root.example.com',
|
||||||
|
* serial: 2013101809,
|
||||||
|
* refresh: 10000,
|
||||||
|
* retry: 2400,
|
||||||
|
* expire: 604800,
|
||||||
|
* minttl: 3600
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.11.10
|
||||||
|
*/
|
||||||
|
export function resolveSoa(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveSoa {
|
||||||
|
function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||||
|
* be an array of objects with the following properties:
|
||||||
|
*
|
||||||
|
* * `priority`
|
||||||
|
* * `weight`
|
||||||
|
* * `port`
|
||||||
|
* * `name`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* priority: 10,
|
||||||
|
* weight: 5,
|
||||||
|
* port: 21223,
|
||||||
|
* name: 'service.example.com'
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.1.27
|
||||||
|
*/
|
||||||
|
export function resolveSrv(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveSrv {
|
||||||
|
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `records` argument passed to the `callback` function is a
|
||||||
|
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||||
|
* one record. Depending on the use case, these could be either joined together or
|
||||||
|
* treated separately.
|
||||||
|
* @since v0.1.27
|
||||||
|
*/
|
||||||
|
export function resolveTxt(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveTxt {
|
||||||
|
function __promisify__(hostname: string): Promise<string[][]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||||
|
* The `ret` argument passed to the `callback` function will be an array containing
|
||||||
|
* various types of records. Each object has a property `type` that indicates the
|
||||||
|
* type of the current record. And depending on the `type`, additional properties
|
||||||
|
* will be present on the object:
|
||||||
|
*
|
||||||
|
* <omitted>
|
||||||
|
*
|
||||||
|
* Here is an example of the `ret` object passed to the callback:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
||||||
|
* { type: 'CNAME', value: 'example.com' },
|
||||||
|
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
||||||
|
* { type: 'NS', value: 'ns1.example.com' },
|
||||||
|
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
||||||
|
* { type: 'SOA',
|
||||||
|
* nsname: 'ns1.example.com',
|
||||||
|
* hostmaster: 'admin.example.com',
|
||||||
|
* serial: 156696742,
|
||||||
|
* refresh: 900,
|
||||||
|
* retry: 900,
|
||||||
|
* expire: 1800,
|
||||||
|
* minttl: 60 } ]
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* DNS server operators may choose not to respond to `ANY` queries. It may be better to call individual methods like {@link resolve4}, {@link resolveMx}, and so on. For more details, see
|
||||||
|
* [RFC 8482](https://tools.ietf.org/html/rfc8482).
|
||||||
|
*/
|
||||||
|
export function resolveAny(
|
||||||
|
hostname: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
||||||
|
): void;
|
||||||
|
export namespace resolveAny {
|
||||||
|
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||||
|
* array of host names.
|
||||||
|
*
|
||||||
|
* On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object, where `err.code` is
|
||||||
|
* one of the [DNS error codes](https://nodejs.org/docs/latest-v22.x/api/dns.html#error-codes).
|
||||||
|
* @since v0.1.16
|
||||||
|
*/
|
||||||
|
export function reverse(
|
||||||
|
ip: string,
|
||||||
|
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||||
|
* The value could be:
|
||||||
|
*
|
||||||
|
* * `ipv4first`: for `order` defaulting to `ipv4first`.
|
||||||
|
* * `ipv6first`: for `order` defaulting to `ipv6first`.
|
||||||
|
* * `verbatim`: for `order` defaulting to `verbatim`.
|
||||||
|
* @since v18.17.0
|
||||||
|
*/
|
||||||
|
export function getDefaultResultOrder(): "ipv4first" | "ipv6first" | "verbatim";
|
||||||
|
/**
|
||||||
|
* Sets the IP address and port of servers to be used when performing DNS
|
||||||
|
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
||||||
|
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* dns.setServers([
|
||||||
|
* '4.4.4.4',
|
||||||
|
* '[2001:4860:4860::8888]',
|
||||||
|
* '4.4.4.4:1053',
|
||||||
|
* '[2001:4860:4860::8888]:1053',
|
||||||
|
* ]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* An error will be thrown if an invalid address is provided.
|
||||||
|
*
|
||||||
|
* The `dns.setServers()` method must not be called while a DNS query is in
|
||||||
|
* progress.
|
||||||
|
*
|
||||||
|
* The {@link setServers} method affects only {@link resolve}, `dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
|
||||||
|
*
|
||||||
|
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
||||||
|
* That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
||||||
|
* subsequent servers provided. Fallback DNS servers will only be used if the
|
||||||
|
* earlier ones time out or result in some other error.
|
||||||
|
* @since v0.11.3
|
||||||
|
* @param servers array of [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952#section-6) formatted addresses
|
||||||
|
*/
|
||||||
|
export function setServers(servers: readonly string[]): void;
|
||||||
|
/**
|
||||||
|
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
||||||
|
* that are currently configured for DNS resolution. A string will include a port
|
||||||
|
* section if a custom port is used.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* [
|
||||||
|
* '4.4.4.4',
|
||||||
|
* '2001:4860:4860::8888',
|
||||||
|
* '4.4.4.4:1053',
|
||||||
|
* '[2001:4860:4860::8888]:1053',
|
||||||
|
* ]
|
||||||
|
* ```
|
||||||
|
* @since v0.11.3
|
||||||
|
*/
|
||||||
|
export function getServers(): string[];
|
||||||
|
/**
|
||||||
|
* Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||||
|
* The value could be:
|
||||||
|
*
|
||||||
|
* * `ipv4first`: sets default `order` to `ipv4first`.
|
||||||
|
* * `ipv6first`: sets default `order` to `ipv6first`.
|
||||||
|
* * `verbatim`: sets default `order` to `verbatim`.
|
||||||
|
*
|
||||||
|
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
|
||||||
|
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
|
||||||
|
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
|
||||||
|
* thread won't affect the default dns orders in workers.
|
||||||
|
* @since v16.4.0, v14.18.0
|
||||||
|
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
||||||
|
*/
|
||||||
|
export function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
||||||
|
// Error codes
|
||||||
|
export const NODATA: "ENODATA";
|
||||||
|
export const FORMERR: "EFORMERR";
|
||||||
|
export const SERVFAIL: "ESERVFAIL";
|
||||||
|
export const NOTFOUND: "ENOTFOUND";
|
||||||
|
export const NOTIMP: "ENOTIMP";
|
||||||
|
export const REFUSED: "EREFUSED";
|
||||||
|
export const BADQUERY: "EBADQUERY";
|
||||||
|
export const BADNAME: "EBADNAME";
|
||||||
|
export const BADFAMILY: "EBADFAMILY";
|
||||||
|
export const BADRESP: "EBADRESP";
|
||||||
|
export const CONNREFUSED: "ECONNREFUSED";
|
||||||
|
export const TIMEOUT: "ETIMEOUT";
|
||||||
|
export const EOF: "EOF";
|
||||||
|
export const FILE: "EFILE";
|
||||||
|
export const NOMEM: "ENOMEM";
|
||||||
|
export const DESTRUCTION: "EDESTRUCTION";
|
||||||
|
export const BADSTR: "EBADSTR";
|
||||||
|
export const BADFLAGS: "EBADFLAGS";
|
||||||
|
export const NONAME: "ENONAME";
|
||||||
|
export const BADHINTS: "EBADHINTS";
|
||||||
|
export const NOTINITIALIZED: "ENOTINITIALIZED";
|
||||||
|
export const LOADIPHLPAPI: "ELOADIPHLPAPI";
|
||||||
|
export const ADDRGETNETWORKPARAMS: "EADDRGETNETWORKPARAMS";
|
||||||
|
export const CANCELLED: "ECANCELLED";
|
||||||
|
export interface ResolverOptions {
|
||||||
|
/**
|
||||||
|
* Query timeout in milliseconds, or `-1` to use the default timeout.
|
||||||
|
*/
|
||||||
|
timeout?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The number of tries the resolver will try contacting each name server before giving up.
|
||||||
|
* @default 4
|
||||||
|
*/
|
||||||
|
tries?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* An independent resolver for DNS requests.
|
||||||
|
*
|
||||||
|
* Creating a new resolver uses the default server settings. Setting
|
||||||
|
* the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnssetserversservers) does not affect
|
||||||
|
* other resolvers:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Resolver } from 'node:dns';
|
||||||
|
* const resolver = new Resolver();
|
||||||
|
* resolver.setServers(['4.4.4.4']);
|
||||||
|
*
|
||||||
|
* // This request will use the server at 4.4.4.4, independent of global settings.
|
||||||
|
* resolver.resolve4('example.org', (err, addresses) => {
|
||||||
|
* // ...
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The following methods from the `node:dns` module are available:
|
||||||
|
*
|
||||||
|
* * `resolver.getServers()`
|
||||||
|
* * `resolver.resolve()`
|
||||||
|
* * `resolver.resolve4()`
|
||||||
|
* * `resolver.resolve6()`
|
||||||
|
* * `resolver.resolveAny()`
|
||||||
|
* * `resolver.resolveCaa()`
|
||||||
|
* * `resolver.resolveCname()`
|
||||||
|
* * `resolver.resolveMx()`
|
||||||
|
* * `resolver.resolveNaptr()`
|
||||||
|
* * `resolver.resolveNs()`
|
||||||
|
* * `resolver.resolvePtr()`
|
||||||
|
* * `resolver.resolveSoa()`
|
||||||
|
* * `resolver.resolveSrv()`
|
||||||
|
* * `resolver.resolveTxt()`
|
||||||
|
* * `resolver.reverse()`
|
||||||
|
* * `resolver.setServers()`
|
||||||
|
* @since v8.3.0
|
||||||
|
*/
|
||||||
|
export class Resolver {
|
||||||
|
constructor(options?: ResolverOptions);
|
||||||
|
/**
|
||||||
|
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
||||||
|
* callbacks will be called with an error with code `ECANCELLED`.
|
||||||
|
* @since v8.3.0
|
||||||
|
*/
|
||||||
|
cancel(): void;
|
||||||
|
getServers: typeof getServers;
|
||||||
|
resolve: typeof resolve;
|
||||||
|
resolve4: typeof resolve4;
|
||||||
|
resolve6: typeof resolve6;
|
||||||
|
resolveAny: typeof resolveAny;
|
||||||
|
resolveCaa: typeof resolveCaa;
|
||||||
|
resolveCname: typeof resolveCname;
|
||||||
|
resolveMx: typeof resolveMx;
|
||||||
|
resolveNaptr: typeof resolveNaptr;
|
||||||
|
resolveNs: typeof resolveNs;
|
||||||
|
resolvePtr: typeof resolvePtr;
|
||||||
|
resolveSoa: typeof resolveSoa;
|
||||||
|
resolveSrv: typeof resolveSrv;
|
||||||
|
resolveTxt: typeof resolveTxt;
|
||||||
|
reverse: typeof reverse;
|
||||||
|
/**
|
||||||
|
* The resolver instance will send its requests from the specified IP address.
|
||||||
|
* This allows programs to specify outbound interfaces when used on multi-homed
|
||||||
|
* systems.
|
||||||
|
*
|
||||||
|
* If a v4 or v6 address is not specified, it is set to the default and the
|
||||||
|
* operating system will choose a local address automatically.
|
||||||
|
*
|
||||||
|
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
||||||
|
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
||||||
|
* The `rrtype` of resolution requests has no impact on the local address used.
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
||||||
|
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
||||||
|
*/
|
||||||
|
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||||
|
setServers: typeof setServers;
|
||||||
|
}
|
||||||
|
export { dnsPromises as promises };
|
||||||
|
}
|
||||||
|
declare module "node:dns" {
|
||||||
|
export * from "dns";
|
||||||
|
}
|
476
websocket_server/node_modules/.ignored/@types/node/dns/promises.d.ts
generated
vendored
Normal file
476
websocket_server/node_modules/.ignored/@types/node/dns/promises.d.ts
generated
vendored
Normal file
@ -0,0 +1,476 @@
|
|||||||
|
/**
|
||||||
|
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
||||||
|
* that return `Promise` objects rather than using callbacks. The API is accessible
|
||||||
|
* via `import { promises as dnsPromises } from 'node:dns'` or `import dnsPromises from 'node:dns/promises'`.
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
declare module "dns/promises" {
|
||||||
|
import {
|
||||||
|
AnyRecord,
|
||||||
|
CaaRecord,
|
||||||
|
LookupAddress,
|
||||||
|
LookupAllOptions,
|
||||||
|
LookupOneOptions,
|
||||||
|
LookupOptions,
|
||||||
|
MxRecord,
|
||||||
|
NaptrRecord,
|
||||||
|
RecordWithTtl,
|
||||||
|
ResolveOptions,
|
||||||
|
ResolverOptions,
|
||||||
|
ResolveWithTtlOptions,
|
||||||
|
SoaRecord,
|
||||||
|
SrvRecord,
|
||||||
|
} from "node:dns";
|
||||||
|
/**
|
||||||
|
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
||||||
|
* that are currently configured for DNS resolution. A string will include a port
|
||||||
|
* section if a custom port is used.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* [
|
||||||
|
* '4.4.4.4',
|
||||||
|
* '2001:4860:4860::8888',
|
||||||
|
* '4.4.4.4:1053',
|
||||||
|
* '[2001:4860:4860::8888]:1053',
|
||||||
|
* ]
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function getServers(): string[];
|
||||||
|
/**
|
||||||
|
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
||||||
|
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
||||||
|
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
||||||
|
* and IPv6 addresses are both returned if found.
|
||||||
|
*
|
||||||
|
* With the `all` option set to `true`, the `Promise` is resolved with `addresses` being an array of objects with the properties `address` and `family`.
|
||||||
|
*
|
||||||
|
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.
|
||||||
|
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||||
|
* the host name does not exist but also when the lookup fails in other ways
|
||||||
|
* such as no available file descriptors.
|
||||||
|
*
|
||||||
|
* [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options) does not necessarily have anything to do with the DNS
|
||||||
|
* protocol. The implementation uses an operating system facility that can
|
||||||
|
* associate names with addresses and vice versa. This implementation can have
|
||||||
|
* subtle but important consequences on the behavior of any Node.js program. Please
|
||||||
|
* take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations) before
|
||||||
|
* using `dnsPromises.lookup()`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dns from 'node:dns';
|
||||||
|
* const dnsPromises = dns.promises;
|
||||||
|
* const options = {
|
||||||
|
* family: 6,
|
||||||
|
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* dnsPromises.lookup('example.com', options).then((result) => {
|
||||||
|
* console.log('address: %j family: IPv%s', result.address, result.family);
|
||||||
|
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // When options.all is true, the result will be an Array.
|
||||||
|
* options.all = true;
|
||||||
|
* dnsPromises.lookup('example.com', options).then((result) => {
|
||||||
|
* console.log('addresses: %j', result);
|
||||||
|
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
||||||
|
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
||||||
|
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||||
|
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||||
|
function lookup(hostname: string): Promise<LookupAddress>;
|
||||||
|
/**
|
||||||
|
* Resolves the given `address` and `port` into a host name and service using
|
||||||
|
* the operating system's underlying `getnameinfo` implementation.
|
||||||
|
*
|
||||||
|
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
||||||
|
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.
|
||||||
|
*
|
||||||
|
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import dnsPromises from 'node:dns';
|
||||||
|
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
||||||
|
* console.log(result.hostname, result.service);
|
||||||
|
* // Prints: localhost ssh
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function lookupService(
|
||||||
|
address: string,
|
||||||
|
port: number,
|
||||||
|
): Promise<{
|
||||||
|
hostname: string;
|
||||||
|
service: string;
|
||||||
|
}>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||||
|
* of the resource records. When successful, the `Promise` is resolved with an
|
||||||
|
* array of resource records. The type and structure of individual results vary
|
||||||
|
* based on `rrtype`:
|
||||||
|
*
|
||||||
|
* <omitted>
|
||||||
|
*
|
||||||
|
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`
|
||||||
|
* is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
|
||||||
|
* @since v10.6.0
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
* @param [rrtype='A'] Resource record type.
|
||||||
|
*/
|
||||||
|
function resolve(hostname: string): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||||
|
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||||
|
function resolve(
|
||||||
|
hostname: string,
|
||||||
|
rrtype: string,
|
||||||
|
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4
|
||||||
|
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||||
|
* @since v10.6.0
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
*/
|
||||||
|
function resolve4(hostname: string): Promise<string[]>;
|
||||||
|
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv6
|
||||||
|
* addresses.
|
||||||
|
* @since v10.6.0
|
||||||
|
* @param hostname Host name to resolve.
|
||||||
|
*/
|
||||||
|
function resolve6(hostname: string): Promise<string[]>;
|
||||||
|
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||||
|
* On success, the `Promise` is resolved with an array containing various types of
|
||||||
|
* records. Each object has a property `type` that indicates the type of the
|
||||||
|
* current record. And depending on the `type`, additional properties will be
|
||||||
|
* present on the object:
|
||||||
|
*
|
||||||
|
* <omitted>
|
||||||
|
*
|
||||||
|
* Here is an example of the result object:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
||||||
|
* { type: 'CNAME', value: 'example.com' },
|
||||||
|
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
||||||
|
* { type: 'NS', value: 'ns1.example.com' },
|
||||||
|
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
||||||
|
* { type: 'SOA',
|
||||||
|
* nsname: 'ns1.example.com',
|
||||||
|
* hostmaster: 'admin.example.com',
|
||||||
|
* serial: 156696742,
|
||||||
|
* refresh: 900,
|
||||||
|
* retry: 900,
|
||||||
|
* expire: 1800,
|
||||||
|
* minttl: 60 } ]
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
||||||
|
* the `Promise` is resolved with an array of objects containing available
|
||||||
|
* certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
|
||||||
|
* @since v15.0.0, v14.17.0
|
||||||
|
*/
|
||||||
|
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
||||||
|
* the `Promise` is resolved with an array of canonical name records available for
|
||||||
|
* the `hostname` (e.g. `['bar.example.com']`).
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveCname(hostname: string): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects
|
||||||
|
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. On success, the `Promise` is resolved with an array
|
||||||
|
* of objects with the following properties:
|
||||||
|
*
|
||||||
|
* * `flags`
|
||||||
|
* * `service`
|
||||||
|
* * `regexp`
|
||||||
|
* * `replacement`
|
||||||
|
* * `order`
|
||||||
|
* * `preference`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* flags: 's',
|
||||||
|
* service: 'SIP+D2U',
|
||||||
|
* regexp: '',
|
||||||
|
* replacement: '_sip._udp.example.com',
|
||||||
|
* order: 30,
|
||||||
|
* preference: 100
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. On success, the `Promise` is resolved with an array of name server
|
||||||
|
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveNs(hostname: string): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of strings
|
||||||
|
* containing the reply records.
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolvePtr(hostname: string): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||||
|
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
||||||
|
* following properties:
|
||||||
|
*
|
||||||
|
* * `nsname`
|
||||||
|
* * `hostmaster`
|
||||||
|
* * `serial`
|
||||||
|
* * `refresh`
|
||||||
|
* * `retry`
|
||||||
|
* * `expire`
|
||||||
|
* * `minttl`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* nsname: 'ns.example.com',
|
||||||
|
* hostmaster: 'root.example.com',
|
||||||
|
* serial: 2013101809,
|
||||||
|
* refresh: 10000,
|
||||||
|
* retry: 2400,
|
||||||
|
* expire: 604800,
|
||||||
|
* minttl: 3600
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects with
|
||||||
|
* the following properties:
|
||||||
|
*
|
||||||
|
* * `priority`
|
||||||
|
* * `weight`
|
||||||
|
* * `port`
|
||||||
|
* * `name`
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* priority: 10,
|
||||||
|
* weight: 5,
|
||||||
|
* port: 21223,
|
||||||
|
* name: 'service.example.com'
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||||
|
/**
|
||||||
|
* Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
||||||
|
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||||
|
* one record. Depending on the use case, these could be either joined together or
|
||||||
|
* treated separately.
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function resolveTxt(hostname: string): Promise<string[][]>;
|
||||||
|
/**
|
||||||
|
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||||
|
* array of host names.
|
||||||
|
*
|
||||||
|
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`
|
||||||
|
* is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
function reverse(ip: string): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Get the default value for `verbatim` in {@link lookup} and [dnsPromises.lookup()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||||
|
* The value could be:
|
||||||
|
*
|
||||||
|
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
||||||
|
* * `verbatim`: for `verbatim` defaulting to `true`.
|
||||||
|
* @since v20.1.0
|
||||||
|
*/
|
||||||
|
function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
||||||
|
/**
|
||||||
|
* Sets the IP address and port of servers to be used when performing DNS
|
||||||
|
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
||||||
|
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* dnsPromises.setServers([
|
||||||
|
* '4.4.4.4',
|
||||||
|
* '[2001:4860:4860::8888]',
|
||||||
|
* '4.4.4.4:1053',
|
||||||
|
* '[2001:4860:4860::8888]:1053',
|
||||||
|
* ]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* An error will be thrown if an invalid address is provided.
|
||||||
|
*
|
||||||
|
* The `dnsPromises.setServers()` method must not be called while a DNS query is in
|
||||||
|
* progress.
|
||||||
|
*
|
||||||
|
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
||||||
|
* That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
||||||
|
* subsequent servers provided. Fallback DNS servers will only be used if the
|
||||||
|
* earlier ones time out or result in some other error.
|
||||||
|
* @since v10.6.0
|
||||||
|
* @param servers array of `RFC 5952` formatted addresses
|
||||||
|
*/
|
||||||
|
function setServers(servers: readonly string[]): void;
|
||||||
|
/**
|
||||||
|
* Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:
|
||||||
|
*
|
||||||
|
* * `ipv4first`: sets default `order` to `ipv4first`.
|
||||||
|
* * `ipv6first`: sets default `order` to `ipv6first`.
|
||||||
|
* * `verbatim`: sets default `order` to `verbatim`.
|
||||||
|
*
|
||||||
|
* The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
||||||
|
* have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
|
||||||
|
* When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
||||||
|
* from the main thread won't affect the default dns orders in workers.
|
||||||
|
* @since v16.4.0, v14.18.0
|
||||||
|
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
||||||
|
*/
|
||||||
|
function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
||||||
|
// Error codes
|
||||||
|
const NODATA: "ENODATA";
|
||||||
|
const FORMERR: "EFORMERR";
|
||||||
|
const SERVFAIL: "ESERVFAIL";
|
||||||
|
const NOTFOUND: "ENOTFOUND";
|
||||||
|
const NOTIMP: "ENOTIMP";
|
||||||
|
const REFUSED: "EREFUSED";
|
||||||
|
const BADQUERY: "EBADQUERY";
|
||||||
|
const BADNAME: "EBADNAME";
|
||||||
|
const BADFAMILY: "EBADFAMILY";
|
||||||
|
const BADRESP: "EBADRESP";
|
||||||
|
const CONNREFUSED: "ECONNREFUSED";
|
||||||
|
const TIMEOUT: "ETIMEOUT";
|
||||||
|
const EOF: "EOF";
|
||||||
|
const FILE: "EFILE";
|
||||||
|
const NOMEM: "ENOMEM";
|
||||||
|
const DESTRUCTION: "EDESTRUCTION";
|
||||||
|
const BADSTR: "EBADSTR";
|
||||||
|
const BADFLAGS: "EBADFLAGS";
|
||||||
|
const NONAME: "ENONAME";
|
||||||
|
const BADHINTS: "EBADHINTS";
|
||||||
|
const NOTINITIALIZED: "ENOTINITIALIZED";
|
||||||
|
const LOADIPHLPAPI: "ELOADIPHLPAPI";
|
||||||
|
const ADDRGETNETWORKPARAMS: "EADDRGETNETWORKPARAMS";
|
||||||
|
const CANCELLED: "ECANCELLED";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An independent resolver for DNS requests.
|
||||||
|
*
|
||||||
|
* Creating a new resolver uses the default server settings. Setting
|
||||||
|
* the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetserversservers) does not affect
|
||||||
|
* other resolvers:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { promises } from 'node:dns';
|
||||||
|
* const resolver = new promises.Resolver();
|
||||||
|
* resolver.setServers(['4.4.4.4']);
|
||||||
|
*
|
||||||
|
* // This request will use the server at 4.4.4.4, independent of global settings.
|
||||||
|
* resolver.resolve4('example.org').then((addresses) => {
|
||||||
|
* // ...
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Alternatively, the same code can be written using async-await style.
|
||||||
|
* (async function() {
|
||||||
|
* const addresses = await resolver.resolve4('example.org');
|
||||||
|
* })();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The following methods from the `dnsPromises` API are available:
|
||||||
|
*
|
||||||
|
* * `resolver.getServers()`
|
||||||
|
* * `resolver.resolve()`
|
||||||
|
* * `resolver.resolve4()`
|
||||||
|
* * `resolver.resolve6()`
|
||||||
|
* * `resolver.resolveAny()`
|
||||||
|
* * `resolver.resolveCaa()`
|
||||||
|
* * `resolver.resolveCname()`
|
||||||
|
* * `resolver.resolveMx()`
|
||||||
|
* * `resolver.resolveNaptr()`
|
||||||
|
* * `resolver.resolveNs()`
|
||||||
|
* * `resolver.resolvePtr()`
|
||||||
|
* * `resolver.resolveSoa()`
|
||||||
|
* * `resolver.resolveSrv()`
|
||||||
|
* * `resolver.resolveTxt()`
|
||||||
|
* * `resolver.reverse()`
|
||||||
|
* * `resolver.setServers()`
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
class Resolver {
|
||||||
|
constructor(options?: ResolverOptions);
|
||||||
|
/**
|
||||||
|
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
||||||
|
* callbacks will be called with an error with code `ECANCELLED`.
|
||||||
|
* @since v8.3.0
|
||||||
|
*/
|
||||||
|
cancel(): void;
|
||||||
|
getServers: typeof getServers;
|
||||||
|
resolve: typeof resolve;
|
||||||
|
resolve4: typeof resolve4;
|
||||||
|
resolve6: typeof resolve6;
|
||||||
|
resolveAny: typeof resolveAny;
|
||||||
|
resolveCaa: typeof resolveCaa;
|
||||||
|
resolveCname: typeof resolveCname;
|
||||||
|
resolveMx: typeof resolveMx;
|
||||||
|
resolveNaptr: typeof resolveNaptr;
|
||||||
|
resolveNs: typeof resolveNs;
|
||||||
|
resolvePtr: typeof resolvePtr;
|
||||||
|
resolveSoa: typeof resolveSoa;
|
||||||
|
resolveSrv: typeof resolveSrv;
|
||||||
|
resolveTxt: typeof resolveTxt;
|
||||||
|
reverse: typeof reverse;
|
||||||
|
/**
|
||||||
|
* The resolver instance will send its requests from the specified IP address.
|
||||||
|
* This allows programs to specify outbound interfaces when used on multi-homed
|
||||||
|
* systems.
|
||||||
|
*
|
||||||
|
* If a v4 or v6 address is not specified, it is set to the default and the
|
||||||
|
* operating system will choose a local address automatically.
|
||||||
|
*
|
||||||
|
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
||||||
|
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
||||||
|
* The `rrtype` of resolution requests has no impact on the local address used.
|
||||||
|
* @since v15.1.0, v14.17.0
|
||||||
|
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
||||||
|
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
||||||
|
*/
|
||||||
|
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||||
|
setServers: typeof setServers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:dns/promises" {
|
||||||
|
export * from "dns/promises";
|
||||||
|
}
|
124
websocket_server/node_modules/.ignored/@types/node/dom-events.d.ts
generated
vendored
Normal file
124
websocket_server/node_modules/.ignored/@types/node/dom-events.d.ts
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
export {}; // Don't export anything!
|
||||||
|
|
||||||
|
//// DOM-like Events
|
||||||
|
// NB: The Event / EventTarget / EventListener implementations below were copied
|
||||||
|
// from lib.dom.d.ts, then edited to reflect Node's documentation at
|
||||||
|
// https://nodejs.org/api/events.html#class-eventtarget.
|
||||||
|
// Please read that link to understand important implementation differences.
|
||||||
|
|
||||||
|
// This conditional type will be the existing global Event in a browser, or
|
||||||
|
// the copy below in a Node environment.
|
||||||
|
type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {}
|
||||||
|
: {
|
||||||
|
/** This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
readonly bubbles: boolean;
|
||||||
|
/** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
cancelBubble: () => void;
|
||||||
|
/** True if the event was created with the cancelable option */
|
||||||
|
readonly cancelable: boolean;
|
||||||
|
/** This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
readonly composed: boolean;
|
||||||
|
/** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
composedPath(): [EventTarget?];
|
||||||
|
/** Alias for event.target. */
|
||||||
|
readonly currentTarget: EventTarget | null;
|
||||||
|
/** Is true if cancelable is true and event.preventDefault() has been called. */
|
||||||
|
readonly defaultPrevented: boolean;
|
||||||
|
/** This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
readonly eventPhase: 0 | 2;
|
||||||
|
/** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
|
||||||
|
readonly isTrusted: boolean;
|
||||||
|
/** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
|
||||||
|
preventDefault(): void;
|
||||||
|
/** This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
returnValue: boolean;
|
||||||
|
/** Alias for event.target. */
|
||||||
|
readonly srcElement: EventTarget | null;
|
||||||
|
/** Stops the invocation of event listeners after the current one completes. */
|
||||||
|
stopImmediatePropagation(): void;
|
||||||
|
/** This is not used in Node.js and is provided purely for completeness. */
|
||||||
|
stopPropagation(): void;
|
||||||
|
/** The `EventTarget` dispatching the event */
|
||||||
|
readonly target: EventTarget | null;
|
||||||
|
/** The millisecond timestamp when the Event object was created. */
|
||||||
|
readonly timeStamp: number;
|
||||||
|
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
|
||||||
|
readonly type: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// See comment above explaining conditional type
|
||||||
|
type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {}
|
||||||
|
: {
|
||||||
|
/**
|
||||||
|
* Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
|
||||||
|
*
|
||||||
|
* If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
|
||||||
|
*
|
||||||
|
* The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
|
||||||
|
* Specifically, the `capture` option is used as part of the key when registering a `listener`.
|
||||||
|
* Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
|
||||||
|
*/
|
||||||
|
addEventListener(
|
||||||
|
type: string,
|
||||||
|
listener: EventListener | EventListenerObject,
|
||||||
|
options?: AddEventListenerOptions | boolean,
|
||||||
|
): void;
|
||||||
|
/** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
|
||||||
|
dispatchEvent(event: Event): boolean;
|
||||||
|
/** Removes the event listener in target's event listener list with the same type, callback, and options. */
|
||||||
|
removeEventListener(
|
||||||
|
type: string,
|
||||||
|
listener: EventListener | EventListenerObject,
|
||||||
|
options?: EventListenerOptions | boolean,
|
||||||
|
): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface EventInit {
|
||||||
|
bubbles?: boolean;
|
||||||
|
cancelable?: boolean;
|
||||||
|
composed?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EventListenerOptions {
|
||||||
|
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||||
|
capture?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AddEventListenerOptions extends EventListenerOptions {
|
||||||
|
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||||
|
once?: boolean;
|
||||||
|
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||||
|
passive?: boolean;
|
||||||
|
/** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
|
||||||
|
signal?: AbortSignal;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EventListener {
|
||||||
|
(evt: Event): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EventListenerObject {
|
||||||
|
handleEvent(object: Event): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
import {} from "events"; // Make this an ambient declaration
|
||||||
|
declare global {
|
||||||
|
/** An event which takes place in the DOM. */
|
||||||
|
interface Event extends __Event {}
|
||||||
|
var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
|
||||||
|
: {
|
||||||
|
prototype: __Event;
|
||||||
|
new(type: string, eventInitDict?: EventInit): __Event;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EventTarget is a DOM interface implemented by objects that can
|
||||||
|
* receive events and may have listeners for them.
|
||||||
|
*/
|
||||||
|
interface EventTarget extends __EventTarget {}
|
||||||
|
var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
|
||||||
|
: {
|
||||||
|
prototype: __EventTarget;
|
||||||
|
new(): __EventTarget;
|
||||||
|
};
|
||||||
|
}
|
170
websocket_server/node_modules/.ignored/@types/node/domain.d.ts
generated
vendored
Normal file
170
websocket_server/node_modules/.ignored/@types/node/domain.d.ts
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
* **This module is pending deprecation.** Once a replacement API has been
|
||||||
|
* finalized, this module will be fully deprecated. Most developers should
|
||||||
|
* **not** have cause to use this module. Users who absolutely must have
|
||||||
|
* the functionality that domains provide may rely on it for the time being
|
||||||
|
* but should expect to have to migrate to a different solution
|
||||||
|
* in the future.
|
||||||
|
*
|
||||||
|
* Domains provide a way to handle multiple different IO operations as a
|
||||||
|
* single group. If any of the event emitters or callbacks registered to a
|
||||||
|
* domain emit an `'error'` event, or throw an error, then the domain object
|
||||||
|
* will be notified, rather than losing the context of the error in the `process.on('uncaughtException')` handler, or causing the program to
|
||||||
|
* exit immediately with an error code.
|
||||||
|
* @deprecated Since v1.4.2 - Deprecated
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/domain.js)
|
||||||
|
*/
|
||||||
|
declare module "domain" {
|
||||||
|
import EventEmitter = require("node:events");
|
||||||
|
/**
|
||||||
|
* The `Domain` class encapsulates the functionality of routing errors and
|
||||||
|
* uncaught exceptions to the active `Domain` object.
|
||||||
|
*
|
||||||
|
* To handle the errors that it catches, listen to its `'error'` event.
|
||||||
|
*/
|
||||||
|
class Domain extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* An array of timers and event emitters that have been explicitly added
|
||||||
|
* to the domain.
|
||||||
|
*/
|
||||||
|
members: Array<EventEmitter | NodeJS.Timer>;
|
||||||
|
/**
|
||||||
|
* The `enter()` method is plumbing used by the `run()`, `bind()`, and `intercept()` methods to set the active domain. It sets `domain.active` and `process.domain` to the domain, and implicitly
|
||||||
|
* pushes the domain onto the domain
|
||||||
|
* stack managed by the domain module (see {@link exit} for details on the
|
||||||
|
* domain stack). The call to `enter()` delimits the beginning of a chain of
|
||||||
|
* asynchronous calls and I/O operations bound to a domain.
|
||||||
|
*
|
||||||
|
* Calling `enter()` changes only the active domain, and does not alter the domain
|
||||||
|
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
||||||
|
* single domain.
|
||||||
|
*/
|
||||||
|
enter(): void;
|
||||||
|
/**
|
||||||
|
* The `exit()` method exits the current domain, popping it off the domain stack.
|
||||||
|
* Any time execution is going to switch to the context of a different chain of
|
||||||
|
* asynchronous calls, it's important to ensure that the current domain is exited.
|
||||||
|
* The call to `exit()` delimits either the end of or an interruption to the chain
|
||||||
|
* of asynchronous calls and I/O operations bound to a domain.
|
||||||
|
*
|
||||||
|
* If there are multiple, nested domains bound to the current execution context, `exit()` will exit any domains nested within this domain.
|
||||||
|
*
|
||||||
|
* Calling `exit()` changes only the active domain, and does not alter the domain
|
||||||
|
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
||||||
|
* single domain.
|
||||||
|
*/
|
||||||
|
exit(): void;
|
||||||
|
/**
|
||||||
|
* Run the supplied function in the context of the domain, implicitly
|
||||||
|
* binding all event emitters, timers, and low-level requests that are
|
||||||
|
* created in that context. Optionally, arguments can be passed to
|
||||||
|
* the function.
|
||||||
|
*
|
||||||
|
* This is the most basic way to use a domain.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import domain from 'node:domain';
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
* const d = domain.create();
|
||||||
|
* d.on('error', (er) => {
|
||||||
|
* console.error('Caught error!', er);
|
||||||
|
* });
|
||||||
|
* d.run(() => {
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* setTimeout(() => { // Simulating some various async stuff
|
||||||
|
* fs.open('non-existent file', 'r', (er, fd) => {
|
||||||
|
* if (er) throw er;
|
||||||
|
* // proceed...
|
||||||
|
* });
|
||||||
|
* }, 100);
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* In this example, the `d.on('error')` handler will be triggered, rather
|
||||||
|
* than crashing the program.
|
||||||
|
*/
|
||||||
|
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||||
|
/**
|
||||||
|
* Explicitly adds an emitter to the domain. If any event handlers called by
|
||||||
|
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
||||||
|
* will be routed to the domain's `'error'` event, just like with implicit
|
||||||
|
* binding.
|
||||||
|
*
|
||||||
|
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
||||||
|
* the domain `'error'` handler.
|
||||||
|
*
|
||||||
|
* If the Timer or `EventEmitter` was already bound to a domain, it is removed
|
||||||
|
* from that one, and bound to this one instead.
|
||||||
|
* @param emitter emitter or timer to be added to the domain
|
||||||
|
*/
|
||||||
|
add(emitter: EventEmitter | NodeJS.Timer): void;
|
||||||
|
/**
|
||||||
|
* The opposite of {@link add}. Removes domain handling from the
|
||||||
|
* specified emitter.
|
||||||
|
* @param emitter emitter or timer to be removed from the domain
|
||||||
|
*/
|
||||||
|
remove(emitter: EventEmitter | NodeJS.Timer): void;
|
||||||
|
/**
|
||||||
|
* The returned function will be a wrapper around the supplied callback
|
||||||
|
* function. When the returned function is called, any errors that are
|
||||||
|
* thrown will be routed to the domain's `'error'` event.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const d = domain.create();
|
||||||
|
*
|
||||||
|
* function readSomeFile(filename, cb) {
|
||||||
|
* fs.readFile(filename, 'utf8', d.bind((er, data) => {
|
||||||
|
* // If this throws, it will also be passed to the domain.
|
||||||
|
* return cb(er, data ? JSON.parse(data) : null);
|
||||||
|
* }));
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* d.on('error', (er) => {
|
||||||
|
* // An error occurred somewhere. If we throw it now, it will crash the program
|
||||||
|
* // with the normal line number and stack message.
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @param callback The callback function
|
||||||
|
* @return The bound function
|
||||||
|
*/
|
||||||
|
bind<T extends Function>(callback: T): T;
|
||||||
|
/**
|
||||||
|
* This method is almost identical to {@link bind}. However, in
|
||||||
|
* addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
|
||||||
|
*
|
||||||
|
* In this way, the common `if (err) return callback(err);` pattern can be replaced
|
||||||
|
* with a single error handler in a single place.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const d = domain.create();
|
||||||
|
*
|
||||||
|
* function readSomeFile(filename, cb) {
|
||||||
|
* fs.readFile(filename, 'utf8', d.intercept((data) => {
|
||||||
|
* // Note, the first argument is never passed to the
|
||||||
|
* // callback since it is assumed to be the 'Error' argument
|
||||||
|
* // and thus intercepted by the domain.
|
||||||
|
*
|
||||||
|
* // If this throws, it will also be passed to the domain
|
||||||
|
* // so the error-handling logic can be moved to the 'error'
|
||||||
|
* // event on the domain instead of being repeated throughout
|
||||||
|
* // the program.
|
||||||
|
* return cb(null, JSON.parse(data));
|
||||||
|
* }));
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* d.on('error', (er) => {
|
||||||
|
* // An error occurred somewhere. If we throw it now, it will crash the program
|
||||||
|
* // with the normal line number and stack message.
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @param callback The callback function
|
||||||
|
* @return The intercepted function
|
||||||
|
*/
|
||||||
|
intercept<T extends Function>(callback: T): T;
|
||||||
|
}
|
||||||
|
function create(): Domain;
|
||||||
|
}
|
||||||
|
declare module "node:domain" {
|
||||||
|
export * from "domain";
|
||||||
|
}
|
931
websocket_server/node_modules/.ignored/@types/node/events.d.ts
generated
vendored
Normal file
931
websocket_server/node_modules/.ignored/@types/node/events.d.ts
generated
vendored
Normal file
@ -0,0 +1,931 @@
|
|||||||
|
/**
|
||||||
|
* Much of the Node.js core API is built around an idiomatic asynchronous
|
||||||
|
* event-driven architecture in which certain kinds of objects (called "emitters")
|
||||||
|
* emit named events that cause `Function` objects ("listeners") to be called.
|
||||||
|
*
|
||||||
|
* For instance: a `net.Server` object emits an event each time a peer
|
||||||
|
* connects to it; a `fs.ReadStream` emits an event when the file is opened;
|
||||||
|
* a `stream` emits an event whenever data is available to be read.
|
||||||
|
*
|
||||||
|
* All objects that emit events are instances of the `EventEmitter` class. These
|
||||||
|
* objects expose an `eventEmitter.on()` function that allows one or more
|
||||||
|
* functions to be attached to named events emitted by the object. Typically,
|
||||||
|
* event names are camel-cased strings but any valid JavaScript property key
|
||||||
|
* can be used.
|
||||||
|
*
|
||||||
|
* When the `EventEmitter` object emits an event, all of the functions attached
|
||||||
|
* to that specific event are called _synchronously_. Any values returned by the
|
||||||
|
* called listeners are _ignored_ and discarded.
|
||||||
|
*
|
||||||
|
* The following example shows a simple `EventEmitter` instance with a single
|
||||||
|
* listener. The `eventEmitter.on()` method is used to register listeners, while
|
||||||
|
* the `eventEmitter.emit()` method is used to trigger the event.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
*
|
||||||
|
* class MyEmitter extends EventEmitter {}
|
||||||
|
*
|
||||||
|
* const myEmitter = new MyEmitter();
|
||||||
|
* myEmitter.on('event', () => {
|
||||||
|
* console.log('an event occurred!');
|
||||||
|
* });
|
||||||
|
* myEmitter.emit('event');
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/events.js)
|
||||||
|
*/
|
||||||
|
declare module "events" {
|
||||||
|
import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
|
||||||
|
// NOTE: This class is in the docs but is **not actually exported** by Node.
|
||||||
|
// If https://github.com/nodejs/node/issues/39903 gets resolved and Node
|
||||||
|
// actually starts exporting the class, uncomment below.
|
||||||
|
// import { EventListener, EventListenerObject } from '__dom-events';
|
||||||
|
// /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
|
||||||
|
// interface NodeEventTarget extends EventTarget {
|
||||||
|
// /**
|
||||||
|
// * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
|
||||||
|
// * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
|
||||||
|
// */
|
||||||
|
// addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
||||||
|
// /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
|
||||||
|
// eventNames(): string[];
|
||||||
|
// /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
|
||||||
|
// listenerCount(type: string): number;
|
||||||
|
// /** Node.js-specific alias for `eventTarget.removeListener()`. */
|
||||||
|
// off(type: string, listener: EventListener | EventListenerObject): this;
|
||||||
|
// /** Node.js-specific alias for `eventTarget.addListener()`. */
|
||||||
|
// on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
||||||
|
// /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
|
||||||
|
// once(type: string, listener: EventListener | EventListenerObject): this;
|
||||||
|
// /**
|
||||||
|
// * Node.js-specific extension to the `EventTarget` class.
|
||||||
|
// * If `type` is specified, removes all registered listeners for `type`,
|
||||||
|
// * otherwise removes all registered listeners.
|
||||||
|
// */
|
||||||
|
// removeAllListeners(type: string): this;
|
||||||
|
// /**
|
||||||
|
// * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
|
||||||
|
// * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
|
||||||
|
// */
|
||||||
|
// removeListener(type: string, listener: EventListener | EventListenerObject): this;
|
||||||
|
// }
|
||||||
|
interface EventEmitterOptions {
|
||||||
|
/**
|
||||||
|
* Enables automatic capturing of promise rejection.
|
||||||
|
*/
|
||||||
|
captureRejections?: boolean | undefined;
|
||||||
|
}
|
||||||
|
interface StaticEventEmitterOptions {
|
||||||
|
/**
|
||||||
|
* Can be used to cancel awaiting events.
|
||||||
|
*/
|
||||||
|
signal?: AbortSignal | undefined;
|
||||||
|
}
|
||||||
|
interface StaticEventEmitterIteratorOptions extends StaticEventEmitterOptions {
|
||||||
|
/**
|
||||||
|
* Names of events that will end the iteration.
|
||||||
|
*/
|
||||||
|
close?: string[] | undefined;
|
||||||
|
/**
|
||||||
|
* The high watermark. The emitter is paused every time the size of events being buffered is higher than it.
|
||||||
|
* Supported only on emitters implementing `pause()` and `resume()` methods.
|
||||||
|
* @default Number.MAX_SAFE_INTEGER
|
||||||
|
*/
|
||||||
|
highWaterMark?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The low watermark. The emitter is resumed every time the size of events being buffered is lower than it.
|
||||||
|
* Supported only on emitters implementing `pause()` and `resume()` methods.
|
||||||
|
* @default 1
|
||||||
|
*/
|
||||||
|
lowWaterMark?: number | undefined;
|
||||||
|
}
|
||||||
|
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
|
||||||
|
type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
|
||||||
|
type DefaultEventMap = [never];
|
||||||
|
type AnyRest = [...args: any[]];
|
||||||
|
type Args<K, T> = T extends DefaultEventMap ? AnyRest : (
|
||||||
|
K extends keyof T ? T[K] : never
|
||||||
|
);
|
||||||
|
type Key<K, T> = T extends DefaultEventMap ? string | symbol : K | keyof T;
|
||||||
|
type Key2<K, T> = T extends DefaultEventMap ? string | symbol : K & keyof T;
|
||||||
|
type Listener<K, T, F> = T extends DefaultEventMap ? F : (
|
||||||
|
K extends keyof T ? (
|
||||||
|
T[K] extends unknown[] ? (...args: T[K]) => void : never
|
||||||
|
)
|
||||||
|
: never
|
||||||
|
);
|
||||||
|
type Listener1<K, T> = Listener<K, T, (...args: any[]) => void>;
|
||||||
|
type Listener2<K, T> = Listener<K, T, Function>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `EventEmitter` class is defined and exposed by the `node:events` module:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* All `EventEmitter`s emit the event `'newListener'` when new listeners are
|
||||||
|
* added and `'removeListener'` when existing listeners are removed.
|
||||||
|
*
|
||||||
|
* It supports the following option:
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
||||||
|
constructor(options?: EventEmitterOptions);
|
||||||
|
|
||||||
|
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
||||||
|
* event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
|
||||||
|
* The `Promise` will resolve with an array of all the arguments emitted to the
|
||||||
|
* given event.
|
||||||
|
*
|
||||||
|
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
|
||||||
|
* semantics and does not listen to the `'error'` event.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { once, EventEmitter } from 'node:events';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* ee.emit('myevent', 42);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* const [value] = await once(ee, 'myevent');
|
||||||
|
* console.log(value);
|
||||||
|
*
|
||||||
|
* const err = new Error('kaboom');
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* ee.emit('error', err);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* try {
|
||||||
|
* await once(ee, 'myevent');
|
||||||
|
* } catch (err) {
|
||||||
|
* console.error('error happened', err);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The special handling of the `'error'` event is only used when `events.once()` is used to wait for another event. If `events.once()` is used to wait for the
|
||||||
|
* '`error'` event itself, then it is treated as any other kind of event without
|
||||||
|
* special handling:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter, once } from 'node:events';
|
||||||
|
*
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* once(ee, 'error')
|
||||||
|
* .then(([err]) => console.log('ok', err.message))
|
||||||
|
* .catch((err) => console.error('error', err.message));
|
||||||
|
*
|
||||||
|
* ee.emit('error', new Error('boom'));
|
||||||
|
*
|
||||||
|
* // Prints: ok boom
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* An `AbortSignal` can be used to cancel waiting for the event:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter, once } from 'node:events';
|
||||||
|
*
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
* const ac = new AbortController();
|
||||||
|
*
|
||||||
|
* async function foo(emitter, event, signal) {
|
||||||
|
* try {
|
||||||
|
* await once(emitter, event, { signal });
|
||||||
|
* console.log('event emitted!');
|
||||||
|
* } catch (error) {
|
||||||
|
* if (error.name === 'AbortError') {
|
||||||
|
* console.error('Waiting for the event was canceled!');
|
||||||
|
* } else {
|
||||||
|
* console.error('There was an error', error.message);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* foo(ee, 'foo', ac.signal);
|
||||||
|
* ac.abort(); // Abort waiting for the event
|
||||||
|
* ee.emit('foo'); // Prints: Waiting for the event was canceled!
|
||||||
|
* ```
|
||||||
|
* @since v11.13.0, v10.16.0
|
||||||
|
*/
|
||||||
|
static once(
|
||||||
|
emitter: NodeJS.EventEmitter,
|
||||||
|
eventName: string | symbol,
|
||||||
|
options?: StaticEventEmitterOptions,
|
||||||
|
): Promise<any[]>;
|
||||||
|
static once(emitter: EventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import { on, EventEmitter } from 'node:events';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* // Emit later on
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* ee.emit('foo', 'bar');
|
||||||
|
* ee.emit('foo', 42);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* for await (const event of on(ee, 'foo')) {
|
||||||
|
* // The execution of this inner block is synchronous and it
|
||||||
|
* // processes one event at a time (even with await). Do not use
|
||||||
|
* // if concurrent execution is required.
|
||||||
|
* console.log(event); // prints ['bar'] [42]
|
||||||
|
* }
|
||||||
|
* // Unreachable here
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns an `AsyncIterator` that iterates `eventName` events. It will throw
|
||||||
|
* if the `EventEmitter` emits `'error'`. It removes all listeners when
|
||||||
|
* exiting the loop. The `value` returned by each iteration is an array
|
||||||
|
* composed of the emitted event arguments.
|
||||||
|
*
|
||||||
|
* An `AbortSignal` can be used to cancel waiting on events:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { on, EventEmitter } from 'node:events';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const ac = new AbortController();
|
||||||
|
*
|
||||||
|
* (async () => {
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* // Emit later on
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* ee.emit('foo', 'bar');
|
||||||
|
* ee.emit('foo', 42);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* for await (const event of on(ee, 'foo', { signal: ac.signal })) {
|
||||||
|
* // The execution of this inner block is synchronous and it
|
||||||
|
* // processes one event at a time (even with await). Do not use
|
||||||
|
* // if concurrent execution is required.
|
||||||
|
* console.log(event); // prints ['bar'] [42]
|
||||||
|
* }
|
||||||
|
* // Unreachable here
|
||||||
|
* })();
|
||||||
|
*
|
||||||
|
* process.nextTick(() => ac.abort());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Use the `close` option to specify an array of event names that will end the iteration:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { on, EventEmitter } from 'node:events';
|
||||||
|
* import process from 'node:process';
|
||||||
|
*
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* // Emit later on
|
||||||
|
* process.nextTick(() => {
|
||||||
|
* ee.emit('foo', 'bar');
|
||||||
|
* ee.emit('foo', 42);
|
||||||
|
* ee.emit('close');
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* for await (const event of on(ee, 'foo', { close: ['close'] })) {
|
||||||
|
* console.log(event); // prints ['bar'] [42]
|
||||||
|
* }
|
||||||
|
* // the loop will exit after 'close' is emitted
|
||||||
|
* console.log('done'); // prints 'done'
|
||||||
|
* ```
|
||||||
|
* @since v13.6.0, v12.16.0
|
||||||
|
* @return An `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
|
||||||
|
*/
|
||||||
|
static on(
|
||||||
|
emitter: NodeJS.EventEmitter,
|
||||||
|
eventName: string | symbol,
|
||||||
|
options?: StaticEventEmitterIteratorOptions,
|
||||||
|
): NodeJS.AsyncIterator<any[]>;
|
||||||
|
static on(
|
||||||
|
emitter: EventTarget,
|
||||||
|
eventName: string,
|
||||||
|
options?: StaticEventEmitterIteratorOptions,
|
||||||
|
): NodeJS.AsyncIterator<any[]>;
|
||||||
|
/**
|
||||||
|
* A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter, listenerCount } from 'node:events';
|
||||||
|
*
|
||||||
|
* const myEmitter = new EventEmitter();
|
||||||
|
* myEmitter.on('event', () => {});
|
||||||
|
* myEmitter.on('event', () => {});
|
||||||
|
* console.log(listenerCount(myEmitter, 'event'));
|
||||||
|
* // Prints: 2
|
||||||
|
* ```
|
||||||
|
* @since v0.9.12
|
||||||
|
* @deprecated Since v3.2.0 - Use `listenerCount` instead.
|
||||||
|
* @param emitter The emitter to query
|
||||||
|
* @param eventName The event name
|
||||||
|
*/
|
||||||
|
static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
|
||||||
|
/**
|
||||||
|
* Returns a copy of the array of listeners for the event named `eventName`.
|
||||||
|
*
|
||||||
|
* For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
|
||||||
|
* the emitter.
|
||||||
|
*
|
||||||
|
* For `EventTarget`s this is the only way to get the event listeners for the
|
||||||
|
* event target. This is useful for debugging and diagnostic purposes.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { getEventListeners, EventEmitter } from 'node:events';
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
* const listener = () => console.log('Events are fun');
|
||||||
|
* ee.on('foo', listener);
|
||||||
|
* console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
|
||||||
|
* }
|
||||||
|
* {
|
||||||
|
* const et = new EventTarget();
|
||||||
|
* const listener = () => console.log('Events are fun');
|
||||||
|
* et.addEventListener('foo', listener);
|
||||||
|
* console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v15.2.0, v14.17.0
|
||||||
|
*/
|
||||||
|
static getEventListeners(emitter: EventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||||
|
/**
|
||||||
|
* Returns the currently set max amount of listeners.
|
||||||
|
*
|
||||||
|
* For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on
|
||||||
|
* the emitter.
|
||||||
|
*
|
||||||
|
* For `EventTarget`s this is the only way to get the max event listeners for the
|
||||||
|
* event target. If the number of event handlers on a single EventTarget exceeds
|
||||||
|
* the max set, the EventTarget will print a warning.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
* console.log(getMaxListeners(ee)); // 10
|
||||||
|
* setMaxListeners(11, ee);
|
||||||
|
* console.log(getMaxListeners(ee)); // 11
|
||||||
|
* }
|
||||||
|
* {
|
||||||
|
* const et = new EventTarget();
|
||||||
|
* console.log(getMaxListeners(et)); // 10
|
||||||
|
* setMaxListeners(11, et);
|
||||||
|
* console.log(getMaxListeners(et)); // 11
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
*/
|
||||||
|
static getMaxListeners(emitter: EventTarget | NodeJS.EventEmitter): number;
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import { setMaxListeners, EventEmitter } from 'node:events';
|
||||||
|
*
|
||||||
|
* const target = new EventTarget();
|
||||||
|
* const emitter = new EventEmitter();
|
||||||
|
*
|
||||||
|
* setMaxListeners(5, target, emitter);
|
||||||
|
* ```
|
||||||
|
* @since v15.4.0
|
||||||
|
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
||||||
|
* @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
|
||||||
|
/**
|
||||||
|
* Listens once to the `abort` event on the provided `signal`.
|
||||||
|
*
|
||||||
|
* Listening to the `abort` event on abort signals is unsafe and may
|
||||||
|
* lead to resource leaks since another third party with the signal can
|
||||||
|
* call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
|
||||||
|
* this since it would violate the web standard. Additionally, the original
|
||||||
|
* API makes it easy to forget to remove listeners.
|
||||||
|
*
|
||||||
|
* This API allows safely using `AbortSignal`s in Node.js APIs by solving these
|
||||||
|
* two issues by listening to the event such that `stopImmediatePropagation` does
|
||||||
|
* not prevent the listener from running.
|
||||||
|
*
|
||||||
|
* Returns a disposable so that it may be unsubscribed from more easily.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { addAbortListener } from 'node:events';
|
||||||
|
*
|
||||||
|
* function example(signal) {
|
||||||
|
* let disposable;
|
||||||
|
* try {
|
||||||
|
* signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
|
||||||
|
* disposable = addAbortListener(signal, (e) => {
|
||||||
|
* // Do something when signal is aborted.
|
||||||
|
* });
|
||||||
|
* } finally {
|
||||||
|
* disposable?.[Symbol.dispose]();
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v20.5.0
|
||||||
|
* @experimental
|
||||||
|
* @return Disposable that removes the `abort` listener.
|
||||||
|
*/
|
||||||
|
static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
|
||||||
|
/**
|
||||||
|
* This symbol shall be used to install a listener for only monitoring `'error'` events. Listeners installed using this symbol are called before the regular `'error'` listeners are called.
|
||||||
|
*
|
||||||
|
* Installing a listener using this symbol does not change the behavior once an `'error'` event is emitted. Therefore, the process will still crash if no
|
||||||
|
* regular `'error'` listener is installed.
|
||||||
|
* @since v13.6.0, v12.17.0
|
||||||
|
*/
|
||||||
|
static readonly errorMonitor: unique symbol;
|
||||||
|
/**
|
||||||
|
* Value: `Symbol.for('nodejs.rejection')`
|
||||||
|
*
|
||||||
|
* See how to write a custom `rejection handler`.
|
||||||
|
* @since v13.4.0, v12.16.0
|
||||||
|
*/
|
||||||
|
static readonly captureRejectionSymbol: unique symbol;
|
||||||
|
/**
|
||||||
|
* Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
|
||||||
|
*
|
||||||
|
* Change the default `captureRejections` option on all new `EventEmitter` objects.
|
||||||
|
* @since v13.4.0, v12.16.0
|
||||||
|
*/
|
||||||
|
static captureRejections: boolean;
|
||||||
|
/**
|
||||||
|
* By default, a maximum of `10` listeners can be registered for any single
|
||||||
|
* event. This limit can be changed for individual `EventEmitter` instances
|
||||||
|
* using the `emitter.setMaxListeners(n)` method. To change the default
|
||||||
|
* for _all_`EventEmitter` instances, the `events.defaultMaxListeners` property
|
||||||
|
* can be used. If this value is not a positive number, a `RangeError` is thrown.
|
||||||
|
*
|
||||||
|
* Take caution when setting the `events.defaultMaxListeners` because the
|
||||||
|
* change affects _all_ `EventEmitter` instances, including those created before
|
||||||
|
* the change is made. However, calling `emitter.setMaxListeners(n)` still has
|
||||||
|
* precedence over `events.defaultMaxListeners`.
|
||||||
|
*
|
||||||
|
* This is not a hard limit. The `EventEmitter` instance will allow
|
||||||
|
* more listeners to be added but will output a trace warning to stderr indicating
|
||||||
|
* that a "possible EventEmitter memory leak" has been detected. For any single
|
||||||
|
* `EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()` methods can be used to
|
||||||
|
* temporarily avoid this warning:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const emitter = new EventEmitter();
|
||||||
|
* emitter.setMaxListeners(emitter.getMaxListeners() + 1);
|
||||||
|
* emitter.once('event', () => {
|
||||||
|
* // do stuff
|
||||||
|
* emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The `--trace-warnings` command-line flag can be used to display the
|
||||||
|
* stack trace for such warnings.
|
||||||
|
*
|
||||||
|
* The emitted warning can be inspected with `process.on('warning')` and will
|
||||||
|
* have the additional `emitter`, `type`, and `count` properties, referring to
|
||||||
|
* the event emitter instance, the event's name and the number of attached
|
||||||
|
* listeners, respectively.
|
||||||
|
* Its `name` property is set to `'MaxListenersExceededWarning'`.
|
||||||
|
* @since v0.11.2
|
||||||
|
*/
|
||||||
|
static defaultMaxListeners: number;
|
||||||
|
}
|
||||||
|
import internal = require("node:events");
|
||||||
|
namespace EventEmitter {
|
||||||
|
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
||||||
|
export { internal as EventEmitter };
|
||||||
|
export interface Abortable {
|
||||||
|
/**
|
||||||
|
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
||||||
|
*/
|
||||||
|
signal?: AbortSignal | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EventEmitterReferencingAsyncResource extends AsyncResource {
|
||||||
|
readonly eventEmitter: EventEmitterAsyncResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
|
||||||
|
/**
|
||||||
|
* The type of async event, this is required when instantiating `EventEmitterAsyncResource`
|
||||||
|
* directly rather than as a child class.
|
||||||
|
* @default new.target.name if instantiated as a child class.
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
|
||||||
|
* require manual async tracking. Specifically, all events emitted by instances
|
||||||
|
* of `events.EventEmitterAsyncResource` will run within its `async context`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
|
||||||
|
* import { notStrictEqual, strictEqual } from 'node:assert';
|
||||||
|
* import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
|
||||||
|
*
|
||||||
|
* // Async tracking tooling will identify this as 'Q'.
|
||||||
|
* const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
|
||||||
|
*
|
||||||
|
* // 'foo' listeners will run in the EventEmitters async context.
|
||||||
|
* ee1.on('foo', () => {
|
||||||
|
* strictEqual(executionAsyncId(), ee1.asyncId);
|
||||||
|
* strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* const ee2 = new EventEmitter();
|
||||||
|
*
|
||||||
|
* // 'foo' listeners on ordinary EventEmitters that do not track async
|
||||||
|
* // context, however, run in the same async context as the emit().
|
||||||
|
* ee2.on('foo', () => {
|
||||||
|
* notStrictEqual(executionAsyncId(), ee2.asyncId);
|
||||||
|
* notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* Promise.resolve().then(() => {
|
||||||
|
* ee1.emit('foo');
|
||||||
|
* ee2.emit('foo');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The `EventEmitterAsyncResource` class has the same methods and takes the
|
||||||
|
* same options as `EventEmitter` and `AsyncResource` themselves.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
export class EventEmitterAsyncResource extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* @param options Only optional in child class.
|
||||||
|
*/
|
||||||
|
constructor(options?: EventEmitterAsyncResourceOptions);
|
||||||
|
/**
|
||||||
|
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||||
|
* be thrown if it is called more than once. This **must** be manually called. If
|
||||||
|
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||||
|
* never be called.
|
||||||
|
*/
|
||||||
|
emitDestroy(): void;
|
||||||
|
/**
|
||||||
|
* The unique `asyncId` assigned to the resource.
|
||||||
|
*/
|
||||||
|
readonly asyncId: number;
|
||||||
|
/**
|
||||||
|
* The same triggerAsyncId that is passed to the AsyncResource constructor.
|
||||||
|
*/
|
||||||
|
readonly triggerAsyncId: number;
|
||||||
|
/**
|
||||||
|
* The returned `AsyncResource` object has an additional `eventEmitter` property
|
||||||
|
* that provides a reference to this `EventEmitterAsyncResource`.
|
||||||
|
*/
|
||||||
|
readonly asyncResource: EventEmitterReferencingAsyncResource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global {
|
||||||
|
namespace NodeJS {
|
||||||
|
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
||||||
|
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
||||||
|
/**
|
||||||
|
* Alias for `emitter.on(eventName, listener)`.
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Adds the `listener` function to the end of the listeners array for the event
|
||||||
|
* named `eventName`. No checks are made to see if the `listener` has already
|
||||||
|
* been added. Multiple calls passing the same combination of `eventName` and
|
||||||
|
* `listener` will result in the `listener` being added, and called, multiple times.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* server.on('connection', (stream) => {
|
||||||
|
* console.log('someone connected!');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
*
|
||||||
|
* By default, event listeners are invoked in the order they are added. The `emitter.prependListener()` method can be used as an alternative to add the
|
||||||
|
* event listener to the beginning of the listeners array.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const myEE = new EventEmitter();
|
||||||
|
* myEE.on('foo', () => console.log('a'));
|
||||||
|
* myEE.prependListener('foo', () => console.log('b'));
|
||||||
|
* myEE.emit('foo');
|
||||||
|
* // Prints:
|
||||||
|
* // b
|
||||||
|
* // a
|
||||||
|
* ```
|
||||||
|
* @since v0.1.101
|
||||||
|
* @param eventName The name of the event.
|
||||||
|
* @param listener The callback function
|
||||||
|
*/
|
||||||
|
on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Adds a **one-time** `listener` function for the event named `eventName`. The
|
||||||
|
* next time `eventName` is triggered, this listener is removed and then invoked.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* server.once('connection', (stream) => {
|
||||||
|
* console.log('Ah, we have our first user!');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
*
|
||||||
|
* By default, event listeners are invoked in the order they are added. The `emitter.prependOnceListener()` method can be used as an alternative to add the
|
||||||
|
* event listener to the beginning of the listeners array.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const myEE = new EventEmitter();
|
||||||
|
* myEE.once('foo', () => console.log('a'));
|
||||||
|
* myEE.prependOnceListener('foo', () => console.log('b'));
|
||||||
|
* myEE.emit('foo');
|
||||||
|
* // Prints:
|
||||||
|
* // b
|
||||||
|
* // a
|
||||||
|
* ```
|
||||||
|
* @since v0.3.0
|
||||||
|
* @param eventName The name of the event.
|
||||||
|
* @param listener The callback function
|
||||||
|
*/
|
||||||
|
once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Removes the specified `listener` from the listener array for the event named `eventName`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const callback = (stream) => {
|
||||||
|
* console.log('someone connected!');
|
||||||
|
* };
|
||||||
|
* server.on('connection', callback);
|
||||||
|
* // ...
|
||||||
|
* server.removeListener('connection', callback);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `removeListener()` will remove, at most, one instance of a listener from the
|
||||||
|
* listener array. If any single listener has been added multiple times to the
|
||||||
|
* listener array for the specified `eventName`, then `removeListener()` must be
|
||||||
|
* called multiple times to remove each instance.
|
||||||
|
*
|
||||||
|
* Once an event is emitted, all listeners attached to it at the
|
||||||
|
* time of emitting are called in order. This implies that any `removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
|
||||||
|
* will not remove them from`emit()` in progress. Subsequent events behave as expected.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* class MyEmitter extends EventEmitter {}
|
||||||
|
* const myEmitter = new MyEmitter();
|
||||||
|
*
|
||||||
|
* const callbackA = () => {
|
||||||
|
* console.log('A');
|
||||||
|
* myEmitter.removeListener('event', callbackB);
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* const callbackB = () => {
|
||||||
|
* console.log('B');
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* myEmitter.on('event', callbackA);
|
||||||
|
*
|
||||||
|
* myEmitter.on('event', callbackB);
|
||||||
|
*
|
||||||
|
* // callbackA removes listener callbackB but it will still be called.
|
||||||
|
* // Internal listener array at time of emit [callbackA, callbackB]
|
||||||
|
* myEmitter.emit('event');
|
||||||
|
* // Prints:
|
||||||
|
* // A
|
||||||
|
* // B
|
||||||
|
*
|
||||||
|
* // callbackB is now removed.
|
||||||
|
* // Internal listener array [callbackA]
|
||||||
|
* myEmitter.emit('event');
|
||||||
|
* // Prints:
|
||||||
|
* // A
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Because listeners are managed using an internal array, calling this will
|
||||||
|
* change the position indices of any listener registered _after_ the listener
|
||||||
|
* being removed. This will not impact the order in which listeners are called,
|
||||||
|
* but it means that any copies of the listener array as returned by
|
||||||
|
* the `emitter.listeners()` method will need to be recreated.
|
||||||
|
*
|
||||||
|
* When a single function has been added as a handler multiple times for a single
|
||||||
|
* event (as in the example below), `removeListener()` will remove the most
|
||||||
|
* recently added instance. In the example the `once('ping')` listener is removed:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const ee = new EventEmitter();
|
||||||
|
*
|
||||||
|
* function pong() {
|
||||||
|
* console.log('pong');
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* ee.on('ping', pong);
|
||||||
|
* ee.once('ping', pong);
|
||||||
|
* ee.removeListener('ping', pong);
|
||||||
|
*
|
||||||
|
* ee.emit('ping');
|
||||||
|
* ee.emit('ping');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Alias for `emitter.removeListener()`.
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Removes all listeners, or those of the specified `eventName`.
|
||||||
|
*
|
||||||
|
* It is bad practice to remove listeners added elsewhere in the code,
|
||||||
|
* particularly when the `EventEmitter` instance was created by some other
|
||||||
|
* component or module (e.g. sockets or file streams).
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
removeAllListeners(eventName?: Key<unknown, T>): this;
|
||||||
|
/**
|
||||||
|
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
||||||
|
* added for a particular event. This is a useful default that helps finding
|
||||||
|
* memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
||||||
|
* modified for this specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) to indicate an unlimited number of listeners.
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
* @since v0.3.5
|
||||||
|
*/
|
||||||
|
setMaxListeners(n: number): this;
|
||||||
|
/**
|
||||||
|
* Returns the current max listener value for the `EventEmitter` which is either
|
||||||
|
* set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
|
||||||
|
* @since v1.0.0
|
||||||
|
*/
|
||||||
|
getMaxListeners(): number;
|
||||||
|
/**
|
||||||
|
* Returns a copy of the array of listeners for the event named `eventName`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* server.on('connection', (stream) => {
|
||||||
|
* console.log('someone connected!');
|
||||||
|
* });
|
||||||
|
* console.log(util.inspect(server.listeners('connection')));
|
||||||
|
* // Prints: [ [Function] ]
|
||||||
|
* ```
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
||||||
|
/**
|
||||||
|
* Returns a copy of the array of listeners for the event named `eventName`,
|
||||||
|
* including any wrappers (such as those created by `.once()`).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const emitter = new EventEmitter();
|
||||||
|
* emitter.once('log', () => console.log('log once'));
|
||||||
|
*
|
||||||
|
* // Returns a new Array with a function `onceWrapper` which has a property
|
||||||
|
* // `listener` which contains the original listener bound above
|
||||||
|
* const listeners = emitter.rawListeners('log');
|
||||||
|
* const logFnWrapper = listeners[0];
|
||||||
|
*
|
||||||
|
* // Logs "log once" to the console and does not unbind the `once` event
|
||||||
|
* logFnWrapper.listener();
|
||||||
|
*
|
||||||
|
* // Logs "log once" to the console and removes the listener
|
||||||
|
* logFnWrapper();
|
||||||
|
*
|
||||||
|
* emitter.on('log', () => console.log('log persistently'));
|
||||||
|
* // Will return a new Array with a single function bound by `.on()` above
|
||||||
|
* const newListeners = emitter.rawListeners('log');
|
||||||
|
*
|
||||||
|
* // Logs "log persistently" twice
|
||||||
|
* newListeners[0]();
|
||||||
|
* emitter.emit('log');
|
||||||
|
* ```
|
||||||
|
* @since v9.4.0
|
||||||
|
*/
|
||||||
|
rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
||||||
|
/**
|
||||||
|
* Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments
|
||||||
|
* to each.
|
||||||
|
*
|
||||||
|
* Returns `true` if the event had listeners, `false` otherwise.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
* const myEmitter = new EventEmitter();
|
||||||
|
*
|
||||||
|
* // First listener
|
||||||
|
* myEmitter.on('event', function firstListener() {
|
||||||
|
* console.log('Helloooo! first listener');
|
||||||
|
* });
|
||||||
|
* // Second listener
|
||||||
|
* myEmitter.on('event', function secondListener(arg1, arg2) {
|
||||||
|
* console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
||||||
|
* });
|
||||||
|
* // Third listener
|
||||||
|
* myEmitter.on('event', function thirdListener(...args) {
|
||||||
|
* const parameters = args.join(', ');
|
||||||
|
* console.log(`event with parameters ${parameters} in third listener`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* console.log(myEmitter.listeners('event'));
|
||||||
|
*
|
||||||
|
* myEmitter.emit('event', 1, 2, 3, 4, 5);
|
||||||
|
*
|
||||||
|
* // Prints:
|
||||||
|
* // [
|
||||||
|
* // [Function: firstListener],
|
||||||
|
* // [Function: secondListener],
|
||||||
|
* // [Function: thirdListener]
|
||||||
|
* // ]
|
||||||
|
* // Helloooo! first listener
|
||||||
|
* // event with parameters 1, 2 in second listener
|
||||||
|
* // event with parameters 1, 2, 3, 4, 5 in third listener
|
||||||
|
* ```
|
||||||
|
* @since v0.1.26
|
||||||
|
*/
|
||||||
|
emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
|
||||||
|
/**
|
||||||
|
* Returns the number of listeners listening for the event named `eventName`.
|
||||||
|
* If `listener` is provided, it will return how many times the listener is found
|
||||||
|
* in the list of the listeners of the event.
|
||||||
|
* @since v3.2.0
|
||||||
|
* @param eventName The name of the event being listened for
|
||||||
|
* @param listener The event handler function
|
||||||
|
*/
|
||||||
|
listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): number;
|
||||||
|
/**
|
||||||
|
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
||||||
|
* event named `eventName`. No checks are made to see if the `listener` has
|
||||||
|
* already been added. Multiple calls passing the same combination of `eventName`
|
||||||
|
* and `listener` will result in the `listener` being added, and called, multiple times.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* server.prependListener('connection', (stream) => {
|
||||||
|
* console.log('someone connected!');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
* @since v6.0.0
|
||||||
|
* @param eventName The name of the event.
|
||||||
|
* @param listener The callback function
|
||||||
|
*/
|
||||||
|
prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this
|
||||||
|
* listener is removed, and then invoked.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* server.prependOnceListener('connection', (stream) => {
|
||||||
|
* console.log('Ah, we have our first user!');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||||
|
* @since v6.0.0
|
||||||
|
* @param eventName The name of the event.
|
||||||
|
* @param listener The callback function
|
||||||
|
*/
|
||||||
|
prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||||
|
/**
|
||||||
|
* Returns an array listing the events for which the emitter has registered
|
||||||
|
* listeners. The values in the array are strings or `Symbol`s.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { EventEmitter } from 'node:events';
|
||||||
|
*
|
||||||
|
* const myEE = new EventEmitter();
|
||||||
|
* myEE.on('foo', () => {});
|
||||||
|
* myEE.on('bar', () => {});
|
||||||
|
*
|
||||||
|
* const sym = Symbol('symbol');
|
||||||
|
* myEE.on(sym, () => {});
|
||||||
|
*
|
||||||
|
* console.log(myEE.eventNames());
|
||||||
|
* // Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
||||||
|
* ```
|
||||||
|
* @since v6.0.0
|
||||||
|
*/
|
||||||
|
eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export = EventEmitter;
|
||||||
|
}
|
||||||
|
declare module "node:events" {
|
||||||
|
import events = require("events");
|
||||||
|
export = events;
|
||||||
|
}
|
4390
websocket_server/node_modules/.ignored/@types/node/fs.d.ts
generated
vendored
Normal file
4390
websocket_server/node_modules/.ignored/@types/node/fs.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1264
websocket_server/node_modules/.ignored/@types/node/fs/promises.d.ts
generated
vendored
Normal file
1264
websocket_server/node_modules/.ignored/@types/node/fs/promises.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
566
websocket_server/node_modules/.ignored/@types/node/globals.d.ts
generated
vendored
Normal file
566
websocket_server/node_modules/.ignored/@types/node/globals.d.ts
generated
vendored
Normal file
@ -0,0 +1,566 @@
|
|||||||
|
export {}; // Make this a module
|
||||||
|
|
||||||
|
// #region Fetch and friends
|
||||||
|
// Conditional type aliases, used at the end of this file.
|
||||||
|
// Will either be empty if lib.dom (or lib.webworker) is included, or the undici version otherwise.
|
||||||
|
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
||||||
|
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
||||||
|
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
||||||
|
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
||||||
|
type _MessageEvent = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").MessageEvent;
|
||||||
|
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("undici-types").RequestInit;
|
||||||
|
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("undici-types").ResponseInit;
|
||||||
|
type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").WebSocket;
|
||||||
|
type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
|
||||||
|
// #endregion Fetch and friends
|
||||||
|
|
||||||
|
// Conditional type definitions for webstorage interface, which conflicts with lib.dom otherwise.
|
||||||
|
type _Storage = typeof globalThis extends { onabort: any } ? {} : {
|
||||||
|
/**
|
||||||
|
* Returns the number of key/value pairs.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/length)
|
||||||
|
*/
|
||||||
|
readonly length: number;
|
||||||
|
/**
|
||||||
|
* Removes all key/value pairs, if there are any.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/clear)
|
||||||
|
*/
|
||||||
|
clear(): void;
|
||||||
|
/**
|
||||||
|
* Returns the current value associated with the given key, or null if the given key does not exist.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/getItem)
|
||||||
|
*/
|
||||||
|
getItem(key: string): string | null;
|
||||||
|
/**
|
||||||
|
* Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/key)
|
||||||
|
*/
|
||||||
|
key(index: number): string | null;
|
||||||
|
/**
|
||||||
|
* Removes the key/value pair with the given key, if a key/value pair with the given key exists.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/removeItem)
|
||||||
|
*/
|
||||||
|
removeItem(key: string): void;
|
||||||
|
/**
|
||||||
|
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
||||||
|
*
|
||||||
|
* Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/setItem)
|
||||||
|
*/
|
||||||
|
setItem(key: string, value: string): void;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
// #region DOMException
|
||||||
|
type _DOMException = typeof globalThis extends { onmessage: any } ? {} : NodeDOMException;
|
||||||
|
interface NodeDOMException extends Error {
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
|
||||||
|
*/
|
||||||
|
readonly code: number;
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
|
||||||
|
readonly message: string;
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
|
||||||
|
readonly name: string;
|
||||||
|
readonly INDEX_SIZE_ERR: 1;
|
||||||
|
readonly DOMSTRING_SIZE_ERR: 2;
|
||||||
|
readonly HIERARCHY_REQUEST_ERR: 3;
|
||||||
|
readonly WRONG_DOCUMENT_ERR: 4;
|
||||||
|
readonly INVALID_CHARACTER_ERR: 5;
|
||||||
|
readonly NO_DATA_ALLOWED_ERR: 6;
|
||||||
|
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
||||||
|
readonly NOT_FOUND_ERR: 8;
|
||||||
|
readonly NOT_SUPPORTED_ERR: 9;
|
||||||
|
readonly INUSE_ATTRIBUTE_ERR: 10;
|
||||||
|
readonly INVALID_STATE_ERR: 11;
|
||||||
|
readonly SYNTAX_ERR: 12;
|
||||||
|
readonly INVALID_MODIFICATION_ERR: 13;
|
||||||
|
readonly NAMESPACE_ERR: 14;
|
||||||
|
readonly INVALID_ACCESS_ERR: 15;
|
||||||
|
readonly VALIDATION_ERR: 16;
|
||||||
|
readonly TYPE_MISMATCH_ERR: 17;
|
||||||
|
readonly SECURITY_ERR: 18;
|
||||||
|
readonly NETWORK_ERR: 19;
|
||||||
|
readonly ABORT_ERR: 20;
|
||||||
|
readonly URL_MISMATCH_ERR: 21;
|
||||||
|
readonly QUOTA_EXCEEDED_ERR: 22;
|
||||||
|
readonly TIMEOUT_ERR: 23;
|
||||||
|
readonly INVALID_NODE_TYPE_ERR: 24;
|
||||||
|
readonly DATA_CLONE_ERR: 25;
|
||||||
|
}
|
||||||
|
interface NodeDOMExceptionConstructor {
|
||||||
|
prototype: DOMException;
|
||||||
|
new(message?: string, nameOrOptions?: string | { name?: string; cause?: unknown }): DOMException;
|
||||||
|
readonly INDEX_SIZE_ERR: 1;
|
||||||
|
readonly DOMSTRING_SIZE_ERR: 2;
|
||||||
|
readonly HIERARCHY_REQUEST_ERR: 3;
|
||||||
|
readonly WRONG_DOCUMENT_ERR: 4;
|
||||||
|
readonly INVALID_CHARACTER_ERR: 5;
|
||||||
|
readonly NO_DATA_ALLOWED_ERR: 6;
|
||||||
|
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
||||||
|
readonly NOT_FOUND_ERR: 8;
|
||||||
|
readonly NOT_SUPPORTED_ERR: 9;
|
||||||
|
readonly INUSE_ATTRIBUTE_ERR: 10;
|
||||||
|
readonly INVALID_STATE_ERR: 11;
|
||||||
|
readonly SYNTAX_ERR: 12;
|
||||||
|
readonly INVALID_MODIFICATION_ERR: 13;
|
||||||
|
readonly NAMESPACE_ERR: 14;
|
||||||
|
readonly INVALID_ACCESS_ERR: 15;
|
||||||
|
readonly VALIDATION_ERR: 16;
|
||||||
|
readonly TYPE_MISMATCH_ERR: 17;
|
||||||
|
readonly SECURITY_ERR: 18;
|
||||||
|
readonly NETWORK_ERR: 19;
|
||||||
|
readonly ABORT_ERR: 20;
|
||||||
|
readonly URL_MISMATCH_ERR: 21;
|
||||||
|
readonly QUOTA_EXCEEDED_ERR: 22;
|
||||||
|
readonly TIMEOUT_ERR: 23;
|
||||||
|
readonly INVALID_NODE_TYPE_ERR: 24;
|
||||||
|
readonly DATA_CLONE_ERR: 25;
|
||||||
|
}
|
||||||
|
// #endregion DOMException
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// Declare "static" methods in Error
|
||||||
|
interface ErrorConstructor {
|
||||||
|
/** Create .stack property on a target object */
|
||||||
|
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional override for formatting stack traces
|
||||||
|
*
|
||||||
|
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
||||||
|
*/
|
||||||
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
||||||
|
|
||||||
|
stackTraceLimit: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------*
|
||||||
|
* *
|
||||||
|
* GLOBAL *
|
||||||
|
* *
|
||||||
|
------------------------------------------------*/
|
||||||
|
|
||||||
|
// For backwards compability
|
||||||
|
interface NodeRequire extends NodeJS.Require {}
|
||||||
|
interface RequireResolve extends NodeJS.RequireResolve {}
|
||||||
|
interface NodeModule extends NodeJS.Module {}
|
||||||
|
|
||||||
|
var global: typeof globalThis;
|
||||||
|
|
||||||
|
var process: NodeJS.Process;
|
||||||
|
var console: Console;
|
||||||
|
|
||||||
|
var __filename: string;
|
||||||
|
var __dirname: string;
|
||||||
|
|
||||||
|
var require: NodeRequire;
|
||||||
|
var module: NodeModule;
|
||||||
|
|
||||||
|
// Same as module.exports
|
||||||
|
var exports: any;
|
||||||
|
|
||||||
|
interface GCFunction {
|
||||||
|
(options: {
|
||||||
|
execution?: "sync";
|
||||||
|
flavor?: "regular" | "last-resort";
|
||||||
|
type?: "major-snapshot" | "major" | "minor";
|
||||||
|
filename?: string;
|
||||||
|
}): void;
|
||||||
|
(options: {
|
||||||
|
execution: "async";
|
||||||
|
flavor?: "regular" | "last-resort";
|
||||||
|
type?: "major-snapshot" | "major" | "minor";
|
||||||
|
filename?: string;
|
||||||
|
}): Promise<void>;
|
||||||
|
(options?: boolean): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only available if `--expose-gc` is passed to the process.
|
||||||
|
*/
|
||||||
|
var gc: undefined | GCFunction;
|
||||||
|
|
||||||
|
// #region borrowed
|
||||||
|
// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
|
||||||
|
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
|
||||||
|
interface AbortController {
|
||||||
|
/**
|
||||||
|
* Returns the AbortSignal object associated with this object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
readonly signal: AbortSignal;
|
||||||
|
/**
|
||||||
|
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
|
||||||
|
*/
|
||||||
|
abort(reason?: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
|
||||||
|
interface AbortSignal extends EventTarget {
|
||||||
|
/**
|
||||||
|
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
||||||
|
*/
|
||||||
|
readonly aborted: boolean;
|
||||||
|
readonly reason: any;
|
||||||
|
onabort: null | ((this: AbortSignal, event: Event) => any);
|
||||||
|
throwIfAborted(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
|
||||||
|
: {
|
||||||
|
prototype: AbortController;
|
||||||
|
new(): AbortController;
|
||||||
|
};
|
||||||
|
|
||||||
|
var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
|
||||||
|
: {
|
||||||
|
prototype: AbortSignal;
|
||||||
|
new(): AbortSignal;
|
||||||
|
abort(reason?: any): AbortSignal;
|
||||||
|
timeout(milliseconds: number): AbortSignal;
|
||||||
|
any(signals: AbortSignal[]): AbortSignal;
|
||||||
|
};
|
||||||
|
// #endregion borrowed
|
||||||
|
|
||||||
|
// #region Storage
|
||||||
|
/**
|
||||||
|
* This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage)
|
||||||
|
*/
|
||||||
|
interface Storage extends _Storage {}
|
||||||
|
|
||||||
|
// Conditional on `onabort` rather than `onmessage`, in order to exclude lib.webworker
|
||||||
|
var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T
|
||||||
|
: {
|
||||||
|
prototype: Storage;
|
||||||
|
new(): Storage;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A browser-compatible implementation of [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||||
|
* Data is stored unencrypted in the file specified by the `--localstorage-file` CLI flag.
|
||||||
|
* Any modification of this data outside of the Web Storage API is not supported.
|
||||||
|
* Enable this API with the `--experimental-webstorage` CLI flag.
|
||||||
|
* @since v22.4.0
|
||||||
|
*/
|
||||||
|
var localStorage: Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A browser-compatible implementation of [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
|
||||||
|
* Data is stored in memory, with a storage quota of 10 MB.
|
||||||
|
* Any modification of this data outside of the Web Storage API is not supported.
|
||||||
|
* Enable this API with the `--experimental-webstorage` CLI flag.
|
||||||
|
* @since v22.4.0
|
||||||
|
*/
|
||||||
|
var sessionStorage: Storage;
|
||||||
|
// #endregion Storage
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since v17.0.0
|
||||||
|
*
|
||||||
|
* Creates a deep clone of an object.
|
||||||
|
*/
|
||||||
|
function structuredClone<T>(
|
||||||
|
value: T,
|
||||||
|
transfer?: { transfer: ReadonlyArray<import("worker_threads").TransferListItem> },
|
||||||
|
): T;
|
||||||
|
|
||||||
|
// #region DOMException
|
||||||
|
/**
|
||||||
|
* @since v17.0.0
|
||||||
|
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
|
||||||
|
*
|
||||||
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
|
||||||
|
*/
|
||||||
|
interface DOMException extends _DOMException {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since v17.0.0
|
||||||
|
*
|
||||||
|
* The WHATWG `DOMException` class. See [DOMException](https://developer.mozilla.org/docs/Web/API/DOMException) for more details.
|
||||||
|
*/
|
||||||
|
var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
|
||||||
|
: NodeDOMExceptionConstructor;
|
||||||
|
// #endregion DOMException
|
||||||
|
|
||||||
|
/*----------------------------------------------*
|
||||||
|
* *
|
||||||
|
* GLOBAL INTERFACES *
|
||||||
|
* *
|
||||||
|
*-----------------------------------------------*/
|
||||||
|
namespace NodeJS {
|
||||||
|
interface CallSite {
|
||||||
|
/**
|
||||||
|
* Value of "this"
|
||||||
|
*/
|
||||||
|
getThis(): unknown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of "this" as a string.
|
||||||
|
* This is the name of the function stored in the constructor field of
|
||||||
|
* "this", if available. Otherwise the object's [[Class]] internal
|
||||||
|
* property.
|
||||||
|
*/
|
||||||
|
getTypeName(): string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current function
|
||||||
|
*/
|
||||||
|
getFunction(): Function | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the current function, typically its name property.
|
||||||
|
* If a name property is not available an attempt will be made to try
|
||||||
|
* to infer a name from the function's context.
|
||||||
|
*/
|
||||||
|
getFunctionName(): string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the property [of "this" or one of its prototypes] that holds
|
||||||
|
* the current function
|
||||||
|
*/
|
||||||
|
getMethodName(): string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the script [if this function was defined in a script]
|
||||||
|
*/
|
||||||
|
getFileName(): string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current line number [if this function was defined in a script]
|
||||||
|
*/
|
||||||
|
getLineNumber(): number | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current column number [if this function was defined in a script]
|
||||||
|
*/
|
||||||
|
getColumnNumber(): number | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A call site object representing the location where eval was called
|
||||||
|
* [if this function was created using a call to eval]
|
||||||
|
*/
|
||||||
|
getEvalOrigin(): string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a toplevel invocation, that is, is "this" the global object?
|
||||||
|
*/
|
||||||
|
isToplevel(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this call take place in code defined by a call to eval?
|
||||||
|
*/
|
||||||
|
isEval(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this call in native V8 code?
|
||||||
|
*/
|
||||||
|
isNative(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a constructor call?
|
||||||
|
*/
|
||||||
|
isConstructor(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is this an async call (i.e. await, Promise.all(), or Promise.any())?
|
||||||
|
*/
|
||||||
|
isAsync(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is this an async call to Promise.all()?
|
||||||
|
*/
|
||||||
|
isPromiseAll(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the index of the promise element that was followed in
|
||||||
|
* Promise.all() or Promise.any() for async stack traces, or null
|
||||||
|
* if the CallSite is not an async
|
||||||
|
*/
|
||||||
|
getPromiseIndex(): number | null;
|
||||||
|
|
||||||
|
getScriptNameOrSourceURL(): string;
|
||||||
|
getScriptHash(): string;
|
||||||
|
|
||||||
|
getEnclosingColumnNumber(): number;
|
||||||
|
getEnclosingLineNumber(): number;
|
||||||
|
getPosition(): number;
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ErrnoException extends Error {
|
||||||
|
errno?: number | undefined;
|
||||||
|
code?: string | undefined;
|
||||||
|
path?: string | undefined;
|
||||||
|
syscall?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ReadableStream extends EventEmitter {
|
||||||
|
readable: boolean;
|
||||||
|
read(size?: number): string | Buffer;
|
||||||
|
setEncoding(encoding: BufferEncoding): this;
|
||||||
|
pause(): this;
|
||||||
|
resume(): this;
|
||||||
|
isPaused(): boolean;
|
||||||
|
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
|
||||||
|
unpipe(destination?: WritableStream): this;
|
||||||
|
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
||||||
|
wrap(oldStream: ReadableStream): this;
|
||||||
|
[Symbol.asyncIterator](): NodeJS.AsyncIterator<string | Buffer>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WritableStream extends EventEmitter {
|
||||||
|
writable: boolean;
|
||||||
|
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||||
|
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||||
|
end(cb?: () => void): this;
|
||||||
|
end(data: string | Uint8Array, cb?: () => void): this;
|
||||||
|
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ReadWriteStream extends ReadableStream, WritableStream {}
|
||||||
|
|
||||||
|
interface RefCounted {
|
||||||
|
ref(): this;
|
||||||
|
unref(): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Require {
|
||||||
|
(id: string): any;
|
||||||
|
resolve: RequireResolve;
|
||||||
|
cache: Dict<NodeModule>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
extensions: RequireExtensions;
|
||||||
|
main: Module | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequireResolve {
|
||||||
|
(id: string, options?: { paths?: string[] | undefined }): string;
|
||||||
|
paths(request: string): string[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
|
||||||
|
".js": (m: Module, filename: string) => any;
|
||||||
|
".json": (m: Module, filename: string) => any;
|
||||||
|
".node": (m: Module, filename: string) => any;
|
||||||
|
}
|
||||||
|
interface Module {
|
||||||
|
/**
|
||||||
|
* `true` if the module is running during the Node.js preload
|
||||||
|
*/
|
||||||
|
isPreloading: boolean;
|
||||||
|
exports: any;
|
||||||
|
require: Require;
|
||||||
|
id: string;
|
||||||
|
filename: string;
|
||||||
|
loaded: boolean;
|
||||||
|
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
||||||
|
parent: Module | null | undefined;
|
||||||
|
children: Module[];
|
||||||
|
/**
|
||||||
|
* @since v11.14.0
|
||||||
|
*
|
||||||
|
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
||||||
|
*/
|
||||||
|
path: string;
|
||||||
|
paths: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Dict<T> {
|
||||||
|
[key: string]: T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ReadOnlyDict<T> {
|
||||||
|
readonly [key: string]: T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An iterable iterator returned by the Node.js API. */
|
||||||
|
// Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used IterableIterator.
|
||||||
|
// TODO: In next major @types/node version, change default TReturn to undefined.
|
||||||
|
interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
|
||||||
|
[Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An async iterable iterator returned by the Node.js API. */
|
||||||
|
// Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used AsyncIterableIterator.
|
||||||
|
// TODO: In next major @types/node version, change default TReturn to undefined.
|
||||||
|
interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
|
||||||
|
[Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequestInit extends _RequestInit {}
|
||||||
|
|
||||||
|
function fetch(
|
||||||
|
input: string | URL | globalThis.Request,
|
||||||
|
init?: RequestInit,
|
||||||
|
): Promise<Response>;
|
||||||
|
|
||||||
|
interface Request extends _Request {}
|
||||||
|
var Request: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
Request: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof import("undici-types").Request;
|
||||||
|
|
||||||
|
interface ResponseInit extends _ResponseInit {}
|
||||||
|
|
||||||
|
interface Response extends _Response {}
|
||||||
|
var Response: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
Response: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof import("undici-types").Response;
|
||||||
|
|
||||||
|
interface FormData extends _FormData {}
|
||||||
|
var FormData: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
FormData: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof import("undici-types").FormData;
|
||||||
|
|
||||||
|
interface Headers extends _Headers {}
|
||||||
|
var Headers: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
Headers: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof import("undici-types").Headers;
|
||||||
|
|
||||||
|
interface MessageEvent extends _MessageEvent {}
|
||||||
|
/**
|
||||||
|
* @since v15.0.0
|
||||||
|
*/
|
||||||
|
var MessageEvent: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
MessageEvent: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof import("undici-types").MessageEvent;
|
||||||
|
|
||||||
|
interface WebSocket extends _WebSocket {}
|
||||||
|
var WebSocket: typeof globalThis extends { onmessage: any; WebSocket: infer T } ? T
|
||||||
|
: typeof import("undici-types").WebSocket;
|
||||||
|
|
||||||
|
interface EventSource extends _EventSource {}
|
||||||
|
/**
|
||||||
|
* Only available through the [--experimental-eventsource](https://nodejs.org/api/cli.html#--experimental-eventsource) flag.
|
||||||
|
*
|
||||||
|
* @since v22.3.0
|
||||||
|
*/
|
||||||
|
var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
|
||||||
|
: typeof import("undici-types").EventSource;
|
||||||
|
}
|
21
websocket_server/node_modules/.ignored/@types/node/globals.typedarray.d.ts
generated
vendored
Normal file
21
websocket_server/node_modules/.ignored/@types/node/globals.typedarray.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export {}; // Make this a module
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace NodeJS {
|
||||||
|
type TypedArray<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
||||||
|
| Uint8Array<TArrayBuffer>
|
||||||
|
| Uint8ClampedArray<TArrayBuffer>
|
||||||
|
| Uint16Array<TArrayBuffer>
|
||||||
|
| Uint32Array<TArrayBuffer>
|
||||||
|
| Int8Array<TArrayBuffer>
|
||||||
|
| Int16Array<TArrayBuffer>
|
||||||
|
| Int32Array<TArrayBuffer>
|
||||||
|
| BigUint64Array<TArrayBuffer>
|
||||||
|
| BigInt64Array<TArrayBuffer>
|
||||||
|
| Float32Array<TArrayBuffer>
|
||||||
|
| Float64Array<TArrayBuffer>;
|
||||||
|
type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
||||||
|
| TypedArray<TArrayBuffer>
|
||||||
|
| DataView<TArrayBuffer>;
|
||||||
|
}
|
||||||
|
}
|
1957
websocket_server/node_modules/.ignored/@types/node/http.d.ts
generated
vendored
Normal file
1957
websocket_server/node_modules/.ignored/@types/node/http.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2555
websocket_server/node_modules/.ignored/@types/node/http2.d.ts
generated
vendored
Normal file
2555
websocket_server/node_modules/.ignored/@types/node/http2.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
544
websocket_server/node_modules/.ignored/@types/node/https.d.ts
generated
vendored
Normal file
544
websocket_server/node_modules/.ignored/@types/node/https.d.ts
generated
vendored
Normal file
@ -0,0 +1,544 @@
|
|||||||
|
/**
|
||||||
|
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
||||||
|
* separate module.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/https.js)
|
||||||
|
*/
|
||||||
|
declare module "https" {
|
||||||
|
import { Duplex } from "node:stream";
|
||||||
|
import * as tls from "node:tls";
|
||||||
|
import * as http from "node:http";
|
||||||
|
import { URL } from "node:url";
|
||||||
|
type ServerOptions<
|
||||||
|
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||||
|
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||||
|
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||||
|
type RequestOptions =
|
||||||
|
& http.RequestOptions
|
||||||
|
& tls.SecureContextOptions
|
||||||
|
& {
|
||||||
|
checkServerIdentity?: typeof tls.checkServerIdentity | undefined;
|
||||||
|
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
||||||
|
servername?: string | undefined; // SNI TLS Extension
|
||||||
|
};
|
||||||
|
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||||
|
rejectUnauthorized?: boolean | undefined;
|
||||||
|
maxCachedSessions?: number | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
||||||
|
* @since v0.4.5
|
||||||
|
*/
|
||||||
|
class Agent extends http.Agent {
|
||||||
|
constructor(options?: AgentOptions);
|
||||||
|
options: AgentOptions;
|
||||||
|
}
|
||||||
|
interface Server<
|
||||||
|
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||||
|
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||||
|
> extends http.Server<Request, Response> {}
|
||||||
|
/**
|
||||||
|
* See `http.Server` for more information.
|
||||||
|
* @since v0.3.4
|
||||||
|
*/
|
||||||
|
class Server<
|
||||||
|
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||||
|
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||||
|
> extends tls.Server {
|
||||||
|
constructor(requestListener?: http.RequestListener<Request, Response>);
|
||||||
|
constructor(
|
||||||
|
options: ServerOptions<Request, Response>,
|
||||||
|
requestListener?: http.RequestListener<Request, Response>,
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Closes all connections connected to this server.
|
||||||
|
* @since v18.2.0
|
||||||
|
*/
|
||||||
|
closeAllConnections(): void;
|
||||||
|
/**
|
||||||
|
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
||||||
|
* @since v18.2.0
|
||||||
|
*/
|
||||||
|
closeIdleConnections(): void;
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
addListener(
|
||||||
|
event: "newSession",
|
||||||
|
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
addListener(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
listener: (
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
) => void,
|
||||||
|
): this;
|
||||||
|
addListener(
|
||||||
|
event: "resumeSession",
|
||||||
|
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
addListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||||
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
addListener(event: "listening", listener: () => void): this;
|
||||||
|
addListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
addListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
addListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||||
|
addListener(
|
||||||
|
event: "connect",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
addListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
addListener(
|
||||||
|
event: "upgrade",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
emit(event: string, ...args: any[]): boolean;
|
||||||
|
emit(event: "keylog", line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
||||||
|
emit(
|
||||||
|
event: "newSession",
|
||||||
|
sessionId: Buffer,
|
||||||
|
sessionData: Buffer,
|
||||||
|
callback: (err: Error, resp: Buffer) => void,
|
||||||
|
): boolean;
|
||||||
|
emit(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
): boolean;
|
||||||
|
emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
||||||
|
emit(event: "secureConnection", tlsSocket: tls.TLSSocket): boolean;
|
||||||
|
emit(event: "tlsClientError", err: Error, tlsSocket: tls.TLSSocket): boolean;
|
||||||
|
emit(event: "close"): boolean;
|
||||||
|
emit(event: "connection", socket: Duplex): boolean;
|
||||||
|
emit(event: "error", err: Error): boolean;
|
||||||
|
emit(event: "listening"): boolean;
|
||||||
|
emit(
|
||||||
|
event: "checkContinue",
|
||||||
|
req: InstanceType<Request>,
|
||||||
|
res: InstanceType<Response>,
|
||||||
|
): boolean;
|
||||||
|
emit(
|
||||||
|
event: "checkExpectation",
|
||||||
|
req: InstanceType<Request>,
|
||||||
|
res: InstanceType<Response>,
|
||||||
|
): boolean;
|
||||||
|
emit(event: "clientError", err: Error, socket: Duplex): boolean;
|
||||||
|
emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||||
|
emit(
|
||||||
|
event: "request",
|
||||||
|
req: InstanceType<Request>,
|
||||||
|
res: InstanceType<Response>,
|
||||||
|
): boolean;
|
||||||
|
emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
on(
|
||||||
|
event: "newSession",
|
||||||
|
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
on(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
listener: (
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
) => void,
|
||||||
|
): this;
|
||||||
|
on(
|
||||||
|
event: "resumeSession",
|
||||||
|
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
on(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
on(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "connection", listener: (socket: Duplex) => void): this;
|
||||||
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
|
on(event: "listening", listener: () => void): this;
|
||||||
|
on(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
on(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
on(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||||
|
on(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||||
|
on(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
on(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
once(
|
||||||
|
event: "newSession",
|
||||||
|
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
once(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
listener: (
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
) => void,
|
||||||
|
): this;
|
||||||
|
once(
|
||||||
|
event: "resumeSession",
|
||||||
|
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
once(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
once(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "connection", listener: (socket: Duplex) => void): this;
|
||||||
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
|
once(event: "listening", listener: () => void): this;
|
||||||
|
once(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
once(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
once(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||||
|
once(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||||
|
once(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
once(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependListener(
|
||||||
|
event: "newSession",
|
||||||
|
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
prependListener(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
listener: (
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
) => void,
|
||||||
|
): this;
|
||||||
|
prependListener(
|
||||||
|
event: "resumeSession",
|
||||||
|
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
prependListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||||
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
|
prependListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||||
|
prependListener(
|
||||||
|
event: "connect",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
prependListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependListener(
|
||||||
|
event: "upgrade",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependOnceListener(
|
||||||
|
event: "newSession",
|
||||||
|
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(
|
||||||
|
event: "OCSPRequest",
|
||||||
|
listener: (
|
||||||
|
certificate: Buffer,
|
||||||
|
issuer: Buffer,
|
||||||
|
callback: (err: Error | null, resp: Buffer) => void,
|
||||||
|
) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(
|
||||||
|
event: "resumeSession",
|
||||||
|
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependOnceListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependOnceListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||||
|
prependOnceListener(
|
||||||
|
event: "connect",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
prependOnceListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||||
|
prependOnceListener(
|
||||||
|
event: "upgrade",
|
||||||
|
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||||
|
): this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* // curl -k https://localhost:8000/
|
||||||
|
* import https from 'node:https';
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
*
|
||||||
|
* const options = {
|
||||||
|
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||||
|
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* https.createServer(options, (req, res) => {
|
||||||
|
* res.writeHead(200);
|
||||||
|
* res.end('hello world\n');
|
||||||
|
* }).listen(8000);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Or
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import https from 'node:https';
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
*
|
||||||
|
* const options = {
|
||||||
|
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
||||||
|
* passphrase: 'sample',
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* https.createServer(options, (req, res) => {
|
||||||
|
* res.writeHead(200);
|
||||||
|
* res.end('hello world\n');
|
||||||
|
* }).listen(8000);
|
||||||
|
* ```
|
||||||
|
* @since v0.3.4
|
||||||
|
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
||||||
|
* @param requestListener A listener to be added to the `'request'` event.
|
||||||
|
*/
|
||||||
|
function createServer<
|
||||||
|
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||||
|
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||||
|
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
|
||||||
|
function createServer<
|
||||||
|
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||||
|
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||||
|
>(
|
||||||
|
options: ServerOptions<Request, Response>,
|
||||||
|
requestListener?: http.RequestListener<Request, Response>,
|
||||||
|
): Server<Request, Response>;
|
||||||
|
/**
|
||||||
|
* Makes a request to a secure web server.
|
||||||
|
*
|
||||||
|
* The following additional `options` from `tls.connect()` are also accepted: `ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`, `honorCipherOrder`, `key`, `passphrase`,
|
||||||
|
* `pfx`, `rejectUnauthorized`, `secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`, `highWaterMark`.
|
||||||
|
*
|
||||||
|
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
||||||
|
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
||||||
|
*
|
||||||
|
* `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
|
||||||
|
* upload a file with a POST request, then write to the `ClientRequest` object.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import https from 'node:https';
|
||||||
|
*
|
||||||
|
* const options = {
|
||||||
|
* hostname: 'encrypted.google.com',
|
||||||
|
* port: 443,
|
||||||
|
* path: '/',
|
||||||
|
* method: 'GET',
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* const req = https.request(options, (res) => {
|
||||||
|
* console.log('statusCode:', res.statusCode);
|
||||||
|
* console.log('headers:', res.headers);
|
||||||
|
*
|
||||||
|
* res.on('data', (d) => {
|
||||||
|
* process.stdout.write(d);
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* req.on('error', (e) => {
|
||||||
|
* console.error(e);
|
||||||
|
* });
|
||||||
|
* req.end();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example using options from `tls.connect()`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const options = {
|
||||||
|
* hostname: 'encrypted.google.com',
|
||||||
|
* port: 443,
|
||||||
|
* path: '/',
|
||||||
|
* method: 'GET',
|
||||||
|
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||||
|
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||||
|
* };
|
||||||
|
* options.agent = new https.Agent(options);
|
||||||
|
*
|
||||||
|
* const req = https.request(options, (res) => {
|
||||||
|
* // ...
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Alternatively, opt out of connection pooling by not using an `Agent`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const options = {
|
||||||
|
* hostname: 'encrypted.google.com',
|
||||||
|
* port: 443,
|
||||||
|
* path: '/',
|
||||||
|
* method: 'GET',
|
||||||
|
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||||
|
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||||
|
* agent: false,
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* const req = https.request(options, (res) => {
|
||||||
|
* // ...
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example using a `URL` as `options`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const options = new URL('https://abc:xyz@example.com');
|
||||||
|
*
|
||||||
|
* const req = https.request(options, (res) => {
|
||||||
|
* // ...
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import tls from 'node:tls';
|
||||||
|
* import https from 'node:https';
|
||||||
|
* import crypto from 'node:crypto';
|
||||||
|
*
|
||||||
|
* function sha256(s) {
|
||||||
|
* return crypto.createHash('sha256').update(s).digest('base64');
|
||||||
|
* }
|
||||||
|
* const options = {
|
||||||
|
* hostname: 'github.com',
|
||||||
|
* port: 443,
|
||||||
|
* path: '/',
|
||||||
|
* method: 'GET',
|
||||||
|
* checkServerIdentity: function(host, cert) {
|
||||||
|
* // Make sure the certificate is issued to the host we are connected to
|
||||||
|
* const err = tls.checkServerIdentity(host, cert);
|
||||||
|
* if (err) {
|
||||||
|
* return err;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Pin the public key, similar to HPKP pin-sha256 pinning
|
||||||
|
* const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
|
||||||
|
* if (sha256(cert.pubkey) !== pubkey256) {
|
||||||
|
* const msg = 'Certificate verification error: ' +
|
||||||
|
* `The public key of '${cert.subject.CN}' ` +
|
||||||
|
* 'does not match our pinned fingerprint';
|
||||||
|
* return new Error(msg);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Pin the exact certificate, rather than the pub key
|
||||||
|
* const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
|
||||||
|
* 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
|
||||||
|
* if (cert.fingerprint256 !== cert256) {
|
||||||
|
* const msg = 'Certificate verification error: ' +
|
||||||
|
* `The certificate of '${cert.subject.CN}' ` +
|
||||||
|
* 'does not match our pinned fingerprint';
|
||||||
|
* return new Error(msg);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // This loop is informational only.
|
||||||
|
* // Print the certificate and public key fingerprints of all certs in the
|
||||||
|
* // chain. Its common to pin the public key of the issuer on the public
|
||||||
|
* // internet, while pinning the public key of the service in sensitive
|
||||||
|
* // environments.
|
||||||
|
* do {
|
||||||
|
* console.log('Subject Common Name:', cert.subject.CN);
|
||||||
|
* console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
|
||||||
|
*
|
||||||
|
* hash = crypto.createHash('sha256');
|
||||||
|
* console.log(' Public key ping-sha256:', sha256(cert.pubkey));
|
||||||
|
*
|
||||||
|
* lastprint256 = cert.fingerprint256;
|
||||||
|
* cert = cert.issuerCertificate;
|
||||||
|
* } while (cert.fingerprint256 !== lastprint256);
|
||||||
|
*
|
||||||
|
* },
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* options.agent = new https.Agent(options);
|
||||||
|
* const req = https.request(options, (res) => {
|
||||||
|
* console.log('All OK. Server matched our pinned cert or public key');
|
||||||
|
* console.log('statusCode:', res.statusCode);
|
||||||
|
* // Print the HPKP values
|
||||||
|
* console.log('headers:', res.headers['public-key-pins']);
|
||||||
|
*
|
||||||
|
* res.on('data', (d) => {});
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* req.on('error', (e) => {
|
||||||
|
* console.error(e.message);
|
||||||
|
* });
|
||||||
|
* req.end();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Outputs for example:
|
||||||
|
*
|
||||||
|
* ```text
|
||||||
|
* Subject Common Name: github.com
|
||||||
|
* Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
|
||||||
|
* Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
|
||||||
|
* Subject Common Name: DigiCert SHA2 Extended Validation Server CA
|
||||||
|
* Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
|
||||||
|
* Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
|
||||||
|
* Subject Common Name: DigiCert High Assurance EV Root CA
|
||||||
|
* Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
|
||||||
|
* Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
|
||||||
|
* All OK. Server matched our pinned cert or public key
|
||||||
|
* statusCode: 200
|
||||||
|
* headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
|
||||||
|
* pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
|
||||||
|
* pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
|
||||||
|
* ```
|
||||||
|
* @since v0.3.6
|
||||||
|
* @param options Accepts all `options` from `request`, with some differences in default values:
|
||||||
|
*/
|
||||||
|
function request(
|
||||||
|
options: RequestOptions | string | URL,
|
||||||
|
callback?: (res: http.IncomingMessage) => void,
|
||||||
|
): http.ClientRequest;
|
||||||
|
function request(
|
||||||
|
url: string | URL,
|
||||||
|
options: RequestOptions,
|
||||||
|
callback?: (res: http.IncomingMessage) => void,
|
||||||
|
): http.ClientRequest;
|
||||||
|
/**
|
||||||
|
* Like `http.get()` but for HTTPS.
|
||||||
|
*
|
||||||
|
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
||||||
|
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import https from 'node:https';
|
||||||
|
*
|
||||||
|
* https.get('https://encrypted.google.com/', (res) => {
|
||||||
|
* console.log('statusCode:', res.statusCode);
|
||||||
|
* console.log('headers:', res.headers);
|
||||||
|
*
|
||||||
|
* res.on('data', (d) => {
|
||||||
|
* process.stdout.write(d);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* }).on('error', (e) => {
|
||||||
|
* console.error(e);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v0.3.6
|
||||||
|
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
|
||||||
|
*/
|
||||||
|
function get(
|
||||||
|
options: RequestOptions | string | URL,
|
||||||
|
callback?: (res: http.IncomingMessage) => void,
|
||||||
|
): http.ClientRequest;
|
||||||
|
function get(
|
||||||
|
url: string | URL,
|
||||||
|
options: RequestOptions,
|
||||||
|
callback?: (res: http.IncomingMessage) => void,
|
||||||
|
): http.ClientRequest;
|
||||||
|
let globalAgent: Agent;
|
||||||
|
}
|
||||||
|
declare module "node:https" {
|
||||||
|
export * from "https";
|
||||||
|
}
|
92
websocket_server/node_modules/.ignored/@types/node/index.d.ts
generated
vendored
Normal file
92
websocket_server/node_modules/.ignored/@types/node/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* License for programmatically and manually incorporated
|
||||||
|
* documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
|
||||||
|
*
|
||||||
|
* Copyright Node.js contributors. All rights reserved.
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// NOTE: These definitions support Node.js and TypeScript 5.7+.
|
||||||
|
|
||||||
|
// Reference required TypeScript libs:
|
||||||
|
/// <reference lib="es2020" />
|
||||||
|
|
||||||
|
// TypeScript backwards-compatibility definitions:
|
||||||
|
/// <reference path="compatibility/index.d.ts" />
|
||||||
|
|
||||||
|
// Definitions specific to TypeScript 5.7+:
|
||||||
|
/// <reference path="globals.typedarray.d.ts" />
|
||||||
|
/// <reference path="buffer.buffer.d.ts" />
|
||||||
|
|
||||||
|
// Definitions for Node.js modules that are not specific to any version of TypeScript:
|
||||||
|
/// <reference path="globals.d.ts" />
|
||||||
|
/// <reference path="assert.d.ts" />
|
||||||
|
/// <reference path="assert/strict.d.ts" />
|
||||||
|
/// <reference path="async_hooks.d.ts" />
|
||||||
|
/// <reference path="buffer.d.ts" />
|
||||||
|
/// <reference path="child_process.d.ts" />
|
||||||
|
/// <reference path="cluster.d.ts" />
|
||||||
|
/// <reference path="console.d.ts" />
|
||||||
|
/// <reference path="constants.d.ts" />
|
||||||
|
/// <reference path="crypto.d.ts" />
|
||||||
|
/// <reference path="dgram.d.ts" />
|
||||||
|
/// <reference path="diagnostics_channel.d.ts" />
|
||||||
|
/// <reference path="dns.d.ts" />
|
||||||
|
/// <reference path="dns/promises.d.ts" />
|
||||||
|
/// <reference path="dns/promises.d.ts" />
|
||||||
|
/// <reference path="domain.d.ts" />
|
||||||
|
/// <reference path="dom-events.d.ts" />
|
||||||
|
/// <reference path="events.d.ts" />
|
||||||
|
/// <reference path="fs.d.ts" />
|
||||||
|
/// <reference path="fs/promises.d.ts" />
|
||||||
|
/// <reference path="http.d.ts" />
|
||||||
|
/// <reference path="http2.d.ts" />
|
||||||
|
/// <reference path="https.d.ts" />
|
||||||
|
/// <reference path="inspector.d.ts" />
|
||||||
|
/// <reference path="module.d.ts" />
|
||||||
|
/// <reference path="net.d.ts" />
|
||||||
|
/// <reference path="os.d.ts" />
|
||||||
|
/// <reference path="path.d.ts" />
|
||||||
|
/// <reference path="perf_hooks.d.ts" />
|
||||||
|
/// <reference path="process.d.ts" />
|
||||||
|
/// <reference path="punycode.d.ts" />
|
||||||
|
/// <reference path="querystring.d.ts" />
|
||||||
|
/// <reference path="readline.d.ts" />
|
||||||
|
/// <reference path="readline/promises.d.ts" />
|
||||||
|
/// <reference path="repl.d.ts" />
|
||||||
|
/// <reference path="sea.d.ts" />
|
||||||
|
/// <reference path="sqlite.d.ts" />
|
||||||
|
/// <reference path="stream.d.ts" />
|
||||||
|
/// <reference path="stream/promises.d.ts" />
|
||||||
|
/// <reference path="stream/consumers.d.ts" />
|
||||||
|
/// <reference path="stream/web.d.ts" />
|
||||||
|
/// <reference path="string_decoder.d.ts" />
|
||||||
|
/// <reference path="test.d.ts" />
|
||||||
|
/// <reference path="timers.d.ts" />
|
||||||
|
/// <reference path="timers/promises.d.ts" />
|
||||||
|
/// <reference path="tls.d.ts" />
|
||||||
|
/// <reference path="trace_events.d.ts" />
|
||||||
|
/// <reference path="tty.d.ts" />
|
||||||
|
/// <reference path="url.d.ts" />
|
||||||
|
/// <reference path="util.d.ts" />
|
||||||
|
/// <reference path="v8.d.ts" />
|
||||||
|
/// <reference path="vm.d.ts" />
|
||||||
|
/// <reference path="wasi.d.ts" />
|
||||||
|
/// <reference path="worker_threads.d.ts" />
|
||||||
|
/// <reference path="zlib.d.ts" />
|
3966
websocket_server/node_modules/.ignored/@types/node/inspector.d.ts
generated
vendored
Normal file
3966
websocket_server/node_modules/.ignored/@types/node/inspector.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
301
websocket_server/node_modules/.ignored/@types/node/module.d.ts
generated
vendored
Normal file
301
websocket_server/node_modules/.ignored/@types/node/module.d.ts
generated
vendored
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
/**
|
||||||
|
* @since v0.3.7
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
declare module "module" {
|
||||||
|
import { URL } from "node:url";
|
||||||
|
import { MessagePort } from "node:worker_threads";
|
||||||
|
namespace Module {
|
||||||
|
/**
|
||||||
|
* The `module.syncBuiltinESMExports()` method updates all the live bindings for
|
||||||
|
* builtin `ES Modules` to match the properties of the `CommonJS` exports. It
|
||||||
|
* does not add or remove exported names from the `ES Modules`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
* import assert from 'node:assert';
|
||||||
|
* import { syncBuiltinESMExports } from 'node:module';
|
||||||
|
*
|
||||||
|
* fs.readFile = newAPI;
|
||||||
|
*
|
||||||
|
* delete fs.readFileSync;
|
||||||
|
*
|
||||||
|
* function newAPI() {
|
||||||
|
* // ...
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* fs.newAPI = newAPI;
|
||||||
|
*
|
||||||
|
* syncBuiltinESMExports();
|
||||||
|
*
|
||||||
|
* import('node:fs').then((esmFS) => {
|
||||||
|
* // It syncs the existing readFile property with the new value
|
||||||
|
* assert.strictEqual(esmFS.readFile, newAPI);
|
||||||
|
* // readFileSync has been deleted from the required fs
|
||||||
|
* assert.strictEqual('readFileSync' in fs, false);
|
||||||
|
* // syncBuiltinESMExports() does not remove readFileSync from esmFS
|
||||||
|
* assert.strictEqual('readFileSync' in esmFS, true);
|
||||||
|
* // syncBuiltinESMExports() does not add names
|
||||||
|
* assert.strictEqual(esmFS.newAPI, undefined);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v12.12.0
|
||||||
|
*/
|
||||||
|
function syncBuiltinESMExports(): void;
|
||||||
|
/**
|
||||||
|
* `path` is the resolved path for the file for which a corresponding source map
|
||||||
|
* should be fetched.
|
||||||
|
* @since v13.7.0, v12.17.0
|
||||||
|
* @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise.
|
||||||
|
*/
|
||||||
|
function findSourceMap(path: string, error?: Error): SourceMap;
|
||||||
|
interface SourceMapPayload {
|
||||||
|
file: string;
|
||||||
|
version: number;
|
||||||
|
sources: string[];
|
||||||
|
sourcesContent: string[];
|
||||||
|
names: string[];
|
||||||
|
mappings: string;
|
||||||
|
sourceRoot: string;
|
||||||
|
}
|
||||||
|
interface SourceMapping {
|
||||||
|
generatedLine: number;
|
||||||
|
generatedColumn: number;
|
||||||
|
originalSource: string;
|
||||||
|
originalLine: number;
|
||||||
|
originalColumn: number;
|
||||||
|
}
|
||||||
|
interface SourceOrigin {
|
||||||
|
/**
|
||||||
|
* The name of the range in the source map, if one was provided
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
/**
|
||||||
|
* The file name of the original source, as reported in the SourceMap
|
||||||
|
*/
|
||||||
|
fileName: string;
|
||||||
|
/**
|
||||||
|
* The 1-indexed lineNumber of the corresponding call site in the original source
|
||||||
|
*/
|
||||||
|
lineNumber: number;
|
||||||
|
/**
|
||||||
|
* The 1-indexed columnNumber of the corresponding call site in the original source
|
||||||
|
*/
|
||||||
|
columnNumber: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @since v13.7.0, v12.17.0
|
||||||
|
*/
|
||||||
|
class SourceMap {
|
||||||
|
/**
|
||||||
|
* Getter for the payload used to construct the `SourceMap` instance.
|
||||||
|
*/
|
||||||
|
readonly payload: SourceMapPayload;
|
||||||
|
constructor(payload: SourceMapPayload);
|
||||||
|
/**
|
||||||
|
* Given a line offset and column offset in the generated source
|
||||||
|
* file, returns an object representing the SourceMap range in the
|
||||||
|
* original file if found, or an empty object if not.
|
||||||
|
*
|
||||||
|
* The object returned contains the following keys:
|
||||||
|
*
|
||||||
|
* The returned value represents the raw range as it appears in the
|
||||||
|
* SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
|
||||||
|
* column numbers as they appear in Error messages and CallSite
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* To get the corresponding 1-indexed line and column numbers from a
|
||||||
|
* lineNumber and columnNumber as they are reported by Error stacks
|
||||||
|
* and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
|
||||||
|
* @param lineOffset The zero-indexed line number offset in the generated source
|
||||||
|
* @param columnOffset The zero-indexed column number offset in the generated source
|
||||||
|
*/
|
||||||
|
findEntry(lineOffset: number, columnOffset: number): SourceMapping;
|
||||||
|
/**
|
||||||
|
* Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
|
||||||
|
* find the corresponding call site location in the original source.
|
||||||
|
*
|
||||||
|
* If the `lineNumber` and `columnNumber` provided are not found in any source map,
|
||||||
|
* then an empty object is returned.
|
||||||
|
* @param lineNumber The 1-indexed line number of the call site in the generated source
|
||||||
|
* @param columnNumber The 1-indexed column number of the call site in the generated source
|
||||||
|
*/
|
||||||
|
findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
|
||||||
|
}
|
||||||
|
interface ImportAttributes extends NodeJS.Dict<string> {
|
||||||
|
type?: string | undefined;
|
||||||
|
}
|
||||||
|
type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
|
||||||
|
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
||||||
|
interface GlobalPreloadContext {
|
||||||
|
port: MessagePort;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated This hook will be removed in a future version.
|
||||||
|
* Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored.
|
||||||
|
*
|
||||||
|
* Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
|
||||||
|
* This hook allows the return of a string that is run as a sloppy-mode script on startup.
|
||||||
|
*
|
||||||
|
* @param context Information to assist the preload code
|
||||||
|
* @return Code to run before application startup
|
||||||
|
*/
|
||||||
|
type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
|
||||||
|
/**
|
||||||
|
* The `initialize` hook provides a way to define a custom function that runs in the hooks thread
|
||||||
|
* when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
|
||||||
|
*
|
||||||
|
* This hook can receive data from a `register` invocation, including ports and other transferrable objects.
|
||||||
|
* The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
|
||||||
|
*/
|
||||||
|
type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
|
||||||
|
interface ResolveHookContext {
|
||||||
|
/**
|
||||||
|
* Export conditions of the relevant `package.json`
|
||||||
|
*/
|
||||||
|
conditions: string[];
|
||||||
|
/**
|
||||||
|
* An object whose key-value pairs represent the assertions for the module to import
|
||||||
|
*/
|
||||||
|
importAttributes: ImportAttributes;
|
||||||
|
/**
|
||||||
|
* The module importing this one, or undefined if this is the Node.js entry point
|
||||||
|
*/
|
||||||
|
parentURL: string | undefined;
|
||||||
|
}
|
||||||
|
interface ResolveFnOutput {
|
||||||
|
/**
|
||||||
|
* A hint to the load hook (it might be ignored)
|
||||||
|
*/
|
||||||
|
format?: ModuleFormat | null | undefined;
|
||||||
|
/**
|
||||||
|
* The import attributes to use when caching the module (optional; if excluded the input will be used)
|
||||||
|
*/
|
||||||
|
importAttributes?: ImportAttributes | undefined;
|
||||||
|
/**
|
||||||
|
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
shortCircuit?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The absolute URL to which this input resolves
|
||||||
|
*/
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
|
||||||
|
* If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
|
||||||
|
* if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
|
||||||
|
*
|
||||||
|
* @param specifier The specified URL path of the module to be resolved
|
||||||
|
* @param context
|
||||||
|
* @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
|
||||||
|
*/
|
||||||
|
type ResolveHook = (
|
||||||
|
specifier: string,
|
||||||
|
context: ResolveHookContext,
|
||||||
|
nextResolve: (
|
||||||
|
specifier: string,
|
||||||
|
context?: ResolveHookContext,
|
||||||
|
) => ResolveFnOutput | Promise<ResolveFnOutput>,
|
||||||
|
) => ResolveFnOutput | Promise<ResolveFnOutput>;
|
||||||
|
interface LoadHookContext {
|
||||||
|
/**
|
||||||
|
* Export conditions of the relevant `package.json`
|
||||||
|
*/
|
||||||
|
conditions: string[];
|
||||||
|
/**
|
||||||
|
* The format optionally supplied by the `resolve` hook chain
|
||||||
|
*/
|
||||||
|
format: ModuleFormat;
|
||||||
|
/**
|
||||||
|
* An object whose key-value pairs represent the assertions for the module to import
|
||||||
|
*/
|
||||||
|
importAttributes: ImportAttributes;
|
||||||
|
}
|
||||||
|
interface LoadFnOutput {
|
||||||
|
format: ModuleFormat;
|
||||||
|
/**
|
||||||
|
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
shortCircuit?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The source for Node.js to evaluate
|
||||||
|
*/
|
||||||
|
source?: ModuleSource;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
|
||||||
|
* It is also in charge of validating the import assertion.
|
||||||
|
*
|
||||||
|
* @param url The URL/path of the module to be loaded
|
||||||
|
* @param context Metadata about the module
|
||||||
|
* @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
|
||||||
|
*/
|
||||||
|
type LoadHook = (
|
||||||
|
url: string,
|
||||||
|
context: LoadHookContext,
|
||||||
|
nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>,
|
||||||
|
) => LoadFnOutput | Promise<LoadFnOutput>;
|
||||||
|
}
|
||||||
|
interface RegisterOptions<Data> {
|
||||||
|
parentURL: string | URL;
|
||||||
|
data?: Data | undefined;
|
||||||
|
transferList?: any[] | undefined;
|
||||||
|
}
|
||||||
|
interface Module extends NodeModule {}
|
||||||
|
class Module {
|
||||||
|
static runMain(): void;
|
||||||
|
static wrap(code: string): string;
|
||||||
|
static createRequire(path: string | URL): NodeRequire;
|
||||||
|
static builtinModules: string[];
|
||||||
|
static isBuiltin(moduleName: string): boolean;
|
||||||
|
static Module: typeof Module;
|
||||||
|
static register<Data = any>(
|
||||||
|
specifier: string | URL,
|
||||||
|
parentURL?: string | URL,
|
||||||
|
options?: RegisterOptions<Data>,
|
||||||
|
): void;
|
||||||
|
static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
||||||
|
constructor(id: string, parent?: Module);
|
||||||
|
}
|
||||||
|
global {
|
||||||
|
interface ImportMeta {
|
||||||
|
/**
|
||||||
|
* The directory name of the current module. This is the same as the `path.dirname()` of the `import.meta.filename`.
|
||||||
|
* **Caveat:** only present on `file:` modules.
|
||||||
|
*/
|
||||||
|
dirname: string;
|
||||||
|
/**
|
||||||
|
* The full absolute path and filename of the current module, with symlinks resolved.
|
||||||
|
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`.
|
||||||
|
* **Caveat:** only local modules support this property. Modules not using the `file:` protocol will not provide it.
|
||||||
|
*/
|
||||||
|
filename: string;
|
||||||
|
/**
|
||||||
|
* The absolute `file:` URL of the module.
|
||||||
|
*/
|
||||||
|
url: string;
|
||||||
|
/**
|
||||||
|
* Provides a module-relative resolution function scoped to each module, returning
|
||||||
|
* the URL string.
|
||||||
|
*
|
||||||
|
* Second `parent` parameter is only used when the `--experimental-import-meta-resolve`
|
||||||
|
* command flag enabled.
|
||||||
|
*
|
||||||
|
* @since v20.6.0
|
||||||
|
*
|
||||||
|
* @param specifier The module specifier to resolve relative to `parent`.
|
||||||
|
* @param parent The absolute parent module URL to resolve from.
|
||||||
|
* @returns The absolute (`file:`) URL string for the resolved module.
|
||||||
|
*/
|
||||||
|
resolve(specifier: string, parent?: string | URL | undefined): string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export = Module;
|
||||||
|
}
|
||||||
|
declare module "node:module" {
|
||||||
|
import module = require("module");
|
||||||
|
export = module;
|
||||||
|
}
|
1001
websocket_server/node_modules/.ignored/@types/node/net.d.ts
generated
vendored
Normal file
1001
websocket_server/node_modules/.ignored/@types/node/net.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
495
websocket_server/node_modules/.ignored/@types/node/os.d.ts
generated
vendored
Normal file
495
websocket_server/node_modules/.ignored/@types/node/os.d.ts
generated
vendored
Normal file
@ -0,0 +1,495 @@
|
|||||||
|
/**
|
||||||
|
* The `node:os` module provides operating system-related utility methods and
|
||||||
|
* properties. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import os from 'node:os';
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/os.js)
|
||||||
|
*/
|
||||||
|
declare module "os" {
|
||||||
|
interface CpuInfo {
|
||||||
|
model: string;
|
||||||
|
speed: number;
|
||||||
|
times: {
|
||||||
|
/** The number of milliseconds the CPU has spent in user mode. */
|
||||||
|
user: number;
|
||||||
|
/** The number of milliseconds the CPU has spent in nice mode. */
|
||||||
|
nice: number;
|
||||||
|
/** The number of milliseconds the CPU has spent in sys mode. */
|
||||||
|
sys: number;
|
||||||
|
/** The number of milliseconds the CPU has spent in idle mode. */
|
||||||
|
idle: number;
|
||||||
|
/** The number of milliseconds the CPU has spent in irq mode. */
|
||||||
|
irq: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface NetworkInterfaceBase {
|
||||||
|
address: string;
|
||||||
|
netmask: string;
|
||||||
|
mac: string;
|
||||||
|
internal: boolean;
|
||||||
|
cidr: string | null;
|
||||||
|
}
|
||||||
|
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||||
|
family: "IPv4";
|
||||||
|
scopeid?: undefined;
|
||||||
|
}
|
||||||
|
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||||
|
family: "IPv6";
|
||||||
|
scopeid: number;
|
||||||
|
}
|
||||||
|
interface UserInfo<T> {
|
||||||
|
username: T;
|
||||||
|
uid: number;
|
||||||
|
gid: number;
|
||||||
|
shell: T | null;
|
||||||
|
homedir: T;
|
||||||
|
}
|
||||||
|
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
||||||
|
/**
|
||||||
|
* Returns the host name of the operating system as a string.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function hostname(): string;
|
||||||
|
/**
|
||||||
|
* Returns an array containing the 1, 5, and 15 minute load averages.
|
||||||
|
*
|
||||||
|
* The load average is a measure of system activity calculated by the operating
|
||||||
|
* system and expressed as a fractional number.
|
||||||
|
*
|
||||||
|
* The load average is a Unix-specific concept. On Windows, the return value is
|
||||||
|
* always `[0, 0, 0]`.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function loadavg(): number[];
|
||||||
|
/**
|
||||||
|
* Returns the system uptime in number of seconds.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function uptime(): number;
|
||||||
|
/**
|
||||||
|
* Returns the amount of free system memory in bytes as an integer.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function freemem(): number;
|
||||||
|
/**
|
||||||
|
* Returns the total amount of system memory in bytes as an integer.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function totalmem(): number;
|
||||||
|
/**
|
||||||
|
* Returns an array of objects containing information about each logical CPU core.
|
||||||
|
* The array will be empty if no CPU information is available, such as if the `/proc` file system is unavailable.
|
||||||
|
*
|
||||||
|
* The properties included on each object include:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||||
|
* speed: 2926,
|
||||||
|
* times: {
|
||||||
|
* user: 252020,
|
||||||
|
* nice: 0,
|
||||||
|
* sys: 30340,
|
||||||
|
* idle: 1070356870,
|
||||||
|
* irq: 0,
|
||||||
|
* },
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||||
|
* speed: 2926,
|
||||||
|
* times: {
|
||||||
|
* user: 306960,
|
||||||
|
* nice: 0,
|
||||||
|
* sys: 26980,
|
||||||
|
* idle: 1071569080,
|
||||||
|
* irq: 0,
|
||||||
|
* },
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||||
|
* speed: 2926,
|
||||||
|
* times: {
|
||||||
|
* user: 248450,
|
||||||
|
* nice: 0,
|
||||||
|
* sys: 21750,
|
||||||
|
* idle: 1070919370,
|
||||||
|
* irq: 0,
|
||||||
|
* },
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||||
|
* speed: 2926,
|
||||||
|
* times: {
|
||||||
|
* user: 256880,
|
||||||
|
* nice: 0,
|
||||||
|
* sys: 19430,
|
||||||
|
* idle: 1070905480,
|
||||||
|
* irq: 20,
|
||||||
|
* },
|
||||||
|
* },
|
||||||
|
* ]
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `nice` values are POSIX-only. On Windows, the `nice` values of all processors
|
||||||
|
* are always 0.
|
||||||
|
*
|
||||||
|
* `os.cpus().length` should not be used to calculate the amount of parallelism
|
||||||
|
* available to an application. Use {@link availableParallelism} for this purpose.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function cpus(): CpuInfo[];
|
||||||
|
/**
|
||||||
|
* Returns an estimate of the default amount of parallelism a program should use.
|
||||||
|
* Always returns a value greater than zero.
|
||||||
|
*
|
||||||
|
* This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism).
|
||||||
|
* @since v19.4.0, v18.14.0
|
||||||
|
*/
|
||||||
|
function availableParallelism(): number;
|
||||||
|
/**
|
||||||
|
* Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
|
||||||
|
* returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
|
||||||
|
*
|
||||||
|
* See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
|
||||||
|
* about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function type(): string;
|
||||||
|
/**
|
||||||
|
* Returns the operating system as a string.
|
||||||
|
*
|
||||||
|
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See
|
||||||
|
* [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
||||||
|
* @since v0.3.3
|
||||||
|
*/
|
||||||
|
function release(): string;
|
||||||
|
/**
|
||||||
|
* Returns an object containing network interfaces that have been assigned a
|
||||||
|
* network address.
|
||||||
|
*
|
||||||
|
* Each key on the returned object identifies a network interface. The associated
|
||||||
|
* value is an array of objects that each describe an assigned network address.
|
||||||
|
*
|
||||||
|
* The properties available on the assigned network address object include:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* lo: [
|
||||||
|
* {
|
||||||
|
* address: '127.0.0.1',
|
||||||
|
* netmask: '255.0.0.0',
|
||||||
|
* family: 'IPv4',
|
||||||
|
* mac: '00:00:00:00:00:00',
|
||||||
|
* internal: true,
|
||||||
|
* cidr: '127.0.0.1/8'
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* address: '::1',
|
||||||
|
* netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
|
||||||
|
* family: 'IPv6',
|
||||||
|
* mac: '00:00:00:00:00:00',
|
||||||
|
* scopeid: 0,
|
||||||
|
* internal: true,
|
||||||
|
* cidr: '::1/128'
|
||||||
|
* }
|
||||||
|
* ],
|
||||||
|
* eth0: [
|
||||||
|
* {
|
||||||
|
* address: '192.168.1.108',
|
||||||
|
* netmask: '255.255.255.0',
|
||||||
|
* family: 'IPv4',
|
||||||
|
* mac: '01:02:03:0a:0b:0c',
|
||||||
|
* internal: false,
|
||||||
|
* cidr: '192.168.1.108/24'
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* address: 'fe80::a00:27ff:fe4e:66a1',
|
||||||
|
* netmask: 'ffff:ffff:ffff:ffff::',
|
||||||
|
* family: 'IPv6',
|
||||||
|
* mac: '01:02:03:0a:0b:0c',
|
||||||
|
* scopeid: 1,
|
||||||
|
* internal: false,
|
||||||
|
* cidr: 'fe80::a00:27ff:fe4e:66a1/64'
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
|
||||||
|
/**
|
||||||
|
* Returns the string path of the current user's home directory.
|
||||||
|
*
|
||||||
|
* On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
|
||||||
|
* uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
|
||||||
|
*
|
||||||
|
* On Windows, it uses the `USERPROFILE` environment variable if defined.
|
||||||
|
* Otherwise it uses the path to the profile directory of the current user.
|
||||||
|
* @since v2.3.0
|
||||||
|
*/
|
||||||
|
function homedir(): string;
|
||||||
|
/**
|
||||||
|
* Returns information about the currently effective user. On POSIX platforms,
|
||||||
|
* this is typically a subset of the password file. The returned object includes
|
||||||
|
* the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and `gid` fields are `-1`, and `shell` is `null`.
|
||||||
|
*
|
||||||
|
* The value of `homedir` returned by `os.userInfo()` is provided by the operating
|
||||||
|
* system. This differs from the result of `os.homedir()`, which queries
|
||||||
|
* environment variables for the home directory before falling back to the
|
||||||
|
* operating system response.
|
||||||
|
*
|
||||||
|
* Throws a [`SystemError`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-systemerror) if a user has no `username` or `homedir`.
|
||||||
|
* @since v6.0.0
|
||||||
|
*/
|
||||||
|
function userInfo(options: { encoding: "buffer" }): UserInfo<Buffer>;
|
||||||
|
function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
|
||||||
|
type SignalConstants = {
|
||||||
|
[key in NodeJS.Signals]: number;
|
||||||
|
};
|
||||||
|
namespace constants {
|
||||||
|
const UV_UDP_REUSEADDR: number;
|
||||||
|
namespace signals {}
|
||||||
|
const signals: SignalConstants;
|
||||||
|
namespace errno {
|
||||||
|
const E2BIG: number;
|
||||||
|
const EACCES: number;
|
||||||
|
const EADDRINUSE: number;
|
||||||
|
const EADDRNOTAVAIL: number;
|
||||||
|
const EAFNOSUPPORT: number;
|
||||||
|
const EAGAIN: number;
|
||||||
|
const EALREADY: number;
|
||||||
|
const EBADF: number;
|
||||||
|
const EBADMSG: number;
|
||||||
|
const EBUSY: number;
|
||||||
|
const ECANCELED: number;
|
||||||
|
const ECHILD: number;
|
||||||
|
const ECONNABORTED: number;
|
||||||
|
const ECONNREFUSED: number;
|
||||||
|
const ECONNRESET: number;
|
||||||
|
const EDEADLK: number;
|
||||||
|
const EDESTADDRREQ: number;
|
||||||
|
const EDOM: number;
|
||||||
|
const EDQUOT: number;
|
||||||
|
const EEXIST: number;
|
||||||
|
const EFAULT: number;
|
||||||
|
const EFBIG: number;
|
||||||
|
const EHOSTUNREACH: number;
|
||||||
|
const EIDRM: number;
|
||||||
|
const EILSEQ: number;
|
||||||
|
const EINPROGRESS: number;
|
||||||
|
const EINTR: number;
|
||||||
|
const EINVAL: number;
|
||||||
|
const EIO: number;
|
||||||
|
const EISCONN: number;
|
||||||
|
const EISDIR: number;
|
||||||
|
const ELOOP: number;
|
||||||
|
const EMFILE: number;
|
||||||
|
const EMLINK: number;
|
||||||
|
const EMSGSIZE: number;
|
||||||
|
const EMULTIHOP: number;
|
||||||
|
const ENAMETOOLONG: number;
|
||||||
|
const ENETDOWN: number;
|
||||||
|
const ENETRESET: number;
|
||||||
|
const ENETUNREACH: number;
|
||||||
|
const ENFILE: number;
|
||||||
|
const ENOBUFS: number;
|
||||||
|
const ENODATA: number;
|
||||||
|
const ENODEV: number;
|
||||||
|
const ENOENT: number;
|
||||||
|
const ENOEXEC: number;
|
||||||
|
const ENOLCK: number;
|
||||||
|
const ENOLINK: number;
|
||||||
|
const ENOMEM: number;
|
||||||
|
const ENOMSG: number;
|
||||||
|
const ENOPROTOOPT: number;
|
||||||
|
const ENOSPC: number;
|
||||||
|
const ENOSR: number;
|
||||||
|
const ENOSTR: number;
|
||||||
|
const ENOSYS: number;
|
||||||
|
const ENOTCONN: number;
|
||||||
|
const ENOTDIR: number;
|
||||||
|
const ENOTEMPTY: number;
|
||||||
|
const ENOTSOCK: number;
|
||||||
|
const ENOTSUP: number;
|
||||||
|
const ENOTTY: number;
|
||||||
|
const ENXIO: number;
|
||||||
|
const EOPNOTSUPP: number;
|
||||||
|
const EOVERFLOW: number;
|
||||||
|
const EPERM: number;
|
||||||
|
const EPIPE: number;
|
||||||
|
const EPROTO: number;
|
||||||
|
const EPROTONOSUPPORT: number;
|
||||||
|
const EPROTOTYPE: number;
|
||||||
|
const ERANGE: number;
|
||||||
|
const EROFS: number;
|
||||||
|
const ESPIPE: number;
|
||||||
|
const ESRCH: number;
|
||||||
|
const ESTALE: number;
|
||||||
|
const ETIME: number;
|
||||||
|
const ETIMEDOUT: number;
|
||||||
|
const ETXTBSY: number;
|
||||||
|
const EWOULDBLOCK: number;
|
||||||
|
const EXDEV: number;
|
||||||
|
const WSAEINTR: number;
|
||||||
|
const WSAEBADF: number;
|
||||||
|
const WSAEACCES: number;
|
||||||
|
const WSAEFAULT: number;
|
||||||
|
const WSAEINVAL: number;
|
||||||
|
const WSAEMFILE: number;
|
||||||
|
const WSAEWOULDBLOCK: number;
|
||||||
|
const WSAEINPROGRESS: number;
|
||||||
|
const WSAEALREADY: number;
|
||||||
|
const WSAENOTSOCK: number;
|
||||||
|
const WSAEDESTADDRREQ: number;
|
||||||
|
const WSAEMSGSIZE: number;
|
||||||
|
const WSAEPROTOTYPE: number;
|
||||||
|
const WSAENOPROTOOPT: number;
|
||||||
|
const WSAEPROTONOSUPPORT: number;
|
||||||
|
const WSAESOCKTNOSUPPORT: number;
|
||||||
|
const WSAEOPNOTSUPP: number;
|
||||||
|
const WSAEPFNOSUPPORT: number;
|
||||||
|
const WSAEAFNOSUPPORT: number;
|
||||||
|
const WSAEADDRINUSE: number;
|
||||||
|
const WSAEADDRNOTAVAIL: number;
|
||||||
|
const WSAENETDOWN: number;
|
||||||
|
const WSAENETUNREACH: number;
|
||||||
|
const WSAENETRESET: number;
|
||||||
|
const WSAECONNABORTED: number;
|
||||||
|
const WSAECONNRESET: number;
|
||||||
|
const WSAENOBUFS: number;
|
||||||
|
const WSAEISCONN: number;
|
||||||
|
const WSAENOTCONN: number;
|
||||||
|
const WSAESHUTDOWN: number;
|
||||||
|
const WSAETOOMANYREFS: number;
|
||||||
|
const WSAETIMEDOUT: number;
|
||||||
|
const WSAECONNREFUSED: number;
|
||||||
|
const WSAELOOP: number;
|
||||||
|
const WSAENAMETOOLONG: number;
|
||||||
|
const WSAEHOSTDOWN: number;
|
||||||
|
const WSAEHOSTUNREACH: number;
|
||||||
|
const WSAENOTEMPTY: number;
|
||||||
|
const WSAEPROCLIM: number;
|
||||||
|
const WSAEUSERS: number;
|
||||||
|
const WSAEDQUOT: number;
|
||||||
|
const WSAESTALE: number;
|
||||||
|
const WSAEREMOTE: number;
|
||||||
|
const WSASYSNOTREADY: number;
|
||||||
|
const WSAVERNOTSUPPORTED: number;
|
||||||
|
const WSANOTINITIALISED: number;
|
||||||
|
const WSAEDISCON: number;
|
||||||
|
const WSAENOMORE: number;
|
||||||
|
const WSAECANCELLED: number;
|
||||||
|
const WSAEINVALIDPROCTABLE: number;
|
||||||
|
const WSAEINVALIDPROVIDER: number;
|
||||||
|
const WSAEPROVIDERFAILEDINIT: number;
|
||||||
|
const WSASYSCALLFAILURE: number;
|
||||||
|
const WSASERVICE_NOT_FOUND: number;
|
||||||
|
const WSATYPE_NOT_FOUND: number;
|
||||||
|
const WSA_E_NO_MORE: number;
|
||||||
|
const WSA_E_CANCELLED: number;
|
||||||
|
const WSAEREFUSED: number;
|
||||||
|
}
|
||||||
|
namespace dlopen {
|
||||||
|
const RTLD_LAZY: number;
|
||||||
|
const RTLD_NOW: number;
|
||||||
|
const RTLD_GLOBAL: number;
|
||||||
|
const RTLD_LOCAL: number;
|
||||||
|
const RTLD_DEEPBIND: number;
|
||||||
|
}
|
||||||
|
namespace priority {
|
||||||
|
const PRIORITY_LOW: number;
|
||||||
|
const PRIORITY_BELOW_NORMAL: number;
|
||||||
|
const PRIORITY_NORMAL: number;
|
||||||
|
const PRIORITY_ABOVE_NORMAL: number;
|
||||||
|
const PRIORITY_HIGH: number;
|
||||||
|
const PRIORITY_HIGHEST: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const devNull: string;
|
||||||
|
/**
|
||||||
|
* The operating system-specific end-of-line marker.
|
||||||
|
* * `\n` on POSIX
|
||||||
|
* * `\r\n` on Windows
|
||||||
|
*/
|
||||||
|
const EOL: string;
|
||||||
|
/**
|
||||||
|
* Returns the operating system CPU architecture for which the Node.js binary was
|
||||||
|
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`,
|
||||||
|
* and `'x64'`.
|
||||||
|
*
|
||||||
|
* The return value is equivalent to [process.arch](https://nodejs.org/docs/latest-v22.x/api/process.html#processarch).
|
||||||
|
* @since v0.5.0
|
||||||
|
*/
|
||||||
|
function arch(): string;
|
||||||
|
/**
|
||||||
|
* Returns a string identifying the kernel version.
|
||||||
|
*
|
||||||
|
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
|
||||||
|
* available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
||||||
|
* @since v13.11.0, v12.17.0
|
||||||
|
*/
|
||||||
|
function version(): string;
|
||||||
|
/**
|
||||||
|
* Returns a string identifying the operating system platform for which
|
||||||
|
* the Node.js binary was compiled. The value is set at compile time.
|
||||||
|
* Possible values are `'aix'`, `'darwin'`, `'freebsd'`, `'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
||||||
|
*
|
||||||
|
* The return value is equivalent to `process.platform`.
|
||||||
|
*
|
||||||
|
* The value `'android'` may also be returned if Node.js is built on the Android
|
||||||
|
* operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
|
||||||
|
* @since v0.5.0
|
||||||
|
*/
|
||||||
|
function platform(): NodeJS.Platform;
|
||||||
|
/**
|
||||||
|
* Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`, `mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`.
|
||||||
|
*
|
||||||
|
* On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
|
||||||
|
* available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
||||||
|
* @since v18.9.0, v16.18.0
|
||||||
|
*/
|
||||||
|
function machine(): string;
|
||||||
|
/**
|
||||||
|
* Returns the operating system's default directory for temporary files as a
|
||||||
|
* string.
|
||||||
|
* @since v0.9.9
|
||||||
|
*/
|
||||||
|
function tmpdir(): string;
|
||||||
|
/**
|
||||||
|
* Returns a string identifying the endianness of the CPU for which the Node.js
|
||||||
|
* binary was compiled.
|
||||||
|
*
|
||||||
|
* Possible values are `'BE'` for big endian and `'LE'` for little endian.
|
||||||
|
* @since v0.9.4
|
||||||
|
*/
|
||||||
|
function endianness(): "BE" | "LE";
|
||||||
|
/**
|
||||||
|
* Returns the scheduling priority for the process specified by `pid`. If `pid` is
|
||||||
|
* not provided or is `0`, the priority of the current process is returned.
|
||||||
|
* @since v10.10.0
|
||||||
|
* @param [pid=0] The process ID to retrieve scheduling priority for.
|
||||||
|
*/
|
||||||
|
function getPriority(pid?: number): number;
|
||||||
|
/**
|
||||||
|
* Attempts to set the scheduling priority for the process specified by `pid`. If `pid` is not provided or is `0`, the process ID of the current process is used.
|
||||||
|
*
|
||||||
|
* The `priority` input must be an integer between `-20` (high priority) and `19` (low priority). Due to differences between Unix priority levels and Windows
|
||||||
|
* priority classes, `priority` is mapped to one of six priority constants in `os.constants.priority`. When retrieving a process priority level, this range
|
||||||
|
* mapping may cause the return value to be slightly different on Windows. To avoid
|
||||||
|
* confusion, set `priority` to one of the priority constants.
|
||||||
|
*
|
||||||
|
* On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
|
||||||
|
* privileges. Otherwise the set priority will be silently reduced to `PRIORITY_HIGH`.
|
||||||
|
* @since v10.10.0
|
||||||
|
* @param [pid=0] The process ID to set scheduling priority for.
|
||||||
|
* @param priority The scheduling priority to assign to the process.
|
||||||
|
*/
|
||||||
|
function setPriority(priority: number): void;
|
||||||
|
function setPriority(pid: number, priority: number): void;
|
||||||
|
}
|
||||||
|
declare module "node:os" {
|
||||||
|
export * from "os";
|
||||||
|
}
|
225
websocket_server/node_modules/.ignored/@types/node/package.json
generated
vendored
Normal file
225
websocket_server/node_modules/.ignored/@types/node/package.json
generated
vendored
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/node",
|
||||||
|
"version": "22.7.8",
|
||||||
|
"description": "TypeScript definitions for node",
|
||||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Microsoft TypeScript",
|
||||||
|
"githubUsername": "Microsoft",
|
||||||
|
"url": "https://github.com/Microsoft"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alberto Schiabel",
|
||||||
|
"githubUsername": "jkomyno",
|
||||||
|
"url": "https://github.com/jkomyno"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alvis HT Tang",
|
||||||
|
"githubUsername": "alvis",
|
||||||
|
"url": "https://github.com/alvis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrew Makarov",
|
||||||
|
"githubUsername": "r3nya",
|
||||||
|
"url": "https://github.com/r3nya"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benjamin Toueg",
|
||||||
|
"githubUsername": "btoueg",
|
||||||
|
"url": "https://github.com/btoueg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Chigozirim C.",
|
||||||
|
"githubUsername": "smac89",
|
||||||
|
"url": "https://github.com/smac89"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "David Junger",
|
||||||
|
"githubUsername": "touffy",
|
||||||
|
"url": "https://github.com/touffy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Deividas Bakanas",
|
||||||
|
"githubUsername": "DeividasBakanas",
|
||||||
|
"url": "https://github.com/DeividasBakanas"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eugene Y. Q. Shen",
|
||||||
|
"githubUsername": "eyqs",
|
||||||
|
"url": "https://github.com/eyqs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hannes Magnusson",
|
||||||
|
"githubUsername": "Hannes-Magnusson-CK",
|
||||||
|
"url": "https://github.com/Hannes-Magnusson-CK"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Huw",
|
||||||
|
"githubUsername": "hoo29",
|
||||||
|
"url": "https://github.com/hoo29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kelvin Jin",
|
||||||
|
"githubUsername": "kjin",
|
||||||
|
"url": "https://github.com/kjin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Klaus Meinhardt",
|
||||||
|
"githubUsername": "ajafff",
|
||||||
|
"url": "https://github.com/ajafff"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Lishude",
|
||||||
|
"githubUsername": "islishude",
|
||||||
|
"url": "https://github.com/islishude"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mariusz Wiktorczyk",
|
||||||
|
"githubUsername": "mwiktorczyk",
|
||||||
|
"url": "https://github.com/mwiktorczyk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mohsen Azimi",
|
||||||
|
"githubUsername": "mohsen1",
|
||||||
|
"url": "https://github.com/mohsen1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nikita Galkin",
|
||||||
|
"githubUsername": "galkin",
|
||||||
|
"url": "https://github.com/galkin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Parambir Singh",
|
||||||
|
"githubUsername": "parambirs",
|
||||||
|
"url": "https://github.com/parambirs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sebastian Silbermann",
|
||||||
|
"githubUsername": "eps1lon",
|
||||||
|
"url": "https://github.com/eps1lon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Thomas den Hollander",
|
||||||
|
"githubUsername": "ThomasdenH",
|
||||||
|
"url": "https://github.com/ThomasdenH"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Wilco Bakker",
|
||||||
|
"githubUsername": "WilcoBakker",
|
||||||
|
"url": "https://github.com/WilcoBakker"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wwwy3y3",
|
||||||
|
"githubUsername": "wwwy3y3",
|
||||||
|
"url": "https://github.com/wwwy3y3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Samuel Ainsworth",
|
||||||
|
"githubUsername": "samuela",
|
||||||
|
"url": "https://github.com/samuela"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kyle Uehlein",
|
||||||
|
"githubUsername": "kuehlein",
|
||||||
|
"url": "https://github.com/kuehlein"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Thanik Bhongbhibhat",
|
||||||
|
"githubUsername": "bhongy",
|
||||||
|
"url": "https://github.com/bhongy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Marcin Kopacz",
|
||||||
|
"githubUsername": "chyzwar",
|
||||||
|
"url": "https://github.com/chyzwar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Trivikram Kamat",
|
||||||
|
"githubUsername": "trivikr",
|
||||||
|
"url": "https://github.com/trivikr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Junxiao Shi",
|
||||||
|
"githubUsername": "yoursunny",
|
||||||
|
"url": "https://github.com/yoursunny"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ilia Baryshnikov",
|
||||||
|
"githubUsername": "qwelias",
|
||||||
|
"url": "https://github.com/qwelias"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ExE Boss",
|
||||||
|
"githubUsername": "ExE-Boss",
|
||||||
|
"url": "https://github.com/ExE-Boss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Piotr Błażejewicz",
|
||||||
|
"githubUsername": "peterblazejewicz",
|
||||||
|
"url": "https://github.com/peterblazejewicz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Anna Henningsen",
|
||||||
|
"githubUsername": "addaleax",
|
||||||
|
"url": "https://github.com/addaleax"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Victor Perin",
|
||||||
|
"githubUsername": "victorperin",
|
||||||
|
"url": "https://github.com/victorperin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Yongsheng Zhang",
|
||||||
|
"githubUsername": "ZYSzys",
|
||||||
|
"url": "https://github.com/ZYSzys"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "NodeJS Contributors",
|
||||||
|
"githubUsername": "NodeJS",
|
||||||
|
"url": "https://github.com/NodeJS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linus Unnebäck",
|
||||||
|
"githubUsername": "LinusU",
|
||||||
|
"url": "https://github.com/LinusU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wafuwafu13",
|
||||||
|
"githubUsername": "wafuwafu13",
|
||||||
|
"url": "https://github.com/wafuwafu13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Matteo Collina",
|
||||||
|
"githubUsername": "mcollina",
|
||||||
|
"url": "https://github.com/mcollina"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dmitry Semigradsky",
|
||||||
|
"githubUsername": "Semigradsky",
|
||||||
|
"url": "https://github.com/Semigradsky"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"typesVersions": {
|
||||||
|
"<=5.6": {
|
||||||
|
"*": [
|
||||||
|
"ts5.6/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/node"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~6.19.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {},
|
||||||
|
"typesPublisherContentHash": "377bdc8e202af21374227159b9bca0a113a355f7eaf6188d2ee0f76e209ac0e7",
|
||||||
|
"typeScriptVersion": "4.8"
|
||||||
|
}
|
200
websocket_server/node_modules/.ignored/@types/node/path.d.ts
generated
vendored
Normal file
200
websocket_server/node_modules/.ignored/@types/node/path.d.ts
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
declare module "path/posix" {
|
||||||
|
import path = require("path");
|
||||||
|
export = path;
|
||||||
|
}
|
||||||
|
declare module "path/win32" {
|
||||||
|
import path = require("path");
|
||||||
|
export = path;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `node:path` module provides utilities for working with file and directory
|
||||||
|
* paths. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import path from 'node:path';
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/path.js)
|
||||||
|
*/
|
||||||
|
declare module "path" {
|
||||||
|
namespace path {
|
||||||
|
/**
|
||||||
|
* A parsed path object generated by path.parse() or consumed by path.format().
|
||||||
|
*/
|
||||||
|
interface ParsedPath {
|
||||||
|
/**
|
||||||
|
* The root of the path such as '/' or 'c:\'
|
||||||
|
*/
|
||||||
|
root: string;
|
||||||
|
/**
|
||||||
|
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||||
|
*/
|
||||||
|
dir: string;
|
||||||
|
/**
|
||||||
|
* The file name including extension (if any) such as 'index.html'
|
||||||
|
*/
|
||||||
|
base: string;
|
||||||
|
/**
|
||||||
|
* The file extension (if any) such as '.html'
|
||||||
|
*/
|
||||||
|
ext: string;
|
||||||
|
/**
|
||||||
|
* The file name without extension (if any) such as 'index'
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
interface FormatInputPathObject {
|
||||||
|
/**
|
||||||
|
* The root of the path such as '/' or 'c:\'
|
||||||
|
*/
|
||||||
|
root?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||||
|
*/
|
||||||
|
dir?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The file name including extension (if any) such as 'index.html'
|
||||||
|
*/
|
||||||
|
base?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The file extension (if any) such as '.html'
|
||||||
|
*/
|
||||||
|
ext?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The file name without extension (if any) such as 'index'
|
||||||
|
*/
|
||||||
|
name?: string | undefined;
|
||||||
|
}
|
||||||
|
interface PlatformPath {
|
||||||
|
/**
|
||||||
|
* Normalize a string path, reducing '..' and '.' parts.
|
||||||
|
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||||
|
*
|
||||||
|
* @param path string path to normalize.
|
||||||
|
* @throws {TypeError} if `path` is not a string.
|
||||||
|
*/
|
||||||
|
normalize(path: string): string;
|
||||||
|
/**
|
||||||
|
* Join all arguments together and normalize the resulting path.
|
||||||
|
*
|
||||||
|
* @param paths paths to join.
|
||||||
|
* @throws {TypeError} if any of the path segments is not a string.
|
||||||
|
*/
|
||||||
|
join(...paths: string[]): string;
|
||||||
|
/**
|
||||||
|
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
||||||
|
*
|
||||||
|
* Starting from leftmost {from} parameter, resolves {to} to an absolute path.
|
||||||
|
*
|
||||||
|
* If {to} isn't already absolute, {from} arguments are prepended in right to left order,
|
||||||
|
* until an absolute path is found. If after using all {from} paths still no absolute path is found,
|
||||||
|
* the current working directory is used as well. The resulting path is normalized,
|
||||||
|
* and trailing slashes are removed unless the path gets resolved to the root directory.
|
||||||
|
*
|
||||||
|
* @param paths A sequence of paths or path segments.
|
||||||
|
* @throws {TypeError} if any of the arguments is not a string.
|
||||||
|
*/
|
||||||
|
resolve(...paths: string[]): string;
|
||||||
|
/**
|
||||||
|
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||||
|
* @param path The path to glob-match against.
|
||||||
|
* @param pattern The glob to check the path against.
|
||||||
|
* @returns Whether or not the `path` matched the `pattern`.
|
||||||
|
* @throws {TypeError} if `path` or `pattern` are not strings.
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
matchesGlob(path: string, pattern: string): boolean;
|
||||||
|
/**
|
||||||
|
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
||||||
|
*
|
||||||
|
* If the given {path} is a zero-length string, `false` will be returned.
|
||||||
|
*
|
||||||
|
* @param path path to test.
|
||||||
|
* @throws {TypeError} if `path` is not a string.
|
||||||
|
*/
|
||||||
|
isAbsolute(path: string): boolean;
|
||||||
|
/**
|
||||||
|
* Solve the relative path from {from} to {to} based on the current working directory.
|
||||||
|
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
||||||
|
*
|
||||||
|
* @throws {TypeError} if either `from` or `to` is not a string.
|
||||||
|
*/
|
||||||
|
relative(from: string, to: string): string;
|
||||||
|
/**
|
||||||
|
* Return the directory name of a path. Similar to the Unix dirname command.
|
||||||
|
*
|
||||||
|
* @param path the path to evaluate.
|
||||||
|
* @throws {TypeError} if `path` is not a string.
|
||||||
|
*/
|
||||||
|
dirname(path: string): string;
|
||||||
|
/**
|
||||||
|
* Return the last portion of a path. Similar to the Unix basename command.
|
||||||
|
* Often used to extract the file name from a fully qualified path.
|
||||||
|
*
|
||||||
|
* @param path the path to evaluate.
|
||||||
|
* @param suffix optionally, an extension to remove from the result.
|
||||||
|
* @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string.
|
||||||
|
*/
|
||||||
|
basename(path: string, suffix?: string): string;
|
||||||
|
/**
|
||||||
|
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
||||||
|
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
|
||||||
|
*
|
||||||
|
* @param path the path to evaluate.
|
||||||
|
* @throws {TypeError} if `path` is not a string.
|
||||||
|
*/
|
||||||
|
extname(path: string): string;
|
||||||
|
/**
|
||||||
|
* The platform-specific file separator. '\\' or '/'.
|
||||||
|
*/
|
||||||
|
readonly sep: "\\" | "/";
|
||||||
|
/**
|
||||||
|
* The platform-specific file delimiter. ';' or ':'.
|
||||||
|
*/
|
||||||
|
readonly delimiter: ";" | ":";
|
||||||
|
/**
|
||||||
|
* Returns an object from a path string - the opposite of format().
|
||||||
|
*
|
||||||
|
* @param path path to evaluate.
|
||||||
|
* @throws {TypeError} if `path` is not a string.
|
||||||
|
*/
|
||||||
|
parse(path: string): ParsedPath;
|
||||||
|
/**
|
||||||
|
* Returns a path string from an object - the opposite of parse().
|
||||||
|
*
|
||||||
|
* @param pathObject path to evaluate.
|
||||||
|
*/
|
||||||
|
format(pathObject: FormatInputPathObject): string;
|
||||||
|
/**
|
||||||
|
* On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
|
||||||
|
* If path is not a string, path will be returned without modifications.
|
||||||
|
* This method is meaningful only on Windows system.
|
||||||
|
* On POSIX systems, the method is non-operational and always returns path without modifications.
|
||||||
|
*/
|
||||||
|
toNamespacedPath(path: string): string;
|
||||||
|
/**
|
||||||
|
* Posix specific pathing.
|
||||||
|
* Same as parent object on posix.
|
||||||
|
*/
|
||||||
|
readonly posix: PlatformPath;
|
||||||
|
/**
|
||||||
|
* Windows specific pathing.
|
||||||
|
* Same as parent object on windows
|
||||||
|
*/
|
||||||
|
readonly win32: PlatformPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const path: path.PlatformPath;
|
||||||
|
export = path;
|
||||||
|
}
|
||||||
|
declare module "node:path" {
|
||||||
|
import path = require("path");
|
||||||
|
export = path;
|
||||||
|
}
|
||||||
|
declare module "node:path/posix" {
|
||||||
|
import path = require("path/posix");
|
||||||
|
export = path;
|
||||||
|
}
|
||||||
|
declare module "node:path/win32" {
|
||||||
|
import path = require("path/win32");
|
||||||
|
export = path;
|
||||||
|
}
|
941
websocket_server/node_modules/.ignored/@types/node/perf_hooks.d.ts
generated
vendored
Normal file
941
websocket_server/node_modules/.ignored/@types/node/perf_hooks.d.ts
generated
vendored
Normal file
@ -0,0 +1,941 @@
|
|||||||
|
/**
|
||||||
|
* This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
|
||||||
|
* Node.js-specific performance measurements.
|
||||||
|
*
|
||||||
|
* Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
|
||||||
|
*
|
||||||
|
* * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
|
||||||
|
* * [Performance Timeline](https://w3c.github.io/performance-timeline/)
|
||||||
|
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
||||||
|
* * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { PerformanceObserver, performance } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((items) => {
|
||||||
|
* console.log(items.getEntries()[0].duration);
|
||||||
|
* performance.clearMarks();
|
||||||
|
* });
|
||||||
|
* obs.observe({ type: 'measure' });
|
||||||
|
* performance.measure('Start to Now');
|
||||||
|
*
|
||||||
|
* performance.mark('A');
|
||||||
|
* doSomeLongRunningProcess(() => {
|
||||||
|
* performance.measure('A to Now', 'A');
|
||||||
|
*
|
||||||
|
* performance.mark('B');
|
||||||
|
* performance.measure('A to B', 'A', 'B');
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/perf_hooks.js)
|
||||||
|
*/
|
||||||
|
declare module "perf_hooks" {
|
||||||
|
import { AsyncResource } from "node:async_hooks";
|
||||||
|
type EntryType =
|
||||||
|
| "dns" // Node.js only
|
||||||
|
| "function" // Node.js only
|
||||||
|
| "gc" // Node.js only
|
||||||
|
| "http2" // Node.js only
|
||||||
|
| "http" // Node.js only
|
||||||
|
| "mark" // available on the Web
|
||||||
|
| "measure" // available on the Web
|
||||||
|
| "net" // Node.js only
|
||||||
|
| "node" // Node.js only
|
||||||
|
| "resource"; // available on the Web
|
||||||
|
interface NodeGCPerformanceDetail {
|
||||||
|
/**
|
||||||
|
* When `performanceEntry.entryType` is equal to 'gc', the `performance.kind` property identifies
|
||||||
|
* the type of garbage collection operation that occurred.
|
||||||
|
* See perf_hooks.constants for valid values.
|
||||||
|
*/
|
||||||
|
readonly kind?: number | undefined;
|
||||||
|
/**
|
||||||
|
* When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
|
||||||
|
* property contains additional information about garbage collection operation.
|
||||||
|
* See perf_hooks.constants for valid values.
|
||||||
|
*/
|
||||||
|
readonly flags?: number | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The constructor of this class is not exposed to users directly.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
class PerformanceEntry {
|
||||||
|
protected constructor();
|
||||||
|
/**
|
||||||
|
* The total number of milliseconds elapsed for this entry. This value will not
|
||||||
|
* be meaningful for all Performance Entry types.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly duration: number;
|
||||||
|
/**
|
||||||
|
* The name of the performance entry.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly name: string;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp marking the starting time of the
|
||||||
|
* Performance Entry.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly startTime: number;
|
||||||
|
/**
|
||||||
|
* The type of the performance entry. It may be one of:
|
||||||
|
*
|
||||||
|
* * `'node'` (Node.js only)
|
||||||
|
* * `'mark'` (available on the Web)
|
||||||
|
* * `'measure'` (available on the Web)
|
||||||
|
* * `'gc'` (Node.js only)
|
||||||
|
* * `'function'` (Node.js only)
|
||||||
|
* * `'http2'` (Node.js only)
|
||||||
|
* * `'http'` (Node.js only)
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly entryType: EntryType;
|
||||||
|
/**
|
||||||
|
* Additional detail specific to the `entryType`.
|
||||||
|
* @since v16.0.0
|
||||||
|
*/
|
||||||
|
readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
||||||
|
toJSON(): any;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Exposes marks created via the `Performance.mark()` method.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
class PerformanceMark extends PerformanceEntry {
|
||||||
|
readonly duration: 0;
|
||||||
|
readonly entryType: "mark";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Exposes measures created via the `Performance.measure()` method.
|
||||||
|
*
|
||||||
|
* The constructor of this class is not exposed to users directly.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
class PerformanceMeasure extends PerformanceEntry {
|
||||||
|
readonly entryType: "measure";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||||
|
*
|
||||||
|
* Provides timing details for Node.js itself. The constructor of this class
|
||||||
|
* is not exposed to users.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
class PerformanceNodeTiming extends PerformanceEntry {
|
||||||
|
readonly entryType: "node";
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the Node.js process
|
||||||
|
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
||||||
|
* has the value of -1.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly bootstrapComplete: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the Node.js environment was
|
||||||
|
* initialized.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly environment: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp of the amount of time the event loop
|
||||||
|
* has been idle within the event loop's event provider (e.g. `epoll_wait`). This
|
||||||
|
* does not take CPU usage into consideration. If the event loop has not yet
|
||||||
|
* started (e.g., in the first tick of the main script), the property has the
|
||||||
|
* value of 0.
|
||||||
|
* @since v14.10.0, v12.19.0
|
||||||
|
*/
|
||||||
|
readonly idleTime: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the Node.js event loop
|
||||||
|
* exited. If the event loop has not yet exited, the property has the value of -1\.
|
||||||
|
* It can only have a value of not -1 in a handler of the `'exit'` event.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly loopExit: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the Node.js event loop
|
||||||
|
* started. If the event loop has not yet started (e.g., in the first tick of the
|
||||||
|
* main script), the property has the value of -1.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly loopStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the Node.js process was initialized.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly nodeStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the V8 platform was
|
||||||
|
* initialized.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly v8Start: number;
|
||||||
|
}
|
||||||
|
interface EventLoopUtilization {
|
||||||
|
idle: number;
|
||||||
|
active: number;
|
||||||
|
utilization: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param utilization1 The result of a previous call to `eventLoopUtilization()`.
|
||||||
|
* @param utilization2 The result of a previous call to `eventLoopUtilization()` prior to `utilization1`.
|
||||||
|
*/
|
||||||
|
type EventLoopUtilityFunction = (
|
||||||
|
utilization1?: EventLoopUtilization,
|
||||||
|
utilization2?: EventLoopUtilization,
|
||||||
|
) => EventLoopUtilization;
|
||||||
|
interface MarkOptions {
|
||||||
|
/**
|
||||||
|
* Additional optional detail to include with the mark.
|
||||||
|
*/
|
||||||
|
detail?: unknown | undefined;
|
||||||
|
/**
|
||||||
|
* An optional timestamp to be used as the mark time.
|
||||||
|
* @default `performance.now()`
|
||||||
|
*/
|
||||||
|
startTime?: number | undefined;
|
||||||
|
}
|
||||||
|
interface MeasureOptions {
|
||||||
|
/**
|
||||||
|
* Additional optional detail to include with the mark.
|
||||||
|
*/
|
||||||
|
detail?: unknown | undefined;
|
||||||
|
/**
|
||||||
|
* Duration between start and end times.
|
||||||
|
*/
|
||||||
|
duration?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Timestamp to be used as the end time, or a string identifying a previously recorded mark.
|
||||||
|
*/
|
||||||
|
end?: number | string | undefined;
|
||||||
|
/**
|
||||||
|
* Timestamp to be used as the start time, or a string identifying a previously recorded mark.
|
||||||
|
*/
|
||||||
|
start?: number | string | undefined;
|
||||||
|
}
|
||||||
|
interface TimerifyOptions {
|
||||||
|
/**
|
||||||
|
* A histogram object created using `perf_hooks.createHistogram()` that will record runtime
|
||||||
|
* durations in nanoseconds.
|
||||||
|
*/
|
||||||
|
histogram?: RecordableHistogram | undefined;
|
||||||
|
}
|
||||||
|
interface Performance {
|
||||||
|
/**
|
||||||
|
* If `name` is not provided, removes all `PerformanceMark` objects from the Performance Timeline.
|
||||||
|
* If `name` is provided, removes only the named mark.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
clearMarks(name?: string): void;
|
||||||
|
/**
|
||||||
|
* If `name` is not provided, removes all `PerformanceMeasure` objects from the Performance Timeline.
|
||||||
|
* If `name` is provided, removes only the named measure.
|
||||||
|
* @since v16.7.0
|
||||||
|
*/
|
||||||
|
clearMeasures(name?: string): void;
|
||||||
|
/**
|
||||||
|
* If `name` is not provided, removes all `PerformanceResourceTiming` objects from the Resource Timeline.
|
||||||
|
* If `name` is provided, removes only the named resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
clearResourceTimings(name?: string): void;
|
||||||
|
/**
|
||||||
|
* eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
|
||||||
|
* It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
|
||||||
|
* No other CPU idle time is taken into consideration.
|
||||||
|
*/
|
||||||
|
eventLoopUtilization: EventLoopUtilityFunction;
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`.
|
||||||
|
* If you are only interested in performance entries of certain types or that have certain names, see
|
||||||
|
* `performance.getEntriesByType()` and `performance.getEntriesByName()`.
|
||||||
|
* @since v16.7.0
|
||||||
|
*/
|
||||||
|
getEntries(): PerformanceEntry[];
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`
|
||||||
|
* whose `performanceEntry.name` is equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to `type`.
|
||||||
|
* @param name
|
||||||
|
* @param type
|
||||||
|
* @since v16.7.0
|
||||||
|
*/
|
||||||
|
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`
|
||||||
|
* whose `performanceEntry.entryType` is equal to `type`.
|
||||||
|
* @param type
|
||||||
|
* @since v16.7.0
|
||||||
|
*/
|
||||||
|
getEntriesByType(type: EntryType): PerformanceEntry[];
|
||||||
|
/**
|
||||||
|
* Creates a new `PerformanceMark` entry in the Performance Timeline.
|
||||||
|
* A `PerformanceMark` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'mark'`,
|
||||||
|
* and whose `performanceEntry.duration` is always `0`.
|
||||||
|
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||||
|
*
|
||||||
|
* The created `PerformanceMark` entry is put in the global Performance Timeline and can be queried with
|
||||||
|
* `performance.getEntries`, `performance.getEntriesByName`, and `performance.getEntriesByType`. When the observation is
|
||||||
|
* performed, the entries should be cleared from the global Performance Timeline manually with `performance.clearMarks`.
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
mark(name: string, options?: MarkOptions): PerformanceMark;
|
||||||
|
/**
|
||||||
|
* Creates a new `PerformanceResourceTiming` entry in the Resource Timeline.
|
||||||
|
* A `PerformanceResourceTiming` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'resource'`.
|
||||||
|
* Performance resources are used to mark moments in the Resource Timeline.
|
||||||
|
* @param timingInfo [Fetch Timing Info](https://fetch.spec.whatwg.org/#fetch-timing-info)
|
||||||
|
* @param requestedUrl The resource url
|
||||||
|
* @param initiatorType The initiator name, e.g: 'fetch'
|
||||||
|
* @param global
|
||||||
|
* @param cacheMode The cache mode must be an empty string ('') or 'local'
|
||||||
|
* @param bodyInfo [Fetch Response Body Info](https://fetch.spec.whatwg.org/#response-body-info)
|
||||||
|
* @param responseStatus The response's status code
|
||||||
|
* @param deliveryType The delivery type. Default: ''.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
markResourceTiming(
|
||||||
|
timingInfo: object,
|
||||||
|
requestedUrl: string,
|
||||||
|
initiatorType: string,
|
||||||
|
global: object,
|
||||||
|
cacheMode: "" | "local",
|
||||||
|
bodyInfo: object,
|
||||||
|
responseStatus: number,
|
||||||
|
deliveryType?: string,
|
||||||
|
): PerformanceResourceTiming;
|
||||||
|
/**
|
||||||
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||||
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||||
|
* and whose performanceEntry.duration measures the number of milliseconds elapsed since startMark and endMark.
|
||||||
|
*
|
||||||
|
* The startMark argument may identify any existing PerformanceMark in the the Performance Timeline, or may identify
|
||||||
|
* any of the timestamp properties provided by the PerformanceNodeTiming class. If the named startMark does not exist,
|
||||||
|
* then startMark is set to timeOrigin by default.
|
||||||
|
*
|
||||||
|
* The endMark argument must identify any existing PerformanceMark in the the Performance Timeline or any of the timestamp
|
||||||
|
* properties provided by the PerformanceNodeTiming class. If the named endMark does not exist, an error will be thrown.
|
||||||
|
* @param name
|
||||||
|
* @param startMark
|
||||||
|
* @param endMark
|
||||||
|
* @return The PerformanceMeasure entry that was created
|
||||||
|
*/
|
||||||
|
measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure;
|
||||||
|
measure(name: string, options: MeasureOptions): PerformanceMeasure;
|
||||||
|
/**
|
||||||
|
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||||
|
*
|
||||||
|
* An instance of the `PerformanceNodeTiming` class that provides performance metrics for specific Node.js operational milestones.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly nodeTiming: PerformanceNodeTiming;
|
||||||
|
/**
|
||||||
|
* Returns the current high resolution millisecond timestamp, where 0 represents the start of the current `node` process.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
now(): number;
|
||||||
|
/**
|
||||||
|
* Sets the global performance resource timing buffer size to the specified number of "resource" type performance entry objects.
|
||||||
|
*
|
||||||
|
* By default the max buffer size is set to 250.
|
||||||
|
* @since v18.8.0
|
||||||
|
*/
|
||||||
|
setResourceTimingBufferSize(maxSize: number): void;
|
||||||
|
/**
|
||||||
|
* The [`timeOrigin`](https://w3c.github.io/hr-time/#dom-performance-timeorigin) specifies the high resolution millisecond timestamp
|
||||||
|
* at which the current `node` process began, measured in Unix time.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
readonly timeOrigin: number;
|
||||||
|
/**
|
||||||
|
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||||
|
*
|
||||||
|
* Wraps a function within a new function that measures the running time of the wrapped function.
|
||||||
|
* A `PerformanceObserver` must be subscribed to the `'function'` event type in order for the timing details to be accessed.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* performance,
|
||||||
|
* PerformanceObserver,
|
||||||
|
* } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* function someFunction() {
|
||||||
|
* console.log('hello world');
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const wrapped = performance.timerify(someFunction);
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((list) => {
|
||||||
|
* console.log(list.getEntries()[0].duration);
|
||||||
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
|
* obs.disconnect();
|
||||||
|
* });
|
||||||
|
* obs.observe({ entryTypes: ['function'] });
|
||||||
|
*
|
||||||
|
* // A performance timeline entry will be created
|
||||||
|
* wrapped();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If the wrapped function returns a promise, a finally handler will be attached to the promise and the duration will be reported
|
||||||
|
* once the finally handler is invoked.
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
|
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
|
||||||
|
/**
|
||||||
|
* An object which is JSON representation of the performance object. It is similar to
|
||||||
|
* [`window.performance.toJSON`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/toJSON) in browsers.
|
||||||
|
* @since v16.1.0
|
||||||
|
*/
|
||||||
|
toJSON(): any;
|
||||||
|
}
|
||||||
|
class PerformanceObserverEntryList {
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||||
|
* with respect to `performanceEntry.startTime`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* performance,
|
||||||
|
* PerformanceObserver,
|
||||||
|
* } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||||
|
* console.log(perfObserverList.getEntries());
|
||||||
|
*
|
||||||
|
* * [
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'test',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 81.465639,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * },
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'meow',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 81.860064,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * }
|
||||||
|
* * ]
|
||||||
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
|
* observer.disconnect();
|
||||||
|
* });
|
||||||
|
* obs.observe({ type: 'mark' });
|
||||||
|
*
|
||||||
|
* performance.mark('test');
|
||||||
|
* performance.mark('meow');
|
||||||
|
* ```
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
getEntries(): PerformanceEntry[];
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||||
|
* with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
|
||||||
|
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* performance,
|
||||||
|
* PerformanceObserver,
|
||||||
|
* } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||||
|
* console.log(perfObserverList.getEntriesByName('meow'));
|
||||||
|
*
|
||||||
|
* * [
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'meow',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 98.545991,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * }
|
||||||
|
* * ]
|
||||||
|
*
|
||||||
|
* console.log(perfObserverList.getEntriesByName('nope')); // []
|
||||||
|
*
|
||||||
|
* console.log(perfObserverList.getEntriesByName('test', 'mark'));
|
||||||
|
*
|
||||||
|
* * [
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'test',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 63.518931,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * }
|
||||||
|
* * ]
|
||||||
|
*
|
||||||
|
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
||||||
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
|
* observer.disconnect();
|
||||||
|
* });
|
||||||
|
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
||||||
|
*
|
||||||
|
* performance.mark('test');
|
||||||
|
* performance.mark('meow');
|
||||||
|
* ```
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
||||||
|
/**
|
||||||
|
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||||
|
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType` is equal to `type`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* performance,
|
||||||
|
* PerformanceObserver,
|
||||||
|
* } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||||
|
* console.log(perfObserverList.getEntriesByType('mark'));
|
||||||
|
*
|
||||||
|
* * [
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'test',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 55.897834,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * },
|
||||||
|
* * PerformanceEntry {
|
||||||
|
* * name: 'meow',
|
||||||
|
* * entryType: 'mark',
|
||||||
|
* * startTime: 56.350146,
|
||||||
|
* * duration: 0,
|
||||||
|
* * detail: null
|
||||||
|
* * }
|
||||||
|
* * ]
|
||||||
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
|
* observer.disconnect();
|
||||||
|
* });
|
||||||
|
* obs.observe({ type: 'mark' });
|
||||||
|
*
|
||||||
|
* performance.mark('test');
|
||||||
|
* performance.mark('meow');
|
||||||
|
* ```
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
getEntriesByType(type: EntryType): PerformanceEntry[];
|
||||||
|
}
|
||||||
|
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
||||||
|
/**
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
class PerformanceObserver extends AsyncResource {
|
||||||
|
constructor(callback: PerformanceObserverCallback);
|
||||||
|
/**
|
||||||
|
* Disconnects the `PerformanceObserver` instance from all notifications.
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
disconnect(): void;
|
||||||
|
/**
|
||||||
|
* Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes` or `options.type`:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* performance,
|
||||||
|
* PerformanceObserver,
|
||||||
|
* } from 'node:perf_hooks';
|
||||||
|
*
|
||||||
|
* const obs = new PerformanceObserver((list, observer) => {
|
||||||
|
* // Called once asynchronously. `list` contains three items.
|
||||||
|
* });
|
||||||
|
* obs.observe({ type: 'mark' });
|
||||||
|
*
|
||||||
|
* for (let n = 0; n < 3; n++)
|
||||||
|
* performance.mark(`test${n}`);
|
||||||
|
* ```
|
||||||
|
* @since v8.5.0
|
||||||
|
*/
|
||||||
|
observe(
|
||||||
|
options:
|
||||||
|
| {
|
||||||
|
entryTypes: readonly EntryType[];
|
||||||
|
buffered?: boolean | undefined;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: EntryType;
|
||||||
|
buffered?: boolean | undefined;
|
||||||
|
},
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Provides detailed network timing data regarding the loading of an application's resources.
|
||||||
|
*
|
||||||
|
* The constructor of this class is not exposed to users directly.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
class PerformanceResourceTiming extends PerformanceEntry {
|
||||||
|
readonly entryType: "resource";
|
||||||
|
protected constructor();
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at immediately before dispatching the `fetch`
|
||||||
|
* request. If the resource is not intercepted by a worker the property will always return 0.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly workerStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp that represents the start time of the fetch which
|
||||||
|
* initiates the redirect.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly redirectStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp that will be created immediately after receiving
|
||||||
|
* the last byte of the response of the last redirect.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly redirectEnd: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp immediately before the Node.js starts to fetch the resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly fetchStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp immediately before the Node.js starts the domain name lookup
|
||||||
|
* for the resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly domainLookupStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately after the Node.js finished
|
||||||
|
* the domain name lookup for the resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly domainLookupEnd: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately before Node.js starts to
|
||||||
|
* establish the connection to the server to retrieve the resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly connectStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately after Node.js finishes
|
||||||
|
* establishing the connection to the server to retrieve the resource.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly connectEnd: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately before Node.js starts the
|
||||||
|
* handshake process to secure the current connection.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly secureConnectionStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately before Node.js receives the
|
||||||
|
* first byte of the response from the server.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly requestStart: number;
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp representing the time immediately after Node.js receives the
|
||||||
|
* last byte of the resource or immediately before the transport connection is closed, whichever comes first.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly responseEnd: number;
|
||||||
|
/**
|
||||||
|
* A number representing the size (in octets) of the fetched resource. The size includes the response header
|
||||||
|
* fields plus the response payload body.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly transferSize: number;
|
||||||
|
/**
|
||||||
|
* A number representing the size (in octets) received from the fetch (HTTP or cache), of the payload body, before
|
||||||
|
* removing any applied content-codings.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly encodedBodySize: number;
|
||||||
|
/**
|
||||||
|
* A number representing the size (in octets) received from the fetch (HTTP or cache), of the message body, after
|
||||||
|
* removing any applied content-codings.
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
readonly decodedBodySize: number;
|
||||||
|
/**
|
||||||
|
* Returns a `object` that is the JSON representation of the `PerformanceResourceTiming` object
|
||||||
|
* @since v18.2.0, v16.17.0
|
||||||
|
*/
|
||||||
|
toJSON(): any;
|
||||||
|
}
|
||||||
|
namespace constants {
|
||||||
|
const NODE_PERFORMANCE_GC_MAJOR: number;
|
||||||
|
const NODE_PERFORMANCE_GC_MINOR: number;
|
||||||
|
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
||||||
|
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
|
||||||
|
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
|
||||||
|
}
|
||||||
|
const performance: Performance;
|
||||||
|
interface EventLoopMonitorOptions {
|
||||||
|
/**
|
||||||
|
* The sampling rate in milliseconds.
|
||||||
|
* Must be greater than zero.
|
||||||
|
* @default 10
|
||||||
|
*/
|
||||||
|
resolution?: number | undefined;
|
||||||
|
}
|
||||||
|
interface Histogram {
|
||||||
|
/**
|
||||||
|
* The number of samples recorded by the histogram.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly count: number;
|
||||||
|
/**
|
||||||
|
* The number of samples recorded by the histogram.
|
||||||
|
* v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly countBigInt: bigint;
|
||||||
|
/**
|
||||||
|
* The number of times the event loop delay exceeded the maximum 1 hour event
|
||||||
|
* loop delay threshold.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly exceeds: number;
|
||||||
|
/**
|
||||||
|
* The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly exceedsBigInt: bigint;
|
||||||
|
/**
|
||||||
|
* The maximum recorded event loop delay.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly max: number;
|
||||||
|
/**
|
||||||
|
* The maximum recorded event loop delay.
|
||||||
|
* v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly maxBigInt: number;
|
||||||
|
/**
|
||||||
|
* The mean of the recorded event loop delays.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly mean: number;
|
||||||
|
/**
|
||||||
|
* The minimum recorded event loop delay.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly min: number;
|
||||||
|
/**
|
||||||
|
* The minimum recorded event loop delay.
|
||||||
|
* v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly minBigInt: bigint;
|
||||||
|
/**
|
||||||
|
* Returns the value at the given percentile.
|
||||||
|
* @since v11.10.0
|
||||||
|
* @param percentile A percentile value in the range (0, 100].
|
||||||
|
*/
|
||||||
|
percentile(percentile: number): number;
|
||||||
|
/**
|
||||||
|
* Returns the value at the given percentile.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
* @param percentile A percentile value in the range (0, 100].
|
||||||
|
*/
|
||||||
|
percentileBigInt(percentile: number): bigint;
|
||||||
|
/**
|
||||||
|
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly percentiles: Map<number, number>;
|
||||||
|
/**
|
||||||
|
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
readonly percentilesBigInt: Map<bigint, bigint>;
|
||||||
|
/**
|
||||||
|
* Resets the collected histogram data.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
reset(): void;
|
||||||
|
/**
|
||||||
|
* The standard deviation of the recorded event loop delays.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
readonly stddev: number;
|
||||||
|
}
|
||||||
|
interface IntervalHistogram extends Histogram {
|
||||||
|
/**
|
||||||
|
* Enables the update interval timer. Returns `true` if the timer was
|
||||||
|
* started, `false` if it was already started.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
enable(): boolean;
|
||||||
|
/**
|
||||||
|
* Disables the update interval timer. Returns `true` if the timer was
|
||||||
|
* stopped, `false` if it was already stopped.
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
disable(): boolean;
|
||||||
|
}
|
||||||
|
interface RecordableHistogram extends Histogram {
|
||||||
|
/**
|
||||||
|
* @since v15.9.0, v14.18.0
|
||||||
|
* @param val The amount to record in the histogram.
|
||||||
|
*/
|
||||||
|
record(val: number | bigint): void;
|
||||||
|
/**
|
||||||
|
* Calculates the amount of time (in nanoseconds) that has passed since the
|
||||||
|
* previous call to `recordDelta()` and records that amount in the histogram.
|
||||||
|
* @since v15.9.0, v14.18.0
|
||||||
|
*/
|
||||||
|
recordDelta(): void;
|
||||||
|
/**
|
||||||
|
* Adds the values from `other` to this histogram.
|
||||||
|
* @since v17.4.0, v16.14.0
|
||||||
|
*/
|
||||||
|
add(other: RecordableHistogram): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||||
|
*
|
||||||
|
* Creates an `IntervalHistogram` object that samples and reports the event loop
|
||||||
|
* delay over time. The delays will be reported in nanoseconds.
|
||||||
|
*
|
||||||
|
* Using a timer to detect approximate event loop delay works because the
|
||||||
|
* execution of timers is tied specifically to the lifecycle of the libuv
|
||||||
|
* event loop. That is, a delay in the loop will cause a delay in the execution
|
||||||
|
* of the timer, and those delays are specifically what this API is intended to
|
||||||
|
* detect.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { monitorEventLoopDelay } from 'node:perf_hooks';
|
||||||
|
* const h = monitorEventLoopDelay({ resolution: 20 });
|
||||||
|
* h.enable();
|
||||||
|
* // Do something.
|
||||||
|
* h.disable();
|
||||||
|
* console.log(h.min);
|
||||||
|
* console.log(h.max);
|
||||||
|
* console.log(h.mean);
|
||||||
|
* console.log(h.stddev);
|
||||||
|
* console.log(h.percentiles);
|
||||||
|
* console.log(h.percentile(50));
|
||||||
|
* console.log(h.percentile(99));
|
||||||
|
* ```
|
||||||
|
* @since v11.10.0
|
||||||
|
*/
|
||||||
|
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
|
||||||
|
interface CreateHistogramOptions {
|
||||||
|
/**
|
||||||
|
* The minimum recordable value. Must be an integer value greater than 0.
|
||||||
|
* @default 1
|
||||||
|
*/
|
||||||
|
min?: number | bigint | undefined;
|
||||||
|
/**
|
||||||
|
* The maximum recordable value. Must be an integer value greater than min.
|
||||||
|
* @default Number.MAX_SAFE_INTEGER
|
||||||
|
*/
|
||||||
|
max?: number | bigint | undefined;
|
||||||
|
/**
|
||||||
|
* The number of accuracy digits. Must be a number between 1 and 5.
|
||||||
|
* @default 3
|
||||||
|
*/
|
||||||
|
figures?: number | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns a `RecordableHistogram`.
|
||||||
|
* @since v15.9.0, v14.18.0
|
||||||
|
*/
|
||||||
|
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
||||||
|
import {
|
||||||
|
performance as _performance,
|
||||||
|
PerformanceEntry as _PerformanceEntry,
|
||||||
|
PerformanceMark as _PerformanceMark,
|
||||||
|
PerformanceMeasure as _PerformanceMeasure,
|
||||||
|
PerformanceObserver as _PerformanceObserver,
|
||||||
|
PerformanceObserverEntryList as _PerformanceObserverEntryList,
|
||||||
|
PerformanceResourceTiming as _PerformanceResourceTiming,
|
||||||
|
} from "perf_hooks";
|
||||||
|
global {
|
||||||
|
/**
|
||||||
|
* `PerformanceEntry` is a global reference for `import { PerformanceEntry } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceentry
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceEntry: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceEntry: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceEntry;
|
||||||
|
/**
|
||||||
|
* `PerformanceMark` is a global reference for `import { PerformanceMark } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performancemark
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceMark: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceMark: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceMark;
|
||||||
|
/**
|
||||||
|
* `PerformanceMeasure` is a global reference for `import { PerformanceMeasure } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performancemeasure
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceMeasure: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceMeasure: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceMeasure;
|
||||||
|
/**
|
||||||
|
* `PerformanceObserver` is a global reference for `import { PerformanceObserver } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceobserver
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceObserver: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceObserver: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceObserver;
|
||||||
|
/**
|
||||||
|
* `PerformanceObserverEntryList` is a global reference for `import { PerformanceObserverEntryList } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceobserverentrylist
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceObserverEntryList: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceObserverEntryList: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceObserverEntryList;
|
||||||
|
/**
|
||||||
|
* `PerformanceResourceTiming` is a global reference for `import { PerformanceResourceTiming } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceresourcetiming
|
||||||
|
* @since v19.0.0
|
||||||
|
*/
|
||||||
|
var PerformanceResourceTiming: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
PerformanceResourceTiming: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _PerformanceResourceTiming;
|
||||||
|
/**
|
||||||
|
* `performance` is a global reference for `import { performance } from 'node:perf_hooks'`
|
||||||
|
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performance
|
||||||
|
* @since v16.0.0
|
||||||
|
*/
|
||||||
|
var performance: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
performance: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _performance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:perf_hooks" {
|
||||||
|
export * from "perf_hooks";
|
||||||
|
}
|
1912
websocket_server/node_modules/.ignored/@types/node/process.d.ts
generated
vendored
Normal file
1912
websocket_server/node_modules/.ignored/@types/node/process.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
117
websocket_server/node_modules/.ignored/@types/node/punycode.d.ts
generated
vendored
Normal file
117
websocket_server/node_modules/.ignored/@types/node/punycode.d.ts
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/**
|
||||||
|
* **The version of the punycode module bundled in Node.js is being deprecated. **In a future major version of Node.js this module will be removed. Users
|
||||||
|
* currently depending on the `punycode` module should switch to using the
|
||||||
|
* userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL
|
||||||
|
* encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`.
|
||||||
|
*
|
||||||
|
* The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It
|
||||||
|
* can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import punycode from 'node:punycode';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is
|
||||||
|
* primarily intended for use in Internationalized Domain Names. Because host
|
||||||
|
* names in URLs are limited to ASCII characters only, Domain Names that contain
|
||||||
|
* non-ASCII characters must be converted into ASCII using the Punycode scheme.
|
||||||
|
* For instance, the Japanese character that translates into the English word, `'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent
|
||||||
|
* to `'example.com'`) is represented by Punycode as the ASCII string `'xn--fsq.com'`.
|
||||||
|
*
|
||||||
|
* The `punycode` module provides a simple implementation of the Punycode standard.
|
||||||
|
*
|
||||||
|
* The `punycode` module is a third-party dependency used by Node.js and
|
||||||
|
* made available to developers as a convenience. Fixes or other modifications to
|
||||||
|
* the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project.
|
||||||
|
* @deprecated Since v7.0.0 - Deprecated
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/punycode.js)
|
||||||
|
*/
|
||||||
|
declare module "punycode" {
|
||||||
|
/**
|
||||||
|
* The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only
|
||||||
|
* characters to the equivalent string of Unicode codepoints.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* punycode.decode('maana-pta'); // 'mañana'
|
||||||
|
* punycode.decode('--dqo34k'); // '☃-⌘'
|
||||||
|
* ```
|
||||||
|
* @since v0.5.1
|
||||||
|
*/
|
||||||
|
function decode(string: string): string;
|
||||||
|
/**
|
||||||
|
* The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* punycode.encode('mañana'); // 'maana-pta'
|
||||||
|
* punycode.encode('☃-⌘'); // '--dqo34k'
|
||||||
|
* ```
|
||||||
|
* @since v0.5.1
|
||||||
|
*/
|
||||||
|
function encode(string: string): string;
|
||||||
|
/**
|
||||||
|
* The `punycode.toUnicode()` method converts a string representing a domain name
|
||||||
|
* containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be
|
||||||
|
* converted.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // decode domain names
|
||||||
|
* punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
|
||||||
|
* punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
|
||||||
|
* punycode.toUnicode('example.com'); // 'example.com'
|
||||||
|
* ```
|
||||||
|
* @since v0.6.1
|
||||||
|
*/
|
||||||
|
function toUnicode(domain: string): string;
|
||||||
|
/**
|
||||||
|
* The `punycode.toASCII()` method converts a Unicode string representing an
|
||||||
|
* Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the
|
||||||
|
* domain name will be converted. Calling `punycode.toASCII()` on a string that
|
||||||
|
* already only contains ASCII characters will have no effect.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // encode domain names
|
||||||
|
* punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
|
||||||
|
* punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
|
||||||
|
* punycode.toASCII('example.com'); // 'example.com'
|
||||||
|
* ```
|
||||||
|
* @since v0.6.1
|
||||||
|
*/
|
||||||
|
function toASCII(domain: string): string;
|
||||||
|
/**
|
||||||
|
* @deprecated since v7.0.0
|
||||||
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
|
* In a future major version of Node.js this module will be removed.
|
||||||
|
* Users currently depending on the punycode module should switch to using
|
||||||
|
* the userland-provided Punycode.js module instead.
|
||||||
|
*/
|
||||||
|
const ucs2: ucs2;
|
||||||
|
interface ucs2 {
|
||||||
|
/**
|
||||||
|
* @deprecated since v7.0.0
|
||||||
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
|
* In a future major version of Node.js this module will be removed.
|
||||||
|
* Users currently depending on the punycode module should switch to using
|
||||||
|
* the userland-provided Punycode.js module instead.
|
||||||
|
*/
|
||||||
|
decode(string: string): number[];
|
||||||
|
/**
|
||||||
|
* @deprecated since v7.0.0
|
||||||
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
|
* In a future major version of Node.js this module will be removed.
|
||||||
|
* Users currently depending on the punycode module should switch to using
|
||||||
|
* the userland-provided Punycode.js module instead.
|
||||||
|
*/
|
||||||
|
encode(codePoints: readonly number[]): string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated since v7.0.0
|
||||||
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
|
* In a future major version of Node.js this module will be removed.
|
||||||
|
* Users currently depending on the punycode module should switch to using
|
||||||
|
* the userland-provided Punycode.js module instead.
|
||||||
|
*/
|
||||||
|
const version: string;
|
||||||
|
}
|
||||||
|
declare module "node:punycode" {
|
||||||
|
export * from "punycode";
|
||||||
|
}
|
153
websocket_server/node_modules/.ignored/@types/node/querystring.d.ts
generated
vendored
Normal file
153
websocket_server/node_modules/.ignored/@types/node/querystring.d.ts
generated
vendored
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* The `node:querystring` module provides utilities for parsing and formatting URL
|
||||||
|
* query strings. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import querystring from 'node:querystring';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `querystring` is more performant than `URLSearchParams` but is not a
|
||||||
|
* standardized API. Use `URLSearchParams` when performance is not critical or
|
||||||
|
* when compatibility with browser code is desirable.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/querystring.js)
|
||||||
|
*/
|
||||||
|
declare module "querystring" {
|
||||||
|
interface StringifyOptions {
|
||||||
|
/**
|
||||||
|
* The function to use when converting URL-unsafe characters to percent-encoding in the query string.
|
||||||
|
* @default `querystring.escape()`
|
||||||
|
*/
|
||||||
|
encodeURIComponent?: ((str: string) => string) | undefined;
|
||||||
|
}
|
||||||
|
interface ParseOptions {
|
||||||
|
/**
|
||||||
|
* Specifies the maximum number of keys to parse. Specify `0` to remove key counting limitations.
|
||||||
|
* @default 1000
|
||||||
|
*/
|
||||||
|
maxKeys?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The function to use when decoding percent-encoded characters in the query string.
|
||||||
|
* @default `querystring.unescape()`
|
||||||
|
*/
|
||||||
|
decodeURIComponent?: ((str: string) => string) | undefined;
|
||||||
|
}
|
||||||
|
interface ParsedUrlQuery extends NodeJS.Dict<string | string[]> {}
|
||||||
|
interface ParsedUrlQueryInput extends
|
||||||
|
NodeJS.Dict<
|
||||||
|
| string
|
||||||
|
| number
|
||||||
|
| boolean
|
||||||
|
| readonly string[]
|
||||||
|
| readonly number[]
|
||||||
|
| readonly boolean[]
|
||||||
|
| null
|
||||||
|
>
|
||||||
|
{}
|
||||||
|
/**
|
||||||
|
* The `querystring.stringify()` method produces a URL query string from a
|
||||||
|
* given `obj` by iterating through the object's "own properties".
|
||||||
|
*
|
||||||
|
* It serializes the following types of values passed in `obj`: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
|
||||||
|
* [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
|
||||||
|
* [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) |
|
||||||
|
* [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
|
||||||
|
* [string\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
|
||||||
|
* [number\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
|
||||||
|
* [bigint\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) |
|
||||||
|
* [boolean\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) The numeric values must be finite. Any other input values will be coerced to
|
||||||
|
* empty strings.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
|
||||||
|
* // Returns 'foo=bar&baz=qux&baz=quux&corge='
|
||||||
|
*
|
||||||
|
* querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
|
||||||
|
* // Returns 'foo:bar;baz:qux'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* By default, characters requiring percent-encoding within the query string will
|
||||||
|
* be encoded as UTF-8\. If an alternative encoding is required, then an alternative `encodeURIComponent` option will need to be specified:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Assuming gbkEncodeURIComponent function already exists,
|
||||||
|
*
|
||||||
|
* querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
|
||||||
|
* { encodeURIComponent: gbkEncodeURIComponent });
|
||||||
|
* ```
|
||||||
|
* @since v0.1.25
|
||||||
|
* @param obj The object to serialize into a URL query string
|
||||||
|
* @param [sep='&'] The substring used to delimit key and value pairs in the query string.
|
||||||
|
* @param [eq='='] . The substring used to delimit keys and values in the query string.
|
||||||
|
*/
|
||||||
|
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
|
||||||
|
/**
|
||||||
|
* The `querystring.parse()` method parses a URL query string (`str`) into a
|
||||||
|
* collection of key and value pairs.
|
||||||
|
*
|
||||||
|
* For example, the query string `'foo=bar&abc=xyz&abc=123'` is parsed into:
|
||||||
|
*
|
||||||
|
* ```json
|
||||||
|
* {
|
||||||
|
* "foo": "bar",
|
||||||
|
* "abc": ["xyz", "123"]
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The object returned by the `querystring.parse()` method _does not_ prototypically inherit from the JavaScript `Object`. This means that typical `Object` methods such as `obj.toString()`,
|
||||||
|
* `obj.hasOwnProperty()`, and others
|
||||||
|
* are not defined and _will not work_.
|
||||||
|
*
|
||||||
|
* By default, percent-encoded characters within the query string will be assumed
|
||||||
|
* to use UTF-8 encoding. If an alternative character encoding is used, then an
|
||||||
|
* alternative `decodeURIComponent` option will need to be specified:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Assuming gbkDecodeURIComponent function already exists...
|
||||||
|
*
|
||||||
|
* querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,
|
||||||
|
* { decodeURIComponent: gbkDecodeURIComponent });
|
||||||
|
* ```
|
||||||
|
* @since v0.1.25
|
||||||
|
* @param str The URL query string to parse
|
||||||
|
* @param [sep='&'] The substring used to delimit key and value pairs in the query string.
|
||||||
|
* @param [eq='='] The substring used to delimit keys and values in the query string.
|
||||||
|
*/
|
||||||
|
function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
|
||||||
|
/**
|
||||||
|
* The querystring.encode() function is an alias for querystring.stringify().
|
||||||
|
*/
|
||||||
|
const encode: typeof stringify;
|
||||||
|
/**
|
||||||
|
* The querystring.decode() function is an alias for querystring.parse().
|
||||||
|
*/
|
||||||
|
const decode: typeof parse;
|
||||||
|
/**
|
||||||
|
* The `querystring.escape()` method performs URL percent-encoding on the given `str` in a manner that is optimized for the specific requirements of URL
|
||||||
|
* query strings.
|
||||||
|
*
|
||||||
|
* The `querystring.escape()` method is used by `querystring.stringify()` and is
|
||||||
|
* generally not expected to be used directly. It is exported primarily to allow
|
||||||
|
* application code to provide a replacement percent-encoding implementation if
|
||||||
|
* necessary by assigning `querystring.escape` to an alternative function.
|
||||||
|
* @since v0.1.25
|
||||||
|
*/
|
||||||
|
function escape(str: string): string;
|
||||||
|
/**
|
||||||
|
* The `querystring.unescape()` method performs decoding of URL percent-encoded
|
||||||
|
* characters on the given `str`.
|
||||||
|
*
|
||||||
|
* The `querystring.unescape()` method is used by `querystring.parse()` and is
|
||||||
|
* generally not expected to be used directly. It is exported primarily to allow
|
||||||
|
* application code to provide a replacement decoding implementation if
|
||||||
|
* necessary by assigning `querystring.unescape` to an alternative function.
|
||||||
|
*
|
||||||
|
* By default, the `querystring.unescape()` method will attempt to use the
|
||||||
|
* JavaScript built-in `decodeURIComponent()` method to decode. If that fails,
|
||||||
|
* a safer equivalent that does not throw on malformed URLs will be used.
|
||||||
|
* @since v0.1.25
|
||||||
|
*/
|
||||||
|
function unescape(str: string): string;
|
||||||
|
}
|
||||||
|
declare module "node:querystring" {
|
||||||
|
export * from "querystring";
|
||||||
|
}
|
540
websocket_server/node_modules/.ignored/@types/node/readline.d.ts
generated
vendored
Normal file
540
websocket_server/node_modules/.ignored/@types/node/readline.d.ts
generated
vendored
Normal file
@ -0,0 +1,540 @@
|
|||||||
|
/**
|
||||||
|
* The `node:readline` module provides an interface for reading data from a [Readable](https://nodejs.org/docs/latest-v22.x/api/stream.html#readable-streams) stream
|
||||||
|
* (such as [`process.stdin`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdin)) one line at a time.
|
||||||
|
*
|
||||||
|
* To use the promise-based APIs:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import * as readline from 'node:readline/promises';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* To use the callback and sync APIs:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import * as readline from 'node:readline';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The following simple example illustrates the basic use of the `node:readline` module.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import * as readline from 'node:readline/promises';
|
||||||
|
* import { stdin as input, stdout as output } from 'node:process';
|
||||||
|
*
|
||||||
|
* const rl = readline.createInterface({ input, output });
|
||||||
|
*
|
||||||
|
* const answer = await rl.question('What do you think of Node.js? ');
|
||||||
|
*
|
||||||
|
* console.log(`Thank you for your valuable feedback: ${answer}`);
|
||||||
|
*
|
||||||
|
* rl.close();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Once this code is invoked, the Node.js application will not terminate until the `readline.Interface` is closed because the interface waits for data to be
|
||||||
|
* received on the `input` stream.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/readline.js)
|
||||||
|
*/
|
||||||
|
declare module "readline" {
|
||||||
|
import { Abortable, EventEmitter } from "node:events";
|
||||||
|
import * as promises from "node:readline/promises";
|
||||||
|
export { promises };
|
||||||
|
export interface Key {
|
||||||
|
sequence?: string | undefined;
|
||||||
|
name?: string | undefined;
|
||||||
|
ctrl?: boolean | undefined;
|
||||||
|
meta?: boolean | undefined;
|
||||||
|
shift?: boolean | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Instances of the `readline.Interface` class are constructed using the `readline.createInterface()` method. Every instance is associated with a
|
||||||
|
* single `input` [Readable](https://nodejs.org/docs/latest-v22.x/api/stream.html#readable-streams) stream and a single `output` [Writable](https://nodejs.org/docs/latest-v22.x/api/stream.html#writable-streams) stream.
|
||||||
|
* The `output` stream is used to print prompts for user input that arrives on,
|
||||||
|
* and is read from, the `input` stream.
|
||||||
|
* @since v0.1.104
|
||||||
|
*/
|
||||||
|
export class Interface extends EventEmitter {
|
||||||
|
readonly terminal: boolean;
|
||||||
|
/**
|
||||||
|
* The current input data being processed by node.
|
||||||
|
*
|
||||||
|
* This can be used when collecting input from a TTY stream to retrieve the
|
||||||
|
* current value that has been processed thus far, prior to the `line` event
|
||||||
|
* being emitted. Once the `line` event has been emitted, this property will
|
||||||
|
* be an empty string.
|
||||||
|
*
|
||||||
|
* Be aware that modifying the value during the instance runtime may have
|
||||||
|
* unintended consequences if `rl.cursor` is not also controlled.
|
||||||
|
*
|
||||||
|
* **If not using a TTY stream for input, use the `'line'` event.**
|
||||||
|
*
|
||||||
|
* One possible use case would be as follows:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const values = ['lorem ipsum', 'dolor sit amet'];
|
||||||
|
* const rl = readline.createInterface(process.stdin);
|
||||||
|
* const showResults = debounce(() => {
|
||||||
|
* console.log(
|
||||||
|
* '\n',
|
||||||
|
* values.filter((val) => val.startsWith(rl.line)).join(' '),
|
||||||
|
* );
|
||||||
|
* }, 300);
|
||||||
|
* process.stdin.on('keypress', (c, k) => {
|
||||||
|
* showResults();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
readonly line: string;
|
||||||
|
/**
|
||||||
|
* The cursor position relative to `rl.line`.
|
||||||
|
*
|
||||||
|
* This will track where the current cursor lands in the input string, when
|
||||||
|
* reading input from a TTY stream. The position of cursor determines the
|
||||||
|
* portion of the input string that will be modified as input is processed,
|
||||||
|
* as well as the column where the terminal caret will be rendered.
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
readonly cursor: number;
|
||||||
|
/**
|
||||||
|
* NOTE: According to the documentation:
|
||||||
|
*
|
||||||
|
* > Instances of the `readline.Interface` class are constructed using the
|
||||||
|
* > `readline.createInterface()` method.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/readline.html#class-interfaceconstructor
|
||||||
|
*/
|
||||||
|
protected constructor(
|
||||||
|
input: NodeJS.ReadableStream,
|
||||||
|
output?: NodeJS.WritableStream,
|
||||||
|
completer?: Completer | AsyncCompleter,
|
||||||
|
terminal?: boolean,
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* NOTE: According to the documentation:
|
||||||
|
*
|
||||||
|
* > Instances of the `readline.Interface` class are constructed using the
|
||||||
|
* > `readline.createInterface()` method.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/readline.html#class-interfaceconstructor
|
||||||
|
*/
|
||||||
|
protected constructor(options: ReadLineOptions);
|
||||||
|
/**
|
||||||
|
* The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
|
||||||
|
* @since v15.3.0, v14.17.0
|
||||||
|
* @return the current prompt string
|
||||||
|
*/
|
||||||
|
getPrompt(): string;
|
||||||
|
/**
|
||||||
|
* The `rl.setPrompt()` method sets the prompt that will be written to `output` whenever `rl.prompt()` is called.
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
setPrompt(prompt: string): void;
|
||||||
|
/**
|
||||||
|
* The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
|
||||||
|
* location at which to provide input.
|
||||||
|
*
|
||||||
|
* When called, `rl.prompt()` will resume the `input` stream if it has been
|
||||||
|
* paused.
|
||||||
|
*
|
||||||
|
* If the `Interface` was created with `output` set to `null` or `undefined` the prompt is not written.
|
||||||
|
* @since v0.1.98
|
||||||
|
* @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`.
|
||||||
|
*/
|
||||||
|
prompt(preserveCursor?: boolean): void;
|
||||||
|
/**
|
||||||
|
* The `rl.question()` method displays the `query` by writing it to the `output`,
|
||||||
|
* waits for user input to be provided on `input`, then invokes the `callback` function passing the provided input as the first argument.
|
||||||
|
*
|
||||||
|
* When called, `rl.question()` will resume the `input` stream if it has been
|
||||||
|
* paused.
|
||||||
|
*
|
||||||
|
* If the `Interface` was created with `output` set to `null` or `undefined` the `query` is not written.
|
||||||
|
*
|
||||||
|
* The `callback` function passed to `rl.question()` does not follow the typical
|
||||||
|
* pattern of accepting an `Error` object or `null` as the first argument.
|
||||||
|
* The `callback` is called with the provided answer as the only argument.
|
||||||
|
*
|
||||||
|
* An error will be thrown if calling `rl.question()` after `rl.close()`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* rl.question('What is your favorite food? ', (answer) => {
|
||||||
|
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Using an `AbortController` to cancel a question.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const ac = new AbortController();
|
||||||
|
* const signal = ac.signal;
|
||||||
|
*
|
||||||
|
* rl.question('What is your favorite food? ', { signal }, (answer) => {
|
||||||
|
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* signal.addEventListener('abort', () => {
|
||||||
|
* console.log('The food question timed out');
|
||||||
|
* }, { once: true });
|
||||||
|
*
|
||||||
|
* setTimeout(() => ac.abort(), 10000);
|
||||||
|
* ```
|
||||||
|
* @since v0.3.3
|
||||||
|
* @param query A statement or query to write to `output`, prepended to the prompt.
|
||||||
|
* @param callback A callback function that is invoked with the user's input in response to the `query`.
|
||||||
|
*/
|
||||||
|
question(query: string, callback: (answer: string) => void): void;
|
||||||
|
question(query: string, options: Abortable, callback: (answer: string) => void): void;
|
||||||
|
/**
|
||||||
|
* The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
|
||||||
|
* later if necessary.
|
||||||
|
*
|
||||||
|
* Calling `rl.pause()` does not immediately pause other events (including `'line'`) from being emitted by the `Interface` instance.
|
||||||
|
* @since v0.3.4
|
||||||
|
*/
|
||||||
|
pause(): this;
|
||||||
|
/**
|
||||||
|
* The `rl.resume()` method resumes the `input` stream if it has been paused.
|
||||||
|
* @since v0.3.4
|
||||||
|
*/
|
||||||
|
resume(): this;
|
||||||
|
/**
|
||||||
|
* The `rl.close()` method closes the `Interface` instance and
|
||||||
|
* relinquishes control over the `input` and `output` streams. When called,
|
||||||
|
* the `'close'` event will be emitted.
|
||||||
|
*
|
||||||
|
* Calling `rl.close()` does not immediately stop other events (including `'line'`)
|
||||||
|
* from being emitted by the `Interface` instance.
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
close(): void;
|
||||||
|
/**
|
||||||
|
* The `rl.write()` method will write either `data` or a key sequence identified
|
||||||
|
* by `key` to the `output`. The `key` argument is supported only if `output` is
|
||||||
|
* a `TTY` text terminal. See `TTY keybindings` for a list of key
|
||||||
|
* combinations.
|
||||||
|
*
|
||||||
|
* If `key` is specified, `data` is ignored.
|
||||||
|
*
|
||||||
|
* When called, `rl.write()` will resume the `input` stream if it has been
|
||||||
|
* paused.
|
||||||
|
*
|
||||||
|
* If the `Interface` was created with `output` set to `null` or `undefined` the `data` and `key` are not written.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* rl.write('Delete this!');
|
||||||
|
* // Simulate Ctrl+U to delete the line written previously
|
||||||
|
* rl.write(null, { ctrl: true, name: 'u' });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The `rl.write()` method will write the data to the `readline` `Interface`'s `input` _as if it were provided by the user_.
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
write(data: string | Buffer, key?: Key): void;
|
||||||
|
write(data: undefined | null | string | Buffer, key: Key): void;
|
||||||
|
/**
|
||||||
|
* Returns the real position of the cursor in relation to the input
|
||||||
|
* prompt + string. Long input (wrapping) strings, as well as multiple
|
||||||
|
* line prompts are included in the calculations.
|
||||||
|
* @since v13.5.0, v12.16.0
|
||||||
|
*/
|
||||||
|
getCursorPos(): CursorPos;
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. close
|
||||||
|
* 2. line
|
||||||
|
* 3. pause
|
||||||
|
* 4. resume
|
||||||
|
* 5. SIGCONT
|
||||||
|
* 6. SIGINT
|
||||||
|
* 7. SIGTSTP
|
||||||
|
* 8. history
|
||||||
|
*/
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
addListener(event: "pause", listener: () => void): this;
|
||||||
|
addListener(event: "resume", listener: () => void): this;
|
||||||
|
addListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
addListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
addListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
addListener(event: "history", listener: (history: string[]) => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "close"): boolean;
|
||||||
|
emit(event: "line", input: string): boolean;
|
||||||
|
emit(event: "pause"): boolean;
|
||||||
|
emit(event: "resume"): boolean;
|
||||||
|
emit(event: "SIGCONT"): boolean;
|
||||||
|
emit(event: "SIGINT"): boolean;
|
||||||
|
emit(event: "SIGTSTP"): boolean;
|
||||||
|
emit(event: "history", history: string[]): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "line", listener: (input: string) => void): this;
|
||||||
|
on(event: "pause", listener: () => void): this;
|
||||||
|
on(event: "resume", listener: () => void): this;
|
||||||
|
on(event: "SIGCONT", listener: () => void): this;
|
||||||
|
on(event: "SIGINT", listener: () => void): this;
|
||||||
|
on(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
on(event: "history", listener: (history: string[]) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "line", listener: (input: string) => void): this;
|
||||||
|
once(event: "pause", listener: () => void): this;
|
||||||
|
once(event: "resume", listener: () => void): this;
|
||||||
|
once(event: "SIGCONT", listener: () => void): this;
|
||||||
|
once(event: "SIGINT", listener: () => void): this;
|
||||||
|
once(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
once(event: "history", listener: (history: string[]) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
prependListener(event: "pause", listener: () => void): this;
|
||||||
|
prependListener(event: "resume", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
prependListener(event: "history", listener: (history: string[]) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
prependOnceListener(event: "pause", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "resume", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "history", listener: (history: string[]) => void): this;
|
||||||
|
[Symbol.asyncIterator](): NodeJS.AsyncIterator<string>;
|
||||||
|
}
|
||||||
|
export type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||||
|
export type Completer = (line: string) => CompleterResult;
|
||||||
|
export type AsyncCompleter = (
|
||||||
|
line: string,
|
||||||
|
callback: (err?: null | Error, result?: CompleterResult) => void,
|
||||||
|
) => void;
|
||||||
|
export type CompleterResult = [string[], string];
|
||||||
|
export interface ReadLineOptions {
|
||||||
|
input: NodeJS.ReadableStream;
|
||||||
|
output?: NodeJS.WritableStream | undefined;
|
||||||
|
completer?: Completer | AsyncCompleter | undefined;
|
||||||
|
terminal?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Initial list of history lines. This option makes sense
|
||||||
|
* only if `terminal` is set to `true` by the user or by an internal `output`
|
||||||
|
* check, otherwise the history caching mechanism is not initialized at all.
|
||||||
|
* @default []
|
||||||
|
*/
|
||||||
|
history?: string[] | undefined;
|
||||||
|
historySize?: number | undefined;
|
||||||
|
prompt?: string | undefined;
|
||||||
|
crlfDelay?: number | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, when a new input line added
|
||||||
|
* to the history list duplicates an older one, this removes the older line
|
||||||
|
* from the list.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
removeHistoryDuplicates?: boolean | undefined;
|
||||||
|
escapeCodeTimeout?: number | undefined;
|
||||||
|
tabSize?: number | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `readline.createInterface()` method creates a new `readline.Interface` instance.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import readline from 'node:readline';
|
||||||
|
* const rl = readline.createInterface({
|
||||||
|
* input: process.stdin,
|
||||||
|
* output: process.stdout,
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Once the `readline.Interface` instance is created, the most common case is to
|
||||||
|
* listen for the `'line'` event:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* rl.on('line', (line) => {
|
||||||
|
* console.log(`Received: ${line}`);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `terminal` is `true` for this instance then the `output` stream will get
|
||||||
|
* the best compatibility if it defines an `output.columns` property and emits
|
||||||
|
* a `'resize'` event on the `output` if or when the columns ever change
|
||||||
|
* (`process.stdout` does this automatically when it is a TTY).
|
||||||
|
*
|
||||||
|
* When creating a `readline.Interface` using `stdin` as input, the program
|
||||||
|
* will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without
|
||||||
|
* waiting for user input, call `process.stdin.unref()`.
|
||||||
|
* @since v0.1.98
|
||||||
|
*/
|
||||||
|
export function createInterface(
|
||||||
|
input: NodeJS.ReadableStream,
|
||||||
|
output?: NodeJS.WritableStream,
|
||||||
|
completer?: Completer | AsyncCompleter,
|
||||||
|
terminal?: boolean,
|
||||||
|
): Interface;
|
||||||
|
export function createInterface(options: ReadLineOptions): Interface;
|
||||||
|
/**
|
||||||
|
* The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
|
||||||
|
*
|
||||||
|
* Optionally, `interface` specifies a `readline.Interface` instance for which
|
||||||
|
* autocompletion is disabled when copy-pasted input is detected.
|
||||||
|
*
|
||||||
|
* If the `stream` is a `TTY`, then it must be in raw mode.
|
||||||
|
*
|
||||||
|
* This is automatically called by any readline instance on its `input` if the `input` is a terminal. Closing the `readline` instance does not stop
|
||||||
|
* the `input` from emitting `'keypress'` events.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* readline.emitKeypressEvents(process.stdin);
|
||||||
|
* if (process.stdin.isTTY)
|
||||||
|
* process.stdin.setRawMode(true);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ## Example: Tiny CLI
|
||||||
|
*
|
||||||
|
* The following example illustrates the use of `readline.Interface` class to
|
||||||
|
* implement a small command-line interface:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import readline from 'node:readline';
|
||||||
|
* const rl = readline.createInterface({
|
||||||
|
* input: process.stdin,
|
||||||
|
* output: process.stdout,
|
||||||
|
* prompt: 'OHAI> ',
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* rl.prompt();
|
||||||
|
*
|
||||||
|
* rl.on('line', (line) => {
|
||||||
|
* switch (line.trim()) {
|
||||||
|
* case 'hello':
|
||||||
|
* console.log('world!');
|
||||||
|
* break;
|
||||||
|
* default:
|
||||||
|
* console.log(`Say what? I might have heard '${line.trim()}'`);
|
||||||
|
* break;
|
||||||
|
* }
|
||||||
|
* rl.prompt();
|
||||||
|
* }).on('close', () => {
|
||||||
|
* console.log('Have a great day!');
|
||||||
|
* process.exit(0);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ## Example: Read file stream line-by-Line
|
||||||
|
*
|
||||||
|
* A common use case for `readline` is to consume an input file one line at a
|
||||||
|
* time. The easiest way to do so is leveraging the `fs.ReadStream` API as
|
||||||
|
* well as a `for await...of` loop:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
* import readline from 'node:readline';
|
||||||
|
*
|
||||||
|
* async function processLineByLine() {
|
||||||
|
* const fileStream = fs.createReadStream('input.txt');
|
||||||
|
*
|
||||||
|
* const rl = readline.createInterface({
|
||||||
|
* input: fileStream,
|
||||||
|
* crlfDelay: Infinity,
|
||||||
|
* });
|
||||||
|
* // Note: we use the crlfDelay option to recognize all instances of CR LF
|
||||||
|
* // ('\r\n') in input.txt as a single line break.
|
||||||
|
*
|
||||||
|
* for await (const line of rl) {
|
||||||
|
* // Each line in input.txt will be successively available here as `line`.
|
||||||
|
* console.log(`Line from file: ${line}`);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* processLineByLine();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Alternatively, one could use the `'line'` event:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
* import readline from 'node:readline';
|
||||||
|
*
|
||||||
|
* const rl = readline.createInterface({
|
||||||
|
* input: fs.createReadStream('sample.txt'),
|
||||||
|
* crlfDelay: Infinity,
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* rl.on('line', (line) => {
|
||||||
|
* console.log(`Line from file: ${line}`);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Currently, `for await...of` loop can be a bit slower. If `async` / `await` flow and speed are both essential, a mixed approach can be applied:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { once } from 'node:events';
|
||||||
|
* import { createReadStream } from 'node:fs';
|
||||||
|
* import { createInterface } from 'node:readline';
|
||||||
|
*
|
||||||
|
* (async function processLineByLine() {
|
||||||
|
* try {
|
||||||
|
* const rl = createInterface({
|
||||||
|
* input: createReadStream('big-file.txt'),
|
||||||
|
* crlfDelay: Infinity,
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* rl.on('line', (line) => {
|
||||||
|
* // Process the line.
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* await once(rl, 'close');
|
||||||
|
*
|
||||||
|
* console.log('File processed.');
|
||||||
|
* } catch (err) {
|
||||||
|
* console.error(err);
|
||||||
|
* }
|
||||||
|
* })();
|
||||||
|
* ```
|
||||||
|
* @since v0.7.7
|
||||||
|
*/
|
||||||
|
export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||||
|
export type Direction = -1 | 0 | 1;
|
||||||
|
export interface CursorPos {
|
||||||
|
rows: number;
|
||||||
|
cols: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `readline.clearLine()` method clears current line of given [TTY](https://nodejs.org/docs/latest-v22.x/api/tty.html) stream
|
||||||
|
* in a specified direction identified by `dir`.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* The `readline.clearScreenDown()` method clears the given [TTY](https://nodejs.org/docs/latest-v22.x/api/tty.html) stream from
|
||||||
|
* the current position of the cursor down.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
||||||
|
* given [TTY](https://nodejs.org/docs/latest-v22.x/api/tty.html) `stream`.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* The `readline.moveCursor()` method moves the cursor _relative_ to its current
|
||||||
|
* position in a given [TTY](https://nodejs.org/docs/latest-v22.x/api/tty.html) `stream`.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||||
|
}
|
||||||
|
declare module "node:readline" {
|
||||||
|
export * from "readline";
|
||||||
|
}
|
150
websocket_server/node_modules/.ignored/@types/node/readline/promises.d.ts
generated
vendored
Normal file
150
websocket_server/node_modules/.ignored/@types/node/readline/promises.d.ts
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/**
|
||||||
|
* @since v17.0.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
declare module "readline/promises" {
|
||||||
|
import { AsyncCompleter, Completer, Direction, Interface as _Interface, ReadLineOptions } from "node:readline";
|
||||||
|
import { Abortable } from "node:events";
|
||||||
|
/**
|
||||||
|
* Instances of the `readlinePromises.Interface` class are constructed using the `readlinePromises.createInterface()` method. Every instance is associated with a
|
||||||
|
* single `input` `Readable` stream and a single `output` `Writable` stream.
|
||||||
|
* The `output` stream is used to print prompts for user input that arrives on,
|
||||||
|
* and is read from, the `input` stream.
|
||||||
|
* @since v17.0.0
|
||||||
|
*/
|
||||||
|
class Interface extends _Interface {
|
||||||
|
/**
|
||||||
|
* The `rl.question()` method displays the `query` by writing it to the `output`,
|
||||||
|
* waits for user input to be provided on `input`, then invokes the `callback` function passing the provided input as the first argument.
|
||||||
|
*
|
||||||
|
* When called, `rl.question()` will resume the `input` stream if it has been
|
||||||
|
* paused.
|
||||||
|
*
|
||||||
|
* If the `Interface` was created with `output` set to `null` or `undefined` the `query` is not written.
|
||||||
|
*
|
||||||
|
* If the question is called after `rl.close()`, it returns a rejected promise.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const answer = await rl.question('What is your favorite food? ');
|
||||||
|
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Using an `AbortSignal` to cancel a question.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const signal = AbortSignal.timeout(10_000);
|
||||||
|
*
|
||||||
|
* signal.addEventListener('abort', () => {
|
||||||
|
* console.log('The food question timed out');
|
||||||
|
* }, { once: true });
|
||||||
|
*
|
||||||
|
* const answer = await rl.question('What is your favorite food? ', { signal });
|
||||||
|
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||||
|
* ```
|
||||||
|
* @since v17.0.0
|
||||||
|
* @param query A statement or query to write to `output`, prepended to the prompt.
|
||||||
|
* @return A promise that is fulfilled with the user's input in response to the `query`.
|
||||||
|
*/
|
||||||
|
question(query: string): Promise<string>;
|
||||||
|
question(query: string, options: Abortable): Promise<string>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @since v17.0.0
|
||||||
|
*/
|
||||||
|
class Readline {
|
||||||
|
/**
|
||||||
|
* @param stream A TTY stream.
|
||||||
|
*/
|
||||||
|
constructor(
|
||||||
|
stream: NodeJS.WritableStream,
|
||||||
|
options?: {
|
||||||
|
autoCommit?: boolean;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* The `rl.clearLine()` method adds to the internal list of pending action an
|
||||||
|
* action that clears current line of the associated `stream` in a specified
|
||||||
|
* direction identified by `dir`.
|
||||||
|
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||||
|
* @since v17.0.0
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
clearLine(dir: Direction): this;
|
||||||
|
/**
|
||||||
|
* The `rl.clearScreenDown()` method adds to the internal list of pending action an
|
||||||
|
* action that clears the associated stream from the current position of the
|
||||||
|
* cursor down.
|
||||||
|
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||||
|
* @since v17.0.0
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
clearScreenDown(): this;
|
||||||
|
/**
|
||||||
|
* The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions.
|
||||||
|
* @since v17.0.0
|
||||||
|
*/
|
||||||
|
commit(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* The `rl.cursorTo()` method adds to the internal list of pending action an action
|
||||||
|
* that moves cursor to the specified position in the associated `stream`.
|
||||||
|
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||||
|
* @since v17.0.0
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
cursorTo(x: number, y?: number): this;
|
||||||
|
/**
|
||||||
|
* The `rl.moveCursor()` method adds to the internal list of pending action an
|
||||||
|
* action that moves the cursor _relative_ to its current position in the
|
||||||
|
* associated `stream`.
|
||||||
|
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||||
|
* @since v17.0.0
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
moveCursor(dx: number, dy: number): this;
|
||||||
|
/**
|
||||||
|
* The `rl.rollback` methods clears the internal list of pending actions without
|
||||||
|
* sending it to the associated `stream`.
|
||||||
|
* @since v17.0.0
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
rollback(): this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import readlinePromises from 'node:readline/promises';
|
||||||
|
* const rl = readlinePromises.createInterface({
|
||||||
|
* input: process.stdin,
|
||||||
|
* output: process.stdout,
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Once the `readlinePromises.Interface` instance is created, the most common case
|
||||||
|
* is to listen for the `'line'` event:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* rl.on('line', (line) => {
|
||||||
|
* console.log(`Received: ${line}`);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `terminal` is `true` for this instance then the `output` stream will get
|
||||||
|
* the best compatibility if it defines an `output.columns` property and emits
|
||||||
|
* a `'resize'` event on the `output` if or when the columns ever change
|
||||||
|
* (`process.stdout` does this automatically when it is a TTY).
|
||||||
|
* @since v17.0.0
|
||||||
|
*/
|
||||||
|
function createInterface(
|
||||||
|
input: NodeJS.ReadableStream,
|
||||||
|
output?: NodeJS.WritableStream,
|
||||||
|
completer?: Completer | AsyncCompleter,
|
||||||
|
terminal?: boolean,
|
||||||
|
): Interface;
|
||||||
|
function createInterface(options: ReadLineOptions): Interface;
|
||||||
|
}
|
||||||
|
declare module "node:readline/promises" {
|
||||||
|
export * from "readline/promises";
|
||||||
|
}
|
430
websocket_server/node_modules/.ignored/@types/node/repl.d.ts
generated
vendored
Normal file
430
websocket_server/node_modules/.ignored/@types/node/repl.d.ts
generated
vendored
Normal file
@ -0,0 +1,430 @@
|
|||||||
|
/**
|
||||||
|
* The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation
|
||||||
|
* that is available both as a standalone program or includible in other
|
||||||
|
* applications. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import repl from 'node:repl';
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/repl.js)
|
||||||
|
*/
|
||||||
|
declare module "repl" {
|
||||||
|
import { AsyncCompleter, Completer, Interface } from "node:readline";
|
||||||
|
import { Context } from "node:vm";
|
||||||
|
import { InspectOptions } from "node:util";
|
||||||
|
interface ReplOptions {
|
||||||
|
/**
|
||||||
|
* The input prompt to display.
|
||||||
|
* @default "> "
|
||||||
|
*/
|
||||||
|
prompt?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The `Readable` stream from which REPL input will be read.
|
||||||
|
* @default process.stdin
|
||||||
|
*/
|
||||||
|
input?: NodeJS.ReadableStream | undefined;
|
||||||
|
/**
|
||||||
|
* The `Writable` stream to which REPL output will be written.
|
||||||
|
* @default process.stdout
|
||||||
|
*/
|
||||||
|
output?: NodeJS.WritableStream | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, specifies that the output should be treated as a TTY terminal, and have
|
||||||
|
* ANSI/VT100 escape codes written to it.
|
||||||
|
* Default: checking the value of the `isTTY` property on the output stream upon
|
||||||
|
* instantiation.
|
||||||
|
*/
|
||||||
|
terminal?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The function to be used when evaluating each given line of input.
|
||||||
|
* Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can
|
||||||
|
* error with `repl.Recoverable` to indicate the input was incomplete and prompt for
|
||||||
|
* additional lines.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_default_evaluation
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_custom_evaluation_functions
|
||||||
|
*/
|
||||||
|
eval?: REPLEval | undefined;
|
||||||
|
/**
|
||||||
|
* Defines if the repl prints output previews or not.
|
||||||
|
* @default `true` Always `false` in case `terminal` is falsy.
|
||||||
|
*/
|
||||||
|
preview?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, specifies that the default `writer` function should include ANSI color
|
||||||
|
* styling to REPL output. If a custom `writer` function is provided then this has no
|
||||||
|
* effect.
|
||||||
|
* @default the REPL instance's `terminal` value
|
||||||
|
*/
|
||||||
|
useColors?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, specifies that the default evaluation function will use the JavaScript
|
||||||
|
* `global` as the context as opposed to creating a new separate context for the REPL
|
||||||
|
* instance. The node CLI REPL sets this value to `true`.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
useGlobal?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, specifies that the default writer will not output the return value of a
|
||||||
|
* command if it evaluates to `undefined`.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
ignoreUndefined?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The function to invoke to format the output of each command before writing to `output`.
|
||||||
|
* @default a wrapper for `util.inspect`
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_customizing_repl_output
|
||||||
|
*/
|
||||||
|
writer?: REPLWriter | undefined;
|
||||||
|
/**
|
||||||
|
* An optional function used for custom Tab auto completion.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/readline.html#readline_use_of_the_completer_function
|
||||||
|
*/
|
||||||
|
completer?: Completer | AsyncCompleter | undefined;
|
||||||
|
/**
|
||||||
|
* A flag that specifies whether the default evaluator executes all JavaScript commands in
|
||||||
|
* strict mode or default (sloppy) mode.
|
||||||
|
* Accepted values are:
|
||||||
|
* - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
|
||||||
|
* - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
|
||||||
|
* prefacing every repl statement with `'use strict'`.
|
||||||
|
*/
|
||||||
|
replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT | undefined;
|
||||||
|
/**
|
||||||
|
* Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is
|
||||||
|
* pressed. This cannot be used together with a custom `eval` function.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
breakEvalOnSigint?: boolean | undefined;
|
||||||
|
}
|
||||||
|
type REPLEval = (
|
||||||
|
this: REPLServer,
|
||||||
|
evalCmd: string,
|
||||||
|
context: Context,
|
||||||
|
file: string,
|
||||||
|
cb: (err: Error | null, result: any) => void,
|
||||||
|
) => void;
|
||||||
|
type REPLWriter = (this: REPLServer, obj: any) => string;
|
||||||
|
/**
|
||||||
|
* This is the default "writer" value, if none is passed in the REPL options,
|
||||||
|
* and it can be overridden by custom print functions.
|
||||||
|
*/
|
||||||
|
const writer: REPLWriter & {
|
||||||
|
options: InspectOptions;
|
||||||
|
};
|
||||||
|
type REPLCommandAction = (this: REPLServer, text: string) => void;
|
||||||
|
interface REPLCommand {
|
||||||
|
/**
|
||||||
|
* Help text to be displayed when `.help` is entered.
|
||||||
|
*/
|
||||||
|
help?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The function to execute, optionally accepting a single string argument.
|
||||||
|
*/
|
||||||
|
action: REPLCommandAction;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Instances of `repl.REPLServer` are created using the {@link start} method
|
||||||
|
* or directly using the JavaScript `new` keyword.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import repl from 'node:repl';
|
||||||
|
*
|
||||||
|
* const options = { useColors: true };
|
||||||
|
*
|
||||||
|
* const firstInstance = repl.start(options);
|
||||||
|
* const secondInstance = new repl.REPLServer(options);
|
||||||
|
* ```
|
||||||
|
* @since v0.1.91
|
||||||
|
*/
|
||||||
|
class REPLServer extends Interface {
|
||||||
|
/**
|
||||||
|
* The `vm.Context` provided to the `eval` function to be used for JavaScript
|
||||||
|
* evaluation.
|
||||||
|
*/
|
||||||
|
readonly context: Context;
|
||||||
|
/**
|
||||||
|
* @deprecated since v14.3.0 - Use `input` instead.
|
||||||
|
*/
|
||||||
|
readonly inputStream: NodeJS.ReadableStream;
|
||||||
|
/**
|
||||||
|
* @deprecated since v14.3.0 - Use `output` instead.
|
||||||
|
*/
|
||||||
|
readonly outputStream: NodeJS.WritableStream;
|
||||||
|
/**
|
||||||
|
* The `Readable` stream from which REPL input will be read.
|
||||||
|
*/
|
||||||
|
readonly input: NodeJS.ReadableStream;
|
||||||
|
/**
|
||||||
|
* The `Writable` stream to which REPL output will be written.
|
||||||
|
*/
|
||||||
|
readonly output: NodeJS.WritableStream;
|
||||||
|
/**
|
||||||
|
* The commands registered via `replServer.defineCommand()`.
|
||||||
|
*/
|
||||||
|
readonly commands: NodeJS.ReadOnlyDict<REPLCommand>;
|
||||||
|
/**
|
||||||
|
* A value indicating whether the REPL is currently in "editor mode".
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_commands_and_special_keys
|
||||||
|
*/
|
||||||
|
readonly editorMode: boolean;
|
||||||
|
/**
|
||||||
|
* A value indicating whether the `_` variable has been assigned.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||||
|
*/
|
||||||
|
readonly underscoreAssigned: boolean;
|
||||||
|
/**
|
||||||
|
* The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL).
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||||
|
*/
|
||||||
|
readonly last: any;
|
||||||
|
/**
|
||||||
|
* A value indicating whether the `_error` variable has been assigned.
|
||||||
|
*
|
||||||
|
* @since v9.8.0
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||||
|
*/
|
||||||
|
readonly underscoreErrAssigned: boolean;
|
||||||
|
/**
|
||||||
|
* The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL).
|
||||||
|
*
|
||||||
|
* @since v9.8.0
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||||
|
*/
|
||||||
|
readonly lastError: any;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is the function to be used when evaluating each
|
||||||
|
* given line of input. If not specified in the REPL options, this is an async wrapper
|
||||||
|
* for the JavaScript `eval()` function.
|
||||||
|
*/
|
||||||
|
readonly eval: REPLEval;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is a value indicating whether the default
|
||||||
|
* `writer` function should include ANSI color styling to REPL output.
|
||||||
|
*/
|
||||||
|
readonly useColors: boolean;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is a value indicating whether the default `eval`
|
||||||
|
* function will use the JavaScript `global` as the context as opposed to creating a new
|
||||||
|
* separate context for the REPL instance.
|
||||||
|
*/
|
||||||
|
readonly useGlobal: boolean;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is a value indicating whether the default `writer`
|
||||||
|
* function should output the result of a command if it evaluates to `undefined`.
|
||||||
|
*/
|
||||||
|
readonly ignoreUndefined: boolean;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is the function to invoke to format the output of
|
||||||
|
* each command before writing to `outputStream`. If not specified in the REPL options,
|
||||||
|
* this will be a wrapper for `util.inspect`.
|
||||||
|
*/
|
||||||
|
readonly writer: REPLWriter;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is the function to use for custom Tab auto-completion.
|
||||||
|
*/
|
||||||
|
readonly completer: Completer | AsyncCompleter;
|
||||||
|
/**
|
||||||
|
* Specified in the REPL options, this is a flag that specifies whether the default `eval`
|
||||||
|
* function should execute all JavaScript commands in strict mode or default (sloppy) mode.
|
||||||
|
* Possible values are:
|
||||||
|
* - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
|
||||||
|
* - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
|
||||||
|
* prefacing every repl statement with `'use strict'`.
|
||||||
|
*/
|
||||||
|
readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
|
||||||
|
/**
|
||||||
|
* NOTE: According to the documentation:
|
||||||
|
*
|
||||||
|
* > Instances of `repl.REPLServer` are created using the `repl.start()` method and
|
||||||
|
* > _should not_ be created directly using the JavaScript `new` keyword.
|
||||||
|
*
|
||||||
|
* `REPLServer` cannot be subclassed due to implementation specifics in NodeJS.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_class_replserver
|
||||||
|
*/
|
||||||
|
private constructor();
|
||||||
|
/**
|
||||||
|
* The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands
|
||||||
|
* to the REPL instance. Such commands are invoked by typing a `.` followed by the `keyword`. The `cmd` is either a `Function` or an `Object` with the following
|
||||||
|
* properties:
|
||||||
|
*
|
||||||
|
* The following example shows two new commands added to the REPL instance:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import repl from 'node:repl';
|
||||||
|
*
|
||||||
|
* const replServer = repl.start({ prompt: '> ' });
|
||||||
|
* replServer.defineCommand('sayhello', {
|
||||||
|
* help: 'Say hello',
|
||||||
|
* action(name) {
|
||||||
|
* this.clearBufferedCommand();
|
||||||
|
* console.log(`Hello, ${name}!`);
|
||||||
|
* this.displayPrompt();
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
* replServer.defineCommand('saybye', function saybye() {
|
||||||
|
* console.log('Goodbye!');
|
||||||
|
* this.close();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The new commands can then be used from within the REPL instance:
|
||||||
|
*
|
||||||
|
* ```console
|
||||||
|
* > .sayhello Node.js User
|
||||||
|
* Hello, Node.js User!
|
||||||
|
* > .saybye
|
||||||
|
* Goodbye!
|
||||||
|
* ```
|
||||||
|
* @since v0.3.0
|
||||||
|
* @param keyword The command keyword (_without_ a leading `.` character).
|
||||||
|
* @param cmd The function to invoke when the command is processed.
|
||||||
|
*/
|
||||||
|
defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
|
||||||
|
/**
|
||||||
|
* The `replServer.displayPrompt()` method readies the REPL instance for input
|
||||||
|
* from the user, printing the configured `prompt` to a new line in the `output` and resuming the `input` to accept new input.
|
||||||
|
*
|
||||||
|
* When multi-line input is being entered, an ellipsis is printed rather than the
|
||||||
|
* 'prompt'.
|
||||||
|
*
|
||||||
|
* When `preserveCursor` is `true`, the cursor placement will not be reset to `0`.
|
||||||
|
*
|
||||||
|
* The `replServer.displayPrompt` method is primarily intended to be called from
|
||||||
|
* within the action function for commands registered using the `replServer.defineCommand()` method.
|
||||||
|
* @since v0.1.91
|
||||||
|
*/
|
||||||
|
displayPrompt(preserveCursor?: boolean): void;
|
||||||
|
/**
|
||||||
|
* The `replServer.clearBufferedCommand()` method clears any command that has been
|
||||||
|
* buffered but not yet executed. This method is primarily intended to be
|
||||||
|
* called from within the action function for commands registered using the `replServer.defineCommand()` method.
|
||||||
|
* @since v9.0.0
|
||||||
|
*/
|
||||||
|
clearBufferedCommand(): void;
|
||||||
|
/**
|
||||||
|
* Initializes a history log file for the REPL instance. When executing the
|
||||||
|
* Node.js binary and using the command-line REPL, a history file is initialized
|
||||||
|
* by default. However, this is not the case when creating a REPL
|
||||||
|
* programmatically. Use this method to initialize a history log file when working
|
||||||
|
* with REPL instances programmatically.
|
||||||
|
* @since v11.10.0
|
||||||
|
* @param historyPath the path to the history file
|
||||||
|
* @param callback called when history writes are ready or upon error
|
||||||
|
*/
|
||||||
|
setupHistory(path: string, callback: (err: Error | null, repl: this) => void): void;
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. close - inherited from `readline.Interface`
|
||||||
|
* 2. line - inherited from `readline.Interface`
|
||||||
|
* 3. pause - inherited from `readline.Interface`
|
||||||
|
* 4. resume - inherited from `readline.Interface`
|
||||||
|
* 5. SIGCONT - inherited from `readline.Interface`
|
||||||
|
* 6. SIGINT - inherited from `readline.Interface`
|
||||||
|
* 7. SIGTSTP - inherited from `readline.Interface`
|
||||||
|
* 8. exit
|
||||||
|
* 9. reset
|
||||||
|
*/
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
addListener(event: "pause", listener: () => void): this;
|
||||||
|
addListener(event: "resume", listener: () => void): this;
|
||||||
|
addListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
addListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
addListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
addListener(event: "exit", listener: () => void): this;
|
||||||
|
addListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "close"): boolean;
|
||||||
|
emit(event: "line", input: string): boolean;
|
||||||
|
emit(event: "pause"): boolean;
|
||||||
|
emit(event: "resume"): boolean;
|
||||||
|
emit(event: "SIGCONT"): boolean;
|
||||||
|
emit(event: "SIGINT"): boolean;
|
||||||
|
emit(event: "SIGTSTP"): boolean;
|
||||||
|
emit(event: "exit"): boolean;
|
||||||
|
emit(event: "reset", context: Context): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "line", listener: (input: string) => void): this;
|
||||||
|
on(event: "pause", listener: () => void): this;
|
||||||
|
on(event: "resume", listener: () => void): this;
|
||||||
|
on(event: "SIGCONT", listener: () => void): this;
|
||||||
|
on(event: "SIGINT", listener: () => void): this;
|
||||||
|
on(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
on(event: "exit", listener: () => void): this;
|
||||||
|
on(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "line", listener: (input: string) => void): this;
|
||||||
|
once(event: "pause", listener: () => void): this;
|
||||||
|
once(event: "resume", listener: () => void): this;
|
||||||
|
once(event: "SIGCONT", listener: () => void): this;
|
||||||
|
once(event: "SIGINT", listener: () => void): this;
|
||||||
|
once(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
once(event: "exit", listener: () => void): this;
|
||||||
|
once(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
prependListener(event: "pause", listener: () => void): this;
|
||||||
|
prependListener(event: "resume", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
prependListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
prependListener(event: "exit", listener: () => void): this;
|
||||||
|
prependListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "line", listener: (input: string) => void): this;
|
||||||
|
prependOnceListener(event: "pause", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "resume", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGCONT", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "exit", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A flag passed in the REPL options. Evaluates expressions in sloppy mode.
|
||||||
|
*/
|
||||||
|
const REPL_MODE_SLOPPY: unique symbol;
|
||||||
|
/**
|
||||||
|
* A flag passed in the REPL options. Evaluates expressions in strict mode.
|
||||||
|
* This is equivalent to prefacing every repl statement with `'use strict'`.
|
||||||
|
*/
|
||||||
|
const REPL_MODE_STRICT: unique symbol;
|
||||||
|
/**
|
||||||
|
* The `repl.start()` method creates and starts a {@link REPLServer} instance.
|
||||||
|
*
|
||||||
|
* If `options` is a string, then it specifies the input prompt:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import repl from 'node:repl';
|
||||||
|
*
|
||||||
|
* // a Unix style prompt
|
||||||
|
* repl.start('$ ');
|
||||||
|
* ```
|
||||||
|
* @since v0.1.91
|
||||||
|
*/
|
||||||
|
function start(options?: string | ReplOptions): REPLServer;
|
||||||
|
/**
|
||||||
|
* Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v22.x/docs/api/repl.html#repl_recoverable_errors
|
||||||
|
*/
|
||||||
|
class Recoverable extends SyntaxError {
|
||||||
|
err: Error;
|
||||||
|
constructor(err: Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:repl" {
|
||||||
|
export * from "repl";
|
||||||
|
}
|
153
websocket_server/node_modules/.ignored/@types/node/sea.d.ts
generated
vendored
Normal file
153
websocket_server/node_modules/.ignored/@types/node/sea.d.ts
generated
vendored
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* This feature allows the distribution of a Node.js application conveniently to a
|
||||||
|
* system that does not have Node.js installed.
|
||||||
|
*
|
||||||
|
* Node.js supports the creation of [single executable applications](https://github.com/nodejs/single-executable) by allowing
|
||||||
|
* the injection of a blob prepared by Node.js, which can contain a bundled script,
|
||||||
|
* into the `node` binary. During start up, the program checks if anything has been
|
||||||
|
* injected. If the blob is found, it executes the script in the blob. Otherwise
|
||||||
|
* Node.js operates as it normally does.
|
||||||
|
*
|
||||||
|
* The single executable application feature currently only supports running a
|
||||||
|
* single embedded script using the `CommonJS` module system.
|
||||||
|
*
|
||||||
|
* Users can create a single executable application from their bundled script
|
||||||
|
* with the `node` binary itself and any tool which can inject resources into the
|
||||||
|
* binary.
|
||||||
|
*
|
||||||
|
* Here are the steps for creating a single executable application using one such
|
||||||
|
* tool, [postject](https://github.com/nodejs/postject):
|
||||||
|
*
|
||||||
|
* 1. Create a JavaScript file:
|
||||||
|
* ```bash
|
||||||
|
* echo 'console.log(`Hello, ${process.argv[2]}!`);' > hello.js
|
||||||
|
* ```
|
||||||
|
* 2. Create a configuration file building a blob that can be injected into the
|
||||||
|
* single executable application (see `Generating single executable preparation blobs` for details):
|
||||||
|
* ```bash
|
||||||
|
* echo '{ "main": "hello.js", "output": "sea-prep.blob" }' > sea-config.json
|
||||||
|
* ```
|
||||||
|
* 3. Generate the blob to be injected:
|
||||||
|
* ```bash
|
||||||
|
* node --experimental-sea-config sea-config.json
|
||||||
|
* ```
|
||||||
|
* 4. Create a copy of the `node` executable and name it according to your needs:
|
||||||
|
* * On systems other than Windows:
|
||||||
|
* ```bash
|
||||||
|
* cp $(command -v node) hello
|
||||||
|
* ```
|
||||||
|
* * On Windows:
|
||||||
|
* ```text
|
||||||
|
* node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')"
|
||||||
|
* ```
|
||||||
|
* The `.exe` extension is necessary.
|
||||||
|
* 5. Remove the signature of the binary (macOS and Windows only):
|
||||||
|
* * On macOS:
|
||||||
|
* ```bash
|
||||||
|
* codesign --remove-signature hello
|
||||||
|
* ```
|
||||||
|
* * On Windows (optional):
|
||||||
|
* [signtool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool) can be used from the installed [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/).
|
||||||
|
* If this step is
|
||||||
|
* skipped, ignore any signature-related warning from postject.
|
||||||
|
* ```powershell
|
||||||
|
* signtool remove /s hello.exe
|
||||||
|
* ```
|
||||||
|
* 6. Inject the blob into the copied binary by running `postject` with
|
||||||
|
* the following options:
|
||||||
|
* * `hello` / `hello.exe` \- The name of the copy of the `node` executable
|
||||||
|
* created in step 4.
|
||||||
|
* * `NODE_SEA_BLOB` \- The name of the resource / note / section in the binary
|
||||||
|
* where the contents of the blob will be stored.
|
||||||
|
* * `sea-prep.blob` \- The name of the blob created in step 1.
|
||||||
|
* * `--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2` \- The [fuse](https://www.electronjs.org/docs/latest/tutorial/fuses) used by the Node.js project to detect if a file has been
|
||||||
|
* injected.
|
||||||
|
* * `--macho-segment-name NODE_SEA` (only needed on macOS) - The name of the
|
||||||
|
* segment in the binary where the contents of the blob will be
|
||||||
|
* stored.
|
||||||
|
* To summarize, here is the required command for each platform:
|
||||||
|
* * On Linux:
|
||||||
|
* ```bash
|
||||||
|
* npx postject hello NODE_SEA_BLOB sea-prep.blob \
|
||||||
|
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||||
|
* ```
|
||||||
|
* * On Windows - PowerShell:
|
||||||
|
* ```powershell
|
||||||
|
* npx postject hello.exe NODE_SEA_BLOB sea-prep.blob `
|
||||||
|
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||||
|
* ```
|
||||||
|
* * On Windows - Command Prompt:
|
||||||
|
* ```text
|
||||||
|
* npx postject hello.exe NODE_SEA_BLOB sea-prep.blob ^
|
||||||
|
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||||
|
* ```
|
||||||
|
* * On macOS:
|
||||||
|
* ```bash
|
||||||
|
* npx postject hello NODE_SEA_BLOB sea-prep.blob \
|
||||||
|
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
|
||||||
|
* --macho-segment-name NODE_SEA
|
||||||
|
* ```
|
||||||
|
* 7. Sign the binary (macOS and Windows only):
|
||||||
|
* * On macOS:
|
||||||
|
* ```bash
|
||||||
|
* codesign --sign - hello
|
||||||
|
* ```
|
||||||
|
* * On Windows (optional):
|
||||||
|
* A certificate needs to be present for this to work. However, the unsigned
|
||||||
|
* binary would still be runnable.
|
||||||
|
* ```powershell
|
||||||
|
* signtool sign /fd SHA256 hello.exe
|
||||||
|
* ```
|
||||||
|
* 8. Run the binary:
|
||||||
|
* * On systems other than Windows
|
||||||
|
* ```console
|
||||||
|
* $ ./hello world
|
||||||
|
* Hello, world!
|
||||||
|
* ```
|
||||||
|
* * On Windows
|
||||||
|
* ```console
|
||||||
|
* $ .\hello.exe world
|
||||||
|
* Hello, world!
|
||||||
|
* ```
|
||||||
|
* @since v19.7.0, v18.16.0
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/src/node_sea.cc)
|
||||||
|
*/
|
||||||
|
declare module "node:sea" {
|
||||||
|
type AssetKey = string;
|
||||||
|
/**
|
||||||
|
* @since v20.12.0
|
||||||
|
* @return Whether this script is running inside a single-executable application.
|
||||||
|
*/
|
||||||
|
function isSea(): boolean;
|
||||||
|
/**
|
||||||
|
* This method can be used to retrieve the assets configured to be bundled into the
|
||||||
|
* single-executable application at build time.
|
||||||
|
* An error is thrown when no matching asset can be found.
|
||||||
|
* @since v20.12.0
|
||||||
|
*/
|
||||||
|
function getAsset(key: AssetKey): ArrayBuffer;
|
||||||
|
function getAsset(key: AssetKey, encoding: string): string;
|
||||||
|
/**
|
||||||
|
* Similar to `sea.getAsset()`, but returns the result in a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
||||||
|
* An error is thrown when no matching asset can be found.
|
||||||
|
* @since v20.12.0
|
||||||
|
*/
|
||||||
|
function getAssetAsBlob(key: AssetKey, options?: {
|
||||||
|
type: string;
|
||||||
|
}): Blob;
|
||||||
|
/**
|
||||||
|
* This method can be used to retrieve the assets configured to be bundled into the
|
||||||
|
* single-executable application at build time.
|
||||||
|
* An error is thrown when no matching asset can be found.
|
||||||
|
*
|
||||||
|
* Unlike `sea.getRawAsset()` or `sea.getAssetAsBlob()`, this method does not
|
||||||
|
* return a copy. Instead, it returns the raw asset bundled inside the executable.
|
||||||
|
*
|
||||||
|
* For now, users should avoid writing to the returned array buffer. If the
|
||||||
|
* injected section is not marked as writable or not aligned properly,
|
||||||
|
* writes to the returned array buffer is likely to result in a crash.
|
||||||
|
* @since v20.12.0
|
||||||
|
*/
|
||||||
|
function getRawAsset(key: AssetKey): string | ArrayBuffer;
|
||||||
|
}
|
213
websocket_server/node_modules/.ignored/@types/node/sqlite.d.ts
generated
vendored
Normal file
213
websocket_server/node_modules/.ignored/@types/node/sqlite.d.ts
generated
vendored
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
/**
|
||||||
|
* The `node:sqlite` module facilitates working with SQLite databases.
|
||||||
|
* To access it:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import sqlite from 'node:sqlite';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This module is only available under the `node:` scheme. The following will not
|
||||||
|
* work:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import sqlite from 'node:sqlite';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The following example shows the basic usage of the `node:sqlite` module to open
|
||||||
|
* an in-memory database, write data to the database, and then read the data back.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { DatabaseSync } from 'node:sqlite';
|
||||||
|
* const database = new DatabaseSync(':memory:');
|
||||||
|
*
|
||||||
|
* // Execute SQL statements from strings.
|
||||||
|
* database.exec(`
|
||||||
|
* CREATE TABLE data(
|
||||||
|
* key INTEGER PRIMARY KEY,
|
||||||
|
* value TEXT
|
||||||
|
* ) STRICT
|
||||||
|
* `);
|
||||||
|
* // Create a prepared statement to insert data into the database.
|
||||||
|
* const insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
|
||||||
|
* // Execute the prepared statement with bound values.
|
||||||
|
* insert.run(1, 'hello');
|
||||||
|
* insert.run(2, 'world');
|
||||||
|
* // Create a prepared statement to read data from the database.
|
||||||
|
* const query = database.prepare('SELECT * FROM data ORDER BY key');
|
||||||
|
* // Execute the prepared statement and log the result set.
|
||||||
|
* console.log(query.all());
|
||||||
|
* // Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]
|
||||||
|
* ```
|
||||||
|
* @since v22.5.0
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/sqlite.js)
|
||||||
|
*/
|
||||||
|
declare module "node:sqlite" {
|
||||||
|
interface DatabaseSyncOptions {
|
||||||
|
/**
|
||||||
|
* If `true`, the database is opened by the constructor.
|
||||||
|
* When this value is `false`, the database must be opened via the `open()` method.
|
||||||
|
*/
|
||||||
|
open?: boolean | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This class represents a single [connection](https://www.sqlite.org/c3ref/sqlite3.html) to a SQLite database. All APIs
|
||||||
|
* exposed by this class execute synchronously.
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
class DatabaseSync {
|
||||||
|
/**
|
||||||
|
* Constructs a new `DatabaseSync` instance.
|
||||||
|
* @param location The location of the database.
|
||||||
|
* A SQLite database can be stored in a file or completely [in memory](https://www.sqlite.org/inmemorydb.html).
|
||||||
|
* To use a file-backed database, the location should be a file path.
|
||||||
|
* To use an in-memory database, the location should be the special name `':memory:'`.
|
||||||
|
* @param options Configuration options for the database connection.
|
||||||
|
*/
|
||||||
|
constructor(location: string, options?: DatabaseSyncOptions);
|
||||||
|
/**
|
||||||
|
* Closes the database connection. An exception is thrown if the database is not
|
||||||
|
* open. This method is a wrapper around [`sqlite3_close_v2()`](https://www.sqlite.org/c3ref/close.html).
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
close(): void;
|
||||||
|
/**
|
||||||
|
* This method allows one or more SQL statements to be executed without returning
|
||||||
|
* any results. This method is useful when executing SQL statements read from a
|
||||||
|
* file. This method is a wrapper around [`sqlite3_exec()`](https://www.sqlite.org/c3ref/exec.html).
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param sql A SQL string to execute.
|
||||||
|
*/
|
||||||
|
exec(sql: string): void;
|
||||||
|
/**
|
||||||
|
* Opens the database specified in the `location` argument of the `DatabaseSync`constructor. This method should only be used when the database is not opened via
|
||||||
|
* the constructor. An exception is thrown if the database is already open.
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
open(): void;
|
||||||
|
/**
|
||||||
|
* Compiles a SQL statement into a [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This method is a wrapper
|
||||||
|
* around [`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html).
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param sql A SQL string to compile to a prepared statement.
|
||||||
|
* @return The prepared statement.
|
||||||
|
*/
|
||||||
|
prepare(sql: string): StatementSync;
|
||||||
|
}
|
||||||
|
type SupportedValueType = null | number | bigint | string | Uint8Array;
|
||||||
|
interface StatementResultingChanges {
|
||||||
|
/**
|
||||||
|
* The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement.
|
||||||
|
* This field is either a number or a `BigInt` depending on the prepared statement's configuration.
|
||||||
|
* This property is the result of [`sqlite3_changes64()`](https://www.sqlite.org/c3ref/changes.html).
|
||||||
|
*/
|
||||||
|
changes: number | bigint;
|
||||||
|
/**
|
||||||
|
* The most recently inserted rowid.
|
||||||
|
* This field is either a number or a `BigInt` depending on the prepared statement's configuration.
|
||||||
|
* This property is the result of [`sqlite3_last_insert_rowid()`](https://www.sqlite.org/c3ref/last_insert_rowid.html).
|
||||||
|
*/
|
||||||
|
lastInsertRowid: number | bigint;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This class represents a single [prepared statement](https://www.sqlite.org/c3ref/stmt.html). This class cannot be
|
||||||
|
* instantiated via its constructor. Instead, instances are created via the`database.prepare()` method. All APIs exposed by this class execute
|
||||||
|
* synchronously.
|
||||||
|
*
|
||||||
|
* A prepared statement is an efficient binary representation of the SQL used to
|
||||||
|
* create it. Prepared statements are parameterizable, and can be invoked multiple
|
||||||
|
* times with different bound values. Parameters also offer protection against [SQL injection](https://en.wikipedia.org/wiki/SQL_injection) attacks. For these reasons, prepared statements are
|
||||||
|
* preferred
|
||||||
|
* over hand-crafted SQL strings when handling user input.
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
class StatementSync {
|
||||||
|
private constructor();
|
||||||
|
/**
|
||||||
|
* This method executes a prepared statement and returns all results as an array of
|
||||||
|
* objects. If the prepared statement does not return any results, this method
|
||||||
|
* returns an empty array. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using
|
||||||
|
* the values in `namedParameters` and `anonymousParameters`.
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
||||||
|
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
||||||
|
* @return An array of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of
|
||||||
|
* the row.
|
||||||
|
*/
|
||||||
|
all(...anonymousParameters: SupportedValueType[]): unknown[];
|
||||||
|
all(
|
||||||
|
namedParameters: Record<string, SupportedValueType>,
|
||||||
|
...anonymousParameters: SupportedValueType[]
|
||||||
|
): unknown[];
|
||||||
|
/**
|
||||||
|
* This method returns the source SQL of the prepared statement with parameter
|
||||||
|
* placeholders replaced by values. This method is a wrapper around [`sqlite3_expanded_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
|
||||||
|
* @since v22.5.0
|
||||||
|
* @return The source SQL expanded to include parameter values.
|
||||||
|
*/
|
||||||
|
expandedSQL(): string;
|
||||||
|
/**
|
||||||
|
* This method executes a prepared statement and returns the first result as an
|
||||||
|
* object. If the prepared statement does not return any results, this method
|
||||||
|
* returns `undefined`. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
|
||||||
|
* values in `namedParameters` and `anonymousParameters`.
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
||||||
|
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
||||||
|
* @return An object corresponding to the first row returned by executing the prepared statement. The keys and values of the object correspond to the column names and values of the row. If no
|
||||||
|
* rows were returned from the database then this method returns `undefined`.
|
||||||
|
*/
|
||||||
|
get(...anonymousParameters: SupportedValueType[]): unknown;
|
||||||
|
get(namedParameters: Record<string, SupportedValueType>, ...anonymousParameters: SupportedValueType[]): unknown;
|
||||||
|
/**
|
||||||
|
* This method executes a prepared statement and returns an object summarizing the
|
||||||
|
* resulting changes. The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_blob.html) using the
|
||||||
|
* values in `namedParameters` and `anonymousParameters`.
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param namedParameters An optional object used to bind named parameters. The keys of this object are used to configure the mapping.
|
||||||
|
* @param anonymousParameters Zero or more values to bind to anonymous parameters.
|
||||||
|
*/
|
||||||
|
run(...anonymousParameters: SupportedValueType[]): StatementResultingChanges;
|
||||||
|
run(
|
||||||
|
namedParameters: Record<string, SupportedValueType>,
|
||||||
|
...anonymousParameters: SupportedValueType[]
|
||||||
|
): StatementResultingChanges;
|
||||||
|
/**
|
||||||
|
* The names of SQLite parameters begin with a prefix character. By default,`node:sqlite` requires that this prefix character is present when binding
|
||||||
|
* parameters. However, with the exception of dollar sign character, these
|
||||||
|
* prefix characters also require extra quoting when used in object keys.
|
||||||
|
*
|
||||||
|
* To improve ergonomics, this method can be used to also allow bare named
|
||||||
|
* parameters, which do not require the prefix character in JavaScript code. There
|
||||||
|
* are several caveats to be aware of when enabling bare named parameters:
|
||||||
|
*
|
||||||
|
* * The prefix character is still required in SQL.
|
||||||
|
* * The prefix character is still allowed in JavaScript. In fact, prefixed names
|
||||||
|
* will have slightly better binding performance.
|
||||||
|
* * Using ambiguous named parameters, such as `$k` and `@k`, in the same prepared
|
||||||
|
* statement will result in an exception as it cannot be determined how to bind
|
||||||
|
* a bare name.
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param enabled Enables or disables support for binding named parameters without the prefix character.
|
||||||
|
*/
|
||||||
|
setAllowBareNamedParameters(enabled: boolean): void;
|
||||||
|
/**
|
||||||
|
* When reading from the database, SQLite `INTEGER`s are mapped to JavaScript
|
||||||
|
* numbers by default. However, SQLite `INTEGER`s can store values larger than
|
||||||
|
* JavaScript numbers are capable of representing. In such cases, this method can
|
||||||
|
* be used to read `INTEGER` data using JavaScript `BigInt`s. This method has no
|
||||||
|
* impact on database write operations where numbers and `BigInt`s are both
|
||||||
|
* supported at all times.
|
||||||
|
* @since v22.5.0
|
||||||
|
* @param enabled Enables or disables the use of `BigInt`s when reading `INTEGER` fields from the database.
|
||||||
|
*/
|
||||||
|
setReadBigInts(enabled: boolean): void;
|
||||||
|
/**
|
||||||
|
* This method returns the source SQL of the prepared statement. This method is a
|
||||||
|
* wrapper around [`sqlite3_sql()`](https://www.sqlite.org/c3ref/expanded_sql.html).
|
||||||
|
* @since v22.5.0
|
||||||
|
* @return The source SQL used to create this prepared statement.
|
||||||
|
*/
|
||||||
|
sourceSQL(): string;
|
||||||
|
}
|
||||||
|
}
|
1726
websocket_server/node_modules/.ignored/@types/node/stream.d.ts
generated
vendored
Normal file
1726
websocket_server/node_modules/.ignored/@types/node/stream.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12
websocket_server/node_modules/.ignored/@types/node/stream/consumers.d.ts
generated
vendored
Normal file
12
websocket_server/node_modules/.ignored/@types/node/stream/consumers.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
declare module "stream/consumers" {
|
||||||
|
import { Blob as NodeBlob } from "node:buffer";
|
||||||
|
import { Readable } from "node:stream";
|
||||||
|
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<Buffer>;
|
||||||
|
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<string>;
|
||||||
|
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<ArrayBuffer>;
|
||||||
|
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<NodeBlob>;
|
||||||
|
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<unknown>;
|
||||||
|
}
|
||||||
|
declare module "node:stream/consumers" {
|
||||||
|
export * from "stream/consumers";
|
||||||
|
}
|
90
websocket_server/node_modules/.ignored/@types/node/stream/promises.d.ts
generated
vendored
Normal file
90
websocket_server/node_modules/.ignored/@types/node/stream/promises.d.ts
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
declare module "stream/promises" {
|
||||||
|
import {
|
||||||
|
FinishedOptions as _FinishedOptions,
|
||||||
|
PipelineDestination,
|
||||||
|
PipelineOptions,
|
||||||
|
PipelinePromise,
|
||||||
|
PipelineSource,
|
||||||
|
PipelineTransform,
|
||||||
|
} from "node:stream";
|
||||||
|
interface FinishedOptions extends _FinishedOptions {
|
||||||
|
/**
|
||||||
|
* If true, removes the listeners registered by this function before the promise is fulfilled.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
cleanup?: boolean | undefined;
|
||||||
|
}
|
||||||
|
function finished(
|
||||||
|
stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
|
||||||
|
options?: FinishedOptions,
|
||||||
|
): Promise<void>;
|
||||||
|
function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
|
||||||
|
source: A,
|
||||||
|
destination: B,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): PipelinePromise<B>;
|
||||||
|
function pipeline<
|
||||||
|
A extends PipelineSource<any>,
|
||||||
|
T1 extends PipelineTransform<A, any>,
|
||||||
|
B extends PipelineDestination<T1, any>,
|
||||||
|
>(
|
||||||
|
source: A,
|
||||||
|
transform1: T1,
|
||||||
|
destination: B,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): PipelinePromise<B>;
|
||||||
|
function pipeline<
|
||||||
|
A extends PipelineSource<any>,
|
||||||
|
T1 extends PipelineTransform<A, any>,
|
||||||
|
T2 extends PipelineTransform<T1, any>,
|
||||||
|
B extends PipelineDestination<T2, any>,
|
||||||
|
>(
|
||||||
|
source: A,
|
||||||
|
transform1: T1,
|
||||||
|
transform2: T2,
|
||||||
|
destination: B,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): PipelinePromise<B>;
|
||||||
|
function pipeline<
|
||||||
|
A extends PipelineSource<any>,
|
||||||
|
T1 extends PipelineTransform<A, any>,
|
||||||
|
T2 extends PipelineTransform<T1, any>,
|
||||||
|
T3 extends PipelineTransform<T2, any>,
|
||||||
|
B extends PipelineDestination<T3, any>,
|
||||||
|
>(
|
||||||
|
source: A,
|
||||||
|
transform1: T1,
|
||||||
|
transform2: T2,
|
||||||
|
transform3: T3,
|
||||||
|
destination: B,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): PipelinePromise<B>;
|
||||||
|
function pipeline<
|
||||||
|
A extends PipelineSource<any>,
|
||||||
|
T1 extends PipelineTransform<A, any>,
|
||||||
|
T2 extends PipelineTransform<T1, any>,
|
||||||
|
T3 extends PipelineTransform<T2, any>,
|
||||||
|
T4 extends PipelineTransform<T3, any>,
|
||||||
|
B extends PipelineDestination<T4, any>,
|
||||||
|
>(
|
||||||
|
source: A,
|
||||||
|
transform1: T1,
|
||||||
|
transform2: T2,
|
||||||
|
transform3: T3,
|
||||||
|
transform4: T4,
|
||||||
|
destination: B,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): PipelinePromise<B>;
|
||||||
|
function pipeline(
|
||||||
|
streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
|
||||||
|
options?: PipelineOptions,
|
||||||
|
): Promise<void>;
|
||||||
|
function pipeline(
|
||||||
|
stream1: NodeJS.ReadableStream,
|
||||||
|
stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
|
||||||
|
...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
|
||||||
|
): Promise<void>;
|
||||||
|
}
|
||||||
|
declare module "node:stream/promises" {
|
||||||
|
export * from "stream/promises";
|
||||||
|
}
|
609
websocket_server/node_modules/.ignored/@types/node/stream/web.d.ts
generated
vendored
Normal file
609
websocket_server/node_modules/.ignored/@types/node/stream/web.d.ts
generated
vendored
Normal file
@ -0,0 +1,609 @@
|
|||||||
|
type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ByteLengthQueuingStrategy;
|
||||||
|
type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
|
||||||
|
: import("stream/web").CompressionStream;
|
||||||
|
type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").CountQueuingStrategy;
|
||||||
|
type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
|
||||||
|
: import("stream/web").DecompressionStream;
|
||||||
|
type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableByteStreamController;
|
||||||
|
type _ReadableStream<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableStream<R>;
|
||||||
|
type _ReadableStreamBYOBReader = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableStreamBYOBReader;
|
||||||
|
type _ReadableStreamBYOBRequest = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableStreamBYOBRequest;
|
||||||
|
type _ReadableStreamDefaultController<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableStreamDefaultController<R>;
|
||||||
|
type _ReadableStreamDefaultReader<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").ReadableStreamDefaultReader<R>;
|
||||||
|
type _TextDecoderStream = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").TextDecoderStream;
|
||||||
|
type _TextEncoderStream = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").TextEncoderStream;
|
||||||
|
type _TransformStream<I = any, O = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").TransformStream<I, O>;
|
||||||
|
type _TransformStreamDefaultController<O = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").TransformStreamDefaultController<O>;
|
||||||
|
type _WritableStream<W = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").WritableStream<W>;
|
||||||
|
type _WritableStreamDefaultController = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").WritableStreamDefaultController;
|
||||||
|
type _WritableStreamDefaultWriter<W = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||||
|
: import("stream/web").WritableStreamDefaultWriter<W>;
|
||||||
|
|
||||||
|
declare module "stream/web" {
|
||||||
|
// stub module, pending copy&paste from .d.ts or manual impl
|
||||||
|
// copy from lib.dom.d.ts
|
||||||
|
interface ReadableWritablePair<R = any, W = any> {
|
||||||
|
readable: ReadableStream<R>;
|
||||||
|
/**
|
||||||
|
* Provides a convenient, chainable way of piping this readable stream
|
||||||
|
* through a transform stream (or any other { writable, readable }
|
||||||
|
* pair). It simply pipes the stream into the writable side of the
|
||||||
|
* supplied pair, and returns the readable side for further use.
|
||||||
|
*
|
||||||
|
* Piping a stream will lock it for the duration of the pipe, preventing
|
||||||
|
* any other consumer from acquiring a reader.
|
||||||
|
*/
|
||||||
|
writable: WritableStream<W>;
|
||||||
|
}
|
||||||
|
interface StreamPipeOptions {
|
||||||
|
preventAbort?: boolean;
|
||||||
|
preventCancel?: boolean;
|
||||||
|
/**
|
||||||
|
* Pipes this readable stream to a given writable stream destination.
|
||||||
|
* The way in which the piping process behaves under various error
|
||||||
|
* conditions can be customized with a number of passed options. It
|
||||||
|
* returns a promise that fulfills when the piping process completes
|
||||||
|
* successfully, or rejects if any errors were encountered.
|
||||||
|
*
|
||||||
|
* Piping a stream will lock it for the duration of the pipe, preventing
|
||||||
|
* any other consumer from acquiring a reader.
|
||||||
|
*
|
||||||
|
* Errors and closures of the source and destination streams propagate
|
||||||
|
* as follows:
|
||||||
|
*
|
||||||
|
* An error in this source readable stream will abort destination,
|
||||||
|
* unless preventAbort is truthy. The returned promise will be rejected
|
||||||
|
* with the source's error, or with any error that occurs during
|
||||||
|
* aborting the destination.
|
||||||
|
*
|
||||||
|
* An error in destination will cancel this source readable stream,
|
||||||
|
* unless preventCancel is truthy. The returned promise will be rejected
|
||||||
|
* with the destination's error, or with any error that occurs during
|
||||||
|
* canceling the source.
|
||||||
|
*
|
||||||
|
* When this source readable stream closes, destination will be closed,
|
||||||
|
* unless preventClose is truthy. The returned promise will be fulfilled
|
||||||
|
* once this process completes, unless an error is encountered while
|
||||||
|
* closing the destination, in which case it will be rejected with that
|
||||||
|
* error.
|
||||||
|
*
|
||||||
|
* If destination starts out closed or closing, this source readable
|
||||||
|
* stream will be canceled, unless preventCancel is true. The returned
|
||||||
|
* promise will be rejected with an error indicating piping to a closed
|
||||||
|
* stream failed, or with any error that occurs during canceling the
|
||||||
|
* source.
|
||||||
|
*
|
||||||
|
* The signal option can be set to an AbortSignal to allow aborting an
|
||||||
|
* ongoing pipe operation via the corresponding AbortController. In this
|
||||||
|
* case, this source readable stream will be canceled, and destination
|
||||||
|
* aborted, unless the respective options preventCancel or preventAbort
|
||||||
|
* are set.
|
||||||
|
*/
|
||||||
|
preventClose?: boolean;
|
||||||
|
signal?: AbortSignal;
|
||||||
|
}
|
||||||
|
interface ReadableStreamGenericReader {
|
||||||
|
readonly closed: Promise<undefined>;
|
||||||
|
cancel(reason?: any): Promise<void>;
|
||||||
|
}
|
||||||
|
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||||
|
interface ReadableStreamReadValueResult<T> {
|
||||||
|
done: false;
|
||||||
|
value: T;
|
||||||
|
}
|
||||||
|
interface ReadableStreamReadDoneResult<T> {
|
||||||
|
done: true;
|
||||||
|
value?: T;
|
||||||
|
}
|
||||||
|
type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
|
||||||
|
interface ReadableByteStreamControllerCallback {
|
||||||
|
(controller: ReadableByteStreamController): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSinkAbortCallback {
|
||||||
|
(reason?: any): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSinkCloseCallback {
|
||||||
|
(): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSinkStartCallback {
|
||||||
|
(controller: WritableStreamDefaultController): any;
|
||||||
|
}
|
||||||
|
interface UnderlyingSinkWriteCallback<W> {
|
||||||
|
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSourceCancelCallback {
|
||||||
|
(reason?: any): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSourcePullCallback<R> {
|
||||||
|
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingSourceStartCallback<R> {
|
||||||
|
(controller: ReadableStreamController<R>): any;
|
||||||
|
}
|
||||||
|
interface TransformerFlushCallback<O> {
|
||||||
|
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface TransformerStartCallback<O> {
|
||||||
|
(controller: TransformStreamDefaultController<O>): any;
|
||||||
|
}
|
||||||
|
interface TransformerTransformCallback<I, O> {
|
||||||
|
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface UnderlyingByteSource {
|
||||||
|
autoAllocateChunkSize?: number;
|
||||||
|
cancel?: ReadableStreamErrorCallback;
|
||||||
|
pull?: ReadableByteStreamControllerCallback;
|
||||||
|
start?: ReadableByteStreamControllerCallback;
|
||||||
|
type: "bytes";
|
||||||
|
}
|
||||||
|
interface UnderlyingSource<R = any> {
|
||||||
|
cancel?: UnderlyingSourceCancelCallback;
|
||||||
|
pull?: UnderlyingSourcePullCallback<R>;
|
||||||
|
start?: UnderlyingSourceStartCallback<R>;
|
||||||
|
type?: undefined;
|
||||||
|
}
|
||||||
|
interface UnderlyingSink<W = any> {
|
||||||
|
abort?: UnderlyingSinkAbortCallback;
|
||||||
|
close?: UnderlyingSinkCloseCallback;
|
||||||
|
start?: UnderlyingSinkStartCallback;
|
||||||
|
type?: undefined;
|
||||||
|
write?: UnderlyingSinkWriteCallback<W>;
|
||||||
|
}
|
||||||
|
interface ReadableStreamErrorCallback {
|
||||||
|
(reason: any): void | PromiseLike<void>;
|
||||||
|
}
|
||||||
|
interface ReadableStreamAsyncIterator<T> extends NodeJS.AsyncIterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
|
||||||
|
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||||
|
}
|
||||||
|
/** This Streams API interface represents a readable stream of byte data. */
|
||||||
|
interface ReadableStream<R = any> {
|
||||||
|
readonly locked: boolean;
|
||||||
|
cancel(reason?: any): Promise<void>;
|
||||||
|
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
|
||||||
|
getReader(): ReadableStreamDefaultReader<R>;
|
||||||
|
getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
|
||||||
|
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
|
||||||
|
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
||||||
|
tee(): [ReadableStream<R>, ReadableStream<R>];
|
||||||
|
values(options?: { preventCancel?: boolean }): ReadableStreamAsyncIterator<R>;
|
||||||
|
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<R>;
|
||||||
|
}
|
||||||
|
const ReadableStream: {
|
||||||
|
prototype: ReadableStream;
|
||||||
|
from<T>(iterable: Iterable<T> | AsyncIterable<T>): ReadableStream<T>;
|
||||||
|
new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
||||||
|
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
||||||
|
};
|
||||||
|
type ReadableStreamReaderMode = "byob";
|
||||||
|
interface ReadableStreamGetReaderOptions {
|
||||||
|
/**
|
||||||
|
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
|
||||||
|
*
|
||||||
|
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
|
||||||
|
*/
|
||||||
|
mode?: ReadableStreamReaderMode;
|
||||||
|
}
|
||||||
|
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
|
||||||
|
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
||||||
|
read(): Promise<ReadableStreamReadResult<R>>;
|
||||||
|
releaseLock(): void;
|
||||||
|
}
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
|
||||||
|
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
|
||||||
|
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
|
||||||
|
releaseLock(): void;
|
||||||
|
}
|
||||||
|
const ReadableStreamDefaultReader: {
|
||||||
|
prototype: ReadableStreamDefaultReader;
|
||||||
|
new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||||
|
};
|
||||||
|
const ReadableStreamBYOBReader: {
|
||||||
|
prototype: ReadableStreamBYOBReader;
|
||||||
|
new(stream: ReadableStream): ReadableStreamBYOBReader;
|
||||||
|
};
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
|
||||||
|
interface ReadableStreamBYOBRequest {
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
|
||||||
|
readonly view: ArrayBufferView | null;
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
|
||||||
|
respond(bytesWritten: number): void;
|
||||||
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
|
||||||
|
respondWithNewView(view: ArrayBufferView): void;
|
||||||
|
}
|
||||||
|
const ReadableStreamBYOBRequest: {
|
||||||
|
prototype: ReadableStreamBYOBRequest;
|
||||||
|
new(): ReadableStreamBYOBRequest;
|
||||||
|
};
|
||||||
|
interface ReadableByteStreamController {
|
||||||
|
readonly byobRequest: undefined;
|
||||||
|
readonly desiredSize: number | null;
|
||||||
|
close(): void;
|
||||||
|
enqueue(chunk: ArrayBufferView): void;
|
||||||
|
error(error?: any): void;
|
||||||
|
}
|
||||||
|
const ReadableByteStreamController: {
|
||||||
|
prototype: ReadableByteStreamController;
|
||||||
|
new(): ReadableByteStreamController;
|
||||||
|
};
|
||||||
|
interface ReadableStreamDefaultController<R = any> {
|
||||||
|
readonly desiredSize: number | null;
|
||||||
|
close(): void;
|
||||||
|
enqueue(chunk?: R): void;
|
||||||
|
error(e?: any): void;
|
||||||
|
}
|
||||||
|
const ReadableStreamDefaultController: {
|
||||||
|
prototype: ReadableStreamDefaultController;
|
||||||
|
new(): ReadableStreamDefaultController;
|
||||||
|
};
|
||||||
|
interface Transformer<I = any, O = any> {
|
||||||
|
flush?: TransformerFlushCallback<O>;
|
||||||
|
readableType?: undefined;
|
||||||
|
start?: TransformerStartCallback<O>;
|
||||||
|
transform?: TransformerTransformCallback<I, O>;
|
||||||
|
writableType?: undefined;
|
||||||
|
}
|
||||||
|
interface TransformStream<I = any, O = any> {
|
||||||
|
readonly readable: ReadableStream<O>;
|
||||||
|
readonly writable: WritableStream<I>;
|
||||||
|
}
|
||||||
|
const TransformStream: {
|
||||||
|
prototype: TransformStream;
|
||||||
|
new<I = any, O = any>(
|
||||||
|
transformer?: Transformer<I, O>,
|
||||||
|
writableStrategy?: QueuingStrategy<I>,
|
||||||
|
readableStrategy?: QueuingStrategy<O>,
|
||||||
|
): TransformStream<I, O>;
|
||||||
|
};
|
||||||
|
interface TransformStreamDefaultController<O = any> {
|
||||||
|
readonly desiredSize: number | null;
|
||||||
|
enqueue(chunk?: O): void;
|
||||||
|
error(reason?: any): void;
|
||||||
|
terminate(): void;
|
||||||
|
}
|
||||||
|
const TransformStreamDefaultController: {
|
||||||
|
prototype: TransformStreamDefaultController;
|
||||||
|
new(): TransformStreamDefaultController;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This Streams API interface provides a standard abstraction for writing
|
||||||
|
* streaming data to a destination, known as a sink. This object comes with
|
||||||
|
* built-in back pressure and queuing.
|
||||||
|
*/
|
||||||
|
interface WritableStream<W = any> {
|
||||||
|
readonly locked: boolean;
|
||||||
|
abort(reason?: any): Promise<void>;
|
||||||
|
close(): Promise<void>;
|
||||||
|
getWriter(): WritableStreamDefaultWriter<W>;
|
||||||
|
}
|
||||||
|
const WritableStream: {
|
||||||
|
prototype: WritableStream;
|
||||||
|
new<W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This Streams API interface is the object returned by
|
||||||
|
* WritableStream.getWriter() and once created locks the < writer to the
|
||||||
|
* WritableStream ensuring that no other streams can write to the underlying
|
||||||
|
* sink.
|
||||||
|
*/
|
||||||
|
interface WritableStreamDefaultWriter<W = any> {
|
||||||
|
readonly closed: Promise<undefined>;
|
||||||
|
readonly desiredSize: number | null;
|
||||||
|
readonly ready: Promise<undefined>;
|
||||||
|
abort(reason?: any): Promise<void>;
|
||||||
|
close(): Promise<void>;
|
||||||
|
releaseLock(): void;
|
||||||
|
write(chunk?: W): Promise<void>;
|
||||||
|
}
|
||||||
|
const WritableStreamDefaultWriter: {
|
||||||
|
prototype: WritableStreamDefaultWriter;
|
||||||
|
new<W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This Streams API interface represents a controller allowing control of a
|
||||||
|
* WritableStream's state. When constructing a WritableStream, the
|
||||||
|
* underlying sink is given a corresponding WritableStreamDefaultController
|
||||||
|
* instance to manipulate.
|
||||||
|
*/
|
||||||
|
interface WritableStreamDefaultController {
|
||||||
|
error(e?: any): void;
|
||||||
|
}
|
||||||
|
const WritableStreamDefaultController: {
|
||||||
|
prototype: WritableStreamDefaultController;
|
||||||
|
new(): WritableStreamDefaultController;
|
||||||
|
};
|
||||||
|
interface QueuingStrategy<T = any> {
|
||||||
|
highWaterMark?: number;
|
||||||
|
size?: QueuingStrategySize<T>;
|
||||||
|
}
|
||||||
|
interface QueuingStrategySize<T = any> {
|
||||||
|
(chunk?: T): number;
|
||||||
|
}
|
||||||
|
interface QueuingStrategyInit {
|
||||||
|
/**
|
||||||
|
* Creates a new ByteLengthQueuingStrategy with the provided high water
|
||||||
|
* mark.
|
||||||
|
*
|
||||||
|
* Note that the provided high water mark will not be validated ahead of
|
||||||
|
* time. Instead, if it is negative, NaN, or not a number, the resulting
|
||||||
|
* ByteLengthQueuingStrategy will cause the corresponding stream
|
||||||
|
* constructor to throw.
|
||||||
|
*/
|
||||||
|
highWaterMark: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This Streams API interface provides a built-in byte length queuing
|
||||||
|
* strategy that can be used when constructing streams.
|
||||||
|
*/
|
||||||
|
interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> {
|
||||||
|
readonly highWaterMark: number;
|
||||||
|
readonly size: QueuingStrategySize<ArrayBufferView>;
|
||||||
|
}
|
||||||
|
const ByteLengthQueuingStrategy: {
|
||||||
|
prototype: ByteLengthQueuingStrategy;
|
||||||
|
new(init: QueuingStrategyInit): ByteLengthQueuingStrategy;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This Streams API interface provides a built-in byte length queuing
|
||||||
|
* strategy that can be used when constructing streams.
|
||||||
|
*/
|
||||||
|
interface CountQueuingStrategy extends QueuingStrategy {
|
||||||
|
readonly highWaterMark: number;
|
||||||
|
readonly size: QueuingStrategySize;
|
||||||
|
}
|
||||||
|
const CountQueuingStrategy: {
|
||||||
|
prototype: CountQueuingStrategy;
|
||||||
|
new(init: QueuingStrategyInit): CountQueuingStrategy;
|
||||||
|
};
|
||||||
|
interface TextEncoderStream {
|
||||||
|
/** Returns "utf-8". */
|
||||||
|
readonly encoding: "utf-8";
|
||||||
|
readonly readable: ReadableStream<Uint8Array>;
|
||||||
|
readonly writable: WritableStream<string>;
|
||||||
|
readonly [Symbol.toStringTag]: string;
|
||||||
|
}
|
||||||
|
const TextEncoderStream: {
|
||||||
|
prototype: TextEncoderStream;
|
||||||
|
new(): TextEncoderStream;
|
||||||
|
};
|
||||||
|
interface TextDecoderOptions {
|
||||||
|
fatal?: boolean;
|
||||||
|
ignoreBOM?: boolean;
|
||||||
|
}
|
||||||
|
type BufferSource = ArrayBufferView | ArrayBuffer;
|
||||||
|
interface TextDecoderStream {
|
||||||
|
/** Returns encoding's name, lower cased. */
|
||||||
|
readonly encoding: string;
|
||||||
|
/** Returns `true` if error mode is "fatal", and `false` otherwise. */
|
||||||
|
readonly fatal: boolean;
|
||||||
|
/** Returns `true` if ignore BOM flag is set, and `false` otherwise. */
|
||||||
|
readonly ignoreBOM: boolean;
|
||||||
|
readonly readable: ReadableStream<string>;
|
||||||
|
readonly writable: WritableStream<BufferSource>;
|
||||||
|
readonly [Symbol.toStringTag]: string;
|
||||||
|
}
|
||||||
|
const TextDecoderStream: {
|
||||||
|
prototype: TextDecoderStream;
|
||||||
|
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
|
||||||
|
};
|
||||||
|
interface CompressionStream {
|
||||||
|
readonly readable: ReadableStream;
|
||||||
|
readonly writable: WritableStream;
|
||||||
|
}
|
||||||
|
const CompressionStream: {
|
||||||
|
prototype: CompressionStream;
|
||||||
|
new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream;
|
||||||
|
};
|
||||||
|
interface DecompressionStream {
|
||||||
|
readonly writable: WritableStream;
|
||||||
|
readonly readable: ReadableStream;
|
||||||
|
}
|
||||||
|
const DecompressionStream: {
|
||||||
|
prototype: DecompressionStream;
|
||||||
|
new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream;
|
||||||
|
};
|
||||||
|
|
||||||
|
global {
|
||||||
|
interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {}
|
||||||
|
/**
|
||||||
|
* `ByteLengthQueuingStrategy` class is a global reference for `import { ByteLengthQueuingStrategy } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-bytelengthqueuingstrategy
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ByteLengthQueuingStrategy: typeof globalThis extends { onmessage: any; ByteLengthQueuingStrategy: infer T }
|
||||||
|
? T
|
||||||
|
: typeof import("stream/web").ByteLengthQueuingStrategy;
|
||||||
|
|
||||||
|
interface CompressionStream extends _CompressionStream {}
|
||||||
|
/**
|
||||||
|
* `CompressionStream` class is a global reference for `import { CompressionStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-compressionstream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var CompressionStream: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
|
||||||
|
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
|
||||||
|
ReportingObserver: any;
|
||||||
|
CompressionStream: infer T;
|
||||||
|
} ? T
|
||||||
|
// TS 4.8, 4.9, 5.0
|
||||||
|
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
|
||||||
|
prototype: T;
|
||||||
|
new(format: "deflate" | "deflate-raw" | "gzip"): T;
|
||||||
|
}
|
||||||
|
: typeof import("stream/web").CompressionStream;
|
||||||
|
|
||||||
|
interface CountQueuingStrategy extends _CountQueuingStrategy {}
|
||||||
|
/**
|
||||||
|
* `CountQueuingStrategy` class is a global reference for `import { CountQueuingStrategy } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-countqueuingstrategy
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T
|
||||||
|
: typeof import("stream/web").CountQueuingStrategy;
|
||||||
|
|
||||||
|
interface DecompressionStream extends _DecompressionStream {}
|
||||||
|
/**
|
||||||
|
* `DecompressionStream` class is a global reference for `import { DecompressionStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-decompressionstream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var DecompressionStream: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
|
||||||
|
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
|
||||||
|
ReportingObserver: any;
|
||||||
|
DecompressionStream: infer T extends object;
|
||||||
|
} ? T
|
||||||
|
// TS 4.8, 4.9, 5.0
|
||||||
|
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
|
||||||
|
prototype: T;
|
||||||
|
new(format: "deflate" | "deflate-raw" | "gzip"): T;
|
||||||
|
}
|
||||||
|
: typeof import("stream/web").DecompressionStream;
|
||||||
|
|
||||||
|
interface ReadableByteStreamController extends _ReadableByteStreamController {}
|
||||||
|
/**
|
||||||
|
* `ReadableByteStreamController` class is a global reference for `import { ReadableByteStreamController } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablebytestreamcontroller
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableByteStreamController: typeof globalThis extends
|
||||||
|
{ onmessage: any; ReadableByteStreamController: infer T } ? T
|
||||||
|
: typeof import("stream/web").ReadableByteStreamController;
|
||||||
|
|
||||||
|
interface ReadableStream<R = any> extends _ReadableStream<R> {}
|
||||||
|
/**
|
||||||
|
* `ReadableStream` class is a global reference for `import { ReadableStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablestream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableStream: typeof globalThis extends { onmessage: any; ReadableStream: infer T } ? T
|
||||||
|
: typeof import("stream/web").ReadableStream;
|
||||||
|
|
||||||
|
interface ReadableStreamBYOBReader extends _ReadableStreamBYOBReader {}
|
||||||
|
/**
|
||||||
|
* `ReadableStreamBYOBReader` class is a global reference for `import { ReadableStreamBYOBReader } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablestreambyobreader
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableStreamBYOBReader: typeof globalThis extends { onmessage: any; ReadableStreamBYOBReader: infer T }
|
||||||
|
? T
|
||||||
|
: typeof import("stream/web").ReadableStreamBYOBReader;
|
||||||
|
|
||||||
|
interface ReadableStreamBYOBRequest extends _ReadableStreamBYOBRequest {}
|
||||||
|
/**
|
||||||
|
* `ReadableStreamBYOBRequest` class is a global reference for `import { ReadableStreamBYOBRequest } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablestreambyobrequest
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableStreamBYOBRequest: typeof globalThis extends { onmessage: any; ReadableStreamBYOBRequest: infer T }
|
||||||
|
? T
|
||||||
|
: typeof import("stream/web").ReadableStreamBYOBRequest;
|
||||||
|
|
||||||
|
interface ReadableStreamDefaultController<R = any> extends _ReadableStreamDefaultController<R> {}
|
||||||
|
/**
|
||||||
|
* `ReadableStreamDefaultController` class is a global reference for `import { ReadableStreamDefaultController } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablestreamdefaultcontroller
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableStreamDefaultController: typeof globalThis extends
|
||||||
|
{ onmessage: any; ReadableStreamDefaultController: infer T } ? T
|
||||||
|
: typeof import("stream/web").ReadableStreamDefaultController;
|
||||||
|
|
||||||
|
interface ReadableStreamDefaultReader<R = any> extends _ReadableStreamDefaultReader<R> {}
|
||||||
|
/**
|
||||||
|
* `ReadableStreamDefaultReader` class is a global reference for `import { ReadableStreamDefaultReader } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-readablestreamdefaultreader
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var ReadableStreamDefaultReader: typeof globalThis extends
|
||||||
|
{ onmessage: any; ReadableStreamDefaultReader: infer T } ? T
|
||||||
|
: typeof import("stream/web").ReadableStreamDefaultReader;
|
||||||
|
|
||||||
|
interface TextDecoderStream extends _TextDecoderStream {}
|
||||||
|
/**
|
||||||
|
* `TextDecoderStream` class is a global reference for `import { TextDecoderStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-textdecoderstream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var TextDecoderStream: typeof globalThis extends { onmessage: any; TextDecoderStream: infer T } ? T
|
||||||
|
: typeof import("stream/web").TextDecoderStream;
|
||||||
|
|
||||||
|
interface TextEncoderStream extends _TextEncoderStream {}
|
||||||
|
/**
|
||||||
|
* `TextEncoderStream` class is a global reference for `import { TextEncoderStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-textencoderstream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var TextEncoderStream: typeof globalThis extends { onmessage: any; TextEncoderStream: infer T } ? T
|
||||||
|
: typeof import("stream/web").TextEncoderStream;
|
||||||
|
|
||||||
|
interface TransformStream<I = any, O = any> extends _TransformStream<I, O> {}
|
||||||
|
/**
|
||||||
|
* `TransformStream` class is a global reference for `import { TransformStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-transformstream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var TransformStream: typeof globalThis extends { onmessage: any; TransformStream: infer T } ? T
|
||||||
|
: typeof import("stream/web").TransformStream;
|
||||||
|
|
||||||
|
interface TransformStreamDefaultController<O = any> extends _TransformStreamDefaultController<O> {}
|
||||||
|
/**
|
||||||
|
* `TransformStreamDefaultController` class is a global reference for `import { TransformStreamDefaultController } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-transformstreamdefaultcontroller
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var TransformStreamDefaultController: typeof globalThis extends
|
||||||
|
{ onmessage: any; TransformStreamDefaultController: infer T } ? T
|
||||||
|
: typeof import("stream/web").TransformStreamDefaultController;
|
||||||
|
|
||||||
|
interface WritableStream<W = any> extends _WritableStream<W> {}
|
||||||
|
/**
|
||||||
|
* `WritableStream` class is a global reference for `import { WritableStream } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-writablestream
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var WritableStream: typeof globalThis extends { onmessage: any; WritableStream: infer T } ? T
|
||||||
|
: typeof import("stream/web").WritableStream;
|
||||||
|
|
||||||
|
interface WritableStreamDefaultController extends _WritableStreamDefaultController {}
|
||||||
|
/**
|
||||||
|
* `WritableStreamDefaultController` class is a global reference for `import { WritableStreamDefaultController } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-writablestreamdefaultcontroller
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var WritableStreamDefaultController: typeof globalThis extends
|
||||||
|
{ onmessage: any; WritableStreamDefaultController: infer T } ? T
|
||||||
|
: typeof import("stream/web").WritableStreamDefaultController;
|
||||||
|
|
||||||
|
interface WritableStreamDefaultWriter<W = any> extends _WritableStreamDefaultWriter<W> {}
|
||||||
|
/**
|
||||||
|
* `WritableStreamDefaultWriter` class is a global reference for `import { WritableStreamDefaultWriter } from 'node:stream/web'`.
|
||||||
|
* https://nodejs.org/api/globals.html#class-writablestreamdefaultwriter
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var WritableStreamDefaultWriter: typeof globalThis extends
|
||||||
|
{ onmessage: any; WritableStreamDefaultWriter: infer T } ? T
|
||||||
|
: typeof import("stream/web").WritableStreamDefaultWriter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:stream/web" {
|
||||||
|
export * from "stream/web";
|
||||||
|
}
|
67
websocket_server/node_modules/.ignored/@types/node/string_decoder.d.ts
generated
vendored
Normal file
67
websocket_server/node_modules/.ignored/@types/node/string_decoder.d.ts
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* The `node:string_decoder` module provides an API for decoding `Buffer` objects
|
||||||
|
* into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
||||||
|
* characters. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { StringDecoder } from 'node:string_decoder';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The following example shows the basic use of the `StringDecoder` class.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { StringDecoder } from 'node:string_decoder';
|
||||||
|
* const decoder = new StringDecoder('utf8');
|
||||||
|
*
|
||||||
|
* const cent = Buffer.from([0xC2, 0xA2]);
|
||||||
|
* console.log(decoder.write(cent)); // Prints: ¢
|
||||||
|
*
|
||||||
|
* const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
||||||
|
* console.log(decoder.write(euro)); // Prints: €
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* When a `Buffer` instance is written to the `StringDecoder` instance, an
|
||||||
|
* internal buffer is used to ensure that the decoded string does not contain
|
||||||
|
* any incomplete multibyte characters. These are held in the buffer until the
|
||||||
|
* next call to `stringDecoder.write()` or until `stringDecoder.end()` is called.
|
||||||
|
*
|
||||||
|
* In the following example, the three UTF-8 encoded bytes of the European Euro
|
||||||
|
* symbol (`€`) are written over three separate operations:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { StringDecoder } from 'node:string_decoder';
|
||||||
|
* const decoder = new StringDecoder('utf8');
|
||||||
|
*
|
||||||
|
* decoder.write(Buffer.from([0xE2]));
|
||||||
|
* decoder.write(Buffer.from([0x82]));
|
||||||
|
* console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/string_decoder.js)
|
||||||
|
*/
|
||||||
|
declare module "string_decoder" {
|
||||||
|
class StringDecoder {
|
||||||
|
constructor(encoding?: BufferEncoding);
|
||||||
|
/**
|
||||||
|
* Returns a decoded string, ensuring that any incomplete multibyte characters at
|
||||||
|
* the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the
|
||||||
|
* returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`.
|
||||||
|
* @since v0.1.99
|
||||||
|
* @param buffer The bytes to decode.
|
||||||
|
*/
|
||||||
|
write(buffer: string | Buffer | NodeJS.ArrayBufferView): string;
|
||||||
|
/**
|
||||||
|
* Returns any remaining input stored in the internal buffer as a string. Bytes
|
||||||
|
* representing incomplete UTF-8 and UTF-16 characters will be replaced with
|
||||||
|
* substitution characters appropriate for the character encoding.
|
||||||
|
*
|
||||||
|
* If the `buffer` argument is provided, one final call to `stringDecoder.write()` is performed before returning the remaining input.
|
||||||
|
* After `end()` is called, the `stringDecoder` object can be reused for new input.
|
||||||
|
* @since v0.9.3
|
||||||
|
* @param buffer The bytes to decode.
|
||||||
|
*/
|
||||||
|
end(buffer?: string | Buffer | NodeJS.ArrayBufferView): string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:string_decoder" {
|
||||||
|
export * from "string_decoder";
|
||||||
|
}
|
2098
websocket_server/node_modules/.ignored/@types/node/test.d.ts
generated
vendored
Normal file
2098
websocket_server/node_modules/.ignored/@types/node/test.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
240
websocket_server/node_modules/.ignored/@types/node/timers.d.ts
generated
vendored
Normal file
240
websocket_server/node_modules/.ignored/@types/node/timers.d.ts
generated
vendored
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/**
|
||||||
|
* The `timer` module exposes a global API for scheduling functions to
|
||||||
|
* be called at some future period of time. Because the timer functions are
|
||||||
|
* globals, there is no need to import `node:timers` to use the API.
|
||||||
|
*
|
||||||
|
* The timer functions within Node.js implement a similar API as the timers API
|
||||||
|
* provided by Web Browsers but use a different internal implementation that is
|
||||||
|
* built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/timers.js)
|
||||||
|
*/
|
||||||
|
declare module "timers" {
|
||||||
|
import { Abortable } from "node:events";
|
||||||
|
import {
|
||||||
|
setImmediate as setImmediatePromise,
|
||||||
|
setInterval as setIntervalPromise,
|
||||||
|
setTimeout as setTimeoutPromise,
|
||||||
|
} from "node:timers/promises";
|
||||||
|
interface TimerOptions extends Abortable {
|
||||||
|
/**
|
||||||
|
* Set to `false` to indicate that the scheduled `Timeout`
|
||||||
|
* should not require the Node.js event loop to remain active.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
ref?: boolean | undefined;
|
||||||
|
}
|
||||||
|
let setTimeout: typeof global.setTimeout;
|
||||||
|
let clearTimeout: typeof global.clearTimeout;
|
||||||
|
let setInterval: typeof global.setInterval;
|
||||||
|
let clearInterval: typeof global.clearInterval;
|
||||||
|
let setImmediate: typeof global.setImmediate;
|
||||||
|
let clearImmediate: typeof global.clearImmediate;
|
||||||
|
global {
|
||||||
|
namespace NodeJS {
|
||||||
|
// compatibility with older typings
|
||||||
|
interface Timer extends RefCounted {
|
||||||
|
hasRef(): boolean;
|
||||||
|
refresh(): this;
|
||||||
|
[Symbol.toPrimitive](): number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This object is created internally and is returned from `setImmediate()`. It
|
||||||
|
* can be passed to `clearImmediate()` in order to cancel the scheduled
|
||||||
|
* actions.
|
||||||
|
*
|
||||||
|
* By default, when an immediate is scheduled, the Node.js event loop will continue
|
||||||
|
* running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()` functions that can be used to
|
||||||
|
* control this default behavior.
|
||||||
|
*/
|
||||||
|
class Immediate implements RefCounted {
|
||||||
|
/**
|
||||||
|
* When called, requests that the Node.js event loop _not_ exit so long as the `Immediate` is active. Calling `immediate.ref()` multiple times will have no
|
||||||
|
* effect.
|
||||||
|
*
|
||||||
|
* By default, all `Immediate` objects are "ref'ed", making it normally unnecessary
|
||||||
|
* to call `immediate.ref()` unless `immediate.unref()` had been called previously.
|
||||||
|
* @since v9.7.0
|
||||||
|
* @return a reference to `immediate`
|
||||||
|
*/
|
||||||
|
ref(): this;
|
||||||
|
/**
|
||||||
|
* When called, the active `Immediate` object will not require the Node.js event
|
||||||
|
* loop to remain active. If there is no other activity keeping the event loop
|
||||||
|
* running, the process may exit before the `Immediate` object's callback is
|
||||||
|
* invoked. Calling `immediate.unref()` multiple times will have no effect.
|
||||||
|
* @since v9.7.0
|
||||||
|
* @return a reference to `immediate`
|
||||||
|
*/
|
||||||
|
unref(): this;
|
||||||
|
/**
|
||||||
|
* If true, the `Immediate` object will keep the Node.js event loop active.
|
||||||
|
* @since v11.0.0
|
||||||
|
*/
|
||||||
|
hasRef(): boolean;
|
||||||
|
_onImmediate: Function; // to distinguish it from the Timeout class
|
||||||
|
/**
|
||||||
|
* Cancels the immediate. This is similar to calling `clearImmediate()`.
|
||||||
|
* @since v20.5.0
|
||||||
|
*/
|
||||||
|
[Symbol.dispose](): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the
|
||||||
|
* scheduled actions.
|
||||||
|
*
|
||||||
|
* By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the
|
||||||
|
* timer is active. Each of the `Timeout` objects returned by these functions
|
||||||
|
* export both `timeout.ref()` and `timeout.unref()` functions that can be used to
|
||||||
|
* control this default behavior.
|
||||||
|
*/
|
||||||
|
class Timeout implements Timer {
|
||||||
|
/**
|
||||||
|
* When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
|
||||||
|
*
|
||||||
|
* By default, all `Timeout` objects are "ref'ed", making it normally unnecessary
|
||||||
|
* to call `timeout.ref()` unless `timeout.unref()` had been called previously.
|
||||||
|
* @since v0.9.1
|
||||||
|
* @return a reference to `timeout`
|
||||||
|
*/
|
||||||
|
ref(): this;
|
||||||
|
/**
|
||||||
|
* When called, the active `Timeout` object will not require the Node.js event loop
|
||||||
|
* to remain active. If there is no other activity keeping the event loop running,
|
||||||
|
* the process may exit before the `Timeout` object's callback is invoked. Calling `timeout.unref()` multiple times will have no effect.
|
||||||
|
* @since v0.9.1
|
||||||
|
* @return a reference to `timeout`
|
||||||
|
*/
|
||||||
|
unref(): this;
|
||||||
|
/**
|
||||||
|
* If true, the `Timeout` object will keep the Node.js event loop active.
|
||||||
|
* @since v11.0.0
|
||||||
|
*/
|
||||||
|
hasRef(): boolean;
|
||||||
|
/**
|
||||||
|
* Sets the timer's start time to the current time, and reschedules the timer to
|
||||||
|
* call its callback at the previously specified duration adjusted to the current
|
||||||
|
* time. This is useful for refreshing a timer without allocating a new
|
||||||
|
* JavaScript object.
|
||||||
|
*
|
||||||
|
* Using this on a timer that has already called its callback will reactivate the
|
||||||
|
* timer.
|
||||||
|
* @since v10.2.0
|
||||||
|
* @return a reference to `timeout`
|
||||||
|
*/
|
||||||
|
refresh(): this;
|
||||||
|
[Symbol.toPrimitive](): number;
|
||||||
|
/**
|
||||||
|
* Cancels the timeout.
|
||||||
|
* @since v20.5.0
|
||||||
|
*/
|
||||||
|
[Symbol.dispose](): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Schedules execution of a one-time `callback` after `delay` milliseconds.
|
||||||
|
*
|
||||||
|
* The `callback` will likely not be invoked in precisely `delay` milliseconds.
|
||||||
|
* Node.js makes no guarantees about the exact timing of when callbacks will fire,
|
||||||
|
* nor of their ordering. The callback will be called as close as possible to the
|
||||||
|
* time specified.
|
||||||
|
*
|
||||||
|
* When `delay` is larger than `2147483647` or less than `1`, the `delay` will be set to `1`. Non-integer delays are truncated to an integer.
|
||||||
|
*
|
||||||
|
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||||
|
*
|
||||||
|
* This method has a custom variant for promises that is available using `timersPromises.setTimeout()`.
|
||||||
|
* @since v0.0.1
|
||||||
|
* @param callback The function to call when the timer elapses.
|
||||||
|
* @param [delay=1] The number of milliseconds to wait before calling the `callback`.
|
||||||
|
* @param args Optional arguments to pass when the `callback` is called.
|
||||||
|
* @return for use with {@link clearTimeout}
|
||||||
|
*/
|
||||||
|
function setTimeout<TArgs extends any[]>(
|
||||||
|
callback: (...args: TArgs) => void,
|
||||||
|
ms?: number,
|
||||||
|
...args: TArgs
|
||||||
|
): NodeJS.Timeout;
|
||||||
|
// util.promisify no rest args compability
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||||
|
function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
||||||
|
namespace setTimeout {
|
||||||
|
const __promisify__: typeof setTimeoutPromise;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Cancels a `Timeout` object created by `setTimeout()`.
|
||||||
|
* @since v0.0.1
|
||||||
|
* @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number.
|
||||||
|
*/
|
||||||
|
function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void;
|
||||||
|
/**
|
||||||
|
* Schedules repeated execution of `callback` every `delay` milliseconds.
|
||||||
|
*
|
||||||
|
* When `delay` is larger than `2147483647` or less than `1`, the `delay` will be
|
||||||
|
* set to `1`. Non-integer delays are truncated to an integer.
|
||||||
|
*
|
||||||
|
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||||
|
*
|
||||||
|
* This method has a custom variant for promises that is available using `timersPromises.setInterval()`.
|
||||||
|
* @since v0.0.1
|
||||||
|
* @param callback The function to call when the timer elapses.
|
||||||
|
* @param [delay=1] The number of milliseconds to wait before calling the `callback`.
|
||||||
|
* @param args Optional arguments to pass when the `callback` is called.
|
||||||
|
* @return for use with {@link clearInterval}
|
||||||
|
*/
|
||||||
|
function setInterval<TArgs extends any[]>(
|
||||||
|
callback: (...args: TArgs) => void,
|
||||||
|
ms?: number,
|
||||||
|
...args: TArgs
|
||||||
|
): NodeJS.Timeout;
|
||||||
|
// util.promisify no rest args compability
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||||
|
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
||||||
|
namespace setInterval {
|
||||||
|
const __promisify__: typeof setIntervalPromise;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Cancels a `Timeout` object created by `setInterval()`.
|
||||||
|
* @since v0.0.1
|
||||||
|
* @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number.
|
||||||
|
*/
|
||||||
|
function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void;
|
||||||
|
/**
|
||||||
|
* Schedules the "immediate" execution of the `callback` after I/O events'
|
||||||
|
* callbacks.
|
||||||
|
*
|
||||||
|
* When multiple calls to `setImmediate()` are made, the `callback` functions are
|
||||||
|
* queued for execution in the order in which they are created. The entire callback
|
||||||
|
* queue is processed every event loop iteration. If an immediate timer is queued
|
||||||
|
* from inside an executing callback, that timer will not be triggered until the
|
||||||
|
* next event loop iteration.
|
||||||
|
*
|
||||||
|
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||||
|
*
|
||||||
|
* This method has a custom variant for promises that is available using `timersPromises.setImmediate()`.
|
||||||
|
* @since v0.9.1
|
||||||
|
* @param callback The function to call at the end of this turn of the Node.js `Event Loop`
|
||||||
|
* @param args Optional arguments to pass when the `callback` is called.
|
||||||
|
* @return for use with {@link clearImmediate}
|
||||||
|
*/
|
||||||
|
function setImmediate<TArgs extends any[]>(
|
||||||
|
callback: (...args: TArgs) => void,
|
||||||
|
...args: TArgs
|
||||||
|
): NodeJS.Immediate;
|
||||||
|
// util.promisify no rest args compability
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||||
|
function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
|
||||||
|
namespace setImmediate {
|
||||||
|
const __promisify__: typeof setImmediatePromise;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Cancels an `Immediate` object created by `setImmediate()`.
|
||||||
|
* @since v0.9.1
|
||||||
|
* @param immediate An `Immediate` object as returned by {@link setImmediate}.
|
||||||
|
*/
|
||||||
|
function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
|
||||||
|
function queueMicrotask(callback: () => void): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:timers" {
|
||||||
|
export * from "timers";
|
||||||
|
}
|
97
websocket_server/node_modules/.ignored/@types/node/timers/promises.d.ts
generated
vendored
Normal file
97
websocket_server/node_modules/.ignored/@types/node/timers/promises.d.ts
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* The `timers/promises` API provides an alternative set of timer functions
|
||||||
|
* that return `Promise` objects. The API is accessible via `import timersPromises from 'node:timers/promises'`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* setTimeout,
|
||||||
|
* setImmediate,
|
||||||
|
* setInterval,
|
||||||
|
* } from 'node:timers/promises';
|
||||||
|
* ```
|
||||||
|
* @since v15.0.0
|
||||||
|
*/
|
||||||
|
declare module "timers/promises" {
|
||||||
|
import { TimerOptions } from "node:timers";
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* setTimeout,
|
||||||
|
* } from 'node:timers/promises';
|
||||||
|
*
|
||||||
|
* const res = await setTimeout(100, 'result');
|
||||||
|
*
|
||||||
|
* console.log(res); // Prints 'result'
|
||||||
|
* ```
|
||||||
|
* @since v15.0.0
|
||||||
|
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||||
|
* @param value A value with which the promise is fulfilled.
|
||||||
|
*/
|
||||||
|
function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* setImmediate,
|
||||||
|
* } from 'node:timers/promises';
|
||||||
|
*
|
||||||
|
* const res = await setImmediate('result');
|
||||||
|
*
|
||||||
|
* console.log(res); // Prints 'result'
|
||||||
|
* ```
|
||||||
|
* @since v15.0.0
|
||||||
|
* @param value A value with which the promise is fulfilled.
|
||||||
|
*/
|
||||||
|
function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
||||||
|
/**
|
||||||
|
* Returns an async iterator that generates values in an interval of `delay` ms.
|
||||||
|
* If `ref` is `true`, you need to call `next()` of async iterator explicitly
|
||||||
|
* or implicitly to keep the event loop alive.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* setInterval,
|
||||||
|
* } from 'node:timers/promises';
|
||||||
|
*
|
||||||
|
* const interval = 100;
|
||||||
|
* for await (const startTime of setInterval(interval, Date.now())) {
|
||||||
|
* const now = Date.now();
|
||||||
|
* console.log(now);
|
||||||
|
* if ((now - startTime) > 1000)
|
||||||
|
* break;
|
||||||
|
* }
|
||||||
|
* console.log(Date.now());
|
||||||
|
* ```
|
||||||
|
* @since v15.9.0
|
||||||
|
*/
|
||||||
|
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
||||||
|
interface Scheduler {
|
||||||
|
/**
|
||||||
|
* An experimental API defined by the [Scheduling APIs](https://github.com/WICG/scheduling-apis) draft specification being developed as a standard Web Platform API.
|
||||||
|
*
|
||||||
|
* Calling `timersPromises.scheduler.wait(delay, options)` is roughly equivalent to calling `timersPromises.setTimeout(delay, undefined, options)` except that the `ref`
|
||||||
|
* option is not supported.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { scheduler } from 'node:timers/promises';
|
||||||
|
*
|
||||||
|
* await scheduler.wait(1000); // Wait one second before continuing
|
||||||
|
* ```
|
||||||
|
* @since v16.14.0
|
||||||
|
* @experimental
|
||||||
|
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||||
|
*/
|
||||||
|
wait: (delay?: number, options?: Pick<TimerOptions, "signal">) => Promise<void>;
|
||||||
|
/**
|
||||||
|
* An experimental API defined by the [Scheduling APIs](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html#promise-execution-tracking) draft specification
|
||||||
|
* being developed as a standard Web Platform API.
|
||||||
|
* Calling `timersPromises.scheduler.yield()` is equivalent to calling `timersPromises.setImmediate()` with no arguments.
|
||||||
|
* @since v16.14.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
yield: () => Promise<void>;
|
||||||
|
}
|
||||||
|
const scheduler: Scheduler;
|
||||||
|
}
|
||||||
|
declare module "node:timers/promises" {
|
||||||
|
export * from "timers/promises";
|
||||||
|
}
|
1220
websocket_server/node_modules/.ignored/@types/node/tls.d.ts
generated
vendored
Normal file
1220
websocket_server/node_modules/.ignored/@types/node/tls.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
197
websocket_server/node_modules/.ignored/@types/node/trace_events.d.ts
generated
vendored
Normal file
197
websocket_server/node_modules/.ignored/@types/node/trace_events.d.ts
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
/**
|
||||||
|
* The `node:trace_events` module provides a mechanism to centralize tracing information
|
||||||
|
* generated by V8, Node.js core, and userspace code.
|
||||||
|
*
|
||||||
|
* Tracing can be enabled with the `--trace-event-categories` command-line flag
|
||||||
|
* or by using the `trace_events` module. The `--trace-event-categories` flag
|
||||||
|
* accepts a list of comma-separated category names.
|
||||||
|
*
|
||||||
|
* The available categories are:
|
||||||
|
*
|
||||||
|
* * `node`: An empty placeholder.
|
||||||
|
* * `node.async_hooks`: Enables capture of detailed [`async_hooks`](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html) trace data.
|
||||||
|
* The [`async_hooks`](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html) events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
|
||||||
|
* * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
|
||||||
|
* * `node.console`: Enables capture of `console.time()` and `console.count()` output.
|
||||||
|
* * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||||
|
* * `node.threadpoolwork.async`: Enables capture of trace data for threadpool asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||||
|
* * `node.dns.native`: Enables capture of trace data for DNS queries.
|
||||||
|
* * `node.net.native`: Enables capture of trace data for network.
|
||||||
|
* * `node.environment`: Enables capture of Node.js Environment milestones.
|
||||||
|
* * `node.fs.sync`: Enables capture of trace data for file system sync methods.
|
||||||
|
* * `node.fs_dir.sync`: Enables capture of trace data for file system sync directory methods.
|
||||||
|
* * `node.fs.async`: Enables capture of trace data for file system async methods.
|
||||||
|
* * `node.fs_dir.async`: Enables capture of trace data for file system async directory methods.
|
||||||
|
* * `node.perf`: Enables capture of [Performance API](https://nodejs.org/docs/latest-v22.x/api/perf_hooks.html) measurements.
|
||||||
|
* * `node.perf.usertiming`: Enables capture of only Performance API User Timing
|
||||||
|
* measures and marks.
|
||||||
|
* * `node.perf.timerify`: Enables capture of only Performance API timerify
|
||||||
|
* measurements.
|
||||||
|
* * `node.promises.rejections`: Enables capture of trace data tracking the number
|
||||||
|
* of unhandled Promise rejections and handled-after-rejections.
|
||||||
|
* * `node.vm.script`: Enables capture of trace data for the `node:vm` module's `runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
||||||
|
* * `v8`: The [V8](https://nodejs.org/docs/latest-v22.x/api/v8.html) events are GC, compiling, and execution related.
|
||||||
|
* * `node.http`: Enables capture of trace data for http request / response.
|
||||||
|
*
|
||||||
|
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* node --trace-event-categories v8,node,node.async_hooks server.js
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Prior versions of Node.js required the use of the `--trace-events-enabled` flag to enable trace events. This requirement has been removed. However, the `--trace-events-enabled` flag _may_ still be
|
||||||
|
* used and will enable the `node`, `node.async_hooks`, and `v8` trace event categories by default.
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* node --trace-events-enabled
|
||||||
|
*
|
||||||
|
* # is equivalent to
|
||||||
|
*
|
||||||
|
* node --trace-event-categories v8,node,node.async_hooks
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Alternatively, trace events may be enabled using the `node:trace_events` module:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import trace_events from 'node:trace_events';
|
||||||
|
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
||||||
|
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
||||||
|
*
|
||||||
|
* // do work
|
||||||
|
*
|
||||||
|
* tracing.disable(); // Disable trace event capture for the 'node.perf' category
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Running Node.js with tracing enabled will produce log files that can be opened
|
||||||
|
* in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) tab of Chrome.
|
||||||
|
*
|
||||||
|
* The logging file is by default called `node_trace.${rotation}.log`, where `${rotation}` is an incrementing log-rotation id. The filepath pattern can
|
||||||
|
* be specified with `--trace-event-file-pattern` that accepts a template
|
||||||
|
* string that supports `${rotation}` and `${pid}`:
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* To guarantee that the log file is properly generated after signal events like `SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
|
||||||
|
* in your code, such as:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* process.on('SIGINT', function onSigint() {
|
||||||
|
* console.info('Received SIGINT.');
|
||||||
|
* process.exit(130); // Or applicable exit code depending on OS and signal
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The tracing system uses the same time source
|
||||||
|
* as the one used by `process.hrtime()`.
|
||||||
|
* However the trace-event timestamps are expressed in microseconds,
|
||||||
|
* unlike `process.hrtime()` which returns nanoseconds.
|
||||||
|
*
|
||||||
|
* The features from this module are not available in [`Worker`](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html#class-worker) threads.
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/trace_events.js)
|
||||||
|
*/
|
||||||
|
declare module "trace_events" {
|
||||||
|
/**
|
||||||
|
* The `Tracing` object is used to enable or disable tracing for sets of
|
||||||
|
* categories. Instances are created using the
|
||||||
|
* `trace_events.createTracing()` method.
|
||||||
|
*
|
||||||
|
* When created, the `Tracing` object is disabled. Calling the
|
||||||
|
* `tracing.enable()` method adds the categories to the set of enabled trace
|
||||||
|
* event categories. Calling `tracing.disable()` will remove the categories
|
||||||
|
* from the set of enabled trace event categories.
|
||||||
|
*/
|
||||||
|
interface Tracing {
|
||||||
|
/**
|
||||||
|
* A comma-separated list of the trace event categories covered by this
|
||||||
|
* `Tracing` object.
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
readonly categories: string;
|
||||||
|
/**
|
||||||
|
* Disables this `Tracing` object.
|
||||||
|
*
|
||||||
|
* Only trace event categories _not_ covered by other enabled `Tracing`
|
||||||
|
* objects and _not_ specified by the `--trace-event-categories` flag
|
||||||
|
* will be disabled.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import trace_events from 'node:trace_events';
|
||||||
|
* const t1 = trace_events.createTracing({ categories: ['node', 'v8'] });
|
||||||
|
* const t2 = trace_events.createTracing({ categories: ['node.perf', 'node'] });
|
||||||
|
* t1.enable();
|
||||||
|
* t2.enable();
|
||||||
|
*
|
||||||
|
* // Prints 'node,node.perf,v8'
|
||||||
|
* console.log(trace_events.getEnabledCategories());
|
||||||
|
*
|
||||||
|
* t2.disable(); // Will only disable emission of the 'node.perf' category
|
||||||
|
*
|
||||||
|
* // Prints 'node,v8'
|
||||||
|
* console.log(trace_events.getEnabledCategories());
|
||||||
|
* ```
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
disable(): void;
|
||||||
|
/**
|
||||||
|
* Enables this `Tracing` object for the set of categories covered by
|
||||||
|
* the `Tracing` object.
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
enable(): void;
|
||||||
|
/**
|
||||||
|
* `true` only if the `Tracing` object has been enabled.
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
readonly enabled: boolean;
|
||||||
|
}
|
||||||
|
interface CreateTracingOptions {
|
||||||
|
/**
|
||||||
|
* An array of trace category names. Values included in the array are
|
||||||
|
* coerced to a string when possible. An error will be thrown if the
|
||||||
|
* value cannot be coerced.
|
||||||
|
*/
|
||||||
|
categories: string[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates and returns a `Tracing` object for the given set of `categories`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import trace_events from 'node:trace_events';
|
||||||
|
* const categories = ['node.perf', 'node.async_hooks'];
|
||||||
|
* const tracing = trace_events.createTracing({ categories });
|
||||||
|
* tracing.enable();
|
||||||
|
* // do stuff
|
||||||
|
* tracing.disable();
|
||||||
|
* ```
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
function createTracing(options: CreateTracingOptions): Tracing;
|
||||||
|
/**
|
||||||
|
* Returns a comma-separated list of all currently-enabled trace event
|
||||||
|
* categories. The current set of enabled trace event categories is determined
|
||||||
|
* by the _union_ of all currently-enabled `Tracing` objects and any categories
|
||||||
|
* enabled using the `--trace-event-categories` flag.
|
||||||
|
*
|
||||||
|
* Given the file `test.js` below, the command `node --trace-event-categories node.perf test.js` will print `'node.async_hooks,node.perf'` to the console.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import trace_events from 'node:trace_events';
|
||||||
|
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
|
||||||
|
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
|
||||||
|
* const t3 = trace_events.createTracing({ categories: ['v8'] });
|
||||||
|
*
|
||||||
|
* t1.enable();
|
||||||
|
* t2.enable();
|
||||||
|
*
|
||||||
|
* console.log(trace_events.getEnabledCategories());
|
||||||
|
* ```
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
function getEnabledCategories(): string | undefined;
|
||||||
|
}
|
||||||
|
declare module "node:trace_events" {
|
||||||
|
export * from "trace_events";
|
||||||
|
}
|
385
websocket_server/node_modules/.ignored/@types/node/ts5.6/buffer.buffer.d.ts
generated
vendored
Normal file
385
websocket_server/node_modules/.ignored/@types/node/ts5.6/buffer.buffer.d.ts
generated
vendored
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
declare module "buffer" {
|
||||||
|
global {
|
||||||
|
interface BufferConstructor {
|
||||||
|
// see ../buffer.d.ts for implementation shared with all TypeScript versions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {str}.
|
||||||
|
*
|
||||||
|
* @param str String to store in buffer.
|
||||||
|
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||||
|
*/
|
||||||
|
new(str: string, encoding?: BufferEncoding): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer of {size} octets.
|
||||||
|
*
|
||||||
|
* @param size count of octets to allocate.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||||
|
*/
|
||||||
|
new(size: number): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {array} of octets.
|
||||||
|
*
|
||||||
|
* @param array The octets to store.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||||
|
*/
|
||||||
|
new(array: Uint8Array): Buffer;
|
||||||
|
/**
|
||||||
|
* Produces a Buffer backed by the same allocated memory as
|
||||||
|
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||||
|
*
|
||||||
|
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||||
|
*/
|
||||||
|
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new buffer containing the given {array} of octets.
|
||||||
|
*
|
||||||
|
* @param array The octets to store.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||||
|
*/
|
||||||
|
new(array: readonly any[]): Buffer;
|
||||||
|
/**
|
||||||
|
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||||
|
*
|
||||||
|
* @param buffer The buffer to copy.
|
||||||
|
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
||||||
|
*/
|
||||||
|
new(buffer: Buffer): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
||||||
|
* Array entries outside that range will be truncated to fit into it.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
||||||
|
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `array` is an `Array`\-like object (that is, one with a `length` property of
|
||||||
|
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
||||||
|
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
||||||
|
* appropriate for `Buffer.from()` variants.
|
||||||
|
*
|
||||||
|
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||||
|
* @since v5.10.0
|
||||||
|
*/
|
||||||
|
from(
|
||||||
|
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
||||||
|
byteOffset?: number,
|
||||||
|
length?: number,
|
||||||
|
): Buffer;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer using the passed {data}
|
||||||
|
* @param data data to create a new Buffer
|
||||||
|
*/
|
||||||
|
from(data: Uint8Array | readonly number[]): Buffer;
|
||||||
|
from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||||
|
* If provided, the {encoding} parameter identifies the character encoding.
|
||||||
|
* If not provided, {encoding} defaults to 'utf8'.
|
||||||
|
*/
|
||||||
|
from(
|
||||||
|
str:
|
||||||
|
| WithImplicitCoercion<string>
|
||||||
|
| {
|
||||||
|
[Symbol.toPrimitive](hint: "string"): string;
|
||||||
|
},
|
||||||
|
encoding?: BufferEncoding,
|
||||||
|
): Buffer;
|
||||||
|
/**
|
||||||
|
* Creates a new Buffer using the passed {data}
|
||||||
|
* @param values to create a new Buffer
|
||||||
|
*/
|
||||||
|
of(...items: number[]): Buffer;
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
||||||
|
*
|
||||||
|
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
||||||
|
*
|
||||||
|
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
||||||
|
* in `list` by adding their lengths.
|
||||||
|
*
|
||||||
|
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
||||||
|
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
||||||
|
* truncated to `totalLength`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
||||||
|
*
|
||||||
|
* const buf1 = Buffer.alloc(10);
|
||||||
|
* const buf2 = Buffer.alloc(14);
|
||||||
|
* const buf3 = Buffer.alloc(18);
|
||||||
|
* const totalLength = buf1.length + buf2.length + buf3.length;
|
||||||
|
*
|
||||||
|
* console.log(totalLength);
|
||||||
|
* // Prints: 42
|
||||||
|
*
|
||||||
|
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
||||||
|
*
|
||||||
|
* console.log(bufA);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 ...>
|
||||||
|
* console.log(bufA.length);
|
||||||
|
* // Prints: 42
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||||
|
* @since v0.7.11
|
||||||
|
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
||||||
|
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
||||||
|
*/
|
||||||
|
concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
|
||||||
|
/**
|
||||||
|
* Copies the underlying memory of `view` into a new `Buffer`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const u16 = new Uint16Array([0, 0xffff]);
|
||||||
|
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
||||||
|
* u16[1] = 0;
|
||||||
|
* console.log(buf.length); // 2
|
||||||
|
* console.log(buf[0]); // 255
|
||||||
|
* console.log(buf[1]); // 255
|
||||||
|
* ```
|
||||||
|
* @since v19.8.0
|
||||||
|
* @param view The {TypedArray} to copy.
|
||||||
|
* @param [offset=0] The starting offset within `view`.
|
||||||
|
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
||||||
|
*/
|
||||||
|
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(5);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 00>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||||
|
*
|
||||||
|
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(5, 'a');
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 61 61 61 61 61>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||||
|
* initialized by calling `buf.fill(fill, encoding)`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
||||||
|
* contents will never contain sensitive data from previous allocations, including
|
||||||
|
* data that might not have been allocated for `Buffer`s.
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
* @since v5.10.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
||||||
|
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
||||||
|
*/
|
||||||
|
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||||
|
*
|
||||||
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||||
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.allocUnsafe(10);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
||||||
|
*
|
||||||
|
* buf.fill(0);
|
||||||
|
*
|
||||||
|
* console.log(buf);
|
||||||
|
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
*
|
||||||
|
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||||
|
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
||||||
|
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
||||||
|
*
|
||||||
|
* Use of this pre-allocated internal memory pool is a key difference between
|
||||||
|
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||||
|
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
||||||
|
* than or equal to half `Buffer.poolSize`. The
|
||||||
|
* difference is subtle but can be important when an application requires the
|
||||||
|
* additional performance that `Buffer.allocUnsafe()` provides.
|
||||||
|
* @since v5.10.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
*/
|
||||||
|
allocUnsafe(size: number): Buffer;
|
||||||
|
/**
|
||||||
|
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
||||||
|
* `size` is 0.
|
||||||
|
*
|
||||||
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||||
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
||||||
|
* such `Buffer` instances with zeroes.
|
||||||
|
*
|
||||||
|
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||||
|
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
||||||
|
* allows applications to avoid the garbage collection overhead of creating many
|
||||||
|
* individually allocated `Buffer` instances. This approach improves both
|
||||||
|
* performance and memory usage by eliminating the need to track and clean up as
|
||||||
|
* many individual `ArrayBuffer` objects.
|
||||||
|
*
|
||||||
|
* However, in the case where a developer may need to retain a small chunk of
|
||||||
|
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||||
|
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
||||||
|
* then copying out the relevant bits.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Need to keep around a few small chunks of memory.
|
||||||
|
* const store = [];
|
||||||
|
*
|
||||||
|
* socket.on('readable', () => {
|
||||||
|
* let data;
|
||||||
|
* while (null !== (data = readable.read())) {
|
||||||
|
* // Allocate for retained data.
|
||||||
|
* const sb = Buffer.allocUnsafeSlow(10);
|
||||||
|
*
|
||||||
|
* // Copy the data into the new allocation.
|
||||||
|
* data.copy(sb, 0, 0, 10);
|
||||||
|
*
|
||||||
|
* store.push(sb);
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* A `TypeError` will be thrown if `size` is not a number.
|
||||||
|
* @since v5.12.0
|
||||||
|
* @param size The desired length of the new `Buffer`.
|
||||||
|
*/
|
||||||
|
allocUnsafeSlow(size: number): Buffer;
|
||||||
|
}
|
||||||
|
interface Buffer extends Uint8Array {
|
||||||
|
// see ../buffer.d.ts for implementation shared with all TypeScript versions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` that references the same memory as the original, but
|
||||||
|
* offset and cropped by the `start` and `end` indices.
|
||||||
|
*
|
||||||
|
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||||
|
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.from('buffer');
|
||||||
|
*
|
||||||
|
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
||||||
|
* copiedBuf[0]++;
|
||||||
|
* console.log(copiedBuf.toString());
|
||||||
|
* // Prints: cuffer
|
||||||
|
*
|
||||||
|
* console.log(buf.toString());
|
||||||
|
* // Prints: buffer
|
||||||
|
*
|
||||||
|
* // With buf.slice(), the original buffer is modified.
|
||||||
|
* const notReallyCopiedBuf = buf.slice();
|
||||||
|
* notReallyCopiedBuf[0]++;
|
||||||
|
* console.log(notReallyCopiedBuf.toString());
|
||||||
|
* // Prints: cuffer
|
||||||
|
* console.log(buf.toString());
|
||||||
|
* // Also prints: cuffer (!)
|
||||||
|
* ```
|
||||||
|
* @since v0.3.0
|
||||||
|
* @deprecated Use `subarray` instead.
|
||||||
|
* @param [start=0] Where the new `Buffer` will start.
|
||||||
|
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||||
|
*/
|
||||||
|
slice(start?: number, end?: number): Buffer;
|
||||||
|
/**
|
||||||
|
* Returns a new `Buffer` that references the same memory as the original, but
|
||||||
|
* offset and cropped by the `start` and `end` indices.
|
||||||
|
*
|
||||||
|
* Specifying `end` greater than `buf.length` will return the same result as
|
||||||
|
* that of `end` equal to `buf.length`.
|
||||||
|
*
|
||||||
|
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
||||||
|
*
|
||||||
|
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
||||||
|
* // from the original `Buffer`.
|
||||||
|
*
|
||||||
|
* const buf1 = Buffer.allocUnsafe(26);
|
||||||
|
*
|
||||||
|
* for (let i = 0; i < 26; i++) {
|
||||||
|
* // 97 is the decimal ASCII value for 'a'.
|
||||||
|
* buf1[i] = i + 97;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const buf2 = buf1.subarray(0, 3);
|
||||||
|
*
|
||||||
|
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||||
|
* // Prints: abc
|
||||||
|
*
|
||||||
|
* buf1[0] = 33;
|
||||||
|
*
|
||||||
|
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||||
|
* // Prints: !bc
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Specifying negative indexes causes the slice to be generated relative to the
|
||||||
|
* end of `buf` rather than the beginning.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { Buffer } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const buf = Buffer.from('buffer');
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-6, -1).toString());
|
||||||
|
* // Prints: buffe
|
||||||
|
* // (Equivalent to buf.subarray(0, 5).)
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-6, -2).toString());
|
||||||
|
* // Prints: buff
|
||||||
|
* // (Equivalent to buf.subarray(0, 4).)
|
||||||
|
*
|
||||||
|
* console.log(buf.subarray(-5, -2).toString());
|
||||||
|
* // Prints: uff
|
||||||
|
* // (Equivalent to buf.subarray(1, 4).)
|
||||||
|
* ```
|
||||||
|
* @since v3.0.0
|
||||||
|
* @param [start=0] Where the new `Buffer` will start.
|
||||||
|
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||||
|
*/
|
||||||
|
subarray(start?: number, end?: number): Buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
websocket_server/node_modules/.ignored/@types/node/ts5.6/globals.typedarray.d.ts
generated
vendored
Normal file
19
websocket_server/node_modules/.ignored/@types/node/ts5.6/globals.typedarray.d.ts
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export {}; // Make this a module
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace NodeJS {
|
||||||
|
type TypedArray =
|
||||||
|
| Uint8Array
|
||||||
|
| Uint8ClampedArray
|
||||||
|
| Uint16Array
|
||||||
|
| Uint32Array
|
||||||
|
| Int8Array
|
||||||
|
| Int16Array
|
||||||
|
| Int32Array
|
||||||
|
| BigUint64Array
|
||||||
|
| BigInt64Array
|
||||||
|
| Float32Array
|
||||||
|
| Float64Array;
|
||||||
|
type ArrayBufferView = TypedArray | DataView;
|
||||||
|
}
|
||||||
|
}
|
92
websocket_server/node_modules/.ignored/@types/node/ts5.6/index.d.ts
generated
vendored
Normal file
92
websocket_server/node_modules/.ignored/@types/node/ts5.6/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* License for programmatically and manually incorporated
|
||||||
|
* documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
|
||||||
|
*
|
||||||
|
* Copyright Node.js contributors. All rights reserved.
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// NOTE: These definitions support Node.js and TypeScript 4.9 through 5.6.
|
||||||
|
|
||||||
|
// Reference required TypeScript libs:
|
||||||
|
/// <reference lib="es2020" />
|
||||||
|
|
||||||
|
// TypeScript backwards-compatibility definitions:
|
||||||
|
/// <reference path="../compatibility/index.d.ts" />
|
||||||
|
|
||||||
|
// Definitions specific to TypeScript 4.9 through 5.6:
|
||||||
|
/// <reference path="./globals.typedarray.d.ts" />
|
||||||
|
/// <reference path="./buffer.buffer.d.ts" />
|
||||||
|
|
||||||
|
// Definitions for Node.js modules that are not specific to any version of TypeScript:
|
||||||
|
/// <reference path="../globals.d.ts" />
|
||||||
|
/// <reference path="../assert.d.ts" />
|
||||||
|
/// <reference path="../assert/strict.d.ts" />
|
||||||
|
/// <reference path="../async_hooks.d.ts" />
|
||||||
|
/// <reference path="../buffer.d.ts" />
|
||||||
|
/// <reference path="../child_process.d.ts" />
|
||||||
|
/// <reference path="../cluster.d.ts" />
|
||||||
|
/// <reference path="../console.d.ts" />
|
||||||
|
/// <reference path="../constants.d.ts" />
|
||||||
|
/// <reference path="../crypto.d.ts" />
|
||||||
|
/// <reference path="../dgram.d.ts" />
|
||||||
|
/// <reference path="../diagnostics_channel.d.ts" />
|
||||||
|
/// <reference path="../dns.d.ts" />
|
||||||
|
/// <reference path="../dns/promises.d.ts" />
|
||||||
|
/// <reference path="../dns/promises.d.ts" />
|
||||||
|
/// <reference path="../domain.d.ts" />
|
||||||
|
/// <reference path="../dom-events.d.ts" />
|
||||||
|
/// <reference path="../events.d.ts" />
|
||||||
|
/// <reference path="../fs.d.ts" />
|
||||||
|
/// <reference path="../fs/promises.d.ts" />
|
||||||
|
/// <reference path="../http.d.ts" />
|
||||||
|
/// <reference path="../http2.d.ts" />
|
||||||
|
/// <reference path="../https.d.ts" />
|
||||||
|
/// <reference path="../inspector.d.ts" />
|
||||||
|
/// <reference path="../module.d.ts" />
|
||||||
|
/// <reference path="../net.d.ts" />
|
||||||
|
/// <reference path="../os.d.ts" />
|
||||||
|
/// <reference path="../path.d.ts" />
|
||||||
|
/// <reference path="../perf_hooks.d.ts" />
|
||||||
|
/// <reference path="../process.d.ts" />
|
||||||
|
/// <reference path="../punycode.d.ts" />
|
||||||
|
/// <reference path="../querystring.d.ts" />
|
||||||
|
/// <reference path="../readline.d.ts" />
|
||||||
|
/// <reference path="../readline/promises.d.ts" />
|
||||||
|
/// <reference path="../repl.d.ts" />
|
||||||
|
/// <reference path="../sea.d.ts" />
|
||||||
|
/// <reference path="../sqlite.d.ts" />
|
||||||
|
/// <reference path="../stream.d.ts" />
|
||||||
|
/// <reference path="../stream/promises.d.ts" />
|
||||||
|
/// <reference path="../stream/consumers.d.ts" />
|
||||||
|
/// <reference path="../stream/web.d.ts" />
|
||||||
|
/// <reference path="../string_decoder.d.ts" />
|
||||||
|
/// <reference path="../test.d.ts" />
|
||||||
|
/// <reference path="../timers.d.ts" />
|
||||||
|
/// <reference path="../timers/promises.d.ts" />
|
||||||
|
/// <reference path="../tls.d.ts" />
|
||||||
|
/// <reference path="../trace_events.d.ts" />
|
||||||
|
/// <reference path="../tty.d.ts" />
|
||||||
|
/// <reference path="../url.d.ts" />
|
||||||
|
/// <reference path="../util.d.ts" />
|
||||||
|
/// <reference path="../v8.d.ts" />
|
||||||
|
/// <reference path="../vm.d.ts" />
|
||||||
|
/// <reference path="../wasi.d.ts" />
|
||||||
|
/// <reference path="../worker_threads.d.ts" />
|
||||||
|
/// <reference path="../zlib.d.ts" />
|
208
websocket_server/node_modules/.ignored/@types/node/tty.d.ts
generated
vendored
Normal file
208
websocket_server/node_modules/.ignored/@types/node/tty.d.ts
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/**
|
||||||
|
* The `node:tty` module provides the `tty.ReadStream` and `tty.WriteStream` classes. In most cases, it will not be necessary or possible to use this module
|
||||||
|
* directly. However, it can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import tty from 'node:tty';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* When Node.js detects that it is being run with a text terminal ("TTY")
|
||||||
|
* attached, `process.stdin` will, by default, be initialized as an instance of `tty.ReadStream` and both `process.stdout` and `process.stderr` will, by
|
||||||
|
* default, be instances of `tty.WriteStream`. The preferred method of determining
|
||||||
|
* whether Node.js is being run within a TTY context is to check that the value of
|
||||||
|
* the `process.stdout.isTTY` property is `true`:
|
||||||
|
*
|
||||||
|
* ```console
|
||||||
|
* $ node -p -e "Boolean(process.stdout.isTTY)"
|
||||||
|
* true
|
||||||
|
* $ node -p -e "Boolean(process.stdout.isTTY)" | cat
|
||||||
|
* false
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* In most cases, there should be little to no reason for an application to
|
||||||
|
* manually create instances of the `tty.ReadStream` and `tty.WriteStream` classes.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/tty.js)
|
||||||
|
*/
|
||||||
|
declare module "tty" {
|
||||||
|
import * as net from "node:net";
|
||||||
|
/**
|
||||||
|
* The `tty.isatty()` method returns `true` if the given `fd` is associated with
|
||||||
|
* a TTY and `false` if it is not, including whenever `fd` is not a non-negative
|
||||||
|
* integer.
|
||||||
|
* @since v0.5.8
|
||||||
|
* @param fd A numeric file descriptor
|
||||||
|
*/
|
||||||
|
function isatty(fd: number): boolean;
|
||||||
|
/**
|
||||||
|
* Represents the readable side of a TTY. In normal circumstances `process.stdin` will be the only `tty.ReadStream` instance in a Node.js
|
||||||
|
* process and there should be no reason to create additional instances.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
class ReadStream extends net.Socket {
|
||||||
|
constructor(fd: number, options?: net.SocketConstructorOpts);
|
||||||
|
/**
|
||||||
|
* A `boolean` that is `true` if the TTY is currently configured to operate as a
|
||||||
|
* raw device.
|
||||||
|
*
|
||||||
|
* This flag is always `false` when a process starts, even if the terminal is
|
||||||
|
* operating in raw mode. Its value will change with subsequent calls to `setRawMode`.
|
||||||
|
* @since v0.7.7
|
||||||
|
*/
|
||||||
|
isRaw: boolean;
|
||||||
|
/**
|
||||||
|
* Allows configuration of `tty.ReadStream` so that it operates as a raw device.
|
||||||
|
*
|
||||||
|
* When in raw mode, input is always available character-by-character, not
|
||||||
|
* including modifiers. Additionally, all special processing of characters by the
|
||||||
|
* terminal is disabled, including echoing input
|
||||||
|
* characters. Ctrl+C will no longer cause a `SIGINT` when
|
||||||
|
* in this mode.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param mode If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw`
|
||||||
|
* property will be set to the resulting mode.
|
||||||
|
* @return The read stream instance.
|
||||||
|
*/
|
||||||
|
setRawMode(mode: boolean): this;
|
||||||
|
/**
|
||||||
|
* A `boolean` that is always `true` for `tty.ReadStream` instances.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
isTTY: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* -1 - to the left from cursor
|
||||||
|
* 0 - the entire line
|
||||||
|
* 1 - to the right from cursor
|
||||||
|
*/
|
||||||
|
type Direction = -1 | 0 | 1;
|
||||||
|
/**
|
||||||
|
* Represents the writable side of a TTY. In normal circumstances, `process.stdout` and `process.stderr` will be the only`tty.WriteStream` instances created for a Node.js process and there
|
||||||
|
* should be no reason to create additional instances.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
class WriteStream extends net.Socket {
|
||||||
|
constructor(fd: number);
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
addListener(event: "resize", listener: () => void): this;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
emit(event: "resize"): boolean;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "resize", listener: () => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "resize", listener: () => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "resize", listener: () => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "resize", listener: () => void): this;
|
||||||
|
/**
|
||||||
|
* `writeStream.clearLine()` clears the current line of this `WriteStream` in a
|
||||||
|
* direction identified by `dir`.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
clearLine(dir: Direction, callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* `writeStream.clearScreenDown()` clears this `WriteStream` from the current
|
||||||
|
* cursor down.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
clearScreenDown(callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* `writeStream.cursorTo()` moves this `WriteStream`'s cursor to the specified
|
||||||
|
* position.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
cursorTo(x: number, y?: number, callback?: () => void): boolean;
|
||||||
|
cursorTo(x: number, callback: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* `writeStream.moveCursor()` moves this `WriteStream`'s cursor _relative_ to its
|
||||||
|
* current position.
|
||||||
|
* @since v0.7.7
|
||||||
|
* @param callback Invoked once the operation completes.
|
||||||
|
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||||
|
*/
|
||||||
|
moveCursor(dx: number, dy: number, callback?: () => void): boolean;
|
||||||
|
/**
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* * `1` for 2,
|
||||||
|
* * `4` for 16,
|
||||||
|
* * `8` for 256,
|
||||||
|
* * `24` for 16,777,216 colors supported.
|
||||||
|
*
|
||||||
|
* Use this to determine what colors the terminal supports. Due to the nature of
|
||||||
|
* colors in terminals it is possible to either have false positives or false
|
||||||
|
* negatives. It depends on process information and the environment variables that
|
||||||
|
* may lie about what terminal is used.
|
||||||
|
* It is possible to pass in an `env` object to simulate the usage of a specific
|
||||||
|
* terminal. This can be useful to check how specific environment settings behave.
|
||||||
|
*
|
||||||
|
* To enforce a specific color support, use one of the below environment settings.
|
||||||
|
*
|
||||||
|
* * 2 colors: `FORCE_COLOR = 0` (Disables colors)
|
||||||
|
* * 16 colors: `FORCE_COLOR = 1`
|
||||||
|
* * 256 colors: `FORCE_COLOR = 2`
|
||||||
|
* * 16,777,216 colors: `FORCE_COLOR = 3`
|
||||||
|
*
|
||||||
|
* Disabling color support is also possible by using the `NO_COLOR` and `NODE_DISABLE_COLORS` environment variables.
|
||||||
|
* @since v9.9.0
|
||||||
|
* @param [env=process.env] An object containing the environment variables to check. This enables simulating the usage of a specific terminal.
|
||||||
|
*/
|
||||||
|
getColorDepth(env?: object): number;
|
||||||
|
/**
|
||||||
|
* Returns `true` if the `writeStream` supports at least as many colors as provided
|
||||||
|
* in `count`. Minimum support is 2 (black and white).
|
||||||
|
*
|
||||||
|
* This has the same false positives and negatives as described in `writeStream.getColorDepth()`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* process.stdout.hasColors();
|
||||||
|
* // Returns true or false depending on if `stdout` supports at least 16 colors.
|
||||||
|
* process.stdout.hasColors(256);
|
||||||
|
* // Returns true or false depending on if `stdout` supports at least 256 colors.
|
||||||
|
* process.stdout.hasColors({ TMUX: '1' });
|
||||||
|
* // Returns true.
|
||||||
|
* process.stdout.hasColors(2 ** 24, { TMUX: '1' });
|
||||||
|
* // Returns false (the environment setting pretends to support 2 ** 8 colors).
|
||||||
|
* ```
|
||||||
|
* @since v11.13.0, v10.16.0
|
||||||
|
* @param [count=16] The number of colors that are requested (minimum 2).
|
||||||
|
* @param [env=process.env] An object containing the environment variables to check. This enables simulating the usage of a specific terminal.
|
||||||
|
*/
|
||||||
|
hasColors(count?: number): boolean;
|
||||||
|
hasColors(env?: object): boolean;
|
||||||
|
hasColors(count: number, env?: object): boolean;
|
||||||
|
/**
|
||||||
|
* `writeStream.getWindowSize()` returns the size of the TTY
|
||||||
|
* corresponding to this `WriteStream`. The array is of the type `[numColumns, numRows]` where `numColumns` and `numRows` represent the number
|
||||||
|
* of columns and rows in the corresponding TTY.
|
||||||
|
* @since v0.7.7
|
||||||
|
*/
|
||||||
|
getWindowSize(): [number, number];
|
||||||
|
/**
|
||||||
|
* A `number` specifying the number of columns the TTY currently has. This property
|
||||||
|
* is updated whenever the `'resize'` event is emitted.
|
||||||
|
* @since v0.7.7
|
||||||
|
*/
|
||||||
|
columns: number;
|
||||||
|
/**
|
||||||
|
* A `number` specifying the number of rows the TTY currently has. This property
|
||||||
|
* is updated whenever the `'resize'` event is emitted.
|
||||||
|
* @since v0.7.7
|
||||||
|
*/
|
||||||
|
rows: number;
|
||||||
|
/**
|
||||||
|
* A `boolean` that is always `true`.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
isTTY: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:tty" {
|
||||||
|
export * from "tty";
|
||||||
|
}
|
972
websocket_server/node_modules/.ignored/@types/node/url.d.ts
generated
vendored
Normal file
972
websocket_server/node_modules/.ignored/@types/node/url.d.ts
generated
vendored
Normal file
@ -0,0 +1,972 @@
|
|||||||
|
/**
|
||||||
|
* The `node:url` module provides utilities for URL resolution and parsing. It can
|
||||||
|
* be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/url.js)
|
||||||
|
*/
|
||||||
|
declare module "url" {
|
||||||
|
import { Blob as NodeBlob } from "node:buffer";
|
||||||
|
import { ClientRequestArgs } from "node:http";
|
||||||
|
import { ParsedUrlQuery, ParsedUrlQueryInput } from "node:querystring";
|
||||||
|
// Input to `url.format`
|
||||||
|
interface UrlObject {
|
||||||
|
auth?: string | null | undefined;
|
||||||
|
hash?: string | null | undefined;
|
||||||
|
host?: string | null | undefined;
|
||||||
|
hostname?: string | null | undefined;
|
||||||
|
href?: string | null | undefined;
|
||||||
|
pathname?: string | null | undefined;
|
||||||
|
protocol?: string | null | undefined;
|
||||||
|
search?: string | null | undefined;
|
||||||
|
slashes?: boolean | null | undefined;
|
||||||
|
port?: string | number | null | undefined;
|
||||||
|
query?: string | null | ParsedUrlQueryInput | undefined;
|
||||||
|
}
|
||||||
|
// Output of `url.parse`
|
||||||
|
interface Url {
|
||||||
|
auth: string | null;
|
||||||
|
hash: string | null;
|
||||||
|
host: string | null;
|
||||||
|
hostname: string | null;
|
||||||
|
href: string;
|
||||||
|
path: string | null;
|
||||||
|
pathname: string | null;
|
||||||
|
protocol: string | null;
|
||||||
|
search: string | null;
|
||||||
|
slashes: boolean | null;
|
||||||
|
port: string | null;
|
||||||
|
query: string | null | ParsedUrlQuery;
|
||||||
|
}
|
||||||
|
interface UrlWithParsedQuery extends Url {
|
||||||
|
query: ParsedUrlQuery;
|
||||||
|
}
|
||||||
|
interface UrlWithStringQuery extends Url {
|
||||||
|
query: string | null;
|
||||||
|
}
|
||||||
|
interface FileUrlToPathOptions {
|
||||||
|
/**
|
||||||
|
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
|
||||||
|
* @default undefined
|
||||||
|
* @since v22.1.0
|
||||||
|
*/
|
||||||
|
windows?: boolean | undefined;
|
||||||
|
}
|
||||||
|
interface PathToFileUrlOptions {
|
||||||
|
/**
|
||||||
|
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
|
||||||
|
* @default undefined
|
||||||
|
* @since v22.1.0
|
||||||
|
*/
|
||||||
|
windows?: boolean | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `url.parse()` method takes a URL string, parses it, and returns a URL
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* A `TypeError` is thrown if `urlString` is not a string.
|
||||||
|
*
|
||||||
|
* A `URIError` is thrown if the `auth` property is present but cannot be decoded.
|
||||||
|
*
|
||||||
|
* `url.parse()` uses a lenient, non-standard algorithm for parsing URL
|
||||||
|
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted
|
||||||
|
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead.
|
||||||
|
* @since v0.1.25
|
||||||
|
* @deprecated Use the WHATWG URL API instead.
|
||||||
|
* @param urlString The URL string to parse.
|
||||||
|
* @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property
|
||||||
|
* on the returned URL object will be an unparsed, undecoded string.
|
||||||
|
* @param [slashesDenoteHost=false] If `true`, the first token after the literal string `//` and preceding the next `/` will be interpreted as the `host`. For instance, given `//foo/bar`, the
|
||||||
|
* result would be `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
|
||||||
|
*/
|
||||||
|
function parse(urlString: string): UrlWithStringQuery;
|
||||||
|
function parse(
|
||||||
|
urlString: string,
|
||||||
|
parseQueryString: false | undefined,
|
||||||
|
slashesDenoteHost?: boolean,
|
||||||
|
): UrlWithStringQuery;
|
||||||
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
||||||
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
||||||
|
/**
|
||||||
|
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
* url.format({
|
||||||
|
* protocol: 'https',
|
||||||
|
* hostname: 'example.com',
|
||||||
|
* pathname: '/some/path',
|
||||||
|
* query: {
|
||||||
|
* page: 1,
|
||||||
|
* format: 'json',
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // => 'https://example.com/some/path?page=1&format=json'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
|
||||||
|
*
|
||||||
|
* The formatting process operates as follows:
|
||||||
|
*
|
||||||
|
* * A new empty string `result` is created.
|
||||||
|
* * If `urlObject.protocol` is a string, it is appended as-is to `result`.
|
||||||
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
||||||
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
||||||
|
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
||||||
|
* * `urlObject.slashes` property is true;
|
||||||
|
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
||||||
|
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
||||||
|
* and appended to `result` followed by the literal string `@`.
|
||||||
|
* * If the `urlObject.host` property is `undefined` then:
|
||||||
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
||||||
|
* an `Error` is thrown.
|
||||||
|
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
||||||
|
* * The literal string `:` is appended to `result`, and
|
||||||
|
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
||||||
|
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
||||||
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
||||||
|
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
||||||
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
||||||
|
* * The value of `urlObject.pathname` is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
||||||
|
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
||||||
|
* * Otherwise, if `urlObject.search` is a string:
|
||||||
|
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
||||||
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
||||||
|
* * The value of `urlObject.search` is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * If the `urlObject.hash` property is a string:
|
||||||
|
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
||||||
|
* character, the literal string `#` is appended to `result`.
|
||||||
|
* * The value of `urlObject.hash` is appended to `result`.
|
||||||
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
||||||
|
* string, an `Error` is thrown.
|
||||||
|
* * `result` is returned.
|
||||||
|
* @since v0.1.25
|
||||||
|
* @legacy Use the WHATWG URL API instead.
|
||||||
|
* @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
|
||||||
|
*/
|
||||||
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
||||||
|
/**
|
||||||
|
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
* url.format({
|
||||||
|
* protocol: 'https',
|
||||||
|
* hostname: 'example.com',
|
||||||
|
* pathname: '/some/path',
|
||||||
|
* query: {
|
||||||
|
* page: 1,
|
||||||
|
* format: 'json',
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // => 'https://example.com/some/path?page=1&format=json'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
|
||||||
|
*
|
||||||
|
* The formatting process operates as follows:
|
||||||
|
*
|
||||||
|
* * A new empty string `result` is created.
|
||||||
|
* * If `urlObject.protocol` is a string, it is appended as-is to `result`.
|
||||||
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
||||||
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
||||||
|
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
||||||
|
* * `urlObject.slashes` property is true;
|
||||||
|
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
||||||
|
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
||||||
|
* and appended to `result` followed by the literal string `@`.
|
||||||
|
* * If the `urlObject.host` property is `undefined` then:
|
||||||
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
||||||
|
* an `Error` is thrown.
|
||||||
|
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
||||||
|
* * The literal string `:` is appended to `result`, and
|
||||||
|
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
||||||
|
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
||||||
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
||||||
|
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
||||||
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
||||||
|
* * The value of `urlObject.pathname` is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
||||||
|
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
||||||
|
* * Otherwise, if `urlObject.search` is a string:
|
||||||
|
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
||||||
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
||||||
|
* * The value of `urlObject.search` is appended to `result`.
|
||||||
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
||||||
|
* * If the `urlObject.hash` property is a string:
|
||||||
|
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
||||||
|
* character, the literal string `#` is appended to `result`.
|
||||||
|
* * The value of `urlObject.hash` is appended to `result`.
|
||||||
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
||||||
|
* string, an `Error` is thrown.
|
||||||
|
* * `result` is returned.
|
||||||
|
* @since v0.1.25
|
||||||
|
* @legacy Use the WHATWG URL API instead.
|
||||||
|
* @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
|
||||||
|
*/
|
||||||
|
function format(urlObject: UrlObject | string): string;
|
||||||
|
/**
|
||||||
|
* The `url.resolve()` method resolves a target URL relative to a base URL in a
|
||||||
|
* manner similar to that of a web browser resolving an anchor tag.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
* url.resolve('/one/two/three', 'four'); // '/one/two/four'
|
||||||
|
* url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
|
||||||
|
* url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* To achieve the same result using the WHATWG URL API:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* function resolve(from, to) {
|
||||||
|
* const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
|
||||||
|
* if (resolvedUrl.protocol === 'resolve:') {
|
||||||
|
* // `from` is a relative URL.
|
||||||
|
* const { pathname, search, hash } = resolvedUrl;
|
||||||
|
* return pathname + search + hash;
|
||||||
|
* }
|
||||||
|
* return resolvedUrl.toString();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* resolve('/one/two/three', 'four'); // '/one/two/four'
|
||||||
|
* resolve('http://example.com/', '/one'); // 'http://example.com/one'
|
||||||
|
* resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
||||||
|
* ```
|
||||||
|
* @since v0.1.25
|
||||||
|
* @legacy Use the WHATWG URL API instead.
|
||||||
|
* @param from The base URL to use if `to` is a relative URL.
|
||||||
|
* @param to The target URL to resolve.
|
||||||
|
*/
|
||||||
|
function resolve(from: string, to: string): string;
|
||||||
|
/**
|
||||||
|
* Returns the [Punycode](https://tools.ietf.org/html/rfc5891#section-4.4) ASCII serialization of the `domain`. If `domain` is an
|
||||||
|
* invalid domain, the empty string is returned.
|
||||||
|
*
|
||||||
|
* It performs the inverse operation to {@link domainToUnicode}.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
*
|
||||||
|
* console.log(url.domainToASCII('español.com'));
|
||||||
|
* // Prints xn--espaol-zwa.com
|
||||||
|
* console.log(url.domainToASCII('中文.com'));
|
||||||
|
* // Prints xn--fiq228c.com
|
||||||
|
* console.log(url.domainToASCII('xn--iñvalid.com'));
|
||||||
|
* // Prints an empty string
|
||||||
|
* ```
|
||||||
|
* @since v7.4.0, v6.13.0
|
||||||
|
*/
|
||||||
|
function domainToASCII(domain: string): string;
|
||||||
|
/**
|
||||||
|
* Returns the Unicode serialization of the `domain`. If `domain` is an invalid
|
||||||
|
* domain, the empty string is returned.
|
||||||
|
*
|
||||||
|
* It performs the inverse operation to {@link domainToASCII}.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import url from 'node:url';
|
||||||
|
*
|
||||||
|
* console.log(url.domainToUnicode('xn--espaol-zwa.com'));
|
||||||
|
* // Prints español.com
|
||||||
|
* console.log(url.domainToUnicode('xn--fiq228c.com'));
|
||||||
|
* // Prints 中文.com
|
||||||
|
* console.log(url.domainToUnicode('xn--iñvalid.com'));
|
||||||
|
* // Prints an empty string
|
||||||
|
* ```
|
||||||
|
* @since v7.4.0, v6.13.0
|
||||||
|
*/
|
||||||
|
function domainToUnicode(domain: string): string;
|
||||||
|
/**
|
||||||
|
* This function ensures the correct decodings of percent-encoded characters as
|
||||||
|
* well as ensuring a cross-platform valid absolute path string.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { fileURLToPath } from 'node:url';
|
||||||
|
*
|
||||||
|
* const __filename = fileURLToPath(import.meta.url);
|
||||||
|
*
|
||||||
|
* new URL('file:///C:/path/').pathname; // Incorrect: /C:/path/
|
||||||
|
* fileURLToPath('file:///C:/path/'); // Correct: C:\path\ (Windows)
|
||||||
|
*
|
||||||
|
* new URL('file://nas/foo.txt').pathname; // Incorrect: /foo.txt
|
||||||
|
* fileURLToPath('file://nas/foo.txt'); // Correct: \\nas\foo.txt (Windows)
|
||||||
|
*
|
||||||
|
* new URL('file:///你好.txt').pathname; // Incorrect: /%E4%BD%A0%E5%A5%BD.txt
|
||||||
|
* fileURLToPath('file:///你好.txt'); // Correct: /你好.txt (POSIX)
|
||||||
|
*
|
||||||
|
* new URL('file:///hello world').pathname; // Incorrect: /hello%20world
|
||||||
|
* fileURLToPath('file:///hello world'); // Correct: /hello world (POSIX)
|
||||||
|
* ```
|
||||||
|
* @since v10.12.0
|
||||||
|
* @param url The file URL string or URL object to convert to a path.
|
||||||
|
* @return The fully-resolved platform-specific Node.js file path.
|
||||||
|
*/
|
||||||
|
function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
|
||||||
|
/**
|
||||||
|
* This function ensures that `path` is resolved absolutely, and that the URL
|
||||||
|
* control characters are correctly encoded when converting into a File URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { pathToFileURL } from 'node:url';
|
||||||
|
*
|
||||||
|
* new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1
|
||||||
|
* pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX)
|
||||||
|
*
|
||||||
|
* new URL('/some/path%.c', 'file:'); // Incorrect: file:///some/path%.c
|
||||||
|
* pathToFileURL('/some/path%.c'); // Correct: file:///some/path%25.c (POSIX)
|
||||||
|
* ```
|
||||||
|
* @since v10.12.0
|
||||||
|
* @param path The path to convert to a File URL.
|
||||||
|
* @return The file URL object.
|
||||||
|
*/
|
||||||
|
function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
|
||||||
|
/**
|
||||||
|
* This utility function converts a URL object into an ordinary options object as
|
||||||
|
* expected by the `http.request()` and `https.request()` APIs.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { urlToHttpOptions } from 'node:url';
|
||||||
|
* const myURL = new URL('https://a:b@測試?abc#foo');
|
||||||
|
*
|
||||||
|
* console.log(urlToHttpOptions(myURL));
|
||||||
|
* /*
|
||||||
|
* {
|
||||||
|
* protocol: 'https:',
|
||||||
|
* hostname: 'xn--g6w251d',
|
||||||
|
* hash: '#foo',
|
||||||
|
* search: '?abc',
|
||||||
|
* pathname: '/',
|
||||||
|
* path: '/?abc',
|
||||||
|
* href: 'https://a:b@xn--g6w251d/?abc#foo',
|
||||||
|
* auth: 'a:b'
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @since v15.7.0, v14.18.0
|
||||||
|
* @param url The `WHATWG URL` object to convert to an options object.
|
||||||
|
* @return Options object
|
||||||
|
*/
|
||||||
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
||||||
|
interface URLFormatOptions {
|
||||||
|
/**
|
||||||
|
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
auth?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
fragment?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
search?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
||||||
|
* being Punycode encoded.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
unicode?: boolean | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Browser-compatible `URL` class, implemented by following the WHATWG URL
|
||||||
|
* Standard. [Examples of parsed URLs](https://url.spec.whatwg.org/#example-url-parsing) may be found in the Standard itself.
|
||||||
|
* The `URL` class is also available on the global object.
|
||||||
|
*
|
||||||
|
* In accordance with browser conventions, all properties of `URL` objects
|
||||||
|
* are implemented as getters and setters on the class prototype, rather than as
|
||||||
|
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
||||||
|
* using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
|
||||||
|
* return `true`.
|
||||||
|
* @since v7.0.0, v6.13.0
|
||||||
|
*/
|
||||||
|
class URL {
|
||||||
|
/**
|
||||||
|
* Creates a `'blob:nodedata:...'` URL string that represents the given `Blob` object and can be used to retrieve the `Blob` later.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* Blob,
|
||||||
|
* resolveObjectURL,
|
||||||
|
* } from 'node:buffer';
|
||||||
|
*
|
||||||
|
* const blob = new Blob(['hello']);
|
||||||
|
* const id = URL.createObjectURL(blob);
|
||||||
|
*
|
||||||
|
* // later...
|
||||||
|
*
|
||||||
|
* const otherBlob = resolveObjectURL(id);
|
||||||
|
* console.log(otherBlob.size);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
||||||
|
*
|
||||||
|
* `Blob` objects are registered within the current thread. If using Worker
|
||||||
|
* Threads, `Blob` objects registered within one Worker will not be available
|
||||||
|
* to other workers or the main thread.
|
||||||
|
* @since v16.7.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
static createObjectURL(blob: NodeBlob): string;
|
||||||
|
/**
|
||||||
|
* Removes the stored `Blob` identified by the given ID. Attempting to revoke a
|
||||||
|
* ID that isn't registered will silently fail.
|
||||||
|
* @since v16.7.0
|
||||||
|
* @experimental
|
||||||
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
||||||
|
*/
|
||||||
|
static revokeObjectURL(id: string): void;
|
||||||
|
/**
|
||||||
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const isValid = URL.canParse('/foo', 'https://example.org/'); // true
|
||||||
|
*
|
||||||
|
* const isNotValid = URL.canParse('/foo'); // false
|
||||||
|
* ```
|
||||||
|
* @since v19.9.0
|
||||||
|
* @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
|
||||||
|
* `converted to a string` first.
|
||||||
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
||||||
|
*/
|
||||||
|
static canParse(input: string, base?: string): boolean;
|
||||||
|
/**
|
||||||
|
* Parses a string as a URL. If `base` is provided, it will be used as the base URL for the purpose of resolving non-absolute `input` URLs.
|
||||||
|
* Returns `null` if `input` is not a valid.
|
||||||
|
* @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
|
||||||
|
* `converted to a string` first.
|
||||||
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
||||||
|
* @since v22.1.0
|
||||||
|
*/
|
||||||
|
static parse(input: string, base?: string): URL | null;
|
||||||
|
constructor(input: string | { toString: () => string }, base?: string | URL);
|
||||||
|
/**
|
||||||
|
* Gets and sets the fragment portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/foo#bar');
|
||||||
|
* console.log(myURL.hash);
|
||||||
|
* // Prints #bar
|
||||||
|
*
|
||||||
|
* myURL.hash = 'baz';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/foo#baz
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid URL characters included in the value assigned to the `hash` property
|
||||||
|
* are `percent-encoded`. The selection of which characters to
|
||||||
|
* percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
||||||
|
*/
|
||||||
|
hash: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the host portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org:81/foo');
|
||||||
|
* console.log(myURL.host);
|
||||||
|
* // Prints example.org:81
|
||||||
|
*
|
||||||
|
* myURL.host = 'example.com:82';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.com:82/foo
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid host values assigned to the `host` property are ignored.
|
||||||
|
*/
|
||||||
|
host: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the host name portion of the URL. The key difference between`url.host` and `url.hostname` is that `url.hostname` does _not_ include the
|
||||||
|
* port.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org:81/foo');
|
||||||
|
* console.log(myURL.hostname);
|
||||||
|
* // Prints example.org
|
||||||
|
*
|
||||||
|
* // Setting the hostname does not change the port
|
||||||
|
* myURL.hostname = 'example.com';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.com:81/foo
|
||||||
|
*
|
||||||
|
* // Use myURL.host to change the hostname and port
|
||||||
|
* myURL.host = 'example.org:82';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org:82/foo
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid host name values assigned to the `hostname` property are ignored.
|
||||||
|
*/
|
||||||
|
hostname: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the serialized URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/foo');
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/foo
|
||||||
|
*
|
||||||
|
* myURL.href = 'https://example.com/bar';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.com/bar
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Getting the value of the `href` property is equivalent to calling {@link toString}.
|
||||||
|
*
|
||||||
|
* Setting the value of this property to a new value is equivalent to creating a
|
||||||
|
* new `URL` object using `new URL(value)`. Each of the `URL` object's properties will be modified.
|
||||||
|
*
|
||||||
|
* If the value assigned to the `href` property is not a valid URL, a `TypeError` will be thrown.
|
||||||
|
*/
|
||||||
|
href: string;
|
||||||
|
/**
|
||||||
|
* Gets the read-only serialization of the URL's origin.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/foo/bar?baz');
|
||||||
|
* console.log(myURL.origin);
|
||||||
|
* // Prints https://example.org
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const idnURL = new URL('https://測試');
|
||||||
|
* console.log(idnURL.origin);
|
||||||
|
* // Prints https://xn--g6w251d
|
||||||
|
*
|
||||||
|
* console.log(idnURL.hostname);
|
||||||
|
* // Prints xn--g6w251d
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
readonly origin: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the password portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://abc:xyz@example.com');
|
||||||
|
* console.log(myURL.password);
|
||||||
|
* // Prints xyz
|
||||||
|
*
|
||||||
|
* myURL.password = '123';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://abc:123@example.com/
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid URL characters included in the value assigned to the `password` property
|
||||||
|
* are `percent-encoded`. The selection of which characters to
|
||||||
|
* percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
||||||
|
*/
|
||||||
|
password: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the path portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/abc/xyz?123');
|
||||||
|
* console.log(myURL.pathname);
|
||||||
|
* // Prints /abc/xyz
|
||||||
|
*
|
||||||
|
* myURL.pathname = '/abcdef';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/abcdef?123
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
||||||
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
||||||
|
*/
|
||||||
|
pathname: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the port portion of the URL.
|
||||||
|
*
|
||||||
|
* The port value may be a number or a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will
|
||||||
|
* result in the `port` value becoming
|
||||||
|
* the empty string (`''`).
|
||||||
|
*
|
||||||
|
* The port value can be an empty string in which case the port depends on
|
||||||
|
* the protocol/scheme:
|
||||||
|
*
|
||||||
|
* <omitted>
|
||||||
|
*
|
||||||
|
* Upon assigning a value to the port, the value will first be converted to a
|
||||||
|
* string using `.toString()`.
|
||||||
|
*
|
||||||
|
* If that string is invalid but it begins with a number, the leading number is
|
||||||
|
* assigned to `port`.
|
||||||
|
* If the number lies outside the range denoted above, it is ignored.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org:8888');
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 8888
|
||||||
|
*
|
||||||
|
* // Default ports are automatically transformed to the empty string
|
||||||
|
* // (HTTPS protocol's default port is 443)
|
||||||
|
* myURL.port = '443';
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints the empty string
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/
|
||||||
|
*
|
||||||
|
* myURL.port = 1234;
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 1234
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org:1234/
|
||||||
|
*
|
||||||
|
* // Completely invalid port strings are ignored
|
||||||
|
* myURL.port = 'abcd';
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 1234
|
||||||
|
*
|
||||||
|
* // Leading numbers are treated as a port number
|
||||||
|
* myURL.port = '5678abcd';
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 5678
|
||||||
|
*
|
||||||
|
* // Non-integers are truncated
|
||||||
|
* myURL.port = 1234.5678;
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 1234
|
||||||
|
*
|
||||||
|
* // Out-of-range numbers which are not represented in scientific notation
|
||||||
|
* // will be ignored.
|
||||||
|
* myURL.port = 1e10; // 10000000000, will be range-checked as described below
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 1234
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Numbers which contain a decimal point,
|
||||||
|
* such as floating-point numbers or numbers in scientific notation,
|
||||||
|
* are not an exception to this rule.
|
||||||
|
* Leading numbers up to the decimal point will be set as the URL's port,
|
||||||
|
* assuming they are valid:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* myURL.port = 4.567e21;
|
||||||
|
* console.log(myURL.port);
|
||||||
|
* // Prints 4 (because it is the leading number in the string '4.567e21')
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
port: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the protocol portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org');
|
||||||
|
* console.log(myURL.protocol);
|
||||||
|
* // Prints https:
|
||||||
|
*
|
||||||
|
* myURL.protocol = 'ftp';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints ftp://example.org/
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Invalid URL protocol values assigned to the `protocol` property are ignored.
|
||||||
|
*/
|
||||||
|
protocol: string;
|
||||||
|
/**
|
||||||
|
* Gets and sets the serialized query portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/abc?123');
|
||||||
|
* console.log(myURL.search);
|
||||||
|
* // Prints ?123
|
||||||
|
*
|
||||||
|
* myURL.search = 'abc=xyz';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/abc?abc=xyz
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Any invalid URL characters appearing in the value assigned the `search` property will be `percent-encoded`. The selection of which
|
||||||
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
||||||
|
*/
|
||||||
|
search: string;
|
||||||
|
/**
|
||||||
|
* Gets the `URLSearchParams` object representing the query parameters of the
|
||||||
|
* URL. This property is read-only but the `URLSearchParams` object it provides
|
||||||
|
* can be used to mutate the URL instance; to replace the entirety of query
|
||||||
|
* parameters of the URL, use the {@link search} setter. See `URLSearchParams` documentation for details.
|
||||||
|
*
|
||||||
|
* Use care when using `.searchParams` to modify the `URL` because,
|
||||||
|
* per the WHATWG specification, the `URLSearchParams` object uses
|
||||||
|
* different rules to determine which characters to percent-encode. For
|
||||||
|
* instance, the `URL` object will not percent encode the ASCII tilde (`~`)
|
||||||
|
* character, while `URLSearchParams` will always encode it:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/abc?foo=~bar');
|
||||||
|
*
|
||||||
|
* console.log(myURL.search); // prints ?foo=~bar
|
||||||
|
*
|
||||||
|
* // Modify the URL via searchParams...
|
||||||
|
* myURL.searchParams.sort();
|
||||||
|
*
|
||||||
|
* console.log(myURL.search); // prints ?foo=%7Ebar
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
readonly searchParams: URLSearchParams;
|
||||||
|
/**
|
||||||
|
* Gets and sets the username portion of the URL.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://abc:xyz@example.com');
|
||||||
|
* console.log(myURL.username);
|
||||||
|
* // Prints abc
|
||||||
|
*
|
||||||
|
* myURL.username = '123';
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://123:xyz@example.com/
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
||||||
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
||||||
|
*/
|
||||||
|
username: string;
|
||||||
|
/**
|
||||||
|
* The `toString()` method on the `URL` object returns the serialized URL. The
|
||||||
|
* value returned is equivalent to that of {@link href} and {@link toJSON}.
|
||||||
|
*/
|
||||||
|
toString(): string;
|
||||||
|
/**
|
||||||
|
* The `toJSON()` method on the `URL` object returns the serialized URL. The
|
||||||
|
* value returned is equivalent to that of {@link href} and {@link toString}.
|
||||||
|
*
|
||||||
|
* This method is automatically called when an `URL` object is serialized
|
||||||
|
* with [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURLs = [
|
||||||
|
* new URL('https://www.example.com'),
|
||||||
|
* new URL('https://test.example.org'),
|
||||||
|
* ];
|
||||||
|
* console.log(JSON.stringify(myURLs));
|
||||||
|
* // Prints ["https://www.example.com/","https://test.example.org/"]
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
toJSON(): string;
|
||||||
|
}
|
||||||
|
interface URLSearchParamsIterator<T> extends NodeJS.Iterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
|
||||||
|
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
|
||||||
|
* four following constructors.
|
||||||
|
* The `URLSearchParams` class is also available on the global object.
|
||||||
|
*
|
||||||
|
* The WHATWG `URLSearchParams` interface and the `querystring` module have
|
||||||
|
* similar purpose, but the purpose of the `querystring` module is more
|
||||||
|
* general, as it allows the customization of delimiter characters (`&` and `=`).
|
||||||
|
* On the other hand, this API is designed purely for URL query strings.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/?abc=123');
|
||||||
|
* console.log(myURL.searchParams.get('abc'));
|
||||||
|
* // Prints 123
|
||||||
|
*
|
||||||
|
* myURL.searchParams.append('abc', 'xyz');
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/?abc=123&abc=xyz
|
||||||
|
*
|
||||||
|
* myURL.searchParams.delete('abc');
|
||||||
|
* myURL.searchParams.set('a', 'b');
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/?a=b
|
||||||
|
*
|
||||||
|
* const newSearchParams = new URLSearchParams(myURL.searchParams);
|
||||||
|
* // The above is equivalent to
|
||||||
|
* // const newSearchParams = new URLSearchParams(myURL.search);
|
||||||
|
*
|
||||||
|
* newSearchParams.append('a', 'c');
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/?a=b
|
||||||
|
* console.log(newSearchParams.toString());
|
||||||
|
* // Prints a=b&a=c
|
||||||
|
*
|
||||||
|
* // newSearchParams.toString() is implicitly called
|
||||||
|
* myURL.search = newSearchParams;
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/?a=b&a=c
|
||||||
|
* newSearchParams.delete('a');
|
||||||
|
* console.log(myURL.href);
|
||||||
|
* // Prints https://example.org/?a=b&a=c
|
||||||
|
* ```
|
||||||
|
* @since v7.5.0, v6.13.0
|
||||||
|
*/
|
||||||
|
class URLSearchParams implements Iterable<[string, string]> {
|
||||||
|
constructor(
|
||||||
|
init?:
|
||||||
|
| URLSearchParams
|
||||||
|
| string
|
||||||
|
| Record<string, string | readonly string[]>
|
||||||
|
| Iterable<[string, string]>
|
||||||
|
| ReadonlyArray<[string, string]>,
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Append a new name-value pair to the query string.
|
||||||
|
*/
|
||||||
|
append(name: string, value: string): void;
|
||||||
|
/**
|
||||||
|
* If `value` is provided, removes all name-value pairs
|
||||||
|
* where name is `name` and value is `value`.
|
||||||
|
*
|
||||||
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
||||||
|
*/
|
||||||
|
delete(name: string, value?: string): void;
|
||||||
|
/**
|
||||||
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
||||||
|
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
||||||
|
*
|
||||||
|
* Alias for `urlSearchParams[@@iterator]()`.
|
||||||
|
*/
|
||||||
|
entries(): URLSearchParamsIterator<[string, string]>;
|
||||||
|
/**
|
||||||
|
* Iterates over each name-value pair in the query and invokes the given function.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const myURL = new URL('https://example.org/?a=b&c=d');
|
||||||
|
* myURL.searchParams.forEach((value, name, searchParams) => {
|
||||||
|
* console.log(name, value, myURL.searchParams === searchParams);
|
||||||
|
* });
|
||||||
|
* // Prints:
|
||||||
|
* // a b true
|
||||||
|
* // c d true
|
||||||
|
* ```
|
||||||
|
* @param fn Invoked for each name-value pair in the query
|
||||||
|
* @param thisArg To be used as `this` value for when `fn` is called
|
||||||
|
*/
|
||||||
|
forEach<TThis = this>(
|
||||||
|
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
||||||
|
thisArg?: TThis,
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Returns the value of the first name-value pair whose name is `name`. If there
|
||||||
|
* are no such pairs, `null` is returned.
|
||||||
|
* @return or `null` if there is no name-value pair with the given `name`.
|
||||||
|
*/
|
||||||
|
get(name: string): string | null;
|
||||||
|
/**
|
||||||
|
* Returns the values of all name-value pairs whose name is `name`. If there are
|
||||||
|
* no such pairs, an empty array is returned.
|
||||||
|
*/
|
||||||
|
getAll(name: string): string[];
|
||||||
|
/**
|
||||||
|
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
||||||
|
*
|
||||||
|
* If `value` is provided, returns `true` when name-value pair with
|
||||||
|
* same `name` and `value` exists.
|
||||||
|
*
|
||||||
|
* If `value` is not provided, returns `true` if there is at least one name-value
|
||||||
|
* pair whose name is `name`.
|
||||||
|
*/
|
||||||
|
has(name: string, value?: string): boolean;
|
||||||
|
/**
|
||||||
|
* Returns an ES6 `Iterator` over the names of each name-value pair.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const params = new URLSearchParams('foo=bar&foo=baz');
|
||||||
|
* for (const name of params.keys()) {
|
||||||
|
* console.log(name);
|
||||||
|
* }
|
||||||
|
* // Prints:
|
||||||
|
* // foo
|
||||||
|
* // foo
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
keys(): URLSearchParamsIterator<string>;
|
||||||
|
/**
|
||||||
|
* Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
|
||||||
|
* set the first such pair's value to `value` and remove all others. If not,
|
||||||
|
* append the name-value pair to the query string.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const params = new URLSearchParams();
|
||||||
|
* params.append('foo', 'bar');
|
||||||
|
* params.append('foo', 'baz');
|
||||||
|
* params.append('abc', 'def');
|
||||||
|
* console.log(params.toString());
|
||||||
|
* // Prints foo=bar&foo=baz&abc=def
|
||||||
|
*
|
||||||
|
* params.set('foo', 'def');
|
||||||
|
* params.set('xyz', 'opq');
|
||||||
|
* console.log(params.toString());
|
||||||
|
* // Prints foo=def&abc=def&xyz=opq
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
set(name: string, value: string): void;
|
||||||
|
/**
|
||||||
|
* The total number of parameter entries.
|
||||||
|
* @since v19.8.0
|
||||||
|
*/
|
||||||
|
readonly size: number;
|
||||||
|
/**
|
||||||
|
* Sort all existing name-value pairs in-place by their names. Sorting is done
|
||||||
|
* with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
|
||||||
|
* with the same name is preserved.
|
||||||
|
*
|
||||||
|
* This method can be used, in particular, to increase cache hits.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const params = new URLSearchParams('query[]=abc&type=search&query[]=123');
|
||||||
|
* params.sort();
|
||||||
|
* console.log(params.toString());
|
||||||
|
* // Prints query%5B%5D=abc&query%5B%5D=123&type=search
|
||||||
|
* ```
|
||||||
|
* @since v7.7.0, v6.13.0
|
||||||
|
*/
|
||||||
|
sort(): void;
|
||||||
|
/**
|
||||||
|
* Returns the search parameters serialized as a string, with characters
|
||||||
|
* percent-encoded where necessary.
|
||||||
|
*/
|
||||||
|
toString(): string;
|
||||||
|
/**
|
||||||
|
* Returns an ES6 `Iterator` over the values of each name-value pair.
|
||||||
|
*/
|
||||||
|
values(): URLSearchParamsIterator<string>;
|
||||||
|
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||||
|
}
|
||||||
|
import { URL as _URL, URLSearchParams as _URLSearchParams } from "url";
|
||||||
|
global {
|
||||||
|
interface URLSearchParams extends _URLSearchParams {}
|
||||||
|
interface URL extends _URL {}
|
||||||
|
interface Global {
|
||||||
|
URL: typeof _URL;
|
||||||
|
URLSearchParams: typeof _URLSearchParams;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* `URL` class is a global reference for `import { URL } from 'url'`
|
||||||
|
* https://nodejs.org/api/url.html#the-whatwg-url-api
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
var URL: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
URL: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _URL;
|
||||||
|
/**
|
||||||
|
* `URLSearchParams` class is a global reference for `import { URLSearchParams } from 'node:url'`
|
||||||
|
* https://nodejs.org/api/url.html#class-urlsearchparams
|
||||||
|
* @since v10.0.0
|
||||||
|
*/
|
||||||
|
var URLSearchParams: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
URLSearchParams: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _URLSearchParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:url" {
|
||||||
|
export * from "url";
|
||||||
|
}
|
2301
websocket_server/node_modules/.ignored/@types/node/util.d.ts
generated
vendored
Normal file
2301
websocket_server/node_modules/.ignored/@types/node/util.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
808
websocket_server/node_modules/.ignored/@types/node/v8.d.ts
generated
vendored
Normal file
808
websocket_server/node_modules/.ignored/@types/node/v8.d.ts
generated
vendored
Normal file
@ -0,0 +1,808 @@
|
|||||||
|
/**
|
||||||
|
* The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import v8 from 'node:v8';
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/v8.js)
|
||||||
|
*/
|
||||||
|
declare module "v8" {
|
||||||
|
import { Readable } from "node:stream";
|
||||||
|
interface HeapSpaceInfo {
|
||||||
|
space_name: string;
|
||||||
|
space_size: number;
|
||||||
|
space_used_size: number;
|
||||||
|
space_available_size: number;
|
||||||
|
physical_space_size: number;
|
||||||
|
}
|
||||||
|
// ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
|
||||||
|
type DoesZapCodeSpaceFlag = 0 | 1;
|
||||||
|
interface HeapInfo {
|
||||||
|
total_heap_size: number;
|
||||||
|
total_heap_size_executable: number;
|
||||||
|
total_physical_size: number;
|
||||||
|
total_available_size: number;
|
||||||
|
used_heap_size: number;
|
||||||
|
heap_size_limit: number;
|
||||||
|
malloced_memory: number;
|
||||||
|
peak_malloced_memory: number;
|
||||||
|
does_zap_garbage: DoesZapCodeSpaceFlag;
|
||||||
|
number_of_native_contexts: number;
|
||||||
|
number_of_detached_contexts: number;
|
||||||
|
total_global_handles_size: number;
|
||||||
|
used_global_handles_size: number;
|
||||||
|
external_memory: number;
|
||||||
|
}
|
||||||
|
interface HeapCodeStatistics {
|
||||||
|
code_and_metadata_size: number;
|
||||||
|
bytecode_and_metadata_size: number;
|
||||||
|
external_script_source_size: number;
|
||||||
|
}
|
||||||
|
interface HeapSnapshotOptions {
|
||||||
|
/**
|
||||||
|
* If true, expose internals in the heap snapshot.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
exposeInternals?: boolean;
|
||||||
|
/**
|
||||||
|
* If true, expose numeric values in artificial fields.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
exposeNumericValues?: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns an integer representing a version tag derived from the V8 version,
|
||||||
|
* command-line flags, and detected CPU features. This is useful for determining
|
||||||
|
* whether a `vm.Script` `cachedData` buffer is compatible with this instance
|
||||||
|
* of V8.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* console.log(v8.cachedDataVersionTag()); // 3947234607
|
||||||
|
* // The value returned by v8.cachedDataVersionTag() is derived from the V8
|
||||||
|
* // version, command-line flags, and detected CPU features. Test that the value
|
||||||
|
* // does indeed update when flags are toggled.
|
||||||
|
* v8.setFlagsFromString('--allow_natives_syntax');
|
||||||
|
* console.log(v8.cachedDataVersionTag()); // 183726201
|
||||||
|
* ```
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
function cachedDataVersionTag(): number;
|
||||||
|
/**
|
||||||
|
* Returns an object with the following properties:
|
||||||
|
*
|
||||||
|
* `does_zap_garbage` is a 0/1 boolean, which signifies whether the `--zap_code_space` option is enabled or not. This makes V8 overwrite heap
|
||||||
|
* garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
|
||||||
|
* because it continuously touches all heap pages and that makes them less likely
|
||||||
|
* to get swapped out by the operating system.
|
||||||
|
*
|
||||||
|
* `number_of_native_contexts` The value of native\_context is the number of the
|
||||||
|
* top-level contexts currently active. Increase of this number over time indicates
|
||||||
|
* a memory leak.
|
||||||
|
*
|
||||||
|
* `number_of_detached_contexts` The value of detached\_context is the number
|
||||||
|
* of contexts that were detached and not yet garbage collected. This number
|
||||||
|
* being non-zero indicates a potential memory leak.
|
||||||
|
*
|
||||||
|
* `total_global_handles_size` The value of total\_global\_handles\_size is the
|
||||||
|
* total memory size of V8 global handles.
|
||||||
|
*
|
||||||
|
* `used_global_handles_size` The value of used\_global\_handles\_size is the
|
||||||
|
* used memory size of V8 global handles.
|
||||||
|
*
|
||||||
|
* `external_memory` The value of external\_memory is the memory size of array
|
||||||
|
* buffers and external strings.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* total_heap_size: 7326976,
|
||||||
|
* total_heap_size_executable: 4194304,
|
||||||
|
* total_physical_size: 7326976,
|
||||||
|
* total_available_size: 1152656,
|
||||||
|
* used_heap_size: 3476208,
|
||||||
|
* heap_size_limit: 1535115264,
|
||||||
|
* malloced_memory: 16384,
|
||||||
|
* peak_malloced_memory: 1127496,
|
||||||
|
* does_zap_garbage: 0,
|
||||||
|
* number_of_native_contexts: 1,
|
||||||
|
* number_of_detached_contexts: 0,
|
||||||
|
* total_global_handles_size: 8192,
|
||||||
|
* used_global_handles_size: 3296,
|
||||||
|
* external_memory: 318824
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v1.0.0
|
||||||
|
*/
|
||||||
|
function getHeapStatistics(): HeapInfo;
|
||||||
|
/**
|
||||||
|
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
||||||
|
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
||||||
|
* heap space can be guaranteed as the statistics are provided via the
|
||||||
|
* V8 [`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
||||||
|
* next.
|
||||||
|
*
|
||||||
|
* The value returned is an array of objects containing the following properties:
|
||||||
|
*
|
||||||
|
* ```json
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* "space_name": "new_space",
|
||||||
|
* "space_size": 2063872,
|
||||||
|
* "space_used_size": 951112,
|
||||||
|
* "space_available_size": 80824,
|
||||||
|
* "physical_space_size": 2063872
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* "space_name": "old_space",
|
||||||
|
* "space_size": 3090560,
|
||||||
|
* "space_used_size": 2493792,
|
||||||
|
* "space_available_size": 0,
|
||||||
|
* "physical_space_size": 3090560
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* "space_name": "code_space",
|
||||||
|
* "space_size": 1260160,
|
||||||
|
* "space_used_size": 644256,
|
||||||
|
* "space_available_size": 960,
|
||||||
|
* "physical_space_size": 1260160
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* "space_name": "map_space",
|
||||||
|
* "space_size": 1094160,
|
||||||
|
* "space_used_size": 201608,
|
||||||
|
* "space_available_size": 0,
|
||||||
|
* "physical_space_size": 1094160
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* "space_name": "large_object_space",
|
||||||
|
* "space_size": 0,
|
||||||
|
* "space_used_size": 0,
|
||||||
|
* "space_available_size": 1490980608,
|
||||||
|
* "physical_space_size": 0
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* ```
|
||||||
|
* @since v6.0.0
|
||||||
|
*/
|
||||||
|
function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
||||||
|
/**
|
||||||
|
* The `v8.setFlagsFromString()` method can be used to programmatically set
|
||||||
|
* V8 command-line flags. This method should be used with care. Changing settings
|
||||||
|
* after the VM has started may result in unpredictable behavior, including
|
||||||
|
* crashes and data loss; or it may simply do nothing.
|
||||||
|
*
|
||||||
|
* The V8 options available for a version of Node.js may be determined by running `node --v8-options`.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Print GC events to stdout for one minute.
|
||||||
|
* import v8 from 'node:v8';
|
||||||
|
* v8.setFlagsFromString('--trace_gc');
|
||||||
|
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
||||||
|
* ```
|
||||||
|
* @since v1.0.0
|
||||||
|
*/
|
||||||
|
function setFlagsFromString(flags: string): void;
|
||||||
|
/**
|
||||||
|
* This is similar to the [`queryObjects()` console API](https://developer.chrome.com/docs/devtools/console/utilities#queryObjects-function)
|
||||||
|
* provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain
|
||||||
|
* in the heap after a full garbage collection, which can be useful for memory leak regression tests. To avoid surprising results, users should
|
||||||
|
* avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the
|
||||||
|
* application.
|
||||||
|
*
|
||||||
|
* To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects
|
||||||
|
* found. If `options.format` is `'summary'`, it returns an array containing brief string representations for each object. The visibility provided
|
||||||
|
* in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filter the
|
||||||
|
* target objects during the search.
|
||||||
|
*
|
||||||
|
* Only objects created in the current execution context are included in the results.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { queryObjects } from 'node:v8';
|
||||||
|
* class A { foo = 'bar'; }
|
||||||
|
* console.log(queryObjects(A)); // 0
|
||||||
|
* const a = new A();
|
||||||
|
* console.log(queryObjects(A)); // 1
|
||||||
|
* // [ "A { foo: 'bar' }" ]
|
||||||
|
* console.log(queryObjects(A, { format: 'summary' }));
|
||||||
|
*
|
||||||
|
* class B extends A { bar = 'qux'; }
|
||||||
|
* const b = new B();
|
||||||
|
* console.log(queryObjects(B)); // 1
|
||||||
|
* // [ "B { foo: 'bar', bar: 'qux' }" ]
|
||||||
|
* console.log(queryObjects(B, { format: 'summary' }));
|
||||||
|
*
|
||||||
|
* // Note that, when there are child classes inheriting from a constructor,
|
||||||
|
* // the constructor also shows up in the prototype chain of the child
|
||||||
|
* // classes's prototoype, so the child classes's prototoype would also be
|
||||||
|
* // included in the result.
|
||||||
|
* console.log(queryObjects(A)); // 3
|
||||||
|
* // [ "B { foo: 'bar', bar: 'qux' }", 'A {}', "A { foo: 'bar' }" ]
|
||||||
|
* console.log(queryObjects(A, { format: 'summary' }));
|
||||||
|
* ```
|
||||||
|
* @param ctor The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.
|
||||||
|
* @since v20.13.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
function queryObjects(ctor: Function): number | string[];
|
||||||
|
function queryObjects(ctor: Function, options: { format: "count" }): number;
|
||||||
|
function queryObjects(ctor: Function, options: { format: "summary" }): string[];
|
||||||
|
/**
|
||||||
|
* Generates a snapshot of the current V8 heap and returns a Readable
|
||||||
|
* Stream that may be used to read the JSON serialized representation.
|
||||||
|
* This JSON stream format is intended to be used with tools such as
|
||||||
|
* Chrome DevTools. The JSON schema is undocumented and specific to the
|
||||||
|
* V8 engine. Therefore, the schema may change from one version of V8 to the next.
|
||||||
|
*
|
||||||
|
* Creating a heap snapshot requires memory about twice the size of the heap at
|
||||||
|
* the time the snapshot is created. This results in the risk of OOM killers
|
||||||
|
* terminating the process.
|
||||||
|
*
|
||||||
|
* Generating a snapshot is a synchronous operation which blocks the event loop
|
||||||
|
* for a duration depending on the heap size.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Print heap snapshot to the console
|
||||||
|
* import v8 from 'node:v8';
|
||||||
|
* const stream = v8.getHeapSnapshot();
|
||||||
|
* stream.pipe(process.stdout);
|
||||||
|
* ```
|
||||||
|
* @since v11.13.0
|
||||||
|
* @return A Readable containing the V8 heap snapshot.
|
||||||
|
*/
|
||||||
|
function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
|
||||||
|
/**
|
||||||
|
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
||||||
|
* file. This file is intended to be used with tools such as Chrome
|
||||||
|
* DevTools. The JSON schema is undocumented and specific to the V8
|
||||||
|
* engine, and may change from one version of V8 to the next.
|
||||||
|
*
|
||||||
|
* A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
|
||||||
|
* not contain any information about the workers, and vice versa.
|
||||||
|
*
|
||||||
|
* Creating a heap snapshot requires memory about twice the size of the heap at
|
||||||
|
* the time the snapshot is created. This results in the risk of OOM killers
|
||||||
|
* terminating the process.
|
||||||
|
*
|
||||||
|
* Generating a snapshot is a synchronous operation which blocks the event loop
|
||||||
|
* for a duration depending on the heap size.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { writeHeapSnapshot } from 'node:v8';
|
||||||
|
* import {
|
||||||
|
* Worker,
|
||||||
|
* isMainThread,
|
||||||
|
* parentPort,
|
||||||
|
* } from 'node:worker_threads';
|
||||||
|
*
|
||||||
|
* if (isMainThread) {
|
||||||
|
* const worker = new Worker(__filename);
|
||||||
|
*
|
||||||
|
* worker.once('message', (filename) => {
|
||||||
|
* console.log(`worker heapdump: ${filename}`);
|
||||||
|
* // Now get a heapdump for the main thread.
|
||||||
|
* console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Tell the worker to create a heapdump.
|
||||||
|
* worker.postMessage('heapdump');
|
||||||
|
* } else {
|
||||||
|
* parentPort.once('message', (message) => {
|
||||||
|
* if (message === 'heapdump') {
|
||||||
|
* // Generate a heapdump for the worker
|
||||||
|
* // and return the filename to the parent.
|
||||||
|
* parentPort.postMessage(writeHeapSnapshot());
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v11.13.0
|
||||||
|
* @param filename The file path where the V8 heap snapshot is to be saved. If not specified, a file name with the pattern `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
|
||||||
|
* generated, where `{pid}` will be the PID of the Node.js process, `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from the main Node.js thread or the id of a
|
||||||
|
* worker thread.
|
||||||
|
* @return The filename where the snapshot was saved.
|
||||||
|
*/
|
||||||
|
function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
|
||||||
|
/**
|
||||||
|
* Get statistics about code and its metadata in the heap, see
|
||||||
|
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
||||||
|
* following properties:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* code_and_metadata_size: 212208,
|
||||||
|
* bytecode_and_metadata_size: 161368,
|
||||||
|
* external_script_source_size: 1410794,
|
||||||
|
* cpu_profiler_metadata_size: 0,
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v12.8.0
|
||||||
|
*/
|
||||||
|
function getHeapCodeStatistics(): HeapCodeStatistics;
|
||||||
|
/**
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
class Serializer {
|
||||||
|
/**
|
||||||
|
* Writes out a header, which includes the serialization format version.
|
||||||
|
*/
|
||||||
|
writeHeader(): void;
|
||||||
|
/**
|
||||||
|
* Serializes a JavaScript value and adds the serialized representation to the
|
||||||
|
* internal buffer.
|
||||||
|
*
|
||||||
|
* This throws an error if `value` cannot be serialized.
|
||||||
|
*/
|
||||||
|
writeValue(val: any): boolean;
|
||||||
|
/**
|
||||||
|
* Returns the stored internal buffer. This serializer should not be used once
|
||||||
|
* the buffer is released. Calling this method results in undefined behavior
|
||||||
|
* if a previous write has failed.
|
||||||
|
*/
|
||||||
|
releaseBuffer(): Buffer;
|
||||||
|
/**
|
||||||
|
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
||||||
|
* Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
|
||||||
|
* @param id A 32-bit unsigned integer.
|
||||||
|
* @param arrayBuffer An `ArrayBuffer` instance.
|
||||||
|
*/
|
||||||
|
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
||||||
|
/**
|
||||||
|
* Write a raw 32-bit unsigned integer.
|
||||||
|
* For use inside of a custom `serializer._writeHostObject()`.
|
||||||
|
*/
|
||||||
|
writeUint32(value: number): void;
|
||||||
|
/**
|
||||||
|
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
|
||||||
|
* For use inside of a custom `serializer._writeHostObject()`.
|
||||||
|
*/
|
||||||
|
writeUint64(hi: number, lo: number): void;
|
||||||
|
/**
|
||||||
|
* Write a JS `number` value.
|
||||||
|
* For use inside of a custom `serializer._writeHostObject()`.
|
||||||
|
*/
|
||||||
|
writeDouble(value: number): void;
|
||||||
|
/**
|
||||||
|
* Write raw bytes into the serializer's internal buffer. The deserializer
|
||||||
|
* will require a way to compute the length of the buffer.
|
||||||
|
* For use inside of a custom `serializer._writeHostObject()`.
|
||||||
|
*/
|
||||||
|
writeRawBytes(buffer: NodeJS.TypedArray): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
|
||||||
|
* stores the part of their underlying `ArrayBuffer`s that they are referring to.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
class DefaultSerializer extends Serializer {}
|
||||||
|
/**
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
class Deserializer {
|
||||||
|
constructor(data: NodeJS.TypedArray);
|
||||||
|
/**
|
||||||
|
* Reads and validates a header (including the format version).
|
||||||
|
* May, for example, reject an invalid or unsupported wire format. In that case,
|
||||||
|
* an `Error` is thrown.
|
||||||
|
*/
|
||||||
|
readHeader(): boolean;
|
||||||
|
/**
|
||||||
|
* Deserializes a JavaScript value from the buffer and returns it.
|
||||||
|
*/
|
||||||
|
readValue(): any;
|
||||||
|
/**
|
||||||
|
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
||||||
|
* Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
|
||||||
|
* `SharedArrayBuffer`s).
|
||||||
|
* @param id A 32-bit unsigned integer.
|
||||||
|
* @param arrayBuffer An `ArrayBuffer` instance.
|
||||||
|
*/
|
||||||
|
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
||||||
|
/**
|
||||||
|
* Reads the underlying wire format version. Likely mostly to be useful to
|
||||||
|
* legacy code reading old wire format versions. May not be called before `.readHeader()`.
|
||||||
|
*/
|
||||||
|
getWireFormatVersion(): number;
|
||||||
|
/**
|
||||||
|
* Read a raw 32-bit unsigned integer and return it.
|
||||||
|
* For use inside of a custom `deserializer._readHostObject()`.
|
||||||
|
*/
|
||||||
|
readUint32(): number;
|
||||||
|
/**
|
||||||
|
* Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]` with two 32-bit unsigned integer entries.
|
||||||
|
* For use inside of a custom `deserializer._readHostObject()`.
|
||||||
|
*/
|
||||||
|
readUint64(): [number, number];
|
||||||
|
/**
|
||||||
|
* Read a JS `number` value.
|
||||||
|
* For use inside of a custom `deserializer._readHostObject()`.
|
||||||
|
*/
|
||||||
|
readDouble(): number;
|
||||||
|
/**
|
||||||
|
* Read raw bytes from the deserializer's internal buffer. The `length` parameter
|
||||||
|
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
||||||
|
* For use inside of a custom `deserializer._readHostObject()`.
|
||||||
|
*/
|
||||||
|
readRawBytes(length: number): Buffer;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
class DefaultDeserializer extends Deserializer {}
|
||||||
|
/**
|
||||||
|
* Uses a `DefaultSerializer` to serialize `value` into a buffer.
|
||||||
|
*
|
||||||
|
* `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
|
||||||
|
* serialize a huge object which requires buffer
|
||||||
|
* larger than `buffer.constants.MAX_LENGTH`.
|
||||||
|
* @since v8.0.0
|
||||||
|
*/
|
||||||
|
function serialize(value: any): Buffer;
|
||||||
|
/**
|
||||||
|
* Uses a `DefaultDeserializer` with default options to read a JS value
|
||||||
|
* from a buffer.
|
||||||
|
* @since v8.0.0
|
||||||
|
* @param buffer A buffer returned by {@link serialize}.
|
||||||
|
*/
|
||||||
|
function deserialize(buffer: NodeJS.TypedArray): any;
|
||||||
|
/**
|
||||||
|
* The `v8.takeCoverage()` method allows the user to write the coverage started by `NODE_V8_COVERAGE` to disk on demand. This method can be invoked multiple
|
||||||
|
* times during the lifetime of the process. Each time the execution counter will
|
||||||
|
* be reset and a new coverage report will be written to the directory specified
|
||||||
|
* by `NODE_V8_COVERAGE`.
|
||||||
|
*
|
||||||
|
* When the process is about to exit, one last coverage will still be written to
|
||||||
|
* disk unless {@link stopCoverage} is invoked before the process exits.
|
||||||
|
* @since v15.1.0, v14.18.0, v12.22.0
|
||||||
|
*/
|
||||||
|
function takeCoverage(): void;
|
||||||
|
/**
|
||||||
|
* The `v8.stopCoverage()` method allows the user to stop the coverage collection
|
||||||
|
* started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
|
||||||
|
* records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
|
||||||
|
* @since v15.1.0, v14.18.0, v12.22.0
|
||||||
|
*/
|
||||||
|
function stopCoverage(): void;
|
||||||
|
/**
|
||||||
|
* The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
|
||||||
|
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
||||||
|
* @experimental
|
||||||
|
* @since v18.10.0, v16.18.0
|
||||||
|
*/
|
||||||
|
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
||||||
|
/**
|
||||||
|
* This API collects GC data in current thread.
|
||||||
|
* @since v19.6.0, v18.15.0
|
||||||
|
*/
|
||||||
|
class GCProfiler {
|
||||||
|
/**
|
||||||
|
* Start collecting GC data.
|
||||||
|
* @since v19.6.0, v18.15.0
|
||||||
|
*/
|
||||||
|
start(): void;
|
||||||
|
/**
|
||||||
|
* Stop collecting GC data and return an object. The content of object
|
||||||
|
* is as follows.
|
||||||
|
*
|
||||||
|
* ```json
|
||||||
|
* {
|
||||||
|
* "version": 1,
|
||||||
|
* "startTime": 1674059033862,
|
||||||
|
* "statistics": [
|
||||||
|
* {
|
||||||
|
* "gcType": "Scavenge",
|
||||||
|
* "beforeGC": {
|
||||||
|
* "heapStatistics": {
|
||||||
|
* "totalHeapSize": 5005312,
|
||||||
|
* "totalHeapSizeExecutable": 524288,
|
||||||
|
* "totalPhysicalSize": 5226496,
|
||||||
|
* "totalAvailableSize": 4341325216,
|
||||||
|
* "totalGlobalHandlesSize": 8192,
|
||||||
|
* "usedGlobalHandlesSize": 2112,
|
||||||
|
* "usedHeapSize": 4883840,
|
||||||
|
* "heapSizeLimit": 4345298944,
|
||||||
|
* "mallocedMemory": 254128,
|
||||||
|
* "externalMemory": 225138,
|
||||||
|
* "peakMallocedMemory": 181760
|
||||||
|
* },
|
||||||
|
* "heapSpaceStatistics": [
|
||||||
|
* {
|
||||||
|
* "spaceName": "read_only_space",
|
||||||
|
* "spaceSize": 0,
|
||||||
|
* "spaceUsedSize": 0,
|
||||||
|
* "spaceAvailableSize": 0,
|
||||||
|
* "physicalSpaceSize": 0
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* },
|
||||||
|
* "cost": 1574.14,
|
||||||
|
* "afterGC": {
|
||||||
|
* "heapStatistics": {
|
||||||
|
* "totalHeapSize": 6053888,
|
||||||
|
* "totalHeapSizeExecutable": 524288,
|
||||||
|
* "totalPhysicalSize": 5500928,
|
||||||
|
* "totalAvailableSize": 4341101384,
|
||||||
|
* "totalGlobalHandlesSize": 8192,
|
||||||
|
* "usedGlobalHandlesSize": 2112,
|
||||||
|
* "usedHeapSize": 4059096,
|
||||||
|
* "heapSizeLimit": 4345298944,
|
||||||
|
* "mallocedMemory": 254128,
|
||||||
|
* "externalMemory": 225138,
|
||||||
|
* "peakMallocedMemory": 181760
|
||||||
|
* },
|
||||||
|
* "heapSpaceStatistics": [
|
||||||
|
* {
|
||||||
|
* "spaceName": "read_only_space",
|
||||||
|
* "spaceSize": 0,
|
||||||
|
* "spaceUsedSize": 0,
|
||||||
|
* "spaceAvailableSize": 0,
|
||||||
|
* "physicalSpaceSize": 0
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ],
|
||||||
|
* "endTime": 1674059036865
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Here's an example.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { GCProfiler } from 'node:v8';
|
||||||
|
* const profiler = new GCProfiler();
|
||||||
|
* profiler.start();
|
||||||
|
* setTimeout(() => {
|
||||||
|
* console.log(profiler.stop());
|
||||||
|
* }, 1000);
|
||||||
|
* ```
|
||||||
|
* @since v19.6.0, v18.15.0
|
||||||
|
*/
|
||||||
|
stop(): GCProfilerResult;
|
||||||
|
}
|
||||||
|
interface GCProfilerResult {
|
||||||
|
version: number;
|
||||||
|
startTime: number;
|
||||||
|
endTime: number;
|
||||||
|
statistics: Array<{
|
||||||
|
gcType: string;
|
||||||
|
cost: number;
|
||||||
|
beforeGC: {
|
||||||
|
heapStatistics: HeapStatistics;
|
||||||
|
heapSpaceStatistics: HeapSpaceStatistics[];
|
||||||
|
};
|
||||||
|
afterGC: {
|
||||||
|
heapStatistics: HeapStatistics;
|
||||||
|
heapSpaceStatistics: HeapSpaceStatistics[];
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
interface HeapStatistics {
|
||||||
|
totalHeapSize: number;
|
||||||
|
totalHeapSizeExecutable: number;
|
||||||
|
totalPhysicalSize: number;
|
||||||
|
totalAvailableSize: number;
|
||||||
|
totalGlobalHandlesSize: number;
|
||||||
|
usedGlobalHandlesSize: number;
|
||||||
|
usedHeapSize: number;
|
||||||
|
heapSizeLimit: number;
|
||||||
|
mallocedMemory: number;
|
||||||
|
externalMemory: number;
|
||||||
|
peakMallocedMemory: number;
|
||||||
|
}
|
||||||
|
interface HeapSpaceStatistics {
|
||||||
|
spaceName: string;
|
||||||
|
spaceSize: number;
|
||||||
|
spaceUsedSize: number;
|
||||||
|
spaceAvailableSize: number;
|
||||||
|
physicalSpaceSize: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
|
||||||
|
* happen if a promise is created without ever getting a continuation.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param promise The promise being created.
|
||||||
|
* @param parent The promise continued from, if applicable.
|
||||||
|
*/
|
||||||
|
interface Init {
|
||||||
|
(promise: Promise<unknown>, parent: Promise<unknown>): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
|
||||||
|
*
|
||||||
|
* The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
|
||||||
|
* The before callback may be called many times in the case where many continuations have been made from the same promise.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
*/
|
||||||
|
interface Before {
|
||||||
|
(promise: Promise<unknown>): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
*/
|
||||||
|
interface After {
|
||||||
|
(promise: Promise<unknown>): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
|
||||||
|
* {@link Promise.reject()}.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
*/
|
||||||
|
interface Settled {
|
||||||
|
(promise: Promise<unknown>): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
|
||||||
|
* around an await, and when the promise resolves or rejects.
|
||||||
|
*
|
||||||
|
* Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
|
||||||
|
* `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
*/
|
||||||
|
interface HookCallbacks {
|
||||||
|
init?: Init;
|
||||||
|
before?: Before;
|
||||||
|
after?: After;
|
||||||
|
settled?: Settled;
|
||||||
|
}
|
||||||
|
interface PromiseHooks {
|
||||||
|
/**
|
||||||
|
* The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param init The {@link Init | `init` callback} to call when a promise is created.
|
||||||
|
* @return Call to stop the hook.
|
||||||
|
*/
|
||||||
|
onInit: (init: Init) => Function;
|
||||||
|
/**
|
||||||
|
* The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param settled The {@link Settled | `settled` callback} to call when a promise is created.
|
||||||
|
* @return Call to stop the hook.
|
||||||
|
*/
|
||||||
|
onSettled: (settled: Settled) => Function;
|
||||||
|
/**
|
||||||
|
* The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param before The {@link Before | `before` callback} to call before a promise continuation executes.
|
||||||
|
* @return Call to stop the hook.
|
||||||
|
*/
|
||||||
|
onBefore: (before: Before) => Function;
|
||||||
|
/**
|
||||||
|
* The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param after The {@link After | `after` callback} to call after a promise continuation executes.
|
||||||
|
* @return Call to stop the hook.
|
||||||
|
*/
|
||||||
|
onAfter: (after: After) => Function;
|
||||||
|
/**
|
||||||
|
* Registers functions to be called for different lifetime events of each promise.
|
||||||
|
* The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
|
||||||
|
* All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
|
||||||
|
* The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
* @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
|
||||||
|
* @return Used for disabling hooks
|
||||||
|
*/
|
||||||
|
createHook: (callbacks: HookCallbacks) => Function;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `promiseHooks` interface can be used to track promise lifecycle events.
|
||||||
|
* @since v17.1.0, v16.14.0
|
||||||
|
*/
|
||||||
|
const promiseHooks: PromiseHooks;
|
||||||
|
type StartupSnapshotCallbackFn = (args: any) => any;
|
||||||
|
interface StartupSnapshot {
|
||||||
|
/**
|
||||||
|
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
||||||
|
* This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
|
||||||
|
* @since v18.6.0, v16.17.0
|
||||||
|
*/
|
||||||
|
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
||||||
|
/**
|
||||||
|
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
||||||
|
* The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
|
||||||
|
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
||||||
|
* @since v18.6.0, v16.17.0
|
||||||
|
*/
|
||||||
|
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
||||||
|
/**
|
||||||
|
* This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
|
||||||
|
* If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
|
||||||
|
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
||||||
|
* @since v18.6.0, v16.17.0
|
||||||
|
*/
|
||||||
|
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
||||||
|
/**
|
||||||
|
* Returns true if the Node.js instance is run to build a snapshot.
|
||||||
|
* @since v18.6.0, v16.17.0
|
||||||
|
*/
|
||||||
|
isBuildingSnapshot(): boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
||||||
|
* # This launches a process with the snapshot
|
||||||
|
* $ node --snapshot-blob snapshot.blob
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
||||||
|
* in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
||||||
|
* For example, if the `entry.js` contains the following script:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* 'use strict';
|
||||||
|
*
|
||||||
|
* import fs from 'node:fs';
|
||||||
|
* import zlib from 'node:zlib';
|
||||||
|
* import path from 'node:path';
|
||||||
|
* import assert from 'node:assert';
|
||||||
|
*
|
||||||
|
* import v8 from 'node:v8';
|
||||||
|
*
|
||||||
|
* class BookShelf {
|
||||||
|
* storage = new Map();
|
||||||
|
*
|
||||||
|
* // Reading a series of files from directory and store them into storage.
|
||||||
|
* constructor(directory, books) {
|
||||||
|
* for (const book of books) {
|
||||||
|
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* static compressAll(shelf) {
|
||||||
|
* for (const [ book, content ] of shelf.storage) {
|
||||||
|
* shelf.storage.set(book, zlib.gzipSync(content));
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* static decompressAll(shelf) {
|
||||||
|
* for (const [ book, content ] of shelf.storage) {
|
||||||
|
* shelf.storage.set(book, zlib.gunzipSync(content));
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // __dirname here is where the snapshot script is placed
|
||||||
|
* // during snapshot building time.
|
||||||
|
* const shelf = new BookShelf(__dirname, [
|
||||||
|
* 'book1.en_US.txt',
|
||||||
|
* 'book1.es_ES.txt',
|
||||||
|
* 'book2.zh_CN.txt',
|
||||||
|
* ]);
|
||||||
|
*
|
||||||
|
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
||||||
|
* // On snapshot serialization, compress the books to reduce size.
|
||||||
|
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
||||||
|
* // On snapshot deserialization, decompress the books.
|
||||||
|
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
||||||
|
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
||||||
|
* // process.env and process.argv are refreshed during snapshot
|
||||||
|
* // deserialization.
|
||||||
|
* const lang = process.env.BOOK_LANG || 'en_US';
|
||||||
|
* const book = process.argv[1];
|
||||||
|
* const name = `${book}.${lang}.txt`;
|
||||||
|
* console.log(shelf.storage.get(name));
|
||||||
|
* }, shelf);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
||||||
|
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
* @since v18.6.0, v16.17.0
|
||||||
|
*/
|
||||||
|
const startupSnapshot: StartupSnapshot;
|
||||||
|
}
|
||||||
|
declare module "node:v8" {
|
||||||
|
export * from "v8";
|
||||||
|
}
|
922
websocket_server/node_modules/.ignored/@types/node/vm.d.ts
generated
vendored
Normal file
922
websocket_server/node_modules/.ignored/@types/node/vm.d.ts
generated
vendored
Normal file
@ -0,0 +1,922 @@
|
|||||||
|
/**
|
||||||
|
* The `node:vm` module enables compiling and running code within V8 Virtual
|
||||||
|
* Machine contexts.
|
||||||
|
*
|
||||||
|
* **The `node:vm` module is not a security**
|
||||||
|
* **mechanism. Do not use it to run untrusted code.**
|
||||||
|
*
|
||||||
|
* JavaScript code can be compiled and run immediately or
|
||||||
|
* compiled, saved, and run later.
|
||||||
|
*
|
||||||
|
* A common use case is to run the code in a different V8 Context. This means
|
||||||
|
* invoked code has a different global object than the invoking code.
|
||||||
|
*
|
||||||
|
* One can provide the context by `contextifying` an
|
||||||
|
* object. The invoked code treats any property in the context like a
|
||||||
|
* global variable. Any changes to global variables caused by the invoked
|
||||||
|
* code are reflected in the context object.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const x = 1;
|
||||||
|
*
|
||||||
|
* const context = { x: 2 };
|
||||||
|
* vm.createContext(context); // Contextify the object.
|
||||||
|
*
|
||||||
|
* const code = 'x += 40; var y = 17;';
|
||||||
|
* // `x` and `y` are global variables in the context.
|
||||||
|
* // Initially, x has the value 2 because that is the value of context.x.
|
||||||
|
* vm.runInContext(code, context);
|
||||||
|
*
|
||||||
|
* console.log(context.x); // 42
|
||||||
|
* console.log(context.y); // 17
|
||||||
|
*
|
||||||
|
* console.log(x); // 1; y is not defined.
|
||||||
|
* ```
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/vm.js)
|
||||||
|
*/
|
||||||
|
declare module "vm" {
|
||||||
|
import { ImportAttributes } from "node:module";
|
||||||
|
interface Context extends NodeJS.Dict<any> {}
|
||||||
|
interface BaseOptions {
|
||||||
|
/**
|
||||||
|
* Specifies the filename used in stack traces produced by this script.
|
||||||
|
* @default ''
|
||||||
|
*/
|
||||||
|
filename?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Specifies the line number offset that is displayed in stack traces produced by this script.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
lineOffset?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Specifies the column number offset that is displayed in stack traces produced by this script.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
columnOffset?: number | undefined;
|
||||||
|
}
|
||||||
|
interface ScriptOptions extends BaseOptions {
|
||||||
|
/**
|
||||||
|
* V8's code cache data for the supplied source.
|
||||||
|
*/
|
||||||
|
cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
|
||||||
|
/** @deprecated in favor of `script.createCachedData()` */
|
||||||
|
produceCachedData?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
||||||
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
||||||
|
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
||||||
|
*/
|
||||||
|
importModuleDynamically?:
|
||||||
|
| ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module)
|
||||||
|
| typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
interface RunningScriptOptions extends BaseOptions {
|
||||||
|
/**
|
||||||
|
* When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
displayErrors?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Specifies the number of milliseconds to execute code before terminating execution.
|
||||||
|
* If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer.
|
||||||
|
*/
|
||||||
|
timeout?: number | undefined;
|
||||||
|
/**
|
||||||
|
* If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received.
|
||||||
|
* Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that.
|
||||||
|
* If execution is terminated, an `Error` will be thrown.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
breakOnSigint?: boolean | undefined;
|
||||||
|
}
|
||||||
|
interface RunningScriptInNewContextOptions extends RunningScriptOptions {
|
||||||
|
/**
|
||||||
|
* Human-readable name of the newly created context.
|
||||||
|
*/
|
||||||
|
contextName?: CreateContextOptions["name"];
|
||||||
|
/**
|
||||||
|
* Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
|
||||||
|
* but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
|
||||||
|
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
||||||
|
*/
|
||||||
|
contextOrigin?: CreateContextOptions["origin"];
|
||||||
|
contextCodeGeneration?: CreateContextOptions["codeGeneration"];
|
||||||
|
/**
|
||||||
|
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
||||||
|
*/
|
||||||
|
microtaskMode?: CreateContextOptions["microtaskMode"];
|
||||||
|
}
|
||||||
|
interface RunningCodeOptions extends RunningScriptOptions {
|
||||||
|
cachedData?: ScriptOptions["cachedData"];
|
||||||
|
importModuleDynamically?: ScriptOptions["importModuleDynamically"];
|
||||||
|
}
|
||||||
|
interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
|
||||||
|
cachedData?: ScriptOptions["cachedData"];
|
||||||
|
importModuleDynamically?: ScriptOptions["importModuleDynamically"];
|
||||||
|
}
|
||||||
|
interface CompileFunctionOptions extends BaseOptions {
|
||||||
|
/**
|
||||||
|
* Provides an optional data with V8's code cache data for the supplied source.
|
||||||
|
*/
|
||||||
|
cachedData?: Buffer | undefined;
|
||||||
|
/**
|
||||||
|
* Specifies whether to produce new cache data.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
produceCachedData?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The sandbox/context in which the said function should be compiled in.
|
||||||
|
*/
|
||||||
|
parsingContext?: Context | undefined;
|
||||||
|
/**
|
||||||
|
* An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling
|
||||||
|
*/
|
||||||
|
contextExtensions?: Object[] | undefined;
|
||||||
|
}
|
||||||
|
interface CreateContextOptions {
|
||||||
|
/**
|
||||||
|
* Human-readable name of the newly created context.
|
||||||
|
* @default 'VM Context i' Where i is an ascending numerical index of the created context.
|
||||||
|
*/
|
||||||
|
name?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Corresponds to the newly created context for display purposes.
|
||||||
|
* The origin should be formatted like a `URL`, but with only the scheme, host, and port (if necessary),
|
||||||
|
* like the value of the `url.origin` property of a URL object.
|
||||||
|
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
||||||
|
* @default ''
|
||||||
|
*/
|
||||||
|
origin?: string | undefined;
|
||||||
|
codeGeneration?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* If set to false any calls to eval or function constructors (Function, GeneratorFunction, etc)
|
||||||
|
* will throw an EvalError.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
strings?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* If set to false any attempt to compile a WebAssembly module will throw a WebAssembly.CompileError.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
wasm?: boolean | undefined;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
/**
|
||||||
|
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
||||||
|
*/
|
||||||
|
microtaskMode?: "afterEvaluate" | undefined;
|
||||||
|
}
|
||||||
|
type MeasureMemoryMode = "summary" | "detailed";
|
||||||
|
interface MeasureMemoryOptions {
|
||||||
|
/**
|
||||||
|
* @default 'summary'
|
||||||
|
*/
|
||||||
|
mode?: MeasureMemoryMode | undefined;
|
||||||
|
/**
|
||||||
|
* @default 'default'
|
||||||
|
*/
|
||||||
|
execution?: "default" | "eager" | undefined;
|
||||||
|
}
|
||||||
|
interface MemoryMeasurement {
|
||||||
|
total: {
|
||||||
|
jsMemoryEstimate: number;
|
||||||
|
jsMemoryRange: [number, number];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Instances of the `vm.Script` class contain precompiled scripts that can be
|
||||||
|
* executed in specific contexts.
|
||||||
|
* @since v0.3.1
|
||||||
|
*/
|
||||||
|
class Script {
|
||||||
|
constructor(code: string, options?: ScriptOptions | string);
|
||||||
|
/**
|
||||||
|
* Runs the compiled code contained by the `vm.Script` object within the given `contextifiedObject` and returns the result. Running code does not have access
|
||||||
|
* to local scope.
|
||||||
|
*
|
||||||
|
* The following example compiles code that increments a global variable, sets
|
||||||
|
* the value of another global variable, then execute the code multiple times.
|
||||||
|
* The globals are contained in the `context` object.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const context = {
|
||||||
|
* animal: 'cat',
|
||||||
|
* count: 2,
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* const script = new vm.Script('count += 1; name = "kitty";');
|
||||||
|
*
|
||||||
|
* vm.createContext(context);
|
||||||
|
* for (let i = 0; i < 10; ++i) {
|
||||||
|
* script.runInContext(context);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* console.log(context);
|
||||||
|
* // Prints: { animal: 'cat', count: 12, name: 'kitty' }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Using the `timeout` or `breakOnSigint` options will result in new event loops
|
||||||
|
* and corresponding threads being started, which have a non-zero performance
|
||||||
|
* overhead.
|
||||||
|
* @since v0.3.1
|
||||||
|
* @param contextifiedObject A `contextified` object as returned by the `vm.createContext()` method.
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any;
|
||||||
|
/**
|
||||||
|
* First contextifies the given `contextObject`, runs the compiled code contained
|
||||||
|
* by the `vm.Script` object within the created context, and returns the result.
|
||||||
|
* Running code does not have access to local scope.
|
||||||
|
*
|
||||||
|
* The following example compiles code that sets a global variable, then executes
|
||||||
|
* the code multiple times in different contexts. The globals are set on and
|
||||||
|
* contained within each individual `context`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const script = new vm.Script('globalVar = "set"');
|
||||||
|
*
|
||||||
|
* const contexts = [{}, {}, {}];
|
||||||
|
* contexts.forEach((context) => {
|
||||||
|
* script.runInNewContext(context);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* console.log(contexts);
|
||||||
|
* // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
|
||||||
|
* ```
|
||||||
|
* @since v0.3.1
|
||||||
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
|
||||||
|
/**
|
||||||
|
* Runs the compiled code contained by the `vm.Script` within the context of the
|
||||||
|
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
|
||||||
|
*
|
||||||
|
* The following example compiles code that increments a `global` variable then
|
||||||
|
* executes that code multiple times:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* global.globalVar = 0;
|
||||||
|
*
|
||||||
|
* const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' });
|
||||||
|
*
|
||||||
|
* for (let i = 0; i < 1000; ++i) {
|
||||||
|
* script.runInThisContext();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* console.log(globalVar);
|
||||||
|
*
|
||||||
|
* // 1000
|
||||||
|
* ```
|
||||||
|
* @since v0.3.1
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
runInThisContext(options?: RunningScriptOptions): any;
|
||||||
|
/**
|
||||||
|
* Creates a code cache that can be used with the `Script` constructor's `cachedData` option. Returns a `Buffer`. This method may be called at any
|
||||||
|
* time and any number of times.
|
||||||
|
*
|
||||||
|
* The code cache of the `Script` doesn't contain any JavaScript observable
|
||||||
|
* states. The code cache is safe to be saved along side the script source and
|
||||||
|
* used to construct new `Script` instances multiple times.
|
||||||
|
*
|
||||||
|
* Functions in the `Script` source can be marked as lazily compiled and they are
|
||||||
|
* not compiled at construction of the `Script`. These functions are going to be
|
||||||
|
* compiled when they are invoked the first time. The code cache serializes the
|
||||||
|
* metadata that V8 currently knows about the `Script` that it can use to speed up
|
||||||
|
* future compilations.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const script = new vm.Script(`
|
||||||
|
* function add(a, b) {
|
||||||
|
* return a + b;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const x = add(1, 2);
|
||||||
|
* `);
|
||||||
|
*
|
||||||
|
* const cacheWithoutAdd = script.createCachedData();
|
||||||
|
* // In `cacheWithoutAdd` the function `add()` is marked for full compilation
|
||||||
|
* // upon invocation.
|
||||||
|
*
|
||||||
|
* script.runInThisContext();
|
||||||
|
*
|
||||||
|
* const cacheWithAdd = script.createCachedData();
|
||||||
|
* // `cacheWithAdd` contains fully compiled function `add()`.
|
||||||
|
* ```
|
||||||
|
* @since v10.6.0
|
||||||
|
*/
|
||||||
|
createCachedData(): Buffer;
|
||||||
|
/** @deprecated in favor of `script.createCachedData()` */
|
||||||
|
cachedDataProduced?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* When `cachedData` is supplied to create the `vm.Script`, this value will be set
|
||||||
|
* to either `true` or `false` depending on acceptance of the data by V8.
|
||||||
|
* Otherwise the value is `undefined`.
|
||||||
|
* @since v5.7.0
|
||||||
|
*/
|
||||||
|
cachedDataRejected?: boolean | undefined;
|
||||||
|
cachedData?: Buffer | undefined;
|
||||||
|
/**
|
||||||
|
* When the script is compiled from a source that contains a source map magic
|
||||||
|
* comment, this property will be set to the URL of the source map.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const script = new vm.Script(`
|
||||||
|
* function myFunc() {}
|
||||||
|
* //# sourceMappingURL=sourcemap.json
|
||||||
|
* `);
|
||||||
|
*
|
||||||
|
* console.log(script.sourceMapURL);
|
||||||
|
* // Prints: sourcemap.json
|
||||||
|
* ```
|
||||||
|
* @since v19.1.0, v18.13.0
|
||||||
|
*/
|
||||||
|
sourceMapURL?: string | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* If given a `contextObject`, the `vm.createContext()` method will
|
||||||
|
* [prepare that object](https://nodejs.org/docs/latest-v22.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
|
||||||
|
* and return a reference to it so that it can be used in `{@link runInContext}` or
|
||||||
|
* [`script.runInContext()`](https://nodejs.org/docs/latest-v22.x/api/vm.html#scriptrunincontextcontextifiedobject-options). Inside such
|
||||||
|
* scripts, the `contextObject` will be the global object, retaining all of its
|
||||||
|
* existing properties but also having the built-in objects and functions any
|
||||||
|
* standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
|
||||||
|
* variables will remain unchanged.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* global.globalVar = 3;
|
||||||
|
*
|
||||||
|
* const context = { globalVar: 1 };
|
||||||
|
* vm.createContext(context);
|
||||||
|
*
|
||||||
|
* vm.runInContext('globalVar *= 2;', context);
|
||||||
|
*
|
||||||
|
* console.log(context);
|
||||||
|
* // Prints: { globalVar: 2 }
|
||||||
|
*
|
||||||
|
* console.log(global.globalVar);
|
||||||
|
* // Prints: 3
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If `contextObject` is omitted (or passed explicitly as `undefined`), a new,
|
||||||
|
* empty `contextified` object will be returned.
|
||||||
|
*
|
||||||
|
* The `vm.createContext()` method is primarily useful for creating a single
|
||||||
|
* context that can be used to run multiple scripts. For instance, if emulating a
|
||||||
|
* web browser, the method can be used to create a single context representing a
|
||||||
|
* window's global object, then run all `<script>` tags together within that
|
||||||
|
* context.
|
||||||
|
*
|
||||||
|
* The provided `name` and `origin` of the context are made visible through the
|
||||||
|
* Inspector API.
|
||||||
|
* @since v0.3.1
|
||||||
|
* @return contextified object.
|
||||||
|
*/
|
||||||
|
function createContext(sandbox?: Context, options?: CreateContextOptions): Context;
|
||||||
|
/**
|
||||||
|
* Returns `true` if the given `object` object has been `contextified` using {@link createContext}.
|
||||||
|
* @since v0.11.7
|
||||||
|
*/
|
||||||
|
function isContext(sandbox: Context): boolean;
|
||||||
|
/**
|
||||||
|
* The `vm.runInContext()` method compiles `code`, runs it within the context of
|
||||||
|
* the `contextifiedObject`, then returns the result. Running code does not have
|
||||||
|
* access to the local scope. The `contextifiedObject` object _must_ have been
|
||||||
|
* previously `contextified` using the {@link createContext} method.
|
||||||
|
*
|
||||||
|
* If `options` is a string, then it specifies the filename.
|
||||||
|
*
|
||||||
|
* The following example compiles and executes different scripts using a single `contextified` object:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const contextObject = { globalVar: 1 };
|
||||||
|
* vm.createContext(contextObject);
|
||||||
|
*
|
||||||
|
* for (let i = 0; i < 10; ++i) {
|
||||||
|
* vm.runInContext('globalVar *= 2;', contextObject);
|
||||||
|
* }
|
||||||
|
* console.log(contextObject);
|
||||||
|
* // Prints: { globalVar: 1024 }
|
||||||
|
* ```
|
||||||
|
* @since v0.3.1
|
||||||
|
* @param code The JavaScript code to compile and run.
|
||||||
|
* @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run.
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
|
||||||
|
/**
|
||||||
|
* The `vm.runInNewContext()` first contextifies the given `contextObject` (or
|
||||||
|
* creates a new `contextObject` if passed as `undefined`), compiles the `code`,
|
||||||
|
* runs it within the created context, then returns the result. Running code
|
||||||
|
* does not have access to the local scope.
|
||||||
|
*
|
||||||
|
* If `options` is a string, then it specifies the filename.
|
||||||
|
*
|
||||||
|
* The following example compiles and executes code that increments a global
|
||||||
|
* variable and sets a new one. These globals are contained in the `contextObject`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const contextObject = {
|
||||||
|
* animal: 'cat',
|
||||||
|
* count: 2,
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* vm.runInNewContext('count += 1; name = "kitty"', contextObject);
|
||||||
|
* console.log(contextObject);
|
||||||
|
* // Prints: { animal: 'cat', count: 3, name: 'kitty' }
|
||||||
|
* ```
|
||||||
|
* @since v0.3.1
|
||||||
|
* @param code The JavaScript code to compile and run.
|
||||||
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
function runInNewContext(
|
||||||
|
code: string,
|
||||||
|
contextObject?: Context,
|
||||||
|
options?: RunningCodeInNewContextOptions | string,
|
||||||
|
): any;
|
||||||
|
/**
|
||||||
|
* `vm.runInThisContext()` compiles `code`, runs it within the context of the
|
||||||
|
* current `global` and returns the result. Running code does not have access to
|
||||||
|
* local scope, but does have access to the current `global` object.
|
||||||
|
*
|
||||||
|
* If `options` is a string, then it specifies the filename.
|
||||||
|
*
|
||||||
|
* The following example illustrates using both `vm.runInThisContext()` and
|
||||||
|
* the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
* let localVar = 'initial value';
|
||||||
|
*
|
||||||
|
* const vmResult = vm.runInThisContext('localVar = "vm";');
|
||||||
|
* console.log(`vmResult: '${vmResult}', localVar: '${localVar}'`);
|
||||||
|
* // Prints: vmResult: 'vm', localVar: 'initial value'
|
||||||
|
*
|
||||||
|
* const evalResult = eval('localVar = "eval";');
|
||||||
|
* console.log(`evalResult: '${evalResult}', localVar: '${localVar}'`);
|
||||||
|
* // Prints: evalResult: 'eval', localVar: 'eval'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Because `vm.runInThisContext()` does not have access to the local scope, `localVar` is unchanged. In contrast,
|
||||||
|
* [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) _does_ have access to the
|
||||||
|
* local scope, so the value `localVar` is changed. In this way `vm.runInThisContext()` is much like an [indirect `eval()` call](https://es5.github.io/#x10.4.2), e.g.`(0,eval)('code')`.
|
||||||
|
*
|
||||||
|
* ## Example: Running an HTTP server within a VM
|
||||||
|
*
|
||||||
|
* When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global
|
||||||
|
* context. The code passed to this VM context will have its own isolated scope.
|
||||||
|
*
|
||||||
|
* In order to run a simple web server using the `node:http` module the code passed
|
||||||
|
* to the context must either import `node:http` on its own, or have a
|
||||||
|
* reference to the `node:http` module passed to it. For instance:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* 'use strict';
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const code = `
|
||||||
|
* ((require) => {
|
||||||
|
* const http = require('node:http');
|
||||||
|
*
|
||||||
|
* http.createServer((request, response) => {
|
||||||
|
* response.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||||
|
* response.end('Hello World\\n');
|
||||||
|
* }).listen(8124);
|
||||||
|
*
|
||||||
|
* console.log('Server running at http://127.0.0.1:8124/');
|
||||||
|
* })`;
|
||||||
|
*
|
||||||
|
* vm.runInThisContext(code)(require);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The `require()` in the above case shares the state with the context it is
|
||||||
|
* passed from. This may introduce risks when untrusted code is executed, e.g.
|
||||||
|
* altering objects in the context in unwanted ways.
|
||||||
|
* @since v0.3.1
|
||||||
|
* @param code The JavaScript code to compile and run.
|
||||||
|
* @return the result of the very last statement executed in the script.
|
||||||
|
*/
|
||||||
|
function runInThisContext(code: string, options?: RunningCodeOptions | string): any;
|
||||||
|
/**
|
||||||
|
* Compiles the given code into the provided context (if no context is
|
||||||
|
* supplied, the current context is used), and returns it wrapped inside a
|
||||||
|
* function with the given `params`.
|
||||||
|
* @since v10.10.0
|
||||||
|
* @param code The body of the function to compile.
|
||||||
|
* @param params An array of strings containing all parameters for the function.
|
||||||
|
*/
|
||||||
|
function compileFunction(
|
||||||
|
code: string,
|
||||||
|
params?: readonly string[],
|
||||||
|
options?: CompileFunctionOptions,
|
||||||
|
): Function & {
|
||||||
|
cachedData?: Script["cachedData"] | undefined;
|
||||||
|
cachedDataProduced?: Script["cachedDataProduced"] | undefined;
|
||||||
|
cachedDataRejected?: Script["cachedDataRejected"] | undefined;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Measure the memory known to V8 and used by all contexts known to the
|
||||||
|
* current V8 isolate, or the main context.
|
||||||
|
*
|
||||||
|
* The format of the object that the returned Promise may resolve with is
|
||||||
|
* specific to the V8 engine and may change from one version of V8 to the next.
|
||||||
|
*
|
||||||
|
* The returned result is different from the statistics returned by `v8.getHeapSpaceStatistics()` in that `vm.measureMemory()` measure the
|
||||||
|
* memory reachable by each V8 specific contexts in the current instance of
|
||||||
|
* the V8 engine, while the result of `v8.getHeapSpaceStatistics()` measure
|
||||||
|
* the memory occupied by each heap space in the current V8 instance.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
* // Measure the memory used by the main context.
|
||||||
|
* vm.measureMemory({ mode: 'summary' })
|
||||||
|
* // This is the same as vm.measureMemory()
|
||||||
|
* .then((result) => {
|
||||||
|
* // The current format is:
|
||||||
|
* // {
|
||||||
|
* // total: {
|
||||||
|
* // jsMemoryEstimate: 2418479, jsMemoryRange: [ 2418479, 2745799 ]
|
||||||
|
* // }
|
||||||
|
* // }
|
||||||
|
* console.log(result);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* const context = vm.createContext({ a: 1 });
|
||||||
|
* vm.measureMemory({ mode: 'detailed', execution: 'eager' })
|
||||||
|
* .then((result) => {
|
||||||
|
* // Reference the context here so that it won't be GC'ed
|
||||||
|
* // until the measurement is complete.
|
||||||
|
* console.log(context.a);
|
||||||
|
* // {
|
||||||
|
* // total: {
|
||||||
|
* // jsMemoryEstimate: 2574732,
|
||||||
|
* // jsMemoryRange: [ 2574732, 2904372 ]
|
||||||
|
* // },
|
||||||
|
* // current: {
|
||||||
|
* // jsMemoryEstimate: 2438996,
|
||||||
|
* // jsMemoryRange: [ 2438996, 2768636 ]
|
||||||
|
* // },
|
||||||
|
* // other: [
|
||||||
|
* // {
|
||||||
|
* // jsMemoryEstimate: 135736,
|
||||||
|
* // jsMemoryRange: [ 135736, 465376 ]
|
||||||
|
* // }
|
||||||
|
* // ]
|
||||||
|
* // }
|
||||||
|
* console.log(result);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v13.10.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
|
||||||
|
interface ModuleEvaluateOptions {
|
||||||
|
timeout?: RunningScriptOptions["timeout"] | undefined;
|
||||||
|
breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
|
||||||
|
}
|
||||||
|
type ModuleLinker = (
|
||||||
|
specifier: string,
|
||||||
|
referencingModule: Module,
|
||||||
|
extra: {
|
||||||
|
attributes: ImportAttributes;
|
||||||
|
},
|
||||||
|
) => Module | Promise<Module>;
|
||||||
|
type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
|
||||||
|
/**
|
||||||
|
* This feature is only available with the `--experimental-vm-modules` command
|
||||||
|
* flag enabled.
|
||||||
|
*
|
||||||
|
* The `vm.Module` class provides a low-level interface for using
|
||||||
|
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script` class that closely mirrors [Module Record](https://262.ecma-international.org/14.0/#sec-abstract-module-records) s as
|
||||||
|
* defined in the ECMAScript
|
||||||
|
* specification.
|
||||||
|
*
|
||||||
|
* Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
|
||||||
|
* its creation. Operations on `vm.Module` objects are intrinsically asynchronous,
|
||||||
|
* in contrast with the synchronous nature of `vm.Script` objects. The use of
|
||||||
|
* 'async' functions can help with manipulating `vm.Module` objects.
|
||||||
|
*
|
||||||
|
* Using a `vm.Module` object requires three distinct steps: creation/parsing,
|
||||||
|
* linking, and evaluation. These three steps are illustrated in the following
|
||||||
|
* example.
|
||||||
|
*
|
||||||
|
* This implementation lies at a lower level than the `ECMAScript Module
|
||||||
|
* loader`. There is also no way to interact with the Loader yet, though
|
||||||
|
* support is planned.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const contextifiedObject = vm.createContext({
|
||||||
|
* secret: 42,
|
||||||
|
* print: console.log,
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Step 1
|
||||||
|
* //
|
||||||
|
* // Create a Module by constructing a new `vm.SourceTextModule` object. This
|
||||||
|
* // parses the provided source text, throwing a `SyntaxError` if anything goes
|
||||||
|
* // wrong. By default, a Module is created in the top context. But here, we
|
||||||
|
* // specify `contextifiedObject` as the context this Module belongs to.
|
||||||
|
* //
|
||||||
|
* // Here, we attempt to obtain the default export from the module "foo", and
|
||||||
|
* // put it into local binding "secret".
|
||||||
|
*
|
||||||
|
* const bar = new vm.SourceTextModule(`
|
||||||
|
* import s from 'foo';
|
||||||
|
* s;
|
||||||
|
* print(s);
|
||||||
|
* `, { context: contextifiedObject });
|
||||||
|
*
|
||||||
|
* // Step 2
|
||||||
|
* //
|
||||||
|
* // "Link" the imported dependencies of this Module to it.
|
||||||
|
* //
|
||||||
|
* // The provided linking callback (the "linker") accepts two arguments: the
|
||||||
|
* // parent module (`bar` in this case) and the string that is the specifier of
|
||||||
|
* // the imported module. The callback is expected to return a Module that
|
||||||
|
* // corresponds to the provided specifier, with certain requirements documented
|
||||||
|
* // in `module.link()`.
|
||||||
|
* //
|
||||||
|
* // If linking has not started for the returned Module, the same linker
|
||||||
|
* // callback will be called on the returned Module.
|
||||||
|
* //
|
||||||
|
* // Even top-level Modules without dependencies must be explicitly linked. The
|
||||||
|
* // callback provided would never be called, however.
|
||||||
|
* //
|
||||||
|
* // The link() method returns a Promise that will be resolved when all the
|
||||||
|
* // Promises returned by the linker resolve.
|
||||||
|
* //
|
||||||
|
* // Note: This is a contrived example in that the linker function creates a new
|
||||||
|
* // "foo" module every time it is called. In a full-fledged module system, a
|
||||||
|
* // cache would probably be used to avoid duplicated modules.
|
||||||
|
*
|
||||||
|
* async function linker(specifier, referencingModule) {
|
||||||
|
* if (specifier === 'foo') {
|
||||||
|
* return new vm.SourceTextModule(`
|
||||||
|
* // The "secret" variable refers to the global variable we added to
|
||||||
|
* // "contextifiedObject" when creating the context.
|
||||||
|
* export default secret;
|
||||||
|
* `, { context: referencingModule.context });
|
||||||
|
*
|
||||||
|
* // Using `contextifiedObject` instead of `referencingModule.context`
|
||||||
|
* // here would work as well.
|
||||||
|
* }
|
||||||
|
* throw new Error(`Unable to resolve dependency: ${specifier}`);
|
||||||
|
* }
|
||||||
|
* await bar.link(linker);
|
||||||
|
*
|
||||||
|
* // Step 3
|
||||||
|
* //
|
||||||
|
* // Evaluate the Module. The evaluate() method returns a promise which will
|
||||||
|
* // resolve after the module has finished evaluating.
|
||||||
|
*
|
||||||
|
* // Prints 42.
|
||||||
|
* await bar.evaluate();
|
||||||
|
* ```
|
||||||
|
* @since v13.0.0, v12.16.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
class Module {
|
||||||
|
/**
|
||||||
|
* The specifiers of all dependencies of this module. The returned array is frozen
|
||||||
|
* to disallow any changes to it.
|
||||||
|
*
|
||||||
|
* Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
|
||||||
|
* the ECMAScript specification.
|
||||||
|
*/
|
||||||
|
dependencySpecifiers: readonly string[];
|
||||||
|
/**
|
||||||
|
* If the `module.status` is `'errored'`, this property contains the exception
|
||||||
|
* thrown by the module during evaluation. If the status is anything else,
|
||||||
|
* accessing this property will result in a thrown exception.
|
||||||
|
*
|
||||||
|
* The value `undefined` cannot be used for cases where there is not a thrown
|
||||||
|
* exception due to possible ambiguity with `throw undefined;`.
|
||||||
|
*
|
||||||
|
* Corresponds to the `[[EvaluationError]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s
|
||||||
|
* in the ECMAScript specification.
|
||||||
|
*/
|
||||||
|
error: any;
|
||||||
|
/**
|
||||||
|
* The identifier of the current module, as set in the constructor.
|
||||||
|
*/
|
||||||
|
identifier: string;
|
||||||
|
context: Context;
|
||||||
|
/**
|
||||||
|
* The namespace object of the module. This is only available after linking
|
||||||
|
* (`module.link()`) has completed.
|
||||||
|
*
|
||||||
|
* Corresponds to the [GetModuleNamespace](https://tc39.es/ecma262/#sec-getmodulenamespace) abstract operation in the ECMAScript
|
||||||
|
* specification.
|
||||||
|
*/
|
||||||
|
namespace: Object;
|
||||||
|
/**
|
||||||
|
* The current status of the module. Will be one of:
|
||||||
|
*
|
||||||
|
* * `'unlinked'`: `module.link()` has not yet been called.
|
||||||
|
* * `'linking'`: `module.link()` has been called, but not all Promises returned
|
||||||
|
* by the linker function have been resolved yet.
|
||||||
|
* * `'linked'`: The module has been linked successfully, and all of its
|
||||||
|
* dependencies are linked, but `module.evaluate()` has not yet been called.
|
||||||
|
* * `'evaluating'`: The module is being evaluated through a `module.evaluate()` on
|
||||||
|
* itself or a parent module.
|
||||||
|
* * `'evaluated'`: The module has been successfully evaluated.
|
||||||
|
* * `'errored'`: The module has been evaluated, but an exception was thrown.
|
||||||
|
*
|
||||||
|
* Other than `'errored'`, this status string corresponds to the specification's [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)'s `[[Status]]` field. `'errored'`
|
||||||
|
* corresponds to `'evaluated'` in the specification, but with `[[EvaluationError]]` set to a
|
||||||
|
* value that is not `undefined`.
|
||||||
|
*/
|
||||||
|
status: ModuleStatus;
|
||||||
|
/**
|
||||||
|
* Evaluate the module.
|
||||||
|
*
|
||||||
|
* This must be called after the module has been linked; otherwise it will reject.
|
||||||
|
* It could be called also when the module has already been evaluated, in which
|
||||||
|
* case it will either do nothing if the initial evaluation ended in success
|
||||||
|
* (`module.status` is `'evaluated'`) or it will re-throw the exception that the
|
||||||
|
* initial evaluation resulted in (`module.status` is `'errored'`).
|
||||||
|
*
|
||||||
|
* This method cannot be called while the module is being evaluated
|
||||||
|
* (`module.status` is `'evaluating'`).
|
||||||
|
*
|
||||||
|
* Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the
|
||||||
|
* ECMAScript specification.
|
||||||
|
* @return Fulfills with `undefined` upon success.
|
||||||
|
*/
|
||||||
|
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Link module dependencies. This method must be called before evaluation, and
|
||||||
|
* can only be called once per module.
|
||||||
|
*
|
||||||
|
* The function is expected to return a `Module` object or a `Promise` that
|
||||||
|
* eventually resolves to a `Module` object. The returned `Module` must satisfy the
|
||||||
|
* following two invariants:
|
||||||
|
*
|
||||||
|
* * It must belong to the same context as the parent `Module`.
|
||||||
|
* * Its `status` must not be `'errored'`.
|
||||||
|
*
|
||||||
|
* If the returned `Module`'s `status` is `'unlinked'`, this method will be
|
||||||
|
* recursively called on the returned `Module` with the same provided `linker` function.
|
||||||
|
*
|
||||||
|
* `link()` returns a `Promise` that will either get resolved when all linking
|
||||||
|
* instances resolve to a valid `Module`, or rejected if the linker function either
|
||||||
|
* throws an exception or returns an invalid `Module`.
|
||||||
|
*
|
||||||
|
* The linker function roughly corresponds to the implementation-defined [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) abstract operation in the
|
||||||
|
* ECMAScript
|
||||||
|
* specification, with a few key differences:
|
||||||
|
*
|
||||||
|
* * The linker function is allowed to be asynchronous while [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) is synchronous.
|
||||||
|
*
|
||||||
|
* The actual [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation used during module
|
||||||
|
* linking is one that returns the modules linked during linking. Since at
|
||||||
|
* that point all modules would have been fully linked already, the [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation is fully synchronous per
|
||||||
|
* specification.
|
||||||
|
*
|
||||||
|
* Corresponds to the [Link() concrete method](https://tc39.es/ecma262/#sec-moduledeclarationlinking) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
|
||||||
|
* the ECMAScript specification.
|
||||||
|
*/
|
||||||
|
link(linker: ModuleLinker): Promise<void>;
|
||||||
|
}
|
||||||
|
interface SourceTextModuleOptions {
|
||||||
|
/**
|
||||||
|
* String used in stack traces.
|
||||||
|
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
||||||
|
*/
|
||||||
|
identifier?: string | undefined;
|
||||||
|
cachedData?: ScriptOptions["cachedData"] | undefined;
|
||||||
|
context?: Context | undefined;
|
||||||
|
lineOffset?: BaseOptions["lineOffset"] | undefined;
|
||||||
|
columnOffset?: BaseOptions["columnOffset"] | undefined;
|
||||||
|
/**
|
||||||
|
* Called during evaluation of this module to initialize the `import.meta`.
|
||||||
|
*/
|
||||||
|
initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
|
||||||
|
importModuleDynamically?: ScriptOptions["importModuleDynamically"] | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This feature is only available with the `--experimental-vm-modules` command
|
||||||
|
* flag enabled.
|
||||||
|
*
|
||||||
|
* The `vm.SourceTextModule` class provides the [Source Text Module Record](https://tc39.es/ecma262/#sec-source-text-module-records) as
|
||||||
|
* defined in the ECMAScript specification.
|
||||||
|
* @since v9.6.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
class SourceTextModule extends Module {
|
||||||
|
/**
|
||||||
|
* Creates a new `SourceTextModule` instance.
|
||||||
|
* @param code JavaScript Module code to parse
|
||||||
|
*/
|
||||||
|
constructor(code: string, options?: SourceTextModuleOptions);
|
||||||
|
}
|
||||||
|
interface SyntheticModuleOptions {
|
||||||
|
/**
|
||||||
|
* String used in stack traces.
|
||||||
|
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
||||||
|
*/
|
||||||
|
identifier?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in.
|
||||||
|
*/
|
||||||
|
context?: Context | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This feature is only available with the `--experimental-vm-modules` command
|
||||||
|
* flag enabled.
|
||||||
|
*
|
||||||
|
* The `vm.SyntheticModule` class provides the [Synthetic Module Record](https://heycam.github.io/webidl/#synthetic-module-records) as
|
||||||
|
* defined in the WebIDL specification. The purpose of synthetic modules is to
|
||||||
|
* provide a generic interface for exposing non-JavaScript sources to ECMAScript
|
||||||
|
* module graphs.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const source = '{ "a": 1 }';
|
||||||
|
* const module = new vm.SyntheticModule(['default'], function() {
|
||||||
|
* const obj = JSON.parse(source);
|
||||||
|
* this.setExport('default', obj);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Use `module` in linking...
|
||||||
|
* ```
|
||||||
|
* @since v13.0.0, v12.16.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
class SyntheticModule extends Module {
|
||||||
|
/**
|
||||||
|
* Creates a new `SyntheticModule` instance.
|
||||||
|
* @param exportNames Array of names that will be exported from the module.
|
||||||
|
* @param evaluateCallback Called when the module is evaluated.
|
||||||
|
*/
|
||||||
|
constructor(
|
||||||
|
exportNames: string[],
|
||||||
|
evaluateCallback: (this: SyntheticModule) => void,
|
||||||
|
options?: SyntheticModuleOptions,
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* This method is used after the module is linked to set the values of exports. If
|
||||||
|
* it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
|
||||||
|
* will be thrown.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import vm from 'node:vm';
|
||||||
|
*
|
||||||
|
* const m = new vm.SyntheticModule(['x'], () => {
|
||||||
|
* m.setExport('x', 1);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* await m.link(() => {});
|
||||||
|
* await m.evaluate();
|
||||||
|
*
|
||||||
|
* assert.strictEqual(m.namespace.x, 1);
|
||||||
|
* ```
|
||||||
|
* @since v13.0.0, v12.16.0
|
||||||
|
* @param name Name of the export to set.
|
||||||
|
* @param value The value to set the export to.
|
||||||
|
*/
|
||||||
|
setExport(name: string, value: any): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns an object containing commonly used constants for VM operations.
|
||||||
|
* @since v20.12.0
|
||||||
|
*/
|
||||||
|
namespace constants {
|
||||||
|
/**
|
||||||
|
* Stability: 1.1 - Active development
|
||||||
|
*
|
||||||
|
* A constant that can be used as the `importModuleDynamically` option to `vm.Script`
|
||||||
|
* and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
|
||||||
|
* context to load the requested module.
|
||||||
|
*
|
||||||
|
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
||||||
|
*/
|
||||||
|
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:vm" {
|
||||||
|
export * from "vm";
|
||||||
|
}
|
181
websocket_server/node_modules/.ignored/@types/node/wasi.d.ts
generated
vendored
Normal file
181
websocket_server/node_modules/.ignored/@types/node/wasi.d.ts
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
/**
|
||||||
|
* **The `node:wasi` module does not currently provide the**
|
||||||
|
* **comprehensive file system security properties provided by some WASI runtimes.**
|
||||||
|
* **Full support for secure file system sandboxing may or may not be implemented in**
|
||||||
|
* **future. In the mean time, do not rely on it to run untrusted code.**
|
||||||
|
*
|
||||||
|
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives WebAssembly applications access to the underlying
|
||||||
|
* operating system via a collection of POSIX-like functions.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { readFile } from 'node:fs/promises';
|
||||||
|
* import { WASI } from 'node:wasi';
|
||||||
|
* import { argv, env } from 'node:process';
|
||||||
|
*
|
||||||
|
* const wasi = new WASI({
|
||||||
|
* version: 'preview1',
|
||||||
|
* args: argv,
|
||||||
|
* env,
|
||||||
|
* preopens: {
|
||||||
|
* '/local': '/some/real/path/that/wasm/can/access',
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* const wasm = await WebAssembly.compile(
|
||||||
|
* await readFile(new URL('./demo.wasm', import.meta.url)),
|
||||||
|
* );
|
||||||
|
* const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());
|
||||||
|
*
|
||||||
|
* wasi.start(instance);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* To run the above example, create a new WebAssembly text format file named `demo.wat`:
|
||||||
|
*
|
||||||
|
* ```text
|
||||||
|
* (module
|
||||||
|
* ;; Import the required fd_write WASI function which will write the given io vectors to stdout
|
||||||
|
* ;; The function signature for fd_write is:
|
||||||
|
* ;; (File Descriptor, *iovs, iovs_len, nwritten) -> Returns number of bytes written
|
||||||
|
* (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
|
||||||
|
*
|
||||||
|
* (memory 1)
|
||||||
|
* (export "memory" (memory 0))
|
||||||
|
*
|
||||||
|
* ;; Write 'hello world\n' to memory at an offset of 8 bytes
|
||||||
|
* ;; Note the trailing newline which is required for the text to appear
|
||||||
|
* (data (i32.const 8) "hello world\n")
|
||||||
|
*
|
||||||
|
* (func $main (export "_start")
|
||||||
|
* ;; Creating a new io vector within linear memory
|
||||||
|
* (i32.store (i32.const 0) (i32.const 8)) ;; iov.iov_base - This is a pointer to the start of the 'hello world\n' string
|
||||||
|
* (i32.store (i32.const 4) (i32.const 12)) ;; iov.iov_len - The length of the 'hello world\n' string
|
||||||
|
*
|
||||||
|
* (call $fd_write
|
||||||
|
* (i32.const 1) ;; file_descriptor - 1 for stdout
|
||||||
|
* (i32.const 0) ;; *iovs - The pointer to the iov array, which is stored at memory location 0
|
||||||
|
* (i32.const 1) ;; iovs_len - We're printing 1 string stored in an iov - so one.
|
||||||
|
* (i32.const 20) ;; nwritten - A place in memory to store the number of bytes written
|
||||||
|
* )
|
||||||
|
* drop ;; Discard the number of bytes written from the top of the stack
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
|
||||||
|
*
|
||||||
|
* ```bash
|
||||||
|
* wat2wasm demo.wat
|
||||||
|
* ```
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/wasi.js)
|
||||||
|
*/
|
||||||
|
declare module "wasi" {
|
||||||
|
interface WASIOptions {
|
||||||
|
/**
|
||||||
|
* An array of strings that the WebAssembly application will
|
||||||
|
* see as command line arguments. The first argument is the virtual path to the
|
||||||
|
* WASI command itself.
|
||||||
|
* @default []
|
||||||
|
*/
|
||||||
|
args?: string[] | undefined;
|
||||||
|
/**
|
||||||
|
* An object similar to `process.env` that the WebAssembly
|
||||||
|
* application will see as its environment.
|
||||||
|
* @default {}
|
||||||
|
*/
|
||||||
|
env?: object | undefined;
|
||||||
|
/**
|
||||||
|
* This object represents the WebAssembly application's
|
||||||
|
* sandbox directory structure. The string keys of `preopens` are treated as
|
||||||
|
* directories within the sandbox. The corresponding values in `preopens` are
|
||||||
|
* the real paths to those directories on the host machine.
|
||||||
|
*/
|
||||||
|
preopens?: NodeJS.Dict<string> | undefined;
|
||||||
|
/**
|
||||||
|
* By default, when WASI applications call `__wasi_proc_exit()`
|
||||||
|
* `wasi.start()` will return with the exit code specified rather than terminatng the process.
|
||||||
|
* Setting this option to `false` will cause the Node.js process to exit with
|
||||||
|
* the specified exit code instead.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
returnOnExit?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The file descriptor used as standard input in the WebAssembly application.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
stdin?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The file descriptor used as standard output in the WebAssembly application.
|
||||||
|
* @default 1
|
||||||
|
*/
|
||||||
|
stdout?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The file descriptor used as standard error in the WebAssembly application.
|
||||||
|
* @default 2
|
||||||
|
*/
|
||||||
|
stderr?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The version of WASI requested.
|
||||||
|
* Currently the only supported versions are `'unstable'` and `'preview1'`. This option is mandatory.
|
||||||
|
* @since v19.8.0
|
||||||
|
*/
|
||||||
|
version: "unstable" | "preview1";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `WASI` class provides the WASI system call API and additional convenience
|
||||||
|
* methods for working with WASI-based applications. Each `WASI` instance
|
||||||
|
* represents a distinct environment.
|
||||||
|
* @since v13.3.0, v12.16.0
|
||||||
|
*/
|
||||||
|
class WASI {
|
||||||
|
constructor(options?: WASIOptions);
|
||||||
|
/**
|
||||||
|
* Return an import object that can be passed to `WebAssembly.instantiate()` if no other WASM imports are needed beyond those provided by WASI.
|
||||||
|
*
|
||||||
|
* If version `unstable` was passed into the constructor it will return:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* { wasi_unstable: wasi.wasiImport }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If version `preview1` was passed into the constructor or no version was specified it will return:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* { wasi_snapshot_preview1: wasi.wasiImport }
|
||||||
|
* ```
|
||||||
|
* @since v19.8.0
|
||||||
|
*/
|
||||||
|
getImportObject(): object;
|
||||||
|
/**
|
||||||
|
* Attempt to begin execution of `instance` as a WASI command by invoking its `_start()` export. If `instance` does not contain a `_start()` export, or if `instance` contains an `_initialize()`
|
||||||
|
* export, then an exception is thrown.
|
||||||
|
*
|
||||||
|
* `start()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`. If
|
||||||
|
* `instance` does not have a `memory` export an exception is thrown.
|
||||||
|
*
|
||||||
|
* If `start()` is called more than once, an exception is thrown.
|
||||||
|
* @since v13.3.0, v12.16.0
|
||||||
|
*/
|
||||||
|
start(instance: object): number; // TODO: avoid DOM dependency until WASM moved to own lib.
|
||||||
|
/**
|
||||||
|
* Attempt to initialize `instance` as a WASI reactor by invoking its `_initialize()` export, if it is present. If `instance` contains a `_start()` export, then an exception is thrown.
|
||||||
|
*
|
||||||
|
* `initialize()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`.
|
||||||
|
* If `instance` does not have a `memory` export an exception is thrown.
|
||||||
|
*
|
||||||
|
* If `initialize()` is called more than once, an exception is thrown.
|
||||||
|
* @since v14.6.0, v12.19.0
|
||||||
|
*/
|
||||||
|
initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
|
||||||
|
/**
|
||||||
|
* `wasiImport` is an object that implements the WASI system call API. This object
|
||||||
|
* should be passed as the `wasi_snapshot_preview1` import during the instantiation
|
||||||
|
* of a [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance).
|
||||||
|
* @since v13.3.0, v12.16.0
|
||||||
|
*/
|
||||||
|
readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:wasi" {
|
||||||
|
export * from "wasi";
|
||||||
|
}
|
712
websocket_server/node_modules/.ignored/@types/node/worker_threads.d.ts
generated
vendored
Normal file
712
websocket_server/node_modules/.ignored/@types/node/worker_threads.d.ts
generated
vendored
Normal file
@ -0,0 +1,712 @@
|
|||||||
|
/**
|
||||||
|
* The `node:worker_threads` module enables the use of threads that execute
|
||||||
|
* JavaScript in parallel. To access it:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import worker from 'node:worker_threads';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Workers (threads) are useful for performing CPU-intensive JavaScript operations.
|
||||||
|
* They do not help much with I/O-intensive work. The Node.js built-in
|
||||||
|
* asynchronous I/O operations are more efficient than Workers can be.
|
||||||
|
*
|
||||||
|
* Unlike `child_process` or `cluster`, `worker_threads` can share memory. They do
|
||||||
|
* so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer` instances.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* Worker, isMainThread, parentPort, workerData,
|
||||||
|
* } from 'node:worker_threads';
|
||||||
|
* import { parse } from 'some-js-parsing-library';
|
||||||
|
*
|
||||||
|
* if (isMainThread) {
|
||||||
|
* module.exports = function parseJSAsync(script) {
|
||||||
|
* return new Promise((resolve, reject) => {
|
||||||
|
* const worker = new Worker(__filename, {
|
||||||
|
* workerData: script,
|
||||||
|
* });
|
||||||
|
* worker.on('message', resolve);
|
||||||
|
* worker.on('error', reject);
|
||||||
|
* worker.on('exit', (code) => {
|
||||||
|
* if (code !== 0)
|
||||||
|
* reject(new Error(`Worker stopped with exit code ${code}`));
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* };
|
||||||
|
* } else {
|
||||||
|
* const script = workerData;
|
||||||
|
* parentPort.postMessage(parse(script));
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The above example spawns a Worker thread for each `parseJSAsync()` call. In
|
||||||
|
* practice, use a pool of Workers for these kinds of tasks. Otherwise, the
|
||||||
|
* overhead of creating Workers would likely exceed their benefit.
|
||||||
|
*
|
||||||
|
* When implementing a worker pool, use the `AsyncResource` API to inform
|
||||||
|
* diagnostic tools (e.g. to provide asynchronous stack traces) about the
|
||||||
|
* correlation between tasks and their outcomes. See `"Using AsyncResource for a Worker thread pool"` in the `async_hooks` documentation for an example implementation.
|
||||||
|
*
|
||||||
|
* Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
|
||||||
|
* specifically `argv` and `execArgv` options.
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/worker_threads.js)
|
||||||
|
*/
|
||||||
|
declare module "worker_threads" {
|
||||||
|
import { Blob } from "node:buffer";
|
||||||
|
import { Context } from "node:vm";
|
||||||
|
import { EventEmitter } from "node:events";
|
||||||
|
import { EventLoopUtilityFunction } from "node:perf_hooks";
|
||||||
|
import { FileHandle } from "node:fs/promises";
|
||||||
|
import { Readable, Writable } from "node:stream";
|
||||||
|
import { URL } from "node:url";
|
||||||
|
import { X509Certificate } from "node:crypto";
|
||||||
|
const isMainThread: boolean;
|
||||||
|
const parentPort: null | MessagePort;
|
||||||
|
const resourceLimits: ResourceLimits;
|
||||||
|
const SHARE_ENV: unique symbol;
|
||||||
|
const threadId: number;
|
||||||
|
const workerData: any;
|
||||||
|
/**
|
||||||
|
* Instances of the `worker.MessageChannel` class represent an asynchronous,
|
||||||
|
* two-way communications channel.
|
||||||
|
* The `MessageChannel` has no methods of its own. `new MessageChannel()` yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { MessageChannel } from 'node:worker_threads';
|
||||||
|
*
|
||||||
|
* const { port1, port2 } = new MessageChannel();
|
||||||
|
* port1.on('message', (message) => console.log('received', message));
|
||||||
|
* port2.postMessage({ foo: 'bar' });
|
||||||
|
* // Prints: received { foo: 'bar' } from the `port1.on('message')` listener
|
||||||
|
* ```
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
class MessageChannel {
|
||||||
|
readonly port1: MessagePort;
|
||||||
|
readonly port2: MessagePort;
|
||||||
|
}
|
||||||
|
interface WorkerPerformance {
|
||||||
|
eventLoopUtilization: EventLoopUtilityFunction;
|
||||||
|
}
|
||||||
|
type TransferListItem = ArrayBuffer | MessagePort | FileHandle | X509Certificate | Blob;
|
||||||
|
/**
|
||||||
|
* Instances of the `worker.MessagePort` class represent one end of an
|
||||||
|
* asynchronous, two-way communications channel. It can be used to transfer
|
||||||
|
* structured data, memory regions and other `MessagePort`s between different `Worker`s.
|
||||||
|
*
|
||||||
|
* This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
class MessagePort extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* Disables further sending of messages on either side of the connection.
|
||||||
|
* This method can be called when no further communication will happen over this `MessagePort`.
|
||||||
|
*
|
||||||
|
* The `'close' event` is emitted on both `MessagePort` instances that
|
||||||
|
* are part of the channel.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
close(): void;
|
||||||
|
/**
|
||||||
|
* Sends a JavaScript value to the receiving side of this channel. `value` is transferred in a way which is compatible with
|
||||||
|
* the [HTML structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).
|
||||||
|
*
|
||||||
|
* In particular, the significant differences to `JSON` are:
|
||||||
|
*
|
||||||
|
* * `value` may contain circular references.
|
||||||
|
* * `value` may contain instances of builtin JS types such as `RegExp`s, `BigInt`s, `Map`s, `Set`s, etc.
|
||||||
|
* * `value` may contain typed arrays, both using `ArrayBuffer`s
|
||||||
|
* and `SharedArrayBuffer`s.
|
||||||
|
* * `value` may contain [`WebAssembly.Module`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module) instances.
|
||||||
|
* * `value` may not contain native (C++-backed) objects other than:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { MessageChannel } from 'node:worker_threads';
|
||||||
|
* const { port1, port2 } = new MessageChannel();
|
||||||
|
*
|
||||||
|
* port1.on('message', (message) => console.log(message));
|
||||||
|
*
|
||||||
|
* const circularData = {};
|
||||||
|
* circularData.foo = circularData;
|
||||||
|
* // Prints: { foo: [Circular] }
|
||||||
|
* port2.postMessage(circularData);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort`, and `FileHandle` objects.
|
||||||
|
* After transferring, they are not usable on the sending side of the channel
|
||||||
|
* anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently
|
||||||
|
* not supported.
|
||||||
|
*
|
||||||
|
* If `value` contains [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances, those are accessible
|
||||||
|
* from either thread. They cannot be listed in `transferList`.
|
||||||
|
*
|
||||||
|
* `value` may still contain `ArrayBuffer` instances that are not in `transferList`; in that case, the underlying memory is copied rather than moved.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { MessageChannel } from 'node:worker_threads';
|
||||||
|
* const { port1, port2 } = new MessageChannel();
|
||||||
|
*
|
||||||
|
* port1.on('message', (message) => console.log(message));
|
||||||
|
*
|
||||||
|
* const uint8Array = new Uint8Array([ 1, 2, 3, 4 ]);
|
||||||
|
* // This posts a copy of `uint8Array`:
|
||||||
|
* port2.postMessage(uint8Array);
|
||||||
|
* // This does not copy data, but renders `uint8Array` unusable:
|
||||||
|
* port2.postMessage(uint8Array, [ uint8Array.buffer ]);
|
||||||
|
*
|
||||||
|
* // The memory for the `sharedUint8Array` is accessible from both the
|
||||||
|
* // original and the copy received by `.on('message')`:
|
||||||
|
* const sharedUint8Array = new Uint8Array(new SharedArrayBuffer(4));
|
||||||
|
* port2.postMessage(sharedUint8Array);
|
||||||
|
*
|
||||||
|
* // This transfers a freshly created message port to the receiver.
|
||||||
|
* // This can be used, for example, to create communication channels between
|
||||||
|
* // multiple `Worker` threads that are children of the same parent thread.
|
||||||
|
* const otherChannel = new MessageChannel();
|
||||||
|
* port2.postMessage({ port: otherChannel.port1 }, [ otherChannel.port1 ]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The message object is cloned immediately, and can be modified after
|
||||||
|
* posting without having side effects.
|
||||||
|
*
|
||||||
|
* For more information on the serialization and deserialization mechanisms
|
||||||
|
* behind this API, see the `serialization API of the node:v8 module`.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
postMessage(value: any, transferList?: readonly TransferListItem[]): void;
|
||||||
|
/**
|
||||||
|
* Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
|
||||||
|
* behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
|
||||||
|
*
|
||||||
|
* If listeners are attached or removed using `.on('message')`, the port
|
||||||
|
* is `ref()`ed and `unref()`ed automatically depending on whether
|
||||||
|
* listeners for the event exist.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
ref(): void;
|
||||||
|
/**
|
||||||
|
* Calling `unref()` on a port allows the thread to exit if this is the only
|
||||||
|
* active handle in the event system. If the port is already `unref()`ed calling `unref()` again has no effect.
|
||||||
|
*
|
||||||
|
* If listeners are attached or removed using `.on('message')`, the port is `ref()`ed and `unref()`ed automatically depending on whether
|
||||||
|
* listeners for the event exist.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
unref(): void;
|
||||||
|
/**
|
||||||
|
* Starts receiving messages on this `MessagePort`. When using this port
|
||||||
|
* as an event emitter, this is called automatically once `'message'` listeners are attached.
|
||||||
|
*
|
||||||
|
* This method exists for parity with the Web `MessagePort` API. In Node.js,
|
||||||
|
* it is only useful for ignoring messages when no event listener is present.
|
||||||
|
* Node.js also diverges in its handling of `.onmessage`. Setting it
|
||||||
|
* automatically calls `.start()`, but unsetting it lets messages queue up
|
||||||
|
* until a new handler is set or the port is discarded.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
start(): void;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
addListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
emit(event: "close"): boolean;
|
||||||
|
emit(event: "message", value: any): boolean;
|
||||||
|
emit(event: "messageerror", error: Error): boolean;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "message", listener: (value: any) => void): this;
|
||||||
|
on(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "message", listener: (value: any) => void): this;
|
||||||
|
once(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
prependListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
removeListener(event: "close", listener: () => void): this;
|
||||||
|
removeListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
removeListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
off(event: "close", listener: () => void): this;
|
||||||
|
off(event: "message", listener: (value: any) => void): this;
|
||||||
|
off(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
addEventListener: EventTarget["addEventListener"];
|
||||||
|
dispatchEvent: EventTarget["dispatchEvent"];
|
||||||
|
removeEventListener: EventTarget["removeEventListener"];
|
||||||
|
}
|
||||||
|
interface WorkerOptions {
|
||||||
|
/**
|
||||||
|
* List of arguments which would be stringified and appended to
|
||||||
|
* `process.argv` in the worker. This is mostly similar to the `workerData`
|
||||||
|
* but the values will be available on the global `process.argv` as if they
|
||||||
|
* were passed as CLI options to the script.
|
||||||
|
*/
|
||||||
|
argv?: any[] | undefined;
|
||||||
|
env?: NodeJS.Dict<string> | typeof SHARE_ENV | undefined;
|
||||||
|
eval?: boolean | undefined;
|
||||||
|
workerData?: any;
|
||||||
|
stdin?: boolean | undefined;
|
||||||
|
stdout?: boolean | undefined;
|
||||||
|
stderr?: boolean | undefined;
|
||||||
|
execArgv?: string[] | undefined;
|
||||||
|
resourceLimits?: ResourceLimits | undefined;
|
||||||
|
/**
|
||||||
|
* Additional data to send in the first worker message.
|
||||||
|
*/
|
||||||
|
transferList?: TransferListItem[] | undefined;
|
||||||
|
/**
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
trackUnmanagedFds?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* An optional `name` to be appended to the worker title
|
||||||
|
* for debuggin/identification purposes, making the final title as
|
||||||
|
* `[worker ${id}] ${name}`.
|
||||||
|
*/
|
||||||
|
name?: string | undefined;
|
||||||
|
}
|
||||||
|
interface ResourceLimits {
|
||||||
|
/**
|
||||||
|
* The maximum size of a heap space for recently created objects.
|
||||||
|
*/
|
||||||
|
maxYoungGenerationSizeMb?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The maximum size of the main heap in MB.
|
||||||
|
*/
|
||||||
|
maxOldGenerationSizeMb?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The size of a pre-allocated memory range used for generated code.
|
||||||
|
*/
|
||||||
|
codeRangeSizeMb?: number | undefined;
|
||||||
|
/**
|
||||||
|
* The default maximum stack size for the thread. Small values may lead to unusable Worker instances.
|
||||||
|
* @default 4
|
||||||
|
*/
|
||||||
|
stackSizeMb?: number | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The `Worker` class represents an independent JavaScript execution thread.
|
||||||
|
* Most Node.js APIs are available inside of it.
|
||||||
|
*
|
||||||
|
* Notable differences inside a Worker environment are:
|
||||||
|
*
|
||||||
|
* * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
|
||||||
|
* * The `import { isMainThread } from 'node:worker_threads'` variable is set to `false`.
|
||||||
|
* * The `import { parentPort } from 'node:worker_threads'` message port is available.
|
||||||
|
* * `process.exit()` does not stop the whole program, just the single thread,
|
||||||
|
* and `process.abort()` is not available.
|
||||||
|
* * `process.chdir()` and `process` methods that set group or user ids
|
||||||
|
* are not available.
|
||||||
|
* * `process.env` is a copy of the parent thread's environment variables,
|
||||||
|
* unless otherwise specified. Changes to one copy are not visible in other
|
||||||
|
* threads, and are not visible to native add-ons (unless `worker.SHARE_ENV` is passed as the `env` option to the `Worker` constructor). On Windows, unlike the main thread, a copy of the
|
||||||
|
* environment variables operates in a case-sensitive manner.
|
||||||
|
* * `process.title` cannot be modified.
|
||||||
|
* * Signals are not delivered through `process.on('...')`.
|
||||||
|
* * Execution may stop at any point as a result of `worker.terminate()` being invoked.
|
||||||
|
* * IPC channels from parent processes are not accessible.
|
||||||
|
* * The `trace_events` module is not supported.
|
||||||
|
* * Native add-ons can only be loaded from multiple threads if they fulfill `certain conditions`.
|
||||||
|
*
|
||||||
|
* Creating `Worker` instances inside of other `Worker`s is possible.
|
||||||
|
*
|
||||||
|
* Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `node:cluster module`, two-way communication
|
||||||
|
* can be achieved through inter-thread message passing. Internally, a `Worker` has
|
||||||
|
* a built-in pair of `MessagePort` s that are already associated with each
|
||||||
|
* other when the `Worker` is created. While the `MessagePort` object on the parent
|
||||||
|
* side is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
|
||||||
|
* on the `Worker` object for the parent thread.
|
||||||
|
*
|
||||||
|
* To create custom messaging channels (which is encouraged over using the default
|
||||||
|
* global channel because it facilitates separation of concerns), users can create
|
||||||
|
* a `MessageChannel` object on either thread and pass one of the`MessagePort`s on that `MessageChannel` to the other thread through a
|
||||||
|
* pre-existing channel, such as the global one.
|
||||||
|
*
|
||||||
|
* See `port.postMessage()` for more information on how messages are passed,
|
||||||
|
* and what kind of JavaScript values can be successfully transported through
|
||||||
|
* the thread barrier.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from 'node:assert';
|
||||||
|
* import {
|
||||||
|
* Worker, MessageChannel, MessagePort, isMainThread, parentPort,
|
||||||
|
* } from 'node:worker_threads';
|
||||||
|
* if (isMainThread) {
|
||||||
|
* const worker = new Worker(__filename);
|
||||||
|
* const subChannel = new MessageChannel();
|
||||||
|
* worker.postMessage({ hereIsYourPort: subChannel.port1 }, [subChannel.port1]);
|
||||||
|
* subChannel.port2.on('message', (value) => {
|
||||||
|
* console.log('received:', value);
|
||||||
|
* });
|
||||||
|
* } else {
|
||||||
|
* parentPort.once('message', (value) => {
|
||||||
|
* assert(value.hereIsYourPort instanceof MessagePort);
|
||||||
|
* value.hereIsYourPort.postMessage('the worker is sending this');
|
||||||
|
* value.hereIsYourPort.close();
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
class Worker extends EventEmitter {
|
||||||
|
/**
|
||||||
|
* If `stdin: true` was passed to the `Worker` constructor, this is a
|
||||||
|
* writable stream. The data written to this stream will be made available in
|
||||||
|
* the worker thread as `process.stdin`.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
readonly stdin: Writable | null;
|
||||||
|
/**
|
||||||
|
* This is a readable stream which contains data written to `process.stdout` inside the worker thread. If `stdout: true` was not passed to the `Worker` constructor, then data is piped to the
|
||||||
|
* parent thread's `process.stdout` stream.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
readonly stdout: Readable;
|
||||||
|
/**
|
||||||
|
* This is a readable stream which contains data written to `process.stderr` inside the worker thread. If `stderr: true` was not passed to the `Worker` constructor, then data is piped to the
|
||||||
|
* parent thread's `process.stderr` stream.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
readonly stderr: Readable;
|
||||||
|
/**
|
||||||
|
* An integer identifier for the referenced thread. Inside the worker thread,
|
||||||
|
* it is available as `import { threadId } from 'node:worker_threads'`.
|
||||||
|
* This value is unique for each `Worker` instance inside a single process.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
readonly threadId: number;
|
||||||
|
/**
|
||||||
|
* Provides the set of JS engine resource constraints for this Worker thread.
|
||||||
|
* If the `resourceLimits` option was passed to the `Worker` constructor,
|
||||||
|
* this matches its values.
|
||||||
|
*
|
||||||
|
* If the worker has stopped, the return value is an empty object.
|
||||||
|
* @since v13.2.0, v12.16.0
|
||||||
|
*/
|
||||||
|
readonly resourceLimits?: ResourceLimits | undefined;
|
||||||
|
/**
|
||||||
|
* An object that can be used to query performance information from a worker
|
||||||
|
* instance. Similar to `perf_hooks.performance`.
|
||||||
|
* @since v15.1.0, v14.17.0, v12.22.0
|
||||||
|
*/
|
||||||
|
readonly performance: WorkerPerformance;
|
||||||
|
/**
|
||||||
|
* @param filename The path to the Worker’s main script or module.
|
||||||
|
* Must be either an absolute path or a relative path (i.e. relative to the current working directory) starting with ./ or ../,
|
||||||
|
* or a WHATWG URL object using file: protocol. If options.eval is true, this is a string containing JavaScript code rather than a path.
|
||||||
|
*/
|
||||||
|
constructor(filename: string | URL, options?: WorkerOptions);
|
||||||
|
/**
|
||||||
|
* Send a message to the worker that is received via `require('node:worker_threads').parentPort.on('message')`.
|
||||||
|
* See `port.postMessage()` for more details.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
postMessage(value: any, transferList?: readonly TransferListItem[]): void;
|
||||||
|
/**
|
||||||
|
* Sends a value to another worker, identified by its thread ID.
|
||||||
|
* @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
|
||||||
|
* If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
|
||||||
|
* @param value The value to send.
|
||||||
|
* @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
|
||||||
|
* or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
|
||||||
|
* @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
|
||||||
|
* If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
|
||||||
|
* @since v22.5.0
|
||||||
|
*/
|
||||||
|
postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
|
||||||
|
postMessageToThread(
|
||||||
|
threadId: number,
|
||||||
|
value: any,
|
||||||
|
transferList: readonly TransferListItem[],
|
||||||
|
timeout?: number,
|
||||||
|
): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
|
||||||
|
* behavior). If the worker is `ref()`ed, calling `ref()` again has
|
||||||
|
* no effect.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
ref(): void;
|
||||||
|
/**
|
||||||
|
* Calling `unref()` on a worker allows the thread to exit if this is the only
|
||||||
|
* active handle in the event system. If the worker is already `unref()`ed calling `unref()` again has no effect.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
unref(): void;
|
||||||
|
/**
|
||||||
|
* Stop all JavaScript execution in the worker thread as soon as possible.
|
||||||
|
* Returns a Promise for the exit code that is fulfilled when the `'exit' event` is emitted.
|
||||||
|
* @since v10.5.0
|
||||||
|
*/
|
||||||
|
terminate(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Returns a readable stream for a V8 snapshot of the current state of the Worker.
|
||||||
|
* See `v8.getHeapSnapshot()` for more details.
|
||||||
|
*
|
||||||
|
* If the Worker thread is no longer running, which may occur before the `'exit' event` is emitted, the returned `Promise` is rejected
|
||||||
|
* immediately with an `ERR_WORKER_NOT_RUNNING` error.
|
||||||
|
* @since v13.9.0, v12.17.0
|
||||||
|
* @return A promise for a Readable Stream containing a V8 heap snapshot
|
||||||
|
*/
|
||||||
|
getHeapSnapshot(): Promise<Readable>;
|
||||||
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
addListener(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
addListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
addListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
addListener(event: "online", listener: () => void): this;
|
||||||
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
emit(event: "error", err: Error): boolean;
|
||||||
|
emit(event: "exit", exitCode: number): boolean;
|
||||||
|
emit(event: "message", value: any): boolean;
|
||||||
|
emit(event: "messageerror", error: Error): boolean;
|
||||||
|
emit(event: "online"): boolean;
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
|
on(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
on(event: "message", listener: (value: any) => void): this;
|
||||||
|
on(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
on(event: "online", listener: () => void): this;
|
||||||
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
|
once(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
once(event: "message", listener: (value: any) => void): this;
|
||||||
|
once(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
once(event: "online", listener: () => void): this;
|
||||||
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependListener(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
prependListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
prependListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
prependListener(event: "online", listener: () => void): this;
|
||||||
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependOnceListener(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
prependOnceListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
prependOnceListener(event: "online", listener: () => void): this;
|
||||||
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
removeListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
removeListener(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
removeListener(event: "message", listener: (value: any) => void): this;
|
||||||
|
removeListener(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
removeListener(event: "online", listener: () => void): this;
|
||||||
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
off(event: "error", listener: (err: Error) => void): this;
|
||||||
|
off(event: "exit", listener: (exitCode: number) => void): this;
|
||||||
|
off(event: "message", listener: (value: any) => void): this;
|
||||||
|
off(event: "messageerror", listener: (error: Error) => void): this;
|
||||||
|
off(event: "online", listener: () => void): this;
|
||||||
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
}
|
||||||
|
interface BroadcastChannel extends NodeJS.RefCounted {}
|
||||||
|
/**
|
||||||
|
* Instances of `BroadcastChannel` allow asynchronous one-to-many communication
|
||||||
|
* with all other `BroadcastChannel` instances bound to the same channel name.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* 'use strict';
|
||||||
|
*
|
||||||
|
* import {
|
||||||
|
* isMainThread,
|
||||||
|
* BroadcastChannel,
|
||||||
|
* Worker,
|
||||||
|
* } from 'node:worker_threads';
|
||||||
|
*
|
||||||
|
* const bc = new BroadcastChannel('hello');
|
||||||
|
*
|
||||||
|
* if (isMainThread) {
|
||||||
|
* let c = 0;
|
||||||
|
* bc.onmessage = (event) => {
|
||||||
|
* console.log(event.data);
|
||||||
|
* if (++c === 10) bc.close();
|
||||||
|
* };
|
||||||
|
* for (let n = 0; n < 10; n++)
|
||||||
|
* new Worker(__filename);
|
||||||
|
* } else {
|
||||||
|
* bc.postMessage('hello from every worker');
|
||||||
|
* bc.close();
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v15.4.0
|
||||||
|
*/
|
||||||
|
class BroadcastChannel {
|
||||||
|
readonly name: string;
|
||||||
|
/**
|
||||||
|
* Invoked with a single \`MessageEvent\` argument when a message is received.
|
||||||
|
* @since v15.4.0
|
||||||
|
*/
|
||||||
|
onmessage: (message: unknown) => void;
|
||||||
|
/**
|
||||||
|
* Invoked with a received message cannot be deserialized.
|
||||||
|
* @since v15.4.0
|
||||||
|
*/
|
||||||
|
onmessageerror: (message: unknown) => void;
|
||||||
|
constructor(name: string);
|
||||||
|
/**
|
||||||
|
* Closes the `BroadcastChannel` connection.
|
||||||
|
* @since v15.4.0
|
||||||
|
*/
|
||||||
|
close(): void;
|
||||||
|
/**
|
||||||
|
* @since v15.4.0
|
||||||
|
* @param message Any cloneable JavaScript value.
|
||||||
|
*/
|
||||||
|
postMessage(message: unknown): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark an object as not transferable. If `object` occurs in the transfer list of
|
||||||
|
* a `port.postMessage()` call, it is ignored.
|
||||||
|
*
|
||||||
|
* In particular, this makes sense for objects that can be cloned, rather than
|
||||||
|
* transferred, and which are used by other objects on the sending side.
|
||||||
|
* For example, Node.js marks the `ArrayBuffer`s it uses for its `Buffer pool` with this.
|
||||||
|
*
|
||||||
|
* This operation cannot be undone.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { MessageChannel, markAsUntransferable } from 'node:worker_threads';
|
||||||
|
*
|
||||||
|
* const pooledBuffer = new ArrayBuffer(8);
|
||||||
|
* const typedArray1 = new Uint8Array(pooledBuffer);
|
||||||
|
* const typedArray2 = new Float64Array(pooledBuffer);
|
||||||
|
*
|
||||||
|
* markAsUntransferable(pooledBuffer);
|
||||||
|
*
|
||||||
|
* const { port1 } = new MessageChannel();
|
||||||
|
* port1.postMessage(typedArray1, [ typedArray1.buffer ]);
|
||||||
|
*
|
||||||
|
* // The following line prints the contents of typedArray1 -- it still owns
|
||||||
|
* // its memory and has been cloned, not transferred. Without
|
||||||
|
* // `markAsUntransferable()`, this would print an empty Uint8Array.
|
||||||
|
* // typedArray2 is intact as well.
|
||||||
|
* console.log(typedArray1);
|
||||||
|
* console.log(typedArray2);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* There is no equivalent to this API in browsers.
|
||||||
|
* @since v14.5.0, v12.19.0
|
||||||
|
*/
|
||||||
|
function markAsUntransferable(object: object): void;
|
||||||
|
/**
|
||||||
|
* Transfer a `MessagePort` to a different `vm` Context. The original `port` object is rendered unusable, and the returned `MessagePort` instance
|
||||||
|
* takes its place.
|
||||||
|
*
|
||||||
|
* The returned `MessagePort` is an object in the target context and
|
||||||
|
* inherits from its global `Object` class. Objects passed to the [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) listener are also created in the
|
||||||
|
* target context
|
||||||
|
* and inherit from its global `Object` class.
|
||||||
|
*
|
||||||
|
* However, the created `MessagePort` no longer inherits from [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), and only
|
||||||
|
* [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) can be used to receive
|
||||||
|
* events using it.
|
||||||
|
* @since v11.13.0
|
||||||
|
* @param port The message port to transfer.
|
||||||
|
* @param contextifiedSandbox A `contextified` object as returned by the `vm.createContext()` method.
|
||||||
|
*/
|
||||||
|
function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort;
|
||||||
|
/**
|
||||||
|
* Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property
|
||||||
|
* that contains the message payload, corresponding to the oldest message in the `MessagePort`'s queue.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { MessageChannel, receiveMessageOnPort } from 'node:worker_threads';
|
||||||
|
* const { port1, port2 } = new MessageChannel();
|
||||||
|
* port1.postMessage({ hello: 'world' });
|
||||||
|
*
|
||||||
|
* console.log(receiveMessageOnPort(port2));
|
||||||
|
* // Prints: { message: { hello: 'world' } }
|
||||||
|
* console.log(receiveMessageOnPort(port2));
|
||||||
|
* // Prints: undefined
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* When this function is used, no `'message'` event is emitted and the `onmessage` listener is not invoked.
|
||||||
|
* @since v12.3.0
|
||||||
|
*/
|
||||||
|
function receiveMessageOnPort(port: MessagePort):
|
||||||
|
| {
|
||||||
|
message: any;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
type Serializable = string | object | number | boolean | bigint;
|
||||||
|
/**
|
||||||
|
* Within a worker thread, `worker.getEnvironmentData()` returns a clone
|
||||||
|
* of data passed to the spawning thread's `worker.setEnvironmentData()`.
|
||||||
|
* Every new `Worker` receives its own copy of the environment data
|
||||||
|
* automatically.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import {
|
||||||
|
* Worker,
|
||||||
|
* isMainThread,
|
||||||
|
* setEnvironmentData,
|
||||||
|
* getEnvironmentData,
|
||||||
|
* } from 'node:worker_threads';
|
||||||
|
*
|
||||||
|
* if (isMainThread) {
|
||||||
|
* setEnvironmentData('Hello', 'World!');
|
||||||
|
* const worker = new Worker(__filename);
|
||||||
|
* } else {
|
||||||
|
* console.log(getEnvironmentData('Hello')); // Prints 'World!'.
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v15.12.0, v14.18.0
|
||||||
|
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
|
||||||
|
*/
|
||||||
|
function getEnvironmentData(key: Serializable): Serializable;
|
||||||
|
/**
|
||||||
|
* The `worker.setEnvironmentData()` API sets the content of `worker.getEnvironmentData()` in the current thread and all new `Worker` instances spawned from the current context.
|
||||||
|
* @since v15.12.0, v14.18.0
|
||||||
|
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
|
||||||
|
* @param value Any arbitrary, cloneable JavaScript value that will be cloned and passed automatically to all new `Worker` instances. If `value` is passed as `undefined`, any previously set value
|
||||||
|
* for the `key` will be deleted.
|
||||||
|
*/
|
||||||
|
function setEnvironmentData(key: Serializable, value: Serializable): void;
|
||||||
|
|
||||||
|
import {
|
||||||
|
BroadcastChannel as _BroadcastChannel,
|
||||||
|
MessageChannel as _MessageChannel,
|
||||||
|
MessagePort as _MessagePort,
|
||||||
|
} from "worker_threads";
|
||||||
|
global {
|
||||||
|
/**
|
||||||
|
* `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'worker_threads'`
|
||||||
|
* https://nodejs.org/api/globals.html#broadcastchannel
|
||||||
|
* @since v18.0.0
|
||||||
|
*/
|
||||||
|
var BroadcastChannel: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
BroadcastChannel: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _BroadcastChannel;
|
||||||
|
/**
|
||||||
|
* `MessageChannel` class is a global reference for `import { MessageChannel } from 'worker_threads'`
|
||||||
|
* https://nodejs.org/api/globals.html#messagechannel
|
||||||
|
* @since v15.0.0
|
||||||
|
*/
|
||||||
|
var MessageChannel: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
MessageChannel: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _MessageChannel;
|
||||||
|
/**
|
||||||
|
* `MessagePort` class is a global reference for `import { MessagePort } from 'worker_threads'`
|
||||||
|
* https://nodejs.org/api/globals.html#messageport
|
||||||
|
* @since v15.0.0
|
||||||
|
*/
|
||||||
|
var MessagePort: typeof globalThis extends {
|
||||||
|
onmessage: any;
|
||||||
|
MessagePort: infer T;
|
||||||
|
} ? T
|
||||||
|
: typeof _MessagePort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module "node:worker_threads" {
|
||||||
|
export * from "worker_threads";
|
||||||
|
}
|
539
websocket_server/node_modules/.ignored/@types/node/zlib.d.ts
generated
vendored
Normal file
539
websocket_server/node_modules/.ignored/@types/node/zlib.d.ts
generated
vendored
Normal file
@ -0,0 +1,539 @@
|
|||||||
|
/**
|
||||||
|
* The `node:zlib` module provides compression functionality implemented using
|
||||||
|
* Gzip, Deflate/Inflate, and Brotli.
|
||||||
|
*
|
||||||
|
* To access it:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import zlib from 'node:zlib';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Compression and decompression are built around the Node.js
|
||||||
|
* [Streams API](https://nodejs.org/docs/latest-v22.x/api/stream.html).
|
||||||
|
*
|
||||||
|
* Compressing or decompressing a stream (such as a file) can be accomplished by
|
||||||
|
* piping the source stream through a `zlib` `Transform` stream into a destination
|
||||||
|
* stream:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { createGzip } from 'node:zlib';
|
||||||
|
* import { pipeline } from 'node:stream';
|
||||||
|
* import {
|
||||||
|
* createReadStream,
|
||||||
|
* createWriteStream,
|
||||||
|
* } from 'node:fs';
|
||||||
|
*
|
||||||
|
* const gzip = createGzip();
|
||||||
|
* const source = createReadStream('input.txt');
|
||||||
|
* const destination = createWriteStream('input.txt.gz');
|
||||||
|
*
|
||||||
|
* pipeline(source, gzip, destination, (err) => {
|
||||||
|
* if (err) {
|
||||||
|
* console.error('An error occurred:', err);
|
||||||
|
* process.exitCode = 1;
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Or, Promisified
|
||||||
|
*
|
||||||
|
* import { promisify } from 'node:util';
|
||||||
|
* const pipe = promisify(pipeline);
|
||||||
|
*
|
||||||
|
* async function do_gzip(input, output) {
|
||||||
|
* const gzip = createGzip();
|
||||||
|
* const source = createReadStream(input);
|
||||||
|
* const destination = createWriteStream(output);
|
||||||
|
* await pipe(source, gzip, destination);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* do_gzip('input.txt', 'input.txt.gz')
|
||||||
|
* .catch((err) => {
|
||||||
|
* console.error('An error occurred:', err);
|
||||||
|
* process.exitCode = 1;
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* It is also possible to compress or decompress data in a single step:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { deflate, unzip } from 'node:zlib';
|
||||||
|
*
|
||||||
|
* const input = '.................................';
|
||||||
|
* deflate(input, (err, buffer) => {
|
||||||
|
* if (err) {
|
||||||
|
* console.error('An error occurred:', err);
|
||||||
|
* process.exitCode = 1;
|
||||||
|
* }
|
||||||
|
* console.log(buffer.toString('base64'));
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* const buffer = Buffer.from('eJzT0yMAAGTvBe8=', 'base64');
|
||||||
|
* unzip(buffer, (err, buffer) => {
|
||||||
|
* if (err) {
|
||||||
|
* console.error('An error occurred:', err);
|
||||||
|
* process.exitCode = 1;
|
||||||
|
* }
|
||||||
|
* console.log(buffer.toString());
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Or, Promisified
|
||||||
|
*
|
||||||
|
* import { promisify } from 'node:util';
|
||||||
|
* const do_unzip = promisify(unzip);
|
||||||
|
*
|
||||||
|
* do_unzip(buffer)
|
||||||
|
* .then((buf) => console.log(buf.toString()))
|
||||||
|
* .catch((err) => {
|
||||||
|
* console.error('An error occurred:', err);
|
||||||
|
* process.exitCode = 1;
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
* @since v0.5.8
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/zlib.js)
|
||||||
|
*/
|
||||||
|
declare module "zlib" {
|
||||||
|
import * as stream from "node:stream";
|
||||||
|
interface ZlibOptions {
|
||||||
|
/**
|
||||||
|
* @default constants.Z_NO_FLUSH
|
||||||
|
*/
|
||||||
|
flush?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default constants.Z_FINISH
|
||||||
|
*/
|
||||||
|
finishFlush?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default 16*1024
|
||||||
|
*/
|
||||||
|
chunkSize?: number | undefined;
|
||||||
|
windowBits?: number | undefined;
|
||||||
|
level?: number | undefined; // compression only
|
||||||
|
memLevel?: number | undefined; // compression only
|
||||||
|
strategy?: number | undefined; // compression only
|
||||||
|
dictionary?: NodeJS.ArrayBufferView | ArrayBuffer | undefined; // deflate/inflate only, empty dictionary by default
|
||||||
|
/**
|
||||||
|
* If `true`, returns an object with `buffer` and `engine`.
|
||||||
|
*/
|
||||||
|
info?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Limits output size when using convenience methods.
|
||||||
|
* @default buffer.kMaxLength
|
||||||
|
*/
|
||||||
|
maxOutputLength?: number | undefined;
|
||||||
|
}
|
||||||
|
interface BrotliOptions {
|
||||||
|
/**
|
||||||
|
* @default constants.BROTLI_OPERATION_PROCESS
|
||||||
|
*/
|
||||||
|
flush?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default constants.BROTLI_OPERATION_FINISH
|
||||||
|
*/
|
||||||
|
finishFlush?: number | undefined;
|
||||||
|
/**
|
||||||
|
* @default 16*1024
|
||||||
|
*/
|
||||||
|
chunkSize?: number | undefined;
|
||||||
|
params?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Each key is a `constants.BROTLI_*` constant.
|
||||||
|
*/
|
||||||
|
[key: number]: boolean | number;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
/**
|
||||||
|
* Limits output size when using [convenience methods](https://nodejs.org/docs/latest-v22.x/api/zlib.html#convenience-methods).
|
||||||
|
* @default buffer.kMaxLength
|
||||||
|
*/
|
||||||
|
maxOutputLength?: number | undefined;
|
||||||
|
}
|
||||||
|
interface Zlib {
|
||||||
|
/** @deprecated Use bytesWritten instead. */
|
||||||
|
readonly bytesRead: number;
|
||||||
|
readonly bytesWritten: number;
|
||||||
|
shell?: boolean | string | undefined;
|
||||||
|
close(callback?: () => void): void;
|
||||||
|
flush(kind?: number, callback?: () => void): void;
|
||||||
|
flush(callback?: () => void): void;
|
||||||
|
}
|
||||||
|
interface ZlibParams {
|
||||||
|
params(level: number, strategy: number, callback: () => void): void;
|
||||||
|
}
|
||||||
|
interface ZlibReset {
|
||||||
|
reset(): void;
|
||||||
|
}
|
||||||
|
interface BrotliCompress extends stream.Transform, Zlib {}
|
||||||
|
interface BrotliDecompress extends stream.Transform, Zlib {}
|
||||||
|
interface Gzip extends stream.Transform, Zlib {}
|
||||||
|
interface Gunzip extends stream.Transform, Zlib {}
|
||||||
|
interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
|
||||||
|
interface Inflate extends stream.Transform, Zlib, ZlibReset {}
|
||||||
|
interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
|
||||||
|
interface InflateRaw extends stream.Transform, Zlib, ZlibReset {}
|
||||||
|
interface Unzip extends stream.Transform, Zlib {}
|
||||||
|
/**
|
||||||
|
* Computes a 32-bit [Cyclic Redundancy Check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) checksum of `data`.
|
||||||
|
* If `value` is specified, it is used as the starting value of the checksum, otherwise, 0 is used as the starting value.
|
||||||
|
* @param data When `data` is a string, it will be encoded as UTF-8 before being used for computation.
|
||||||
|
* @param value An optional starting value. It must be a 32-bit unsigned integer. @default 0
|
||||||
|
* @returns A 32-bit unsigned integer containing the checksum.
|
||||||
|
* @since v22.2.0
|
||||||
|
*/
|
||||||
|
function crc32(data: string | Buffer | NodeJS.ArrayBufferView, value?: number): number;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `BrotliCompress` object.
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function createBrotliCompress(options?: BrotliOptions): BrotliCompress;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `BrotliDecompress` object.
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function createBrotliDecompress(options?: BrotliOptions): BrotliDecompress;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `Gzip` object.
|
||||||
|
* See `example`.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createGzip(options?: ZlibOptions): Gzip;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `Gunzip` object.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createGunzip(options?: ZlibOptions): Gunzip;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `Deflate` object.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createDeflate(options?: ZlibOptions): Deflate;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `Inflate` object.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createInflate(options?: ZlibOptions): Inflate;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `DeflateRaw` object.
|
||||||
|
*
|
||||||
|
* An upgrade of zlib from 1.2.8 to 1.2.11 changed behavior when `windowBits` is set to 8 for raw deflate streams. zlib would automatically set `windowBits` to 9 if was initially set to 8. Newer
|
||||||
|
* versions of zlib will throw an exception,
|
||||||
|
* so Node.js restored the original behavior of upgrading a value of 8 to 9,
|
||||||
|
* since passing `windowBits = 9` to zlib actually results in a compressed stream
|
||||||
|
* that effectively uses an 8-bit window only.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `InflateRaw` object.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createInflateRaw(options?: ZlibOptions): InflateRaw;
|
||||||
|
/**
|
||||||
|
* Creates and returns a new `Unzip` object.
|
||||||
|
* @since v0.5.8
|
||||||
|
*/
|
||||||
|
function createUnzip(options?: ZlibOptions): Unzip;
|
||||||
|
type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
|
||||||
|
type CompressCallback = (error: Error | null, result: Buffer) => void;
|
||||||
|
/**
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
||||||
|
function brotliCompress(buf: InputType, callback: CompressCallback): void;
|
||||||
|
namespace brotliCompress {
|
||||||
|
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compress a chunk of data with `BrotliCompress`.
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function brotliCompressSync(buf: InputType, options?: BrotliOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
||||||
|
function brotliDecompress(buf: InputType, callback: CompressCallback): void;
|
||||||
|
namespace brotliDecompress {
|
||||||
|
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Decompress a chunk of data with `BrotliDecompress`.
|
||||||
|
* @since v11.7.0, v10.16.0
|
||||||
|
*/
|
||||||
|
function brotliDecompressSync(buf: InputType, options?: BrotliOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function deflate(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace deflate {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compress a chunk of data with `Deflate`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function deflateRaw(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace deflateRaw {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compress a chunk of data with `DeflateRaw`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function gzip(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace gzip {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compress a chunk of data with `Gzip`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function gunzip(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace gunzip {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Decompress a chunk of data with `Gunzip`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function inflate(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace inflate {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Decompress a chunk of data with `Inflate`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function inflateRaw(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace inflateRaw {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Decompress a chunk of data with `InflateRaw`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
/**
|
||||||
|
* @since v0.6.0
|
||||||
|
*/
|
||||||
|
function unzip(buf: InputType, callback: CompressCallback): void;
|
||||||
|
function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
||||||
|
namespace unzip {
|
||||||
|
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Decompress a chunk of data with `Unzip`.
|
||||||
|
* @since v0.11.12
|
||||||
|
*/
|
||||||
|
function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
||||||
|
namespace constants {
|
||||||
|
const BROTLI_DECODE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number;
|
||||||
|
const BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number;
|
||||||
|
const BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_RESERVED: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number;
|
||||||
|
const BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number;
|
||||||
|
const BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number;
|
||||||
|
const BROTLI_DECODER_ERROR_UNREACHABLE: number;
|
||||||
|
const BROTLI_DECODER_NEEDS_MORE_INPUT: number;
|
||||||
|
const BROTLI_DECODER_NEEDS_MORE_OUTPUT: number;
|
||||||
|
const BROTLI_DECODER_NO_ERROR: number;
|
||||||
|
const BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number;
|
||||||
|
const BROTLI_DECODER_PARAM_LARGE_WINDOW: number;
|
||||||
|
const BROTLI_DECODER_RESULT_ERROR: number;
|
||||||
|
const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number;
|
||||||
|
const BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number;
|
||||||
|
const BROTLI_DECODER_RESULT_SUCCESS: number;
|
||||||
|
const BROTLI_DECODER_SUCCESS: number;
|
||||||
|
const BROTLI_DEFAULT_MODE: number;
|
||||||
|
const BROTLI_DEFAULT_QUALITY: number;
|
||||||
|
const BROTLI_DEFAULT_WINDOW: number;
|
||||||
|
const BROTLI_ENCODE: number;
|
||||||
|
const BROTLI_LARGE_MAX_WINDOW_BITS: number;
|
||||||
|
const BROTLI_MAX_INPUT_BLOCK_BITS: number;
|
||||||
|
const BROTLI_MAX_QUALITY: number;
|
||||||
|
const BROTLI_MAX_WINDOW_BITS: number;
|
||||||
|
const BROTLI_MIN_INPUT_BLOCK_BITS: number;
|
||||||
|
const BROTLI_MIN_QUALITY: number;
|
||||||
|
const BROTLI_MIN_WINDOW_BITS: number;
|
||||||
|
const BROTLI_MODE_FONT: number;
|
||||||
|
const BROTLI_MODE_GENERIC: number;
|
||||||
|
const BROTLI_MODE_TEXT: number;
|
||||||
|
const BROTLI_OPERATION_EMIT_METADATA: number;
|
||||||
|
const BROTLI_OPERATION_FINISH: number;
|
||||||
|
const BROTLI_OPERATION_FLUSH: number;
|
||||||
|
const BROTLI_OPERATION_PROCESS: number;
|
||||||
|
const BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number;
|
||||||
|
const BROTLI_PARAM_LARGE_WINDOW: number;
|
||||||
|
const BROTLI_PARAM_LGBLOCK: number;
|
||||||
|
const BROTLI_PARAM_LGWIN: number;
|
||||||
|
const BROTLI_PARAM_MODE: number;
|
||||||
|
const BROTLI_PARAM_NDIRECT: number;
|
||||||
|
const BROTLI_PARAM_NPOSTFIX: number;
|
||||||
|
const BROTLI_PARAM_QUALITY: number;
|
||||||
|
const BROTLI_PARAM_SIZE_HINT: number;
|
||||||
|
const DEFLATE: number;
|
||||||
|
const DEFLATERAW: number;
|
||||||
|
const GUNZIP: number;
|
||||||
|
const GZIP: number;
|
||||||
|
const INFLATE: number;
|
||||||
|
const INFLATERAW: number;
|
||||||
|
const UNZIP: number;
|
||||||
|
// Allowed flush values.
|
||||||
|
const Z_NO_FLUSH: number;
|
||||||
|
const Z_PARTIAL_FLUSH: number;
|
||||||
|
const Z_SYNC_FLUSH: number;
|
||||||
|
const Z_FULL_FLUSH: number;
|
||||||
|
const Z_FINISH: number;
|
||||||
|
const Z_BLOCK: number;
|
||||||
|
const Z_TREES: number;
|
||||||
|
// Return codes for the compression/decompression functions.
|
||||||
|
// Negative values are errors, positive values are used for special but normal events.
|
||||||
|
const Z_OK: number;
|
||||||
|
const Z_STREAM_END: number;
|
||||||
|
const Z_NEED_DICT: number;
|
||||||
|
const Z_ERRNO: number;
|
||||||
|
const Z_STREAM_ERROR: number;
|
||||||
|
const Z_DATA_ERROR: number;
|
||||||
|
const Z_MEM_ERROR: number;
|
||||||
|
const Z_BUF_ERROR: number;
|
||||||
|
const Z_VERSION_ERROR: number;
|
||||||
|
// Compression levels.
|
||||||
|
const Z_NO_COMPRESSION: number;
|
||||||
|
const Z_BEST_SPEED: number;
|
||||||
|
const Z_BEST_COMPRESSION: number;
|
||||||
|
const Z_DEFAULT_COMPRESSION: number;
|
||||||
|
// Compression strategy.
|
||||||
|
const Z_FILTERED: number;
|
||||||
|
const Z_HUFFMAN_ONLY: number;
|
||||||
|
const Z_RLE: number;
|
||||||
|
const Z_FIXED: number;
|
||||||
|
const Z_DEFAULT_STRATEGY: number;
|
||||||
|
const Z_DEFAULT_WINDOWBITS: number;
|
||||||
|
|
||||||
|
const Z_MIN_WINDOWBITS: number;
|
||||||
|
const Z_MAX_WINDOWBITS: number;
|
||||||
|
const Z_MIN_CHUNK: number;
|
||||||
|
const Z_MAX_CHUNK: number;
|
||||||
|
const Z_DEFAULT_CHUNK: number;
|
||||||
|
const Z_MIN_MEMLEVEL: number;
|
||||||
|
const Z_MAX_MEMLEVEL: number;
|
||||||
|
const Z_DEFAULT_MEMLEVEL: number;
|
||||||
|
const Z_MIN_LEVEL: number;
|
||||||
|
const Z_MAX_LEVEL: number;
|
||||||
|
const Z_DEFAULT_LEVEL: number;
|
||||||
|
const ZLIB_VERNUM: number;
|
||||||
|
}
|
||||||
|
// Allowed flush values.
|
||||||
|
/** @deprecated Use `constants.Z_NO_FLUSH` */
|
||||||
|
const Z_NO_FLUSH: number;
|
||||||
|
/** @deprecated Use `constants.Z_PARTIAL_FLUSH` */
|
||||||
|
const Z_PARTIAL_FLUSH: number;
|
||||||
|
/** @deprecated Use `constants.Z_SYNC_FLUSH` */
|
||||||
|
const Z_SYNC_FLUSH: number;
|
||||||
|
/** @deprecated Use `constants.Z_FULL_FLUSH` */
|
||||||
|
const Z_FULL_FLUSH: number;
|
||||||
|
/** @deprecated Use `constants.Z_FINISH` */
|
||||||
|
const Z_FINISH: number;
|
||||||
|
/** @deprecated Use `constants.Z_BLOCK` */
|
||||||
|
const Z_BLOCK: number;
|
||||||
|
/** @deprecated Use `constants.Z_TREES` */
|
||||||
|
const Z_TREES: number;
|
||||||
|
// Return codes for the compression/decompression functions.
|
||||||
|
// Negative values are errors, positive values are used for special but normal events.
|
||||||
|
/** @deprecated Use `constants.Z_OK` */
|
||||||
|
const Z_OK: number;
|
||||||
|
/** @deprecated Use `constants.Z_STREAM_END` */
|
||||||
|
const Z_STREAM_END: number;
|
||||||
|
/** @deprecated Use `constants.Z_NEED_DICT` */
|
||||||
|
const Z_NEED_DICT: number;
|
||||||
|
/** @deprecated Use `constants.Z_ERRNO` */
|
||||||
|
const Z_ERRNO: number;
|
||||||
|
/** @deprecated Use `constants.Z_STREAM_ERROR` */
|
||||||
|
const Z_STREAM_ERROR: number;
|
||||||
|
/** @deprecated Use `constants.Z_DATA_ERROR` */
|
||||||
|
const Z_DATA_ERROR: number;
|
||||||
|
/** @deprecated Use `constants.Z_MEM_ERROR` */
|
||||||
|
const Z_MEM_ERROR: number;
|
||||||
|
/** @deprecated Use `constants.Z_BUF_ERROR` */
|
||||||
|
const Z_BUF_ERROR: number;
|
||||||
|
/** @deprecated Use `constants.Z_VERSION_ERROR` */
|
||||||
|
const Z_VERSION_ERROR: number;
|
||||||
|
// Compression levels.
|
||||||
|
/** @deprecated Use `constants.Z_NO_COMPRESSION` */
|
||||||
|
const Z_NO_COMPRESSION: number;
|
||||||
|
/** @deprecated Use `constants.Z_BEST_SPEED` */
|
||||||
|
const Z_BEST_SPEED: number;
|
||||||
|
/** @deprecated Use `constants.Z_BEST_COMPRESSION` */
|
||||||
|
const Z_BEST_COMPRESSION: number;
|
||||||
|
/** @deprecated Use `constants.Z_DEFAULT_COMPRESSION` */
|
||||||
|
const Z_DEFAULT_COMPRESSION: number;
|
||||||
|
// Compression strategy.
|
||||||
|
/** @deprecated Use `constants.Z_FILTERED` */
|
||||||
|
const Z_FILTERED: number;
|
||||||
|
/** @deprecated Use `constants.Z_HUFFMAN_ONLY` */
|
||||||
|
const Z_HUFFMAN_ONLY: number;
|
||||||
|
/** @deprecated Use `constants.Z_RLE` */
|
||||||
|
const Z_RLE: number;
|
||||||
|
/** @deprecated Use `constants.Z_FIXED` */
|
||||||
|
const Z_FIXED: number;
|
||||||
|
/** @deprecated Use `constants.Z_DEFAULT_STRATEGY` */
|
||||||
|
const Z_DEFAULT_STRATEGY: number;
|
||||||
|
/** @deprecated */
|
||||||
|
const Z_BINARY: number;
|
||||||
|
/** @deprecated */
|
||||||
|
const Z_TEXT: number;
|
||||||
|
/** @deprecated */
|
||||||
|
const Z_ASCII: number;
|
||||||
|
/** @deprecated */
|
||||||
|
const Z_UNKNOWN: number;
|
||||||
|
/** @deprecated */
|
||||||
|
const Z_DEFLATED: number;
|
||||||
|
}
|
||||||
|
declare module "node:zlib" {
|
||||||
|
export * from "zlib";
|
||||||
|
}
|
21
websocket_server/node_modules/.ignored/@types/socket.io/LICENSE
generated
vendored
Executable file
21
websocket_server/node_modules/.ignored/@types/socket.io/LICENSE
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
3
websocket_server/node_modules/.ignored/@types/socket.io/README.md
generated
vendored
Executable file
3
websocket_server/node_modules/.ignored/@types/socket.io/README.md
generated
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
This is a stub types definition for @types/socket.io (https://github.com/socketio/socket.io#readme).
|
||||||
|
|
||||||
|
socket.io provides its own type definitions, so you don't need @types/socket.io installed!
|
13
websocket_server/node_modules/.ignored/@types/socket.io/package.json
generated
vendored
Executable file
13
websocket_server/node_modules/.ignored/@types/socket.io/package.json
generated
vendored
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/socket.io",
|
||||||
|
"version": "3.0.2",
|
||||||
|
"typings": null,
|
||||||
|
"description": "Stub TypeScript definitions entry for socket.io, which provides its own types definitions",
|
||||||
|
"main": "",
|
||||||
|
"scripts": {},
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"socket.io": "*"
|
||||||
|
}
|
||||||
|
}
|
33
websocket_server/node_modules/.ignored/cors/CONTRIBUTING.md
generated
vendored
Normal file
33
websocket_server/node_modules/.ignored/cors/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# contributing to `cors`
|
||||||
|
|
||||||
|
CORS is a node.js package for providing a [connect](http://www.senchalabs.org/connect/)/[express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. Learn more about the project in [the README](README.md).
|
||||||
|
|
||||||
|
## The CORS Spec
|
||||||
|
|
||||||
|
[http://www.w3.org/TR/cors/](http://www.w3.org/TR/cors/)
|
||||||
|
|
||||||
|
## Pull Requests Welcome
|
||||||
|
|
||||||
|
* Include `'use strict';` in every javascript file.
|
||||||
|
* 2 space indentation.
|
||||||
|
* Please run the testing steps below before submitting.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
$ npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Interactive Testing Harness
|
||||||
|
|
||||||
|
[http://node-cors-client.herokuapp.com](http://node-cors-client.herokuapp.com)
|
||||||
|
|
||||||
|
Related git repositories:
|
||||||
|
|
||||||
|
* [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server)
|
||||||
|
* [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT License](http://www.opensource.org/licenses/mit-license.php)
|
58
websocket_server/node_modules/.ignored/cors/HISTORY.md
generated
vendored
Normal file
58
websocket_server/node_modules/.ignored/cors/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
2.8.5 / 2018-11-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix setting `maxAge` option to `0`
|
||||||
|
|
||||||
|
2.8.4 / 2017-07-12
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Work-around Safari bug in default pre-flight response
|
||||||
|
|
||||||
|
2.8.3 / 2017-03-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix error when options delegate missing `methods` option
|
||||||
|
|
||||||
|
2.8.2 / 2017-03-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix error when frozen options are passed
|
||||||
|
* Send "Vary: Origin" when using regular expressions
|
||||||
|
* Send "Vary: Access-Control-Request-Headers" when dynamic `allowedHeaders`
|
||||||
|
|
||||||
|
2.8.1 / 2016-09-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
This release only changed documentation.
|
||||||
|
|
||||||
|
2.8.0 / 2016-08-23
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `optionsSuccessStatus` option
|
||||||
|
|
||||||
|
2.7.2 / 2016-08-23
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix error when Node.js running in strict mode
|
||||||
|
|
||||||
|
2.7.1 / 2015-05-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Move module into expressjs organization
|
||||||
|
|
||||||
|
2.7.0 / 2015-05-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Allow array of matching condition as `origin` option
|
||||||
|
* Allow regular expression as `origin` option
|
||||||
|
|
||||||
|
2.6.1 / 2015-05-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Update `license` in package.json
|
||||||
|
|
||||||
|
2.6.0 / 2015-04-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `preflightContinue` option
|
||||||
|
* Fix "Vary: Origin" header added for "*"
|
22
websocket_server/node_modules/.ignored/cors/LICENSE
generated
vendored
Normal file
22
websocket_server/node_modules/.ignored/cors/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Troy Goode <troygoode@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
243
websocket_server/node_modules/.ignored/cors/README.md
generated
vendored
Normal file
243
websocket_server/node_modules/.ignored/cors/README.md
generated
vendored
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
# cors
|
||||||
|
|
||||||
|
[![NPM Version][npm-image]][npm-url]
|
||||||
|
[![NPM Downloads][downloads-image]][downloads-url]
|
||||||
|
[![Build Status][travis-image]][travis-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
CORS is a node.js package for providing a [Connect](http://www.senchalabs.org/connect/)/[Express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options.
|
||||||
|
|
||||||
|
**[Follow me (@troygoode) on Twitter!](https://twitter.com/intent/user?screen_name=troygoode)**
|
||||||
|
|
||||||
|
* [Installation](#installation)
|
||||||
|
* [Usage](#usage)
|
||||||
|
* [Simple Usage](#simple-usage-enable-all-cors-requests)
|
||||||
|
* [Enable CORS for a Single Route](#enable-cors-for-a-single-route)
|
||||||
|
* [Configuring CORS](#configuring-cors)
|
||||||
|
* [Configuring CORS Asynchronously](#configuring-cors-asynchronously)
|
||||||
|
* [Enabling CORS Pre-Flight](#enabling-cors-pre-flight)
|
||||||
|
* [Configuration Options](#configuration-options)
|
||||||
|
* [Demo](#demo)
|
||||||
|
* [License](#license)
|
||||||
|
* [Author](#author)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install cors
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Simple Usage (Enable *All* CORS Requests)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
app.use(cors())
|
||||||
|
|
||||||
|
app.get('/products/:id', function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for all origins!'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Enable CORS for a Single Route
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
app.get('/products/:id', cors(), function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for a Single Route'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuring CORS
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
var corsOptions = {
|
||||||
|
origin: 'http://example.com',
|
||||||
|
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/products/:id', cors(corsOptions), function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for only example.com.'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuring CORS w/ Dynamic Origin
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
var whitelist = ['http://example1.com', 'http://example2.com']
|
||||||
|
var corsOptions = {
|
||||||
|
origin: function (origin, callback) {
|
||||||
|
if (whitelist.indexOf(origin) !== -1) {
|
||||||
|
callback(null, true)
|
||||||
|
} else {
|
||||||
|
callback(new Error('Not allowed by CORS'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/products/:id', cors(corsOptions), function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
If you do not want to block REST tools or server-to-server requests,
|
||||||
|
add a `!origin` check in the origin function like so:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var corsOptions = {
|
||||||
|
origin: function (origin, callback) {
|
||||||
|
if (whitelist.indexOf(origin) !== -1 || !origin) {
|
||||||
|
callback(null, true)
|
||||||
|
} else {
|
||||||
|
callback(new Error('Not allowed by CORS'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Enabling CORS Pre-Flight
|
||||||
|
|
||||||
|
Certain CORS requests are considered 'complex' and require an initial
|
||||||
|
`OPTIONS` request (called the "pre-flight request"). An example of a
|
||||||
|
'complex' CORS request is one that uses an HTTP verb other than
|
||||||
|
GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable
|
||||||
|
pre-flighting, you must add a new OPTIONS handler for the route you want
|
||||||
|
to support:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
app.options('/products/:id', cors()) // enable pre-flight request for DELETE request
|
||||||
|
app.del('/products/:id', cors(), function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for all origins!'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also enable pre-flight across-the-board like so:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
app.options('*', cors()) // include before other routes
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuring CORS Asynchronously
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var express = require('express')
|
||||||
|
var cors = require('cors')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
var whitelist = ['http://example1.com', 'http://example2.com']
|
||||||
|
var corsOptionsDelegate = function (req, callback) {
|
||||||
|
var corsOptions;
|
||||||
|
if (whitelist.indexOf(req.header('Origin')) !== -1) {
|
||||||
|
corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response
|
||||||
|
} else {
|
||||||
|
corsOptions = { origin: false } // disable CORS for this request
|
||||||
|
}
|
||||||
|
callback(null, corsOptions) // callback expects two parameters: error and options
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/products/:id', cors(corsOptionsDelegate), function (req, res, next) {
|
||||||
|
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(80, function () {
|
||||||
|
console.log('CORS-enabled web server listening on port 80')
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration Options
|
||||||
|
|
||||||
|
* `origin`: Configures the **Access-Control-Allow-Origin** CORS header. Possible values:
|
||||||
|
- `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`, or set it to `false` to disable CORS.
|
||||||
|
- `String` - set `origin` to a specific origin. For example if you set it to `"http://example.com"` only requests from "http://example.com" will be allowed.
|
||||||
|
- `RegExp` - set `origin` to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern `/example\.com$/` will reflect any request that is coming from an origin ending with "example.com".
|
||||||
|
- `Array` - set `origin` to an array of valid origins. Each origin can be a `String` or a `RegExp`. For example `["http://example1.com", /\.example2\.com$/]` will accept any request from "http://example1.com" or from a subdomain of "example2.com".
|
||||||
|
- `Function` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (which expects the signature `err [object], allow [bool]`) as the second.
|
||||||
|
* `methods`: Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`).
|
||||||
|
* `allowedHeaders`: Configures the **Access-Control-Allow-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: `['Content-Type', 'Authorization']`). If not specified, defaults to reflecting the headers specified in the request's **Access-Control-Request-Headers** header.
|
||||||
|
* `exposedHeaders`: Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') or an array (ex: `['Content-Range', 'X-Content-Range']`). If not specified, no custom headers are exposed.
|
||||||
|
* `credentials`: Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted.
|
||||||
|
* `maxAge`: Configures the **Access-Control-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted.
|
||||||
|
* `preflightContinue`: Pass the CORS preflight response to the next handler.
|
||||||
|
* `optionsSuccessStatus`: Provides a status code to use for successful `OPTIONS` requests, since some legacy browsers (IE11, various SmartTVs) choke on `204`.
|
||||||
|
|
||||||
|
The default configuration is the equivalent of:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"origin": "*",
|
||||||
|
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
|
||||||
|
"preflightContinue": false,
|
||||||
|
"optionsSuccessStatus": 204
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For details on the effect of each CORS header, read [this](http://www.html5rocks.com/en/tutorials/cors/) article on HTML5 Rocks.
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
A demo that illustrates CORS working (and not working) using jQuery is available here: [http://node-cors-client.herokuapp.com/](http://node-cors-client.herokuapp.com/)
|
||||||
|
|
||||||
|
Code for that demo can be found here:
|
||||||
|
|
||||||
|
* Client: [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client)
|
||||||
|
* Server: [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT License](http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
[Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com))
|
||||||
|
|
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/expressjs/cors/master.svg
|
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/cors?branch=master
|
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/cors.svg
|
||||||
|
[downloads-url]: https://npmjs.org/package/cors
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/cors.svg
|
||||||
|
[npm-url]: https://npmjs.org/package/cors
|
||||||
|
[travis-image]: https://img.shields.io/travis/expressjs/cors/master.svg
|
||||||
|
[travis-url]: https://travis-ci.org/expressjs/cors
|
238
websocket_server/node_modules/.ignored/cors/lib/index.js
generated
vendored
Normal file
238
websocket_server/node_modules/.ignored/cors/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
(function () {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var assign = require('object-assign');
|
||||||
|
var vary = require('vary');
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
origin: '*',
|
||||||
|
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||||
|
preflightContinue: false,
|
||||||
|
optionsSuccessStatus: 204
|
||||||
|
};
|
||||||
|
|
||||||
|
function isString(s) {
|
||||||
|
return typeof s === 'string' || s instanceof String;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOriginAllowed(origin, allowedOrigin) {
|
||||||
|
if (Array.isArray(allowedOrigin)) {
|
||||||
|
for (var i = 0; i < allowedOrigin.length; ++i) {
|
||||||
|
if (isOriginAllowed(origin, allowedOrigin[i])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else if (isString(allowedOrigin)) {
|
||||||
|
return origin === allowedOrigin;
|
||||||
|
} else if (allowedOrigin instanceof RegExp) {
|
||||||
|
return allowedOrigin.test(origin);
|
||||||
|
} else {
|
||||||
|
return !!allowedOrigin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureOrigin(options, req) {
|
||||||
|
var requestOrigin = req.headers.origin,
|
||||||
|
headers = [],
|
||||||
|
isAllowed;
|
||||||
|
|
||||||
|
if (!options.origin || options.origin === '*') {
|
||||||
|
// allow any origin
|
||||||
|
headers.push([{
|
||||||
|
key: 'Access-Control-Allow-Origin',
|
||||||
|
value: '*'
|
||||||
|
}]);
|
||||||
|
} else if (isString(options.origin)) {
|
||||||
|
// fixed origin
|
||||||
|
headers.push([{
|
||||||
|
key: 'Access-Control-Allow-Origin',
|
||||||
|
value: options.origin
|
||||||
|
}]);
|
||||||
|
headers.push([{
|
||||||
|
key: 'Vary',
|
||||||
|
value: 'Origin'
|
||||||
|
}]);
|
||||||
|
} else {
|
||||||
|
isAllowed = isOriginAllowed(requestOrigin, options.origin);
|
||||||
|
// reflect origin
|
||||||
|
headers.push([{
|
||||||
|
key: 'Access-Control-Allow-Origin',
|
||||||
|
value: isAllowed ? requestOrigin : false
|
||||||
|
}]);
|
||||||
|
headers.push([{
|
||||||
|
key: 'Vary',
|
||||||
|
value: 'Origin'
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureMethods(options) {
|
||||||
|
var methods = options.methods;
|
||||||
|
if (methods.join) {
|
||||||
|
methods = options.methods.join(','); // .methods is an array, so turn it into a string
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
key: 'Access-Control-Allow-Methods',
|
||||||
|
value: methods
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureCredentials(options) {
|
||||||
|
if (options.credentials === true) {
|
||||||
|
return {
|
||||||
|
key: 'Access-Control-Allow-Credentials',
|
||||||
|
value: 'true'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureAllowedHeaders(options, req) {
|
||||||
|
var allowedHeaders = options.allowedHeaders || options.headers;
|
||||||
|
var headers = [];
|
||||||
|
|
||||||
|
if (!allowedHeaders) {
|
||||||
|
allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers
|
||||||
|
headers.push([{
|
||||||
|
key: 'Vary',
|
||||||
|
value: 'Access-Control-Request-Headers'
|
||||||
|
}]);
|
||||||
|
} else if (allowedHeaders.join) {
|
||||||
|
allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string
|
||||||
|
}
|
||||||
|
if (allowedHeaders && allowedHeaders.length) {
|
||||||
|
headers.push([{
|
||||||
|
key: 'Access-Control-Allow-Headers',
|
||||||
|
value: allowedHeaders
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureExposedHeaders(options) {
|
||||||
|
var headers = options.exposedHeaders;
|
||||||
|
if (!headers) {
|
||||||
|
return null;
|
||||||
|
} else if (headers.join) {
|
||||||
|
headers = headers.join(','); // .headers is an array, so turn it into a string
|
||||||
|
}
|
||||||
|
if (headers && headers.length) {
|
||||||
|
return {
|
||||||
|
key: 'Access-Control-Expose-Headers',
|
||||||
|
value: headers
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureMaxAge(options) {
|
||||||
|
var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString()
|
||||||
|
if (maxAge && maxAge.length) {
|
||||||
|
return {
|
||||||
|
key: 'Access-Control-Max-Age',
|
||||||
|
value: maxAge
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyHeaders(headers, res) {
|
||||||
|
for (var i = 0, n = headers.length; i < n; i++) {
|
||||||
|
var header = headers[i];
|
||||||
|
if (header) {
|
||||||
|
if (Array.isArray(header)) {
|
||||||
|
applyHeaders(header, res);
|
||||||
|
} else if (header.key === 'Vary' && header.value) {
|
||||||
|
vary(res, header.value);
|
||||||
|
} else if (header.value) {
|
||||||
|
res.setHeader(header.key, header.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cors(options, req, res, next) {
|
||||||
|
var headers = [],
|
||||||
|
method = req.method && req.method.toUpperCase && req.method.toUpperCase();
|
||||||
|
|
||||||
|
if (method === 'OPTIONS') {
|
||||||
|
// preflight
|
||||||
|
headers.push(configureOrigin(options, req));
|
||||||
|
headers.push(configureCredentials(options, req));
|
||||||
|
headers.push(configureMethods(options, req));
|
||||||
|
headers.push(configureAllowedHeaders(options, req));
|
||||||
|
headers.push(configureMaxAge(options, req));
|
||||||
|
headers.push(configureExposedHeaders(options, req));
|
||||||
|
applyHeaders(headers, res);
|
||||||
|
|
||||||
|
if (options.preflightContinue) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
// Safari (and potentially other browsers) need content-length 0,
|
||||||
|
// for 204 or they just hang waiting for a body
|
||||||
|
res.statusCode = options.optionsSuccessStatus;
|
||||||
|
res.setHeader('Content-Length', '0');
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// actual response
|
||||||
|
headers.push(configureOrigin(options, req));
|
||||||
|
headers.push(configureCredentials(options, req));
|
||||||
|
headers.push(configureExposedHeaders(options, req));
|
||||||
|
applyHeaders(headers, res);
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function middlewareWrapper(o) {
|
||||||
|
// if options are static (either via defaults or custom options passed in), wrap in a function
|
||||||
|
var optionsCallback = null;
|
||||||
|
if (typeof o === 'function') {
|
||||||
|
optionsCallback = o;
|
||||||
|
} else {
|
||||||
|
optionsCallback = function (req, cb) {
|
||||||
|
cb(null, o);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return function corsMiddleware(req, res, next) {
|
||||||
|
optionsCallback(req, function (err, options) {
|
||||||
|
if (err) {
|
||||||
|
next(err);
|
||||||
|
} else {
|
||||||
|
var corsOptions = assign({}, defaults, options);
|
||||||
|
var originCallback = null;
|
||||||
|
if (corsOptions.origin && typeof corsOptions.origin === 'function') {
|
||||||
|
originCallback = corsOptions.origin;
|
||||||
|
} else if (corsOptions.origin) {
|
||||||
|
originCallback = function (origin, cb) {
|
||||||
|
cb(null, corsOptions.origin);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originCallback) {
|
||||||
|
originCallback(req.headers.origin, function (err2, origin) {
|
||||||
|
if (err2 || !origin) {
|
||||||
|
next(err2);
|
||||||
|
} else {
|
||||||
|
corsOptions.origin = origin;
|
||||||
|
cors(corsOptions, req, res, next);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// can pass either an options hash, an options delegate, or nothing
|
||||||
|
module.exports = middlewareWrapper;
|
||||||
|
|
||||||
|
}());
|
41
websocket_server/node_modules/.ignored/cors/package.json
generated
vendored
Normal file
41
websocket_server/node_modules/.ignored/cors/package.json
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "cors",
|
||||||
|
"description": "Node.js CORS middleware",
|
||||||
|
"version": "2.8.5",
|
||||||
|
"author": "Troy Goode <troygoode@gmail.com> (https://github.com/troygoode/)",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"cors",
|
||||||
|
"express",
|
||||||
|
"connect",
|
||||||
|
"middleware"
|
||||||
|
],
|
||||||
|
"repository": "expressjs/cors",
|
||||||
|
"main": "./lib/index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"object-assign": "^4",
|
||||||
|
"vary": "^1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"after": "0.8.2",
|
||||||
|
"eslint": "2.13.1",
|
||||||
|
"express": "4.16.3",
|
||||||
|
"mocha": "5.2.0",
|
||||||
|
"nyc": "13.1.0",
|
||||||
|
"supertest": "3.3.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib/index.js",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
"HISTORY.md",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.10"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "npm run lint && nyc --reporter=html --reporter=text mocha --require test/support/env",
|
||||||
|
"lint": "eslint lib test"
|
||||||
|
}
|
||||||
|
}
|
3647
websocket_server/node_modules/.ignored/express/History.md
generated
vendored
Normal file
3647
websocket_server/node_modules/.ignored/express/History.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
websocket_server/node_modules/.ignored/express/LICENSE
generated
vendored
Normal file
24
websocket_server/node_modules/.ignored/express/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>
|
||||||
|
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
260
websocket_server/node_modules/.ignored/express/Readme.md
generated
vendored
Normal file
260
websocket_server/node_modules/.ignored/express/Readme.md
generated
vendored
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)
|
||||||
|
|
||||||
|
**Fast, unopinionated, minimalist web framework for [Node.js](http://nodejs.org).**
|
||||||
|
|
||||||
|
**This project has a [Code of Conduct][].**
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Installation](#Installation)
|
||||||
|
* [Features](#Features)
|
||||||
|
* [Docs & Community](#docs--community)
|
||||||
|
* [Quick Start](#Quick-Start)
|
||||||
|
* [Running Tests](#Running-Tests)
|
||||||
|
* [Philosophy](#Philosophy)
|
||||||
|
* [Examples](#Examples)
|
||||||
|
* [Contributing to Express](#Contributing)
|
||||||
|
* [TC (Technical Committee)](#tc-technical-committee)
|
||||||
|
* [Triagers](#triagers)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Install Size][npm-install-size-image]][npm-install-size-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-downloads-url]
|
||||||
|
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
const express = require('express')
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
app.get('/', function (req, res) {
|
||||||
|
res.send('Hello World')
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(3000)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/).
|
||||||
|
|
||||||
|
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
|
||||||
|
Node.js 0.10 or higher is required.
|
||||||
|
|
||||||
|
If this is a brand new project, make sure to create a `package.json` first with
|
||||||
|
the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
|
||||||
|
|
||||||
|
Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm install express
|
||||||
|
```
|
||||||
|
|
||||||
|
Follow [our installing guide](http://expressjs.com/en/starter/installing.html)
|
||||||
|
for more information.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Robust routing
|
||||||
|
* Focus on high performance
|
||||||
|
* Super-high test coverage
|
||||||
|
* HTTP helpers (redirection, caching, etc)
|
||||||
|
* View system supporting 14+ template engines
|
||||||
|
* Content negotiation
|
||||||
|
* Executable for generating applications quickly
|
||||||
|
|
||||||
|
## Docs & Community
|
||||||
|
|
||||||
|
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
||||||
|
* [#express](https://web.libera.chat/#express) on [Libera Chat](https://libera.chat) IRC
|
||||||
|
* [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
|
||||||
|
* Visit the [Wiki](https://github.com/expressjs/express/wiki)
|
||||||
|
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
||||||
|
* [Gitter](https://gitter.im/expressjs/express) for support and discussion
|
||||||
|
|
||||||
|
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x).
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:
|
||||||
|
|
||||||
|
Install the executable. The executable's major version will match Express's:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm install -g express-generator@4
|
||||||
|
```
|
||||||
|
|
||||||
|
Create the app:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ express /tmp/foo && cd /tmp/foo
|
||||||
|
```
|
||||||
|
|
||||||
|
Install dependencies:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the server:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
View the website at: http://localhost:3000
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
The Express philosophy is to provide small, robust tooling for HTTP servers, making
|
||||||
|
it a great solution for single page applications, websites, hybrids, or public
|
||||||
|
HTTP APIs.
|
||||||
|
|
||||||
|
Express does not force you to use any specific ORM or template engine. With support for over
|
||||||
|
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
||||||
|
you can quickly craft your perfect framework.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
To view the examples, clone the Express repo and install the dependencies:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ git clone https://github.com/expressjs/express.git --depth 1
|
||||||
|
$ cd express
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run whichever example you want:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ node examples/content-negotiation
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
[![Linux Build][github-actions-ci-image]][github-actions-ci-url]
|
||||||
|
[![Windows Build][appveyor-image]][appveyor-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
The Express.js project welcomes all constructive contributions. Contributions take many forms,
|
||||||
|
from code for bug fixes and enhancements, to additions and fixes to documentation, additional
|
||||||
|
tests, triaging incoming pull requests and issues, and more!
|
||||||
|
|
||||||
|
See the [Contributing Guide](Contributing.md) for more technical details on contributing.
|
||||||
|
|
||||||
|
### Security Issues
|
||||||
|
|
||||||
|
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
To run the test suite, first install the dependencies, then run `npm test`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm install
|
||||||
|
$ npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## People
|
||||||
|
|
||||||
|
The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||||
|
|
||||||
|
[List of all contributors](https://github.com/expressjs/express/graphs/contributors)
|
||||||
|
|
||||||
|
### TC (Technical Committee)
|
||||||
|
|
||||||
|
* [UlisesGascon](https://github.com/UlisesGascon) - **Ulises Gascón** (he/him)
|
||||||
|
* [jonchurch](https://github.com/jonchurch) - **Jon Church**
|
||||||
|
* [wesleytodd](https://github.com/wesleytodd) - **Wes Todd**
|
||||||
|
* [LinusU](https://github.com/LinusU) - **Linus Unnebäck**
|
||||||
|
* [blakeembrey](https://github.com/blakeembrey) - **Blake Embrey**
|
||||||
|
* [sheplu](https://github.com/sheplu) - **Jean Burellier**
|
||||||
|
* [crandmck](https://github.com/crandmck) - **Rand McKinney**
|
||||||
|
* [ctcpip](https://github.com/ctcpip) - **Chris de Almeida**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>TC emeriti members</summary>
|
||||||
|
|
||||||
|
#### TC emeriti members
|
||||||
|
|
||||||
|
* [dougwilson](https://github.com/dougwilson) - **Douglas Wilson**
|
||||||
|
* [hacksparrow](https://github.com/hacksparrow) - **Hage Yaapa**
|
||||||
|
* [jonathanong](https://github.com/jonathanong) - **jongleberry**
|
||||||
|
* [niftylettuce](https://github.com/niftylettuce) - **niftylettuce**
|
||||||
|
* [troygoode](https://github.com/troygoode) - **Troy Goode**
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
### Triagers
|
||||||
|
|
||||||
|
* [aravindvnair99](https://github.com/aravindvnair99) - **Aravind Nair**
|
||||||
|
* [carpasse](https://github.com/carpasse) - **Carlos Serrano**
|
||||||
|
* [CBID2](https://github.com/CBID2) - **Christine Belzie**
|
||||||
|
* [enyoghasim](https://github.com/enyoghasim) - **David Enyoghasim**
|
||||||
|
* [UlisesGascon](https://github.com/UlisesGascon) - **Ulises Gascón** (he/him)
|
||||||
|
* [mertcanaltin](https://github.com/mertcanaltin) - **Mert Can Altin**
|
||||||
|
* [0ss](https://github.com/0ss) - **Salah**
|
||||||
|
* [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)
|
||||||
|
* [3imed-jaberi](https://github.com/3imed-jaberi) - **Imed Jaberi**
|
||||||
|
* [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)
|
||||||
|
* [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**
|
||||||
|
* [IamLizu](https://github.com/IamLizu) - **S M Mahmudul Hasan** (he/him)
|
||||||
|
* [Sushmeet](https://github.com/Sushmeet) - **Sushmeet Sunger**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Triagers emeriti members</summary>
|
||||||
|
|
||||||
|
#### Emeritus Triagers
|
||||||
|
|
||||||
|
* [AuggieH](https://github.com/AuggieH) - **Auggie Hudak**
|
||||||
|
* [G-Rath](https://github.com/G-Rath) - **Gareth Jones**
|
||||||
|
* [MohammadXroid](https://github.com/MohammadXroid) - **Mohammad Ayashi**
|
||||||
|
* [NawafSwe](https://github.com/NawafSwe) - **Nawaf Alsharqi**
|
||||||
|
* [NotMoni](https://github.com/NotMoni) - **Moni**
|
||||||
|
* [VigneshMurugan](https://github.com/VigneshMurugan) - **Vignesh Murugan**
|
||||||
|
* [davidmashe](https://github.com/davidmashe) - **David Ashe**
|
||||||
|
* [digitaIfabric](https://github.com/digitaIfabric) - **David**
|
||||||
|
* [e-l-i-s-e](https://github.com/e-l-i-s-e) - **Elise Bonner**
|
||||||
|
* [fed135](https://github.com/fed135) - **Frederic Charette**
|
||||||
|
* [firmanJS](https://github.com/firmanJS) - **Firman Abdul Hakim**
|
||||||
|
* [getspooky](https://github.com/getspooky) - **Yasser Ameur**
|
||||||
|
* [ghinks](https://github.com/ghinks) - **Glenn**
|
||||||
|
* [ghousemohamed](https://github.com/ghousemohamed) - **Ghouse Mohamed**
|
||||||
|
* [gireeshpunathil](https://github.com/gireeshpunathil) - **Gireesh Punathil**
|
||||||
|
* [jake32321](https://github.com/jake32321) - **Jake Reed**
|
||||||
|
* [jonchurch](https://github.com/jonchurch) - **Jon Church**
|
||||||
|
* [lekanikotun](https://github.com/lekanikotun) - **Troy Goode**
|
||||||
|
* [marsonya](https://github.com/marsonya) - **Lekan Ikotun**
|
||||||
|
* [mastermatt](https://github.com/mastermatt) - **Matt R. Wilson**
|
||||||
|
* [maxakuru](https://github.com/maxakuru) - **Max Edell**
|
||||||
|
* [mlrawlings](https://github.com/mlrawlings) - **Michael Rawlings**
|
||||||
|
* [rodion-arr](https://github.com/rodion-arr) - **Rodion Abdurakhimov**
|
||||||
|
* [sheplu](https://github.com/sheplu) - **Jean Burellier**
|
||||||
|
* [tarunyadav1](https://github.com/tarunyadav1) - **Tarun yadav**
|
||||||
|
* [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe**
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/express/master?label=windows
|
||||||
|
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/express/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
|
||||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/express/master?label=linux
|
||||||
|
[github-actions-ci-url]: https://github.com/expressjs/express/actions/workflows/ci.yml
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/express
|
||||||
|
[npm-downloads-url]: https://npmcharts.com/compare/express?minimal=true
|
||||||
|
[npm-install-size-image]: https://badgen.net/packagephobia/install/express
|
||||||
|
[npm-install-size-url]: https://packagephobia.com/result?p=express
|
||||||
|
[npm-url]: https://npmjs.org/package/express
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/express
|
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/express/badge
|
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/express
|
||||||
|
[Code of Conduct]: https://github.com/expressjs/express/blob/master/Code-Of-Conduct.md
|
11
websocket_server/node_modules/.ignored/express/index.js
generated
vendored
Normal file
11
websocket_server/node_modules/.ignored/express/index.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/*!
|
||||||
|
* express
|
||||||
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||||
|
* Copyright(c) 2013 Roman Shtylman
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./lib/express');
|
661
websocket_server/node_modules/.ignored/express/lib/application.js
generated
vendored
Normal file
661
websocket_server/node_modules/.ignored/express/lib/application.js
generated
vendored
Normal file
@ -0,0 +1,661 @@
|
|||||||
|
/*!
|
||||||
|
* express
|
||||||
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||||
|
* Copyright(c) 2013 Roman Shtylman
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var finalhandler = require('finalhandler');
|
||||||
|
var Router = require('./router');
|
||||||
|
var methods = require('methods');
|
||||||
|
var middleware = require('./middleware/init');
|
||||||
|
var query = require('./middleware/query');
|
||||||
|
var debug = require('debug')('express:application');
|
||||||
|
var View = require('./view');
|
||||||
|
var http = require('http');
|
||||||
|
var compileETag = require('./utils').compileETag;
|
||||||
|
var compileQueryParser = require('./utils').compileQueryParser;
|
||||||
|
var compileTrust = require('./utils').compileTrust;
|
||||||
|
var deprecate = require('depd')('express');
|
||||||
|
var flatten = require('array-flatten');
|
||||||
|
var merge = require('utils-merge');
|
||||||
|
var resolve = require('path').resolve;
|
||||||
|
var setPrototypeOf = require('setprototypeof')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module variables.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||||
|
var slice = Array.prototype.slice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application prototype.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var app = exports = module.exports = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Variable for trust proxy inheritance back-compat
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the server.
|
||||||
|
*
|
||||||
|
* - setup default configuration
|
||||||
|
* - setup default middleware
|
||||||
|
* - setup route reflection methods
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.init = function init() {
|
||||||
|
this.cache = {};
|
||||||
|
this.engines = {};
|
||||||
|
this.settings = {};
|
||||||
|
|
||||||
|
this.defaultConfiguration();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize application configuration.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.defaultConfiguration = function defaultConfiguration() {
|
||||||
|
var env = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
|
// default settings
|
||||||
|
this.enable('x-powered-by');
|
||||||
|
this.set('etag', 'weak');
|
||||||
|
this.set('env', env);
|
||||||
|
this.set('query parser', 'extended');
|
||||||
|
this.set('subdomain offset', 2);
|
||||||
|
this.set('trust proxy', false);
|
||||||
|
|
||||||
|
// trust proxy inherit back-compat
|
||||||
|
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||||
|
configurable: true,
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
debug('booting in %s mode', env);
|
||||||
|
|
||||||
|
this.on('mount', function onmount(parent) {
|
||||||
|
// inherit trust proxy
|
||||||
|
if (this.settings[trustProxyDefaultSymbol] === true
|
||||||
|
&& typeof parent.settings['trust proxy fn'] === 'function') {
|
||||||
|
delete this.settings['trust proxy'];
|
||||||
|
delete this.settings['trust proxy fn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// inherit protos
|
||||||
|
setPrototypeOf(this.request, parent.request)
|
||||||
|
setPrototypeOf(this.response, parent.response)
|
||||||
|
setPrototypeOf(this.engines, parent.engines)
|
||||||
|
setPrototypeOf(this.settings, parent.settings)
|
||||||
|
});
|
||||||
|
|
||||||
|
// setup locals
|
||||||
|
this.locals = Object.create(null);
|
||||||
|
|
||||||
|
// top-most app is mounted at /
|
||||||
|
this.mountpath = '/';
|
||||||
|
|
||||||
|
// default locals
|
||||||
|
this.locals.settings = this.settings;
|
||||||
|
|
||||||
|
// default configuration
|
||||||
|
this.set('view', View);
|
||||||
|
this.set('views', resolve('views'));
|
||||||
|
this.set('jsonp callback name', 'callback');
|
||||||
|
|
||||||
|
if (env === 'production') {
|
||||||
|
this.enable('view cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(this, 'router', {
|
||||||
|
get: function() {
|
||||||
|
throw new Error('\'app.router\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lazily adds the base router if it has not yet been added.
|
||||||
|
*
|
||||||
|
* We cannot add the base router in the defaultConfiguration because
|
||||||
|
* it reads app settings which might be set after that has run.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
app.lazyrouter = function lazyrouter() {
|
||||||
|
if (!this._router) {
|
||||||
|
this._router = new Router({
|
||||||
|
caseSensitive: this.enabled('case sensitive routing'),
|
||||||
|
strict: this.enabled('strict routing')
|
||||||
|
});
|
||||||
|
|
||||||
|
this._router.use(query(this.get('query parser fn')));
|
||||||
|
this._router.use(middleware.init(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch a req, res pair into the application. Starts pipeline processing.
|
||||||
|
*
|
||||||
|
* If no callback is provided, then default error handlers will respond
|
||||||
|
* in the event of an error bubbling through the stack.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.handle = function handle(req, res, callback) {
|
||||||
|
var router = this._router;
|
||||||
|
|
||||||
|
// final handler
|
||||||
|
var done = callback || finalhandler(req, res, {
|
||||||
|
env: this.get('env'),
|
||||||
|
onerror: logerror.bind(this)
|
||||||
|
});
|
||||||
|
|
||||||
|
// no routes
|
||||||
|
if (!router) {
|
||||||
|
debug('no routes defined on app');
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
router.handle(req, res, done);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy `Router#use()` to add middleware to the app router.
|
||||||
|
* See Router#use() documentation for details.
|
||||||
|
*
|
||||||
|
* If the _fn_ parameter is an express app, then it will be
|
||||||
|
* mounted at the _route_ specified.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.use = function use(fn) {
|
||||||
|
var offset = 0;
|
||||||
|
var path = '/';
|
||||||
|
|
||||||
|
// default path to '/'
|
||||||
|
// disambiguate app.use([fn])
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
var arg = fn;
|
||||||
|
|
||||||
|
while (Array.isArray(arg) && arg.length !== 0) {
|
||||||
|
arg = arg[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// first arg is the path
|
||||||
|
if (typeof arg !== 'function') {
|
||||||
|
offset = 1;
|
||||||
|
path = fn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var fns = flatten(slice.call(arguments, offset));
|
||||||
|
|
||||||
|
if (fns.length === 0) {
|
||||||
|
throw new TypeError('app.use() requires a middleware function')
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup router
|
||||||
|
this.lazyrouter();
|
||||||
|
var router = this._router;
|
||||||
|
|
||||||
|
fns.forEach(function (fn) {
|
||||||
|
// non-express app
|
||||||
|
if (!fn || !fn.handle || !fn.set) {
|
||||||
|
return router.use(path, fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('.use app under %s', path);
|
||||||
|
fn.mountpath = path;
|
||||||
|
fn.parent = this;
|
||||||
|
|
||||||
|
// restore .app property on req and res
|
||||||
|
router.use(path, function mounted_app(req, res, next) {
|
||||||
|
var orig = req.app;
|
||||||
|
fn.handle(req, res, function (err) {
|
||||||
|
setPrototypeOf(req, orig.request)
|
||||||
|
setPrototypeOf(res, orig.response)
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// mounted an app
|
||||||
|
fn.emit('mount', this);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy to the app `Router#route()`
|
||||||
|
* Returns a new `Route` instance for the _path_.
|
||||||
|
*
|
||||||
|
* Routes are isolated middleware stacks for specific paths.
|
||||||
|
* See the Route api docs for details.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.route = function route(path) {
|
||||||
|
this.lazyrouter();
|
||||||
|
return this._router.route(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the given template engine callback `fn`
|
||||||
|
* as `ext`.
|
||||||
|
*
|
||||||
|
* By default will `require()` the engine based on the
|
||||||
|
* file extension. For example if you try to render
|
||||||
|
* a "foo.ejs" file Express will invoke the following internally:
|
||||||
|
*
|
||||||
|
* app.engine('ejs', require('ejs').__express);
|
||||||
|
*
|
||||||
|
* For engines that do not provide `.__express` out of the box,
|
||||||
|
* or if you wish to "map" a different extension to the template engine
|
||||||
|
* you may use this method. For example mapping the EJS template engine to
|
||||||
|
* ".html" files:
|
||||||
|
*
|
||||||
|
* app.engine('html', require('ejs').renderFile);
|
||||||
|
*
|
||||||
|
* In this case EJS provides a `.renderFile()` method with
|
||||||
|
* the same signature that Express expects: `(path, options, callback)`,
|
||||||
|
* though note that it aliases this method as `ejs.__express` internally
|
||||||
|
* so if you're using ".ejs" extensions you don't need to do anything.
|
||||||
|
*
|
||||||
|
* Some template engines do not follow this convention, the
|
||||||
|
* [Consolidate.js](https://github.com/tj/consolidate.js)
|
||||||
|
* library was created to map all of node's popular template
|
||||||
|
* engines to follow this convention, thus allowing them to
|
||||||
|
* work seamlessly within Express.
|
||||||
|
*
|
||||||
|
* @param {String} ext
|
||||||
|
* @param {Function} fn
|
||||||
|
* @return {app} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.engine = function engine(ext, fn) {
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
throw new Error('callback function required');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get file extension
|
||||||
|
var extension = ext[0] !== '.'
|
||||||
|
? '.' + ext
|
||||||
|
: ext;
|
||||||
|
|
||||||
|
// store engine
|
||||||
|
this.engines[extension] = fn;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy to `Router#param()` with one added api feature. The _name_ parameter
|
||||||
|
* can be an array of names.
|
||||||
|
*
|
||||||
|
* See the Router#param() docs for more details.
|
||||||
|
*
|
||||||
|
* @param {String|Array} name
|
||||||
|
* @param {Function} fn
|
||||||
|
* @return {app} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.param = function param(name, fn) {
|
||||||
|
this.lazyrouter();
|
||||||
|
|
||||||
|
if (Array.isArray(name)) {
|
||||||
|
for (var i = 0; i < name.length; i++) {
|
||||||
|
this.param(name[i], fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._router.param(name, fn);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign `setting` to `val`, or return `setting`'s value.
|
||||||
|
*
|
||||||
|
* app.set('foo', 'bar');
|
||||||
|
* app.set('foo');
|
||||||
|
* // => "bar"
|
||||||
|
*
|
||||||
|
* Mounted servers inherit their parent server's settings.
|
||||||
|
*
|
||||||
|
* @param {String} setting
|
||||||
|
* @param {*} [val]
|
||||||
|
* @return {Server} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.set = function set(setting, val) {
|
||||||
|
if (arguments.length === 1) {
|
||||||
|
// app.get(setting)
|
||||||
|
var settings = this.settings
|
||||||
|
|
||||||
|
while (settings && settings !== Object.prototype) {
|
||||||
|
if (hasOwnProperty.call(settings, setting)) {
|
||||||
|
return settings[setting]
|
||||||
|
}
|
||||||
|
|
||||||
|
settings = Object.getPrototypeOf(settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('set "%s" to %o', setting, val);
|
||||||
|
|
||||||
|
// set value
|
||||||
|
this.settings[setting] = val;
|
||||||
|
|
||||||
|
// trigger matched settings
|
||||||
|
switch (setting) {
|
||||||
|
case 'etag':
|
||||||
|
this.set('etag fn', compileETag(val));
|
||||||
|
break;
|
||||||
|
case 'query parser':
|
||||||
|
this.set('query parser fn', compileQueryParser(val));
|
||||||
|
break;
|
||||||
|
case 'trust proxy':
|
||||||
|
this.set('trust proxy fn', compileTrust(val));
|
||||||
|
|
||||||
|
// trust proxy inherit back-compat
|
||||||
|
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||||
|
configurable: true,
|
||||||
|
value: false
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the app's absolute pathname
|
||||||
|
* based on the parent(s) that have
|
||||||
|
* mounted it.
|
||||||
|
*
|
||||||
|
* For example if the application was
|
||||||
|
* mounted as "/admin", which itself
|
||||||
|
* was mounted as "/blog" then the
|
||||||
|
* return value would be "/blog/admin".
|
||||||
|
*
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.path = function path() {
|
||||||
|
return this.parent
|
||||||
|
? this.parent.path() + this.mountpath
|
||||||
|
: '';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if `setting` is enabled (truthy).
|
||||||
|
*
|
||||||
|
* app.enabled('foo')
|
||||||
|
* // => false
|
||||||
|
*
|
||||||
|
* app.enable('foo')
|
||||||
|
* app.enabled('foo')
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* @param {String} setting
|
||||||
|
* @return {Boolean}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.enabled = function enabled(setting) {
|
||||||
|
return Boolean(this.set(setting));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if `setting` is disabled.
|
||||||
|
*
|
||||||
|
* app.disabled('foo')
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* app.enable('foo')
|
||||||
|
* app.disabled('foo')
|
||||||
|
* // => false
|
||||||
|
*
|
||||||
|
* @param {String} setting
|
||||||
|
* @return {Boolean}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.disabled = function disabled(setting) {
|
||||||
|
return !this.set(setting);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable `setting`.
|
||||||
|
*
|
||||||
|
* @param {String} setting
|
||||||
|
* @return {app} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.enable = function enable(setting) {
|
||||||
|
return this.set(setting, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable `setting`.
|
||||||
|
*
|
||||||
|
* @param {String} setting
|
||||||
|
* @return {app} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.disable = function disable(setting) {
|
||||||
|
return this.set(setting, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
methods.forEach(function(method){
|
||||||
|
app[method] = function(path){
|
||||||
|
if (method === 'get' && arguments.length === 1) {
|
||||||
|
// app.get(setting)
|
||||||
|
return this.set(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lazyrouter();
|
||||||
|
|
||||||
|
var route = this._router.route(path);
|
||||||
|
route[method].apply(route, slice.call(arguments, 1));
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special-cased "all" method, applying the given route `path`,
|
||||||
|
* middleware, and callback to _every_ HTTP method.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Function} ...
|
||||||
|
* @return {app} for chaining
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.all = function all(path) {
|
||||||
|
this.lazyrouter();
|
||||||
|
|
||||||
|
var route = this._router.route(path);
|
||||||
|
var args = slice.call(arguments, 1);
|
||||||
|
|
||||||
|
for (var i = 0; i < methods.length; i++) {
|
||||||
|
route[methods[i]].apply(route, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
// del -> delete alias
|
||||||
|
|
||||||
|
app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the given view `name` name with `options`
|
||||||
|
* and a callback accepting an error and the
|
||||||
|
* rendered template string.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* app.render('email', { name: 'Tobi' }, function(err, html){
|
||||||
|
* // ...
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @param {Object|Function} options or fn
|
||||||
|
* @param {Function} callback
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.render = function render(name, options, callback) {
|
||||||
|
var cache = this.cache;
|
||||||
|
var done = callback;
|
||||||
|
var engines = this.engines;
|
||||||
|
var opts = options;
|
||||||
|
var renderOptions = {};
|
||||||
|
var view;
|
||||||
|
|
||||||
|
// support callback function as second arg
|
||||||
|
if (typeof options === 'function') {
|
||||||
|
done = options;
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge app.locals
|
||||||
|
merge(renderOptions, this.locals);
|
||||||
|
|
||||||
|
// merge options._locals
|
||||||
|
if (opts._locals) {
|
||||||
|
merge(renderOptions, opts._locals);
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge options
|
||||||
|
merge(renderOptions, opts);
|
||||||
|
|
||||||
|
// set .cache unless explicitly provided
|
||||||
|
if (renderOptions.cache == null) {
|
||||||
|
renderOptions.cache = this.enabled('view cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
// primed cache
|
||||||
|
if (renderOptions.cache) {
|
||||||
|
view = cache[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
// view
|
||||||
|
if (!view) {
|
||||||
|
var View = this.get('view');
|
||||||
|
|
||||||
|
view = new View(name, {
|
||||||
|
defaultEngine: this.get('view engine'),
|
||||||
|
root: this.get('views'),
|
||||||
|
engines: engines
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!view.path) {
|
||||||
|
var dirs = Array.isArray(view.root) && view.root.length > 1
|
||||||
|
? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"'
|
||||||
|
: 'directory "' + view.root + '"'
|
||||||
|
var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs);
|
||||||
|
err.view = view;
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prime the cache
|
||||||
|
if (renderOptions.cache) {
|
||||||
|
cache[name] = view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// render
|
||||||
|
tryRender(view, renderOptions, done);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listen for connections.
|
||||||
|
*
|
||||||
|
* A node `http.Server` is returned, with this
|
||||||
|
* application (which is a `Function`) as its
|
||||||
|
* callback. If you wish to create both an HTTP
|
||||||
|
* and HTTPS server you may do so with the "http"
|
||||||
|
* and "https" modules as shown here:
|
||||||
|
*
|
||||||
|
* var http = require('http')
|
||||||
|
* , https = require('https')
|
||||||
|
* , express = require('express')
|
||||||
|
* , app = express();
|
||||||
|
*
|
||||||
|
* http.createServer(app).listen(80);
|
||||||
|
* https.createServer({ ... }, app).listen(443);
|
||||||
|
*
|
||||||
|
* @return {http.Server}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.listen = function listen() {
|
||||||
|
var server = http.createServer(this);
|
||||||
|
return server.listen.apply(server, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log error using console.error.
|
||||||
|
*
|
||||||
|
* @param {Error} err
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function logerror(err) {
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (this.get('env') !== 'test') console.error(err.stack || err.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try rendering a view.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tryRender(view, options, callback) {
|
||||||
|
try {
|
||||||
|
view.render(options, callback);
|
||||||
|
} catch (err) {
|
||||||
|
callback(err);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user