mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'dev' into proxy-logiv-dev-v4
This commit is contained in:
commit
9b49cb2b50
@ -41,7 +41,7 @@
|
||||
"cors": "2.8.5",
|
||||
"cronosjs": "1.7.1",
|
||||
"denque": "2.1.0",
|
||||
"express": "4.18.2",
|
||||
"express": "4.19.2",
|
||||
"express-session": "1.17.3",
|
||||
"form-data": "4.0.0",
|
||||
"fs-extra": "11.1.1",
|
||||
@ -64,7 +64,7 @@
|
||||
"mqtt": "4.3.7",
|
||||
"multer": "1.4.5-lts.1",
|
||||
"mustache": "4.2.0",
|
||||
"node-red-admin": "^3.1.2",
|
||||
"node-red-admin": "^3.1.3",
|
||||
"node-watch": "0.7.4",
|
||||
"nopt": "5.0.0",
|
||||
"oauth2orize": "1.11.1",
|
||||
@ -112,7 +112,7 @@
|
||||
"mermaid": "^10.4.0",
|
||||
"minami": "1.2.3",
|
||||
"mocha": "9.2.2",
|
||||
"node-red-node-test-helper": "^0.3.2",
|
||||
"node-red-node-test-helper": "^0.3.3",
|
||||
"nodemon": "2.0.20",
|
||||
"proxy": "^1.0.2",
|
||||
"sass": "1.62.1",
|
||||
|
@ -91,6 +91,7 @@ module.exports = {
|
||||
// Plugins
|
||||
adminApp.get("/plugins", needsPermission("plugins.read"), plugins.getAll, apiUtil.errorHandler);
|
||||
adminApp.get("/plugins/messages", needsPermission("plugins.read"), plugins.getCatalogs, apiUtil.errorHandler);
|
||||
adminApp.get(/^\/plugins\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,needsPermission("plugins.read"),plugins.getConfig,apiUtil.errorHandler);
|
||||
|
||||
adminApp.get("/diagnostics", needsPermission("diagnostics.read"), diagnostics.getReport, apiUtil.errorHandler);
|
||||
|
||||
|
@ -40,5 +40,31 @@ module.exports = {
|
||||
console.log(err.stack);
|
||||
apiUtils.rejectHandler(req,res,err);
|
||||
})
|
||||
},
|
||||
getConfig: function(req, res) {
|
||||
|
||||
let opts = {
|
||||
user: req.user,
|
||||
module: req.params[0],
|
||||
req: apiUtils.getRequestLogObject(req)
|
||||
}
|
||||
|
||||
if (req.get("accept") === "application/json") {
|
||||
runtimeAPI.nodes.getNodeInfo(opts.module).then(function(result) {
|
||||
res.send(result);
|
||||
}).catch(function(err) {
|
||||
apiUtils.rejectHandler(req,res,err);
|
||||
})
|
||||
} else {
|
||||
opts.lang = apiUtils.determineLangFromHeaders(req.acceptsLanguages());
|
||||
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
|
||||
opts.lang = "en-US";
|
||||
}
|
||||
runtimeAPI.plugins.getPluginConfig(opts).then(function(result) {
|
||||
return res.send(result);
|
||||
}).catch(function(err) {
|
||||
apiUtils.rejectHandler(req,res,err);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -77,6 +77,53 @@ function CommsConnection(ws, user) {
|
||||
log.trace("comms.close "+self.session);
|
||||
removeActiveConnection(self);
|
||||
});
|
||||
|
||||
const handleAuthPacket = function(msg) {
|
||||
Tokens.get(msg.auth).then(function(client) {
|
||||
if (client) {
|
||||
Users.get(client.user).then(function(user) {
|
||||
if (user) {
|
||||
self.user = user;
|
||||
log.audit({event: "comms.auth",user:self.user});
|
||||
completeConnection(msg, client.scope,msg.auth,true);
|
||||
} else {
|
||||
log.audit({event: "comms.auth.fail"});
|
||||
completeConnection(msg, null,null,false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Users.tokens(msg.auth).then(function(user) {
|
||||
if (user) {
|
||||
self.user = user;
|
||||
log.audit({event: "comms.auth",user:self.user});
|
||||
completeConnection(msg, user.permissions,msg.auth,true);
|
||||
} else {
|
||||
log.audit({event: "comms.auth.fail"});
|
||||
completeConnection(msg, null,null,false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const completeConnection = function(msg, userScope, session, sendAck) {
|
||||
try {
|
||||
if (!userScope || !Permissions.hasPermission(userScope,"status.read")) {
|
||||
ws.send(JSON.stringify({auth:"fail"}));
|
||||
ws.close();
|
||||
} else {
|
||||
pendingAuth = false;
|
||||
addActiveConnection(self);
|
||||
self.token = msg.auth;
|
||||
if (sendAck) {
|
||||
ws.send(JSON.stringify({auth:"ok"}));
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.stack);
|
||||
// Just in case the socket closes before we attempt
|
||||
// to send anything.
|
||||
}
|
||||
}
|
||||
ws.on('message', function(data,flags) {
|
||||
var msg = null;
|
||||
try {
|
||||
@ -86,68 +133,34 @@ function CommsConnection(ws, user) {
|
||||
return;
|
||||
}
|
||||
if (!pendingAuth) {
|
||||
if (msg.subscribe) {
|
||||
if (msg.auth) {
|
||||
handleAuthPacket(msg)
|
||||
} else if (msg.subscribe) {
|
||||
self.subscribe(msg.subscribe);
|
||||
// handleRemoteSubscription(ws,msg.subscribe);
|
||||
} else if (msg.topic) {
|
||||
runtimeAPI.comms.receive({
|
||||
user: self.user,
|
||||
client: self,
|
||||
topic: msg.topic,
|
||||
data: msg.data
|
||||
})
|
||||
}
|
||||
} else {
|
||||
var completeConnection = function(userScope,session,sendAck) {
|
||||
try {
|
||||
if (!userScope || !Permissions.hasPermission(userScope,"status.read")) {
|
||||
ws.send(JSON.stringify({auth:"fail"}));
|
||||
ws.close();
|
||||
} else {
|
||||
pendingAuth = false;
|
||||
addActiveConnection(self);
|
||||
self.token = msg.auth;
|
||||
if (sendAck) {
|
||||
ws.send(JSON.stringify({auth:"ok"}));
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.stack);
|
||||
// Just in case the socket closes before we attempt
|
||||
// to send anything.
|
||||
}
|
||||
}
|
||||
if (msg.auth) {
|
||||
Tokens.get(msg.auth).then(function(client) {
|
||||
if (client) {
|
||||
Users.get(client.user).then(function(user) {
|
||||
if (user) {
|
||||
self.user = user;
|
||||
log.audit({event: "comms.auth",user:self.user});
|
||||
completeConnection(client.scope,msg.auth,true);
|
||||
} else {
|
||||
log.audit({event: "comms.auth.fail"});
|
||||
completeConnection(null,null,false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Users.tokens(msg.auth).then(function(user) {
|
||||
if (user) {
|
||||
self.user = user;
|
||||
log.audit({event: "comms.auth",user:self.user});
|
||||
completeConnection(user.permissions,msg.auth,true);
|
||||
} else {
|
||||
log.audit({event: "comms.auth.fail"});
|
||||
completeConnection(null,null,false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
handleAuthPacket(msg)
|
||||
} else {
|
||||
if (anonymousUser) {
|
||||
log.audit({event: "comms.auth",user:anonymousUser});
|
||||
self.user = anonymousUser;
|
||||
completeConnection(anonymousUser.permissions,null,false);
|
||||
completeConnection(msg, anonymousUser.permissions, null, false);
|
||||
//TODO: duplicated code - pull non-auth message handling out
|
||||
if (msg.subscribe) {
|
||||
self.subscribe(msg.subscribe);
|
||||
}
|
||||
} else {
|
||||
log.audit({event: "comms.auth.fail"});
|
||||
completeConnection(null,null,false);
|
||||
completeConnection(msg, null,null,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
"clone": "2.1.2",
|
||||
"cors": "2.8.5",
|
||||
"express-session": "1.17.3",
|
||||
"express": "4.18.2",
|
||||
"express": "4.19.2",
|
||||
"memorystore": "1.6.7",
|
||||
"mime": "3.0.0",
|
||||
"multer": "1.4.5-lts.1",
|
||||
|
@ -590,6 +590,8 @@
|
||||
},
|
||||
"nodeCount": "__label__ Node",
|
||||
"nodeCount_plural": "__label__ Nodes",
|
||||
"pluginCount": "__count__ Plugin",
|
||||
"pluginCount_plural": "__count__ Plugins",
|
||||
"moduleCount": "__count__ Modul verfügbar",
|
||||
"moduleCount_plural": "__count__ Module verfügbar",
|
||||
"inuse": "In Gebrauch",
|
||||
|
@ -614,6 +614,8 @@
|
||||
},
|
||||
"nodeCount": "__label__ node",
|
||||
"nodeCount_plural": "__label__ nodes",
|
||||
"pluginCount": "__count__ plugin",
|
||||
"pluginCount_plural": "__count__ plugins",
|
||||
"moduleCount": "__count__ module available",
|
||||
"moduleCount_plural": "__count__ modules available",
|
||||
"inuse": "in use",
|
||||
|
@ -924,7 +924,14 @@
|
||||
"date": "horodatage",
|
||||
"jsonata": "expression",
|
||||
"env": "variable d'environnement",
|
||||
"cred": "identifiant"
|
||||
"cred": "identifiant",
|
||||
"conf-types": "noeud de configuration"
|
||||
},
|
||||
"date": {
|
||||
"format": {
|
||||
"timestamp": "millisecondes depuis l'époque",
|
||||
"object": "Objet de date JavaScript"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editableList": {
|
||||
|
@ -924,7 +924,14 @@
|
||||
"date": "日時",
|
||||
"jsonata": "JSONata式",
|
||||
"env": "環境変数",
|
||||
"cred": "認証情報"
|
||||
"cred": "認証情報",
|
||||
"conf-types": "設定ノード"
|
||||
},
|
||||
"date": {
|
||||
"format": {
|
||||
"timestamp": "エポックからの経過ミリ秒",
|
||||
"object": "JavaScript日付オブジェクト"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editableList": {
|
||||
@ -1230,7 +1237,7 @@
|
||||
},
|
||||
"env-var": {
|
||||
"environment": "環境変数",
|
||||
"header": "大域環境変数",
|
||||
"header": "グローバル環境変数",
|
||||
"revert": "破棄"
|
||||
},
|
||||
"action-list": {
|
||||
@ -1382,7 +1389,7 @@
|
||||
"copy-item-edit-url": "要素の編集URLをコピー",
|
||||
"move-flow-to-start": "フローを先頭に移動",
|
||||
"move-flow-to-end": "フローを末尾に移動",
|
||||
"show-global-env": "大域環境変数を表示",
|
||||
"show-global-env": "グローバル環境変数を表示",
|
||||
"lock-flow": "フローを固定",
|
||||
"unlock-flow": "フローの固定を解除",
|
||||
"show-node-help": "ノードのヘルプを表示"
|
||||
|
@ -26,6 +26,15 @@ RED.comms = (function() {
|
||||
var reconnectAttempts = 0;
|
||||
var active = false;
|
||||
|
||||
RED.events.on('login', function(username) {
|
||||
// User has logged in
|
||||
// Need to upgrade the connection to be authenticated
|
||||
if (ws && ws.readyState == 1) {
|
||||
const auth_tokens = RED.settings.get("auth-tokens");
|
||||
ws.send(JSON.stringify({auth:auth_tokens.access_token}))
|
||||
}
|
||||
})
|
||||
|
||||
function connectWS() {
|
||||
active = true;
|
||||
var wspath;
|
||||
@ -56,6 +65,7 @@ RED.comms = (function() {
|
||||
ws.send(JSON.stringify({subscribe:t}));
|
||||
}
|
||||
}
|
||||
emit('connect')
|
||||
}
|
||||
|
||||
ws = new WebSocket(wspath);
|
||||
@ -180,9 +190,53 @@ RED.comms = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function send(topic, msg) {
|
||||
if (ws && ws.readyState == 1) {
|
||||
ws.send(JSON.stringify({
|
||||
topic,
|
||||
data: msg
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
const eventHandlers = {};
|
||||
function on(evt,func) {
|
||||
eventHandlers[evt] = eventHandlers[evt]||[];
|
||||
eventHandlers[evt].push(func);
|
||||
}
|
||||
function off(evt,func) {
|
||||
const handler = eventHandlers[evt];
|
||||
if (handler) {
|
||||
for (let i=0;i<handler.length;i++) {
|
||||
if (handler[i] === func) {
|
||||
handler.splice(i,1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function emit() {
|
||||
const evt = arguments[0]
|
||||
const args = Array.prototype.slice.call(arguments,1);
|
||||
if (eventHandlers[evt]) {
|
||||
let cpyHandlers = [...eventHandlers[evt]];
|
||||
for (let i=0;i<cpyHandlers.length;i++) {
|
||||
try {
|
||||
cpyHandlers[i].apply(null, args);
|
||||
} catch(err) {
|
||||
console.warn("RED.comms.emit error: ["+evt+"] "+(err.toString()));
|
||||
console.warn(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
connect: connectWS,
|
||||
subscribe: subscribe,
|
||||
unsubscribe:unsubscribe
|
||||
unsubscribe:unsubscribe,
|
||||
on,
|
||||
off,
|
||||
send
|
||||
}
|
||||
})();
|
||||
|
@ -149,6 +149,8 @@ RED.nodes = (function() {
|
||||
},
|
||||
removeNodeSet: function(id) {
|
||||
var ns = nodeSets[id];
|
||||
if (!ns) { return {} }
|
||||
|
||||
for (var j=0;j<ns.types.length;j++) {
|
||||
delete typeToId[ns.types[j]];
|
||||
}
|
||||
@ -572,12 +574,16 @@ RED.nodes = (function() {
|
||||
* @param {String} z tab id
|
||||
*/
|
||||
checkTabState: function (z) {
|
||||
const ws = workspaces[z]
|
||||
const ws = workspaces[z] || subflows[z]
|
||||
if (ws) {
|
||||
const contentsChanged = tabDirtyMap[z].size > 0 || tabDeletedNodesMap[z].size > 0
|
||||
if (Boolean(ws.contentsChanged) !== contentsChanged) {
|
||||
ws.contentsChanged = contentsChanged
|
||||
RED.events.emit("flows:change", ws);
|
||||
if (ws.type === 'tab') {
|
||||
RED.events.emit("flows:change", ws);
|
||||
} else {
|
||||
RED.events.emit("subflows:change", ws);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1050,7 +1056,22 @@ RED.nodes = (function() {
|
||||
RED.nodes.registerType("subflow:"+sf.id, {
|
||||
defaults:{
|
||||
name:{value:""},
|
||||
env:{value:[]}
|
||||
env:{value:[], validate: function(value) {
|
||||
const errors = []
|
||||
if (value) {
|
||||
value.forEach(env => {
|
||||
const r = RED.utils.validateTypedProperty(env.value, env.type)
|
||||
if (r !== true) {
|
||||
errors.push(env.name+': '+r)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (errors.length === 0) {
|
||||
return true
|
||||
} else {
|
||||
return errors
|
||||
}
|
||||
}}
|
||||
},
|
||||
icon: function() { return sf.icon||"subflow.svg" },
|
||||
category: sf.category || "subflows",
|
||||
|
@ -1,6 +1,7 @@
|
||||
RED.plugins = (function() {
|
||||
var plugins = {};
|
||||
var pluginsByType = {};
|
||||
var moduleList = {};
|
||||
|
||||
function registerPlugin(id,definition) {
|
||||
plugins[id] = definition;
|
||||
@ -38,9 +39,43 @@ RED.plugins = (function() {
|
||||
function getPluginsByType(type) {
|
||||
return pluginsByType[type] || [];
|
||||
}
|
||||
|
||||
function setPluginList(list) {
|
||||
for(let i=0;i<list.length;i++) {
|
||||
let p = list[i];
|
||||
addPlugin(p);
|
||||
}
|
||||
}
|
||||
|
||||
function addPlugin(p) {
|
||||
|
||||
moduleList[p.module] = moduleList[p.module] || {
|
||||
name:p.module,
|
||||
version:p.version,
|
||||
local:p.local,
|
||||
sets:{},
|
||||
plugin: true,
|
||||
id: p.id
|
||||
};
|
||||
if (p.pending_version) {
|
||||
moduleList[p.module].pending_version = p.pending_version;
|
||||
}
|
||||
moduleList[p.module].sets[p.name] = p;
|
||||
|
||||
RED.events.emit("registry:plugin-module-added",p.module);
|
||||
}
|
||||
|
||||
function getModule(module) {
|
||||
return moduleList[module];
|
||||
}
|
||||
|
||||
return {
|
||||
registerPlugin: registerPlugin,
|
||||
getPlugin: getPlugin,
|
||||
getPluginsByType: getPluginsByType
|
||||
getPluginsByType: getPluginsByType,
|
||||
|
||||
setPluginList: setPluginList,
|
||||
addPlugin: addPlugin,
|
||||
getModule: getModule
|
||||
}
|
||||
})();
|
||||
|
@ -25,6 +25,7 @@ var RED = (function() {
|
||||
cache: false,
|
||||
url: 'plugins',
|
||||
success: function(data) {
|
||||
RED.plugins.setPluginList(data);
|
||||
loader.reportProgress(RED._("event.loadPlugins"), 13)
|
||||
RED.i18n.loadPluginCatalogs(function() {
|
||||
loadPlugins(function() {
|
||||
@ -534,6 +535,41 @@ var RED = (function() {
|
||||
RED.view.redrawStatus(node);
|
||||
}
|
||||
});
|
||||
RED.comms.subscribe("notification/plugin/#",function(topic,msg) {
|
||||
if (topic == "notification/plugin/added") {
|
||||
RED.settings.refreshSettings(function(err, data) {
|
||||
let addedPlugins = [];
|
||||
msg.forEach(function(m) {
|
||||
let id = m.id;
|
||||
RED.plugins.addPlugin(m);
|
||||
|
||||
m.plugins.forEach((p) => {
|
||||
addedPlugins.push(p.id);
|
||||
})
|
||||
|
||||
RED.i18n.loadNodeCatalog(id, function() {
|
||||
var lang = localStorage.getItem("editor-language")||RED.i18n.detectLanguage();
|
||||
$.ajax({
|
||||
headers: {
|
||||
"Accept":"text/html",
|
||||
"Accept-Language": lang
|
||||
},
|
||||
cache: false,
|
||||
url: 'plugins/'+id,
|
||||
success: function(data) {
|
||||
appendPluginConfig(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
if (addedPlugins.length) {
|
||||
let pluginList = "<ul><li>"+addedPlugins.map(RED.utils.sanitize).join("</li><li>")+"</li></ul>";
|
||||
// ToDo: Adapt notification (node -> plugin)
|
||||
RED.notify(RED._("palette.event.nodeAdded", {count:addedPlugins.length})+pluginList,"success");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
let pendingNodeRemovedNotifications = []
|
||||
let pendingNodeRemovedTimeout
|
||||
|
@ -118,10 +118,16 @@ RED.contextMenu = (function () {
|
||||
onselect: 'core:split-wire-with-link-nodes',
|
||||
disabled: !canEdit || !hasLinks
|
||||
},
|
||||
null,
|
||||
{ onselect: 'core:show-import-dialog', label: RED._('common.label.import')},
|
||||
{ onselect: 'core:show-examples-import-dialog', label: RED._('menu.label.importExample') }
|
||||
null
|
||||
)
|
||||
if (RED.settings.theme("menu.menu-item-import-library", true)) {
|
||||
insertOptions.push(
|
||||
{ onselect: 'core:show-import-dialog', label: RED._('common.label.import')},
|
||||
{ onselect: 'core:show-examples-import-dialog', label: RED._('menu.label.importExample') }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if (hasSelection && canEdit) {
|
||||
const nodeOptions = []
|
||||
if (!hasMultipleSelection && !isGroup) {
|
||||
@ -194,8 +200,14 @@ RED.contextMenu = (function () {
|
||||
{ onselect: 'core:paste-from-internal-clipboard', label: RED._("keyboard.pasteNode"), disabled: !canEdit || !RED.view.clipboard() },
|
||||
{ onselect: 'core:delete-selection', label: RED._('keyboard.deleteSelected'), disabled: !canEdit || !canDelete },
|
||||
{ onselect: 'core:delete-selection-and-reconnect', label: RED._('keyboard.deleteReconnect'), disabled: !canEdit || !canDelete },
|
||||
{ onselect: 'core:show-export-dialog', label: RED._("menu.label.export") },
|
||||
{ onselect: 'core:select-all-nodes', label: RED._("keyboard.selectAll") },
|
||||
)
|
||||
if (RED.settings.theme("menu.menu-item-export-library", true)) {
|
||||
menuItems.push(
|
||||
{ onselect: 'core:show-export-dialog', label: RED._("menu.label.export") }
|
||||
)
|
||||
}
|
||||
menuItems.push(
|
||||
{ onselect: 'core:select-all-nodes', label: RED._("keyboard.selectAll") }
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,7 @@ RED.editor.codeEditor.monaco = (function() {
|
||||
createMonacoCompletionItem("set (flow context)", 'flow.set("${1:name}", ${1:value});','Set a value in flow context',range),
|
||||
createMonacoCompletionItem("get (global context)", 'global.get("${1:name}");','Get a value from global context',range),
|
||||
createMonacoCompletionItem("set (global context)", 'global.set("${1:name}", ${1:value});','Set a value in global context',range),
|
||||
createMonacoCompletionItem("get (env)", 'env.get("${1|NR_NODE_ID,NR_NODE_NAME,NR_NODE_PATH,NR_GROUP_ID,NR_GROUP_NAME,NR_FLOW_ID,NR_FLOW_NAME|}");','Get env variable value',range),
|
||||
createMonacoCompletionItem("get (env)", 'env.get("${1|NR_NODE_ID,NR_NODE_NAME,NR_NODE_PATH,NR_GROUP_ID,NR_GROUP_NAME,NR_FLOW_ID,NR_FLOW_NAME,NR_SUBFLOW_NAME,NR_SUBFLOW_ID,NR_SUBFLOW_PATH|}");','Get env variable value',range),
|
||||
createMonacoCompletionItem("cloneMessage (RED.util)", 'RED.util.cloneMessage(${1:msg});',
|
||||
["```typescript",
|
||||
"RED.util.cloneMessage<T extends registry.NodeMessage>(msg: T): T",
|
||||
|
@ -153,10 +153,6 @@ RED.envVar = (function() {
|
||||
}
|
||||
|
||||
function init(done) {
|
||||
if (!RED.user.hasPermission("settings.write")) {
|
||||
RED.notify(RED._("user.errors.settings"),"error");
|
||||
return;
|
||||
}
|
||||
RED.userSettings.add({
|
||||
id:'envvar',
|
||||
title: RED._("env-var.environment"),
|
||||
|
@ -248,86 +248,106 @@ RED.palette.editor = (function() {
|
||||
var moduleInfo = nodeEntries[module].info;
|
||||
var nodeEntry = nodeEntries[module].elements;
|
||||
if (nodeEntry) {
|
||||
var activeTypeCount = 0;
|
||||
var typeCount = 0;
|
||||
var errorCount = 0;
|
||||
nodeEntry.errorList.empty();
|
||||
nodeEntries[module].totalUseCount = 0;
|
||||
nodeEntries[module].setUseCount = {};
|
||||
if (moduleInfo.plugin) {
|
||||
nodeEntry.enableButton.hide();
|
||||
nodeEntry.removeButton.show();
|
||||
|
||||
for (var setName in moduleInfo.sets) {
|
||||
if (moduleInfo.sets.hasOwnProperty(setName)) {
|
||||
var inUseCount = 0;
|
||||
var set = moduleInfo.sets[setName];
|
||||
var setElements = nodeEntry.sets[setName];
|
||||
if (set.err) {
|
||||
errorCount++;
|
||||
var errMessage = set.err;
|
||||
if (set.err.message) {
|
||||
errMessage = set.err.message;
|
||||
} else if (set.err.code) {
|
||||
errMessage = set.err.code;
|
||||
let pluginCount = 0;
|
||||
for (let setName in moduleInfo.sets) {
|
||||
if (moduleInfo.sets.hasOwnProperty(setName)) {
|
||||
let set = moduleInfo.sets[setName];
|
||||
if (set.plugins) {
|
||||
pluginCount += set.plugins.length;
|
||||
}
|
||||
$("<li>").text(errMessage).appendTo(nodeEntry.errorList);
|
||||
}
|
||||
if (set.enabled) {
|
||||
activeTypeCount += set.types.length;
|
||||
}
|
||||
typeCount += set.types.length;
|
||||
for (var i=0;i<moduleInfo.sets[setName].types.length;i++) {
|
||||
var t = moduleInfo.sets[setName].types[i];
|
||||
inUseCount += (typesInUse[t]||0);
|
||||
var swatch = setElements.swatches[t];
|
||||
}
|
||||
|
||||
nodeEntry.setCount.text(RED._('palette.editor.pluginCount',{count:pluginCount,label:pluginCount}));
|
||||
|
||||
} else {
|
||||
var activeTypeCount = 0;
|
||||
var typeCount = 0;
|
||||
var errorCount = 0;
|
||||
nodeEntry.errorList.empty();
|
||||
nodeEntries[module].totalUseCount = 0;
|
||||
nodeEntries[module].setUseCount = {};
|
||||
|
||||
for (var setName in moduleInfo.sets) {
|
||||
if (moduleInfo.sets.hasOwnProperty(setName)) {
|
||||
var inUseCount = 0;
|
||||
const set = moduleInfo.sets[setName];
|
||||
const setElements = nodeEntry.sets[setName]
|
||||
|
||||
if (set.err) {
|
||||
errorCount++;
|
||||
var errMessage = set.err;
|
||||
if (set.err.message) {
|
||||
errMessage = set.err.message;
|
||||
} else if (set.err.code) {
|
||||
errMessage = set.err.code;
|
||||
}
|
||||
$("<li>").text(errMessage).appendTo(nodeEntry.errorList);
|
||||
}
|
||||
if (set.enabled) {
|
||||
var def = RED.nodes.getType(t);
|
||||
if (def && def.color) {
|
||||
swatch.css({background:RED.utils.getNodeColor(t,def)});
|
||||
swatch.css({border: "1px solid "+getContrastingBorder(swatch.css('backgroundColor'))})
|
||||
activeTypeCount += set.types.length;
|
||||
}
|
||||
typeCount += set.types.length;
|
||||
for (var i=0;i<moduleInfo.sets[setName].types.length;i++) {
|
||||
var t = moduleInfo.sets[setName].types[i];
|
||||
inUseCount += (typesInUse[t]||0);
|
||||
if (setElements && set.enabled) {
|
||||
var def = RED.nodes.getType(t);
|
||||
if (def && def.color) {
|
||||
setElements.swatches[t].css({background:RED.utils.getNodeColor(t,def)});
|
||||
setElements.swatches[t].css({border: "1px solid "+getContrastingBorder(setElements.swatches[t].css('backgroundColor'))})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nodeEntries[module].setUseCount[setName] = inUseCount;
|
||||
nodeEntries[module].totalUseCount += inUseCount;
|
||||
nodeEntries[module].setUseCount[setName] = inUseCount;
|
||||
nodeEntries[module].totalUseCount += inUseCount;
|
||||
|
||||
if (inUseCount > 0) {
|
||||
setElements.enableButton.text(RED._('palette.editor.inuse'));
|
||||
setElements.enableButton.addClass('disabled');
|
||||
} else {
|
||||
setElements.enableButton.removeClass('disabled');
|
||||
if (set.enabled) {
|
||||
setElements.enableButton.text(RED._('palette.editor.disable'));
|
||||
} else {
|
||||
setElements.enableButton.text(RED._('palette.editor.enable'));
|
||||
if (setElements) {
|
||||
if (inUseCount > 0) {
|
||||
setElements.enableButton.text(RED._('palette.editor.inuse'));
|
||||
setElements.enableButton.addClass('disabled');
|
||||
} else {
|
||||
setElements.enableButton.removeClass('disabled');
|
||||
if (set.enabled) {
|
||||
setElements.enableButton.text(RED._('palette.editor.disable'));
|
||||
} else {
|
||||
setElements.enableButton.text(RED._('palette.editor.enable'));
|
||||
}
|
||||
}
|
||||
setElements.setRow.toggleClass("red-ui-palette-module-set-disabled",!set.enabled);
|
||||
}
|
||||
}
|
||||
setElements.setRow.toggleClass("red-ui-palette-module-set-disabled",!set.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCount === 0) {
|
||||
nodeEntry.errorRow.hide()
|
||||
} else {
|
||||
nodeEntry.errorRow.show();
|
||||
}
|
||||
|
||||
var nodeCount = (activeTypeCount === typeCount)?typeCount:activeTypeCount+" / "+typeCount;
|
||||
nodeEntry.setCount.text(RED._('palette.editor.nodeCount',{count:typeCount,label:nodeCount}));
|
||||
|
||||
if (nodeEntries[module].totalUseCount > 0) {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.inuse'));
|
||||
nodeEntry.enableButton.addClass('disabled');
|
||||
nodeEntry.removeButton.hide();
|
||||
} else {
|
||||
nodeEntry.enableButton.removeClass('disabled');
|
||||
if (moduleInfo.local) {
|
||||
nodeEntry.removeButton.css('display', 'inline-block');
|
||||
}
|
||||
if (activeTypeCount === 0) {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.enableall'));
|
||||
if (errorCount === 0) {
|
||||
nodeEntry.errorRow.hide()
|
||||
} else {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.disableall'));
|
||||
nodeEntry.errorRow.show();
|
||||
}
|
||||
|
||||
var nodeCount = (activeTypeCount === typeCount)?typeCount:activeTypeCount+" / "+typeCount;
|
||||
nodeEntry.setCount.text(RED._('palette.editor.nodeCount',{count:typeCount,label:nodeCount}));
|
||||
|
||||
if (nodeEntries[module].totalUseCount > 0) {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.inuse'));
|
||||
nodeEntry.enableButton.addClass('disabled');
|
||||
nodeEntry.removeButton.hide();
|
||||
} else {
|
||||
nodeEntry.enableButton.removeClass('disabled');
|
||||
if (moduleInfo.local) {
|
||||
nodeEntry.removeButton.css('display', 'inline-block');
|
||||
}
|
||||
if (activeTypeCount === 0) {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.enableall'));
|
||||
} else {
|
||||
nodeEntry.enableButton.text(RED._('palette.editor.disableall'));
|
||||
}
|
||||
nodeEntry.container.toggleClass("disabled",(activeTypeCount === 0));
|
||||
}
|
||||
nodeEntry.container.toggleClass("disabled",(activeTypeCount === 0));
|
||||
}
|
||||
}
|
||||
if (moduleInfo.pending_version) {
|
||||
@ -678,6 +698,33 @@ RED.palette.editor = (function() {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
RED.events.on("registry:plugin-module-added", function(module) {
|
||||
|
||||
if (!nodeEntries.hasOwnProperty(module)) {
|
||||
nodeEntries[module] = {info:RED.plugins.getModule(module)};
|
||||
var index = [module];
|
||||
for (var s in nodeEntries[module].info.sets) {
|
||||
if (nodeEntries[module].info.sets.hasOwnProperty(s)) {
|
||||
index.push(s);
|
||||
index = index.concat(nodeEntries[module].info.sets[s].types)
|
||||
}
|
||||
}
|
||||
nodeEntries[module].index = index.join(",").toLowerCase();
|
||||
nodeList.editableList('addItem', nodeEntries[module]);
|
||||
} else {
|
||||
_refreshNodeModule(module);
|
||||
}
|
||||
|
||||
for (var i=0;i<filteredList.length;i++) {
|
||||
if (filteredList[i].info.id === module) {
|
||||
var installButton = filteredList[i].elements.installButton;
|
||||
installButton.addClass('disabled');
|
||||
installButton.text(RED._('palette.editor.installed'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var settingsPane;
|
||||
@ -804,6 +851,7 @@ RED.palette.editor = (function() {
|
||||
errorRow: errorRow,
|
||||
errorList: errorList,
|
||||
setCount: setCount,
|
||||
setButton: setButton,
|
||||
container: container,
|
||||
shade: shade,
|
||||
versionSpan: versionSpan,
|
||||
@ -814,49 +862,88 @@ RED.palette.editor = (function() {
|
||||
if (container.hasClass('expanded')) {
|
||||
container.removeClass('expanded');
|
||||
contentRow.slideUp();
|
||||
setTimeout(() => {
|
||||
contentRow.empty()
|
||||
}, 200)
|
||||
object.elements.sets = {}
|
||||
} else {
|
||||
container.addClass('expanded');
|
||||
populateSetList()
|
||||
contentRow.slideDown();
|
||||
}
|
||||
})
|
||||
|
||||
var setList = Object.keys(entry.sets)
|
||||
setList.sort(function(A,B) {
|
||||
return A.toLowerCase().localeCompare(B.toLowerCase());
|
||||
});
|
||||
setList.forEach(function(setName) {
|
||||
var set = entry.sets[setName];
|
||||
var setRow = $('<div>',{class:"red-ui-palette-module-set"}).appendTo(contentRow);
|
||||
var buttonGroup = $('<div>',{class:"red-ui-palette-module-set-button-group"}).appendTo(setRow);
|
||||
var typeSwatches = {};
|
||||
set.types.forEach(function(t) {
|
||||
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
|
||||
typeSwatches[t] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
||||
$('<span>',{class:"red-ui-palette-module-type-node"}).text(t).appendTo(typeDiv);
|
||||
})
|
||||
var enableButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').appendTo(buttonGroup);
|
||||
enableButton.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
if (object.setUseCount[setName] === 0) {
|
||||
var currentSet = RED.nodes.registry.getNodeSet(set.id);
|
||||
shade.show();
|
||||
var newState = !currentSet.enabled
|
||||
changeNodeState(set.id,newState,shade,function(xhr){
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.'+(newState?'enable':'disable')+'Failed',{module: id,message:xhr.responseJSON.message}));
|
||||
const populateSetList = function () {
|
||||
var setList = Object.keys(entry.sets)
|
||||
setList.sort(function(A,B) {
|
||||
return A.toLowerCase().localeCompare(B.toLowerCase());
|
||||
});
|
||||
setList.forEach(function(setName) {
|
||||
var set = entry.sets[setName];
|
||||
var setRow = $('<div>',{class:"red-ui-palette-module-set"}).appendTo(contentRow);
|
||||
var buttonGroup = $('<div>',{class:"red-ui-palette-module-set-button-group"}).appendTo(setRow);
|
||||
var typeSwatches = {};
|
||||
let enableButton;
|
||||
if (set.types) {
|
||||
set.types.forEach(function(t) {
|
||||
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
|
||||
typeSwatches[t] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
||||
if (set.enabled) {
|
||||
var def = RED.nodes.getType(t);
|
||||
if (def && def.color) {
|
||||
typeSwatches[t].css({background:RED.utils.getNodeColor(t,def)});
|
||||
typeSwatches[t].css({border: "1px solid "+getContrastingBorder(typeSwatches[t].css('backgroundColor'))})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
$('<span>',{class:"red-ui-palette-module-type-node"}).text(t).appendTo(typeDiv);
|
||||
})
|
||||
enableButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').appendTo(buttonGroup);
|
||||
enableButton.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
if (object.setUseCount[setName] === 0) {
|
||||
var currentSet = RED.nodes.registry.getNodeSet(set.id);
|
||||
shade.show();
|
||||
var newState = !currentSet.enabled
|
||||
changeNodeState(set.id,newState,shade,function(xhr){
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.'+(newState?'enable':'disable')+'Failed',{module: id,message:xhr.responseJSON.message}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
object.elements.sets[set.name] = {
|
||||
setRow: setRow,
|
||||
enableButton: enableButton,
|
||||
swatches: typeSwatches
|
||||
};
|
||||
});
|
||||
if (object.setUseCount[setName] > 0) {
|
||||
enableButton.text(RED._('palette.editor.inuse'));
|
||||
enableButton.addClass('disabled');
|
||||
} else {
|
||||
enableButton.removeClass('disabled');
|
||||
if (set.enabled) {
|
||||
enableButton.text(RED._('palette.editor.disable'));
|
||||
} else {
|
||||
enableButton.text(RED._('palette.editor.enable'));
|
||||
}
|
||||
}
|
||||
setRow.toggleClass("red-ui-palette-module-set-disabled",!set.enabled);
|
||||
|
||||
|
||||
}
|
||||
if (set.plugins) {
|
||||
set.plugins.forEach(function(p) {
|
||||
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
|
||||
// typeSwatches[p.id] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
||||
$('<span><i class="fa fa-puzzle-piece" aria-hidden="true"></i> </span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
||||
$('<span>',{class:"red-ui-palette-module-type-node"}).text(p.id).appendTo(typeDiv);
|
||||
})
|
||||
}
|
||||
|
||||
object.elements.sets[set.name] = {
|
||||
setRow: setRow,
|
||||
enableButton: enableButton,
|
||||
swatches: typeSwatches
|
||||
};
|
||||
});
|
||||
}
|
||||
enableButton.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
if (object.totalUseCount === 0) {
|
||||
@ -1226,7 +1313,55 @@ RED.palette.editor = (function() {
|
||||
}
|
||||
}
|
||||
]
|
||||
}); }
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// dedicated list management for plugins
|
||||
if (entry.plugin) {
|
||||
|
||||
let e = nodeEntries[entry.name];
|
||||
if (e) {
|
||||
nodeList.editableList('removeItem', e);
|
||||
delete nodeEntries[entry.name];
|
||||
}
|
||||
|
||||
// We assume that a plugin that implements onremove
|
||||
// cleans the editor accordingly of its left-overs.
|
||||
let found_onremove = true;
|
||||
|
||||
let keys = Object.keys(entry.sets);
|
||||
keys.forEach((key) => {
|
||||
let set = entry.sets[key];
|
||||
for (let i=0; i<set.plugins?.length; i++) {
|
||||
let plgn = RED.plugins.getPlugin(set.plugins[i].id);
|
||||
if (plgn && plgn.onremove && typeof plgn.onremove === 'function') {
|
||||
plgn.onremove();
|
||||
} else {
|
||||
if (plgn && plgn.onadd && typeof plgn.onadd === 'function') {
|
||||
// if there's no 'onadd', there shouldn't be any left-overs
|
||||
found_onremove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!found_onremove) {
|
||||
let removeNotify = RED.notify("Removed plugin " + entry.name + ". Please reload the editor to clear left-overs.",{
|
||||
modal: true,
|
||||
fixed: true,
|
||||
type: 'warning',
|
||||
buttons: [
|
||||
{
|
||||
text: "Understood",
|
||||
class:"primary",
|
||||
click: function(e) {
|
||||
removeNotify.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
notification.close();
|
||||
|
@ -35,6 +35,10 @@ RED.palette = (function() {
|
||||
var categoryContainers = {};
|
||||
var sidebarControls;
|
||||
|
||||
let paletteState = { filter: "", collapsed: [] };
|
||||
|
||||
let filterRefreshTimeout
|
||||
|
||||
function createCategory(originalCategory,rootCategory,category,ns) {
|
||||
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
|
||||
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
|
||||
@ -60,20 +64,57 @@ RED.palette = (function() {
|
||||
catDiv.data('label',label);
|
||||
categoryContainers[category] = {
|
||||
container: catDiv,
|
||||
close: function() {
|
||||
hide: function (instant) {
|
||||
if (instant) {
|
||||
catDiv.hide()
|
||||
} else {
|
||||
catDiv.slideUp()
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
catDiv.show()
|
||||
},
|
||||
isOpen: function () {
|
||||
return !!catDiv.hasClass("red-ui-palette-open")
|
||||
},
|
||||
getNodeCount: function (visibleOnly) {
|
||||
const nodes = catDiv.find(".red-ui-palette-node")
|
||||
if (visibleOnly) {
|
||||
return nodes.filter(function() { return $(this).css('display') !== 'none'}).length
|
||||
} else {
|
||||
return nodes.length
|
||||
}
|
||||
},
|
||||
close: function(instant, skipSaveState) {
|
||||
catDiv.removeClass("red-ui-palette-open");
|
||||
catDiv.addClass("red-ui-palette-closed");
|
||||
$("#red-ui-palette-base-category-"+category).slideUp();
|
||||
if (instant) {
|
||||
$("#red-ui-palette-base-category-"+category).hide();
|
||||
} else {
|
||||
$("#red-ui-palette-base-category-"+category).slideUp();
|
||||
}
|
||||
$("#red-ui-palette-header-"+category+" i").removeClass("expanded");
|
||||
if (!skipSaveState) {
|
||||
if (!paletteState.collapsed.includes(category)) {
|
||||
paletteState.collapsed.push(category);
|
||||
savePaletteState();
|
||||
}
|
||||
}
|
||||
},
|
||||
open: function() {
|
||||
open: function(skipSaveState) {
|
||||
catDiv.addClass("red-ui-palette-open");
|
||||
catDiv.removeClass("red-ui-palette-closed");
|
||||
$("#red-ui-palette-base-category-"+category).slideDown();
|
||||
$("#red-ui-palette-header-"+category+" i").addClass("expanded");
|
||||
if (!skipSaveState) {
|
||||
if (paletteState.collapsed.includes(category)) {
|
||||
paletteState.collapsed.splice(paletteState.collapsed.indexOf(category), 1);
|
||||
savePaletteState();
|
||||
}
|
||||
}
|
||||
},
|
||||
toggle: function() {
|
||||
if (catDiv.hasClass("red-ui-palette-open")) {
|
||||
if (categoryContainers[category].isOpen()) {
|
||||
categoryContainers[category].close();
|
||||
} else {
|
||||
categoryContainers[category].open();
|
||||
@ -415,8 +456,16 @@ RED.palette = (function() {
|
||||
|
||||
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
|
||||
if (categoryNode.find(".red-ui-palette-node").length === 1) {
|
||||
categoryContainers[rootCategory].open();
|
||||
if (!paletteState?.collapsed?.includes(rootCategory)) {
|
||||
categoryContainers[rootCategory].open();
|
||||
} else {
|
||||
categoryContainers[rootCategory].close(true);
|
||||
}
|
||||
}
|
||||
clearTimeout(filterRefreshTimeout)
|
||||
filterRefreshTimeout = setTimeout(() => {
|
||||
refreshFilter()
|
||||
}, 200)
|
||||
|
||||
}
|
||||
}
|
||||
@ -516,7 +565,8 @@ RED.palette = (function() {
|
||||
paletteNode.css("backgroundColor", sf.color);
|
||||
}
|
||||
|
||||
function filterChange(val) {
|
||||
function refreshFilter() {
|
||||
const val = $("#red-ui-palette-search input").val()
|
||||
var re = new RegExp(val.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'),'i');
|
||||
$("#red-ui-palette-container .red-ui-palette-node").each(function(i,el) {
|
||||
var currentLabel = $(el).attr("data-palette-label");
|
||||
@ -528,16 +578,26 @@ RED.palette = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
for (var category in categoryContainers) {
|
||||
for (let category in categoryContainers) {
|
||||
if (categoryContainers.hasOwnProperty(category)) {
|
||||
if (categoryContainers[category].container
|
||||
.find(".red-ui-palette-node")
|
||||
.filter(function() { return $(this).css('display') !== 'none'}).length === 0) {
|
||||
categoryContainers[category].close();
|
||||
categoryContainers[category].container.slideUp();
|
||||
const categorySection = categoryContainers[category]
|
||||
if (categorySection.getNodeCount(true) === 0) {
|
||||
categorySection.hide()
|
||||
} else {
|
||||
categoryContainers[category].open();
|
||||
categoryContainers[category].container.show();
|
||||
categorySection.show()
|
||||
if (val) {
|
||||
// There is a filter being applied and it has matched
|
||||
// something in this category - show the contents
|
||||
categorySection.open(true)
|
||||
} else {
|
||||
// No filter. Only show the category if it isn't in lastState
|
||||
if (!paletteState.collapsed.includes(category)) {
|
||||
categorySection.open(true)
|
||||
} else if (categorySection.isOpen()) {
|
||||
// This section should be collapsed but isn't - so make it so
|
||||
categorySection.close(true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -553,6 +613,9 @@ RED.palette = (function() {
|
||||
|
||||
$("#red-ui-palette > .red-ui-palette-spinner").show();
|
||||
|
||||
RED.events.on('logout', function () {
|
||||
RED.settings.removeLocal('palette-state')
|
||||
})
|
||||
|
||||
RED.events.on('registry:node-type-added', function(nodeType) {
|
||||
var def = RED.nodes.getType(nodeType);
|
||||
@ -596,14 +659,14 @@ RED.palette = (function() {
|
||||
|
||||
RED.events.on("subflows:change",refreshSubflow);
|
||||
|
||||
|
||||
|
||||
$("#red-ui-palette-search input").searchBox({
|
||||
delay: 100,
|
||||
change: function() {
|
||||
filterChange($(this).val());
|
||||
refreshFilter();
|
||||
paletteState.filter = $(this).val();
|
||||
savePaletteState();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
sidebarControls = $('<div class="red-ui-sidebar-control-left"><i class="fa fa-chevron-left"></i></div>').appendTo($("#red-ui-palette"));
|
||||
RED.popover.tooltip(sidebarControls,RED._("keyboard.togglePalette"),"core:toggle-palette");
|
||||
@ -669,7 +732,23 @@ RED.palette = (function() {
|
||||
togglePalette(state);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
paletteState = JSON.parse(RED.settings.getLocal("palette-state") || '{"filter":"", "collapsed": []}');
|
||||
if (paletteState.filter) {
|
||||
// Apply the category filter
|
||||
$("#red-ui-palette-search input").searchBox("value", paletteState.filter);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Unexpected error loading palette state from localStorage: ", error);
|
||||
}
|
||||
setTimeout(() => {
|
||||
// Lazily tidy up any categories that haven't been reloaded
|
||||
paletteState.collapsed = paletteState.collapsed.filter(category => !!categoryContainers[category])
|
||||
savePaletteState()
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
function togglePalette(state) {
|
||||
if (!state) {
|
||||
$("#red-ui-main-container").addClass("red-ui-palette-closed");
|
||||
@ -689,6 +768,15 @@ RED.palette = (function() {
|
||||
})
|
||||
return categories;
|
||||
}
|
||||
|
||||
function savePaletteState() {
|
||||
try {
|
||||
RED.settings.setLocal("palette-state", JSON.stringify(paletteState));
|
||||
} catch (error) {
|
||||
console.error("Unexpected error saving palette state to localStorage: ", error);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
add:addNodeType,
|
||||
|
@ -491,6 +491,11 @@ RED.workspaces = (function() {
|
||||
createWorkspaceTabs();
|
||||
RED.events.on("sidebar:resize",workspace_tabs.resize);
|
||||
|
||||
RED.events.on("workspace:clear", () => {
|
||||
// Reset the index used to generate new flow names
|
||||
workspaceIndex = 0
|
||||
})
|
||||
|
||||
RED.actions.add("core:show-next-tab",function() {
|
||||
var oldActive = activeWorkspace;
|
||||
workspace_tabs.nextTab();
|
||||
@ -657,6 +662,9 @@ RED.workspaces = (function() {
|
||||
RED.events.on("flows:change", (ws) => {
|
||||
$("#red-ui-tab-"+(ws.id.replace(".","-"))).toggleClass('red-ui-workspace-changed',!!(ws.contentsChanged || ws.changed || ws.added));
|
||||
})
|
||||
RED.events.on("subflows:change", (ws) => {
|
||||
$("#red-ui-tab-"+(ws.id.replace(".","-"))).toggleClass('red-ui-workspace-changed',!!(ws.contentsChanged || ws.changed || ws.added));
|
||||
})
|
||||
|
||||
hideWorkspace();
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ RED.user = (function() {
|
||||
}
|
||||
|
||||
function logout() {
|
||||
RED.events.emit('logout')
|
||||
var tokens = RED.settings.get("auth-tokens");
|
||||
var token = tokens?tokens.access_token:"";
|
||||
$.ajax({
|
||||
@ -225,6 +226,7 @@ RED.user = (function() {
|
||||
});
|
||||
}
|
||||
});
|
||||
$('<i class="fa fa-user"></i>').appendTo("#red-ui-header-button-user");
|
||||
} else {
|
||||
RED.menu.addItem("red-ui-header-button-user",{
|
||||
id:"usermenu-item-username",
|
||||
@ -237,6 +239,15 @@ RED.user = (function() {
|
||||
RED.user.logout();
|
||||
}
|
||||
});
|
||||
const userMenu = $("#red-ui-header-button-user")
|
||||
userMenu.empty()
|
||||
if (RED.settings.user.image) {
|
||||
$('<span class="user-profile"></span>').css({
|
||||
backgroundImage: "url("+RED.settings.user.image+")",
|
||||
}).appendTo(userMenu);
|
||||
} else {
|
||||
$('<i class="fa fa-user"></i>').appendTo(userMenu);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -247,14 +258,6 @@ RED.user = (function() {
|
||||
|
||||
var userMenu = $('<li><a id="red-ui-header-button-user" class="button hide" href="#"></a></li>')
|
||||
.prependTo(".red-ui-header-toolbar");
|
||||
if (RED.settings.user.image) {
|
||||
$('<span class="user-profile"></span>').css({
|
||||
backgroundImage: "url("+RED.settings.user.image+")",
|
||||
}).appendTo(userMenu.find("a"));
|
||||
} else {
|
||||
$('<i class="fa fa-user"></i>').appendTo(userMenu.find("a"));
|
||||
}
|
||||
|
||||
RED.menu.init({id:"red-ui-header-button-user",
|
||||
options: []
|
||||
});
|
||||
|
@ -63,25 +63,29 @@
|
||||
}
|
||||
|
||||
.red-ui-header-toolbar {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
float: right;
|
||||
|
||||
> li {
|
||||
display: inline-block;
|
||||
display: inline-flex;
|
||||
align-items: stretch;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.button {
|
||||
height: 100%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 20px;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
padding: 0px 12px;
|
||||
text-decoration: none;
|
||||
@ -271,13 +275,13 @@
|
||||
color: var(--red-ui-header-menu-heading-color);
|
||||
}
|
||||
|
||||
#red-ui-header-button-user .user-profile {
|
||||
.user-profile {
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 35px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export default {
|
||||
"ja": "タブ上の変更通知",
|
||||
"fr": "Notification de changement sur les onglets"
|
||||
},
|
||||
image: 'images/tab-changes.png',
|
||||
image: '3.1/images/tab-changes.png',
|
||||
description: {
|
||||
"en-US": `<p>When a tab contains undeployed changes it now shows the
|
||||
same style of change icon used by nodes.</p>
|
||||
@ -89,7 +89,7 @@ export default {
|
||||
"ja": "ヘルプを見つける",
|
||||
"fr": "Trouver de l'aide"
|
||||
},
|
||||
image: 'images/node-help.png',
|
||||
image: '3.1/images/node-help.png',
|
||||
description: {
|
||||
"en-US": `<p>All node edit dialogs now include a link to that node's help
|
||||
in the footer.</p>
|
||||
@ -107,7 +107,7 @@ export default {
|
||||
"ja": "コンテキストメニューの改善",
|
||||
"fr": "Menu contextuel amélioré"
|
||||
},
|
||||
image: 'images/context-menu.png',
|
||||
image: '3.1/images/context-menu.png',
|
||||
description: {
|
||||
"en-US": `<p>The editor's context menu has been expanded to make lots more of
|
||||
the built-in actions available.</p>
|
||||
@ -129,7 +129,7 @@ export default {
|
||||
"ja": "フローを非表示",
|
||||
"fr": "Masquage de flux"
|
||||
},
|
||||
image: 'images/hiding-flows.png',
|
||||
image: '3.1/images/hiding-flows.png',
|
||||
description: {
|
||||
"en-US": `<p>Hiding flows is now done through the flow context menu.</p>
|
||||
<p>The 'hide' button in previous releases has been removed from the tabs
|
||||
@ -147,7 +147,7 @@ export default {
|
||||
"ja": "フローを固定",
|
||||
"fr": "Verrouillage de flux"
|
||||
},
|
||||
image: 'images/locking-flows.png',
|
||||
image: '3.1/images/locking-flows.png',
|
||||
description: {
|
||||
"en-US": `<p>Flows can now be locked to prevent accidental changes being made.</p>
|
||||
<p>When locked you cannot modify the nodes in any way.</p>
|
||||
@ -187,7 +187,7 @@ export default {
|
||||
"ja": "Mermaid図を追加",
|
||||
"fr": "Ajout de diagrammes Mermaid"
|
||||
},
|
||||
image: 'images/mermaid.png',
|
||||
image: '3.1/images/mermaid.png',
|
||||
description: {
|
||||
"en-US": `<p>You can also add <a href="https://github.com/mermaid-js/mermaid">Mermaid</a> diagrams directly into your node or flow descriptions.</p>
|
||||
<p>This gives you much richer options for documenting your flows.</p>`,
|
||||
@ -203,11 +203,11 @@ export default {
|
||||
"ja": "グローバル環境変数の管理",
|
||||
"fr": "Gestion des variables d'environnement globales"
|
||||
},
|
||||
image: 'images/global-env-vars.png',
|
||||
image: '3.1/images/global-env-vars.png',
|
||||
description: {
|
||||
"en-US": `<p>You can set environment variables that apply to all nodes and flows in the new
|
||||
'Global Environment Variables' section of User Settings.</p>`,
|
||||
"ja": `<p>ユーザ設定に新しく追加された「大域環境変数」のセクションで、全てのノードとフローに適用される環境変数を登録できます。</p>`,
|
||||
"ja": `<p>ユーザ設定に新しく追加された「グローバル環境変数」のセクションで、全てのノードとフローに適用される環境変数を登録できます。</p>`,
|
||||
"fr": `<p>Vous pouvez définir des variables d'environnement qui s'appliquent à tous les noeuds et flux dans la nouvelle
|
||||
section "Global Environment Variables" des paramètres utilisateur.</p>`
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ export default {
|
||||
titleIcon: "fa fa-map-o",
|
||||
title: {
|
||||
"en-US": "Welcome to Node-RED 4.0 Beta 1!",
|
||||
"ja": "Node-RED 4.0 Beta 0へようこそ!",
|
||||
"ja": "Node-RED 4.0 Beta 1へようこそ!",
|
||||
"fr": "Bienvenue dans Node-RED 4.0 Beta 1!"
|
||||
},
|
||||
description: {
|
||||
@ -17,7 +17,8 @@ export default {
|
||||
{
|
||||
title: {
|
||||
"en-US": "Timestamp formatting options",
|
||||
// "ja": ""
|
||||
"ja": "タイムスタンプの形式の項目",
|
||||
"fr": "Options de formatage de l'horodatage"
|
||||
},
|
||||
image: 'images/nr4-timestamp-formatting.png',
|
||||
description: {
|
||||
@ -26,28 +27,47 @@ export default {
|
||||
<ul>
|
||||
<li>Milliseconds since epoch - this is existing behaviour of the timestamp option</li>
|
||||
<li>ISO 8601 - a common format used by many systems</li>
|
||||
<li>JavaScript Data Object</li>
|
||||
<li>JavaScript Date Object</li>
|
||||
</ul>`,
|
||||
// "ja": ``
|
||||
"ja": `<p>タイムスタンプを設定するノードに、タイムスタンプの形式を指定できる項目が追加されました。</p>
|
||||
<p>次の3つの項目を追加したことで、簡単に選択できるようになりました:<p>
|
||||
<ul>
|
||||
<li>エポックからのミリ秒 - 従来動作と同じになるタイムスタンプの項目</li>
|
||||
<li>ISO 8601 - 多くのシステムで使用されている共通の形式</li>
|
||||
<li>JavaScript日付オブジェクト</li>
|
||||
</ul>`,
|
||||
"fr": `<p>Les noeuds qui vous permettent de définir un horodatage disposent désormais d'options sur le format dans lequel cet horodatage peut être défini.</p>
|
||||
<p>Nous gardons les choses simples en proposant trois options :<p>
|
||||
<ul>
|
||||
<li>Millisecondes depuis l'époque : il s'agit du comportement existant de l'option d'horodatage</li>
|
||||
<li>ISO 8601 : un format commun utilisé par de nombreux systèmes</li>
|
||||
<li>Objet Date JavaScript</li>
|
||||
</ul>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: {
|
||||
"en-US": "Auto-complete of flow/global and env types",
|
||||
// "ja": ""
|
||||
"ja": "フロー/グローバル、環境変数の型の自動補完",
|
||||
"fr": "Saisie automatique des types de flux/global et env"
|
||||
},
|
||||
image: 'images/nr4-auto-complete.png',
|
||||
description: {
|
||||
"en-US": `<p>The <code>flow</code>/<code>global</code> context inputs and the <code>env</code> input
|
||||
now all include auto-complete suggestions based on the live state of your flows.</p>
|
||||
`,
|
||||
// "ja": ``
|
||||
"ja": `<p><code>flow</code>/<code>global</code>コンテキストや<code>env</code>の入力を、現在のフローの状態をもとに自動補完で提案するようになりました。</p>
|
||||
`,
|
||||
"fr": `<p>Les entrées contextuelles <code>flow</code>/<code>global</code> et l'entrée <code>env</code>
|
||||
incluent désormais des suggestions de saisie semi-automatique basées sur l'état actuel de vos flux.</p>
|
||||
`,
|
||||
}
|
||||
},
|
||||
{
|
||||
title: {
|
||||
"en-US": "Config node customisation in Subflows",
|
||||
// "ja": ""
|
||||
"ja": "サブフローでの設定ノードのカスタマイズ",
|
||||
"fr": "Personnalisation du noeud de configuration dans les sous-flux"
|
||||
},
|
||||
image: 'images/nr4-sf-config.png',
|
||||
description: {
|
||||
@ -56,7 +76,14 @@ export default {
|
||||
<p>For example, each instance of a subflow that connects to an MQTT Broker and does some post-processing
|
||||
of the messages received can be pointed at a different broker.</p>
|
||||
`,
|
||||
// "ja": ``
|
||||
"ja": `<p>サブフローをカスタマイズして、選択した型の異なる設定ノードを各インスタンスが使用できるようになりました。</p>
|
||||
<p>例えば、MQTTブローカへ接続し、メッセージ受信と後処理を行うサブフローの各インスタンスに異なるブローカを指定することも可能です。</p>
|
||||
`,
|
||||
"fr": `<p>Les sous-flux peuvent désormais être personnalisés pour permettre à chaque instance d'utiliser un
|
||||
noeud de configuration d'un type sélectionné.</p>
|
||||
<p>Par exemple, chaque instance d'un sous-flux qui se connecte à un courtier MQTT et effectue un post-traitement
|
||||
des messages reçus peut être pointée vers un autre courtier.</p>
|
||||
`
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -74,6 +101,21 @@ export default {
|
||||
<li>Customisable headers on the WebSocket node</li>
|
||||
<li>Split node now can operate on any message property</li>
|
||||
<li>and lots more...</li>
|
||||
</ul>`,
|
||||
"ja": `<p>コアノードには沢山の軽微な修正、ドキュメント更新、小さな機能拡張が入っています。全リストはヘルプサイドバーにある変更履歴を参照してください。</p>
|
||||
<ul>
|
||||
<li>RFC4180に完全に準拠したCSVモード</li>
|
||||
<li>WebSocketノードのカスタマイズ可能なヘッダ</li>
|
||||
<li>Splitノードは、メッセージプロパティで操作できるようになりました</li>
|
||||
<li>他にも沢山あります...</li>
|
||||
</ul>`,
|
||||
"fr": `<p>Les noeuds principaux ont reçu de nombreux correctifs mineurs ainsi que des améliorations. La documentation a été mise à jour.
|
||||
Consultez le journal des modifications dans la barre latérale d'aide pour une liste complète. Ci-dessous, les changements les plus importants :</p>
|
||||
<ul>
|
||||
<li>Un mode CSV entièrement conforme à la norme RFC4180</li>
|
||||
<li>En-têtes personnalisables pour le noeud WebSocket</li>
|
||||
<li>Le noeud Split peut désormais fonctionner sur n'importe quelle propriété de message</li>
|
||||
<li>Et bien plus encore...</li>
|
||||
</ul>`
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
interface NodeMessage {
|
||||
topic?: string;
|
||||
payload?: any;
|
||||
_msgid?: string;
|
||||
/** `_msgid` is generated internally. It not something you typically need to set or modify. */ _msgid?: string;
|
||||
[other: string]: any; //permit other properties
|
||||
}
|
||||
|
||||
@ -19,15 +19,15 @@ declare const promisify:typeof import('util').promisify
|
||||
/**
|
||||
* @typedef NodeStatus
|
||||
* @type {object}
|
||||
* @property {string} [fill] The fill property can be: red, green, yellow, blue or grey.
|
||||
* @property {string} [shape] The shape property can be: ring or dot.
|
||||
* @property {string} [text] The text to display
|
||||
* @property {'red'|'green'|'yellow'|'blue'|'grey'|string} [fill] - The fill property can be: red, green, yellow, blue or grey.
|
||||
* @property {'ring'|'dot'|string} [shape] The shape property can be: ring or dot.
|
||||
* @property {string|boolean|number} [text] The text to display
|
||||
*/
|
||||
interface NodeStatus {
|
||||
/** The fill property can be: red, green, yellow, blue or grey */
|
||||
fill?: string,
|
||||
fill?: 'red'|'green'|'yellow'|'blue'|'grey'|string,
|
||||
/** The shape property can be: ring or dot */
|
||||
shape?: string,
|
||||
shape?: 'ring'|'dot'|string,
|
||||
/** The text to display */
|
||||
text?: string|boolean|number
|
||||
}
|
||||
@ -37,25 +37,24 @@ declare class node {
|
||||
* Send 1 or more messages asynchronously
|
||||
* @param {object | object[]} msg The msg object
|
||||
* @param {Boolean} [clone=true] Flag to indicate the `msg` should be cloned. Default = `true`
|
||||
* @see node-red documentation [writing-functions: sending messages asynchronously](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously)
|
||||
* @see Node-RED documentation [writing-functions: sending messages asynchronously](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously)
|
||||
*/
|
||||
static send(msg:object|object[], clone?:Boolean): void;
|
||||
static send(msg:NodeMessage|NodeMessage[], clone?:Boolean): void;
|
||||
/** Inform runtime this instance has completed its operation */
|
||||
static done();
|
||||
/** Send an error to the console and debug side bar. Include `msg` in the 2nd parameter to trigger the catch node. */
|
||||
static error(err:string|Error, msg?:object);
|
||||
static error(err:string|Error, msg?:NodeMessage);
|
||||
/** Log a warn message to the console and debug sidebar */
|
||||
static warn(warning:string|object);
|
||||
/** Log an info message to the console (not sent to sidebar)' */
|
||||
static log(info:string|object);
|
||||
/** Sets the status icon and text underneath the node.
|
||||
* @param {NodeStatus} status - The status object `{fill, shape, text}`
|
||||
* @see node-red documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
|
||||
* @see Node-RED documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
|
||||
*/
|
||||
static status(status:NodeStatus);
|
||||
/** Sets the status text underneath the node.
|
||||
* @param {string} status - The status to display
|
||||
* @see node-red documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
|
||||
* @see Node-RED documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
|
||||
*/
|
||||
static status(status:string|boolean|number);
|
||||
/** the id of this node */
|
||||
@ -264,9 +263,12 @@ declare class global {
|
||||
/** Get an array of the keys in the context store */
|
||||
static keys(store: string, callback: Function);
|
||||
}
|
||||
|
||||
// (string & {}) is a workaround for offering string type completion without enforcing it. See https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939
|
||||
type NR_ENV_NAME_STRING = 'NR_NODE_ID'|'NR_NODE_NAME'|'NR_NODE_PATH'|'NR_GROUP_ID'|'NR_GROUP_NAME'|'NR_FLOW_ID'|'NR_FLOW_NAME'|'NR_SUBFLOW_ID'|'NR_SUBFLOW_NAME'|'NR_SUBFLOW_PATH' | (string & {})
|
||||
declare class env {
|
||||
/**
|
||||
* Get an environment variable value
|
||||
* Get an environment variable value defined in the OS, or in the global/flow/subflow/group environment variables.
|
||||
*
|
||||
* Predefined node-red variables...
|
||||
* * `NR_NODE_ID` - the ID of the node
|
||||
@ -276,9 +278,16 @@ declare class env {
|
||||
* * `NR_GROUP_NAME` - the Name of the containing group
|
||||
* * `NR_FLOW_ID` - the ID of the flow the node is on
|
||||
* * `NR_FLOW_NAME` - the Name of the flow the node is on
|
||||
* @param name Name of the environment variable to get
|
||||
* * `NR_SUBFLOW_ID` - the ID of the subflow the node is in
|
||||
* * `NR_SUBFLOW_NAME` - the Name of the subflow the node is in
|
||||
* * `NR_SUBFLOW_PATH` - the Path of the subflow the node is in
|
||||
* @param name - The name of the environment variable
|
||||
* @example
|
||||
* ```const flowName = env.get("NR_FLOW_NAME");```
|
||||
* ```const flowName = env.get("NR_FLOW_NAME") // get the name of the flow```
|
||||
* @example
|
||||
* ```const systemHomeDir = env.get("HOME") // get the user's home directory```
|
||||
* @example
|
||||
* ```const systemHomeDir = env.get("LABEL1") // get the value of a global/flow/subflow/group defined variable named "LABEL1"```
|
||||
*/
|
||||
static get(name:string) :any;
|
||||
static get(name:NR_ENV_NAME_STRING) :any;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/assert.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js)
|
||||
*/
|
||||
declare module 'assert' {
|
||||
/**
|
||||
@ -290,8 +290,8 @@ declare module 'assert' {
|
||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
* using the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) ( `==` ). `NaN` is special handled
|
||||
* and treated as being identical in case both sides are `NaN`.
|
||||
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
||||
* and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
@ -323,9 +323,8 @@ declare module 'assert' {
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive inequality with the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison)(`!=` ). `NaN` is special handled and treated as
|
||||
* being identical in case both
|
||||
* sides are `NaN`.
|
||||
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
||||
* specially handled and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
@ -415,7 +414,7 @@ declare module 'assert' {
|
||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests strict equality between the `actual` and `expected` parameters as
|
||||
* determined by the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
@ -453,7 +452,7 @@ declare module 'assert' {
|
||||
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
||||
* determined by the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||
@ -9,7 +9,7 @@
|
||||
* import async_hooks from 'async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/async_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js)
|
||||
*/
|
||||
declare module 'async_hooks' {
|
||||
/**
|
||||
@ -367,7 +367,7 @@ declare module 'async_hooks' {
|
||||
*
|
||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||
* with each other data.
|
||||
* with each other's data.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
class AsyncLocalStorage<T> {
|
||||
@ -398,8 +398,9 @@ declare module 'async_hooks' {
|
||||
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 or
|
||||
* the asynchronous operations created within the callback.
|
||||
* 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.
|
||||
*
|
||||
@ -413,6 +414,9 @@ declare module 'async_hooks' {
|
||||
* try {
|
||||
* asyncLocalStorage.run(store, () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* setTimeout(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* }, 200);
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
|
||||
@ -44,7 +44,7 @@
|
||||
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
||||
* const buf7 = Buffer.from('tést', 'latin1');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/buffer.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/buffer.js)
|
||||
*/
|
||||
declare module 'buffer' {
|
||||
import { BinaryLike } from 'node:crypto';
|
||||
@ -117,18 +117,17 @@ declare module 'buffer' {
|
||||
/**
|
||||
* A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
|
||||
* multiple worker threads.
|
||||
* @since v15.7.0
|
||||
* @experimental
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
export class Blob {
|
||||
/**
|
||||
* The total size of the `Blob` in bytes.
|
||||
* @since v15.7.0
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
readonly size: number;
|
||||
/**
|
||||
* The content-type of the `Blob`.
|
||||
* @since v15.7.0
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
readonly type: string;
|
||||
/**
|
||||
@ -143,13 +142,13 @@ declare module 'buffer' {
|
||||
/**
|
||||
* Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of
|
||||
* the `Blob` data.
|
||||
* @since v15.7.0
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
/**
|
||||
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
||||
* data. The original `Blob` is not altered.
|
||||
* @since v15.7.0
|
||||
* @since v15.7.0, v14.18.0
|
||||
* @param start The starting index.
|
||||
* @param end The ending index.
|
||||
* @param type The content-type for the new `Blob`
|
||||
@ -158,7 +157,7 @@ declare module 'buffer' {
|
||||
/**
|
||||
* Returns a promise that fulfills with the contents of the `Blob` decoded as a
|
||||
* UTF-8 string.
|
||||
* @since v15.7.0
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
text(): Promise<string>;
|
||||
/**
|
||||
@ -169,6 +168,12 @@ declare module 'buffer' {
|
||||
}
|
||||
export import atob = globalThis.atob;
|
||||
export import btoa = globalThis.btoa;
|
||||
|
||||
import { Blob as NodeBlob } from 'buffer';
|
||||
// This conditional type will be the existing global Blob in a browser, or
|
||||
// the copy below in a Node environment.
|
||||
type __Blob = typeof globalThis extends { onmessage: any, Blob: infer T }
|
||||
? T : NodeBlob;
|
||||
global {
|
||||
// Buffer class
|
||||
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
||||
@ -394,7 +399,7 @@ declare module 'buffer' {
|
||||
* @since v0.11.13
|
||||
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
||||
*/
|
||||
compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
||||
compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||
*
|
||||
@ -447,7 +452,7 @@ declare module 'buffer' {
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` 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.
|
||||
* _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 'buffer';
|
||||
@ -485,7 +490,7 @@ declare module 'buffer' {
|
||||
* 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
|
||||
* _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,
|
||||
@ -708,7 +713,7 @@ declare module 'buffer' {
|
||||
* @param [sourceStart=0] The offset within `buf` at which to begin comparison.
|
||||
* @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
|
||||
*/
|
||||
compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1;
|
||||
/**
|
||||
* Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
|
||||
*
|
||||
@ -767,8 +772,6 @@ declare module 'buffer' {
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* This is the same behavior as `buf.subarray()`.
|
||||
*
|
||||
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||
*
|
||||
@ -784,8 +787,17 @@ declare module 'buffer' {
|
||||
*
|
||||
* 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).
|
||||
*/
|
||||
@ -1952,7 +1964,7 @@ declare module 'buffer' {
|
||||
*
|
||||
* * a string, `value` is interpreted according to the character encoding in`encoding`.
|
||||
* * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
|
||||
* To compare a partial `Buffer`, use `buf.slice()`.
|
||||
* To compare a partial `Buffer`, use `buf.subarray`.
|
||||
* * a number, `value` will be interpreted as an unsigned 8-bit integer
|
||||
* value between `0` and `255`.
|
||||
*
|
||||
@ -2208,7 +2220,7 @@ declare module 'buffer' {
|
||||
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
||||
* @since v15.13.0
|
||||
* @since v15.13.0, v14.17.0
|
||||
* @deprecated Use `Buffer.from(data, 'base64')` instead.
|
||||
* @param data The Base64-encoded input string.
|
||||
*/
|
||||
@ -2224,11 +2236,24 @@ declare module 'buffer' {
|
||||
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
||||
* @since v15.13.0
|
||||
* @since v15.13.0, v14.17.0
|
||||
* @deprecated Use `buf.toString('base64')` instead.
|
||||
* @param data An ASCII (Latin1) string.
|
||||
*/
|
||||
function btoa(data: string): string;
|
||||
|
||||
interface Blob extends __Blob {}
|
||||
/**
|
||||
* `Blob` class is a global reference for `require('node:buffer').Blob`
|
||||
* https://nodejs.org/api/buffer.html#class-blob
|
||||
* @since v18.0.0
|
||||
*/
|
||||
var Blob: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Blob: infer T;
|
||||
}
|
||||
? T
|
||||
: typeof NodeBlob;
|
||||
}
|
||||
}
|
||||
declare module 'node:buffer' {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `child_process` module provides the ability to spawn subprocesses in
|
||||
@ -31,8 +31,11 @@
|
||||
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
|
||||
*
|
||||
* The command lookup is performed using the `options.env.PATH` environment
|
||||
* variable if it is in the `options` object. Otherwise, `process.env.PATH` is
|
||||
* used.
|
||||
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
||||
* used. If `options.env` is set without `PATH`, lookup on Unix is performed
|
||||
* on a default search path search of `/usr/bin:/bin` (see your operating system's
|
||||
* manual for execvpe/execvp), on Windows the current processes environment
|
||||
* variable `PATH` is used.
|
||||
*
|
||||
* On Windows, environment variables are case-insensitive. Node.js
|
||||
* lexicographically sorts the `env` keys and uses the first one that
|
||||
@ -63,7 +66,7 @@
|
||||
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
||||
* the synchronous methods can have significant impact on performance due to
|
||||
* stalling the event loop while spawned processes complete.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/child_process.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js)
|
||||
*/
|
||||
declare module 'child_process' {
|
||||
import { ObjectEncodingOptions } from 'node:fs';
|
||||
@ -624,7 +627,7 @@ declare module 'child_process' {
|
||||
}
|
||||
interface CommonOptions extends ProcessEnvOptions {
|
||||
/**
|
||||
* @default false
|
||||
* @default true
|
||||
*/
|
||||
windowsHide?: boolean | undefined;
|
||||
/**
|
||||
|
@ -1,10 +1,11 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* A single instance of Node.js runs in a single thread. To take advantage of
|
||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
||||
* processes to handle the load.
|
||||
* 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` 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.
|
||||
@ -52,7 +53,7 @@
|
||||
* ```
|
||||
*
|
||||
* 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/v16.9.0/lib/cluster.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/cluster.js)
|
||||
*/
|
||||
declare module 'cluster' {
|
||||
import * as child from 'node:child_process';
|
||||
@ -102,9 +103,9 @@ declare module 'cluster' {
|
||||
/**
|
||||
* 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()`.
|
||||
* In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
|
||||
*
|
||||
* In a worker this sends a message to the primary. It is identical to`process.send()`.
|
||||
* 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:
|
||||
*
|
||||
@ -126,19 +127,13 @@ declare module 'cluster' {
|
||||
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, it does this
|
||||
* by disconnecting the `worker.process`, and once disconnected, killing
|
||||
* with `signal`. In the worker, it does it by disconnecting the channel,
|
||||
* and then exiting with code `0`.
|
||||
* 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`.
|
||||
*
|
||||
* Because `kill()` attempts to gracefully disconnect the worker process, it is
|
||||
* susceptible to waiting indefinitely for the disconnect to complete. For example,
|
||||
* if the worker enters an infinite loop, a graceful disconnect will never occur.
|
||||
* If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
|
||||
* The `kill()` function kills the worker process without waiting for a graceful
|
||||
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* This method is aliased as `worker.destroy()` for backward compatibility.
|
||||
* 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()`.
|
||||
@ -256,7 +251,8 @@ declare module 'cluster' {
|
||||
*/
|
||||
isDead(): boolean;
|
||||
/**
|
||||
* This property is `true` if the worker exited due to `.kill()` or`.disconnect()`. If the worker exited any other way, it is `false`. If the
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
@ -56,7 +56,7 @@
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/console.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js)
|
||||
*/
|
||||
declare module 'console' {
|
||||
import console = require('node:console');
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `crypto` module provides cryptographic functionality that includes a set of
|
||||
@ -16,12 +16,64 @@
|
||||
* // Prints:
|
||||
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/crypto.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/crypto.js)
|
||||
*/
|
||||
declare module 'crypto' {
|
||||
import * as stream from 'node:stream';
|
||||
import { PeerCertificate } from 'node:tls';
|
||||
interface Certificate {
|
||||
/**
|
||||
* SPKAC is a Certificate Signing Request mechanism originally implemented by
|
||||
* Netscape and was specified formally as part of [HTML5's `keygen` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen).
|
||||
*
|
||||
* `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects
|
||||
* should not use this element anymore.
|
||||
*
|
||||
* The `crypto` module provides the `Certificate` class for working with SPKAC
|
||||
* data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
|
||||
* implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally.
|
||||
* @since v0.11.8
|
||||
*/
|
||||
class Certificate {
|
||||
/**
|
||||
* ```js
|
||||
* const { Certificate } = await import('crypto');
|
||||
* const spkac = getSpkacSomehow();
|
||||
* const challenge = Certificate.exportChallenge(spkac);
|
||||
* console.log(challenge.toString('utf8'));
|
||||
* // Prints: the challenge as a UTF8 string
|
||||
* ```
|
||||
* @since v9.0.0
|
||||
* @param encoding The `encoding` of the `spkac` string.
|
||||
* @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
|
||||
*/
|
||||
static exportChallenge(spkac: BinaryLike): Buffer;
|
||||
/**
|
||||
* ```js
|
||||
* const { Certificate } = await import('crypto');
|
||||
* const spkac = getSpkacSomehow();
|
||||
* const publicKey = Certificate.exportPublicKey(spkac);
|
||||
* console.log(publicKey);
|
||||
* // Prints: the public key as <Buffer ...>
|
||||
* ```
|
||||
* @since v9.0.0
|
||||
* @param encoding The `encoding` of the `spkac` string.
|
||||
* @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
|
||||
*/
|
||||
static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
|
||||
/**
|
||||
* ```js
|
||||
* import { Buffer } from 'buffer';
|
||||
* const { Certificate } = await import('crypto');
|
||||
*
|
||||
* const spkac = getSpkacSomehow();
|
||||
* console.log(Certificate.verifySpkac(Buffer.from(spkac)));
|
||||
* // Prints: true or false
|
||||
* ```
|
||||
* @since v9.0.0
|
||||
* @param encoding The `encoding` of the `spkac` string.
|
||||
* @return `true` if the given `spkac` data structure is valid, `false` otherwise.
|
||||
*/
|
||||
static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
|
||||
/**
|
||||
* @deprecated
|
||||
* @param spkac
|
||||
@ -45,31 +97,6 @@ declare module 'crypto' {
|
||||
*/
|
||||
verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
|
||||
}
|
||||
const Certificate: Certificate & {
|
||||
/** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
|
||||
new (): Certificate;
|
||||
/** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
|
||||
(): Certificate;
|
||||
/**
|
||||
* @param spkac
|
||||
* @returns The challenge component of the `spkac` data structure,
|
||||
* which includes a public key and a challenge.
|
||||
*/
|
||||
exportChallenge(spkac: BinaryLike): Buffer;
|
||||
/**
|
||||
* @param spkac
|
||||
* @param encoding The encoding of the spkac string.
|
||||
* @returns The public key component of the `spkac` data structure,
|
||||
* which includes a public key and a challenge.
|
||||
*/
|
||||
exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
|
||||
/**
|
||||
* @param spkac
|
||||
* @returns `true` if the given `spkac` data structure is valid,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
|
||||
};
|
||||
namespace constants {
|
||||
// https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
|
||||
const OPENSSL_VERSION_NUMBER: number;
|
||||
@ -175,7 +202,7 @@ declare module 'crypto' {
|
||||
*
|
||||
* The `algorithm` is dependent on the available algorithms supported by the
|
||||
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
||||
* On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
|
||||
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
||||
* display the available digest algorithms.
|
||||
*
|
||||
* Example: generating the sha256 sum of a file
|
||||
@ -215,7 +242,7 @@ declare module 'crypto' {
|
||||
*
|
||||
* The `algorithm` is dependent on the available algorithms supported by the
|
||||
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
||||
* On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
|
||||
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
||||
* display the available digest algorithms.
|
||||
*
|
||||
* The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
|
||||
@ -253,7 +280,7 @@ declare module 'crypto' {
|
||||
*/
|
||||
function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
|
||||
// https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
|
||||
type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex';
|
||||
type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
|
||||
type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
|
||||
type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
|
||||
type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
|
||||
@ -662,12 +689,13 @@ declare module 'crypto' {
|
||||
* Creates and returns a `Cipher` object that uses the given `algorithm` and`password`.
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
|
||||
* tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
* The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
||||
* display the available cipher algorithms.
|
||||
*
|
||||
* The `password` is used to derive the cipher key and initialization vector (IV).
|
||||
@ -700,12 +728,13 @@ declare module 'crypto' {
|
||||
* initialization vector (`iv`).
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
|
||||
* tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
* The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
||||
* display the available cipher algorithms.
|
||||
*
|
||||
* The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
|
||||
@ -925,8 +954,9 @@ declare module 'crypto' {
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key).
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
* The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
|
||||
* function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
|
||||
@ -951,12 +981,13 @@ declare module 'crypto' {
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`).
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags
|
||||
* to those with the specified length.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
* The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
|
||||
* recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
||||
* display the available cipher algorithms.
|
||||
*
|
||||
* The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
|
||||
@ -1162,13 +1193,11 @@ declare module 'crypto' {
|
||||
format?: KeyFormat | undefined;
|
||||
type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
|
||||
passphrase?: string | Buffer | undefined;
|
||||
encoding?: string | undefined;
|
||||
}
|
||||
interface PublicKeyInput {
|
||||
key: string | Buffer;
|
||||
format?: KeyFormat | undefined;
|
||||
type?: 'pkcs1' | 'spki' | undefined;
|
||||
encoding?: string | undefined;
|
||||
}
|
||||
/**
|
||||
* Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
|
||||
@ -1279,7 +1308,6 @@ declare module 'crypto' {
|
||||
interface VerifyKeyObjectInput extends SigningOptions {
|
||||
key: KeyObject;
|
||||
}
|
||||
interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
||||
type KeyLike = string | Buffer | KeyObject;
|
||||
/**
|
||||
* The `Sign` class is a utility for generating signatures. It can be used in one
|
||||
@ -1434,8 +1462,8 @@ declare module 'crypto' {
|
||||
* be passed instead of a public key.
|
||||
* @since v0.1.92
|
||||
*/
|
||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
|
||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
|
||||
}
|
||||
/**
|
||||
* Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
|
||||
@ -1453,10 +1481,10 @@ declare module 'crypto' {
|
||||
* @param [generator=2]
|
||||
* @param generatorEncoding The `encoding` of the `generator` string.
|
||||
*/
|
||||
function createDiffieHellman(primeLength: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
|
||||
function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
|
||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding): DiffieHellman;
|
||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
|
||||
function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
|
||||
function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
|
||||
function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
|
||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
|
||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
|
||||
/**
|
||||
* The `DiffieHellman` class is a utility for creating Diffie-Hellman key
|
||||
@ -1805,7 +1833,7 @@ declare module 'crypto' {
|
||||
* Return a random integer `n` such that `min <= n < max`. This
|
||||
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
||||
*
|
||||
* The range (`max - min`) must be less than `2**48`. `min` and `max` must
|
||||
* The range (`max - min`) must be less than 2^48. `min` and `max` must
|
||||
* be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||
*
|
||||
* If the `callback` function is not provided, the random integer is
|
||||
@ -2281,11 +2309,11 @@ declare module 'crypto' {
|
||||
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
|
||||
* returned.
|
||||
* @since v0.11.14
|
||||
* @param encoding The `encoding` of the return value.
|
||||
* @param [encoding] The `encoding` of the return value.
|
||||
* @param [format='uncompressed']
|
||||
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
||||
*/
|
||||
getPublicKey(): Buffer;
|
||||
getPublicKey(encoding?: null, format?: ECDHKeyFormat): Buffer;
|
||||
getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
|
||||
/**
|
||||
* Sets the EC Diffie-Hellman private key.
|
||||
@ -2316,7 +2344,8 @@ declare module 'crypto' {
|
||||
* comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/).
|
||||
*
|
||||
* `a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
|
||||
* must have the same byte length.
|
||||
* must have the same byte length. An error is thrown if `a` and `b` have
|
||||
* different byte lengths.
|
||||
*
|
||||
* If at least one of `a` and `b` is a `TypedArray` with more than one byte per
|
||||
* entry, such as `Uint16Array`, the result will be computed using the platform
|
||||
@ -2331,7 +2360,7 @@ declare module 'crypto' {
|
||||
/** @deprecated since v10.0.0 */
|
||||
const DEFAULT_ENCODING: BufferEncoding;
|
||||
type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
|
||||
type KeyFormat = 'pem' | 'der' | 'jwk';
|
||||
type KeyFormat = 'pem' | 'der';
|
||||
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
||||
format: T;
|
||||
cipher?: string | undefined;
|
||||
@ -2942,16 +2971,11 @@ declare module 'crypto' {
|
||||
* If the `callback` function is provided this function uses libuv's threadpool.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
||||
function verify(
|
||||
algorithm: string | null | undefined,
|
||||
data: NodeJS.ArrayBufferView,
|
||||
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
|
||||
signature: NodeJS.ArrayBufferView
|
||||
): boolean;
|
||||
function verify(
|
||||
algorithm: string | null | undefined,
|
||||
data: NodeJS.ArrayBufferView,
|
||||
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
|
||||
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
|
||||
signature: NodeJS.ArrayBufferView,
|
||||
callback: (error: Error | null, result: boolean) => void
|
||||
): void;
|
||||
@ -3100,34 +3124,33 @@ declare module 'crypto' {
|
||||
*/
|
||||
disableEntropyCache?: boolean | undefined;
|
||||
}
|
||||
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
||||
/**
|
||||
* Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
|
||||
* cryptographic pseudorandom number generator.
|
||||
* @since v15.6.0
|
||||
* @since v15.6.0, v14.17.0
|
||||
*/
|
||||
function randomUUID(options?: RandomUUIDOptions): UUID;
|
||||
function randomUUID(options?: RandomUUIDOptions): string;
|
||||
interface X509CheckOptions {
|
||||
/**
|
||||
* @default 'always'
|
||||
*/
|
||||
subject?: 'always' | 'default' | 'never';
|
||||
subject: 'always' | 'never';
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
wildcards?: boolean;
|
||||
wildcards: boolean;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
partialWildcards?: boolean;
|
||||
partialWildcards: boolean;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
multiLabelWildcards?: boolean;
|
||||
multiLabelWildcards: boolean;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
singleLabelSubdomains?: boolean;
|
||||
singleLabelSubdomains: boolean;
|
||||
}
|
||||
/**
|
||||
* Encapsulates an X509 certificate and provides read-only access to
|
||||
@ -3144,12 +3167,16 @@ declare module 'crypto' {
|
||||
*/
|
||||
class X509Certificate {
|
||||
/**
|
||||
* Will be \`true\` if this is a Certificate Authority (ca) certificate.
|
||||
* Will be \`true\` if this is a Certificate Authority (CA) certificate.
|
||||
* @since v15.6.0
|
||||
*/
|
||||
readonly ca: boolean;
|
||||
/**
|
||||
* The SHA-1 fingerprint of this certificate.
|
||||
*
|
||||
* Because SHA-1 is cryptographically broken and because the security of SHA-1 is
|
||||
* significantly worse than that of algorithms that are commonly used to sign
|
||||
* certificates, consider using `x509.fingerprint256` instead.
|
||||
* @since v15.6.0
|
||||
*/
|
||||
readonly fingerprint: string;
|
||||
@ -3208,6 +3235,10 @@ declare module 'crypto' {
|
||||
readonly raw: Buffer;
|
||||
/**
|
||||
* The serial number of this certificate.
|
||||
*
|
||||
* Serial numbers are assigned by certificate authorities and do not uniquely
|
||||
* identify certificates. Consider using `x509.fingerprint256` as a unique
|
||||
* identifier instead.
|
||||
* @since v15.6.0
|
||||
*/
|
||||
readonly serialNumber: string;
|
||||
@ -3224,18 +3255,50 @@ declare module 'crypto' {
|
||||
constructor(buffer: BinaryLike);
|
||||
/**
|
||||
* Checks whether the certificate matches the given email address.
|
||||
*
|
||||
* If the `'subject'` option is undefined or set to `'default'`, the certificate
|
||||
* subject is only considered if the subject alternative name extension either does
|
||||
* not exist or does not contain any email addresses.
|
||||
*
|
||||
* If the `'subject'` option is set to `'always'` and if the subject alternative
|
||||
* name extension either does not exist or does not contain a matching email
|
||||
* address, the certificate subject is considered.
|
||||
*
|
||||
* If the `'subject'` option is set to `'never'`, the certificate subject is never
|
||||
* considered, even if the certificate contains no subject alternative names.
|
||||
* @since v15.6.0
|
||||
* @return Returns `email` if the certificate matches, `undefined` if it does not.
|
||||
*/
|
||||
checkEmail(email: string, options?: Pick<X509CheckOptions, 'subject'>): string | undefined;
|
||||
/**
|
||||
* Checks whether the certificate matches the given host name.
|
||||
*
|
||||
* If the certificate matches the given host name, the matching subject name is
|
||||
* returned. The returned name might be an exact match (e.g., `foo.example.com`)
|
||||
* or it might contain wildcards (e.g., `*.example.com`). Because host name
|
||||
* comparisons are case-insensitive, the returned subject name might also differ
|
||||
* from the given `name` in capitalization.
|
||||
*
|
||||
* If the `'subject'` option is undefined or set to `'default'`, the certificate
|
||||
* subject is only considered if the subject alternative name extension either does
|
||||
* not exist or does not contain any DNS names. This behavior is consistent with [RFC 2818](https://www.rfc-editor.org/rfc/rfc2818.txt) ("HTTP Over TLS").
|
||||
*
|
||||
* If the `'subject'` option is set to `'always'` and if the subject alternative
|
||||
* name extension either does not exist or does not contain a matching DNS name,
|
||||
* the certificate subject is considered.
|
||||
*
|
||||
* If the `'subject'` option is set to `'never'`, the certificate subject is never
|
||||
* considered, even if the certificate contains no subject alternative names.
|
||||
* @since v15.6.0
|
||||
* @return Returns `name` if the certificate matches, `undefined` if it does not.
|
||||
* @return Returns a subject name that matches `name`, or `undefined` if no subject name matches `name`.
|
||||
*/
|
||||
checkHost(name: string, options?: X509CheckOptions): string | undefined;
|
||||
/**
|
||||
* Checks whether the certificate matches the given IP address (IPv4 or IPv6).
|
||||
*
|
||||
* Only [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280.txt) `iPAddress` subject alternative names are considered, and they
|
||||
* must match the given `ip` address exactly. Other subject alternative names as
|
||||
* well as the subject field of the certificate are ignored.
|
||||
* @since v15.6.0
|
||||
* @return Returns `ip` if the certificate matches, `undefined` if it does not.
|
||||
*/
|
||||
@ -3408,6 +3471,19 @@ declare module 'crypto' {
|
||||
* @param [flags=crypto.constants.ENGINE_METHOD_ALL]
|
||||
*/
|
||||
function setEngine(engine: string, flags?: number): void;
|
||||
/**
|
||||
* A convenient alias for `crypto.webcrypto.getRandomValues()`.
|
||||
* This implementation is not compliant with the Web Crypto spec,
|
||||
* to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead.
|
||||
* @since v17.4.0
|
||||
* @returns Returns `typedArray`.
|
||||
*/
|
||||
function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
|
||||
/**
|
||||
* A convenient alias for `crypto.webcrypto.subtle`.
|
||||
* @since v17.4.0
|
||||
*/
|
||||
const subtle: webcrypto.SubtleCrypto;
|
||||
/**
|
||||
* An implementation of the Web Crypto API standard.
|
||||
*
|
||||
@ -3565,7 +3641,7 @@ declare module 'crypto' {
|
||||
* The UUID is generated using a cryptographic pseudorandom number generator.
|
||||
* @since v16.7.0
|
||||
*/
|
||||
randomUUID(): UUID;
|
||||
randomUUID(): string;
|
||||
CryptoKey: CryptoKeyConstructor;
|
||||
}
|
||||
// This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
|
||||
@ -3650,17 +3726,22 @@ declare module 'crypto' {
|
||||
/**
|
||||
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
||||
* `subtle.deriveBits()` attempts to generate `length` bits.
|
||||
* The Node.js implementation requires that `length` is a multiple of `8`.
|
||||
* The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
|
||||
* When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
|
||||
* for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
|
||||
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
||||
*
|
||||
* The algorithms currently supported include:
|
||||
*
|
||||
* - `'ECDH'`
|
||||
* - `'X25519'`
|
||||
* - `'X448'`
|
||||
* - `'HKDF'`
|
||||
* - `'PBKDF2'`
|
||||
* @since v15.0.0
|
||||
*/
|
||||
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
||||
deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
|
||||
deriveBits(algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
||||
/**
|
||||
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
||||
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
||||
@ -3671,6 +3752,8 @@ declare module 'crypto' {
|
||||
* The algorithms currently supported include:
|
||||
*
|
||||
* - `'ECDH'`
|
||||
* - `'X25519'`
|
||||
* - `'X448'`
|
||||
* - `'HKDF'`
|
||||
* - `'PBKDF2'`
|
||||
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
||||
@ -3739,7 +3822,11 @@ declare module 'crypto' {
|
||||
* - `'RSA-PSS'`
|
||||
* - `'RSA-OAEP'`
|
||||
* - `'ECDSA'`
|
||||
* - `'Ed25519'`
|
||||
* - `'Ed448'`
|
||||
* - `'ECDH'`
|
||||
* - `'X25519'`
|
||||
* - `'X448'`
|
||||
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
||||
*
|
||||
* - `'HMAC'`
|
||||
@ -3787,6 +3874,8 @@ declare module 'crypto' {
|
||||
* - `'RSASSA-PKCS1-v1_5'`
|
||||
* - `'RSA-PSS'`
|
||||
* - `'ECDSA'`
|
||||
* - `'Ed25519'`
|
||||
* - `'Ed448'`
|
||||
* - `'HMAC'`
|
||||
* @since v15.0.0
|
||||
*/
|
||||
@ -3812,7 +3901,11 @@ declare module 'crypto' {
|
||||
* - `'RSA-PSS'`
|
||||
* - `'RSA-OAEP'`
|
||||
* - `'ECDSA'`
|
||||
* - `'Ed25519'`
|
||||
* - `'Ed448'`
|
||||
* - `'ECDH'`
|
||||
* - `'X25519'`
|
||||
* - `'X448'`
|
||||
* - `'HMAC'`
|
||||
* - `'AES-CTR'`
|
||||
* - `'AES-CBC'`
|
||||
@ -3841,6 +3934,8 @@ declare module 'crypto' {
|
||||
* - `'RSASSA-PKCS1-v1_5'`
|
||||
* - `'RSA-PSS'`
|
||||
* - `'ECDSA'`
|
||||
* - `'Ed25519'`
|
||||
* - `'Ed448'`
|
||||
* - `'HMAC'`
|
||||
* @since v15.0.0
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
||||
@ -26,7 +26,7 @@
|
||||
* server.bind(41234);
|
||||
* // Prints: server listening 0.0.0.0:41234
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/dgram.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dgram.js)
|
||||
*/
|
||||
declare module 'dgram' {
|
||||
import { AddressInfo } from 'node:net';
|
||||
@ -263,7 +263,7 @@ declare module 'dgram' {
|
||||
*
|
||||
* 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 falsy, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
||||
* 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
|
||||
@ -454,7 +454,7 @@ declare module 'dgram' {
|
||||
* 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 between 1 and 255\. The default on most systems
|
||||
* 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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `diagnostics_channel` module provides an API to create named channels
|
||||
@ -23,7 +23,7 @@
|
||||
* should generally include the module name to avoid collisions with data from
|
||||
* other modules.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/diagnostics_channel.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js)
|
||||
*/
|
||||
declare module 'diagnostics_channel' {
|
||||
/**
|
||||
@ -44,7 +44,7 @@ declare module 'diagnostics_channel' {
|
||||
* @param name The channel name
|
||||
* @return If there are active subscribers
|
||||
*/
|
||||
function hasSubscribers(name: string | symbol): boolean;
|
||||
function hasSubscribers(name: string): boolean;
|
||||
/**
|
||||
* This is the primary entry-point for anyone wanting to interact with a named
|
||||
* channel. It produces a channel object which is optimized to reduce overhead at
|
||||
@ -59,8 +59,8 @@ declare module 'diagnostics_channel' {
|
||||
* @param name The channel name
|
||||
* @return The named channel object
|
||||
*/
|
||||
function channel(name: string | symbol): Channel;
|
||||
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
||||
function channel(name: string): Channel;
|
||||
type ChannelListener = (message: unknown, name: string) => void;
|
||||
/**
|
||||
* The class `Channel` represents an individual named channel within the data
|
||||
* pipeline. It is use to track subscribers and to publish messages when there
|
||||
@ -71,7 +71,7 @@ declare module 'diagnostics_channel' {
|
||||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
class Channel {
|
||||
readonly name: string | symbol;
|
||||
readonly name: string;
|
||||
/**
|
||||
* Check if there are active subscribers to this channel. This is helpful if
|
||||
* the message you want to send might be expensive to prepare.
|
||||
@ -91,7 +91,7 @@ declare module 'diagnostics_channel' {
|
||||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
readonly hasSubscribers: boolean;
|
||||
private constructor(name: string | symbol);
|
||||
private constructor(name: string);
|
||||
/**
|
||||
* Publish a message to any subscribers to the channel. This will
|
||||
* trigger message handlers synchronously so they will execute within
|
||||
@ -146,6 +146,7 @@ declare module 'diagnostics_channel' {
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @param onMessage The previous subscribed handler to remove
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
unsubscribe(onMessage: ChannelListener): void;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `dns` module enables name resolution. For example, use it to look up IP
|
||||
@ -45,7 +45,7 @@
|
||||
* ```
|
||||
*
|
||||
* See the `Implementation considerations section` for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/dns.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js)
|
||||
*/
|
||||
declare module 'dns' {
|
||||
import * as dnsPromises from 'node:dns/promises';
|
||||
@ -61,6 +61,9 @@ declare module 'dns' {
|
||||
family?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
all?: boolean | undefined;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
verbatim?: boolean | undefined;
|
||||
}
|
||||
export interface LookupOneOptions extends LookupOptions {
|
||||
@ -174,7 +177,7 @@ declare module 'dns' {
|
||||
type: 'AAAA';
|
||||
}
|
||||
export interface CaaRecord {
|
||||
critical: number;
|
||||
critial: number;
|
||||
issue?: string | undefined;
|
||||
issuewild?: string | undefined;
|
||||
iodef?: string | undefined;
|
||||
@ -317,7 +320,7 @@ declare module 'dns' {
|
||||
* 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
|
||||
* @since v15.0.0, v14.17.0
|
||||
*/
|
||||
export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
|
||||
export namespace resolveCaa {
|
||||
@ -530,14 +533,16 @@ declare module 'dns' {
|
||||
*/
|
||||
export function getServers(): string[];
|
||||
/**
|
||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
||||
* - `ipv4first`: sets default `verbatim` `false`.
|
||||
* - `verbatim`: sets default `verbatim` `true`.
|
||||
* Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
|
||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
||||
* @since v14.18.0
|
||||
* @param order must be 'ipv4first' or 'verbatim'.
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher
|
||||
* priority than `--dns-result-order`. When using `worker threads`,{@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'` or `'verbatim'`.
|
||||
*/
|
||||
export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||
// Error codes
|
||||
@ -643,7 +648,7 @@ declare module 'dns' {
|
||||
* 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
|
||||
* @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.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
||||
@ -192,7 +192,7 @@ declare module 'dns/promises' {
|
||||
* 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
|
||||
* @since v15.0.0, v14.17.0
|
||||
*/
|
||||
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||
/**
|
||||
@ -335,14 +335,16 @@ declare module 'dns/promises' {
|
||||
*/
|
||||
function setServers(servers: ReadonlyArray<string>): void;
|
||||
/**
|
||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
||||
* - `ipv4first`: sets default `verbatim` `false`.
|
||||
* - `verbatim`: sets default `verbatim` `true`.
|
||||
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
|
||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
||||
* @since v14.18.0
|
||||
* @param order must be 'ipv4first' or 'verbatim'.
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have
|
||||
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.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'` or `'verbatim'`.
|
||||
*/
|
||||
function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||
class Resolver {
|
||||
|
129
packages/node_modules/@node-red/editor-client/src/types/node/dom-events.d.ts
vendored
Normal file
129
packages/node_modules/@node-red/editor-client/src/types/node/dom-events.d.ts
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* **This module is pending deprecation.** Once a replacement API has been
|
||||
@ -15,7 +15,7 @@
|
||||
* 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/v16.9.0/lib/domain.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js)
|
||||
*/
|
||||
declare module 'domain' {
|
||||
import EventEmitter = require('node:events');
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* Much of the Node.js core API is built around an idiomatic asynchronous
|
||||
@ -35,19 +35,56 @@
|
||||
* });
|
||||
* myEmitter.emit('event');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/events.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
|
||||
*/
|
||||
declare module 'events' {
|
||||
// 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 NodeEventTarget {
|
||||
// Any EventTarget with a Node-style `once` function
|
||||
interface _NodeEventTarget {
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
interface DOMEventTarget {
|
||||
// Any EventTarget with a DOM-style `addEventListener`
|
||||
interface _DOMEventTarget {
|
||||
addEventListener(
|
||||
eventName: string,
|
||||
listener: (...args: any[]) => void,
|
||||
@ -157,8 +194,8 @@ declare module 'events' {
|
||||
* ```
|
||||
* @since v11.13.0, v10.16.0
|
||||
*/
|
||||
static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
/**
|
||||
* ```js
|
||||
* const { on, EventEmitter } = require('events');
|
||||
@ -260,9 +297,9 @@ declare module 'events' {
|
||||
* getEventListeners(et, 'foo'); // [listener]
|
||||
* }
|
||||
* ```
|
||||
* @since v15.2.0
|
||||
* @since v15.2.0, v14.17.0
|
||||
*/
|
||||
static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* ```js
|
||||
* const {
|
||||
@ -280,7 +317,7 @@ declare module 'events' {
|
||||
* @param eventsTargets 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<DOMEventTarget | NodeJS.EventEmitter>): void;
|
||||
static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
|
||||
/**
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||
* events. Listeners installed using this symbol are called before the regular
|
||||
@ -396,8 +433,8 @@ declare module 'events' {
|
||||
* 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.
|
||||
* 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
|
||||
* const myEmitter = new MyEmitter();
|
||||
@ -599,7 +636,7 @@ declare module 'events' {
|
||||
*/
|
||||
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): 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
|
||||
* 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `fs` module enables interacting with the file system in a
|
||||
@ -19,7 +19,7 @@
|
||||
*
|
||||
* All file system operations have synchronous, callback, and promise-based
|
||||
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/fs.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/fs.js)
|
||||
*/
|
||||
declare module 'fs' {
|
||||
import * as stream from 'node:stream';
|
||||
@ -271,18 +271,22 @@ declare module 'fs' {
|
||||
*/
|
||||
export interface StatWatcher extends EventEmitter {
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have
|
||||
* no effect.
|
||||
*
|
||||
* By default, all `fs.StatWatcher` objects are "ref'ed", making it normally
|
||||
* unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
|
||||
* called previously.
|
||||
* @since v14.3.0, v12.20.0
|
||||
* When called, requests that the Node.js event loop not exit so long as the `fs.StatWatcher` is active.
|
||||
* Calling `watcher.ref()` multiple times will have no effect.
|
||||
* By default, all `fs.StatWatcher`` objects are "ref'ed", making it normally unnecessary to call `watcher.ref()`
|
||||
* unless `watcher.unref()` had been called previously.
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* When called, the active `fs.StatWatcher` 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 `fs.StatWatcher` object's
|
||||
* callback is invoked. Calling `watcher.unref()` multiple times will have
|
||||
* no effect.
|
||||
* @since v14.3.0, v12.20.0
|
||||
* When called, the active `fs.StatWatcher`` 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 `fs.StatWatcher`` object's callback is invoked.
|
||||
* `Calling watcher.unref()` multiple times will have no effect.
|
||||
*/
|
||||
unref(): this;
|
||||
}
|
||||
@ -1017,8 +1021,10 @@ declare module 'fs' {
|
||||
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
|
||||
}
|
||||
/**
|
||||
* Synchronous fstat(2) - Get file status.
|
||||
* @param fd A file descriptor.
|
||||
* Retrieves the `fs.Stats` for the file descriptor.
|
||||
*
|
||||
* See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
|
||||
* @since v0.1.95
|
||||
*/
|
||||
export function fstatSync(
|
||||
fd: number,
|
||||
@ -1033,7 +1039,6 @@ declare module 'fs' {
|
||||
}
|
||||
): BigIntStats;
|
||||
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
|
||||
|
||||
/**
|
||||
* Retrieves the `fs.Stats` for the symbolic link referred to by the path.
|
||||
* The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
|
||||
@ -1121,15 +1126,15 @@ declare module 'fs' {
|
||||
* ```js
|
||||
* import { symlink } from 'fs';
|
||||
*
|
||||
* symlink('./mew', './example/mewtwo', callback);
|
||||
* symlink('./mew', './mewtwo', callback);
|
||||
* ```
|
||||
*
|
||||
* The above example creates a symbolic link `mewtwo` in the `example` which points
|
||||
* to `mew` in the same directory:
|
||||
* The above example creates a symbolic link `mewtwo` which points to `mew` in the
|
||||
* same directory:
|
||||
*
|
||||
* ```bash
|
||||
* $ tree example/
|
||||
* example/
|
||||
* $ tree .
|
||||
* .
|
||||
* ├── mew
|
||||
* └── mewtwo -> ./mew
|
||||
* ```
|
||||
@ -1393,7 +1398,7 @@ declare module 'fs' {
|
||||
* Use `fs.rm(path, { recursive: true, force: true })` instead.
|
||||
*
|
||||
* If `true`, perform a recursive directory removal. In
|
||||
* recursive mode soperations are retried on failure.
|
||||
* recursive mode, operations are retried on failure.
|
||||
* @default false
|
||||
*/
|
||||
recursive?: boolean | undefined;
|
||||
@ -1999,8 +2004,8 @@ declare module 'fs' {
|
||||
export function open(path: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
||||
/**
|
||||
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
|
||||
* @param [flags='r'] See `support of file system `flags``.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param [flags='r'] See `support of file system `flags``.
|
||||
*/
|
||||
export function open(path: PathLike, flags: OpenMode | undefined, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
||||
/**
|
||||
@ -2008,6 +2013,7 @@ declare module 'fs' {
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
*/
|
||||
export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
||||
|
||||
export namespace open {
|
||||
/**
|
||||
* Asynchronous open(2) - open and possibly create a file.
|
||||
@ -2096,8 +2102,7 @@ declare module 'fs' {
|
||||
*/
|
||||
export function fsyncSync(fd: number): void;
|
||||
/**
|
||||
* Write `buffer` to the file specified by `fd`. If `buffer` is a normal object, it
|
||||
* must have an own `toString` function property.
|
||||
* Write `buffer` to the file specified by `fd`.
|
||||
*
|
||||
* `offset` determines the part of the buffer to be written, and `length` is
|
||||
* an integer specifying the number of bytes to write.
|
||||
@ -2220,8 +2225,6 @@ declare module 'fs' {
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
||||
*
|
||||
* For detailed information, see the documentation of the asynchronous version of
|
||||
* this API: {@link write}.
|
||||
* @since v0.1.21
|
||||
@ -2237,6 +2240,23 @@ declare module 'fs' {
|
||||
*/
|
||||
export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
|
||||
export type ReadPosition = number | bigint;
|
||||
export interface ReadSyncOptions {
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
offset?: number | undefined;
|
||||
/**
|
||||
* @default `length of buffer`
|
||||
*/
|
||||
length?: number | undefined;
|
||||
/**
|
||||
* @default null
|
||||
*/
|
||||
position?: ReadPosition | null | undefined;
|
||||
}
|
||||
export interface ReadAsyncOptions<TBuffer extends NodeJS.ArrayBufferView> extends ReadSyncOptions {
|
||||
buffer?: TBuffer;
|
||||
}
|
||||
/**
|
||||
* Read data from the file specified by `fd`.
|
||||
*
|
||||
@ -2262,6 +2282,21 @@ declare module 'fs' {
|
||||
position: ReadPosition | null,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
||||
): void;
|
||||
/**
|
||||
* Similar to the above `fs.read` function, this version takes an optional `options` object.
|
||||
* If not otherwise specified in an `options` object,
|
||||
* `buffer` defaults to `Buffer.alloc(16384)`,
|
||||
* `offset` defaults to `0`,
|
||||
* `length` defaults to `buffer.byteLength`, `- offset` as of Node 17.6.0
|
||||
* `position` defaults to `null`
|
||||
* @since v12.17.0, 13.11.0
|
||||
*/
|
||||
export function read<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
options: ReadAsyncOptions<TBuffer>,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
||||
): void;
|
||||
export function read(fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
|
||||
export namespace read {
|
||||
/**
|
||||
* @param fd A file descriptor.
|
||||
@ -2280,20 +2315,17 @@ declare module 'fs' {
|
||||
bytesRead: number;
|
||||
buffer: TBuffer;
|
||||
}>;
|
||||
}
|
||||
export interface ReadSyncOptions {
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
offset?: number | undefined;
|
||||
/**
|
||||
* @default `length of buffer`
|
||||
*/
|
||||
length?: number | undefined;
|
||||
/**
|
||||
* @default null
|
||||
*/
|
||||
position?: ReadPosition | null | undefined;
|
||||
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
options: ReadAsyncOptions<TBuffer>
|
||||
): Promise<{
|
||||
bytesRead: number;
|
||||
buffer: TBuffer;
|
||||
}>;
|
||||
function __promisify__(fd: number): Promise<{
|
||||
bytesRead: number;
|
||||
buffer: NodeJS.ArrayBufferView;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* Returns the number of `bytesRead`.
|
||||
@ -2558,8 +2590,6 @@ declare module 'fs' {
|
||||
*
|
||||
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
||||
*
|
||||
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
||||
*
|
||||
* ```js
|
||||
* import { writeFile } from 'fs';
|
||||
* import { Buffer } from 'buffer';
|
||||
@ -2636,8 +2666,6 @@ declare module 'fs' {
|
||||
/**
|
||||
* Returns `undefined`.
|
||||
*
|
||||
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
||||
*
|
||||
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
||||
*
|
||||
* For detailed information, see the documentation of the asynchronous version of
|
||||
@ -2821,6 +2849,52 @@ declare module 'fs' {
|
||||
persistent?: boolean | undefined;
|
||||
interval?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* Watch for changes on `filename`. The callback `listener` will be called each
|
||||
* time the file is accessed.
|
||||
*
|
||||
* The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
|
||||
* whether the process should continue to run as long as files are being watched.
|
||||
* The `options` object may specify an `interval` property indicating how often the
|
||||
* target should be polled in milliseconds.
|
||||
*
|
||||
* The `listener` gets two arguments the current stat object and the previous
|
||||
* stat object:
|
||||
*
|
||||
* ```js
|
||||
* import { watchFile } from 'fs';
|
||||
*
|
||||
* watchFile('message.text', (curr, prev) => {
|
||||
* console.log(`the current mtime is: ${curr.mtime}`);
|
||||
* console.log(`the previous mtime was: ${prev.mtime}`);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
|
||||
* the numeric values in these objects are specified as `BigInt`s.
|
||||
*
|
||||
* To be notified when the file was modified, not just accessed, it is necessary
|
||||
* to compare `curr.mtimeMs` and `prev.mtimeMs`.
|
||||
*
|
||||
* When an `fs.watchFile` operation results in an `ENOENT` error, it
|
||||
* will invoke the listener once, with all the fields zeroed (or, for dates, the
|
||||
* Unix Epoch). If the file is created later on, the listener will be called
|
||||
* again, with the latest stat objects. This is a change in functionality since
|
||||
* v0.10.
|
||||
*
|
||||
* Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
|
||||
*
|
||||
* When a file being watched by `fs.watchFile()` disappears and reappears,
|
||||
* then the contents of `previous` in the second callback event (the file's
|
||||
* reappearance) will be the same as the contents of `previous` in the first
|
||||
* callback event (its disappearance).
|
||||
*
|
||||
* This happens when:
|
||||
*
|
||||
* * the file is deleted, followed by a restore
|
||||
* * the file is renamed and then renamed a second time back to its original name
|
||||
* @since v0.1.31
|
||||
*/
|
||||
export function watchFile(
|
||||
filename: PathLike,
|
||||
options:
|
||||
@ -3189,9 +3263,9 @@ declare module 'fs' {
|
||||
/**
|
||||
* Tests a user's permissions for the file or directory specified by `path`.
|
||||
* The `mode` argument is an optional integer that specifies the accessibility
|
||||
* checks to be performed. Check `File access constants` for possible values
|
||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
||||
* checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
* The final argument, `callback`, is a callback function that is invoked with
|
||||
* a possible error argument. If any of the accessibility checks fail, the error
|
||||
@ -3217,14 +3291,9 @@ declare module 'fs' {
|
||||
* console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
|
||||
* });
|
||||
*
|
||||
* // Check if the file exists in the current directory, and if it is writable.
|
||||
* access(file, constants.F_OK | constants.W_OK, (err) => {
|
||||
* if (err) {
|
||||
* console.error(
|
||||
* `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
|
||||
* } else {
|
||||
* console.log(`${file} exists, and it is writable`);
|
||||
* }
|
||||
* // Check if the file is readable and writable.
|
||||
* access(file, constants.R_OK | constants.W_OK, (err) => {
|
||||
* console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
@ -3368,10 +3437,9 @@ declare module 'fs' {
|
||||
/**
|
||||
* Synchronously tests a user's permissions for the file or directory specified
|
||||
* by `path`. The `mode` argument is an optional integer that specifies the
|
||||
* accessibility checks to be performed. Check `File access constants` for
|
||||
* possible values of `mode`. It is possible to create a mask consisting of
|
||||
* the bitwise OR of two or more values
|
||||
* (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
||||
* accessibility checks to be performed. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and
|
||||
* `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
||||
* the method will return `undefined`.
|
||||
@ -3474,9 +3542,9 @@ declare module 'fs' {
|
||||
/**
|
||||
* `options` may also include a `start` option to allow writing data at some
|
||||
* position past the beginning of the file, allowed values are in the
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than replacing
|
||||
* it may require the `flags` option to be set to `r+` rather than the default `w`.
|
||||
* The `encoding` can be any one of those accepted by `Buffer`.
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
||||
* replacing it may require the `flags` option to be set to `r+` rather than the
|
||||
* default `w`. The `encoding` can be any one of those accepted by `Buffer`.
|
||||
*
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* then the file descriptor won't be closed, even if there's an error.
|
||||
@ -3756,6 +3824,11 @@ declare module 'fs' {
|
||||
* @default false
|
||||
*/
|
||||
recursive?: boolean;
|
||||
/**
|
||||
* When true, path resolution for symlinks will be skipped
|
||||
* @default false
|
||||
*/
|
||||
verbatimSymlinks?: boolean;
|
||||
}
|
||||
export interface CopyOptions extends CopyOptionsBase {
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `fs/promises` API provides asynchronous file system methods that return
|
||||
@ -14,6 +14,7 @@
|
||||
declare module 'fs/promises' {
|
||||
import { Abortable } from 'node:events';
|
||||
import { Stream } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import {
|
||||
BigIntStats,
|
||||
BufferEncodingOption,
|
||||
@ -33,11 +34,14 @@ declare module 'fs/promises' {
|
||||
RmOptions,
|
||||
StatOptions,
|
||||
Stats,
|
||||
TimeLike,
|
||||
WatchEventType,
|
||||
WatchOptions,
|
||||
WriteStream,
|
||||
WriteVResult,
|
||||
} from 'node:fs';
|
||||
import { Interface as ReadlineInterface } from 'node:readline';
|
||||
|
||||
interface FileChangeInfo<T extends string | Buffer> {
|
||||
eventType: WatchEventType;
|
||||
filename: T;
|
||||
@ -46,11 +50,11 @@ declare module 'fs/promises' {
|
||||
mode?: Mode | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
}
|
||||
interface FileReadResult<T extends ArrayBufferView> {
|
||||
interface FileReadResult<T extends NodeJS.ArrayBufferView> {
|
||||
bytesRead: number;
|
||||
buffer: T;
|
||||
}
|
||||
interface FileReadOptions<T extends ArrayBufferView = Buffer> {
|
||||
interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
|
||||
/**
|
||||
* @default `Buffer.alloc(0xffff)`
|
||||
*/
|
||||
@ -167,9 +171,9 @@ declare module 'fs/promises' {
|
||||
/**
|
||||
* `options` may also include a `start` option to allow writing data at some
|
||||
* position past the beginning of the file, allowed values are in the
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than replacing
|
||||
* it may require the `flags` `open` option to be set to `r+` rather than the
|
||||
* default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
||||
* replacing it may require the `flags` `open` option to be set to `r+` rather than
|
||||
* the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
||||
*
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* then the file descriptor won't be closed, even if there's an error.
|
||||
@ -211,8 +215,31 @@ declare module 'fs/promises' {
|
||||
* integer, the current file position will remain unchanged.
|
||||
* @return Fulfills upon success with an object with two properties:
|
||||
*/
|
||||
read<T extends ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
||||
read<T extends ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
||||
read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
||||
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
||||
/**
|
||||
* Returns a `ReadableStream` that may be used to read the files data.
|
||||
*
|
||||
* An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
|
||||
* or closing.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* const file = await open('./some/file/to/read');
|
||||
*
|
||||
* for await (const chunk of file.readableWebStream())
|
||||
* console.log(chunk);
|
||||
*
|
||||
* await file.close();
|
||||
* ```
|
||||
*
|
||||
* While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method.
|
||||
*
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
readableWebStream(): ReadableStream;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
*
|
||||
@ -261,6 +288,23 @@ declare module 'fs/promises' {
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string | Buffer>;
|
||||
/**
|
||||
* Convenience method to create a `readline` interface and stream over the file. For example:
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* const file = await open('./some/file/to/read');
|
||||
*
|
||||
* for await (const line of file.readLines()) {
|
||||
* console.log(line);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since v18.11.0
|
||||
* @param options See `filehandle.createReadStream()` for the options.
|
||||
*/
|
||||
readLines(options?: CreateReadStreamOptions): ReadlineInterface;
|
||||
/**
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with an {fs.Stats} for the file.
|
||||
@ -309,13 +353,12 @@ declare module 'fs/promises' {
|
||||
* Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
||||
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object, or an
|
||||
* object with an own `toString` function
|
||||
* property. The promise is resolved with no arguments upon success.
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
||||
* The promise is resolved with no arguments upon success.
|
||||
*
|
||||
* If `options` is a string, then it specifies the `encoding`.
|
||||
*
|
||||
@ -333,20 +376,18 @@ declare module 'fs/promises' {
|
||||
/**
|
||||
* Write `buffer` to the file.
|
||||
*
|
||||
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
||||
*
|
||||
* The promise is resolved with an object containing two properties:
|
||||
*
|
||||
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
||||
* without waiting for the promise to be resolved (or rejected). For this
|
||||
* scenario, use `fs.createWriteStream()`.
|
||||
* scenario, use `filehandle.createWriteStream()`.
|
||||
*
|
||||
* On Linux, positional writes do not work when the file is opened in append mode.
|
||||
* The kernel ignores the position argument and always appends the data to
|
||||
* the end of the file.
|
||||
* @since v10.0.0
|
||||
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
||||
* @param [length=buffer.byteLength] The number of bytes from `buffer` to write.
|
||||
* @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
|
||||
* @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
|
||||
* See the POSIX pwrite(2) documentation for more detail.
|
||||
*/
|
||||
@ -411,12 +452,13 @@ declare module 'fs/promises' {
|
||||
}
|
||||
|
||||
const constants: typeof fsConstants;
|
||||
|
||||
/**
|
||||
* Tests a user's permissions for the file or directory specified by `path`.
|
||||
* The `mode` argument is an optional integer that specifies the accessibility
|
||||
* checks to be performed. Check `File access constants` for possible values
|
||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
||||
* checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
* If the accessibility check is successful, the promise is resolved with no
|
||||
* value. If any of the accessibility checks fail, the promise is rejected
|
||||
@ -747,7 +789,7 @@ declare module 'fs/promises' {
|
||||
* @since v14.5.0, v12.19.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function lutimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Changes the ownership of a file.
|
||||
* @since v10.0.0
|
||||
@ -765,7 +807,7 @@ declare module 'fs/promises' {
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function.
|
||||
*
|
||||
@ -836,7 +878,9 @@ declare module 'fs/promises' {
|
||||
*/
|
||||
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
||||
/**
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a `Buffer`, or, an object with an own (not inherited)`toString` function property.
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
||||
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
||||
*
|
||||
* The `encoding` option is ignored if `data` is a buffer.
|
||||
*
|
||||
@ -851,7 +895,7 @@ declare module 'fs/promises' {
|
||||
*
|
||||
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
||||
* method that performs multiple `write` calls internally to write the buffer
|
||||
* passed to it. For performance sensitive code consider using `fs.createWriteStream()`.
|
||||
* passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
|
||||
*
|
||||
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
||||
* Cancelation is "best effort", and some amount of data is likely still
|
||||
@ -1049,7 +1093,7 @@ declare module 'fs/promises' {
|
||||
* disappears in the directory.
|
||||
*
|
||||
* All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
|
||||
* @since v15.9.0
|
||||
* @since v15.9.0, v14.18.0
|
||||
* @return of objects with the properties:
|
||||
*/
|
||||
function watch(
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
// Declare "static" methods in Error
|
||||
interface ErrorConstructor {
|
||||
@ -56,28 +56,32 @@ interface AbortController {
|
||||
/**
|
||||
* 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;
|
||||
abort(): 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 {
|
||||
interface AbortSignal extends EventTarget {
|
||||
/**
|
||||
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
||||
*/
|
||||
readonly aborted: boolean;
|
||||
}
|
||||
|
||||
declare var AbortController: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T}
|
||||
? T
|
||||
: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
|
||||
declare var AbortSignal: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
abort(reason?: any): AbortSignal;
|
||||
timeout(milliseconds: number): AbortSignal;
|
||||
};
|
||||
declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal: infer T}
|
||||
? T
|
||||
: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
abort(reason?: any): AbortSignal;
|
||||
timeout(milliseconds: number): AbortSignal;
|
||||
};
|
||||
//#endregion borrowed
|
||||
|
||||
//#region ArrayLike.at()
|
||||
@ -105,6 +109,16 @@ interface BigInt64Array extends RelativeIndexable<bigint> {}
|
||||
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
||||
//#endregion ArrayLike.at() end
|
||||
|
||||
/**
|
||||
* @since v17.0.0
|
||||
*
|
||||
* Creates a deep clone of an object.
|
||||
*/
|
||||
declare function structuredClone<T>(
|
||||
value: T,
|
||||
transfer?: { transfer: ReadonlyArray<import('worker_threads').TransferListItem> },
|
||||
): T;
|
||||
|
||||
/*----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
@ -210,9 +224,9 @@ declare namespace NodeJS {
|
||||
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): void;
|
||||
end(data: string | Uint8Array, cb?: () => void): void;
|
||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
|
||||
end(cb?: () => void): this;
|
||||
end(data: string | Uint8Array, cb?: () => void): this;
|
||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||
}
|
||||
|
||||
interface ReadWriteStream extends ReadableStream, WritableStream { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* To use the HTTP server and client one must `require('http')`.
|
||||
@ -16,7 +16,7 @@
|
||||
* { 'content-length': '123',
|
||||
* 'content-type': 'text/plain',
|
||||
* 'connection': 'keep-alive',
|
||||
* 'host': 'mysite.com',
|
||||
* 'host': 'example.com',
|
||||
* 'accept': '*' }
|
||||
* ```
|
||||
*
|
||||
@ -37,10 +37,10 @@
|
||||
* 'content-LENGTH', '123',
|
||||
* 'content-type', 'text/plain',
|
||||
* 'CONNECTION', 'keep-alive',
|
||||
* 'Host', 'mysite.com',
|
||||
* 'Host', 'example.com',
|
||||
* 'accepT', '*' ]
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/http.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js)
|
||||
*/
|
||||
declare module 'http' {
|
||||
import * as stream from 'node:stream';
|
||||
@ -244,14 +244,12 @@ declare module 'http' {
|
||||
* Limit the amount of time the parser will wait to receive the complete HTTP
|
||||
* headers.
|
||||
*
|
||||
* In case of inactivity, the rules defined in `server.timeout` apply. However,
|
||||
* that inactivity based timeout would still allow the connection to be kept open
|
||||
* if the headers are being sent very slowly (by default, up to a byte per 2
|
||||
* minutes). In order to prevent this, whenever header data arrives an additional
|
||||
* check is made that more than `server.headersTimeout` milliseconds has not
|
||||
* passed since the connection was established. If the check fails, a `'timeout'`event is emitted on the server object, and (by default) the socket is destroyed.
|
||||
* See `server.timeout` for more information on how timeout behavior can be
|
||||
* customized.
|
||||
* If the timeout expires, the server responds with status 408 without
|
||||
* forwarding the request to the request listener and then closes the connection.
|
||||
*
|
||||
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
||||
* potential Denial-of-Service attacks in case the server is deployed without a
|
||||
* reverse proxy in front.
|
||||
* @since v11.3.0, v10.14.0
|
||||
*/
|
||||
headersTimeout: number;
|
||||
@ -284,6 +282,16 @@ declare module 'http' {
|
||||
* @since v14.11.0
|
||||
*/
|
||||
requestTimeout: number;
|
||||
/**
|
||||
* 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: 'close', listener: () => void): this;
|
||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
@ -410,7 +418,7 @@ declare module 'http' {
|
||||
/**
|
||||
* Aliases of `outgoingMessage.socket`
|
||||
* @since v0.3.0
|
||||
* @deprecated Since v15.12.0 - Use `socket` instead.
|
||||
* @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
|
||||
*/
|
||||
readonly connection: Socket | null;
|
||||
/**
|
||||
@ -461,13 +469,13 @@ declare module 'http' {
|
||||
* const headers = outgoingMessage.getHeaders();
|
||||
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
* @since v7.7.0
|
||||
*/
|
||||
getHeaders(): OutgoingHttpHeaders;
|
||||
/**
|
||||
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
||||
* names are lowercase.
|
||||
* @since v8.0.0
|
||||
* @since v7.7.0
|
||||
*/
|
||||
getHeaderNames(): string[];
|
||||
/**
|
||||
@ -477,7 +485,7 @@ declare module 'http' {
|
||||
* ```js
|
||||
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
* @since v7.7.0
|
||||
*/
|
||||
hasHeader(name: string): boolean;
|
||||
/**
|
||||
@ -487,6 +495,7 @@ declare module 'http' {
|
||||
* outgoingMessage.removeHeader('Content-Encoding');
|
||||
* ```
|
||||
* @since v0.4.0
|
||||
* @param name Header name
|
||||
*/
|
||||
removeHeader(name: string): void;
|
||||
/**
|
||||
@ -564,11 +573,46 @@ declare module 'http' {
|
||||
assignSocket(socket: Socket): void;
|
||||
detachSocket(socket: Socket): void;
|
||||
/**
|
||||
* Sends a HTTP/1.1 100 Continue message to the client, indicating that
|
||||
* Sends an HTTP/1.1 100 Continue message to the client, indicating that
|
||||
* the request body should be sent. See the `'checkContinue'` event on`Server`.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
writeContinue(callback?: () => void): void;
|
||||
/**
|
||||
* Sends an HTTP/1.1 103 Early Hints message to the client with a Link header,
|
||||
* indicating that the user agent can preload/preconnect the linked resources.
|
||||
* The `hints` is an object containing the values of headers to be sent with
|
||||
* early hints message. The optional `callback` argument will be called when
|
||||
* the response message has been written.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const earlyHintsLink = '</styles.css>; rel=preload; as=style';
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLink,
|
||||
* });
|
||||
*
|
||||
* const earlyHintsLinks = [
|
||||
* '</styles.css>; rel=preload; as=style',
|
||||
* '</scripts.js>; rel=preload; as=script',
|
||||
* ];
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks,
|
||||
* 'x-trace-id': 'id for diagnostics'
|
||||
* });
|
||||
*
|
||||
* const earlyHintsCallback = () => console.log('early hints message sent');
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks
|
||||
* }, earlyHintsCallback);
|
||||
* ```
|
||||
*
|
||||
* @since v18.11.0
|
||||
* @param hints An object containing the values of headers
|
||||
* @param callback Will be called when the response message has been written
|
||||
*/
|
||||
writeEarlyHints(hints: Record<string, string | string[]>, callback?: () => void): void;
|
||||
/**
|
||||
* Sends a response header to the request. The status code is a 3-digit HTTP
|
||||
* status code, like `404`. The last argument, `headers`, are the response headers.
|
||||
@ -633,7 +677,7 @@ declare module 'http' {
|
||||
): this;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
|
||||
/**
|
||||
* Sends a HTTP/1.1 102 Processing message to the client, indicating that
|
||||
* Sends an HTTP/1.1 102 Processing message to the client, indicating that
|
||||
* the request body should be sent.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
@ -681,6 +725,7 @@ declare module 'http' {
|
||||
* The `request.aborted` property will be `true` if the request has
|
||||
* been aborted.
|
||||
* @since v0.11.14
|
||||
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
||||
*/
|
||||
aborted: boolean;
|
||||
/**
|
||||
@ -694,13 +739,58 @@ declare module 'http' {
|
||||
*/
|
||||
protocol: string;
|
||||
/**
|
||||
* Whether the request is send through a reused socket.
|
||||
* When sending request through a keep-alive enabled agent, the underlying socket
|
||||
* might be reused. But if server closes connection at unfortunate time, client
|
||||
* may run into a 'ECONNRESET' error.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('http');
|
||||
*
|
||||
* // Server has a 5 seconds keep-alive timeout by default
|
||||
* http
|
||||
* .createServer((req, res) => {
|
||||
* res.write('hello\n');
|
||||
* res.end();
|
||||
* })
|
||||
* .listen(3000);
|
||||
*
|
||||
* setInterval(() => {
|
||||
* // Adapting a keep-alive agent
|
||||
* http.get('http://localhost:3000', { agent }, (res) => {
|
||||
* res.on('data', (data) => {
|
||||
* // Do nothing
|
||||
* });
|
||||
* });
|
||||
* }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
|
||||
* ```
|
||||
*
|
||||
* By marking a request whether it reused socket or not, we can do
|
||||
* automatic error retry base on it.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('http');
|
||||
* const agent = new http.Agent({ keepAlive: true });
|
||||
*
|
||||
* function retriableRequest() {
|
||||
* const req = http
|
||||
* .get('http://localhost:3000', { agent }, (res) => {
|
||||
* // ...
|
||||
* })
|
||||
* .on('error', (err) => {
|
||||
* // Check if retry is needed
|
||||
* if (req.reusedSocket && err.code === 'ECONNRESET') {
|
||||
* retriableRequest();
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* retriableRequest();
|
||||
* ```
|
||||
* @since v13.0.0, v12.16.0
|
||||
*/
|
||||
reusedSocket: boolean;
|
||||
/**
|
||||
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
||||
* @default 2000
|
||||
*/
|
||||
maxHeadersCount: number;
|
||||
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
||||
@ -750,9 +840,12 @@ declare module 'http' {
|
||||
* const headerNames = request.getRawHeaderNames();
|
||||
* // headerNames === ['Foo', 'Set-Cookie']
|
||||
* ```
|
||||
* @since v15.13.0
|
||||
* @since v15.13.0, v14.17.0
|
||||
*/
|
||||
getRawHeaderNames(): string[];
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
addListener(event: 'abort', listener: () => void): this;
|
||||
addListener(
|
||||
event: 'connect',
|
||||
@ -774,6 +867,9 @@ declare module 'http' {
|
||||
addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
on(event: 'abort', listener: () => void): this;
|
||||
on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
||||
on(event: 'continue', listener: () => void): this;
|
||||
@ -789,6 +885,9 @@ declare module 'http' {
|
||||
on(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||
on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
once(event: 'abort', listener: () => void): this;
|
||||
once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
||||
once(event: 'continue', listener: () => void): this;
|
||||
@ -804,6 +903,9 @@ declare module 'http' {
|
||||
once(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||
once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
prependListener(event: 'abort', listener: () => void): this;
|
||||
prependListener(
|
||||
event: 'connect',
|
||||
@ -825,6 +927,9 @@ declare module 'http' {
|
||||
prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
prependOnceListener(event: 'abort', listener: () => void): this;
|
||||
prependOnceListener(
|
||||
event: 'connect',
|
||||
@ -863,6 +968,7 @@ declare module 'http' {
|
||||
* The `message.aborted` property will be `true` if the request has
|
||||
* been aborted.
|
||||
* @since v10.1.0
|
||||
* @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
|
||||
*/
|
||||
aborted: boolean;
|
||||
/**
|
||||
@ -914,7 +1020,7 @@ declare module 'http' {
|
||||
*
|
||||
* This property is guaranteed to be an instance of the `net.Socket` class,
|
||||
* a subclass of `stream.Duplex`, unless the user specified a socket
|
||||
* type other than `net.Socket`.
|
||||
* type other than `net.Socket` or internally nulled.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
socket: Socket;
|
||||
@ -929,7 +1035,7 @@ declare module 'http' {
|
||||
* // { 'user-agent': 'curl/7.22.0',
|
||||
* // host: '127.0.0.1:8000',
|
||||
* // accept: '*' }
|
||||
* console.log(request.headers);
|
||||
* console.log(request.getHeaders());
|
||||
* ```
|
||||
*
|
||||
* Duplicates in raw headers are handled in the following ways, depending on the
|
||||
@ -1005,14 +1111,14 @@ declare module 'http' {
|
||||
* To parse the URL into its parts:
|
||||
*
|
||||
* ```js
|
||||
* new URL(request.url, `http://${request.headers.host}`);
|
||||
* new URL(request.url, `http://${request.getHeaders().host}`);
|
||||
* ```
|
||||
*
|
||||
* When `request.url` is `'/status?name=ryan'` and`request.headers.host` is `'localhost:3000'`:
|
||||
* When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
|
||||
*
|
||||
* ```console
|
||||
* $ node
|
||||
* > new URL(request.url, `http://${request.headers.host}`)
|
||||
* > new URL(request.url, `http://${request.getHeaders().host}`)
|
||||
* URL {
|
||||
* href: 'http://localhost:3000/status?name=ryan',
|
||||
* origin: 'http://localhost:3000',
|
||||
@ -1212,11 +1318,16 @@ declare module 'http' {
|
||||
function createServer<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
>(options: ServerOptions, requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: RequestListener<Request, Response>,
|
||||
): Server<Request, Response>;
|
||||
// although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
|
||||
// create interface RequestOptions would make the naming more clear to developers
|
||||
interface RequestOptions extends ClientRequestArgs {}
|
||||
/**
|
||||
* `options` in `socket.connect()` are also supported.
|
||||
*
|
||||
* Node.js maintains several connections per server to make HTTP requests.
|
||||
* This function allows one to transparently issue requests.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. It
|
||||
@ -9,7 +9,7 @@
|
||||
* const http2 = require('http2');
|
||||
* ```
|
||||
* @since v8.4.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/http2.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http2.js)
|
||||
*/
|
||||
declare module 'http2' {
|
||||
import EventEmitter = require('node:events');
|
||||
@ -86,7 +86,7 @@ declare module 'http2' {
|
||||
*/
|
||||
readonly destroyed: boolean;
|
||||
/**
|
||||
* Set the `true` if the `END_STREAM` flag was set in the request or response
|
||||
* Set to `true` if the `END_STREAM` flag was set in the request or response
|
||||
* HEADERS frame received, indicating that no additional data should be received
|
||||
* and the readable side of the `Http2Stream` will be closed.
|
||||
* @since v10.11.0
|
||||
@ -761,7 +761,7 @@ declare module 'http2' {
|
||||
* session.setLocalWindowSize(expectedWindowSize);
|
||||
* });
|
||||
* ```
|
||||
* @since v15.3.0
|
||||
* @since v15.3.0, v14.18.0
|
||||
*/
|
||||
setLocalWindowSize(windowSize: number): void;
|
||||
/**
|
||||
@ -849,6 +849,11 @@ declare module 'http2' {
|
||||
* For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
|
||||
* HTTP/2 request to the connected server.
|
||||
*
|
||||
* When a `ClientHttp2Session` is first created, the socket may not yet be
|
||||
* connected. if `clienthttp2session.request()` is called during this time, the
|
||||
* actual request will be deferred until the socket is ready to go.
|
||||
* If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown.
|
||||
*
|
||||
* This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
|
||||
*
|
||||
* ```js
|
||||
@ -1640,7 +1645,7 @@ declare module 'http2' {
|
||||
* be called multiple times to provide successive parts of the body.
|
||||
*
|
||||
* In the `http` module, the response body is omitted when the
|
||||
* request is a HEAD request. Similarly, the `204` and `304` responses_must not_ include a message body.
|
||||
* request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body.
|
||||
*
|
||||
* `chunk` can be a string or a buffer. If `chunk` is a string,
|
||||
* the second parameter specifies how to encode it into a byte stream.
|
||||
@ -1668,6 +1673,34 @@ declare module 'http2' {
|
||||
* @since v8.4.0
|
||||
*/
|
||||
writeContinue(): void;
|
||||
/**
|
||||
* Sends a status `103 Early Hints` to the client with a Link header,
|
||||
* indicating that the user agent can preload/preconnect the linked resources.
|
||||
* The `hints` is an object containing the values of headers to be sent with
|
||||
* early hints message.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const earlyHintsLink = '</styles.css>; rel=preload; as=style';
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLink,
|
||||
* });
|
||||
*
|
||||
* const earlyHintsLinks = [
|
||||
* '</styles.css>; rel=preload; as=style',
|
||||
* '</scripts.js>; rel=preload; as=script',
|
||||
* ];
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks,
|
||||
* 'x-trace-id': 'id for diagnostics'
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @since v18.11.0
|
||||
* @param hints An object containing the values of headers
|
||||
*/
|
||||
writeEarlyHints(hints: Record<string, string | string[]>): void;
|
||||
/**
|
||||
* Sends a response header to the request. The status code is a 3-digit HTTP
|
||||
* status code, like `404`. The last argument, `headers`, are the response headers.
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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/v16.9.0/lib/https.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js)
|
||||
*/
|
||||
declare module 'https' {
|
||||
import { Duplex } from 'node:stream';
|
||||
@ -17,7 +17,6 @@ declare module 'https' {
|
||||
> = 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
|
||||
};
|
||||
@ -50,6 +49,16 @@ declare module 'https' {
|
||||
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(
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* @since v0.3.7
|
||||
@ -88,7 +88,6 @@ declare module 'module' {
|
||||
static wrap(code: string): string;
|
||||
static createRequire(path: string | URL): NodeRequire;
|
||||
static builtinModules: string[];
|
||||
static isBuiltin(moduleName: string): boolean;
|
||||
static Module: typeof Module;
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* > Stability: 2 - Stable
|
||||
@ -13,7 +13,7 @@
|
||||
* ```js
|
||||
* const net = require('net');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/net.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js)
|
||||
*/
|
||||
declare module 'net' {
|
||||
import * as stream from 'node:stream';
|
||||
@ -134,6 +134,17 @@ declare module 'net' {
|
||||
* @return The socket itself.
|
||||
*/
|
||||
pause(): this;
|
||||
/**
|
||||
* Close the TCP connection by sending an RST packet and destroy the stream.
|
||||
* If this TCP socket is in connecting status, it will send an RST packet
|
||||
* and destroy this TCP socket once it is connected. Otherwise, it will call
|
||||
* `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket
|
||||
* (for example, a pipe), calling this method will immediately throw
|
||||
* an `ERR_INVALID_HANDLE_TYPE` Error.
|
||||
* @since v18.3.0
|
||||
* @return The socket itself.
|
||||
*/
|
||||
resetAndDestroy(): this;
|
||||
/**
|
||||
* Resumes reading after a call to `socket.pause()`.
|
||||
* @return The socket itself.
|
||||
@ -211,7 +222,7 @@ declare module 'net' {
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will_not_ let the program exit if it's the only socket left (the default behavior).
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior).
|
||||
* If the socket is `ref`ed calling `ref` again will have no effect.
|
||||
* @since v0.9.1
|
||||
* @return The socket itself.
|
||||
@ -271,15 +282,9 @@ declare module 'net' {
|
||||
readonly localPort?: number;
|
||||
/**
|
||||
* The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @since v18.8.0
|
||||
*/
|
||||
readonly localFamily?: string;
|
||||
/**
|
||||
* This is `true` if the socket is not connected yet, either because `.connect()`
|
||||
* has not yet been called or because it is still in the process of connecting (see `socket.connecting`).
|
||||
* @since v10.16.0
|
||||
*/
|
||||
readonly pending: boolean;
|
||||
/**
|
||||
* This property represents the state of the connection as a string.
|
||||
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
||||
@ -329,7 +334,8 @@ declare module 'net' {
|
||||
* 5. end
|
||||
* 6. error
|
||||
* 7. lookup
|
||||
* 8. timeout
|
||||
* 8. ready
|
||||
* 9. timeout
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
@ -436,6 +442,14 @@ declare module 'net' {
|
||||
*/
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
}
|
||||
interface DropArgument {
|
||||
localAddress?: string;
|
||||
localPort?: number;
|
||||
localFamily?: string;
|
||||
remoteAddress?: string;
|
||||
remotePort?: number;
|
||||
remoteFamily?: string;
|
||||
}
|
||||
/**
|
||||
* This class is used to create a TCP or `IPC` server.
|
||||
* @since v0.1.90
|
||||
@ -540,7 +554,7 @@ declare module 'net' {
|
||||
*/
|
||||
getConnections(cb: (error: Error | null, count: number) => void): void;
|
||||
/**
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will_not_ let the program exit if it's the only server left (the default behavior).
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior).
|
||||
* If the server is `ref`ed calling `ref()` again will have no effect.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
@ -572,49 +586,56 @@ declare module 'net' {
|
||||
* 2. connection
|
||||
* 3. error
|
||||
* 4. listening
|
||||
* 5. drop
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'listening', listener: () => void): this;
|
||||
addListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connection', socket: Socket): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'drop', data?: DropArgument): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'listening', listener: () => void): this;
|
||||
on(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'listening', listener: () => void): this;
|
||||
once(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'listening', listener: () => void): this;
|
||||
prependListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||
prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
}
|
||||
type IPVersion = 'ipv4' | 'ipv6';
|
||||
/**
|
||||
* The `BlockList` object can be used with some network APIs to specify rules for
|
||||
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
||||
* IP subnets.
|
||||
* @since v15.0.0
|
||||
* @since v15.0.0, v14.18.0
|
||||
*/
|
||||
class BlockList {
|
||||
/**
|
||||
* Adds a rule to block the given IP address.
|
||||
* @since v15.0.0
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param address An IPv4 or IPv6 address.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
@ -622,7 +643,7 @@ declare module 'net' {
|
||||
addAddress(address: SocketAddress): void;
|
||||
/**
|
||||
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
||||
* @since v15.0.0
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param start The starting IPv4 or IPv6 address in the range.
|
||||
* @param end The ending IPv4 or IPv6 address in the range.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
@ -631,7 +652,7 @@ declare module 'net' {
|
||||
addRange(start: SocketAddress, end: SocketAddress): void;
|
||||
/**
|
||||
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
||||
* @since v15.0.0
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param net The network IPv4 or IPv6 address.
|
||||
* @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
@ -655,7 +676,7 @@ declare module 'net' {
|
||||
* console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
|
||||
* console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
|
||||
* ```
|
||||
* @since v15.0.0
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param address The IP address to check
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
@ -686,7 +707,7 @@ declare module 'net' {
|
||||
*
|
||||
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
||||
*
|
||||
* Here is an example of an TCP echo server which listens for connections
|
||||
* Here is an example of a TCP echo server which listens for connections
|
||||
* on port 8124:
|
||||
*
|
||||
* ```js
|
||||
@ -765,19 +786,39 @@ declare module 'net' {
|
||||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||
/**
|
||||
* Tests if input is an IP address. Returns `0` for invalid strings,
|
||||
* returns `4` for IP version 4 addresses, and returns `6` for IP version 6
|
||||
* addresses.
|
||||
* Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
|
||||
* address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIP('::1'); // returns 6
|
||||
* net.isIP('127.0.0.1'); // returns 4
|
||||
* net.isIP('127.000.000.001'); // returns 0
|
||||
* net.isIP('127.0.0.1/24'); // returns 0
|
||||
* net.isIP('fhqwhgads'); // returns 0
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIP(input: string): number;
|
||||
/**
|
||||
* Returns `true` if input is a version 4 IP address, otherwise returns `false`.
|
||||
* Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
|
||||
* leading zeroes. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv4('127.0.0.1'); // returns true
|
||||
* net.isIPv4('127.000.000.001'); // returns false
|
||||
* net.isIPv4('127.0.0.1/24'); // returns false
|
||||
* net.isIPv4('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIPv4(input: string): boolean;
|
||||
/**
|
||||
* Returns `true` if input is a version 6 IP address, otherwise returns `false`.
|
||||
* Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv6('::1'); // returns true
|
||||
* net.isIPv6('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIPv6(input: string): boolean;
|
||||
@ -803,25 +844,25 @@ declare module 'net' {
|
||||
port?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* @since v15.14.0
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
class SocketAddress {
|
||||
constructor(options: SocketAddressInitOptions);
|
||||
/**
|
||||
* @since v15.14.0
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly address: string;
|
||||
/**
|
||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
||||
* @since v15.14.0
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly family: IPVersion;
|
||||
/**
|
||||
* @since v15.14.0
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly port: number;
|
||||
/**
|
||||
* @since v15.14.0
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly flowlabel: number;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `os` module provides operating system-related utility methods and
|
||||
@ -8,7 +8,7 @@
|
||||
* ```js
|
||||
* const os = require('os');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/os.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js)
|
||||
*/
|
||||
declare module 'os' {
|
||||
interface CpuInfo {
|
||||
@ -31,6 +31,7 @@ declare module 'os' {
|
||||
}
|
||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||
family: 'IPv4';
|
||||
scopeid?: undefined;
|
||||
}
|
||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||
family: 'IPv6';
|
||||
@ -390,7 +391,7 @@ declare module 'os' {
|
||||
const EOL: string;
|
||||
/**
|
||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* The return value is equivalent to `process.arch`.
|
||||
* @since v0.5.0
|
||||
@ -405,8 +406,9 @@ declare module 'os' {
|
||||
*/
|
||||
function version(): string;
|
||||
/**
|
||||
* Returns a string identifying the operating system platform. The value is set
|
||||
* at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
||||
* 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`.
|
||||
*
|
||||
@ -415,6 +417,15 @@ declare module 'os' {
|
||||
* @since v0.5.0
|
||||
*/
|
||||
function platform(): NodeJS.Platform;
|
||||
/**
|
||||
* Returns the machine type as a string, such as arm, 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
|
||||
*/
|
||||
function machine(): string;
|
||||
/**
|
||||
* Returns the operating system's default directory for temporary files as a
|
||||
* string.
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'path/posix' {
|
||||
import path = require('path');
|
||||
@ -16,7 +16,7 @@ declare module 'path/win32' {
|
||||
* ```js
|
||||
* const path = require('path');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/path.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/path.js)
|
||||
*/
|
||||
declare module 'path' {
|
||||
namespace path {
|
||||
@ -93,7 +93,7 @@ declare module 'path' {
|
||||
* 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 string paths to join.
|
||||
* @param paths A sequence of paths or path segments.
|
||||
* @throws {TypeError} if any of the arguments is not a string.
|
||||
*/
|
||||
resolve(...paths: string[]): string;
|
||||
@ -125,10 +125,10 @@ declare module 'path' {
|
||||
* Often used to extract the file name from a fully qualified path.
|
||||
*
|
||||
* @param path the path to evaluate.
|
||||
* @param ext optionally, an extension to remove from the result.
|
||||
* @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, ext?: string): 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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -29,7 +29,7 @@
|
||||
* performance.measure('A to B', 'A', 'B');
|
||||
* });
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/perf_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/perf_hooks.js)
|
||||
*/
|
||||
declare module 'perf_hooks' {
|
||||
import { AsyncResource } from 'node:async_hooks';
|
||||
@ -88,6 +88,14 @@ declare module 'perf_hooks' {
|
||||
* @since v16.0.0
|
||||
*/
|
||||
readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
||||
toJSON(): any;
|
||||
}
|
||||
class PerformanceMark extends PerformanceEntry {
|
||||
readonly duration: 0;
|
||||
readonly entryType: 'mark';
|
||||
}
|
||||
class PerformanceMeasure extends PerformanceEntry {
|
||||
readonly entryType: 'measure';
|
||||
}
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
@ -229,8 +237,9 @@ declare module 'perf_hooks' {
|
||||
* and whose performanceEntry.duration is always 0.
|
||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||
* @param name
|
||||
* @return The PerformanceMark entry that was created
|
||||
*/
|
||||
mark(name?: string, options?: MarkOptions): void;
|
||||
mark(name?: string, options?: MarkOptions): PerformanceMark;
|
||||
/**
|
||||
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||
@ -245,9 +254,10 @@ declare module 'perf_hooks' {
|
||||
* @param name
|
||||
* @param startMark
|
||||
* @param endMark
|
||||
* @return The PerformanceMeasure entry that was created
|
||||
*/
|
||||
measure(name: string, startMark?: string, endMark?: string): void;
|
||||
measure(name: string, options: MeasureOptions): void;
|
||||
measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure;
|
||||
measure(name: string, options: MeasureOptions): PerformanceMeasure;
|
||||
/**
|
||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
||||
*/
|
||||
@ -302,6 +312,9 @@ declare module 'perf_hooks' {
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
@ -349,6 +362,9 @@ declare module 'perf_hooks' {
|
||||
* * ]
|
||||
*
|
||||
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
||||
@ -387,6 +403,8 @@ declare module 'perf_hooks' {
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
@ -416,7 +434,7 @@ declare module 'perf_hooks' {
|
||||
* } = require('perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((list, observer) => {
|
||||
* // Called three times synchronously. `list` contains one item.
|
||||
* // Called once asynchronously. `list` contains three items.
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
*
|
||||
@ -519,7 +537,7 @@ declare module 'perf_hooks' {
|
||||
}
|
||||
interface RecordableHistogram extends Histogram {
|
||||
/**
|
||||
* @since v15.9.0
|
||||
* @since v15.9.0, v14.18.0
|
||||
* @param val The amount to record in the histogram.
|
||||
*/
|
||||
record(val: number | bigint): void;
|
||||
@ -528,9 +546,15 @@ declare module 'perf_hooks' {
|
||||
* previous call to `recordDelta()` and records that amount in the histogram.
|
||||
*
|
||||
* ## Examples
|
||||
* @since v15.9.0
|
||||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
recordDelta(): void;
|
||||
/**
|
||||
* Adds the values from other to this histogram.
|
||||
* @since v17.4.0, v16.14.0
|
||||
* @param other Recordable Histogram to combine with
|
||||
*/
|
||||
add(other: RecordableHistogram): void;
|
||||
}
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
@ -580,9 +604,24 @@ declare module 'perf_hooks' {
|
||||
}
|
||||
/**
|
||||
* Returns a `RecordableHistogram`.
|
||||
* @since v15.9.0
|
||||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
||||
|
||||
import { performance as _performance } from 'perf_hooks';
|
||||
global {
|
||||
/**
|
||||
* `performance` is a global reference for `require('perf_hooks').performance`
|
||||
* https://nodejs.org/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';
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'process' {
|
||||
import * as tty from 'node:tty';
|
||||
@ -52,6 +52,7 @@ declare module 'process' {
|
||||
openssl: string;
|
||||
}
|
||||
type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
|
||||
type Architecture = 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x64';
|
||||
type Signals =
|
||||
| 'SIGABRT'
|
||||
| 'SIGALRM'
|
||||
@ -99,7 +100,7 @@ declare module 'process' {
|
||||
type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
|
||||
/**
|
||||
* Most of the time the unhandledRejection will be an Error, but this should not be relied upon
|
||||
* as *anything* can be thrown/rejected, it is therefore unsafe to assume the the value is an Error.
|
||||
* as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error.
|
||||
*/
|
||||
type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
|
||||
type WarningListener = (warning: Error) => void;
|
||||
@ -592,7 +593,7 @@ declare module 'process' {
|
||||
*
|
||||
* The reason this is problematic is because writes to `process.stdout` in Node.js
|
||||
* are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js
|
||||
* event loop. Calling `process.exit()`, however, forces the process to exit_before_ those additional writes to `stdout` can be performed.
|
||||
* event loop. Calling `process.exit()`, however, forces the process to exit _before_ those additional writes to `stdout` can be performed.
|
||||
*
|
||||
* Rather than calling `process.exit()` directly, the code _should_ set the`process.exitCode` and allow the process to exit naturally by avoiding
|
||||
* scheduling any additional work for the event loop:
|
||||
@ -644,7 +645,7 @@ declare module 'process' {
|
||||
* Android).
|
||||
* @since v0.1.31
|
||||
*/
|
||||
getgid(): number;
|
||||
getgid?: () => number;
|
||||
/**
|
||||
* The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a
|
||||
* numeric ID or a group name
|
||||
@ -671,7 +672,7 @@ declare module 'process' {
|
||||
* @since v0.1.31
|
||||
* @param id The group name or ID
|
||||
*/
|
||||
setgid(id: number | string): void;
|
||||
setgid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getuid()` method returns the numeric user identity of the process.
|
||||
* (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
|
||||
@ -688,7 +689,7 @@ declare module 'process' {
|
||||
* Android).
|
||||
* @since v0.1.28
|
||||
*/
|
||||
getuid(): number;
|
||||
getuid?: () => number;
|
||||
/**
|
||||
* The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a
|
||||
* numeric ID or a username string.
|
||||
@ -714,7 +715,7 @@ declare module 'process' {
|
||||
* This feature is not available in `Worker` threads.
|
||||
* @since v0.1.28
|
||||
*/
|
||||
setuid(id: number | string): void;
|
||||
setuid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.geteuid()` method returns the numerical effective user identity of
|
||||
* the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
|
||||
@ -731,7 +732,7 @@ declare module 'process' {
|
||||
* Android).
|
||||
* @since v2.0.0
|
||||
*/
|
||||
geteuid(): number;
|
||||
geteuid?: () => number;
|
||||
/**
|
||||
* The `process.seteuid()` method sets the effective user identity of the process.
|
||||
* (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username
|
||||
@ -758,7 +759,7 @@ declare module 'process' {
|
||||
* @since v2.0.0
|
||||
* @param id A user name or ID
|
||||
*/
|
||||
seteuid(id: number | string): void;
|
||||
seteuid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getegid()` method returns the numerical effective group identity
|
||||
* of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).)
|
||||
@ -775,7 +776,7 @@ declare module 'process' {
|
||||
* Android).
|
||||
* @since v2.0.0
|
||||
*/
|
||||
getegid(): number;
|
||||
getegid?: () => number;
|
||||
/**
|
||||
* The `process.setegid()` method sets the effective group identity of the process.
|
||||
* (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group
|
||||
@ -802,7 +803,7 @@ declare module 'process' {
|
||||
* @since v2.0.0
|
||||
* @param id A group name or ID
|
||||
*/
|
||||
setegid(id: number | string): void;
|
||||
setegid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getgroups()` method returns an array with the supplementary group
|
||||
* IDs. POSIX leaves it unspecified if the effective group ID is included but
|
||||
@ -820,7 +821,7 @@ declare module 'process' {
|
||||
* Android).
|
||||
* @since v0.9.4
|
||||
*/
|
||||
getgroups(): number[];
|
||||
getgroups?: () => number[];
|
||||
/**
|
||||
* The `process.setgroups()` method sets the supplementary group IDs for the
|
||||
* Node.js process. This is a privileged operation that requires the Node.js
|
||||
@ -846,7 +847,7 @@ declare module 'process' {
|
||||
* This feature is not available in `Worker` threads.
|
||||
* @since v0.9.4
|
||||
*/
|
||||
setgroups(groups: ReadonlyArray<string | number>): void;
|
||||
setgroups?: (groups: ReadonlyArray<string | number>) => void;
|
||||
/**
|
||||
* The `process.setUncaughtExceptionCaptureCallback()` function sets a function
|
||||
* that will be invoked when an uncaught exception occurs, which will receive the
|
||||
@ -1043,7 +1044,7 @@ declare module 'process' {
|
||||
title: string;
|
||||
/**
|
||||
* The operating system CPU architecture for which the Node.js binary was compiled.
|
||||
* Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
||||
* Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* ```js
|
||||
* import { arch } from 'process';
|
||||
@ -1052,10 +1053,10 @@ declare module 'process' {
|
||||
* ```
|
||||
* @since v0.5.0
|
||||
*/
|
||||
readonly arch: string;
|
||||
readonly arch: Architecture;
|
||||
/**
|
||||
* The `process.platform` property returns a string identifying the operating
|
||||
* system platform on which the Node.js process is running.
|
||||
* system platform for which the Node.js binary was compiled.
|
||||
*
|
||||
* Currently possible values are:
|
||||
*
|
||||
@ -1408,7 +1409,7 @@ declare module 'process' {
|
||||
emit(event: 'unhandledRejection', reason: unknown, promise: Promise<unknown>): boolean;
|
||||
emit(event: 'warning', warning: Error): boolean;
|
||||
emit(event: 'message', message: unknown, sendHandle: unknown): this;
|
||||
emit(event: Signals, signal: Signals): boolean;
|
||||
emit(event: Signals, signal?: Signals): boolean;
|
||||
emit(event: 'multipleResolves', type: MultipleResolveType, promise: Promise<unknown>, value: unknown): this;
|
||||
emit(event: 'worker', listener: WorkerListener): this;
|
||||
on(event: 'beforeExit', listener: BeforeExitListener): this;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `querystring` module provides utilities for parsing and formatting URL
|
||||
@ -12,7 +12,7 @@
|
||||
* `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/v16.9.0/lib/querystring.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/querystring.js)
|
||||
*/
|
||||
declare module 'querystring' {
|
||||
interface StringifyOptions {
|
||||
|
@ -1,39 +1,46 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. It can be accessed
|
||||
* using:
|
||||
* The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time.
|
||||
*
|
||||
* To use the promise-based APIs:
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('readline');
|
||||
* 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 `readline` module.
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('readline');
|
||||
* import * as readline from 'node:readline/promises';
|
||||
* import { stdin as input, stdout as output } from 'node:process';
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout
|
||||
* });
|
||||
* const rl = readline.createInterface({ input, output });
|
||||
*
|
||||
* rl.question('What do you think of Node.js? ', (answer) => {
|
||||
* // TODO: Log the answer in a database
|
||||
* console.log(`Thank you for your valuable feedback: ${answer}`);
|
||||
* const answer = await rl.question('What do you think of Node.js? ');
|
||||
*
|
||||
* rl.close();
|
||||
* });
|
||||
* 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/v16.9.0/lib/readline.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js)
|
||||
*/
|
||||
declare module 'readline' {
|
||||
import { Abortable, EventEmitter } from 'node:events';
|
||||
interface Key {
|
||||
import * as promises from 'node:readline/promises';
|
||||
|
||||
export { promises };
|
||||
export interface Key {
|
||||
sequence?: string | undefined;
|
||||
name?: string | undefined;
|
||||
ctrl?: boolean | undefined;
|
||||
@ -47,7 +54,7 @@ declare module 'readline' {
|
||||
* and is read from, the `input` stream.
|
||||
* @since v0.1.104
|
||||
*/
|
||||
class Interface extends EventEmitter {
|
||||
export class Interface extends EventEmitter {
|
||||
readonly terminal: boolean;
|
||||
/**
|
||||
* The current input data being processed by node.
|
||||
@ -314,11 +321,11 @@ declare module 'readline' {
|
||||
prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||
}
|
||||
type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||
type Completer = (line: string) => CompleterResult;
|
||||
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
||||
type CompleterResult = [string[], string];
|
||||
interface ReadLineOptions {
|
||||
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;
|
||||
@ -379,8 +386,8 @@ declare module 'readline' {
|
||||
* ```
|
||||
* @since v0.1.98
|
||||
*/
|
||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||
function createInterface(options: ReadLineOptions): Interface;
|
||||
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.
|
||||
*
|
||||
@ -397,11 +404,114 @@ declare module 'readline' {
|
||||
* 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
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const { once } = require('events');
|
||||
* const { createReadStream } = require('fs');
|
||||
* const { createInterface } = require('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
|
||||
*/
|
||||
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||
type Direction = -1 | 0 | 1;
|
||||
interface CursorPos {
|
||||
export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||
export type Direction = -1 | 0 | 1;
|
||||
export interface CursorPos {
|
||||
rows: number;
|
||||
cols: number;
|
||||
}
|
||||
@ -412,7 +522,7 @@ declare module 'readline' {
|
||||
* @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`.
|
||||
*/
|
||||
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.clearScreenDown()` method clears the given `TTY` stream from
|
||||
* the current position of the cursor down.
|
||||
@ -420,7 +530,7 @@ declare module 'readline' {
|
||||
* @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`.
|
||||
*/
|
||||
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
||||
* given `TTY` `stream`.
|
||||
@ -428,7 +538,7 @@ declare module 'readline' {
|
||||
* @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`.
|
||||
*/
|
||||
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||
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` `stream`.
|
||||
@ -539,7 +649,7 @@ declare module 'readline' {
|
||||
* @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`.
|
||||
*/
|
||||
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||
export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||
}
|
||||
declare module 'node:readline' {
|
||||
export * from 'readline';
|
||||
|
146
packages/node_modules/@node-red/editor-client/src/types/node/readline/promises.d.ts
vendored
Normal file
146
packages/node_modules/@node-red/editor-client/src/types/node/readline/promises.d.ts
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `readline/promise` module provides an API for reading lines of input from a Readable stream one line at a time.
|
||||
*
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline/promises.js)
|
||||
* @since v17.0.0
|
||||
*/
|
||||
declare module 'readline/promises' {
|
||||
import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline';
|
||||
import { Abortable } from 'node:events';
|
||||
|
||||
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 readlinePromises.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.
|
||||
*/
|
||||
question(query: string): Promise<string>;
|
||||
question(query: string, options: Abortable): Promise<string>;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
clearScreenDown(): this;
|
||||
/**
|
||||
* The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
moveCursor(dx: number, dy: number): this;
|
||||
/**
|
||||
* The `rl.rollback()` method clears the internal list of pending actions without sending it to the associated `stream`.
|
||||
*/
|
||||
rollback(): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance.
|
||||
*
|
||||
* ```js
|
||||
* const readlinePromises = require('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).
|
||||
*
|
||||
* ## Use of the `completer` function
|
||||
*
|
||||
* The `completer` function takes the current line entered by the user as an argument, and returns an `Array` with 2 entries:
|
||||
*
|
||||
* - An Array with matching entries for the completion.
|
||||
* - The substring that was used for the matching.
|
||||
*
|
||||
* For instance: `[[substr1, substr2, ...], originalsubstring]`.
|
||||
*
|
||||
* ```js
|
||||
* function completer(line) {
|
||||
* const completions = '.help .error .exit .quit .q'.split(' ');
|
||||
* const hits = completions.filter((c) => c.startsWith(line));
|
||||
* // Show all completions if none found
|
||||
* return [hits.length ? hits : completions, line];
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `completer` function can also returns a `Promise`, or be asynchronous:
|
||||
*
|
||||
* ```js
|
||||
* async function completer(linePartial) {
|
||||
* await someAsyncWork();
|
||||
* return [['123'], linePartial];
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
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';
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* A stream is an abstract interface for working with streaming data in Node.js.
|
||||
@ -17,13 +17,14 @@
|
||||
*
|
||||
* The `stream` module is useful for creating new types of stream instances. It is
|
||||
* usually not necessary to use the `stream` module to consume streams.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/stream.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/stream.js)
|
||||
*/
|
||||
declare module 'stream' {
|
||||
import { EventEmitter, Abortable } from 'node:events';
|
||||
import { Blob as NodeBlob } from 'node:buffer';
|
||||
import { Blob as NodeBlob } from "node:buffer";
|
||||
import * as streamPromises from 'node:stream/promises';
|
||||
import * as streamConsumers from 'node:stream/consumers';
|
||||
import * as streamWeb from 'node:stream/web';
|
||||
class internal extends EventEmitter {
|
||||
pipe<T extends NodeJS.WritableStream>(
|
||||
destination: T,
|
||||
@ -56,11 +57,23 @@ declare module 'stream' {
|
||||
* A utility method for creating Readable Streams out of iterators.
|
||||
*/
|
||||
static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
|
||||
/**
|
||||
* A utility method for creating a `Readable` from a web `ReadableStream`.
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
static fromWeb(readableStream: streamWeb.ReadableStream, options?: Pick<ReadableOptions, 'encoding' | 'highWaterMark' | 'objectMode' | 'signal'>): Readable;
|
||||
/**
|
||||
* Returns whether the stream has been read from or cancelled.
|
||||
* @since v16.8.0
|
||||
*/
|
||||
static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean;
|
||||
/**
|
||||
* A utility method for creating a web `ReadableStream` from a `Readable`.
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
static toWeb(streamReadable: Readable): streamWeb.ReadableStream;
|
||||
/**
|
||||
* Returns whether the stream was destroyed or errored before emitting `'end'`.
|
||||
* @since v16.8.0
|
||||
@ -75,7 +88,7 @@ declare module 'stream' {
|
||||
readable: boolean;
|
||||
/**
|
||||
* Returns whether `'data'` has been emitted.
|
||||
* @since v16.7.0
|
||||
* @since v16.7.0, v14.18.0
|
||||
* @experimental
|
||||
*/
|
||||
readonly readableDidRead: boolean;
|
||||
@ -117,13 +130,23 @@ declare module 'stream' {
|
||||
* @since v8.0.0
|
||||
*/
|
||||
destroyed: boolean;
|
||||
/**
|
||||
* Is true after 'close' has been emitted.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
readonly closed: boolean;
|
||||
/**
|
||||
* Returns error if the stream has been destroyed with an error.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
readonly errored: Error | null;
|
||||
constructor(opts?: ReadableOptions);
|
||||
_construct?(callback: (error?: Error | null) => void): void;
|
||||
_read(size: number): void;
|
||||
/**
|
||||
* The `readable.read()` method pulls some data out of the internal buffer and
|
||||
* returns it. If no data available to be read, `null` is returned. By default,
|
||||
* the data will be returned as a `Buffer` object unless an encoding has been
|
||||
* The `readable.read()` method reads data out of the internal buffer and
|
||||
* returns it. If no data is available to be read, `null` is returned. By default,
|
||||
* the data is returned as a `Buffer` object unless an encoding has been
|
||||
* specified using the `readable.setEncoding()` method or the stream is operating
|
||||
* in object mode.
|
||||
*
|
||||
@ -338,7 +361,7 @@ declare module 'stream' {
|
||||
* let chunk;
|
||||
* while (null !== (chunk = stream.read())) {
|
||||
* const str = decoder.write(chunk);
|
||||
* if (str.match(/\n\n/)) {
|
||||
* if (str.includes('\n\n')) {
|
||||
* // Found the header boundary.
|
||||
* const split = str.split(/\n\n/);
|
||||
* header += split.shift();
|
||||
@ -351,10 +374,10 @@ declare module 'stream' {
|
||||
* stream.unshift(buf);
|
||||
* // Now the body of the message can be read from the stream.
|
||||
* callback(null, header, stream);
|
||||
* } else {
|
||||
* // Still reading the header.
|
||||
* header += str;
|
||||
* return;
|
||||
* }
|
||||
* // Still reading the header.
|
||||
* header += str;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@ -500,6 +523,18 @@ declare module 'stream' {
|
||||
* @since v0.9.4
|
||||
*/
|
||||
class Writable extends Stream implements NodeJS.WritableStream {
|
||||
/**
|
||||
* A utility method for creating a `Writable` from a web `WritableStream`.
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
static fromWeb(writableStream: streamWeb.WritableStream, options?: Pick<WritableOptions, 'decodeStrings' | 'highWaterMark' | 'objectMode' | 'signal'>): Writable;
|
||||
/**
|
||||
* A utility method for creating a web `WritableStream` from a `Writable`.
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
static toWeb(streamWritable: Writable): streamWeb.WritableStream;
|
||||
/**
|
||||
* Is `true` if it is safe to call `writable.write()`, which means
|
||||
* the stream has not been destroyed, errored or ended.
|
||||
@ -545,6 +580,21 @@ declare module 'stream' {
|
||||
* @since v8.0.0
|
||||
*/
|
||||
destroyed: boolean;
|
||||
/**
|
||||
* Is true after 'close' has been emitted.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
readonly closed: boolean;
|
||||
/**
|
||||
* Returns error if the stream has been destroyed with an error.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
readonly errored: Error | null;
|
||||
/**
|
||||
* Is `true` if the stream's buffer has been full and stream will emit 'drain'.
|
||||
* @since v15.2.0, v14.17.0
|
||||
*/
|
||||
readonly writableNeedDrain: boolean;
|
||||
constructor(opts?: WritableOptions);
|
||||
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
||||
_writev?(
|
||||
@ -571,7 +621,7 @@ declare module 'stream' {
|
||||
* While a stream is not draining, calls to `write()` will buffer `chunk`, and
|
||||
* return false. Once all currently buffered chunks are drained (accepted for
|
||||
* delivery by the operating system), the `'drain'` event will be emitted.
|
||||
* It is recommended that once `write()` returns false, no more chunks be written
|
||||
* Once `write()` returns false, do not write more chunks
|
||||
* until the `'drain'` event is emitted. While calling `write()` on a stream that
|
||||
* is not draining is allowed, Node.js will buffer all written chunks until
|
||||
* maximum memory usage occurs, at which point it will abort unconditionally.
|
||||
@ -665,8 +715,8 @@ declare module 'stream' {
|
||||
* The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
|
||||
*
|
||||
* When using `writable.cork()` and `writable.uncork()` to manage the buffering
|
||||
* of writes to a stream, it is recommended that calls to `writable.uncork()` be
|
||||
* deferred using `process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event loop phase.
|
||||
* of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event
|
||||
* loop phase.
|
||||
*
|
||||
* ```js
|
||||
* stream.cork();
|
||||
@ -811,6 +861,9 @@ declare module 'stream' {
|
||||
readonly writableLength: number;
|
||||
readonly writableObjectMode: boolean;
|
||||
readonly writableCorked: number;
|
||||
readonly writableNeedDrain: boolean;
|
||||
readonly closed: boolean;
|
||||
readonly errored: Error | null;
|
||||
/**
|
||||
* If `false` then the stream will automatically end the writable side when the
|
||||
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
||||
@ -862,105 +915,6 @@ declare module 'stream' {
|
||||
end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this;
|
||||
cork(): void;
|
||||
uncork(): void;
|
||||
/**
|
||||
* Event emitter
|
||||
* The defined events on documents including:
|
||||
* 1. close
|
||||
* 2. data
|
||||
* 3. drain
|
||||
* 4. end
|
||||
* 5. error
|
||||
* 6. finish
|
||||
* 7. pause
|
||||
* 8. pipe
|
||||
* 9. readable
|
||||
* 10. resume
|
||||
* 11. unpipe
|
||||
*/
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
addListener(event: 'drain', listener: () => void): this;
|
||||
addListener(event: 'end', listener: () => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'finish', listener: () => void): this;
|
||||
addListener(event: 'pause', listener: () => void): this;
|
||||
addListener(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
addListener(event: 'readable', listener: () => void): this;
|
||||
addListener(event: 'resume', listener: () => void): this;
|
||||
addListener(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'data', chunk: any): boolean;
|
||||
emit(event: 'drain'): boolean;
|
||||
emit(event: 'end'): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'finish'): boolean;
|
||||
emit(event: 'pause'): boolean;
|
||||
emit(event: 'pipe', src: Readable): boolean;
|
||||
emit(event: 'readable'): boolean;
|
||||
emit(event: 'resume'): boolean;
|
||||
emit(event: 'unpipe', src: Readable): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'data', listener: (chunk: any) => void): this;
|
||||
on(event: 'drain', listener: () => void): this;
|
||||
on(event: 'end', listener: () => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'finish', listener: () => void): this;
|
||||
on(event: 'pause', listener: () => void): this;
|
||||
on(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
on(event: 'readable', listener: () => void): this;
|
||||
on(event: 'resume', listener: () => void): this;
|
||||
on(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'data', listener: (chunk: any) => void): this;
|
||||
once(event: 'drain', listener: () => void): this;
|
||||
once(event: 'end', listener: () => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'finish', listener: () => void): this;
|
||||
once(event: 'pause', listener: () => void): this;
|
||||
once(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
once(event: 'readable', listener: () => void): this;
|
||||
once(event: 'resume', listener: () => void): this;
|
||||
once(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
prependListener(event: 'drain', listener: () => void): this;
|
||||
prependListener(event: 'end', listener: () => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'finish', listener: () => void): this;
|
||||
prependListener(event: 'pause', listener: () => void): this;
|
||||
prependListener(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
prependListener(event: 'readable', listener: () => void): this;
|
||||
prependListener(event: 'resume', listener: () => void): this;
|
||||
prependListener(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
prependOnceListener(event: 'drain', listener: () => void): this;
|
||||
prependOnceListener(event: 'end', listener: () => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'finish', listener: () => void): this;
|
||||
prependOnceListener(event: 'pause', listener: () => void): this;
|
||||
prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
prependOnceListener(event: 'readable', listener: () => void): this;
|
||||
prependOnceListener(event: 'resume', listener: () => void): this;
|
||||
prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
removeListener(event: 'close', listener: () => void): this;
|
||||
removeListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
removeListener(event: 'drain', listener: () => void): this;
|
||||
removeListener(event: 'end', listener: () => void): this;
|
||||
removeListener(event: 'error', listener: (err: Error) => void): this;
|
||||
removeListener(event: 'finish', listener: () => void): this;
|
||||
removeListener(event: 'pause', listener: () => void): this;
|
||||
removeListener(event: 'pipe', listener: (src: Readable) => void): this;
|
||||
removeListener(event: 'readable', listener: () => void): this;
|
||||
removeListener(event: 'resume', listener: () => void): this;
|
||||
removeListener(event: 'unpipe', listener: (src: Readable) => void): this;
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
type TransformCallback = (error?: Error | null, data?: any) => void;
|
||||
interface TransformOptions extends DuplexOptions {
|
||||
@ -1209,7 +1163,7 @@ declare module 'stream' {
|
||||
* async function run() {
|
||||
* await pipeline(
|
||||
* fs.createReadStream('lowercase.txt'),
|
||||
* async function* (source, signal) {
|
||||
* async function* (source, { signal }) {
|
||||
* source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
|
||||
* for await (const chunk of source) {
|
||||
* yield await processChunk(chunk, { signal });
|
||||
@ -1233,7 +1187,7 @@ declare module 'stream' {
|
||||
*
|
||||
* async function run() {
|
||||
* await pipeline(
|
||||
* async function * (signal) {
|
||||
* async function* ({ signal }) {
|
||||
* await someLongRunningfn({ signal });
|
||||
* yield 'asd';
|
||||
* },
|
||||
@ -1252,7 +1206,31 @@ declare module 'stream' {
|
||||
*
|
||||
* `stream.pipeline()` leaves dangling event listeners on the streams
|
||||
* after the `callback` has been invoked. In the case of reuse of streams after
|
||||
* failure, this can cause event listener leaks and swallowed errors.
|
||||
* failure, this can cause event listener leaks and swallowed errors. If the last
|
||||
* stream is readable, dangling event listeners will be removed so that the last
|
||||
* stream can be consumed later.
|
||||
*
|
||||
* `stream.pipeline()` closes all the streams when an error is raised.
|
||||
* The `IncomingRequest` usage with `pipeline` could lead to an unexpected behavior
|
||||
* once it would destroy the socket without sending the expected response.
|
||||
* See the example below:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const http = require('http');
|
||||
* const { pipeline } = require('stream');
|
||||
*
|
||||
* const server = http.createServer((req, res) => {
|
||||
* const fileStream = fs.createReadStream('./fileNotExist.txt');
|
||||
* pipeline(fileStream, res, (err) => {
|
||||
* if (err) {
|
||||
* console.log(err); // No such file
|
||||
* // this message can't be sent once `pipeline` already destroyed the socket
|
||||
* return res.end('error!!!');
|
||||
* }
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @param callback Called when the pipeline is fully done.
|
||||
*/
|
||||
@ -1344,13 +1322,13 @@ declare module 'stream' {
|
||||
|
||||
/**
|
||||
* Returns whether the stream has encountered an error.
|
||||
* @since v16.14.0
|
||||
* @since v17.3.0
|
||||
*/
|
||||
function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the stream is readable.
|
||||
* @since v16.14.0
|
||||
* @since v17.4.0
|
||||
*/
|
||||
function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'stream/consumers' {
|
||||
import { Readable } from 'node:stream';
|
||||
import { Blob as NodeBlob } from "node:buffer";
|
||||
import { Readable } from 'node:stream';
|
||||
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
||||
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
||||
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<ArrayBuffer>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'stream/promises' {
|
||||
import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream';
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
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>;
|
||||
/**
|
||||
@ -18,7 +17,6 @@ declare module 'stream/web' {
|
||||
*/
|
||||
writable: WritableStream<W>;
|
||||
}
|
||||
|
||||
interface StreamPipeOptions {
|
||||
preventAbort?: boolean;
|
||||
preventCancel?: boolean;
|
||||
@ -66,70 +64,53 @@ declare module 'stream/web' {
|
||||
preventClose?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
interface ReadableStreamGenericReader {
|
||||
readonly closed: Promise<undefined>;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
}
|
||||
|
||||
interface ReadableStreamDefaultReadValueResult<T> {
|
||||
done: false;
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface ReadableStreamDefaultReadDoneResult {
|
||||
done: true;
|
||||
value?: undefined;
|
||||
}
|
||||
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||
type ReadableStreamDefaultReadResult<T> =
|
||||
| ReadableStreamDefaultReadValueResult<T>
|
||||
| ReadableStreamDefaultReadDoneResult;
|
||||
|
||||
type ReadableStreamDefaultReadResult<T> = ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult;
|
||||
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;
|
||||
@ -137,14 +118,12 @@ declare module 'stream/web' {
|
||||
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;
|
||||
@ -152,11 +131,9 @@ declare module 'stream/web' {
|
||||
type?: undefined;
|
||||
write?: UnderlyingSinkWriteCallback<W>;
|
||||
}
|
||||
|
||||
interface ReadableStreamErrorCallback {
|
||||
(reason: any): void | PromiseLike<void>;
|
||||
}
|
||||
|
||||
/** This Streams API interface represents a readable stream of byte data. */
|
||||
interface ReadableStream<R = any> {
|
||||
readonly locked: boolean;
|
||||
@ -168,29 +145,21 @@ declare module 'stream/web' {
|
||||
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
||||
}
|
||||
|
||||
const ReadableStream: {
|
||||
prototype: ReadableStream;
|
||||
new (
|
||||
underlyingSource: UnderlyingByteSource,
|
||||
strategy?: QueuingStrategy<Uint8Array>,
|
||||
): ReadableStream<Uint8Array>;
|
||||
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
||||
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
||||
};
|
||||
|
||||
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
||||
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
||||
releaseLock(): void;
|
||||
}
|
||||
|
||||
const ReadableStreamDefaultReader: {
|
||||
prototype: ReadableStreamDefaultReader;
|
||||
new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||
};
|
||||
|
||||
const ReadableStreamBYOBReader: any;
|
||||
const ReadableStreamBYOBRequest: any;
|
||||
|
||||
interface ReadableByteStreamController {
|
||||
readonly byobRequest: undefined;
|
||||
readonly desiredSize: number | null;
|
||||
@ -198,24 +167,20 @@ declare module 'stream/web' {
|
||||
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;
|
||||
@ -223,33 +188,24 @@ declare module 'stream/web' {
|
||||
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>;
|
||||
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
|
||||
@ -261,12 +217,10 @@ declare module 'stream/web' {
|
||||
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
|
||||
@ -282,12 +236,10 @@ declare module 'stream/web' {
|
||||
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
|
||||
@ -297,21 +249,17 @@ declare module 'stream/web' {
|
||||
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
|
||||
@ -324,7 +272,6 @@ declare module 'stream/web' {
|
||||
*/
|
||||
highWaterMark: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This Streams API interface provides a built-in byte length queuing
|
||||
* strategy that can be used when constructing streams.
|
||||
@ -333,12 +280,10 @@ declare module 'stream/web' {
|
||||
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.
|
||||
@ -347,12 +292,10 @@ declare module 'stream/web' {
|
||||
readonly highWaterMark: number;
|
||||
readonly size: QueuingStrategySize;
|
||||
}
|
||||
|
||||
const CountQueuingStrategy: {
|
||||
prototype: CountQueuingStrategy;
|
||||
new (init: QueuingStrategyInit): CountQueuingStrategy;
|
||||
};
|
||||
|
||||
interface TextEncoderStream {
|
||||
/** Returns "utf-8". */
|
||||
readonly encoding: 'utf-8';
|
||||
@ -360,19 +303,15 @@ declare module 'stream/web' {
|
||||
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;
|
||||
@ -384,7 +323,6 @@ declare module 'stream/web' {
|
||||
readonly writable: WritableStream<BufferSource>;
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
const TextDecoderStream: {
|
||||
prototype: TextDecoderStream;
|
||||
new (label?: string, options?: TextDecoderOptions): TextDecoderStream;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `string_decoder` module provides an API for decoding `Buffer` objects into
|
||||
@ -39,7 +39,7 @@
|
||||
* decoder.write(Buffer.from([0x82]));
|
||||
* console.log(decoder.end(Buffer.from([0xAC])));
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/string_decoder.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js)
|
||||
*/
|
||||
declare module 'string_decoder' {
|
||||
class StringDecoder {
|
||||
|
@ -1,11 +1,19 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `node:test` module provides a standalone testing module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.17.0/lib/test.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.8.0/lib/test.js)
|
||||
*/
|
||||
declare module 'node:test' {
|
||||
/**
|
||||
* Programmatically start the test runner.
|
||||
* @since v18.9.0
|
||||
* @param options Configuration options for running tests.
|
||||
* @returns A {@link TapStream} that emits events about the test execution.
|
||||
*/
|
||||
function run(options?: RunOptions): TapStream;
|
||||
|
||||
/**
|
||||
* The `test()` function is the value imported from the test module. Each invocation of this
|
||||
* function results in the creation of a test point in the TAP output.
|
||||
@ -31,7 +39,7 @@ declare module 'node:test' {
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
@ -45,8 +53,8 @@ declare module 'node:test' {
|
||||
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||
function test(fn?: TestFn): Promise<void>;
|
||||
|
||||
/*
|
||||
* @since v16.17.0
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the suite, which is displayed when reporting suite results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the suite
|
||||
@ -57,8 +65,8 @@ declare module 'node:test' {
|
||||
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
||||
function describe(fn?: SuiteFn): void;
|
||||
|
||||
/*
|
||||
* @since v16.17.0
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
@ -89,17 +97,133 @@ declare module 'node:test' {
|
||||
*/
|
||||
type ItFn = (done: (result?: any) => void) => any;
|
||||
|
||||
interface RunOptions {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
concurrency?: number | boolean;
|
||||
|
||||
/**
|
||||
* An array containing the list of files to run. If unspecified, the test runner execution model will be used.
|
||||
*/
|
||||
files?: readonly string[];
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test.
|
||||
* @default undefined
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A successful call of the run() method will return a new TapStream object, streaming a TAP output.
|
||||
* TapStream will emit events in the order of the tests' definitions.
|
||||
* @since v18.9.0
|
||||
*/
|
||||
interface TapStream extends NodeJS.ReadableStream {
|
||||
addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
emit(event: 'test:diagnostic', message: string): boolean;
|
||||
emit(event: 'test:fail', data: TestFail): boolean;
|
||||
emit(event: 'test:pass', data: TestPass): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
on(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
interface TestFail {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The failure casing test to fail.
|
||||
*/
|
||||
error: Error;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
interface TestPass {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of `TestContext` is passed to each test function in order to interact with the
|
||||
* test runner. However, the `TestContext` constructor is not exposed as part of the API.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
*/
|
||||
interface TestContext {
|
||||
/**
|
||||
* This function is used to write TAP diagnostics to the output. Any diagnostic information is
|
||||
* included at the end of the test's results. This function does not return a value.
|
||||
* @param message Message to be displayed as a TAP diagnostic.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
*/
|
||||
diagnostic(message: string): void;
|
||||
|
||||
@ -108,7 +232,7 @@ declare module 'node:test' {
|
||||
* option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
|
||||
* command-line option, this function is a no-op.
|
||||
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
*/
|
||||
runOnly(shouldRunOnlyTests: boolean): void;
|
||||
|
||||
@ -117,7 +241,7 @@ declare module 'node:test' {
|
||||
* provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
|
||||
* the test function. This function does not return a value.
|
||||
* @param message Optional skip message to be displayed in TAP output.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
*/
|
||||
skip(message?: string): void;
|
||||
|
||||
@ -126,14 +250,14 @@ declare module 'node:test' {
|
||||
* included in the TAP output. Calling `todo()` does not terminate execution of the test
|
||||
* function. This function does not return a value.
|
||||
* @param message Optional `TODO` message to be displayed in TAP output.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
*/
|
||||
todo(message?: string): void;
|
||||
|
||||
/**
|
||||
* This function is used to create subtests under the current test. This function behaves in
|
||||
* the same fashion as the top level {@link test} function.
|
||||
* @since v16.17.0
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
@ -162,7 +286,7 @@ declare module 'node:test' {
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test.
|
||||
* @since v16.17.0
|
||||
* @since v18.8.0
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
@ -177,7 +301,7 @@ declare module 'node:test' {
|
||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
* @since v16.17.0
|
||||
* @since v18.7.0
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
@ -189,5 +313,65 @@ declare module 'node:test' {
|
||||
todo?: boolean | string;
|
||||
}
|
||||
|
||||
export { test as default, test, describe, it };
|
||||
/**
|
||||
* This function is used to create a hook running before running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function before(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function after(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running before each subtest of the current suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function beforeEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after each subtest of the current test.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function afterEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* The hook function. If the hook uses callbacks, the callback function is passed as the
|
||||
* second argument.
|
||||
*/
|
||||
type HookFn = (done: (result?: any) => void) => any;
|
||||
|
||||
/**
|
||||
* Configuration options for hooks.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
interface HookOptions {
|
||||
/**
|
||||
* Allows aborting an in-progress hook.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the hook will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach };
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `timer` module exposes a global API for scheduling functions to
|
||||
@ -9,7 +9,7 @@
|
||||
* 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/v16.9.0/lib/timers.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js)
|
||||
*/
|
||||
declare module 'timers' {
|
||||
import { Abortable } from 'node:events';
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `timers/promises` API provides an alternative set of timer functions
|
||||
@ -65,31 +65,6 @@ declare module 'timers/promises' {
|
||||
* @since v15.9.0
|
||||
*/
|
||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
||||
|
||||
interface Scheduler {
|
||||
/**
|
||||
* ```js
|
||||
* import { scheduler } from 'node:timers/promises';
|
||||
*
|
||||
* await scheduler.wait(1000); // Wait one second before continuing
|
||||
* ```
|
||||
* An experimental API defined by the 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.
|
||||
* @since v16.14.0
|
||||
* @experimental
|
||||
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||
*/
|
||||
wait: (delay?: number, options?: TimerOptions) => Promise<void>;
|
||||
/**
|
||||
* An experimental API defined by the Scheduling APIs 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';
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `tls` module provides an implementation of the Transport Layer Security
|
||||
@ -9,11 +9,12 @@
|
||||
* ```js
|
||||
* const tls = require('tls');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/tls.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tls.js)
|
||||
*/
|
||||
declare module 'tls' {
|
||||
import { X509Certificate } from 'node:crypto';
|
||||
import * as net from 'node:net';
|
||||
import * as stream from 'stream';
|
||||
const CLIENT_RENEG_LIMIT: number;
|
||||
const CLIENT_RENEG_WINDOW: number;
|
||||
interface Certificate {
|
||||
@ -145,8 +146,8 @@ declare module 'tls' {
|
||||
*/
|
||||
constructor(socket: net.Socket, options?: TLSSocketOptions);
|
||||
/**
|
||||
* Returns `true` if the peer certificate was signed by one of the CAs specified
|
||||
* when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||
* This property is `true` if the peer certificate was signed by one of the CAs
|
||||
* specified when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||
* @since v0.11.4
|
||||
*/
|
||||
authorized: boolean;
|
||||
@ -345,9 +346,9 @@ declare module 'tls' {
|
||||
* When enabled, TLS packet trace information is written to `stderr`. This can be
|
||||
* used to debug TLS connection problems.
|
||||
*
|
||||
* Note: The format of the output is identical to the output of `openssl s_client -trace` or `openssl s_server -trace`. While it is produced by OpenSSL's`SSL_trace()` function, the format is
|
||||
* undocumented, can change without notice,
|
||||
* and should not be relied on.
|
||||
* The format of the output is identical to the output of`openssl s_client -trace` or `openssl s_server -trace`. While it is produced by
|
||||
* OpenSSL's `SSL_trace()` function, the format is undocumented, can change
|
||||
* without notice, and should not be relied on.
|
||||
* @since v12.2.0
|
||||
*/
|
||||
enableTrace(): void;
|
||||
@ -376,7 +377,7 @@ declare module 'tls' {
|
||||
* 128,
|
||||
* 'client finished');
|
||||
*
|
||||
*
|
||||
* /*
|
||||
* Example return value of keyingMaterial:
|
||||
* <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
|
||||
* 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
|
||||
@ -519,7 +520,7 @@ declare module 'tls' {
|
||||
host?: string | undefined;
|
||||
port?: number | undefined;
|
||||
path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
|
||||
socket?: net.Socket | undefined; // Establish secure connection on a given socket rather than creating a new socket
|
||||
socket?: stream.Duplex | undefined; // Establish secure connection on a given socket rather than creating a new socket
|
||||
checkServerIdentity?: typeof checkServerIdentity | undefined;
|
||||
servername?: string | undefined; // SNI TLS Extension
|
||||
session?: Buffer | undefined;
|
||||
@ -725,7 +726,7 @@ declare module 'tls' {
|
||||
* object.passphrase is optional. Encrypted keys will be decrypted with
|
||||
* object.passphrase if provided, or options.passphrase if it is not.
|
||||
*/
|
||||
key?: string | Buffer | Array<Buffer | KeyObject> | undefined;
|
||||
key?: string | Buffer | Array<string | Buffer | KeyObject> | undefined;
|
||||
/**
|
||||
* Name of an OpenSSL engine to get private key from. Should be used
|
||||
* together with privateKeyIdentifier.
|
||||
@ -816,13 +817,19 @@ declare module 'tls' {
|
||||
* Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on
|
||||
* failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type).
|
||||
*
|
||||
* This function can be overwritten by providing alternative function as part of
|
||||
* the `options.checkServerIdentity` option passed to `tls.connect()`. The
|
||||
* This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as
|
||||
* such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead.
|
||||
*
|
||||
* This function can be overwritten by providing an alternative function as the`options.checkServerIdentity` option that is passed to `tls.connect()`. The
|
||||
* overwriting function can call `tls.checkServerIdentity()` of course, to augment
|
||||
* the checks done with additional verification.
|
||||
*
|
||||
* This function is only called if the certificate passed all other checks, such as
|
||||
* being issued by trusted CA (`options.ca`).
|
||||
*
|
||||
* Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name
|
||||
* was present (see [CVE-2021-44531](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531)). Applications that wish to accept`uniformResourceIdentifier` subject alternative names can use
|
||||
* a custom`options.checkServerIdentity` function that implements the desired behavior.
|
||||
* @since v0.8.4
|
||||
* @param hostname The host name or IP address to verify the certificate against.
|
||||
* @param cert A `certificate object` representing the peer's certificate.
|
||||
@ -975,6 +982,8 @@ declare module 'tls' {
|
||||
* lower-case for historical reasons, but must be uppercased to be used in
|
||||
* the `ciphers` option of {@link createSecureContext}.
|
||||
*
|
||||
* Not all supported ciphers are enabled by default. See `Modifying the default TLS cipher suite`.
|
||||
*
|
||||
* Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
|
||||
* TLSv1.2 and below.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `trace_events` module provides a mechanism to centralize tracing information
|
||||
@ -69,6 +69,16 @@
|
||||
* 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,
|
||||
@ -76,7 +86,7 @@
|
||||
*
|
||||
* The features from this module are not available in `Worker` threads.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/trace_events.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/trace_events.js)
|
||||
*/
|
||||
declare module 'trace_events' {
|
||||
/**
|
||||
|
964
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/assert.d.ts
vendored
Normal file
964
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/assert.d.ts
vendored
Normal file
@ -0,0 +1,964 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js)
|
||||
*/
|
||||
declare module 'assert' {
|
||||
/**
|
||||
* An alias of {@link ok}.
|
||||
* @since v0.5.9
|
||||
* @param value The input that is checked for being truthy.
|
||||
*/
|
||||
function assert(value: unknown, message?: string | Error): asserts value;
|
||||
namespace assert {
|
||||
/**
|
||||
* Indicates the failure of an assertion. All errors thrown by the `assert` module
|
||||
* will be instances of the `AssertionError` class.
|
||||
*/
|
||||
class AssertionError extends Error {
|
||||
actual: unknown;
|
||||
expected: unknown;
|
||||
operator: string;
|
||||
generatedMessage: boolean;
|
||||
code: 'ERR_ASSERTION';
|
||||
constructor(options?: {
|
||||
/** If provided, the error message is set to this value. */
|
||||
message?: string | undefined;
|
||||
/** The `actual` property on the error instance. */
|
||||
actual?: unknown | undefined;
|
||||
/** The `expected` property on the error instance. */
|
||||
expected?: unknown | undefined;
|
||||
/** The `operator` property on the error instance. */
|
||||
operator?: string | undefined;
|
||||
/** If provided, the generated stack trace omits frames before this function. */
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function | undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* This feature is currently experimental and behavior might still change.
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @experimental
|
||||
*/
|
||||
class CallTracker {
|
||||
/**
|
||||
* The wrapper function is expected to be called exactly `exact` times. If the
|
||||
* function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
|
||||
* error.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func);
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @param [fn='A no-op function']
|
||||
* @param [exact=1]
|
||||
* @return that wraps `fn`.
|
||||
*/
|
||||
calls(exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
||||
/**
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
* const callsfunc = tracker.calls(func);
|
||||
* callsfunc(1, 2, 3);
|
||||
*
|
||||
* assert.deepStrictEqual(tracker.getCalls(callsfunc),
|
||||
* [{ thisArg: this, arguments: [1, 2, 3 ] }]);
|
||||
* ```
|
||||
*
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @params fn
|
||||
* @returns An Array with the calls to a tracked function.
|
||||
*/
|
||||
getCalls(fn: Function): CallTrackerCall[];
|
||||
/**
|
||||
* The arrays contains information about the expected and actual number of calls of
|
||||
* the functions that have not been called the expected number of times.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* function foo() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func, 2);
|
||||
*
|
||||
* // Returns an array containing information on callsfunc()
|
||||
* tracker.report();
|
||||
* // [
|
||||
* // {
|
||||
* // message: 'Expected the func function to be executed 2 time(s) but was
|
||||
* // executed 0 time(s).',
|
||||
* // actual: 0,
|
||||
* // expected: 2,
|
||||
* // operator: 'func',
|
||||
* // stack: stack trace
|
||||
* // }
|
||||
* // ]
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @return of objects containing information about the wrapper functions returned by `calls`.
|
||||
*/
|
||||
report(): CallTrackerReportInformation[];
|
||||
/**
|
||||
* Reset calls of the call tracker.
|
||||
* If a tracked function is passed as an argument, the calls will be reset for it.
|
||||
* If no arguments are passed, all tracked functions will be reset.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
* const callsfunc = tracker.calls(func);
|
||||
*
|
||||
* callsfunc();
|
||||
* // Tracker was called once
|
||||
* tracker.getCalls(callsfunc).length === 1;
|
||||
*
|
||||
* tracker.reset(callsfunc);
|
||||
* tracker.getCalls(callsfunc).length === 0;
|
||||
* ```
|
||||
*
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @param fn a tracked function to reset.
|
||||
*/
|
||||
reset(fn?: Function): void;
|
||||
/**
|
||||
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
||||
* have not been called the expected number of times.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func, 2);
|
||||
*
|
||||
* callsfunc();
|
||||
*
|
||||
* // Will throw an error since callsfunc() was only called once.
|
||||
* tracker.verify();
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
*/
|
||||
verify(): void;
|
||||
}
|
||||
interface CallTrackerCall {
|
||||
thisArg: object;
|
||||
arguments: unknown[];
|
||||
}
|
||||
interface CallTrackerReportInformation {
|
||||
message: string;
|
||||
/** The actual number of times the function was called. */
|
||||
actual: number;
|
||||
/** The number of times the function was expected to be called. */
|
||||
expected: number;
|
||||
/** The name of the function that is wrapped. */
|
||||
operator: string;
|
||||
/** A stack trace of the function. */
|
||||
stack: object;
|
||||
}
|
||||
type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
|
||||
/**
|
||||
* Throws an `AssertionError` with the provided error message or a default
|
||||
* error message. If the `message` parameter is an instance of an `Error` then
|
||||
* it will be thrown instead of the `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.fail();
|
||||
* // AssertionError [ERR_ASSERTION]: Failed
|
||||
*
|
||||
* assert.fail('boom');
|
||||
* // AssertionError [ERR_ASSERTION]: boom
|
||||
*
|
||||
* assert.fail(new TypeError('need array'));
|
||||
* // TypeError: need array
|
||||
* ```
|
||||
*
|
||||
* Using `assert.fail()` with more than two arguments is possible but deprecated.
|
||||
* See below for further details.
|
||||
* @since v0.1.21
|
||||
* @param [message='Failed']
|
||||
*/
|
||||
function fail(message?: string | Error): never;
|
||||
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
||||
function fail(
|
||||
actual: unknown,
|
||||
expected: unknown,
|
||||
message?: string | Error,
|
||||
operator?: string,
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function
|
||||
): never;
|
||||
/**
|
||||
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
||||
*
|
||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
||||
*
|
||||
* Be aware that in the `repl` the error message will be different to the one
|
||||
* thrown in a file! See below for further details.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.ok(true);
|
||||
* // OK
|
||||
* assert.ok(1);
|
||||
* // OK
|
||||
*
|
||||
* assert.ok();
|
||||
* // AssertionError: No value argument passed to `assert.ok()`
|
||||
*
|
||||
* assert.ok(false, 'it\'s false');
|
||||
* // AssertionError: it's false
|
||||
*
|
||||
* // In the repl:
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: false == true
|
||||
*
|
||||
* // In a file (e.g. test.js):
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(typeof 123 === 'string')
|
||||
*
|
||||
* assert.ok(false);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(false)
|
||||
*
|
||||
* assert.ok(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(0)
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* // Using `assert()` works the same:
|
||||
* assert(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert(0)
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function ok(value: unknown, message?: string | Error): asserts value;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link strictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
||||
* and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* assert.equal(1, 1);
|
||||
* // OK, 1 == 1
|
||||
* assert.equal(1, '1');
|
||||
* // OK, 1 == '1'
|
||||
* assert.equal(NaN, NaN);
|
||||
* // OK
|
||||
*
|
||||
* assert.equal(1, 2);
|
||||
* // AssertionError: 1 == 2
|
||||
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
||||
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
||||
* ```
|
||||
*
|
||||
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
||||
* specially handled and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* assert.notEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notEqual(1, 1);
|
||||
* // AssertionError: 1 != 1
|
||||
*
|
||||
* assert.notEqual(1, '1');
|
||||
* // AssertionError: 1 != '1'
|
||||
* ```
|
||||
*
|
||||
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
||||
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link deepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
||||
*
|
||||
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
||||
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
||||
* surprising results.
|
||||
*
|
||||
* _Deep equality_ means that the enumerable "own" properties of child objects
|
||||
* are also recursively evaluated by the following rules.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notDeepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
||||
*
|
||||
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
*
|
||||
* const obj1 = {
|
||||
* a: {
|
||||
* b: 1
|
||||
* }
|
||||
* };
|
||||
* const obj2 = {
|
||||
* a: {
|
||||
* b: 2
|
||||
* }
|
||||
* };
|
||||
* const obj3 = {
|
||||
* a: {
|
||||
* b: 1
|
||||
* }
|
||||
* };
|
||||
* const obj4 = Object.create(obj1);
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj1);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj3);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj4);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
||||
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests strict equality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.strictEqual(1, 2);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* //
|
||||
* // 1 !== 2
|
||||
*
|
||||
* assert.strictEqual(1, 1);
|
||||
* // OK
|
||||
*
|
||||
* assert.strictEqual('Hello foobar', 'Hello World!');
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* // + actual - expected
|
||||
* //
|
||||
* // + 'Hello foobar'
|
||||
* // - 'Hello World!'
|
||||
* // ^
|
||||
*
|
||||
* const apples = 1;
|
||||
* const oranges = 2;
|
||||
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
||||
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
||||
*
|
||||
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
||||
* // TypeError: Inputs are not identical
|
||||
* ```
|
||||
*
|
||||
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.notStrictEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notStrictEqual(1, 1);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
||||
* //
|
||||
* // 1
|
||||
*
|
||||
* assert.notStrictEqual(1, '1');
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests for deep equality between the `actual` and `expected` parameters.
|
||||
* "Deep" equality means that the enumerable "own" properties of child objects
|
||||
* are recursively evaluated also by the following rules.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
||||
* with a `message` property set equal to the value of the `message` parameter. If
|
||||
* the `message` parameter is undefined, a default error message is assigned. If
|
||||
* the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the function `fn` to throw an error.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* a validation object where each property will be tested for strict deep equality,
|
||||
* or an instance of error where each property will be tested for strict deep
|
||||
* equality including the non-enumerable `message` and `name` properties. When
|
||||
* using an object, it is also possible to use a regular expression, when
|
||||
* validating against a string property. See below for examples.
|
||||
*
|
||||
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
||||
* fails.
|
||||
*
|
||||
* Custom validation object/error instance:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* const err = new TypeError('Wrong value');
|
||||
* err.code = 404;
|
||||
* err.foo = 'bar';
|
||||
* err.info = {
|
||||
* nested: true,
|
||||
* baz: 'text'
|
||||
* };
|
||||
* err.reg = /abc/i;
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* baz: 'text'
|
||||
* }
|
||||
* // Only properties on the validation object will be tested for.
|
||||
* // Using nested objects requires all properties to be present. Otherwise
|
||||
* // the validation is going to fail.
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* // Using regular expressions to validate error properties:
|
||||
* throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* // The `name` and `message` properties are strings and using regular
|
||||
* // expressions on those will match against the string. If they fail, an
|
||||
* // error is thrown.
|
||||
* name: /^TypeError$/,
|
||||
* message: /Wrong/,
|
||||
* foo: 'bar',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* // It is not possible to use regular expressions for nested properties!
|
||||
* baz: 'text'
|
||||
* },
|
||||
* // The `reg` property contains a regular expression and only if the
|
||||
* // validation object contains an identical regular expression, it is going
|
||||
* // to pass.
|
||||
* reg: /abc/i
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* // Fails due to the different `message` and `name` properties:
|
||||
* throws(
|
||||
* () => {
|
||||
* const otherErr = new Error('Not found');
|
||||
* // Copy all enumerable properties from `err` to `otherErr`.
|
||||
* for (const [key, value] of Object.entries(err)) {
|
||||
* otherErr[key] = value;
|
||||
* }
|
||||
* throw otherErr;
|
||||
* },
|
||||
* // The error's `message` and `name` properties will also be checked when using
|
||||
* // an error as validation object.
|
||||
* err
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate instanceof using constructor:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* Error
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
||||
*
|
||||
* Using a regular expression runs `.toString` on the error object, and will
|
||||
* therefore also include the error name.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* /^Error: Wrong value$/
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Custom error validation:
|
||||
*
|
||||
* The function must return `true` to indicate all internal validations passed.
|
||||
* It will otherwise fail with an `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert(err instanceof Error);
|
||||
* assert(/value/.test(err));
|
||||
* // Avoid returning anything from validation functions besides `true`.
|
||||
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
||||
* // throw an error about the specific validation that failed (as done in this
|
||||
* // example) and add as much helpful debugging information to that error as
|
||||
* // possible.
|
||||
* return true;
|
||||
* },
|
||||
* 'unexpected error'
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
||||
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
||||
* a string as the second argument gets considered:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* function throwingFirst() {
|
||||
* throw new Error('First');
|
||||
* }
|
||||
*
|
||||
* function throwingSecond() {
|
||||
* throw new Error('Second');
|
||||
* }
|
||||
*
|
||||
* function notThrowing() {}
|
||||
*
|
||||
* // The second argument is a string and the input function threw an Error.
|
||||
* // The first case will not throw as it does not match for the error message
|
||||
* // thrown by the input function!
|
||||
* assert.throws(throwingFirst, 'Second');
|
||||
* // In the next example the message has no benefit over the message from the
|
||||
* // error and since it is not clear if the user intended to actually match
|
||||
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
||||
* assert.throws(throwingSecond, 'Second');
|
||||
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
||||
*
|
||||
* // The string is only used (as message) in case the function does not throw:
|
||||
* assert.throws(notThrowing, 'Second');
|
||||
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
||||
*
|
||||
* // If it was intended to match for the error message do this instead:
|
||||
* // It does not throw because the error messages match.
|
||||
* assert.throws(throwingSecond, /Second$/);
|
||||
*
|
||||
* // If the error message does not match, an AssertionError is thrown.
|
||||
* assert.throws(throwingFirst, /Second$/);
|
||||
* // AssertionError [ERR_ASSERTION]
|
||||
* ```
|
||||
*
|
||||
* Due to the confusing error-prone notation, avoid a string as the second
|
||||
* argument.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function throws(block: () => unknown, message?: string | Error): void;
|
||||
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Asserts that the function `fn` does not throw an error.
|
||||
*
|
||||
* Using `assert.doesNotThrow()` is actually not useful because there
|
||||
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
||||
* adding a comment next to the specific code path that should not throw and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
||||
*
|
||||
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
||||
* different type, or if the `error` parameter is undefined, the error is
|
||||
* propagated back to the caller.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* The following, for instance, will throw the `TypeError` because there is no
|
||||
* matching error type in the assertion:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* However, the following will result in an `AssertionError` with the message
|
||||
* 'Got unwanted exception...':
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* TypeError
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* /Wrong value/,
|
||||
* 'Whoops'
|
||||
* );
|
||||
* // Throws: AssertionError: Got unwanted exception: Whoops
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
||||
* testing the `error` argument in callbacks. The stack trace contains all frames
|
||||
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.ifError(null);
|
||||
* // OK
|
||||
* assert.ifError(0);
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
||||
* assert.ifError('error');
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
||||
* assert.ifError(new Error());
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
||||
*
|
||||
* // Create some random error frames.
|
||||
* let err;
|
||||
* (function errorFrame() {
|
||||
* err = new Error('test error');
|
||||
* })();
|
||||
*
|
||||
* (function ifErrorFrame() {
|
||||
* assert.ifError(err);
|
||||
* })();
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
||||
* // at ifErrorFrame
|
||||
* // at errorFrame
|
||||
* ```
|
||||
* @since v0.1.97
|
||||
*/
|
||||
function ifError(value: unknown): asserts value is null | undefined;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
||||
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
||||
* handler is skipped.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* an object where each property will be tested for, or an instance of error where
|
||||
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
||||
*
|
||||
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value'
|
||||
* }
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert.strictEqual(err.name, 'TypeError');
|
||||
* assert.strictEqual(err.message, 'Wrong value');
|
||||
* return true;
|
||||
* }
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.rejects(
|
||||
* Promise.reject(new Error('Wrong value')),
|
||||
* Error
|
||||
* ).then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
||||
* example in {@link throws} carefully if using a string as the second
|
||||
* argument gets considered.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is not rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
||||
* the function does not return a promise, `assert.doesNotReject()` will return a
|
||||
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
||||
* the error handler is skipped.
|
||||
*
|
||||
* Using `assert.doesNotReject()` is actually not useful because there is little
|
||||
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
||||
* adding a comment next to the specific code path that should not reject and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* await assert.doesNotReject(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
||||
* .then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
*/
|
||||
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
||||
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
||||
/**
|
||||
* Expects the `string` input to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.match('I will fail', /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
||||
*
|
||||
* assert.match(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.match('I will pass', /pass/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the `string` input not to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
*
|
||||
* assert.doesNotMatch('I will fail', /fail/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
||||
*
|
||||
* assert.doesNotMatch(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.doesNotMatch('I will pass', /different/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
|
||||
(value: unknown, message?: string | Error): asserts value;
|
||||
equal: typeof strictEqual;
|
||||
notEqual: typeof notStrictEqual;
|
||||
deepEqual: typeof deepStrictEqual;
|
||||
notDeepEqual: typeof notDeepStrictEqual;
|
||||
// Mapped types and assertion functions are incompatible?
|
||||
// TS2775: Assertions require every name in the call target
|
||||
// to be declared with an explicit type annotation.
|
||||
ok: typeof ok;
|
||||
strictEqual: typeof strictEqual;
|
||||
deepStrictEqual: typeof deepStrictEqual;
|
||||
ifError: typeof ifError;
|
||||
strict: typeof strict;
|
||||
};
|
||||
}
|
||||
export = assert;
|
||||
}
|
||||
declare module 'node:assert' {
|
||||
import assert = require('assert');
|
||||
export = assert;
|
||||
}
|
11
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/assert/strict.d.ts
vendored
Normal file
11
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/assert/strict.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
||||
declare module 'node:assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
504
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/async_hooks.d.ts
vendored
Normal file
504
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/async_hooks.d.ts
vendored
Normal file
@ -0,0 +1,504 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||
* can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* import async_hooks from 'async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js)
|
||||
*/
|
||||
declare module 'async_hooks' {
|
||||
/**
|
||||
* ```js
|
||||
* import { executionAsyncId } from 'async_hooks';
|
||||
*
|
||||
* console.log(executionAsyncId()); // 1 - bootstrap
|
||||
* 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`.
|
||||
* @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 'fs';
|
||||
* import { executionAsyncId, executionAsyncResource } from '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 'http';
|
||||
* import {
|
||||
* executionAsyncId,
|
||||
* executionAsyncResource,
|
||||
* createHook
|
||||
* } from '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`.
|
||||
* @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.
|
||||
* @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 '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 '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.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @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 & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
/**
|
||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @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 & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
/**
|
||||
* 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 `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 'http';
|
||||
* import { AsyncLocalStorage } from '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> {
|
||||
/**
|
||||
* 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, 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';
|
||||
}
|
2262
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/buffer.d.ts
vendored
Normal file
2262
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/buffer.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1372
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/child_process.d.ts
vendored
Normal file
1372
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/child_process.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
413
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/cluster.d.ts
vendored
Normal file
413
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/cluster.d.ts
vendored
Normal file
@ -0,0 +1,413 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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` 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 'cluster';
|
||||
* import http from 'http';
|
||||
* import { cpus } from 'os';
|
||||
* import process from 'process';
|
||||
*
|
||||
* const numCPUs = cpus().length;
|
||||
*
|
||||
* 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/v18.0.0/lib/cluster.js)
|
||||
*/
|
||||
declare module 'cluster' {
|
||||
import * as child from 'node:child_process';
|
||||
import EventEmitter = require('node:events');
|
||||
import * as net from 'node:net';
|
||||
export interface ClusterSettings {
|
||||
execArgv?: string[] | undefined; // default: process.execArgv
|
||||
exec?: string | undefined;
|
||||
args?: string[] | undefined;
|
||||
silent?: boolean | undefined;
|
||||
stdio?: any[] | undefined;
|
||||
uid?: number | undefined;
|
||||
gid?: number | undefined;
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
}
|
||||
export interface Address {
|
||||
address: string;
|
||||
port: number;
|
||||
addressType: number | 'udp4' | 'udp6'; // 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()`, the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
||||
*
|
||||
* See: `Child Process module`.
|
||||
*
|
||||
* 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()`.
|
||||
*
|
||||
* 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. `options` supports the following properties:
|
||||
*/
|
||||
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()`.
|
||||
* @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
|
||||
* 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 net = require('net');
|
||||
* 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 'cluster';
|
||||
* import http from 'http';
|
||||
* import { cpus } from 'os';
|
||||
* import process from 'process';
|
||||
*
|
||||
* const numCPUs = cpus().length;
|
||||
*
|
||||
* 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;
|
||||
fork(env?: any): Worker;
|
||||
/** @deprecated since v16.0.0 - use isPrimary. */
|
||||
readonly isMaster: boolean;
|
||||
readonly isPrimary: boolean;
|
||||
readonly isWorker: boolean;
|
||||
schedulingPolicy: number;
|
||||
readonly settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
||||
setupMaster(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
||||
*/
|
||||
setupPrimary(settings?: ClusterSettings): void;
|
||||
readonly worker?: Worker | undefined;
|
||||
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';
|
||||
}
|
415
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/console.d.ts
vendored
Normal file
415
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/console.d.ts
vendored
Normal file
@ -0,0 +1,415 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**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` 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/v18.0.0/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()`.
|
||||
*
|
||||
* 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 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 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()` 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()`).
|
||||
*
|
||||
* ```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()` is called on each argument and the resulting string
|
||||
* values are concatenated. See `util.format()` 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()`).
|
||||
*
|
||||
* ```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()` 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?: ReadonlyArray<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
|
||||
*/
|
||||
time(label?: string): void;
|
||||
/**
|
||||
* Stops a timer that was previously started by calling {@link time} and
|
||||
* prints the result to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('100-elements');
|
||||
* for (let i = 0; i < 100; i++) {}
|
||||
* console.timeEnd('100-elements');
|
||||
* // prints 100-elements: 225.438ms
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
*/
|
||||
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
|
||||
*/
|
||||
timeLog(label?: string, ...data: any[]): void;
|
||||
/**
|
||||
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` 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.
|
||||
* Starts a JavaScript CPU profile with an optional label.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
profileEnd(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
||||
*/
|
||||
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` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**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` 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/v16.4.2/lib/console.js)
|
||||
*/
|
||||
namespace console {
|
||||
interface ConsoleConstructorOptions {
|
||||
stdout: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream | undefined;
|
||||
ignoreErrors?: boolean | undefined;
|
||||
colorMode?: boolean | 'auto' | undefined;
|
||||
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;
|
||||
}
|
3967
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/crypto.d.ts
vendored
Normal file
3967
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/crypto.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
548
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dgram.d.ts
vendored
Normal file
548
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dgram.d.ts
vendored
Normal file
@ -0,0 +1,548 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`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/v18.0.0/lib/dgram.js)
|
||||
*/
|
||||
declare module 'dgram' {
|
||||
import { AddressInfo } from 'node:net';
|
||||
import * as dns from 'node:dns';
|
||||
import { EventEmitter, Abortable } 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 'cluster';
|
||||
* import dgram from '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 'dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`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;
|
||||
/**
|
||||
* 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 'dgram';
|
||||
* import { Buffer } from '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 'dgram';
|
||||
* import { Buffer } from '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 'dgram';
|
||||
* import { Buffer } from '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 | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | ReadonlyArray<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 addition 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;
|
||||
}
|
||||
}
|
||||
declare module 'node:dgram' {
|
||||
export * from 'dgram';
|
||||
}
|
156
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/diagnostics_channel.d.ts
vendored
Normal file
156
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/diagnostics_channel.d.ts
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `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 '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.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js)
|
||||
*/
|
||||
declare module 'diagnostics_channel' {
|
||||
/**
|
||||
* 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 '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): boolean;
|
||||
/**
|
||||
* This is the primary entry-point for anyone wanting to interact with 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 '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): Channel;
|
||||
type ChannelListener = (message: unknown, name: string) => void;
|
||||
/**
|
||||
* The class `Channel` represents an individual named channel within the data
|
||||
* pipeline. It is use 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 {
|
||||
readonly name: string;
|
||||
/**
|
||||
* 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 '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);
|
||||
/**
|
||||
* 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 '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 'diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.subscribe((message, name) => {
|
||||
* // Received data
|
||||
* });
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @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 '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
|
||||
* @param onMessage The previous subscribed handler to remove
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
unsubscribe(onMessage: ChannelListener): void;
|
||||
}
|
||||
}
|
||||
declare module 'node:diagnostics_channel' {
|
||||
export * from 'diagnostics_channel';
|
||||
}
|
662
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dns.d.ts
vendored
Normal file
662
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dns.d.ts
vendored
Normal file
@ -0,0 +1,662 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `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
|
||||
* const dns = require('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 `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
|
||||
* const dns = require('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` for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js)
|
||||
*/
|
||||
declare module 'dns' {
|
||||
import * as dnsPromises from 'node:dns/promises';
|
||||
// Supported getaddrinfo flags.
|
||||
export const ADDRCONFIG: number;
|
||||
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 {
|
||||
family?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
all?: boolean | undefined;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
verbatim?: boolean | undefined;
|
||||
}
|
||||
export interface LookupOneOptions extends LookupOptions {
|
||||
all?: false | undefined;
|
||||
}
|
||||
export interface LookupAllOptions extends LookupOptions {
|
||||
all: true;
|
||||
}
|
||||
export interface LookupAddress {
|
||||
address: string;
|
||||
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 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` before using`dns.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('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()` 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` object, where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('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()` 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 {
|
||||
critial: 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` 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 a 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` object, where `err.code` is
|
||||
* one of the `DNS error codes`.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
||||
/**
|
||||
* 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` formatted addresses
|
||||
*/
|
||||
export function setServers(servers: ReadonlyArray<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 `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher
|
||||
* priority than `--dns-result-order`. When using `worker threads`,{@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'` or `'verbatim'`.
|
||||
*/
|
||||
export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||
// Error codes
|
||||
export const NODATA: string;
|
||||
export const FORMERR: string;
|
||||
export const SERVFAIL: string;
|
||||
export const NOTFOUND: string;
|
||||
export const NOTIMP: string;
|
||||
export const REFUSED: string;
|
||||
export const BADQUERY: string;
|
||||
export const BADNAME: string;
|
||||
export const BADFAMILY: string;
|
||||
export const BADRESP: string;
|
||||
export const CONNREFUSED: string;
|
||||
export const TIMEOUT: string;
|
||||
export const EOF: string;
|
||||
export const FILE: string;
|
||||
export const NOMEM: string;
|
||||
export const DESTRUCTION: string;
|
||||
export const BADSTR: string;
|
||||
export const BADFLAGS: string;
|
||||
export const NONAME: string;
|
||||
export const BADHINTS: string;
|
||||
export const NOTINITIALIZED: string;
|
||||
export const LOADIPHLPAPI: string;
|
||||
export const ADDRGETNETWORKPARAMS: string;
|
||||
export const CANCELLED: string;
|
||||
export interface ResolverOptions {
|
||||
timeout?: number | undefined;
|
||||
/**
|
||||
* @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()` does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('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 `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;
|
||||
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';
|
||||
}
|
373
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dns/promises.d.ts
vendored
Normal file
373
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dns/promises.d.ts
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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 `require('dns').promises` or `require('dns/promises')`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
declare module 'dns/promises' {
|
||||
import {
|
||||
LookupAddress,
|
||||
LookupOneOptions,
|
||||
LookupAllOptions,
|
||||
LookupOptions,
|
||||
AnyRecord,
|
||||
CaaRecord,
|
||||
MxRecord,
|
||||
NaptrRecord,
|
||||
SoaRecord,
|
||||
SrvRecord,
|
||||
ResolveWithTtlOptions,
|
||||
RecordWithTtl,
|
||||
ResolveOptions,
|
||||
ResolverOptions,
|
||||
} 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` 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()` 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` before
|
||||
* using `dnsPromises.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('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` object, where `err.code`is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dnsPromises = require('dns').promises;
|
||||
* 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` object, where `err.code`is one of the `DNS 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` object, where `err.code`is one of the `DNS error codes`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function reverse(ip: string): Promise<string[]>;
|
||||
/**
|
||||
* 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: ReadonlyArray<string>): void;
|
||||
/**
|
||||
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have
|
||||
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.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'` or `'verbatim'`.
|
||||
*/
|
||||
function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||
class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
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;
|
||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
}
|
||||
declare module 'node:dns/promises' {
|
||||
export * from 'dns/promises';
|
||||
}
|
129
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dom-events.d.ts
vendored
Normal file
129
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/dom-events.d.ts
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
173
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/domain.d.ts
vendored
Normal file
173
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/domain.d.ts
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* **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/v18.0.0/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 lowlevel 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
|
||||
* const domain = require('domain');
|
||||
* const fs = require('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';
|
||||
}
|
681
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/events.d.ts
vendored
Normal file
681
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/events.d.ts
vendored
Normal file
@ -0,0 +1,681 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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
|
||||
* const EventEmitter = require('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/v18.0.0/lib/events.js)
|
||||
*/
|
||||
declare module 'events' {
|
||||
// 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;
|
||||
}
|
||||
// Any EventTarget with a Node-style `once` function
|
||||
interface _NodeEventTarget {
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
// Any EventTarget with a DOM-style `addEventListener`
|
||||
interface _DOMEventTarget {
|
||||
addEventListener(
|
||||
eventName: string,
|
||||
listener: (...args: any[]) => void,
|
||||
opts?: {
|
||||
once: boolean;
|
||||
}
|
||||
): any;
|
||||
}
|
||||
interface StaticEventEmitterOptions {
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
||||
/**
|
||||
* The `EventEmitter` class is defined and exposed by the `events` module:
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('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 {
|
||||
constructor(options?: EventEmitterOptions);
|
||||
/**
|
||||
* 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
|
||||
* const { once, EventEmitter } = require('events');
|
||||
*
|
||||
* async function run() {
|
||||
* 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.log('error happened', err);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* run();
|
||||
* ```
|
||||
*
|
||||
* 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
|
||||
* const { EventEmitter, once } = require('events');
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* once(ee, 'error')
|
||||
* .then(([err]) => console.log('ok', err.message))
|
||||
* .catch((err) => console.log('error', err.message));
|
||||
*
|
||||
* ee.emit('error', new Error('boom'));
|
||||
*
|
||||
* // Prints: ok boom
|
||||
* ```
|
||||
*
|
||||
* An `AbortSignal` can be used to cancel waiting for the event:
|
||||
*
|
||||
* ```js
|
||||
* const { EventEmitter, once } = require('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: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
/**
|
||||
* ```js
|
||||
* const { on, EventEmitter } = require('events');
|
||||
*
|
||||
* (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')) {
|
||||
* // 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
|
||||
* const { on, EventEmitter } = require('events');
|
||||
* 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());
|
||||
* ```
|
||||
* @since v13.6.0, v12.16.0
|
||||
* @param eventName The name of the event being listened for
|
||||
* @return that iterates `eventName` events emitted by the `emitter`
|
||||
*/
|
||||
static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
||||
/**
|
||||
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
||||
*
|
||||
* ```js
|
||||
* const { EventEmitter, listenerCount } = require('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
|
||||
* const { getEventListeners, EventEmitter } = require('events');
|
||||
*
|
||||
* {
|
||||
* const ee = new EventEmitter();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* ee.on('foo', listener);
|
||||
* getEventListeners(ee, 'foo'); // [listener]
|
||||
* }
|
||||
* {
|
||||
* const et = new EventTarget();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* et.addEventListener('foo', listener);
|
||||
* getEventListeners(et, 'foo'); // [listener]
|
||||
* }
|
||||
* ```
|
||||
* @since v15.2.0, v14.17.0
|
||||
*/
|
||||
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* ```js
|
||||
* const {
|
||||
* setMaxListeners,
|
||||
* EventEmitter
|
||||
* } = require('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 eventsTargets 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<_DOMEventTarget | NodeJS.EventEmitter>): void;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
static readonly errorMonitor: unique symbol;
|
||||
static readonly captureRejectionSymbol: unique symbol;
|
||||
/**
|
||||
* Sets or gets the default captureRejection value for all emitters.
|
||||
*/
|
||||
// TODO: These should be described using static getter/setter pairs:
|
||||
static captureRejections: boolean;
|
||||
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;
|
||||
}
|
||||
}
|
||||
global {
|
||||
namespace NodeJS {
|
||||
interface EventEmitter {
|
||||
/**
|
||||
* Alias for `emitter.on(eventName, listener)`.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
addListener(eventName: string | symbol, listener: (...args: any[]) => void): 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
|
||||
* 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(eventName: string | symbol, listener: (...args: any[]) => void): 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
|
||||
* 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(eventName: string | symbol, listener: (...args: any[]) => void): 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
|
||||
* 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
|
||||
* 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(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Alias for `emitter.removeListener()`.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
off(eventName: string | symbol, listener: (...args: any[]) => void): 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(event?: string | symbol): 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(eventName: string | symbol): Function[];
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`,
|
||||
* including any wrappers (such as those created by `.once()`).
|
||||
*
|
||||
* ```js
|
||||
* 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(eventName: string | symbol): Function[];
|
||||
/**
|
||||
* 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
|
||||
* const EventEmitter = require('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(eventName: string | symbol, ...args: any[]): boolean;
|
||||
/**
|
||||
* Returns the number of listeners listening to the event named `eventName`.
|
||||
* @since v3.2.0
|
||||
* @param eventName The name of the event being listened for
|
||||
*/
|
||||
listenerCount(eventName: string | symbol): 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(eventName: string | symbol, listener: (...args: any[]) => void): 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(eventName: string | symbol, listener: (...args: any[]) => void): 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
|
||||
* const EventEmitter = require('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>;
|
||||
}
|
||||
}
|
||||
}
|
||||
export = EventEmitter;
|
||||
}
|
||||
declare module 'node:events' {
|
||||
import events = require('events');
|
||||
export = events;
|
||||
}
|
3875
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/fs.d.ts
vendored
Normal file
3875
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/fs.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1141
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/fs/promises.d.ts
vendored
Normal file
1141
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/fs/promises.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
297
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/globals.d.ts
vendored
Normal file
297
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/globals.d.ts
vendored
Normal file
@ -0,0 +1,297 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
// 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 { }
|
||||
|
||||
declare var process: NodeJS.Process;
|
||||
declare var console: Console;
|
||||
|
||||
declare var __filename: string;
|
||||
declare var __dirname: string;
|
||||
|
||||
declare var require: NodeRequire;
|
||||
declare var module: NodeModule;
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
|
||||
/**
|
||||
* Only available if `--expose-gc` is passed to the process.
|
||||
*/
|
||||
declare var gc: undefined | (() => void);
|
||||
|
||||
//#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(): 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;
|
||||
}
|
||||
|
||||
declare var AbortController: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
|
||||
declare var AbortSignal: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
// TODO: Add abort() static
|
||||
};
|
||||
//#endregion borrowed
|
||||
|
||||
//#region ArrayLike.at()
|
||||
interface RelativeIndexable<T> {
|
||||
/**
|
||||
* Takes an integer value and returns the item at that index,
|
||||
* allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the array.
|
||||
*/
|
||||
at(index: number): T | undefined;
|
||||
}
|
||||
interface String extends RelativeIndexable<string> {}
|
||||
interface Array<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> {}
|
||||
//#endregion ArrayLike.at() end
|
||||
|
||||
/**
|
||||
* @since v17.0.0
|
||||
*
|
||||
* Creates a deep clone of an object.
|
||||
*/
|
||||
declare function structuredClone<T>(
|
||||
value: T,
|
||||
transfer?: { transfer: ReadonlyArray<import('worker_threads').TransferListItem> },
|
||||
): T;
|
||||
|
||||
/*----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
* *
|
||||
*-----------------------------------------------*/
|
||||
declare 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 | null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
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](): AsyncIterableIterator<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;
|
||||
}
|
||||
|
||||
type TypedArray =
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Uint16Array
|
||||
| Uint32Array
|
||||
| Int8Array
|
||||
| Int16Array
|
||||
| Int32Array
|
||||
| BigUint64Array
|
||||
| BigInt64Array
|
||||
| Float32Array
|
||||
| Float64Array;
|
||||
type ArrayBufferView = TypedArray | DataView;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
1617
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/http.d.ts
vendored
Normal file
1617
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/http.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2137
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/http2.d.ts
vendored
Normal file
2137
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/http2.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
544
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/https.d.ts
vendored
Normal file
544
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/https.d.ts
vendored
Normal file
@ -0,0 +1,544 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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/v18.0.0/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 = typeof http.ServerResponse,
|
||||
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||
type RequestOptions = http.RequestOptions &
|
||||
tls.SecureContextOptions & {
|
||||
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 = 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 = 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> & { req: InstanceType<Request> },
|
||||
): boolean;
|
||||
emit(
|
||||
event: 'checkExpectation',
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & { req: InstanceType<Request> },
|
||||
): 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> & { req: InstanceType<Request> },
|
||||
): 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/
|
||||
* const https = require('https');
|
||||
* const fs = require('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
|
||||
* const https = require('https');
|
||||
* const fs = require('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 = 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 = 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
|
||||
* const https = require('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
|
||||
* const tls = require('tls');
|
||||
* const https = require('https');
|
||||
* const crypto = require('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-sha25 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
|
||||
* const https = require('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';
|
||||
}
|
117
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/module.d.ts
vendored
Normal file
117
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/module.d.ts
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* @since v0.3.7
|
||||
*/
|
||||
declare module 'module' {
|
||||
import { URL } from 'node:url';
|
||||
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
|
||||
* const fs = require('fs');
|
||||
* const assert = require('assert');
|
||||
* const { syncBuiltinESMExports } = require('module');
|
||||
*
|
||||
* fs.readFile = newAPI;
|
||||
*
|
||||
* delete fs.readFileSync;
|
||||
*
|
||||
* function newAPI() {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
* fs.newAPI = newAPI;
|
||||
*
|
||||
* syncBuiltinESMExports();
|
||||
*
|
||||
* import('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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* @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 number and column number in the generated source file, returns
|
||||
* an object representing the position in the original file. The object returned
|
||||
* consists of the following keys:
|
||||
*/
|
||||
findEntry(line: number, column: number): SourceMapping;
|
||||
}
|
||||
}
|
||||
interface Module extends NodeModule {}
|
||||
class Module {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
static createRequire(path: string | URL): NodeRequire;
|
||||
static builtinModules: string[];
|
||||
static Module: typeof Module;
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
global {
|
||||
interface ImportMeta {
|
||||
url: string;
|
||||
/**
|
||||
* @experimental
|
||||
* This feature is only available with the `--experimental-import-meta-resolve`
|
||||
* command flag enabled.
|
||||
*
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @param specified The module specifier to resolve relative to `parent`.
|
||||
* @param parent The absolute parent module URL to resolve from. If none
|
||||
* is specified, the value of `import.meta.url` is used as the default.
|
||||
*/
|
||||
resolve?(specified: string, parent?: string | URL): Promise<string>;
|
||||
}
|
||||
}
|
||||
export = Module;
|
||||
}
|
||||
declare module 'node:module' {
|
||||
import module = require('module');
|
||||
export = module;
|
||||
}
|
872
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/net.d.ts
vendored
Normal file
872
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/net.d.ts
vendored
Normal file
@ -0,0 +1,872 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* > Stability: 2 - Stable
|
||||
*
|
||||
* The `net` module provides an asynchronous network API for creating stream-based
|
||||
* TCP or `IPC` servers ({@link createServer}) and clients
|
||||
* ({@link createConnection}).
|
||||
*
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('net');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js)
|
||||
*/
|
||||
declare module 'net' {
|
||||
import * as stream from 'node:stream';
|
||||
import { Abortable, EventEmitter } from 'node:events';
|
||||
import * as dns from 'node:dns';
|
||||
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
port: number;
|
||||
}
|
||||
interface SocketConstructorOpts {
|
||||
fd?: number | undefined;
|
||||
allowHalfOpen?: boolean | undefined;
|
||||
readable?: boolean | undefined;
|
||||
writable?: boolean | undefined;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
interface OnReadOpts {
|
||||
buffer: Uint8Array | (() => Uint8Array);
|
||||
/**
|
||||
* This function is called for every chunk of incoming data.
|
||||
* Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
|
||||
* Return false from this function to implicitly pause() the socket.
|
||||
*/
|
||||
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
||||
}
|
||||
interface ConnectOpts {
|
||||
/**
|
||||
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
||||
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
||||
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
||||
*/
|
||||
onread?: OnReadOpts | undefined;
|
||||
}
|
||||
interface TcpSocketConnectOpts extends ConnectOpts {
|
||||
port: number;
|
||||
host?: string | undefined;
|
||||
localAddress?: string | undefined;
|
||||
localPort?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
family?: number | undefined;
|
||||
lookup?: LookupFunction | undefined;
|
||||
noDelay?: boolean | undefined;
|
||||
keepAlive?: boolean | undefined;
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
}
|
||||
interface IpcSocketConnectOpts extends ConnectOpts {
|
||||
path: string;
|
||||
}
|
||||
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
||||
type SocketReadyState = 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
|
||||
/**
|
||||
* This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
|
||||
* (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
|
||||
* an `EventEmitter`.
|
||||
*
|
||||
* A `net.Socket` can be created by the user and used directly to interact with
|
||||
* a server. For example, it is returned by {@link createConnection},
|
||||
* so the user can use it to talk to the server.
|
||||
*
|
||||
* It can also be created by Node.js and passed to the user when a connection
|
||||
* is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
|
||||
* it to interact with the client.
|
||||
* @since v0.3.4
|
||||
*/
|
||||
class Socket extends stream.Duplex {
|
||||
constructor(options?: SocketConstructorOpts);
|
||||
/**
|
||||
* Sends data on the socket. The second parameter specifies the encoding in the
|
||||
* case of a string. It defaults to UTF8 encoding.
|
||||
*
|
||||
* Returns `true` if the entire data was flushed successfully to the kernel
|
||||
* buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
|
||||
*
|
||||
* The optional `callback` parameter will be executed when the data is finally
|
||||
* written out, which may not be immediately.
|
||||
*
|
||||
* See `Writable` stream `write()` method for more
|
||||
* information.
|
||||
* @since v0.1.90
|
||||
* @param [encoding='utf8'] Only used when data is `string`.
|
||||
*/
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
||||
/**
|
||||
* Initiate a connection on a given socket.
|
||||
*
|
||||
* Possible signatures:
|
||||
*
|
||||
* * `socket.connect(options[, connectListener])`
|
||||
* * `socket.connect(path[, connectListener])` for `IPC` connections.
|
||||
* * `socket.connect(port[, host][, connectListener])` for TCP connections.
|
||||
* * Returns: `net.Socket` The socket itself.
|
||||
*
|
||||
* This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
|
||||
* instead of a `'connect'` event, an `'error'` event will be emitted with
|
||||
* the error passed to the `'error'` listener.
|
||||
* The last parameter `connectListener`, if supplied, will be added as a listener
|
||||
* for the `'connect'` event **once**.
|
||||
*
|
||||
* This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
|
||||
* behavior.
|
||||
*/
|
||||
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
||||
connect(port: number, host: string, connectionListener?: () => void): this;
|
||||
connect(port: number, connectionListener?: () => void): this;
|
||||
connect(path: string, connectionListener?: () => void): this;
|
||||
/**
|
||||
* Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
|
||||
* @since v0.1.90
|
||||
* @return The socket itself.
|
||||
*/
|
||||
setEncoding(encoding?: BufferEncoding): this;
|
||||
/**
|
||||
* Pauses the reading of data. That is, `'data'` events will not be emitted.
|
||||
* Useful to throttle back an upload.
|
||||
* @return The socket itself.
|
||||
*/
|
||||
pause(): this;
|
||||
/**
|
||||
* Close the TCP connection by sending an RST packet and destroy the stream.
|
||||
* If this TCP socket is in connecting status, it will send an RST packet
|
||||
* and destroy this TCP socket once it is connected. Otherwise, it will call
|
||||
* `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket
|
||||
* (for example, a pipe), calling this method will immediately throw
|
||||
* an `ERR_INVALID_HANDLE_TYPE` Error.
|
||||
* @since v18.3.0
|
||||
* @return The socket itself.
|
||||
*/
|
||||
resetAndDestroy(): this;
|
||||
/**
|
||||
* Resumes reading after a call to `socket.pause()`.
|
||||
* @return The socket itself.
|
||||
*/
|
||||
resume(): this;
|
||||
/**
|
||||
* Sets the socket to timeout after `timeout` milliseconds of inactivity on
|
||||
* the socket. By default `net.Socket` do not have a timeout.
|
||||
*
|
||||
* When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
|
||||
* end the connection.
|
||||
*
|
||||
* ```js
|
||||
* socket.setTimeout(3000);
|
||||
* socket.on('timeout', () => {
|
||||
* console.log('socket timeout');
|
||||
* socket.end();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* If `timeout` is 0, then the existing idle timeout is disabled.
|
||||
*
|
||||
* The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
|
||||
* @since v0.1.90
|
||||
* @return The socket itself.
|
||||
*/
|
||||
setTimeout(timeout: number, callback?: () => void): this;
|
||||
/**
|
||||
* Enable/disable the use of Nagle's algorithm.
|
||||
*
|
||||
* When a TCP connection is created, it will have Nagle's algorithm enabled.
|
||||
*
|
||||
* Nagle's algorithm delays data before it is sent via the network. It attempts
|
||||
* to optimize throughput at the expense of latency.
|
||||
*
|
||||
* Passing `true` for `noDelay` or not passing an argument will disable Nagle's
|
||||
* algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
|
||||
* algorithm.
|
||||
* @since v0.1.90
|
||||
* @param [noDelay=true]
|
||||
* @return The socket itself.
|
||||
*/
|
||||
setNoDelay(noDelay?: boolean): this;
|
||||
/**
|
||||
* Enable/disable keep-alive functionality, and optionally set the initial
|
||||
* delay before the first keepalive probe is sent on an idle socket.
|
||||
*
|
||||
* Set `initialDelay` (in milliseconds) to set the delay between the last
|
||||
* data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
|
||||
* (or previous) setting.
|
||||
*
|
||||
* Enabling the keep-alive functionality will set the following socket options:
|
||||
*
|
||||
* * `SO_KEEPALIVE=1`
|
||||
* * `TCP_KEEPIDLE=initialDelay`
|
||||
* * `TCP_KEEPCNT=10`
|
||||
* * `TCP_KEEPINTVL=1`
|
||||
* @since v0.1.92
|
||||
* @param [enable=false]
|
||||
* @param [initialDelay=0]
|
||||
* @return The socket itself.
|
||||
*/
|
||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||
/**
|
||||
* Returns the bound `address`, the address `family` name and `port` of the
|
||||
* socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
||||
* @since v0.1.90
|
||||
*/
|
||||
address(): AddressInfo | {};
|
||||
/**
|
||||
* Calling `unref()` on a socket will allow the program to exit if this is the only
|
||||
* active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
|
||||
* @since v0.9.1
|
||||
* @return The socket itself.
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior).
|
||||
* If the socket is `ref`ed calling `ref` again will have no effect.
|
||||
* @since v0.9.1
|
||||
* @return The socket itself.
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* This property shows the number of characters buffered for writing. The buffer
|
||||
* may contain strings whose length after encoding is not yet known. So this number
|
||||
* is only an approximation of the number of bytes in the buffer.
|
||||
*
|
||||
* `net.Socket` has the property that `socket.write()` always works. This is to
|
||||
* help users get up and running quickly. The computer cannot always keep up
|
||||
* with the amount of data that is written to a socket. The network connection
|
||||
* simply might be too slow. Node.js will internally queue up the data written to a
|
||||
* socket and send it out over the wire when it is possible.
|
||||
*
|
||||
* The consequence of this internal buffering is that memory may grow.
|
||||
* Users who experience large or growing `bufferSize` should attempt to
|
||||
* "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
|
||||
* @since v0.3.8
|
||||
* @deprecated Since v14.6.0 - Use `writableLength` instead.
|
||||
*/
|
||||
readonly bufferSize: number;
|
||||
/**
|
||||
* The amount of received bytes.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly bytesRead: number;
|
||||
/**
|
||||
* The amount of bytes sent.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly bytesWritten: number;
|
||||
/**
|
||||
* If `true`,`socket.connect(options[, connectListener])` was
|
||||
* called and has not yet finished. It will stay `true` until the socket becomes
|
||||
* connected, then it is set to `false` and the `'connect'` event is emitted. Note
|
||||
* that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
|
||||
* @since v6.1.0
|
||||
*/
|
||||
readonly connecting: boolean;
|
||||
/**
|
||||
* See `writable.destroyed` for further details.
|
||||
*/
|
||||
readonly destroyed: boolean;
|
||||
/**
|
||||
* The string representation of the local IP address the remote client is
|
||||
* connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
|
||||
* connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
|
||||
* @since v0.9.6
|
||||
*/
|
||||
readonly localAddress?: string;
|
||||
/**
|
||||
* The numeric representation of the local port. For example, `80` or `21`.
|
||||
* @since v0.9.6
|
||||
*/
|
||||
readonly localPort?: number;
|
||||
/**
|
||||
* The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
readonly localFamily?: string;
|
||||
/**
|
||||
* This property represents the state of the connection as a string.
|
||||
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
||||
* @since v0.5.0
|
||||
*/
|
||||
readonly readyState: SocketReadyState;
|
||||
/**
|
||||
* The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
|
||||
* the socket is destroyed (for example, if the client disconnected).
|
||||
* @since v0.5.10
|
||||
*/
|
||||
readonly remoteAddress?: string | undefined;
|
||||
/**
|
||||
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
readonly remoteFamily?: string | undefined;
|
||||
/**
|
||||
* The numeric representation of the remote port. For example, `80` or `21`.
|
||||
* @since v0.5.10
|
||||
*/
|
||||
readonly remotePort?: number | undefined;
|
||||
/**
|
||||
* The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set.
|
||||
* @since v10.7.0
|
||||
*/
|
||||
readonly timeout?: number | undefined;
|
||||
/**
|
||||
* Half-closes the socket. i.e., it sends a FIN packet. It is possible the
|
||||
* server will still send some data.
|
||||
*
|
||||
* See `writable.end()` for further details.
|
||||
* @since v0.1.90
|
||||
* @param [encoding='utf8'] Only used when data is `string`.
|
||||
* @param callback Optional callback for when the socket is finished.
|
||||
* @return The socket itself.
|
||||
*/
|
||||
end(callback?: () => void): this;
|
||||
end(buffer: Uint8Array | string, callback?: () => void): this;
|
||||
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connect
|
||||
* 3. data
|
||||
* 4. drain
|
||||
* 5. end
|
||||
* 6. error
|
||||
* 7. lookup
|
||||
* 8. ready
|
||||
* 9. timeout
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
addListener(event: 'connect', listener: () => void): this;
|
||||
addListener(event: 'data', listener: (data: Buffer) => void): this;
|
||||
addListener(event: 'drain', listener: () => void): this;
|
||||
addListener(event: 'end', listener: () => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||
addListener(event: 'ready', listener: () => void): this;
|
||||
addListener(event: 'timeout', listener: () => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: 'close', hadError: boolean): boolean;
|
||||
emit(event: 'connect'): boolean;
|
||||
emit(event: 'data', data: Buffer): boolean;
|
||||
emit(event: 'drain'): boolean;
|
||||
emit(event: 'end'): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
|
||||
emit(event: 'ready'): boolean;
|
||||
emit(event: 'timeout'): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
on(event: 'connect', listener: () => void): this;
|
||||
on(event: 'data', listener: (data: Buffer) => void): this;
|
||||
on(event: 'drain', listener: () => void): this;
|
||||
on(event: 'end', listener: () => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||
on(event: 'ready', listener: () => void): this;
|
||||
on(event: 'timeout', listener: () => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
once(event: 'connect', listener: () => void): this;
|
||||
once(event: 'data', listener: (data: Buffer) => void): this;
|
||||
once(event: 'drain', listener: () => void): this;
|
||||
once(event: 'end', listener: () => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||
once(event: 'ready', listener: () => void): this;
|
||||
once(event: 'timeout', listener: () => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
prependListener(event: 'connect', listener: () => void): this;
|
||||
prependListener(event: 'data', listener: (data: Buffer) => void): this;
|
||||
prependListener(event: 'drain', listener: () => void): this;
|
||||
prependListener(event: 'end', listener: () => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||
prependListener(event: 'ready', listener: () => void): this;
|
||||
prependListener(event: 'timeout', listener: () => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
||||
prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
|
||||
prependOnceListener(event: 'drain', listener: () => void): this;
|
||||
prependOnceListener(event: 'end', listener: () => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||
prependOnceListener(event: 'ready', listener: () => void): this;
|
||||
prependOnceListener(event: 'timeout', listener: () => void): this;
|
||||
}
|
||||
interface ListenOptions extends Abortable {
|
||||
port?: number | undefined;
|
||||
host?: string | undefined;
|
||||
backlog?: number | undefined;
|
||||
path?: string | undefined;
|
||||
exclusive?: boolean | undefined;
|
||||
readableAll?: boolean | undefined;
|
||||
writableAll?: boolean | undefined;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
ipv6Only?: boolean | undefined;
|
||||
}
|
||||
interface ServerOpts {
|
||||
/**
|
||||
* Indicates whether half-opened TCP connections are allowed.
|
||||
* @default false
|
||||
*/
|
||||
allowHalfOpen?: boolean | undefined;
|
||||
/**
|
||||
* Indicates whether the socket should be paused on incoming connections.
|
||||
* @default false
|
||||
*/
|
||||
pauseOnConnect?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
|
||||
* @default false
|
||||
* @since v16.5.0
|
||||
*/
|
||||
noDelay?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
||||
* similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
|
||||
* @default false
|
||||
* @since v16.5.0
|
||||
*/
|
||||
keepAlive?: boolean | undefined;
|
||||
/**
|
||||
* If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
|
||||
* @default 0
|
||||
* @since v16.5.0
|
||||
*/
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
}
|
||||
interface DropArgument {
|
||||
localAddress?: string;
|
||||
localPort?: number;
|
||||
localFamily?: string;
|
||||
remoteAddress?: string;
|
||||
remotePort?: number;
|
||||
remoteFamily?: string;
|
||||
}
|
||||
/**
|
||||
* This class is used to create a TCP or `IPC` server.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
class Server extends EventEmitter {
|
||||
constructor(connectionListener?: (socket: Socket) => void);
|
||||
constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
|
||||
/**
|
||||
* Start a server listening for connections. A `net.Server` can be a TCP or
|
||||
* an `IPC` server depending on what it listens to.
|
||||
*
|
||||
* Possible signatures:
|
||||
*
|
||||
* * `server.listen(handle[, backlog][, callback])`
|
||||
* * `server.listen(options[, callback])`
|
||||
* * `server.listen(path[, backlog][, callback])` for `IPC` servers
|
||||
* * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
|
||||
*
|
||||
* This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
|
||||
* event.
|
||||
*
|
||||
* All `listen()` methods can take a `backlog` parameter to specify the maximum
|
||||
* length of the queue of pending connections. The actual length will be determined
|
||||
* by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
|
||||
*
|
||||
* All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
|
||||
* details).
|
||||
*
|
||||
* The `server.listen()` method can be called again if and only if there was an
|
||||
* error during the first `server.listen()` call or `server.close()` has been
|
||||
* called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
|
||||
*
|
||||
* One of the most common errors raised when listening is `EADDRINUSE`.
|
||||
* This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
|
||||
* after a certain amount of time:
|
||||
*
|
||||
* ```js
|
||||
* server.on('error', (e) => {
|
||||
* if (e.code === 'EADDRINUSE') {
|
||||
* console.log('Address in use, retrying...');
|
||||
* setTimeout(() => {
|
||||
* server.close();
|
||||
* server.listen(PORT, HOST);
|
||||
* }, 1000);
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
||||
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(port?: number, listeningListener?: () => void): this;
|
||||
listen(path: string, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(path: string, listeningListener?: () => void): this;
|
||||
listen(options: ListenOptions, listeningListener?: () => void): this;
|
||||
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(handle: any, listeningListener?: () => void): this;
|
||||
/**
|
||||
* Stops the server from accepting new connections and keeps existing
|
||||
* connections. This function is asynchronous, the server is finally closed
|
||||
* when all connections are ended and the server emits a `'close'` event.
|
||||
* The optional `callback` will be called once the `'close'` event occurs. Unlike
|
||||
* that event, it will be called with an `Error` as its only argument if the server
|
||||
* was not open when it was closed.
|
||||
* @since v0.1.90
|
||||
* @param callback Called when the server is closed.
|
||||
*/
|
||||
close(callback?: (err?: Error) => void): this;
|
||||
/**
|
||||
* Returns the bound `address`, the address `family` name, and `port` of the server
|
||||
* as reported by the operating system if listening on an IP socket
|
||||
* (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
||||
*
|
||||
* For a server listening on a pipe or Unix domain socket, the name is returned
|
||||
* as a string.
|
||||
*
|
||||
* ```js
|
||||
* const server = net.createServer((socket) => {
|
||||
* socket.end('goodbye\n');
|
||||
* }).on('error', (err) => {
|
||||
* // Handle errors here.
|
||||
* throw err;
|
||||
* });
|
||||
*
|
||||
* // Grab an arbitrary unused port.
|
||||
* server.listen(() => {
|
||||
* console.log('opened server on', server.address());
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `server.address()` returns `null` before the `'listening'` event has been
|
||||
* emitted or after calling `server.close()`.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
address(): AddressInfo | string | null;
|
||||
/**
|
||||
* Asynchronously get the number of concurrent connections on the server. Works
|
||||
* when sockets were sent to forks.
|
||||
*
|
||||
* Callback should take two arguments `err` and `count`.
|
||||
* @since v0.9.7
|
||||
*/
|
||||
getConnections(cb: (error: Error | null, count: number) => void): void;
|
||||
/**
|
||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior).
|
||||
* If the server is `ref`ed calling `ref()` again will have no effect.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* Calling `unref()` on a server will allow the program to exit if this is the only
|
||||
* active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* Set this property to reject connections when the server's connection count gets
|
||||
* high.
|
||||
*
|
||||
* It is not recommended to use this option once a socket has been sent to a child
|
||||
* with `child_process.fork()`.
|
||||
* @since v0.2.0
|
||||
*/
|
||||
maxConnections: number;
|
||||
connections: number;
|
||||
/**
|
||||
* Indicates whether or not the server is listening for connections.
|
||||
* @since v5.7.0
|
||||
*/
|
||||
listening: boolean;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connection
|
||||
* 3. error
|
||||
* 4. listening
|
||||
* 5. drop
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'listening', listener: () => void): this;
|
||||
addListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connection', socket: Socket): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'drop', data?: DropArgument): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'listening', listener: () => void): this;
|
||||
on(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'listening', listener: () => void): this;
|
||||
once(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'listening', listener: () => void): this;
|
||||
prependListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||
prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||
}
|
||||
type IPVersion = 'ipv4' | 'ipv6';
|
||||
/**
|
||||
* The `BlockList` object can be used with some network APIs to specify rules for
|
||||
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
||||
* IP subnets.
|
||||
* @since v15.0.0, v14.18.0
|
||||
*/
|
||||
class BlockList {
|
||||
/**
|
||||
* Adds a rule to block the given IP address.
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param address An IPv4 or IPv6 address.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
addAddress(address: string, type?: IPVersion): void;
|
||||
addAddress(address: SocketAddress): void;
|
||||
/**
|
||||
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param start The starting IPv4 or IPv6 address in the range.
|
||||
* @param end The ending IPv4 or IPv6 address in the range.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
addRange(start: string, end: string, type?: IPVersion): void;
|
||||
addRange(start: SocketAddress, end: SocketAddress): void;
|
||||
/**
|
||||
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param net The network IPv4 or IPv6 address.
|
||||
* @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
addSubnet(net: SocketAddress, prefix: number): void;
|
||||
addSubnet(net: string, prefix: number, type?: IPVersion): void;
|
||||
/**
|
||||
* Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
|
||||
*
|
||||
* ```js
|
||||
* const blockList = new net.BlockList();
|
||||
* blockList.addAddress('123.123.123.123');
|
||||
* blockList.addRange('10.0.0.1', '10.0.0.10');
|
||||
* blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
|
||||
*
|
||||
* console.log(blockList.check('123.123.123.123')); // Prints: true
|
||||
* console.log(blockList.check('10.0.0.3')); // Prints: true
|
||||
* console.log(blockList.check('222.111.111.222')); // Prints: false
|
||||
*
|
||||
* // IPv6 notation for IPv4 addresses works:
|
||||
* console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
|
||||
* console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
|
||||
* ```
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param address The IP address to check
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
check(address: SocketAddress): boolean;
|
||||
check(address: string, type?: IPVersion): boolean;
|
||||
}
|
||||
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
||||
/**
|
||||
* Creates a new TCP or `IPC` server.
|
||||
*
|
||||
* If `allowHalfOpen` is set to `true`, when the other end of the socket
|
||||
* signals the end of transmission, the server will only send back the end of
|
||||
* transmission when `socket.end()` is explicitly called. For example, in the
|
||||
* context of TCP, when a FIN packed is received, a FIN packed is sent
|
||||
* back only when `socket.end()` is explicitly called. Until then the
|
||||
* connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
|
||||
*
|
||||
* If `pauseOnConnect` is set to `true`, then the socket associated with each
|
||||
* incoming connection will be paused, and no data will be read from its handle.
|
||||
* This allows connections to be passed between processes without any data being
|
||||
* read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
|
||||
*
|
||||
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
||||
*
|
||||
* Here is an example of a TCP echo server which listens for connections
|
||||
* on port 8124:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('net');
|
||||
* const server = net.createServer((c) => {
|
||||
* // 'connection' listener.
|
||||
* console.log('client connected');
|
||||
* c.on('end', () => {
|
||||
* console.log('client disconnected');
|
||||
* });
|
||||
* c.write('hello\r\n');
|
||||
* c.pipe(c);
|
||||
* });
|
||||
* server.on('error', (err) => {
|
||||
* throw err;
|
||||
* });
|
||||
* server.listen(8124, () => {
|
||||
* console.log('server bound');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Test this by using `telnet`:
|
||||
*
|
||||
* ```console
|
||||
* $ telnet localhost 8124
|
||||
* ```
|
||||
*
|
||||
* To listen on the socket `/tmp/echo.sock`:
|
||||
*
|
||||
* ```js
|
||||
* server.listen('/tmp/echo.sock', () => {
|
||||
* console.log('server bound');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Use `nc` to connect to a Unix domain socket server:
|
||||
*
|
||||
* ```console
|
||||
* $ nc -U /tmp/echo.sock
|
||||
* ```
|
||||
* @since v0.5.0
|
||||
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
|
||||
*/
|
||||
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
||||
function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
|
||||
/**
|
||||
* Aliases to {@link createConnection}.
|
||||
*
|
||||
* Possible signatures:
|
||||
*
|
||||
* * {@link connect}
|
||||
* * {@link connect} for `IPC` connections.
|
||||
* * {@link connect} for TCP connections.
|
||||
*/
|
||||
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||
function connect(path: string, connectionListener?: () => void): Socket;
|
||||
/**
|
||||
* A factory function, which creates a new {@link Socket},
|
||||
* immediately initiates connection with `socket.connect()`,
|
||||
* then returns the `net.Socket` that starts the connection.
|
||||
*
|
||||
* When the connection is established, a `'connect'` event will be emitted
|
||||
* on the returned socket. The last parameter `connectListener`, if supplied,
|
||||
* will be added as a listener for the `'connect'` event **once**.
|
||||
*
|
||||
* Possible signatures:
|
||||
*
|
||||
* * {@link createConnection}
|
||||
* * {@link createConnection} for `IPC` connections.
|
||||
* * {@link createConnection} for TCP connections.
|
||||
*
|
||||
* The {@link connect} function is an alias to this function.
|
||||
*/
|
||||
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||
/**
|
||||
* Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
|
||||
* address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIP('::1'); // returns 6
|
||||
* net.isIP('127.0.0.1'); // returns 4
|
||||
* net.isIP('127.000.000.001'); // returns 0
|
||||
* net.isIP('127.0.0.1/24'); // returns 0
|
||||
* net.isIP('fhqwhgads'); // returns 0
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIP(input: string): number;
|
||||
/**
|
||||
* Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
|
||||
* leading zeroes. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv4('127.0.0.1'); // returns true
|
||||
* net.isIPv4('127.000.000.001'); // returns false
|
||||
* net.isIPv4('127.0.0.1/24'); // returns false
|
||||
* net.isIPv4('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIPv4(input: string): boolean;
|
||||
/**
|
||||
* Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv6('::1'); // returns true
|
||||
* net.isIPv6('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIPv6(input: string): boolean;
|
||||
interface SocketAddressInitOptions {
|
||||
/**
|
||||
* The network address as either an IPv4 or IPv6 string.
|
||||
* @default 127.0.0.1
|
||||
*/
|
||||
address?: string | undefined;
|
||||
/**
|
||||
* @default `'ipv4'`
|
||||
*/
|
||||
family?: IPVersion | undefined;
|
||||
/**
|
||||
* An IPv6 flow-label used only if `family` is `'ipv6'`.
|
||||
* @default 0
|
||||
*/
|
||||
flowlabel?: number | undefined;
|
||||
/**
|
||||
* An IP port.
|
||||
* @default 0
|
||||
*/
|
||||
port?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
class SocketAddress {
|
||||
constructor(options: SocketAddressInitOptions);
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly address: string;
|
||||
/**
|
||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly family: IPVersion;
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly port: number;
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly flowlabel: number;
|
||||
}
|
||||
}
|
||||
declare module 'node:net' {
|
||||
export * from 'net';
|
||||
}
|
469
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/os.d.ts
vendored
Normal file
469
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/os.d.ts
vendored
Normal file
@ -0,0 +1,469 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `os` module provides operating system-related utility methods and
|
||||
* properties. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const os = require('os');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js)
|
||||
*/
|
||||
declare module 'os' {
|
||||
interface CpuInfo {
|
||||
model: string;
|
||||
speed: number;
|
||||
times: {
|
||||
user: number;
|
||||
nice: number;
|
||||
sys: number;
|
||||
idle: number;
|
||||
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;
|
||||
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 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.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
function cpus(): CpuInfo[];
|
||||
/**
|
||||
* 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` 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 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;
|
||||
const EOL: string;
|
||||
/**
|
||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* The return value is equivalent to `process.arch`.
|
||||
* @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, 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
|
||||
*/
|
||||
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';
|
||||
}
|
194
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/path.d.ts
vendored
Normal file
194
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/path.d.ts
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'path/posix' {
|
||||
import path = require('path');
|
||||
export = path;
|
||||
}
|
||||
declare module 'path/win32' {
|
||||
import path = require('path');
|
||||
export = path;
|
||||
}
|
||||
/**
|
||||
* The `path` module provides utilities for working with file and directory paths.
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const path = require('path');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/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;
|
||||
/**
|
||||
* 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;
|
||||
}
|
628
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/perf_hooks.d.ts
vendored
Normal file
628
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/perf_hooks.d.ts
vendored
Normal file
@ -0,0 +1,628 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* 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/)
|
||||
*
|
||||
* ```js
|
||||
* const { PerformanceObserver, performance } = require('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/v18.0.0/lib/perf_hooks.js)
|
||||
*/
|
||||
declare module 'perf_hooks' {
|
||||
import { AsyncResource } from 'node:async_hooks';
|
||||
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
class PerformanceMark extends PerformanceEntry {
|
||||
readonly duration: 0;
|
||||
readonly entryType: 'mark';
|
||||
}
|
||||
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 {
|
||||
/**
|
||||
* 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 V8 platform was
|
||||
* initialized.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
readonly v8Start: number;
|
||||
}
|
||||
interface EventLoopUtilization {
|
||||
idle: number;
|
||||
active: number;
|
||||
utilization: number;
|
||||
}
|
||||
/**
|
||||
* @param util1 The result of a previous call to eventLoopUtilization()
|
||||
* @param util2 The result of a previous call to eventLoopUtilization() prior to util1
|
||||
*/
|
||||
type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: 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.
|
||||
* @param name
|
||||
*/
|
||||
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.
|
||||
* @param name
|
||||
* @since v16.7.0
|
||||
*/
|
||||
clearMeasures(name?: string): void;
|
||||
/**
|
||||
* 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.
|
||||
* @param name
|
||||
* @return The PerformanceMark entry that was created
|
||||
*/
|
||||
mark(name?: string, options?: MarkOptions): PerformanceMark;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
||||
*/
|
||||
readonly nodeTiming: PerformanceNodeTiming;
|
||||
/**
|
||||
* @return the current high resolution millisecond timestamp
|
||||
*/
|
||||
now(): number;
|
||||
/**
|
||||
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
||||
*/
|
||||
readonly timeOrigin: number;
|
||||
/**
|
||||
* 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.
|
||||
* @param fn
|
||||
*/
|
||||
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
interface PerformanceObserverEntryList {
|
||||
/**
|
||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||
* with respect to `performanceEntry.startTime`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntries());
|
||||
*
|
||||
* * [
|
||||
* * PerformanceEntry {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 81.465639,
|
||||
* * duration: 0
|
||||
* * },
|
||||
* * PerformanceEntry {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 81.860064,
|
||||
* * duration: 0
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByName('meow'));
|
||||
*
|
||||
* * [
|
||||
* * PerformanceEntry {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 98.545991,
|
||||
* * duration: 0
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
* console.log(perfObserverList.getEntriesByName('nope')); // []
|
||||
*
|
||||
* console.log(perfObserverList.getEntriesByName('test', 'mark'));
|
||||
*
|
||||
* * [
|
||||
* * PerformanceEntry {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 63.518931,
|
||||
* * duration: 0
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
* 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
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByType('mark'));
|
||||
*
|
||||
* * [
|
||||
* * PerformanceEntry {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 55.897834,
|
||||
* * duration: 0
|
||||
* * },
|
||||
* * PerformanceEntry {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 56.350146,
|
||||
* * duration: 0
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
* 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;
|
||||
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
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('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: ReadonlyArray<EntryType>;
|
||||
buffered?: boolean | undefined;
|
||||
}
|
||||
| {
|
||||
type: EntryType;
|
||||
buffered?: boolean | undefined;
|
||||
}
|
||||
): void;
|
||||
}
|
||||
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 {
|
||||
/**
|
||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly percentiles: Map<number, number>;
|
||||
/**
|
||||
* 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 minimum recorded event loop delay.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly min: number;
|
||||
/**
|
||||
* The maximum recorded event loop delay.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly max: number;
|
||||
/**
|
||||
* The mean of the recorded event loop delays.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly mean: number;
|
||||
/**
|
||||
* The standard deviation of the recorded event loop delays.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly stddev: number;
|
||||
/**
|
||||
* Resets the collected histogram data.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
reset(): void;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
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.
|
||||
*
|
||||
* ## Examples
|
||||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
recordDelta(): void;
|
||||
/**
|
||||
* Adds the values from other to this histogram.
|
||||
* @since v17.4.0, v16.14.0
|
||||
* @param other Recordable Histogram to combine with
|
||||
*/
|
||||
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
|
||||
* const { monitorEventLoopDelay } = require('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 } from 'perf_hooks';
|
||||
global {
|
||||
/**
|
||||
* `performance` is a global reference for `require('perf_hooks').performance`
|
||||
* https://nodejs.org/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';
|
||||
}
|
1485
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/process.d.ts
vendored
Normal file
1485
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/process.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
134
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/querystring.d.ts
vendored
Normal file
134
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/querystring.d.ts
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `querystring` module provides utilities for parsing and formatting URL
|
||||
* query strings. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const querystring = require('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/v18.0.0/lib/querystring.js)
|
||||
*/
|
||||
declare module 'querystring' {
|
||||
interface StringifyOptions {
|
||||
encodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
interface ParseOptions {
|
||||
maxKeys?: number | undefined;
|
||||
decodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
interface ParsedUrlQuery extends NodeJS.Dict<string | string[]> {}
|
||||
interface ParsedUrlQueryInput extends NodeJS.Dict<string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<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:
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* 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';
|
||||
}
|
656
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/readline.d.ts
vendored
Normal file
656
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/readline.d.ts
vendored
Normal file
@ -0,0 +1,656 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) 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 `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/v18.0.0/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` 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 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-v10.x/docs/api/readline.html#readline_class_interface
|
||||
*/
|
||||
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-v10.x/docs/api/readline.html#readline_class_interface
|
||||
*/
|
||||
protected constructor(options: ReadLineOptions);
|
||||
/**
|
||||
* The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
|
||||
* @since v15.3.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 `readline.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 `readline.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 `readline.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.
|
||||
*
|
||||
* 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);
|
||||
* ```
|
||||
*
|
||||
* If this method is invoked as it's util.promisify()ed version, it returns a
|
||||
* Promise that fulfills with the answer. If the question is canceled using
|
||||
* an `AbortController` it will reject with an `AbortError`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('util');
|
||||
* const question = util.promisify(rl.question).bind(rl);
|
||||
*
|
||||
* async function questionExample() {
|
||||
* try {
|
||||
* const answer = await question('What is you favorite food? ');
|
||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||
* } catch (err) {
|
||||
* console.error('Question rejected', err);
|
||||
* }
|
||||
* }
|
||||
* questionExample();
|
||||
* ```
|
||||
* @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 `readline.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 `readline.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 `readline.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 `readline.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](): AsyncIterableIterator<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
|
||||
* const readline = require('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 `EOF` (Ctrl+D on
|
||||
* Linux/macOS, Ctrl+Z followed by Return on
|
||||
* Windows).
|
||||
* If you want your application to exit without waiting for user input, you can `unref()` the standard input stream:
|
||||
*
|
||||
* ```js
|
||||
* 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
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const { once } = require('events');
|
||||
* const { createReadStream } = require('fs');
|
||||
* const { createInterface } = require('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` 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` 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` `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` `stream`.
|
||||
*
|
||||
* ## Example: Tiny CLI
|
||||
*
|
||||
* The following example illustrates the use of `readline.Interface` class to
|
||||
* implement a small command-line interface:
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const fs = require('fs');
|
||||
* const readline = require('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
|
||||
* const { once } = require('events');
|
||||
* const { createReadStream } = require('fs');
|
||||
* const { createInterface } = require('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
|
||||
* @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';
|
||||
}
|
146
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/readline/promises.d.ts
vendored
Normal file
146
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/readline/promises.d.ts
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `readline/promise` module provides an API for reading lines of input from a Readable stream one line at a time.
|
||||
*
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline/promises.js)
|
||||
* @since v17.0.0
|
||||
*/
|
||||
declare module 'readline/promises' {
|
||||
import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline';
|
||||
import { Abortable } from 'node:events';
|
||||
|
||||
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 readlinePromises.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.
|
||||
*/
|
||||
question(query: string): Promise<string>;
|
||||
question(query: string, options: Abortable): Promise<string>;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
clearScreenDown(): this;
|
||||
/**
|
||||
* The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
moveCursor(dx: number, dy: number): this;
|
||||
/**
|
||||
* The `rl.rollback()` method clears the internal list of pending actions without sending it to the associated `stream`.
|
||||
*/
|
||||
rollback(): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance.
|
||||
*
|
||||
* ```js
|
||||
* const readlinePromises = require('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).
|
||||
*
|
||||
* ## Use of the `completer` function
|
||||
*
|
||||
* The `completer` function takes the current line entered by the user as an argument, and returns an `Array` with 2 entries:
|
||||
*
|
||||
* - An Array with matching entries for the completion.
|
||||
* - The substring that was used for the matching.
|
||||
*
|
||||
* For instance: `[[substr1, substr2, ...], originalsubstring]`.
|
||||
*
|
||||
* ```js
|
||||
* function completer(line) {
|
||||
* const completions = '.help .error .exit .quit .q'.split(' ');
|
||||
* const hits = completions.filter((c) => c.startsWith(line));
|
||||
* // Show all completions if none found
|
||||
* return [hits.length ? hits : completions, line];
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `completer` function can also returns a `Promise`, or be asynchronous:
|
||||
*
|
||||
* ```js
|
||||
* async function completer(linePartial) {
|
||||
* await someAsyncWork();
|
||||
* return [['123'], linePartial];
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
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';
|
||||
}
|
1343
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream.d.ts
vendored
Normal file
1343
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/consumers.d.ts
vendored
Normal file
15
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/consumers.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'stream/consumers' {
|
||||
import { Blob as NodeBlob } from "node:buffer";
|
||||
import { Readable } from 'node:stream';
|
||||
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
||||
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
||||
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<ArrayBuffer>;
|
||||
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<NodeBlob>;
|
||||
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<unknown>;
|
||||
}
|
||||
declare module 'node:stream/consumers' {
|
||||
export * from 'stream/consumers';
|
||||
}
|
45
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/promises.d.ts
vendored
Normal file
45
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/promises.d.ts
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
declare module 'stream/promises' {
|
||||
import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream';
|
||||
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';
|
||||
}
|
333
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/web.d.ts
vendored
Normal file
333
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/stream/web.d.ts
vendored
Normal file
@ -0,0 +1,333 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
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>;
|
||||
}
|
||||
interface ReadableStreamDefaultReadValueResult<T> {
|
||||
done: false;
|
||||
value: T;
|
||||
}
|
||||
interface ReadableStreamDefaultReadDoneResult {
|
||||
done: true;
|
||||
value?: undefined;
|
||||
}
|
||||
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||
type ReadableStreamDefaultReadResult<T> = ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult;
|
||||
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>;
|
||||
}
|
||||
/** This Streams API interface represents a readable stream of byte data. */
|
||||
interface ReadableStream<R = any> {
|
||||
readonly locked: boolean;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
getReader(): ReadableStreamDefaultReader<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 }): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
||||
}
|
||||
const ReadableStream: {
|
||||
prototype: ReadableStream;
|
||||
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
||||
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
||||
};
|
||||
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
||||
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
||||
releaseLock(): void;
|
||||
}
|
||||
const ReadableStreamDefaultReader: {
|
||||
prototype: ReadableStreamDefaultReader;
|
||||
new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||
};
|
||||
const ReadableStreamBYOBReader: any;
|
||||
const ReadableStreamBYOBRequest: any;
|
||||
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 (label?: string, options?: TextDecoderOptions): TextDecoderStream;
|
||||
};
|
||||
}
|
||||
declare module 'node:stream/web' {
|
||||
export * from 'stream/web';
|
||||
}
|
70
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/string_decoder.d.ts
vendored
Normal file
70
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/string_decoder.d.ts
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `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
|
||||
* const { StringDecoder } = require('string_decoder');
|
||||
* ```
|
||||
*
|
||||
* The following example shows the basic use of the `StringDecoder` class.
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('string_decoder');
|
||||
* const decoder = new StringDecoder('utf8');
|
||||
*
|
||||
* const cent = Buffer.from([0xC2, 0xA2]);
|
||||
* console.log(decoder.write(cent));
|
||||
*
|
||||
* const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
||||
* console.log(decoder.write(euro));
|
||||
* ```
|
||||
*
|
||||
* 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
|
||||
* const { StringDecoder } = require('string_decoder');
|
||||
* const decoder = new StringDecoder('utf8');
|
||||
*
|
||||
* decoder.write(Buffer.from([0xE2]));
|
||||
* decoder.write(Buffer.from([0x82]));
|
||||
* console.log(decoder.end(Buffer.from([0xAC])));
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/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 A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
||||
*/
|
||||
write(buffer: Buffer): 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 A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
||||
*/
|
||||
end(buffer?: Buffer): string;
|
||||
}
|
||||
}
|
||||
declare module 'node:string_decoder' {
|
||||
export * from 'string_decoder';
|
||||
}
|
377
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/test.d.ts
vendored
Normal file
377
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/test.d.ts
vendored
Normal file
@ -0,0 +1,377 @@
|
||||
|
||||
/* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
|
||||
|
||||
/**
|
||||
* The `node:test` module provides a standalone testing module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.8.0/lib/test.js)
|
||||
*/
|
||||
declare module 'node:test' {
|
||||
/**
|
||||
* Programmatically start the test runner.
|
||||
* @since v18.9.0
|
||||
* @param options Configuration options for running tests.
|
||||
* @returns A {@link TapStream} that emits events about the test execution.
|
||||
*/
|
||||
function run(options?: RunOptions): TapStream;
|
||||
|
||||
/**
|
||||
* The `test()` function is the value imported from the test module. Each invocation of this
|
||||
* function results in the creation of a test point in the TAP output.
|
||||
*
|
||||
* The {@link TestContext} object passed to the fn argument can be used to perform actions
|
||||
* related to the current test. Examples include skipping the test, adding additional TAP
|
||||
* diagnostic information, or creating subtests.
|
||||
*
|
||||
* `test()` returns a {@link Promise} that resolves once the test completes. The return value
|
||||
* can usually be discarded for top level tests. However, the return value from subtests should
|
||||
* be used to prevent the parent test from finishing first and cancelling the subtest as shown
|
||||
* in the following example.
|
||||
*
|
||||
* ```js
|
||||
* test('top level test', async (t) => {
|
||||
* // The setTimeout() in the following subtest would cause it to outlive its
|
||||
* // parent test if 'await' is removed on the next line. Once the parent test
|
||||
* // completes, it will cancel any outstanding subtests.
|
||||
* await t.test('longer running subtest', async (t) => {
|
||||
* return new Promise((resolve, reject) => {
|
||||
* setTimeout(resolve, 1000);
|
||||
* });
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. The first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
||||
*/
|
||||
function test(name?: string, fn?: TestFn): Promise<void>;
|
||||
function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||
function test(fn?: TestFn): Promise<void>;
|
||||
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the suite, which is displayed when reporting suite results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the suite
|
||||
* @param fn The function under suite. Default: A no-op function.
|
||||
*/
|
||||
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
||||
function describe(name?: string, fn?: SuiteFn): void;
|
||||
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
||||
function describe(fn?: SuiteFn): void;
|
||||
|
||||
/**
|
||||
* @since v18.6.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
*/
|
||||
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
|
||||
function it(name?: string, fn?: ItFn): void;
|
||||
function it(options?: TestOptions, fn?: ItFn): void;
|
||||
function it(fn?: ItFn): void;
|
||||
|
||||
/**
|
||||
* The type of a function under test. The first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is passed as
|
||||
* the second argument.
|
||||
*/
|
||||
type TestFn = (t: TestContext, done: (result?: any) => void) => any;
|
||||
|
||||
/**
|
||||
* The type of a function under Suite.
|
||||
* If the test uses callbacks, the callback function is passed as an argument
|
||||
*/
|
||||
type SuiteFn = (done: (result?: any) => void) => void;
|
||||
|
||||
/**
|
||||
* The type of a function under test.
|
||||
* If the test uses callbacks, the callback function is passed as an argument
|
||||
*/
|
||||
type ItFn = (done: (result?: any) => void) => any;
|
||||
|
||||
interface RunOptions {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
concurrency?: number | boolean;
|
||||
|
||||
/**
|
||||
* An array containing the list of files to run. If unspecified, the test runner execution model will be used.
|
||||
*/
|
||||
files?: readonly string[];
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test.
|
||||
* @default undefined
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A successful call of the run() method will return a new TapStream object, streaming a TAP output.
|
||||
* TapStream will emit events in the order of the tests' definitions.
|
||||
* @since v18.9.0
|
||||
*/
|
||||
interface TapStream extends NodeJS.ReadableStream {
|
||||
addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
emit(event: 'test:diagnostic', message: string): boolean;
|
||||
emit(event: 'test:fail', data: TestFail): boolean;
|
||||
emit(event: 'test:pass', data: TestPass): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
on(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
||||
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
||||
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
interface TestFail {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The failure casing test to fail.
|
||||
*/
|
||||
error: Error;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
interface TestPass {
|
||||
/**
|
||||
* The test duration.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The test name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The ordinal number of the test.
|
||||
*/
|
||||
testNumber: number;
|
||||
|
||||
/**
|
||||
* Present if `context.todo` is called.
|
||||
*/
|
||||
todo?: string;
|
||||
|
||||
/**
|
||||
* Present if `context.skip` is called.
|
||||
*/
|
||||
skip?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of `TestContext` is passed to each test function in order to interact with the
|
||||
* test runner. However, the `TestContext` constructor is not exposed as part of the API.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
interface TestContext {
|
||||
/**
|
||||
* This function is used to write TAP diagnostics to the output. Any diagnostic information is
|
||||
* included at the end of the test's results. This function does not return a value.
|
||||
* @param message Message to be displayed as a TAP diagnostic.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
diagnostic(message: string): void;
|
||||
|
||||
/**
|
||||
* If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
|
||||
* option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
|
||||
* command-line option, this function is a no-op.
|
||||
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
runOnly(shouldRunOnlyTests: boolean): void;
|
||||
|
||||
/**
|
||||
* This function causes the test's output to indicate the test as skipped. If `message` is
|
||||
* provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
|
||||
* the test function. This function does not return a value.
|
||||
* @param message Optional skip message to be displayed in TAP output.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
skip(message?: string): void;
|
||||
|
||||
/**
|
||||
* This function adds a `TODO` directive to the test's output. If `message` is provided, it is
|
||||
* included in the TAP output. Calling `todo()` does not terminate execution of the test
|
||||
* function. This function does not return a value.
|
||||
* @param message Optional `TODO` message to be displayed in TAP output.
|
||||
* @since v18.0.0
|
||||
*/
|
||||
todo(message?: string): void;
|
||||
|
||||
/**
|
||||
* This function is used to create subtests under the current test. This function behaves in
|
||||
* the same fashion as the top level {@link test} function.
|
||||
* @since v18.0.0
|
||||
* @param name The name of the test, which is displayed when reporting test results.
|
||||
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||
* @param options Configuration options for the test
|
||||
* @param fn The function under test. This first argument to this function is a
|
||||
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
||||
* passed as the second argument. Default: A no-op function.
|
||||
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
||||
*/
|
||||
test: typeof test;
|
||||
}
|
||||
|
||||
interface TestOptions {
|
||||
/**
|
||||
* The number of tests that can be run at the same time. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default 1
|
||||
*/
|
||||
concurrency?: number;
|
||||
|
||||
/**
|
||||
* If truthy, and the test context is configured to run `only` tests, then this test will be
|
||||
* run. Otherwise, the test is skipped.
|
||||
* @default false
|
||||
*/
|
||||
only?: boolean;
|
||||
|
||||
/**
|
||||
* Allows aborting an in-progress test.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* If truthy, the test is skipped. If a string is provided, that string is displayed in the
|
||||
* test results as the reason for skipping the test.
|
||||
* @default false
|
||||
*/
|
||||
skip?: boolean | string;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
* @since v18.7.0
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
|
||||
* the test results as the reason why the test is `TODO`.
|
||||
* @default false
|
||||
*/
|
||||
todo?: boolean | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running before running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function before(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after running a suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function after(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running before each subtest of the current suite.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function beforeEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* This function is used to create a hook running after each subtest of the current test.
|
||||
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
||||
* the second argument. Default: A no-op function.
|
||||
* @param options Configuration options for the hook.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
function afterEach(fn?: HookFn, options?: HookOptions): void;
|
||||
|
||||
/**
|
||||
* The hook function. If the hook uses callbacks, the callback function is passed as the
|
||||
* second argument.
|
||||
*/
|
||||
type HookFn = (done: (result?: any) => void) => any;
|
||||
|
||||
/**
|
||||
* Configuration options for hooks.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
interface HookOptions {
|
||||
/**
|
||||
* Allows aborting an in-progress hook.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
|
||||
/**
|
||||
* A number of milliseconds the hook will fail after. If unspecified, subtests inherit this
|
||||
* value from their parent.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach };
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user