Merge branch 'dev' into resyn-dev
8
.github/workflows/tests.yml
vendored
@ -12,12 +12,11 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
permissions:
|
permissions:
|
||||||
checks: write # for coverallsapp/github-action to create new checks
|
|
||||||
contents: read # for actions/checkout to fetch code
|
contents: read # for actions/checkout to fetch code
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16, 18, 20]
|
node-version: [18, 20]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
@ -29,8 +28,3 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
npm run test
|
npm run test
|
||||||
# - name: Publish to coveralls.io
|
|
||||||
# if: ${{ matrix.node-version == 16 }}
|
|
||||||
# uses: coverallsapp/github-action@v1.1.2
|
|
||||||
# with:
|
|
||||||
# github-token: ${{ github.token }}
|
|
||||||
|
31
CHANGELOG.md
@ -1,3 +1,34 @@
|
|||||||
|
#### 4.0.0-beta.1: Beta Release
|
||||||
|
|
||||||
|
Editor
|
||||||
|
|
||||||
|
- Click on id in debug panel highlights node or flow (#4439) @ralphwetzel
|
||||||
|
- Support config selection in a subflow env var (#4587) @Steve-Mcl
|
||||||
|
- Add timestamp formatting options to TypedInput (#4468) @knolleary
|
||||||
|
- Allow RED.view.select to select links (#4553) @lgrkvst
|
||||||
|
- Add auto-complete to flow/global/env typedInput types (#4480) @knolleary
|
||||||
|
- Improve the appearance of the Node-RED primary header (#4598) @joepavitt
|
||||||
|
|
||||||
|
Runtime
|
||||||
|
|
||||||
|
- let settings.httpNodeAuth accept single middleware or array of middlewares (#4572) @kevinGodell
|
||||||
|
- Upgrade to JSONata 2.x (#4590) @knolleary
|
||||||
|
- Bump minimum version to node 18 (#4571) @knolleary
|
||||||
|
- npm: Remove production flag on npm invocation (#4347) @ZJvandeWeg
|
||||||
|
- Timer testing fix (#4367) @hlovdal
|
||||||
|
- Bump to 4.0.0-dev (#4322) @knolleary
|
||||||
|
|
||||||
|
Nodes
|
||||||
|
|
||||||
|
- TCP node - when resetting, if no payload, stay disconnected @dceejay
|
||||||
|
- HTML node: add option for collecting attributes and content (#4513) @gorenje
|
||||||
|
- let split node specify property to split on, and join auto join correctly (#4386) @dceejay
|
||||||
|
- Add RFC4180 compliant mode to CSV node (#4540) @Steve-Mcl
|
||||||
|
- Fix change node to return boolean if asked (#4525) @dceejay
|
||||||
|
- Let msg.reset reset Tcp request node connection when in stay connected mode (#4406) @dceejay
|
||||||
|
- Let debug node status msg length be settable via settings (#4402) @dceejay
|
||||||
|
- Feat: Add ability to set headers for WebSocket client (#4436) @marcus-j-davies
|
||||||
|
|
||||||
#### 3.1.8: Maintenance Release
|
#### 3.1.8: Maintenance Release
|
||||||
|
|
||||||
- Add validation and error handling on subflow instance properties (#4632) @knolleary
|
- Add validation and error handling on subflow instance properties (#4632) @knolleary
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red",
|
"name": "node-red",
|
||||||
"version": "3.1.8",
|
"version": "4.0.0-beta.1",
|
||||||
"description": "Low-code programming for event-driven applications",
|
"description": "Low-code programming for event-driven applications",
|
||||||
"homepage": "https://nodered.org",
|
"homepage": "https://nodered.org",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@ -54,7 +54,7 @@
|
|||||||
"is-utf8": "0.2.1",
|
"is-utf8": "0.2.1",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"json-stringify-safe": "5.0.1",
|
"json-stringify-safe": "5.0.1",
|
||||||
"jsonata": "1.8.7",
|
"jsonata": "2.0.4",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"media-typer": "1.1.0",
|
"media-typer": "1.1.0",
|
||||||
"memorystore": "1.6.7",
|
"memorystore": "1.6.7",
|
||||||
@ -122,6 +122,6 @@
|
|||||||
"supertest": "6.3.3"
|
"supertest": "6.3.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,9 @@ module.exports = {
|
|||||||
store: req.query['store'],
|
store: req.query['store'],
|
||||||
req: apiUtils.getRequestLogObject(req)
|
req: apiUtils.getRequestLogObject(req)
|
||||||
}
|
}
|
||||||
|
if (req.query['keysOnly'] !== undefined) {
|
||||||
|
opts.keysOnly = true
|
||||||
|
}
|
||||||
runtimeAPI.context.getValue(opts).then(function(result) {
|
runtimeAPI.context.getValue(opts).then(function(result) {
|
||||||
res.json(result);
|
res.json(result);
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
|
@ -91,6 +91,7 @@ module.exports = {
|
|||||||
// Plugins
|
// Plugins
|
||||||
adminApp.get("/plugins", needsPermission("plugins.read"), plugins.getAll, apiUtil.errorHandler);
|
adminApp.get("/plugins", needsPermission("plugins.read"), plugins.getAll, apiUtil.errorHandler);
|
||||||
adminApp.get("/plugins/messages", needsPermission("plugins.read"), plugins.getCatalogs, 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);
|
adminApp.get("/diagnostics", needsPermission("diagnostics.read"), diagnostics.getReport, apiUtil.errorHandler);
|
||||||
|
|
||||||
|
@ -40,5 +40,31 @@ module.exports = {
|
|||||||
console.log(err.stack);
|
console.log(err.stack);
|
||||||
apiUtils.rejectHandler(req,res,err);
|
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);
|
log.trace("comms.close "+self.session);
|
||||||
removeActiveConnection(self);
|
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) {
|
ws.on('message', function(data,flags) {
|
||||||
var msg = null;
|
var msg = null;
|
||||||
try {
|
try {
|
||||||
@ -86,68 +133,34 @@ function CommsConnection(ws, user) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!pendingAuth) {
|
if (!pendingAuth) {
|
||||||
if (msg.subscribe) {
|
if (msg.auth) {
|
||||||
|
handleAuthPacket(msg)
|
||||||
|
} else if (msg.subscribe) {
|
||||||
self.subscribe(msg.subscribe);
|
self.subscribe(msg.subscribe);
|
||||||
// handleRemoteSubscription(ws,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 {
|
} 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) {
|
if (msg.auth) {
|
||||||
Tokens.get(msg.auth).then(function(client) {
|
handleAuthPacket(msg)
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if (anonymousUser) {
|
if (anonymousUser) {
|
||||||
log.audit({event: "comms.auth",user:anonymousUser});
|
log.audit({event: "comms.auth",user:anonymousUser});
|
||||||
self.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
|
//TODO: duplicated code - pull non-auth message handling out
|
||||||
if (msg.subscribe) {
|
if (msg.subscribe) {
|
||||||
self.subscribe(msg.subscribe);
|
self.subscribe(msg.subscribe);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.audit({event: "comms.auth.fail"});
|
log.audit({event: "comms.auth.fail"});
|
||||||
completeConnection(null,null,false);
|
completeConnection(msg, null,null,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@node-red/editor-api",
|
"name": "@node-red/editor-api",
|
||||||
"version": "3.1.8",
|
"version": "4.0.0-beta.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -16,8 +16,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@node-red/util": "3.1.8",
|
"@node-red/util": "4.0.0-beta.1",
|
||||||
"@node-red/editor-client": "3.1.8",
|
"@node-red/editor-client": "4.0.0-beta.1",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"body-parser": "1.20.2",
|
"body-parser": "1.20.2",
|
||||||
"clone": "2.1.2",
|
"clone": "2.1.2",
|
||||||
|
@ -590,6 +590,8 @@
|
|||||||
},
|
},
|
||||||
"nodeCount": "__label__ Node",
|
"nodeCount": "__label__ Node",
|
||||||
"nodeCount_plural": "__label__ Nodes",
|
"nodeCount_plural": "__label__ Nodes",
|
||||||
|
"pluginCount": "__count__ Plugin",
|
||||||
|
"pluginCount_plural": "__count__ Plugins",
|
||||||
"moduleCount": "__count__ Modul verfügbar",
|
"moduleCount": "__count__ Modul verfügbar",
|
||||||
"moduleCount_plural": "__count__ Module verfügbar",
|
"moduleCount_plural": "__count__ Module verfügbar",
|
||||||
"inuse": "In Gebrauch",
|
"inuse": "In Gebrauch",
|
||||||
|
@ -614,6 +614,8 @@
|
|||||||
},
|
},
|
||||||
"nodeCount": "__label__ node",
|
"nodeCount": "__label__ node",
|
||||||
"nodeCount_plural": "__label__ nodes",
|
"nodeCount_plural": "__label__ nodes",
|
||||||
|
"pluginCount": "__count__ plugin",
|
||||||
|
"pluginCount_plural": "__count__ plugins",
|
||||||
"moduleCount": "__count__ module available",
|
"moduleCount": "__count__ module available",
|
||||||
"moduleCount_plural": "__count__ modules available",
|
"moduleCount_plural": "__count__ modules available",
|
||||||
"inuse": "in use",
|
"inuse": "in use",
|
||||||
@ -924,7 +926,14 @@
|
|||||||
"date": "timestamp",
|
"date": "timestamp",
|
||||||
"jsonata": "expression",
|
"jsonata": "expression",
|
||||||
"env": "env variable",
|
"env": "env variable",
|
||||||
"cred": "credential"
|
"cred": "credential",
|
||||||
|
"conf-types": "config node"
|
||||||
|
},
|
||||||
|
"date": {
|
||||||
|
"format": {
|
||||||
|
"timestamp": "milliseconds since epoch",
|
||||||
|
"object": "JavaScript Date Object"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editableList": {
|
"editableList": {
|
||||||
|
@ -924,7 +924,14 @@
|
|||||||
"date": "horodatage",
|
"date": "horodatage",
|
||||||
"jsonata": "expression",
|
"jsonata": "expression",
|
||||||
"env": "variable d'environnement",
|
"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": {
|
"editableList": {
|
||||||
|
@ -924,7 +924,14 @@
|
|||||||
"date": "日時",
|
"date": "日時",
|
||||||
"jsonata": "JSONata式",
|
"jsonata": "JSONata式",
|
||||||
"env": "環境変数",
|
"env": "環境変数",
|
||||||
"cred": "認証情報"
|
"cred": "認証情報",
|
||||||
|
"conf-types": "設定ノード"
|
||||||
|
},
|
||||||
|
"date": {
|
||||||
|
"format": {
|
||||||
|
"timestamp": "エポックからの経過ミリ秒",
|
||||||
|
"object": "JavaScript日付オブジェクト"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editableList": {
|
"editableList": {
|
||||||
@ -1230,7 +1237,7 @@
|
|||||||
},
|
},
|
||||||
"env-var": {
|
"env-var": {
|
||||||
"environment": "環境変数",
|
"environment": "環境変数",
|
||||||
"header": "大域環境変数",
|
"header": "グローバル環境変数",
|
||||||
"revert": "破棄"
|
"revert": "破棄"
|
||||||
},
|
},
|
||||||
"action-list": {
|
"action-list": {
|
||||||
@ -1382,7 +1389,7 @@
|
|||||||
"copy-item-edit-url": "要素の編集URLをコピー",
|
"copy-item-edit-url": "要素の編集URLをコピー",
|
||||||
"move-flow-to-start": "フローを先頭に移動",
|
"move-flow-to-start": "フローを先頭に移動",
|
||||||
"move-flow-to-end": "フローを末尾に移動",
|
"move-flow-to-end": "フローを末尾に移動",
|
||||||
"show-global-env": "大域環境変数を表示",
|
"show-global-env": "グローバル環境変数を表示",
|
||||||
"lock-flow": "フローを固定",
|
"lock-flow": "フローを固定",
|
||||||
"unlock-flow": "フローの固定を解除",
|
"unlock-flow": "フローの固定を解除",
|
||||||
"show-node-help": "ノードのヘルプを表示"
|
"show-node-help": "ノードのヘルプを表示"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@node-red/editor-client",
|
"name": "@node-red/editor-client",
|
||||||
"version": "3.1.8",
|
"version": "4.0.0-beta.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -26,6 +26,15 @@ RED.comms = (function() {
|
|||||||
var reconnectAttempts = 0;
|
var reconnectAttempts = 0;
|
||||||
var active = false;
|
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() {
|
function connectWS() {
|
||||||
active = true;
|
active = true;
|
||||||
var wspath;
|
var wspath;
|
||||||
@ -56,6 +65,7 @@ RED.comms = (function() {
|
|||||||
ws.send(JSON.stringify({subscribe:t}));
|
ws.send(JSON.stringify({subscribe:t}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emit('connect')
|
||||||
}
|
}
|
||||||
|
|
||||||
ws = new WebSocket(wspath);
|
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 {
|
return {
|
||||||
connect: connectWS,
|
connect: connectWS,
|
||||||
subscribe: subscribe,
|
subscribe: subscribe,
|
||||||
unsubscribe:unsubscribe
|
unsubscribe:unsubscribe,
|
||||||
|
on,
|
||||||
|
off,
|
||||||
|
send
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -91,6 +91,31 @@ RED.nodes = (function() {
|
|||||||
getNodeTypes: function() {
|
getNodeTypes: function() {
|
||||||
return Object.keys(nodeDefinitions);
|
return Object.keys(nodeDefinitions);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get an array of node definitions
|
||||||
|
* @param {Object} options - options object
|
||||||
|
* @param {boolean} [options.configOnly] - if true, only return config nodes
|
||||||
|
* @param {function} [options.filter] - a filter function to apply to the list of nodes
|
||||||
|
* @returns array of node definitions
|
||||||
|
*/
|
||||||
|
getNodeDefinitions: function(options) {
|
||||||
|
const result = []
|
||||||
|
const configOnly = (options && options.configOnly)
|
||||||
|
const filter = (options && options.filter)
|
||||||
|
const keys = Object.keys(nodeDefinitions)
|
||||||
|
for (const key of keys) {
|
||||||
|
const def = nodeDefinitions[key]
|
||||||
|
if(!def) { continue }
|
||||||
|
if (configOnly && def.category !== "config") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (filter && !filter(nodeDefinitions[key])) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
result.push(nodeDefinitions[key])
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
},
|
||||||
setNodeList: function(list) {
|
setNodeList: function(list) {
|
||||||
nodeList = [];
|
nodeList = [];
|
||||||
for(var i=0;i<list.length;i++) {
|
for(var i=0;i<list.length;i++) {
|
||||||
@ -124,6 +149,8 @@ RED.nodes = (function() {
|
|||||||
},
|
},
|
||||||
removeNodeSet: function(id) {
|
removeNodeSet: function(id) {
|
||||||
var ns = nodeSets[id];
|
var ns = nodeSets[id];
|
||||||
|
if (!ns) { return {} }
|
||||||
|
|
||||||
for (var j=0;j<ns.types.length;j++) {
|
for (var j=0;j<ns.types.length;j++) {
|
||||||
delete typeToId[ns.types[j]];
|
delete typeToId[ns.types[j]];
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
RED.plugins = (function() {
|
RED.plugins = (function() {
|
||||||
var plugins = {};
|
var plugins = {};
|
||||||
var pluginsByType = {};
|
var pluginsByType = {};
|
||||||
|
var moduleList = {};
|
||||||
|
|
||||||
function registerPlugin(id,definition) {
|
function registerPlugin(id,definition) {
|
||||||
plugins[id] = definition;
|
plugins[id] = definition;
|
||||||
@ -38,9 +39,43 @@ RED.plugins = (function() {
|
|||||||
function getPluginsByType(type) {
|
function getPluginsByType(type) {
|
||||||
return pluginsByType[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 {
|
return {
|
||||||
registerPlugin: registerPlugin,
|
registerPlugin: registerPlugin,
|
||||||
getPlugin: getPlugin,
|
getPlugin: getPlugin,
|
||||||
getPluginsByType: getPluginsByType
|
getPluginsByType: getPluginsByType,
|
||||||
|
|
||||||
|
setPluginList: setPluginList,
|
||||||
|
addPlugin: addPlugin,
|
||||||
|
getModule: getModule
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -25,6 +25,7 @@ var RED = (function() {
|
|||||||
cache: false,
|
cache: false,
|
||||||
url: 'plugins',
|
url: 'plugins',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
RED.plugins.setPluginList(data);
|
||||||
loader.reportProgress(RED._("event.loadPlugins"), 13)
|
loader.reportProgress(RED._("event.loadPlugins"), 13)
|
||||||
RED.i18n.loadPluginCatalogs(function() {
|
RED.i18n.loadPluginCatalogs(function() {
|
||||||
loadPlugins(function() {
|
loadPlugins(function() {
|
||||||
@ -534,6 +535,41 @@ var RED = (function() {
|
|||||||
RED.view.redrawStatus(node);
|
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 pendingNodeRemovedNotifications = []
|
||||||
let pendingNodeRemovedTimeout
|
let pendingNodeRemovedTimeout
|
||||||
|
@ -174,12 +174,24 @@
|
|||||||
this.uiContainer.width(m[1]);
|
this.uiContainer.width(m[1]);
|
||||||
}
|
}
|
||||||
if (this.options.sortable) {
|
if (this.options.sortable) {
|
||||||
|
var isCanceled = false; // Flag to track if an item has been canceled from being dropped into a different list
|
||||||
|
var noDrop = false; // Flag to track if an item is being dragged into a different list
|
||||||
var handle = (typeof this.options.sortable === 'string')?
|
var handle = (typeof this.options.sortable === 'string')?
|
||||||
this.options.sortable :
|
this.options.sortable :
|
||||||
".red-ui-editableList-item-handle";
|
".red-ui-editableList-item-handle";
|
||||||
var sortOptions = {
|
var sortOptions = {
|
||||||
axis: "y",
|
axis: "y",
|
||||||
update: function( event, ui ) {
|
update: function( event, ui ) {
|
||||||
|
// dont trigger update if the item is being canceled
|
||||||
|
const targetList = $(event.target);
|
||||||
|
const draggedItem = ui.item;
|
||||||
|
const draggedItemParent = draggedItem.parent();
|
||||||
|
if (!targetList.is(draggedItemParent) && draggedItem.hasClass("red-ui-editableList-item-constrained")) {
|
||||||
|
noDrop = true;
|
||||||
|
}
|
||||||
|
if (isCanceled || noDrop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (that.options.sortItems) {
|
if (that.options.sortItems) {
|
||||||
that.options.sortItems(that.items());
|
that.options.sortItems(that.items());
|
||||||
}
|
}
|
||||||
@ -189,8 +201,32 @@
|
|||||||
tolerance: "pointer",
|
tolerance: "pointer",
|
||||||
forcePlaceholderSize:true,
|
forcePlaceholderSize:true,
|
||||||
placeholder: "red-ui-editabelList-item-placeholder",
|
placeholder: "red-ui-editabelList-item-placeholder",
|
||||||
start: function(e, ui){
|
start: function (event, ui) {
|
||||||
ui.placeholder.height(ui.item.height()-4);
|
isCanceled = false;
|
||||||
|
ui.placeholder.height(ui.item.height() - 4);
|
||||||
|
ui.item.css('cursor', 'grabbing'); // TODO: this doesn't seem to work, use a class instead?
|
||||||
|
},
|
||||||
|
stop: function (event, ui) {
|
||||||
|
ui.item.css('cursor', 'auto');
|
||||||
|
},
|
||||||
|
receive: function (event, ui) {
|
||||||
|
if (ui.item.hasClass("red-ui-editableList-item-constrained")) {
|
||||||
|
isCanceled = true;
|
||||||
|
$(ui.sender).sortable('cancel');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
over: function (event, ui) {
|
||||||
|
// if the dragged item is constrained, prevent it from being dropped into a different list
|
||||||
|
const targetList = $(event.target);
|
||||||
|
const draggedItem = ui.item;
|
||||||
|
const draggedItemParent = draggedItem.parent();
|
||||||
|
if (!targetList.is(draggedItemParent) && draggedItem.hasClass("red-ui-editableList-item-constrained")) {
|
||||||
|
noDrop = true;
|
||||||
|
draggedItem.css('cursor', 'no-drop'); // TODO: this doesn't seem to work, use a class instead?
|
||||||
|
} else {
|
||||||
|
noDrop = false;
|
||||||
|
draggedItem.css('cursor', 'grabbing'); // TODO: this doesn't seem to work, use a class instead?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (this.options.connectWith) {
|
if (this.options.connectWith) {
|
||||||
|
@ -54,25 +54,26 @@
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoComplete = function(options) {
|
function getMatch(value, searchValue) {
|
||||||
function getMatch(value, searchValue) {
|
const idx = value.toLowerCase().indexOf(searchValue.toLowerCase());
|
||||||
const idx = value.toLowerCase().indexOf(searchValue.toLowerCase());
|
const len = idx > -1 ? searchValue.length : 0;
|
||||||
const len = idx > -1 ? searchValue.length : 0;
|
return {
|
||||||
return {
|
index: idx,
|
||||||
index: idx,
|
found: idx > -1,
|
||||||
found: idx > -1,
|
pre: value.substring(0,idx),
|
||||||
pre: value.substring(0,idx),
|
match: value.substring(idx,idx+len),
|
||||||
match: value.substring(idx,idx+len),
|
post: value.substring(idx+len),
|
||||||
post: value.substring(idx+len),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function generateSpans(match) {
|
|
||||||
const els = [];
|
|
||||||
if(match.pre) { els.push($('<span/>').text(match.pre)); }
|
|
||||||
if(match.match) { els.push($('<span/>',{style:"font-weight: bold; color: var(--red-ui-text-color-link);"}).text(match.match)); }
|
|
||||||
if(match.post) { els.push($('<span/>').text(match.post)); }
|
|
||||||
return els;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
function generateSpans(match) {
|
||||||
|
const els = [];
|
||||||
|
if(match.pre) { els.push($('<span/>').text(match.pre)); }
|
||||||
|
if(match.match) { els.push($('<span/>',{style:"font-weight: bold; color: var(--red-ui-text-color-link);"}).text(match.match)); }
|
||||||
|
if(match.post) { els.push($('<span/>').text(match.post)); }
|
||||||
|
return els;
|
||||||
|
}
|
||||||
|
|
||||||
|
const msgAutoComplete = function(options) {
|
||||||
return function(val) {
|
return function(val) {
|
||||||
var matches = [];
|
var matches = [];
|
||||||
options.forEach(opt => {
|
options.forEach(opt => {
|
||||||
@ -102,6 +103,197 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEnvVars (obj, envVars = {}) {
|
||||||
|
contextKnownKeys.env = contextKnownKeys.env || {}
|
||||||
|
if (contextKnownKeys.env[obj.id]) {
|
||||||
|
return contextKnownKeys.env[obj.id]
|
||||||
|
}
|
||||||
|
let parent
|
||||||
|
if (obj.type === 'tab' || obj.type === 'subflow') {
|
||||||
|
RED.nodes.eachConfig(function (conf) {
|
||||||
|
if (conf.type === "global-config") {
|
||||||
|
parent = conf;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (obj.g) {
|
||||||
|
parent = RED.nodes.group(obj.g)
|
||||||
|
} else if (obj.z) {
|
||||||
|
parent = RED.nodes.workspace(obj.z) || RED.nodes.subflow(obj.z)
|
||||||
|
}
|
||||||
|
if (parent) {
|
||||||
|
getEnvVars(parent, envVars)
|
||||||
|
}
|
||||||
|
if (obj.env) {
|
||||||
|
obj.env.forEach(env => {
|
||||||
|
envVars[env.name] = obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
contextKnownKeys.env[obj.id] = envVars
|
||||||
|
return envVars
|
||||||
|
}
|
||||||
|
|
||||||
|
const envAutoComplete = function (val) {
|
||||||
|
const editStack = RED.editor.getEditStack()
|
||||||
|
if (editStack.length === 0) {
|
||||||
|
done([])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const editingNode = editStack.pop()
|
||||||
|
if (!editingNode) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const envVarsMap = getEnvVars(editingNode)
|
||||||
|
const envVars = Object.keys(envVarsMap)
|
||||||
|
const matches = []
|
||||||
|
const i = val.lastIndexOf('${')
|
||||||
|
let searchKey = val
|
||||||
|
let isSubkey = false
|
||||||
|
if (i > -1) {
|
||||||
|
if (val.lastIndexOf('}') < i) {
|
||||||
|
searchKey = val.substring(i+2)
|
||||||
|
isSubkey = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
envVars.forEach(v => {
|
||||||
|
let valMatch = getMatch(v, searchKey);
|
||||||
|
if (valMatch.found) {
|
||||||
|
const optSrc = envVarsMap[v]
|
||||||
|
const element = $('<div>',{style: "display: flex"});
|
||||||
|
const valEl = $('<div/>',{style:"font-family: var(--red-ui-monospace-font); white-space:nowrap; overflow: hidden; flex-grow:1"});
|
||||||
|
valEl.append(generateSpans(valMatch))
|
||||||
|
valEl.appendTo(element)
|
||||||
|
|
||||||
|
if (optSrc) {
|
||||||
|
const optEl = $('<div>').css({ "font-size": "0.8em" });
|
||||||
|
let label
|
||||||
|
if (optSrc.type === 'global-config') {
|
||||||
|
label = RED._('sidebar.context.global')
|
||||||
|
} else if (optSrc.type === 'group') {
|
||||||
|
label = RED.utils.getNodeLabel(optSrc) || (RED._('sidebar.info.group') + ': '+optSrc.id)
|
||||||
|
} else {
|
||||||
|
label = RED.utils.getNodeLabel(optSrc) || optSrc.id
|
||||||
|
}
|
||||||
|
|
||||||
|
optEl.append(generateSpans({ match: label }));
|
||||||
|
optEl.appendTo(element);
|
||||||
|
}
|
||||||
|
matches.push({
|
||||||
|
value: isSubkey ? val + v + '}' : v,
|
||||||
|
label: element,
|
||||||
|
i: valMatch.index
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
matches.sort(function(A,B){return A.i-B.i})
|
||||||
|
return matches
|
||||||
|
}
|
||||||
|
|
||||||
|
let contextKnownKeys = {}
|
||||||
|
let contextCache = {}
|
||||||
|
if (RED.events) {
|
||||||
|
RED.events.on("editor:close", function () {
|
||||||
|
contextCache = {}
|
||||||
|
contextKnownKeys = {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextAutoComplete = function() {
|
||||||
|
const that = this
|
||||||
|
const getContextKeysFromRuntime = function(scope, store, searchKey, done) {
|
||||||
|
contextKnownKeys[scope] = contextKnownKeys[scope] || {}
|
||||||
|
contextKnownKeys[scope][store] = contextKnownKeys[scope][store] || new Set()
|
||||||
|
if (searchKey.length > 0) {
|
||||||
|
try {
|
||||||
|
RED.utils.normalisePropertyExpression(searchKey)
|
||||||
|
} catch (err) {
|
||||||
|
// Not a valid context key, so don't try looking up
|
||||||
|
done()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const url = `context/${scope}/${encodeURIComponent(searchKey)}?store=${store}&keysOnly`
|
||||||
|
if (contextCache[url]) {
|
||||||
|
// console.log('CACHED', url)
|
||||||
|
done()
|
||||||
|
} else {
|
||||||
|
// console.log('GET', url)
|
||||||
|
$.getJSON(url, function(data) {
|
||||||
|
// console.log(data)
|
||||||
|
contextCache[url] = true
|
||||||
|
const result = data[store] || {}
|
||||||
|
const keys = result.keys || []
|
||||||
|
const keyPrefix = searchKey + (searchKey.length > 0 ? '.' : '')
|
||||||
|
keys.forEach(key => {
|
||||||
|
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(key)) {
|
||||||
|
contextKnownKeys[scope][store].add(keyPrefix + key)
|
||||||
|
} else {
|
||||||
|
contextKnownKeys[scope][store].add(searchKey + "[\""+key.replace(/"/,"\\\"")+"\"]")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const getContextKeys = function(key, done) {
|
||||||
|
const keyParts = key.split('.')
|
||||||
|
const partialKey = keyParts.pop()
|
||||||
|
let scope = that.propertyType
|
||||||
|
if (scope === 'flow') {
|
||||||
|
// Get the flow id of the node we're editing
|
||||||
|
const editStack = RED.editor.getEditStack()
|
||||||
|
if (editStack.length === 0) {
|
||||||
|
done([])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const editingNode = editStack.pop()
|
||||||
|
if (editingNode.z) {
|
||||||
|
scope = `${scope}/${editingNode.z}`
|
||||||
|
} else {
|
||||||
|
done([])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const store = (contextStoreOptions.length === 1) ? contextStoreOptions[0].value : that.optionValue
|
||||||
|
const searchKey = keyParts.join('.')
|
||||||
|
|
||||||
|
getContextKeysFromRuntime(scope, store, searchKey, function() {
|
||||||
|
if (contextKnownKeys[scope][store].has(key) || key.endsWith(']')) {
|
||||||
|
getContextKeysFromRuntime(scope, store, key, function() {
|
||||||
|
done(contextKnownKeys[scope][store])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
done(contextKnownKeys[scope][store])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return function(val, done) {
|
||||||
|
getContextKeys(val, function (keys) {
|
||||||
|
const matches = []
|
||||||
|
keys.forEach(v => {
|
||||||
|
let optVal = v
|
||||||
|
let valMatch = getMatch(optVal, val);
|
||||||
|
if (!valMatch.found && val.length > 0 && val.endsWith('.')) {
|
||||||
|
// Search key ends in '.' - but doesn't match. Check again
|
||||||
|
// with [" at the end instead so we match bracket notation
|
||||||
|
valMatch = getMatch(optVal, val.substring(0, val.length - 1) + '["')
|
||||||
|
}
|
||||||
|
if (valMatch.found) {
|
||||||
|
const element = $('<div>',{style: "display: flex"});
|
||||||
|
const valEl = $('<div/>',{style:"font-family: var(--red-ui-monospace-font); white-space:nowrap; overflow: hidden; flex-grow:1"});
|
||||||
|
valEl.append(generateSpans(valMatch))
|
||||||
|
valEl.appendTo(element)
|
||||||
|
matches.push({
|
||||||
|
value: optVal,
|
||||||
|
label: element,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
matches.sort(function(a, b) { return a.value.localeCompare(b.value) });
|
||||||
|
done(matches);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This is a hand-generated list of completions for the core nodes (based on the node help html).
|
// This is a hand-generated list of completions for the core nodes (based on the node help html).
|
||||||
var msgCompletions = [
|
var msgCompletions = [
|
||||||
{ value: "payload" },
|
{ value: "payload" },
|
||||||
@ -166,20 +358,22 @@
|
|||||||
{ value: "_session", source: ["websocket out","tcp out"] },
|
{ value: "_session", source: ["websocket out","tcp out"] },
|
||||||
]
|
]
|
||||||
var allOptions = {
|
var allOptions = {
|
||||||
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression, autoComplete: autoComplete(msgCompletions)},
|
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression, autoComplete: msgAutoComplete(msgCompletions)},
|
||||||
flow: {value:"flow",label:"flow.",hasValue:true,
|
flow: {value:"flow",label:"flow.",hasValue:true,
|
||||||
options:[],
|
options:[],
|
||||||
validate:RED.utils.validatePropertyExpression,
|
validate:RED.utils.validatePropertyExpression,
|
||||||
parse: contextParse,
|
parse: contextParse,
|
||||||
export: contextExport,
|
export: contextExport,
|
||||||
valueLabel: contextLabel
|
valueLabel: contextLabel,
|
||||||
|
autoComplete: contextAutoComplete
|
||||||
},
|
},
|
||||||
global: {value:"global",label:"global.",hasValue:true,
|
global: {value:"global",label:"global.",hasValue:true,
|
||||||
options:[],
|
options:[],
|
||||||
validate:RED.utils.validatePropertyExpression,
|
validate:RED.utils.validatePropertyExpression,
|
||||||
parse: contextParse,
|
parse: contextParse,
|
||||||
export: contextExport,
|
export: contextExport,
|
||||||
valueLabel: contextLabel
|
valueLabel: contextLabel,
|
||||||
|
autoComplete: contextAutoComplete
|
||||||
},
|
},
|
||||||
str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"},
|
str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"},
|
||||||
num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate: function(v) {
|
num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate: function(v) {
|
||||||
@ -214,7 +408,25 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.svg"},
|
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.svg"},
|
||||||
date: {value:"date",label:"timestamp",icon:"fa fa-clock-o",hasValue:false},
|
date: {
|
||||||
|
value:"date",
|
||||||
|
label:"timestamp",
|
||||||
|
icon:"fa fa-clock-o",
|
||||||
|
options:[
|
||||||
|
{
|
||||||
|
label: 'milliseconds since epoch',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'YYYY-MM-DDTHH:mm:ss.sssZ',
|
||||||
|
value: 'iso'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'JavaScript Date Object',
|
||||||
|
value: 'object'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
jsonata: {
|
jsonata: {
|
||||||
value: "jsonata",
|
value: "jsonata",
|
||||||
label: "expression",
|
label: "expression",
|
||||||
@ -251,7 +463,8 @@
|
|||||||
env: {
|
env: {
|
||||||
value: "env",
|
value: "env",
|
||||||
label: "env variable",
|
label: "env variable",
|
||||||
icon: "red/images/typedInput/env.svg"
|
icon: "red/images/typedInput/env.svg",
|
||||||
|
autoComplete: envAutoComplete
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
value: "node",
|
value: "node",
|
||||||
@ -383,18 +596,75 @@
|
|||||||
eyeButton.show();
|
eyeButton.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'conf-types': {
|
||||||
|
value: "conf-types",
|
||||||
|
label: "config",
|
||||||
|
icon: "fa fa-cog",
|
||||||
|
// hasValue: false,
|
||||||
|
valueLabel: function (container, value) {
|
||||||
|
// get the selected option (for access to the "name" and "module" properties)
|
||||||
|
const _options = this._optionsCache || this.typeList.find(opt => opt.value === value)?.options || []
|
||||||
|
const selectedOption = _options.find(opt => opt.value === value) || {
|
||||||
|
title: '',
|
||||||
|
name: '',
|
||||||
|
module: ''
|
||||||
|
}
|
||||||
|
container.attr("title", selectedOption.title) // set tooltip to the full path/id of the module/node
|
||||||
|
container.text(selectedOption.name) // apply the "name" of the selected option
|
||||||
|
// set "line-height" such as to make the "name" appear further up, giving room for the "module" to be displayed below the value
|
||||||
|
container.css("line-height", "1.4em")
|
||||||
|
// add the module name in smaller, lighter font below the value
|
||||||
|
$('<div></div>').text(selectedOption.module).css({
|
||||||
|
// "font-family": "var(--red-ui-monospace-font)",
|
||||||
|
color: "var(--red-ui-tertiary-text-color)",
|
||||||
|
"font-size": "0.8em",
|
||||||
|
"line-height": "1em",
|
||||||
|
opacity: 0.8
|
||||||
|
}).appendTo(container);
|
||||||
|
},
|
||||||
|
// hasValue: false,
|
||||||
|
options: function () {
|
||||||
|
if (this._optionsCache) {
|
||||||
|
return this._optionsCache
|
||||||
|
}
|
||||||
|
const configNodes = RED.nodes.registry.getNodeDefinitions({configOnly: true, filter: (def) => def.type !== "global-config"}).map((def) => {
|
||||||
|
// create a container with with 2 rows (row 1 for the name, row 2 for the module name in smaller, lighter font)
|
||||||
|
const container = $('<div style="display: flex; flex-direction: column; justify-content: space-between; row-gap: 1px;">')
|
||||||
|
const row1Name = $('<div>').text(def.type)
|
||||||
|
const row2Module = $('<div style="font-size: 0.8em; color: var(--red-ui-tertiary-text-color);">').text(def.set.module)
|
||||||
|
container.append(row1Name, row2Module)
|
||||||
|
|
||||||
|
return {
|
||||||
|
value: def.type,
|
||||||
|
name: def.type,
|
||||||
|
enabled: def.set.enabled ?? true,
|
||||||
|
local: def.set.local,
|
||||||
|
title: def.set.id, // tooltip e.g. "node-red-contrib-foo/bar"
|
||||||
|
module: def.set.module,
|
||||||
|
icon: container[0].outerHTML.trim(), // the typeInput will interpret this as html text and render it in the anchor
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this._optionsCache = configNodes
|
||||||
|
return configNodes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// For a type with options, check value is a valid selection
|
// For a type with options, check value is a valid selection
|
||||||
// If !opt.multiple, returns the valid option object
|
// If !opt.multiple, returns the valid option object
|
||||||
// if opt.multiple, returns an array of valid option objects
|
// if opt.multiple, returns an array of valid option objects
|
||||||
// If not valid, returns null;
|
// If not valid, returns null;
|
||||||
|
|
||||||
function isOptionValueValid(opt, currentVal) {
|
function isOptionValueValid(opt, currentVal) {
|
||||||
|
let _options = opt.options
|
||||||
|
if (typeof _options === "function") {
|
||||||
|
_options = _options.call(this)
|
||||||
|
}
|
||||||
if (!opt.multiple) {
|
if (!opt.multiple) {
|
||||||
for (var i=0;i<opt.options.length;i++) {
|
for (var i=0;i<_options.length;i++) {
|
||||||
op = opt.options[i];
|
op = _options[i];
|
||||||
if (typeof op === "string" && op === currentVal) {
|
if (typeof op === "string" && op === currentVal) {
|
||||||
return {value:currentVal}
|
return {value:currentVal}
|
||||||
} else if (op.value === currentVal) {
|
} else if (op.value === currentVal) {
|
||||||
@ -411,8 +681,8 @@
|
|||||||
currentValues[v] = true;
|
currentValues[v] = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (var i=0;i<opt.options.length;i++) {
|
for (var i=0;i<_options.length;i++) {
|
||||||
op = opt.options[i];
|
op = _options[i];
|
||||||
var val = typeof op === "string" ? op : op.value;
|
var val = typeof op === "string" ? op : op.value;
|
||||||
if (currentValues.hasOwnProperty(val)) {
|
if (currentValues.hasOwnProperty(val)) {
|
||||||
delete currentValues[val];
|
delete currentValues[val];
|
||||||
@ -427,6 +697,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nlsd = false;
|
var nlsd = false;
|
||||||
|
let contextStoreOptions;
|
||||||
|
|
||||||
$.widget( "nodered.typedInput", {
|
$.widget( "nodered.typedInput", {
|
||||||
_create: function() {
|
_create: function() {
|
||||||
@ -438,7 +709,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var contextStores = RED.settings.context.stores;
|
var contextStores = RED.settings.context.stores;
|
||||||
var contextOptions = contextStores.map(function(store) {
|
contextStoreOptions = contextStores.map(function(store) {
|
||||||
return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database"></i>'}
|
return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database"></i>'}
|
||||||
}).sort(function(A,B) {
|
}).sort(function(A,B) {
|
||||||
if (A.value === RED.settings.context.default) {
|
if (A.value === RED.settings.context.default) {
|
||||||
@ -449,13 +720,17 @@
|
|||||||
return A.value.localeCompare(B.value);
|
return A.value.localeCompare(B.value);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (contextOptions.length < 2) {
|
if (contextStoreOptions.length < 2) {
|
||||||
allOptions.flow.options = [];
|
allOptions.flow.options = [];
|
||||||
allOptions.global.options = [];
|
allOptions.global.options = [];
|
||||||
} else {
|
} else {
|
||||||
allOptions.flow.options = contextOptions;
|
allOptions.flow.options = contextStoreOptions;
|
||||||
allOptions.global.options = contextOptions;
|
allOptions.global.options = contextStoreOptions;
|
||||||
}
|
}
|
||||||
|
// Translate timestamp options
|
||||||
|
allOptions.date.options.forEach(opt => {
|
||||||
|
opt.label = RED._("typedInput.date.format." + (opt.value || 'timestamp'), {defaultValue: opt.label})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
nlsd = true;
|
nlsd = true;
|
||||||
var that = this;
|
var that = this;
|
||||||
@ -544,7 +819,7 @@
|
|||||||
that.element.trigger('paste',evt);
|
that.element.trigger('paste',evt);
|
||||||
});
|
});
|
||||||
this.input.on('keydown', function(evt) {
|
this.input.on('keydown', function(evt) {
|
||||||
if (that.typeMap[that.propertyType].autoComplete) {
|
if (that.typeMap[that.propertyType].autoComplete || that.input.hasClass('red-ui-autoComplete')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (evt.keyCode >= 37 && evt.keyCode <= 40) {
|
if (evt.keyCode >= 37 && evt.keyCode <= 40) {
|
||||||
@ -838,7 +1113,9 @@
|
|||||||
if (this.optionMenu) {
|
if (this.optionMenu) {
|
||||||
this.optionMenu.remove();
|
this.optionMenu.remove();
|
||||||
}
|
}
|
||||||
this.menu.remove();
|
if (this.menu) {
|
||||||
|
this.menu.remove();
|
||||||
|
}
|
||||||
this.uiSelect.remove();
|
this.uiSelect.remove();
|
||||||
},
|
},
|
||||||
types: function(types) {
|
types: function(types) {
|
||||||
@ -871,7 +1148,7 @@
|
|||||||
this.menu = this._createMenu(this.typeList,{},function(v) { that.type(v) });
|
this.menu = this._createMenu(this.typeList,{},function(v) { that.type(v) });
|
||||||
if (currentType && !this.typeMap.hasOwnProperty(currentType)) {
|
if (currentType && !this.typeMap.hasOwnProperty(currentType)) {
|
||||||
if (!firstCall) {
|
if (!firstCall) {
|
||||||
this.type(this.typeList[0].value);
|
this.type(this.typeList[0]?.value || ""); // permit empty typeList
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.propertyType = null;
|
this.propertyType = null;
|
||||||
@ -908,6 +1185,11 @@
|
|||||||
var selectedOption = [];
|
var selectedOption = [];
|
||||||
var valueToCheck = value;
|
var valueToCheck = value;
|
||||||
if (opt.options) {
|
if (opt.options) {
|
||||||
|
let _options = opt.options
|
||||||
|
if (typeof opt.options === "function") {
|
||||||
|
_options = opt.options.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.hasValue && opt.parse) {
|
if (opt.hasValue && opt.parse) {
|
||||||
var parts = opt.parse(value);
|
var parts = opt.parse(value);
|
||||||
if (this.options.debug) { console.log(this.identifier,"new parse",parts) }
|
if (this.options.debug) { console.log(this.identifier,"new parse",parts) }
|
||||||
@ -921,8 +1203,8 @@
|
|||||||
checkValues = valueToCheck.split(",");
|
checkValues = valueToCheck.split(",");
|
||||||
}
|
}
|
||||||
checkValues.forEach(function(valueToCheck) {
|
checkValues.forEach(function(valueToCheck) {
|
||||||
for (var i=0;i<opt.options.length;i++) {
|
for (var i=0;i<_options.length;i++) {
|
||||||
var op = opt.options[i];
|
var op = _options[i];
|
||||||
if (typeof op === "string") {
|
if (typeof op === "string") {
|
||||||
if (op === valueToCheck || op === ""+valueToCheck) {
|
if (op === valueToCheck || op === ""+valueToCheck) {
|
||||||
selectedOption.push(that.activeOptions[op]);
|
selectedOption.push(that.activeOptions[op]);
|
||||||
@ -957,7 +1239,7 @@
|
|||||||
},
|
},
|
||||||
type: function(type) {
|
type: function(type) {
|
||||||
if (!arguments.length) {
|
if (!arguments.length) {
|
||||||
return this.propertyType;
|
return this.propertyType || this.options?.default || '';
|
||||||
} else {
|
} else {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (this.options.debug) { console.log(this.identifier,"----- SET TYPE -----",type) }
|
if (this.options.debug) { console.log(this.identifier,"----- SET TYPE -----",type) }
|
||||||
@ -967,6 +1249,9 @@
|
|||||||
// If previousType is !null, then this is a change of the type, rather than the initialisation
|
// If previousType is !null, then this is a change of the type, rather than the initialisation
|
||||||
var previousType = this.typeMap[this.propertyType];
|
var previousType = this.typeMap[this.propertyType];
|
||||||
previousValue = this.input.val();
|
previousValue = this.input.val();
|
||||||
|
if (this.input.hasClass('red-ui-autoComplete')) {
|
||||||
|
this.input.autoComplete("destroy");
|
||||||
|
}
|
||||||
|
|
||||||
if (previousType && this.typeChanged) {
|
if (previousType && this.typeChanged) {
|
||||||
if (this.options.debug) { console.log(this.identifier,"typeChanged",{previousType,previousValue}) }
|
if (this.options.debug) { console.log(this.identifier,"typeChanged",{previousType,previousValue}) }
|
||||||
@ -1013,7 +1298,9 @@
|
|||||||
this.input.val(this.oldValues.hasOwnProperty("_")?this.oldValues["_"]:(opt.default||""))
|
this.input.val(this.oldValues.hasOwnProperty("_")?this.oldValues["_"]:(opt.default||""))
|
||||||
}
|
}
|
||||||
if (previousType.autoComplete) {
|
if (previousType.autoComplete) {
|
||||||
this.input.autoComplete("destroy");
|
if (this.input.hasClass('red-ui-autoComplete')) {
|
||||||
|
this.input.autoComplete("destroy");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.propertyType = type;
|
this.propertyType = type;
|
||||||
@ -1053,6 +1340,10 @@
|
|||||||
this.optionMenu = null;
|
this.optionMenu = null;
|
||||||
}
|
}
|
||||||
if (opt.options) {
|
if (opt.options) {
|
||||||
|
let _options = opt.options
|
||||||
|
if (typeof _options === "function") {
|
||||||
|
_options = opt.options.call(this);
|
||||||
|
}
|
||||||
if (this.optionExpandButton) {
|
if (this.optionExpandButton) {
|
||||||
this.optionExpandButton.hide();
|
this.optionExpandButton.hide();
|
||||||
this.optionExpandButton.shown = false;
|
this.optionExpandButton.shown = false;
|
||||||
@ -1069,7 +1360,7 @@
|
|||||||
this.valueLabelContainer.hide();
|
this.valueLabelContainer.hide();
|
||||||
}
|
}
|
||||||
this.activeOptions = {};
|
this.activeOptions = {};
|
||||||
opt.options.forEach(function(o) {
|
_options.forEach(function(o) {
|
||||||
if (typeof o === 'string') {
|
if (typeof o === 'string') {
|
||||||
that.activeOptions[o] = {label:o,value:o};
|
that.activeOptions[o] = {label:o,value:o};
|
||||||
} else {
|
} else {
|
||||||
@ -1089,7 +1380,7 @@
|
|||||||
if (validValues) {
|
if (validValues) {
|
||||||
that._updateOptionSelectLabel(validValues)
|
that._updateOptionSelectLabel(validValues)
|
||||||
} else {
|
} else {
|
||||||
op = opt.options[0];
|
op = _options[0] || {value:""}; // permit zero options
|
||||||
if (typeof op === "string") {
|
if (typeof op === "string") {
|
||||||
this.value(op);
|
this.value(op);
|
||||||
that._updateOptionSelectLabel({value:op});
|
that._updateOptionSelectLabel({value:op});
|
||||||
@ -1108,7 +1399,7 @@
|
|||||||
that._updateOptionSelectLabel(validValues);
|
that._updateOptionSelectLabel(validValues);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var selectedOption = this.optionValue||opt.options[0];
|
var selectedOption = this.optionValue||_options[0];
|
||||||
if (opt.parse) {
|
if (opt.parse) {
|
||||||
var selectedOptionObj = typeof selectedOption === "string"?{value:selectedOption}:selectedOption
|
var selectedOptionObj = typeof selectedOption === "string"?{value:selectedOption}:selectedOption
|
||||||
var parts = opt.parse(this.input.val(),selectedOptionObj);
|
var parts = opt.parse(this.input.val(),selectedOptionObj);
|
||||||
@ -1141,8 +1432,18 @@
|
|||||||
} else {
|
} else {
|
||||||
this.optionSelectTrigger.hide();
|
this.optionSelectTrigger.hide();
|
||||||
}
|
}
|
||||||
|
if (opt.autoComplete) {
|
||||||
|
let searchFunction = opt.autoComplete
|
||||||
|
if (searchFunction.length === 0) {
|
||||||
|
searchFunction = opt.autoComplete.call(this)
|
||||||
|
}
|
||||||
|
this.input.autoComplete({
|
||||||
|
search: searchFunction,
|
||||||
|
minLength: 0
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.optionMenu = this._createMenu(opt.options,opt,function(v){
|
this.optionMenu = this._createMenu(_options,opt,function(v){
|
||||||
if (!opt.multiple) {
|
if (!opt.multiple) {
|
||||||
that._updateOptionSelectLabel(that.activeOptions[v]);
|
that._updateOptionSelectLabel(that.activeOptions[v]);
|
||||||
if (!opt.hasValue) {
|
if (!opt.hasValue) {
|
||||||
@ -1183,8 +1484,12 @@
|
|||||||
this.valueLabelContainer.hide();
|
this.valueLabelContainer.hide();
|
||||||
this.elementDiv.show();
|
this.elementDiv.show();
|
||||||
if (opt.autoComplete) {
|
if (opt.autoComplete) {
|
||||||
|
let searchFunction = opt.autoComplete
|
||||||
|
if (searchFunction.length === 0) {
|
||||||
|
searchFunction = opt.autoComplete.call(this)
|
||||||
|
}
|
||||||
this.input.autoComplete({
|
this.input.autoComplete({
|
||||||
search: opt.autoComplete,
|
search: searchFunction,
|
||||||
minLength: 0
|
minLength: 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -326,47 +326,78 @@ RED.editor = (function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a config-node select box for this property
|
* Create a config-node select box for this property
|
||||||
* @param node - the node being edited
|
* @param {Object} node - the node being edited
|
||||||
* @param property - the name of the field
|
* @param {String} property - the name of the node property
|
||||||
* @param type - the type of the config-node
|
* @param {String} type - the type of the config-node
|
||||||
|
* @param {"node-config-input"|"node-input"|"node-input-subflow-env"} prefix - the prefix to use in the input element ids
|
||||||
|
* @param {Function} [filter] - a function to filter the list of config nodes
|
||||||
|
* @param {Object} [env] - the environment variable object (only used for subflow env vars)
|
||||||
*/
|
*/
|
||||||
function prepareConfigNodeSelect(node,property,type,prefix,filter) {
|
function prepareConfigNodeSelect(node, property, type, prefix, filter, env) {
|
||||||
var input = $("#"+prefix+"-"+property);
|
let nodeValue
|
||||||
if (input.length === 0 ) {
|
if (prefix === 'node-input-subflow-env') {
|
||||||
|
nodeValue = env?.value
|
||||||
|
} else {
|
||||||
|
nodeValue = node[property]
|
||||||
|
}
|
||||||
|
|
||||||
|
const buttonId = `${prefix}-lookup-${property}`
|
||||||
|
const selectId = prefix + '-' + property
|
||||||
|
const input = $(`#${selectId}`);
|
||||||
|
if (input.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newWidth = input.width();
|
const attrStyle = input.attr('style');
|
||||||
var attrStyle = input.attr('style');
|
let newWidth;
|
||||||
var m;
|
let m;
|
||||||
if ((m = /(^|\s|;)width\s*:\s*([^;]+)/i.exec(attrStyle)) !== null) {
|
if ((m = /(^|\s|;)width\s*:\s*([^;]+)/i.exec(attrStyle)) !== null) {
|
||||||
newWidth = m[2].trim();
|
newWidth = m[2].trim();
|
||||||
} else {
|
} else {
|
||||||
newWidth = "70%";
|
newWidth = "70%";
|
||||||
}
|
}
|
||||||
var outerWrap = $("<div></div>").css({
|
const outerWrap = $("<div></div>").css({
|
||||||
width: newWidth,
|
width: newWidth,
|
||||||
display:'inline-flex'
|
display: 'inline-flex'
|
||||||
});
|
});
|
||||||
var select = $('<select id="'+prefix+'-'+property+'"></select>').appendTo(outerWrap);
|
const select = $('<select id="' + selectId + '"></select>').appendTo(outerWrap);
|
||||||
input.replaceWith(outerWrap);
|
input.replaceWith(outerWrap);
|
||||||
// set the style attr directly - using width() on FF causes a value of 114%...
|
// set the style attr directly - using width() on FF causes a value of 114%...
|
||||||
select.css({
|
select.css({
|
||||||
'flex-grow': 1
|
'flex-grow': 1
|
||||||
});
|
});
|
||||||
updateConfigNodeSelect(property,type,node[property],prefix,filter);
|
updateConfigNodeSelect(property, type, nodeValue, prefix, filter);
|
||||||
$('<a id="'+prefix+'-lookup-'+property+'" class="red-ui-button"><i class="fa fa-pencil"></i></a>')
|
const disableButton = function(disabled) {
|
||||||
.css({"margin-left":"10px"})
|
btn.prop( "disabled", !!disabled)
|
||||||
|
btn.toggleClass("disabled", !!disabled)
|
||||||
|
}
|
||||||
|
// create the edit button
|
||||||
|
const btn = $('<a id="' + buttonId + '" class="red-ui-button"><i class="fa fa-pencil"></i></a>')
|
||||||
|
.css({ "margin-left": "10px" })
|
||||||
.appendTo(outerWrap);
|
.appendTo(outerWrap);
|
||||||
$('#'+prefix+'-lookup-'+property).on("click", function(e) {
|
|
||||||
showEditConfigNodeDialog(property,type,select.find(":selected").val(),prefix,node);
|
// add the click handler
|
||||||
|
btn.on("click", function (e) {
|
||||||
|
const selectedOpt = select.find(":selected")
|
||||||
|
if (selectedOpt.data('env')) { return } // don't show the dialog for env vars items (MVP. Future enhancement: lookup the env, if present, show the associated edit dialog)
|
||||||
|
if (btn.prop("disabled")) { return }
|
||||||
|
showEditConfigNodeDialog(property, type, selectedOpt.val(), prefix, node);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// dont permit the user to click the button if the selected option is an env var
|
||||||
|
select.on("change", function () {
|
||||||
|
const selectedOpt = select.find(":selected")
|
||||||
|
if (selectedOpt?.data('env')) {
|
||||||
|
disableButton(true)
|
||||||
|
} else {
|
||||||
|
disableButton(false)
|
||||||
|
}
|
||||||
|
});
|
||||||
var label = "";
|
var label = "";
|
||||||
var configNode = RED.nodes.node(node[property]);
|
var configNode = RED.nodes.node(nodeValue);
|
||||||
var node_def = RED.nodes.getType(type);
|
|
||||||
|
|
||||||
if (configNode) {
|
if (configNode) {
|
||||||
label = RED.utils.getNodeLabel(configNode,configNode.id);
|
label = RED.utils.getNodeLabel(configNode, configNode.id);
|
||||||
}
|
}
|
||||||
input.val(label);
|
input.val(label);
|
||||||
}
|
}
|
||||||
@ -768,12 +799,9 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function defaultConfigNodeSort(A,B) {
|
function defaultConfigNodeSort(A,B) {
|
||||||
if (A.__label__ < B.__label__) {
|
// sort case insensitive so that `[env] node-name` items are at the top and
|
||||||
return -1;
|
// not mixed inbetween the the lower and upper case items
|
||||||
} else if (A.__label__ > B.__label__) {
|
return (A.__label__ || '').localeCompare((B.__label__ || ''), undefined, {sensitivity: 'base'})
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateConfigNodeSelect(name,type,value,prefix,filter) {
|
function updateConfigNodeSelect(name,type,value,prefix,filter) {
|
||||||
@ -788,7 +816,7 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
$("#"+prefix+"-"+name).val(value);
|
$("#"+prefix+"-"+name).val(value);
|
||||||
} else {
|
} else {
|
||||||
|
let inclSubflowEnvvars = false
|
||||||
var select = $("#"+prefix+"-"+name);
|
var select = $("#"+prefix+"-"+name);
|
||||||
var node_def = RED.nodes.getType(type);
|
var node_def = RED.nodes.getType(type);
|
||||||
select.children().remove();
|
select.children().remove();
|
||||||
@ -796,6 +824,7 @@ RED.editor = (function() {
|
|||||||
var activeWorkspace = RED.nodes.workspace(RED.workspaces.active());
|
var activeWorkspace = RED.nodes.workspace(RED.workspaces.active());
|
||||||
if (!activeWorkspace) {
|
if (!activeWorkspace) {
|
||||||
activeWorkspace = RED.nodes.subflow(RED.workspaces.active());
|
activeWorkspace = RED.nodes.subflow(RED.workspaces.active());
|
||||||
|
inclSubflowEnvvars = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var configNodes = [];
|
var configNodes = [];
|
||||||
@ -811,6 +840,31 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// as includeSubflowEnvvars is true, this is a subflow.
|
||||||
|
// include any 'conf-types' env vars as a list of avaiable configs
|
||||||
|
// in the config dropdown as `[env] node-name`
|
||||||
|
if (inclSubflowEnvvars && activeWorkspace.env) {
|
||||||
|
const parentEnv = activeWorkspace.env.filter(env => env.ui?.type === 'conf-types' && env.type === type)
|
||||||
|
if (parentEnv && parentEnv.length > 0) {
|
||||||
|
const locale = RED.i18n.lang()
|
||||||
|
for (let i = 0; i < parentEnv.length; i++) {
|
||||||
|
const tenv = parentEnv[i]
|
||||||
|
const ui = tenv.ui || {}
|
||||||
|
const labels = ui.label || {}
|
||||||
|
const labelText = RED.editor.envVarList.lookupLabel(labels, labels["en-US"] || tenv.name, locale)
|
||||||
|
const config = {
|
||||||
|
env: tenv,
|
||||||
|
id: '${' + parentEnv[0].name + '}',
|
||||||
|
type: type,
|
||||||
|
label: labelText,
|
||||||
|
__label__: `[env] ${labelText}`
|
||||||
|
}
|
||||||
|
configNodes.push(config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var configSortFn = defaultConfigNodeSort;
|
var configSortFn = defaultConfigNodeSort;
|
||||||
if (typeof node_def.sort == "function") {
|
if (typeof node_def.sort == "function") {
|
||||||
configSortFn = node_def.sort;
|
configSortFn = node_def.sort;
|
||||||
@ -822,7 +876,10 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configNodes.forEach(function(cn) {
|
configNodes.forEach(function(cn) {
|
||||||
$('<option value="'+cn.id+'"'+(value==cn.id?" selected":"")+'></option>').text(RED.text.bidi.enforceTextDirectionWithUCC(cn.__label__)).appendTo(select);
|
const option = $('<option value="'+cn.id+'"'+(value==cn.id?" selected":"")+'></option>').text(RED.text.bidi.enforceTextDirectionWithUCC(cn.__label__)).appendTo(select);
|
||||||
|
if (cn.env) {
|
||||||
|
option.data('env', cn.env) // set a data attribute to indicate this is an env var (to inhibit the edit button)
|
||||||
|
}
|
||||||
delete cn.__label__;
|
delete cn.__label__;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1483,9 +1540,16 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
RED.tray.close(function() {
|
RED.tray.close(function() {
|
||||||
var filter = null;
|
var filter = null;
|
||||||
if (editContext && typeof editContext._def.defaults[configProperty].filter === 'function') {
|
// when editing a config via subflow edit panel, the `configProperty` will not
|
||||||
filter = function(n) {
|
// necessarily be a property of the editContext._def.defaults object
|
||||||
return editContext._def.defaults[configProperty].filter.call(editContext,n);
|
// Also, when editing via dashboard sidebar, editContext can be null
|
||||||
|
// so we need to guard both scenarios
|
||||||
|
if (editContext?._def) {
|
||||||
|
const isSubflow = (editContext._def.type === 'subflow' || /subflow:.*/.test(editContext._def.type))
|
||||||
|
if (editContext && !isSubflow && typeof editContext._def.defaults?.[configProperty]?.filter === 'function') {
|
||||||
|
filter = function(n) {
|
||||||
|
return editContext._def.defaults[configProperty].filter.call(editContext,n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateConfigNodeSelect(configProperty,configType,editing_config_node.id,prefix,filter);
|
updateConfigNodeSelect(configProperty,configType,editing_config_node.id,prefix,filter);
|
||||||
@ -1546,7 +1610,7 @@ RED.editor = (function() {
|
|||||||
RED.history.push(historyEvent);
|
RED.history.push(historyEvent);
|
||||||
RED.tray.close(function() {
|
RED.tray.close(function() {
|
||||||
var filter = null;
|
var filter = null;
|
||||||
if (editContext && typeof editContext._def.defaults[configProperty].filter === 'function') {
|
if (editContext && typeof editContext._def.defaults[configProperty]?.filter === 'function') {
|
||||||
filter = function(n) {
|
filter = function(n) {
|
||||||
return editContext._def.defaults[configProperty].filter.call(editContext,n);
|
return editContext._def.defaults[configProperty].filter.call(editContext,n);
|
||||||
}
|
}
|
||||||
@ -2087,6 +2151,7 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
editBuffer: function(options) { showTypeEditor("_buffer", options) },
|
editBuffer: function(options) { showTypeEditor("_buffer", options) },
|
||||||
|
getEditStack: function () { return [...editStack] },
|
||||||
buildEditForm: buildEditForm,
|
buildEditForm: buildEditForm,
|
||||||
validateNode: validateNode,
|
validateNode: validateNode,
|
||||||
updateNodeProperties: updateNodeProperties,
|
updateNodeProperties: updateNodeProperties,
|
||||||
@ -2131,6 +2196,7 @@ RED.editor = (function() {
|
|||||||
filteredEditPanes[type] = filter
|
filteredEditPanes[type] = filter
|
||||||
}
|
}
|
||||||
editPanes[type] = definition;
|
editPanes[type] = definition;
|
||||||
}
|
},
|
||||||
|
prepareConfigNodeSelect: prepareConfigNodeSelect,
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -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("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("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("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});',
|
createMonacoCompletionItem("cloneMessage (RED.util)", 'RED.util.cloneMessage(${1:msg});',
|
||||||
["```typescript",
|
["```typescript",
|
||||||
"RED.util.cloneMessage<T extends registry.NodeMessage>(msg: T): T",
|
"RED.util.cloneMessage<T extends registry.NodeMessage>(msg: T): T",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
RED.editor.envVarList = (function() {
|
RED.editor.envVarList = (function() {
|
||||||
|
|
||||||
var currentLocale = 'en-US';
|
var currentLocale = 'en-US';
|
||||||
var DEFAULT_ENV_TYPE_LIST = ['str','num','bool','json','bin','env'];
|
const DEFAULT_ENV_TYPE_LIST = ['str','num','bool','json','bin','env'];
|
||||||
var DEFAULT_ENV_TYPE_LIST_INC_CRED = ['str','num','bool','json','bin','env','cred','jsonata'];
|
const DEFAULT_ENV_TYPE_LIST_INC_CONFTYPES = ['str','num','bool','json','bin','env','conf-types'];
|
||||||
|
const DEFAULT_ENV_TYPE_LIST_INC_CRED = ['str','num','bool','json','bin','env','cred','jsonata'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create env var edit interface
|
* Create env var edit interface
|
||||||
@ -10,8 +11,8 @@ RED.editor.envVarList = (function() {
|
|||||||
* @param node - subflow node
|
* @param node - subflow node
|
||||||
*/
|
*/
|
||||||
function buildPropertiesList(envContainer, node) {
|
function buildPropertiesList(envContainer, node) {
|
||||||
|
if(RED.editor.envVarList.debug) { console.log('envVarList: buildPropertiesList', envContainer, node) }
|
||||||
var isTemplateNode = (node.type === "subflow");
|
const isTemplateNode = (node.type === "subflow");
|
||||||
|
|
||||||
envContainer
|
envContainer
|
||||||
.css({
|
.css({
|
||||||
@ -83,7 +84,14 @@ RED.editor.envVarList = (function() {
|
|||||||
// if `opt.ui` does not exist, then apply defaults. If these
|
// if `opt.ui` does not exist, then apply defaults. If these
|
||||||
// defaults do not change then they will get stripped off
|
// defaults do not change then they will get stripped off
|
||||||
// before saving.
|
// before saving.
|
||||||
if (opt.type === 'cred') {
|
if (opt.type === 'conf-types') {
|
||||||
|
opt.ui = opt.ui || {
|
||||||
|
icon: "fa fa-cog",
|
||||||
|
type: "conf-types",
|
||||||
|
opts: {opts:[]}
|
||||||
|
}
|
||||||
|
opt.ui.type = "conf-types";
|
||||||
|
} else if (opt.type === 'cred') {
|
||||||
opt.ui = opt.ui || {
|
opt.ui = opt.ui || {
|
||||||
icon: "",
|
icon: "",
|
||||||
type: "cred"
|
type: "cred"
|
||||||
@ -119,7 +127,7 @@ RED.editor.envVarList = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
buildEnvEditRow(uiRow, opt.ui, nameField, valueField);
|
buildEnvEditRow(uiRow, opt, nameField, valueField);
|
||||||
nameField.trigger('change');
|
nameField.trigger('change');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -181,21 +189,23 @@ RED.editor.envVarList = (function() {
|
|||||||
* @param nameField - name field of env var
|
* @param nameField - name field of env var
|
||||||
* @param valueField - value field of env var
|
* @param valueField - value field of env var
|
||||||
*/
|
*/
|
||||||
function buildEnvEditRow(container, ui, nameField, valueField) {
|
function buildEnvEditRow(container, opt, nameField, valueField) {
|
||||||
|
const ui = opt.ui
|
||||||
|
if(RED.editor.envVarList.debug) { console.log('envVarList: buildEnvEditRow', container, ui, nameField, valueField) }
|
||||||
container.addClass("red-ui-editor-subflow-env-ui-row")
|
container.addClass("red-ui-editor-subflow-env-ui-row")
|
||||||
var topRow = $('<div></div>').appendTo(container);
|
var topRow = $('<div></div>').appendTo(container);
|
||||||
$('<div></div>').appendTo(topRow);
|
$('<div></div>').appendTo(topRow);
|
||||||
$('<div>').text(RED._("editor.icon")).appendTo(topRow);
|
$('<div>').text(RED._("editor.icon")).appendTo(topRow);
|
||||||
$('<div>').text(RED._("editor.label")).appendTo(topRow);
|
$('<div>').text(RED._("editor.label")).appendTo(topRow);
|
||||||
$('<div>').text(RED._("editor.inputType")).appendTo(topRow);
|
$('<div class="red-env-ui-input-type-col">').text(RED._("editor.inputType")).appendTo(topRow);
|
||||||
|
|
||||||
var row = $('<div></div>').appendTo(container);
|
var row = $('<div></div>').appendTo(container);
|
||||||
$('<div><i class="red-ui-editableList-item-handle fa fa-bars"></i></div>').appendTo(row);
|
$('<div><i class="red-ui-editableList-item-handle fa fa-bars"></i></div>').appendTo(row);
|
||||||
var typeOptions = {
|
var typeOptions = {
|
||||||
'input': {types:DEFAULT_ENV_TYPE_LIST},
|
'input': {types:DEFAULT_ENV_TYPE_LIST_INC_CONFTYPES},
|
||||||
'select': {opts:[]},
|
'select': {opts:[]},
|
||||||
'spinner': {},
|
'spinner': {},
|
||||||
'cred': {}
|
'cred': {}
|
||||||
};
|
};
|
||||||
if (ui.opts) {
|
if (ui.opts) {
|
||||||
typeOptions[ui.type] = ui.opts;
|
typeOptions[ui.type] = ui.opts;
|
||||||
@ -260,15 +270,16 @@ RED.editor.envVarList = (function() {
|
|||||||
labelInput.attr("placeholder",$(this).val())
|
labelInput.attr("placeholder",$(this).val())
|
||||||
});
|
});
|
||||||
|
|
||||||
var inputCell = $('<div></div>').appendTo(row);
|
var inputCell = $('<div class="red-env-ui-input-type-col"></div>').appendTo(row);
|
||||||
var inputCellInput = $('<input type="text">').css("width","100%").appendTo(inputCell);
|
var uiInputTypeInput = $('<input type="text">').css("width","100%").appendTo(inputCell);
|
||||||
if (ui.type === "input") {
|
if (ui.type === "input") {
|
||||||
inputCellInput.val(ui.opts.types.join(","));
|
uiInputTypeInput.val(ui.opts.types.join(","));
|
||||||
}
|
}
|
||||||
var checkbox;
|
var checkbox;
|
||||||
var selectBox;
|
var selectBox;
|
||||||
|
|
||||||
inputCellInput.typedInput({
|
// the options presented in the UI section for an "input" type selection
|
||||||
|
uiInputTypeInput.typedInput({
|
||||||
types: [
|
types: [
|
||||||
{
|
{
|
||||||
value:"input",
|
value:"input",
|
||||||
@ -429,7 +440,7 @@ RED.editor.envVarList = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.opts.opts = vals;
|
ui.opts.opts = vals;
|
||||||
inputCellInput.typedInput('value',Date.now())
|
uiInputTypeInput.typedInput('value',Date.now())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,12 +507,13 @@ RED.editor.envVarList = (function() {
|
|||||||
} else {
|
} else {
|
||||||
delete ui.opts.max;
|
delete ui.opts.max;
|
||||||
}
|
}
|
||||||
inputCellInput.typedInput('value',Date.now())
|
uiInputTypeInput.typedInput('value',Date.now())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'conf-types',
|
||||||
{
|
{
|
||||||
value:"none",
|
value:"none",
|
||||||
label:RED._("editor.inputs.none"), icon:"fa fa-times",hasValue:false
|
label:RED._("editor.inputs.none"), icon:"fa fa-times",hasValue:false
|
||||||
@ -519,14 +531,20 @@ RED.editor.envVarList = (function() {
|
|||||||
// In the case of 'input' type, the typedInput uses the multiple-option
|
// In the case of 'input' type, the typedInput uses the multiple-option
|
||||||
// mode. Its value needs to be set to a comma-separately list of the
|
// mode. Its value needs to be set to a comma-separately list of the
|
||||||
// selected options.
|
// selected options.
|
||||||
inputCellInput.typedInput('value',ui.opts.types.join(","))
|
uiInputTypeInput.typedInput('value',ui.opts.types.join(","))
|
||||||
|
} else if (ui.type === 'conf-types') {
|
||||||
|
// In the case of 'conf-types' type, the typedInput will be populated
|
||||||
|
// with a list of all config nodes types installed.
|
||||||
|
// Restore the value to the last selected type
|
||||||
|
uiInputTypeInput.typedInput('value', opt.type)
|
||||||
} else {
|
} else {
|
||||||
// No other type cares about `value`, but doing this will
|
// No other type cares about `value`, but doing this will
|
||||||
// force a refresh of the label now that `ui.opts` has
|
// force a refresh of the label now that `ui.opts` has
|
||||||
// been updated.
|
// been updated.
|
||||||
inputCellInput.typedInput('value',Date.now())
|
uiInputTypeInput.typedInput('value',Date.now())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(RED.editor.envVarList.debug) { console.log('envVarList: inputCellInput on:typedinputtypechange. ui.type = ' + ui.type) }
|
||||||
switch (ui.type) {
|
switch (ui.type) {
|
||||||
case 'input':
|
case 'input':
|
||||||
valueField.typedInput('types',ui.opts.types);
|
valueField.typedInput('types',ui.opts.types);
|
||||||
@ -544,7 +562,7 @@ RED.editor.envVarList = (function() {
|
|||||||
valueField.typedInput('types',['cred']);
|
valueField.typedInput('types',['cred']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
valueField.typedInput('types',DEFAULT_ENV_TYPE_LIST)
|
valueField.typedInput('types', DEFAULT_ENV_TYPE_LIST);
|
||||||
}
|
}
|
||||||
if (ui.type === 'checkbox') {
|
if (ui.type === 'checkbox') {
|
||||||
valueField.typedInput('type','bool');
|
valueField.typedInput('type','bool');
|
||||||
@ -556,8 +574,46 @@ RED.editor.envVarList = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).on("change", function(evt,type) {
|
}).on("change", function(evt,type) {
|
||||||
if (ui.type === 'input') {
|
const selectedType = $(this).typedInput('type') // the UI typedInput type
|
||||||
var types = inputCellInput.typedInput('value');
|
if(RED.editor.envVarList.debug) { console.log('envVarList: inputCellInput on:change. selectedType = ' + selectedType) }
|
||||||
|
if (selectedType === 'conf-types') {
|
||||||
|
const selectedConfigType = $(this).typedInput('value') || opt.type
|
||||||
|
let activeWorkspace = RED.nodes.workspace(RED.workspaces.active());
|
||||||
|
if (!activeWorkspace) {
|
||||||
|
activeWorkspace = RED.nodes.subflow(RED.workspaces.active());
|
||||||
|
}
|
||||||
|
|
||||||
|
// get a list of all config nodes matching the selectedValue
|
||||||
|
const configNodes = [];
|
||||||
|
RED.nodes.eachConfig(function(config) {
|
||||||
|
if (config.type == selectedConfigType && (!config.z || config.z === activeWorkspace.id)) {
|
||||||
|
const modulePath = config._def?.set?.id || ''
|
||||||
|
let label = RED.utils.getNodeLabel(config, config.id) || config.id;
|
||||||
|
label += config.d ? ' ['+RED._('workspace.disabled')+']' : '';
|
||||||
|
const _config = {
|
||||||
|
_type: selectedConfigType,
|
||||||
|
value: config.id,
|
||||||
|
label: label,
|
||||||
|
title: modulePath ? modulePath + ' - ' + label : label,
|
||||||
|
enabled: config.d !== true,
|
||||||
|
disabled: config.d === true,
|
||||||
|
}
|
||||||
|
configNodes.push(_config);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const tiTypes = {
|
||||||
|
value: selectedConfigType,
|
||||||
|
label: "config",
|
||||||
|
icon: "fa fa-cog",
|
||||||
|
options: configNodes,
|
||||||
|
}
|
||||||
|
valueField.typedInput('types', [tiTypes]);
|
||||||
|
valueField.typedInput('type', selectedConfigType);
|
||||||
|
valueField.typedInput('value', opt.value);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (ui.type === 'input') {
|
||||||
|
var types = uiInputTypeInput.typedInput('value');
|
||||||
ui.opts.types = (types === "") ? ["str"] : types.split(",");
|
ui.opts.types = (types === "") ? ["str"] : types.split(",");
|
||||||
valueField.typedInput('types',ui.opts.types);
|
valueField.typedInput('types',ui.opts.types);
|
||||||
}
|
}
|
||||||
@ -569,7 +625,7 @@ RED.editor.envVarList = (function() {
|
|||||||
})
|
})
|
||||||
// Set the input to the right type. This will trigger the 'typedinputtypechange'
|
// Set the input to the right type. This will trigger the 'typedinputtypechange'
|
||||||
// event handler (just above ^^) to update the value if needed
|
// event handler (just above ^^) to update the value if needed
|
||||||
inputCellInput.typedInput('type',ui.type)
|
uiInputTypeInput.typedInput('type',ui.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLocale(l, list) {
|
function setLocale(l, list) {
|
||||||
|
@ -153,10 +153,6 @@ RED.envVar = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(done) {
|
function init(done) {
|
||||||
if (!RED.user.hasPermission("settings.write")) {
|
|
||||||
RED.notify(RED._("user.errors.settings"),"error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RED.userSettings.add({
|
RED.userSettings.add({
|
||||||
id:'envvar',
|
id:'envvar',
|
||||||
title: RED._("env-var.environment"),
|
title: RED._("env-var.environment"),
|
||||||
|
@ -248,86 +248,106 @@ RED.palette.editor = (function() {
|
|||||||
var moduleInfo = nodeEntries[module].info;
|
var moduleInfo = nodeEntries[module].info;
|
||||||
var nodeEntry = nodeEntries[module].elements;
|
var nodeEntry = nodeEntries[module].elements;
|
||||||
if (nodeEntry) {
|
if (nodeEntry) {
|
||||||
var activeTypeCount = 0;
|
if (moduleInfo.plugin) {
|
||||||
var typeCount = 0;
|
nodeEntry.enableButton.hide();
|
||||||
var errorCount = 0;
|
nodeEntry.removeButton.show();
|
||||||
nodeEntry.errorList.empty();
|
|
||||||
nodeEntries[module].totalUseCount = 0;
|
|
||||||
nodeEntries[module].setUseCount = {};
|
|
||||||
|
|
||||||
for (var setName in moduleInfo.sets) {
|
let pluginCount = 0;
|
||||||
if (moduleInfo.sets.hasOwnProperty(setName)) {
|
for (let setName in moduleInfo.sets) {
|
||||||
var inUseCount = 0;
|
if (moduleInfo.sets.hasOwnProperty(setName)) {
|
||||||
var set = moduleInfo.sets[setName];
|
let set = moduleInfo.sets[setName];
|
||||||
var setElements = nodeEntry.sets[setName];
|
if (set.plugins) {
|
||||||
if (set.err) {
|
pluginCount += set.plugins.length;
|
||||||
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) {
|
}
|
||||||
activeTypeCount += set.types.length;
|
|
||||||
}
|
nodeEntry.setCount.text(RED._('palette.editor.pluginCount',{count:pluginCount,label:pluginCount}));
|
||||||
typeCount += set.types.length;
|
|
||||||
for (var i=0;i<moduleInfo.sets[setName].types.length;i++) {
|
} else {
|
||||||
var t = moduleInfo.sets[setName].types[i];
|
var activeTypeCount = 0;
|
||||||
inUseCount += (typesInUse[t]||0);
|
var typeCount = 0;
|
||||||
var swatch = setElements.swatches[t];
|
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) {
|
if (set.enabled) {
|
||||||
var def = RED.nodes.getType(t);
|
activeTypeCount += set.types.length;
|
||||||
if (def && def.color) {
|
}
|
||||||
swatch.css({background:RED.utils.getNodeColor(t,def)});
|
typeCount += set.types.length;
|
||||||
swatch.css({border: "1px solid "+getContrastingBorder(swatch.css('backgroundColor'))})
|
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].setUseCount[setName] = inUseCount;
|
nodeEntries[module].totalUseCount += inUseCount;
|
||||||
nodeEntries[module].totalUseCount += inUseCount;
|
|
||||||
|
|
||||||
if (inUseCount > 0) {
|
if (setElements) {
|
||||||
setElements.enableButton.text(RED._('palette.editor.inuse'));
|
if (inUseCount > 0) {
|
||||||
setElements.enableButton.addClass('disabled');
|
setElements.enableButton.text(RED._('palette.editor.inuse'));
|
||||||
} else {
|
setElements.enableButton.addClass('disabled');
|
||||||
setElements.enableButton.removeClass('disabled');
|
} else {
|
||||||
if (set.enabled) {
|
setElements.enableButton.removeClass('disabled');
|
||||||
setElements.enableButton.text(RED._('palette.editor.disable'));
|
if (set.enabled) {
|
||||||
} else {
|
setElements.enableButton.text(RED._('palette.editor.disable'));
|
||||||
setElements.enableButton.text(RED._('palette.editor.enable'));
|
} 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) {
|
if (errorCount === 0) {
|
||||||
nodeEntry.errorRow.hide()
|
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'));
|
|
||||||
} else {
|
} 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) {
|
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;
|
var settingsPane;
|
||||||
@ -804,6 +851,7 @@ RED.palette.editor = (function() {
|
|||||||
errorRow: errorRow,
|
errorRow: errorRow,
|
||||||
errorList: errorList,
|
errorList: errorList,
|
||||||
setCount: setCount,
|
setCount: setCount,
|
||||||
|
setButton: setButton,
|
||||||
container: container,
|
container: container,
|
||||||
shade: shade,
|
shade: shade,
|
||||||
versionSpan: versionSpan,
|
versionSpan: versionSpan,
|
||||||
@ -814,49 +862,88 @@ RED.palette.editor = (function() {
|
|||||||
if (container.hasClass('expanded')) {
|
if (container.hasClass('expanded')) {
|
||||||
container.removeClass('expanded');
|
container.removeClass('expanded');
|
||||||
contentRow.slideUp();
|
contentRow.slideUp();
|
||||||
|
setTimeout(() => {
|
||||||
|
contentRow.empty()
|
||||||
|
}, 200)
|
||||||
|
object.elements.sets = {}
|
||||||
} else {
|
} else {
|
||||||
container.addClass('expanded');
|
container.addClass('expanded');
|
||||||
|
populateSetList()
|
||||||
contentRow.slideDown();
|
contentRow.slideDown();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const populateSetList = function () {
|
||||||
var setList = Object.keys(entry.sets)
|
var setList = Object.keys(entry.sets)
|
||||||
setList.sort(function(A,B) {
|
setList.sort(function(A,B) {
|
||||||
return A.toLowerCase().localeCompare(B.toLowerCase());
|
return A.toLowerCase().localeCompare(B.toLowerCase());
|
||||||
});
|
});
|
||||||
setList.forEach(function(setName) {
|
setList.forEach(function(setName) {
|
||||||
var set = entry.sets[setName];
|
var set = entry.sets[setName];
|
||||||
var setRow = $('<div>',{class:"red-ui-palette-module-set"}).appendTo(contentRow);
|
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 buttonGroup = $('<div>',{class:"red-ui-palette-module-set-button-group"}).appendTo(setRow);
|
||||||
var typeSwatches = {};
|
var typeSwatches = {};
|
||||||
set.types.forEach(function(t) {
|
let enableButton;
|
||||||
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
|
if (set.types) {
|
||||||
typeSwatches[t] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
set.types.forEach(function(t) {
|
||||||
$('<span>',{class:"red-ui-palette-module-type-node"}).text(t).appendTo(typeDiv);
|
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
|
||||||
})
|
typeSwatches[t] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
|
||||||
var enableButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').appendTo(buttonGroup);
|
if (set.enabled) {
|
||||||
enableButton.on("click", function(evt) {
|
var def = RED.nodes.getType(t);
|
||||||
evt.preventDefault();
|
if (def && def.color) {
|
||||||
if (object.setUseCount[setName] === 0) {
|
typeSwatches[t].css({background:RED.utils.getNodeColor(t,def)});
|
||||||
var currentSet = RED.nodes.registry.getNodeSet(set.id);
|
typeSwatches[t].css({border: "1px solid "+getContrastingBorder(typeSwatches[t].css('backgroundColor'))})
|
||||||
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}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
$('<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] = {
|
if (object.setUseCount[setName] > 0) {
|
||||||
setRow: setRow,
|
enableButton.text(RED._('palette.editor.inuse'));
|
||||||
enableButton: enableButton,
|
enableButton.addClass('disabled');
|
||||||
swatches: typeSwatches
|
} 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) {
|
enableButton.on("click", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
if (object.totalUseCount === 0) {
|
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();
|
notification.close();
|
||||||
|
@ -35,6 +35,10 @@ RED.palette = (function() {
|
|||||||
var categoryContainers = {};
|
var categoryContainers = {};
|
||||||
var sidebarControls;
|
var sidebarControls;
|
||||||
|
|
||||||
|
let paletteState = { filter: "", collapsed: [] };
|
||||||
|
|
||||||
|
let filterRefreshTimeout
|
||||||
|
|
||||||
function createCategory(originalCategory,rootCategory,category,ns) {
|
function createCategory(originalCategory,rootCategory,category,ns) {
|
||||||
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
|
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
|
||||||
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
|
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
|
||||||
@ -60,20 +64,57 @@ RED.palette = (function() {
|
|||||||
catDiv.data('label',label);
|
catDiv.data('label',label);
|
||||||
categoryContainers[category] = {
|
categoryContainers[category] = {
|
||||||
container: catDiv,
|
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.removeClass("red-ui-palette-open");
|
||||||
catDiv.addClass("red-ui-palette-closed");
|
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");
|
$("#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.addClass("red-ui-palette-open");
|
||||||
catDiv.removeClass("red-ui-palette-closed");
|
catDiv.removeClass("red-ui-palette-closed");
|
||||||
$("#red-ui-palette-base-category-"+category).slideDown();
|
$("#red-ui-palette-base-category-"+category).slideDown();
|
||||||
$("#red-ui-palette-header-"+category+" i").addClass("expanded");
|
$("#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() {
|
toggle: function() {
|
||||||
if (catDiv.hasClass("red-ui-palette-open")) {
|
if (categoryContainers[category].isOpen()) {
|
||||||
categoryContainers[category].close();
|
categoryContainers[category].close();
|
||||||
} else {
|
} else {
|
||||||
categoryContainers[category].open();
|
categoryContainers[category].open();
|
||||||
@ -415,8 +456,16 @@ RED.palette = (function() {
|
|||||||
|
|
||||||
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
|
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
|
||||||
if (categoryNode.find(".red-ui-palette-node").length === 1) {
|
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);
|
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');
|
var re = new RegExp(val.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'),'i');
|
||||||
$("#red-ui-palette-container .red-ui-palette-node").each(function(i,el) {
|
$("#red-ui-palette-container .red-ui-palette-node").each(function(i,el) {
|
||||||
var currentLabel = $(el).attr("data-palette-label");
|
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.hasOwnProperty(category)) {
|
||||||
if (categoryContainers[category].container
|
const categorySection = categoryContainers[category]
|
||||||
.find(".red-ui-palette-node")
|
if (categorySection.getNodeCount(true) === 0) {
|
||||||
.filter(function() { return $(this).css('display') !== 'none'}).length === 0) {
|
categorySection.hide()
|
||||||
categoryContainers[category].close();
|
|
||||||
categoryContainers[category].container.slideUp();
|
|
||||||
} else {
|
} else {
|
||||||
categoryContainers[category].open();
|
categorySection.show()
|
||||||
categoryContainers[category].container.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-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) {
|
RED.events.on('registry:node-type-added', function(nodeType) {
|
||||||
var def = RED.nodes.getType(nodeType);
|
var def = RED.nodes.getType(nodeType);
|
||||||
@ -596,14 +659,14 @@ RED.palette = (function() {
|
|||||||
|
|
||||||
RED.events.on("subflows:change",refreshSubflow);
|
RED.events.on("subflows:change",refreshSubflow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#red-ui-palette-search input").searchBox({
|
$("#red-ui-palette-search input").searchBox({
|
||||||
delay: 100,
|
delay: 100,
|
||||||
change: function() {
|
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"));
|
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");
|
RED.popover.tooltip(sidebarControls,RED._("keyboard.togglePalette"),"core:toggle-palette");
|
||||||
@ -669,7 +732,23 @@ RED.palette = (function() {
|
|||||||
togglePalette(state);
|
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) {
|
function togglePalette(state) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
$("#red-ui-main-container").addClass("red-ui-palette-closed");
|
$("#red-ui-main-container").addClass("red-ui-palette-closed");
|
||||||
@ -689,6 +768,15 @@ RED.palette = (function() {
|
|||||||
})
|
})
|
||||||
return categories;
|
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 {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
add:addNodeType,
|
add:addNodeType,
|
||||||
|
@ -909,17 +909,19 @@ RED.subflow = (function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create interface for controlling env var UI definition
|
* Build the edit dialog for a subflow template (creating/modifying a subflow template)
|
||||||
|
* @param {Object} uiContainer - the jQuery container for the environment variable list
|
||||||
|
* @param {Object} node - the subflow template node
|
||||||
*/
|
*/
|
||||||
function buildEnvControl(envList,node) {
|
function buildEnvControl(uiContainer,node) {
|
||||||
var tabs = RED.tabs.create({
|
var tabs = RED.tabs.create({
|
||||||
id: "subflow-env-tabs",
|
id: "subflow-env-tabs",
|
||||||
onchange: function(tab) {
|
onchange: function(tab) {
|
||||||
if (tab.id === "subflow-env-tab-preview") {
|
if (tab.id === "subflow-env-tab-preview") {
|
||||||
var inputContainer = $("#subflow-input-ui");
|
var inputContainer = $("#subflow-input-ui");
|
||||||
var list = envList.editableList("items");
|
var list = uiContainer.editableList("items");
|
||||||
var exportedEnv = exportEnvList(list, true);
|
var exportedEnv = exportEnvList(list, true);
|
||||||
buildEnvUI(inputContainer, exportedEnv,node);
|
buildEnvUI(inputContainer, exportedEnv, node);
|
||||||
}
|
}
|
||||||
$("#subflow-env-tabs-content").children().hide();
|
$("#subflow-env-tabs-content").children().hide();
|
||||||
$("#" + tab.id).show();
|
$("#" + tab.id).show();
|
||||||
@ -957,12 +959,33 @@ RED.subflow = (function() {
|
|||||||
RED.editor.envVarList.setLocale(locale);
|
RED.editor.envVarList.setLocale(locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function buildEnvUIRow(row, tenv, ui, node) {
|
* Build a UI row for a subflow instance environment variable
|
||||||
|
* Also used to build the UI row for subflow template preview
|
||||||
|
* @param {JQuery} row - A form row element
|
||||||
|
* @param {Object} tenv - A template environment variable
|
||||||
|
* @param {String} tenv.name - The name of the environment variable
|
||||||
|
* @param {String} tenv.type - The type of the environment variable
|
||||||
|
* @param {String} tenv.value - The value set for this environment variable
|
||||||
|
* @param {Object} tenv.parent - The parent environment variable
|
||||||
|
* @param {String} tenv.parent.value - The value set for the parent environment variable
|
||||||
|
* @param {String} tenv.parent.type - The type of the parent environment variable
|
||||||
|
* @param {Object} tenv.ui - The UI configuration for the environment variable
|
||||||
|
* @param {String} tenv.ui.icon - The icon for the environment variable
|
||||||
|
* @param {Object} tenv.ui.label - The label for the environment variable
|
||||||
|
* @param {String} tenv.ui.type - The type of the UI control for the environment variable
|
||||||
|
* @param {Object} node - The subflow instance node
|
||||||
|
*/
|
||||||
|
function buildEnvUIRow(row, tenv, node) {
|
||||||
|
if(RED.subflow.debug) { console.log("buildEnvUIRow", tenv) }
|
||||||
|
const ui = tenv.ui || {}
|
||||||
ui.label = ui.label||{};
|
ui.label = ui.label||{};
|
||||||
if ((tenv.type === "cred" || (tenv.parent && tenv.parent.type === "cred")) && !ui.type) {
|
if ((tenv.type === "cred" || (tenv.parent && tenv.parent.type === "cred")) && !ui.type) {
|
||||||
ui.type = "cred";
|
ui.type = "cred";
|
||||||
ui.opts = {};
|
ui.opts = {};
|
||||||
|
} else if (tenv.type === "conf-types") {
|
||||||
|
ui.type = "conf-types"
|
||||||
|
ui.opts = { types: ['conf-types'] }
|
||||||
} else if (!ui.type) {
|
} else if (!ui.type) {
|
||||||
ui.type = "input";
|
ui.type = "input";
|
||||||
ui.opts = { types: RED.editor.envVarList.DEFAULT_ENV_TYPE_LIST }
|
ui.opts = { types: RED.editor.envVarList.DEFAULT_ENV_TYPE_LIST }
|
||||||
@ -1006,9 +1029,10 @@ RED.subflow = (function() {
|
|||||||
if (tenv.hasOwnProperty('type')) {
|
if (tenv.hasOwnProperty('type')) {
|
||||||
val.type = tenv.type;
|
val.type = tenv.type;
|
||||||
}
|
}
|
||||||
|
const elId = getSubflowEnvPropertyName(tenv.name)
|
||||||
switch(ui.type) {
|
switch(ui.type) {
|
||||||
case "input":
|
case "input":
|
||||||
input = $('<input type="text">').css('width','70%').appendTo(row);
|
input = $('<input type="text">').css('width','70%').attr('id', elId).appendTo(row);
|
||||||
if (ui.opts.types && ui.opts.types.length > 0) {
|
if (ui.opts.types && ui.opts.types.length > 0) {
|
||||||
var inputType = val.type;
|
var inputType = val.type;
|
||||||
if (ui.opts.types.indexOf(inputType) === -1) {
|
if (ui.opts.types.indexOf(inputType) === -1) {
|
||||||
@ -1035,7 +1059,7 @@ RED.subflow = (function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "select":
|
case "select":
|
||||||
input = $('<select>').css('width','70%').appendTo(row);
|
input = $('<select>').css('width','70%').attr('id', elId).appendTo(row);
|
||||||
if (ui.opts.opts) {
|
if (ui.opts.opts) {
|
||||||
ui.opts.opts.forEach(function(o) {
|
ui.opts.opts.forEach(function(o) {
|
||||||
$('<option>').val(o.v).text(RED.editor.envVarList.lookupLabel(o.l, o.l['en-US']||o.v, locale)).appendTo(input);
|
$('<option>').val(o.v).text(RED.editor.envVarList.lookupLabel(o.l, o.l['en-US']||o.v, locale)).appendTo(input);
|
||||||
@ -1046,7 +1070,7 @@ RED.subflow = (function() {
|
|||||||
case "checkbox":
|
case "checkbox":
|
||||||
label.css("cursor","default");
|
label.css("cursor","default");
|
||||||
var cblabel = $('<label>').css('width','70%').appendTo(row);
|
var cblabel = $('<label>').css('width','70%').appendTo(row);
|
||||||
input = $('<input type="checkbox">').css({
|
input = $('<input type="checkbox">').attr('id', elId).css({
|
||||||
marginTop: 0,
|
marginTop: 0,
|
||||||
width: 'auto',
|
width: 'auto',
|
||||||
height: '34px'
|
height: '34px'
|
||||||
@ -1064,7 +1088,7 @@ RED.subflow = (function() {
|
|||||||
input.prop("checked",boolVal);
|
input.prop("checked",boolVal);
|
||||||
break;
|
break;
|
||||||
case "spinner":
|
case "spinner":
|
||||||
input = $('<input>').css('width','70%').appendTo(row);
|
input = $('<input>').css('width','70%').attr('id', elId).appendTo(row);
|
||||||
var spinnerOpts = {};
|
var spinnerOpts = {};
|
||||||
if (ui.opts.hasOwnProperty('min')) {
|
if (ui.opts.hasOwnProperty('min')) {
|
||||||
spinnerOpts.min = ui.opts.min;
|
spinnerOpts.min = ui.opts.min;
|
||||||
@ -1093,18 +1117,25 @@ RED.subflow = (function() {
|
|||||||
default: 'cred'
|
default: 'cred'
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
}
|
case "conf-types":
|
||||||
if (input) {
|
// let clsId = 'config-node-input-' + val.type + '-' + val.value + '-' + Math.floor(Math.random() * 100000);
|
||||||
input.attr('id',getSubflowEnvPropertyName(tenv.name))
|
// clsId = clsId.replace(/\W/g, '-');
|
||||||
|
// input = $('<input>').css('width','70%').addClass(clsId).attr('id', elId).appendTo(row);
|
||||||
|
input = $('<input>').css('width','70%').attr('id', elId).appendTo(row);
|
||||||
|
const _type = tenv.parent?.type || tenv.type;
|
||||||
|
RED.editor.prepareConfigNodeSelect(node, tenv.name, _type, 'node-input-subflow-env', null, tenv);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create environment variable input UI
|
* Build the edit form for a subflow instance
|
||||||
|
* Also used to build the preview form in the subflow template edit dialog
|
||||||
* @param uiContainer - container for UI
|
* @param uiContainer - container for UI
|
||||||
* @param envList - env var definitions of template
|
* @param envList - env var definitions of template
|
||||||
*/
|
*/
|
||||||
function buildEnvUI(uiContainer, envList, node) {
|
function buildEnvUI(uiContainer, envList, node) {
|
||||||
|
if(RED.subflow.debug) { console.log("buildEnvUI",envList) }
|
||||||
uiContainer.empty();
|
uiContainer.empty();
|
||||||
for (var i = 0; i < envList.length; i++) {
|
for (var i = 0; i < envList.length; i++) {
|
||||||
var tenv = envList[i];
|
var tenv = envList[i];
|
||||||
@ -1112,7 +1143,7 @@ RED.subflow = (function() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var row = $("<div/>", { class: "form-row" }).appendTo(uiContainer);
|
var row = $("<div/>", { class: "form-row" }).appendTo(uiContainer);
|
||||||
buildEnvUIRow(row,tenv, tenv.ui || {}, node);
|
buildEnvUIRow(row, tenv, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// buildEnvUI
|
// buildEnvUI
|
||||||
@ -1185,6 +1216,9 @@ RED.subflow = (function() {
|
|||||||
delete ui.opts
|
delete ui.opts
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "conf-types":
|
||||||
|
delete ui.opts;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
delete ui.opts;
|
delete ui.opts;
|
||||||
}
|
}
|
||||||
@ -1207,8 +1241,9 @@ RED.subflow = (function() {
|
|||||||
if (/^subflow:/.test(node.type)) {
|
if (/^subflow:/.test(node.type)) {
|
||||||
var subflowDef = RED.nodes.subflow(node.type.substring(8));
|
var subflowDef = RED.nodes.subflow(node.type.substring(8));
|
||||||
if (subflowDef.env) {
|
if (subflowDef.env) {
|
||||||
subflowDef.env.forEach(function(env) {
|
subflowDef.env.forEach(function(env, i) {
|
||||||
var item = {
|
var item = {
|
||||||
|
index: i,
|
||||||
name:env.name,
|
name:env.name,
|
||||||
parent: {
|
parent: {
|
||||||
type: env.type,
|
type: env.type,
|
||||||
@ -1245,14 +1280,20 @@ RED.subflow = (function() {
|
|||||||
var nodePropValue = nodeProp;
|
var nodePropValue = nodeProp;
|
||||||
if (prop.ui && prop.ui.type === "cred") {
|
if (prop.ui && prop.ui.type === "cred") {
|
||||||
nodePropType = "cred";
|
nodePropType = "cred";
|
||||||
|
} else if (prop.ui && prop.ui.type === "conf-types") {
|
||||||
|
nodePropType = prop.value.type
|
||||||
} else {
|
} else {
|
||||||
switch(typeof nodeProp) {
|
switch(typeof nodeProp) {
|
||||||
case "string": nodePropType = "str"; break;
|
case "string": nodePropType = "str"; break;
|
||||||
case "number": nodePropType = "num"; break;
|
case "number": nodePropType = "num"; break;
|
||||||
case "boolean": nodePropType = "bool"; nodePropValue = nodeProp?"true":"false"; break;
|
case "boolean": nodePropType = "bool"; nodePropValue = nodeProp?"true":"false"; break;
|
||||||
default:
|
default:
|
||||||
nodePropType = nodeProp.type;
|
if (nodeProp) {
|
||||||
nodePropValue = nodeProp.value;
|
nodePropType = nodeProp.type;
|
||||||
|
nodePropValue = nodeProp.value;
|
||||||
|
} else {
|
||||||
|
nodePropType = 'str'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var item = {
|
var item = {
|
||||||
@ -1273,6 +1314,7 @@ RED.subflow = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exportSubflowInstanceEnv(node) {
|
function exportSubflowInstanceEnv(node) {
|
||||||
|
if(RED.subflow.debug) { console.log("exportSubflowInstanceEnv",node) }
|
||||||
var env = [];
|
var env = [];
|
||||||
// First, get the values for the SubflowTemplate defined properties
|
// First, get the values for the SubflowTemplate defined properties
|
||||||
// - these are the ones with custom UI elements
|
// - these are the ones with custom UI elements
|
||||||
@ -1319,6 +1361,9 @@ RED.subflow = (function() {
|
|||||||
item.type = 'bool';
|
item.type = 'bool';
|
||||||
item.value = ""+input.prop("checked");
|
item.value = ""+input.prop("checked");
|
||||||
break;
|
break;
|
||||||
|
case "conf-types":
|
||||||
|
item.value = input.val()
|
||||||
|
item.type = data.parent.value;
|
||||||
}
|
}
|
||||||
if (ui.type === "cred" || item.type !== data.parent.type || item.value !== data.parent.value) {
|
if (ui.type === "cred" || item.type !== data.parent.type || item.value !== data.parent.value) {
|
||||||
env.push(item);
|
env.push(item);
|
||||||
@ -1332,8 +1377,15 @@ RED.subflow = (function() {
|
|||||||
return 'node-input-subflow-env-'+name.replace(/[^a-z0-9-_]/ig,"_");
|
return 'node-input-subflow-env-'+name.replace(/[^a-z0-9-_]/ig,"_");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by subflow.oneditprepare for both instances and templates
|
|
||||||
|
/**
|
||||||
|
* Build the subflow edit form
|
||||||
|
* Called by subflow.oneditprepare for both instances and templates
|
||||||
|
* @param {"subflow"|"subflow-template"} type - the type of subflow being edited
|
||||||
|
* @param {Object} node - the node being edited
|
||||||
|
*/
|
||||||
function buildEditForm(type,node) {
|
function buildEditForm(type,node) {
|
||||||
|
if(RED.subflow.debug) { console.log("buildEditForm",type,node) }
|
||||||
if (type === "subflow-template") {
|
if (type === "subflow-template") {
|
||||||
// This is the tabbed UI that offers the env list - with UI options
|
// This is the tabbed UI that offers the env list - with UI options
|
||||||
// plus the preview tab
|
// plus the preview tab
|
||||||
|
@ -435,10 +435,15 @@ RED.tourGuide = (function() {
|
|||||||
|
|
||||||
function listTour() {
|
function listTour() {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
id: "4_0",
|
||||||
|
label: "4.0",
|
||||||
|
path: "./tours/welcome.js"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "3_1",
|
id: "3_1",
|
||||||
label: "3.1",
|
label: "3.1",
|
||||||
path: "./tours/welcome.js"
|
path: "./tours/3.1/welcome.js"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "3_0",
|
id: "3_0",
|
||||||
|
@ -483,6 +483,16 @@ RED.utils = (function() {
|
|||||||
$('<span class="red-ui-debug-msg-type-string-swatch"></span>').css('backgroundColor',obj).appendTo(e);
|
$('<span class="red-ui-debug-msg-type-string-swatch"></span>').css('backgroundColor',obj).appendTo(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let n = RED.nodes.node(obj) ?? RED.nodes.workspace(obj);
|
||||||
|
if (n) {
|
||||||
|
if (options.nodeSelector && "function" == typeof options.nodeSelector) {
|
||||||
|
e.css('cursor', 'pointer').on("click", function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
options.nodeSelector(n.id);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (typeof obj === 'number') {
|
} else if (typeof obj === 'number') {
|
||||||
e = $('<span class="red-ui-debug-msg-type-number"></span>').appendTo(entryObj);
|
e = $('<span class="red-ui-debug-msg-type-number"></span>').appendTo(entryObj);
|
||||||
|
|
||||||
@ -589,6 +599,7 @@ RED.utils = (function() {
|
|||||||
exposeApi: exposeApi,
|
exposeApi: exposeApi,
|
||||||
// tools: tools // Do not pass tools down as we
|
// tools: tools // Do not pass tools down as we
|
||||||
// keep them attached to the top-level header
|
// keep them attached to the top-level header
|
||||||
|
nodeSelector: options.nodeSelector,
|
||||||
}
|
}
|
||||||
).appendTo(row);
|
).appendTo(row);
|
||||||
}
|
}
|
||||||
@ -619,6 +630,7 @@ RED.utils = (function() {
|
|||||||
exposeApi: exposeApi,
|
exposeApi: exposeApi,
|
||||||
// tools: tools // Do not pass tools down as we
|
// tools: tools // Do not pass tools down as we
|
||||||
// keep them attached to the top-level header
|
// keep them attached to the top-level header
|
||||||
|
nodeSelector: options.nodeSelector,
|
||||||
}
|
}
|
||||||
).appendTo(row);
|
).appendTo(row);
|
||||||
}
|
}
|
||||||
@ -675,6 +687,7 @@ RED.utils = (function() {
|
|||||||
exposeApi: exposeApi,
|
exposeApi: exposeApi,
|
||||||
// tools: tools // Do not pass tools down as we
|
// tools: tools // Do not pass tools down as we
|
||||||
// keep them attached to the top-level header
|
// keep them attached to the top-level header
|
||||||
|
nodeSelector: options.nodeSelector,
|
||||||
}
|
}
|
||||||
).appendTo(row);
|
).appendTo(row);
|
||||||
}
|
}
|
||||||
|
@ -6252,6 +6252,10 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (selection.links) {
|
||||||
|
selectedLinks.clear();
|
||||||
|
selection.links.forEach(selectedLinks.add);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateSelection();
|
updateSelection();
|
||||||
|
@ -187,6 +187,7 @@ RED.user = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
|
RED.events.emit('logout')
|
||||||
var tokens = RED.settings.get("auth-tokens");
|
var tokens = RED.settings.get("auth-tokens");
|
||||||
var token = tokens?tokens.access_token:"";
|
var token = tokens?tokens.access_token:"";
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -225,6 +226,7 @@ RED.user = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('<i class="fa fa-user"></i>').appendTo("#red-ui-header-button-user");
|
||||||
} else {
|
} else {
|
||||||
RED.menu.addItem("red-ui-header-button-user",{
|
RED.menu.addItem("red-ui-header-button-user",{
|
||||||
id:"usermenu-item-username",
|
id:"usermenu-item-username",
|
||||||
@ -237,6 +239,15 @@ RED.user = (function() {
|
|||||||
RED.user.logout();
|
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>')
|
var userMenu = $('<li><a id="red-ui-header-button-user" class="button hide" href="#"></a></li>')
|
||||||
.prependTo(".red-ui-header-toolbar");
|
.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",
|
RED.menu.init({id:"red-ui-header-button-user",
|
||||||
options: []
|
options: []
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ body {
|
|||||||
}
|
}
|
||||||
#red-ui-main-container {
|
#red-ui-main-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:40px; left:0; bottom: 0; right:0;
|
top: var(--red-ui-header-height); left:0; bottom: 0; right:0;
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,8 @@ $deploy-button-background-disabled-hover: #555;
|
|||||||
|
|
||||||
$header-background: #000;
|
$header-background: #000;
|
||||||
$header-button-background-active: #121212;
|
$header-button-background-active: #121212;
|
||||||
$header-menu-color: #C7C7C7;
|
$header-accent: #d41313;
|
||||||
|
$header-menu-color: #eee;
|
||||||
$header-menu-color-disabled: #666;
|
$header-menu-color-disabled: #666;
|
||||||
$header-menu-heading-color: #fff;
|
$header-menu-heading-color: #fff;
|
||||||
$header-menu-sublabel-color: #aeaeae;
|
$header-menu-sublabel-color: #aeaeae;
|
||||||
|
@ -23,16 +23,20 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: var(--red-ui-header-height);
|
||||||
background: var(--red-ui-header-background);
|
background: var(--red-ui-header-background);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0px 0px 0px 20px;
|
padding: 0px 0px 0px 20px;
|
||||||
color: var(--red-ui-header-menu-color);
|
color: var(--red-ui-header-menu-color);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
border-bottom: 2px solid var(--red-ui-header-accent);
|
||||||
|
padding-top: 2px;
|
||||||
|
|
||||||
span.red-ui-header-logo {
|
span.red-ui-header-logo {
|
||||||
float: left;
|
float: left;
|
||||||
margin-top: 5px;
|
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@ -42,7 +46,7 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: 16px !important;
|
font-size: 16px !important;
|
||||||
&:not(:first-child) {
|
&:not(:first-child) {
|
||||||
margin-left: 5px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
@ -59,25 +63,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.red-ui-header-toolbar {
|
.red-ui-header-toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
||||||
> li {
|
> li {
|
||||||
display: inline-block;
|
display: inline-flex;
|
||||||
|
align-items: stretch;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
height: 100%;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 40px;
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
padding: 0px 12px;
|
padding: 0px 12px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@ -267,13 +275,13 @@
|
|||||||
color: var(--red-ui-header-menu-heading-color);
|
color: var(--red-ui-header-menu-heading-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#red-ui-header-button-user .user-profile {
|
.user-profile {
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 40px;
|
width: 30px;
|
||||||
height: 35px;
|
height: 30px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
packages/node_modules/@node-red/editor-client/src/sass/sizes.scss
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
$header-height: 48px;
|
@ -15,4 +15,5 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
@import "colors";
|
@import "colors";
|
||||||
|
@import "sizes";
|
||||||
@import "variables";
|
@import "variables";
|
@ -15,6 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
@import "colors";
|
@import "colors";
|
||||||
|
@import "sizes";
|
||||||
@import "variables";
|
@import "variables";
|
||||||
@import "mixins";
|
@import "mixins";
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
--red-ui-shadow: #{$shadow};
|
--red-ui-shadow: #{$shadow};
|
||||||
|
|
||||||
|
// Header Height
|
||||||
|
--red-ui-header-height: #{$header-height};
|
||||||
|
|
||||||
// Main body text
|
// Main body text
|
||||||
--red-ui-primary-text-color: #{$primary-text-color};
|
--red-ui-primary-text-color: #{$primary-text-color};
|
||||||
// UI control label text
|
// UI control label text
|
||||||
@ -240,6 +243,7 @@
|
|||||||
|
|
||||||
|
|
||||||
--red-ui-header-background: #{$header-background};
|
--red-ui-header-background: #{$header-background};
|
||||||
|
--red-ui-header-accent: #{$header-accent};
|
||||||
--red-ui-header-button-background-active: #{$header-button-background-active};
|
--red-ui-header-button-background-active: #{$header-button-background-active};
|
||||||
--red-ui-header-menu-color: #{$header-menu-color};
|
--red-ui-header-menu-color: #{$header-menu-color};
|
||||||
--red-ui-header-menu-color-disabled: #{$header-menu-color-disabled};
|
--red-ui-header-menu-color-disabled: #{$header-menu-color-disabled};
|
||||||
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 189 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
231
packages/node_modules/@node-red/editor-client/src/tours/3.1/welcome.js
vendored
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
export default {
|
||||||
|
version: "3.1.0",
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
titleIcon: "fa fa-map-o",
|
||||||
|
title: {
|
||||||
|
"en-US": "Welcome to Node-RED 3.1!",
|
||||||
|
"ja": "Node-RED 3.1へようこそ!",
|
||||||
|
"fr": "Bienvenue dans Node-RED 3.1!"
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
"en-US": "<p>Let's take a moment to discover the new features in this release.</p>",
|
||||||
|
"ja": "<p>本リリースの新機能を見つけてみましょう。</p>",
|
||||||
|
"fr": "<p>Prenons un moment pour découvrir les nouvelles fonctionnalités de cette version.</p>"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "New ways to work with groups",
|
||||||
|
"ja": "グループの新たな操作方法",
|
||||||
|
"fr": "De nouvelles façons de travailler avec les groupes"
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
"en-US": `<p>We have changed how you interact with groups in the editor.</p>
|
||||||
|
<ul>
|
||||||
|
<li>They don't get in the way when clicking on a node</li>
|
||||||
|
<li>They can be reordered using the Moving Forwards and Move Backwards actions</li>
|
||||||
|
<li>Multiple nodes can be dragged into a group in one go</li>
|
||||||
|
<li>Holding <code>Alt</code> when dragging a node will *remove* it from its group</li>
|
||||||
|
</ul>`,
|
||||||
|
"ja": `<p>エディタ上のグループの操作が変更されました。</p>
|
||||||
|
<ul>
|
||||||
|
<li>グループ内のノードをクリックする時に、グループが邪魔をすることが無くなりました。</li>
|
||||||
|
<li>「前面へ移動」と「背面へ移動」の動作を用いて、複数のグループの表示順序を変えることができます。</li>
|
||||||
|
<li>グループ内へ一度に複数のノードをドラッグできるようになりました。</li>
|
||||||
|
<li><code>Alt</code> を押したまま、グループ内のノードをドラッグすると、そのグループから *除く* ことができます。</li>
|
||||||
|
</ul>`,
|
||||||
|
"fr": `<p>Nous avons modifié la façon dont vous interagissez avec les groupes dans l'éditeur.</p>
|
||||||
|
<ul>
|
||||||
|
<li>Ils ne gênent plus lorsque vous cliquez sur un noeud</li>
|
||||||
|
<li>Ils peuvent être réorganisés à l'aide des actions Avancer et Reculer</li>
|
||||||
|
<li>Plusieurs noeuds peuvent être glissés dans un groupe en une seule fois</li>
|
||||||
|
<li>Maintenir <code>Alt</code> lors du déplacement d'un noeud le *supprimera* de son groupe</li>
|
||||||
|
</ul>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Change notification on tabs",
|
||||||
|
"ja": "タブ上の変更通知",
|
||||||
|
"fr": "Notification de changement sur les onglets"
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
<p>This will make it much easier to track down changes when you're
|
||||||
|
working across multiple flows.</p>`,
|
||||||
|
"ja": `<p>タブ内にデプロイされていない変更が存在する時は、ノードと同じスタイルで変更の印が表示されるようになりました。</p>
|
||||||
|
<p>これによって複数のフローを編集している時に、変更を見つけるのが簡単になりました。</p>`,
|
||||||
|
"fr": `<p>Lorsqu'un onglet contient des modifications non déployées, il affiche désormais le
|
||||||
|
même style d'icône de changement utilisé par les noeuds.</p>
|
||||||
|
<p>Cela facilitera grandement le suivi des modifications lorsque vous
|
||||||
|
travaillez sur plusieurs flux.</p>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "A bigger canvas to work with",
|
||||||
|
"ja": "より広くなった作業キャンバス",
|
||||||
|
"fr": "Un canevas plus grand pour travailler"
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
"en-US": `<p>The default canvas size has been increased so you can fit more
|
||||||
|
into one flow.</p>
|
||||||
|
<p>We still recommend using tools such as subflows and Link Nodes to help
|
||||||
|
keep things organised, but now you have more room to work in.</p>`,
|
||||||
|
"ja": `<p>標準のキャンバスが広くなったため、1つのフローに沢山のものを含めることができるようになりました。</p>
|
||||||
|
<p>引き続き、サブフローやリンクノードなどの方法を用いて整理することをお勧めしますが、作業できる場所が増えました。</p>`,
|
||||||
|
"fr": `<p>La taille par défaut du canevas a été augmentée pour que vous puissiez en mettre plus
|
||||||
|
sur un seul flux.</p>
|
||||||
|
<p>Nous recommandons toujours d'utiliser des outils tels que les sous-flux et les noeuds de lien pour vous aider
|
||||||
|
à garder les choses organisées, mais vous avez maintenant plus d'espace pour travailler.</p>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Finding help",
|
||||||
|
"ja": "ヘルプを見つける",
|
||||||
|
"fr": "Trouver de l'aide"
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
<p>Clicking it will open up the Help sidebar showing the help for that node.</p>`,
|
||||||
|
"ja": `<p>全てのノードの編集ダイアログの下に、ノードのヘルプへのリンクが追加されました。</p>
|
||||||
|
<p>これをクリックすると、ノードのヘルプサイドバーが表示されます。</p>`,
|
||||||
|
"fr": `<p>Toutes les boîtes de dialogue d'édition de noeud incluent désormais un lien vers l'aide de ce noeud
|
||||||
|
dans le pied de page.</p>
|
||||||
|
<p>Cliquer dessus ouvrira la barre latérale d'aide affichant l'aide pour ce noeud.</p>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Improved Context Menu",
|
||||||
|
"ja": "コンテキストメニューの改善",
|
||||||
|
"fr": "Menu contextuel amélioré"
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
<p>Adding nodes, working with groups and plenty
|
||||||
|
of other useful tools are now just a click away.</p>
|
||||||
|
<p>The flow tab bar also has its own context menu to make working
|
||||||
|
with your flows much easier.</p>`,
|
||||||
|
"ja": `<p>より多くの組み込み動作を利用できるように、エディタのコンテキストメニューが拡張されました。</p>
|
||||||
|
<p>ノードの追加、グループの操作、その他の便利なツールをクリックするだけで実行できるようになりました。</p>
|
||||||
|
<p>フローのタブバーには、フローの操作をより簡単にする独自のコンテキストメニューもあります。</p>`,
|
||||||
|
"fr": `<p>Le menu contextuel de l'éditeur a été étendu pour faire beaucoup plus d'actions intégrées disponibles.</p>
|
||||||
|
<p>Ajouter des noeuds, travailler avec des groupes et beaucoup d'autres outils utiles sont désormais à portée de clic.</p>
|
||||||
|
<p>La barre d'onglets de flux possède également son propre menu contextuel pour faciliter l'utilisation de vos flux.</p>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Hiding Flows",
|
||||||
|
"ja": "フローを非表示",
|
||||||
|
"fr": "Masquage de flux"
|
||||||
|
},
|
||||||
|
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
|
||||||
|
as they were being clicked accidentally too often.</p>`,
|
||||||
|
"ja": `<p>フローを非表示にする機能は、フローのコンテキストメニューから実行するようになりました。</p>
|
||||||
|
<p>これまでのリリースでタブに存在していた「非表示」ボタンは、よく誤ってクリックされていたため、削除されました。</p>`,
|
||||||
|
"fr": `<p>Le masquage des flux s'effectue désormais via le menu contextuel du flux.</p>
|
||||||
|
<p>Le bouton "Masquer" des versions précédentes a été supprimé des onglets
|
||||||
|
car il était cliqué accidentellement trop souvent.</p>`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Locking Flows",
|
||||||
|
"ja": "フローを固定",
|
||||||
|
"fr": "Verrouillage de flux"
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
<p>The flow context menu provides the options to lock and unlock flows,
|
||||||
|
as well as in the Info sidebar explorer.</p>`,
|
||||||
|
"ja": `<p>誤ってフローに変更が加えられてしまうのを防ぐために、フローを固定できるようになりました。</p>
|
||||||
|
<p>固定されている時は、ノードを修正することはできません。</p>
|
||||||
|
<p>フローのコンテキストメニューと、情報サイドバーのエクスプローラには、フローの固定や解除をするためのオプションが用意されています。</p>`,
|
||||||
|
"fr": `<p>Les flux peuvent désormais être verrouillés pour éviter toute modification accidentelle.</p>
|
||||||
|
<p>Lorsqu'il est verrouillé, vous ne pouvez en aucun cas modifier les noeuds.</p>
|
||||||
|
<p>Le menu contextuel du flux fournit les options pour verrouiller et déverrouiller les flux,
|
||||||
|
ainsi que dans l'explorateur de la barre latérale d'informations.</p>`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Adding Images to node/flow descriptions",
|
||||||
|
"ja": "ノードやフローの説明へ画像を追加",
|
||||||
|
"fr": "Ajout d'images aux descriptions de noeud/flux"
|
||||||
|
},
|
||||||
|
// image: 'images/debug-path-tooltip.png',
|
||||||
|
description: {
|
||||||
|
"en-US": `<p>You can now add images to a node's or flows's description.</p>
|
||||||
|
<p>Simply drag the image into the text editor and it will get added inline.</p>
|
||||||
|
<p>When the description is shown in the Info sidebar, the image will be displayed.</p>`,
|
||||||
|
"ja": `<p>ノードまたはフローの説明に、画像を追加できるようになりました。</p>
|
||||||
|
<p>画像をテキストエディタにドラッグするだけで、行内に埋め込まれます。</p>
|
||||||
|
<p>情報サイドバーの説明を開くと、その画像が表示されます。</p>`,
|
||||||
|
"fr": `<p>Vous pouvez désormais ajouter des images à la description d'un noeud ou d'un flux.</p>
|
||||||
|
<p>Faites simplement glisser l'image dans l'éditeur de texte et elle sera ajoutée en ligne.</p>
|
||||||
|
<p>Lorsque la description s'affiche dans la barre latérale d'informations, l'image s'affiche.</p>`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Adding Mermaid Diagrams",
|
||||||
|
"ja": "Mermaid図を追加",
|
||||||
|
"fr": "Ajout de diagrammes Mermaid"
|
||||||
|
},
|
||||||
|
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>`,
|
||||||
|
"ja": `<p>ノードやフローの説明に、<a href="https://github.com/mermaid-js/mermaid">Mermaid</a>図を直接追加することもできます。</p>
|
||||||
|
<p>これによって、フローを説明する文書作成の選択肢がより多くなります。</p>`,
|
||||||
|
"fr": `<p>Vous pouvez également ajouter des diagrammes <a href="https://github.com/mermaid-js/mermaid">Mermaid</a> directement dans vos descriptions de noeud ou de flux.</p>
|
||||||
|
<p>Cela vous offre des options beaucoup plus riches pour documenter vos flux.</p>`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Managing Global Environment Variables",
|
||||||
|
"ja": "グローバル環境変数の管理",
|
||||||
|
"fr": "Gestion des variables d'environnement globales"
|
||||||
|
},
|
||||||
|
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>`,
|
||||||
|
"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>`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: {
|
||||||
|
"en-US": "Node Updates",
|
||||||
|
"ja": "ノードの更新",
|
||||||
|
"fr": "Mises à jour des noeuds"
|
||||||
|
},
|
||||||
|
// image: "images/",
|
||||||
|
description: {
|
||||||
|
"en-US": `<p>The core nodes have received lots of minor fixes, documentation updates and
|
||||||
|
small enhancements. Check the full changelog in the Help sidebar for a full list.</p>`,
|
||||||
|
"ja": `<p>コアノードにマイナーな修正、ドキュメント更新、小規模な拡張が数多く追加されています。全ての一覧は、ヘルプサイドバーの全ての更新履歴を確認してください。</p>`,
|
||||||
|
"fr": `<p>Les noeuds principaux ont reçu de nombreux correctifs mineurs, mises à jour de la documentation et
|
||||||
|
petites améliorations. Consulter le journal des modifications complet dans la barre latérale d'aide.</p>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
BIN
packages/node_modules/@node-red/editor-client/src/tours/images/nr4-auto-complete.png
vendored
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
packages/node_modules/@node-red/editor-client/src/tours/images/nr4-sf-config.png
vendored
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
packages/node_modules/@node-red/editor-client/src/tours/images/nr4-timestamp-formatting.png
vendored
Normal file
After Width: | Height: | Size: 15 KiB |
@ -1,12 +1,12 @@
|
|||||||
export default {
|
export default {
|
||||||
version: "3.1.0",
|
version: "4.0.0-beta.1",
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
titleIcon: "fa fa-map-o",
|
titleIcon: "fa fa-map-o",
|
||||||
title: {
|
title: {
|
||||||
"en-US": "Welcome to Node-RED 3.1!",
|
"en-US": "Welcome to Node-RED 4.0 Beta 1!",
|
||||||
"ja": "Node-RED 3.1へようこそ!",
|
"ja": "Node-RED 4.0 Beta 1へようこそ!",
|
||||||
"fr": "Bienvenue dans Node-RED 3.1!"
|
"fr": "Bienvenue dans Node-RED 4.0 Beta 1!"
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
"en-US": "<p>Let's take a moment to discover the new features in this release.</p>",
|
"en-US": "<p>Let's take a moment to discover the new features in this release.</p>",
|
||||||
@ -16,202 +16,76 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: {
|
title: {
|
||||||
"en-US": "New ways to work with groups",
|
"en-US": "Timestamp formatting options",
|
||||||
"ja": "グループの新たな操作方法",
|
"ja": "タイムスタンプの形式の項目",
|
||||||
"fr": "De nouvelles façons de travailler avec les groupes"
|
"fr": "Options de formatage de l'horodatage"
|
||||||
},
|
},
|
||||||
|
image: 'images/nr4-timestamp-formatting.png',
|
||||||
description: {
|
description: {
|
||||||
"en-US": `<p>We have changed how you interact with groups in the editor.</p>
|
"en-US": `<p>Nodes that let you set a timestamp now have options on what format that timestamp should be in.</p>
|
||||||
|
<p>We're keeping it simple to begin with by providing three options:<p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>They don't get in the way when clicking on a node</li>
|
<li>Milliseconds since epoch - this is existing behaviour of the timestamp option</li>
|
||||||
<li>They can be reordered using the Moving Forwards and Move Backwards actions</li>
|
<li>ISO 8601 - a common format used by many systems</li>
|
||||||
<li>Multiple nodes can be dragged into a group in one go</li>
|
<li>JavaScript Date Object</li>
|
||||||
<li>Holding <code>Alt</code> when dragging a node will *remove* it from its group</li>
|
|
||||||
</ul>`,
|
</ul>`,
|
||||||
"ja": `<p>エディタ上のグループの操作が変更されました。</p>
|
"ja": `<p>タイムスタンプを設定するノードに、タイムスタンプの形式を指定できる項目が追加されました。</p>
|
||||||
|
<p>次の3つの項目を追加したことで、簡単に選択できるようになりました:<p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>グループ内のノードをクリックする時に、グループが邪魔をすることが無くなりました。</li>
|
<li>エポックからのミリ秒 - 従来動作と同じになるタイムスタンプの項目</li>
|
||||||
<li>「前面へ移動」と「背面へ移動」の動作を用いて、複数のグループの表示順序を変えることができます。</li>
|
<li>ISO 8601 - 多くのシステムで使用されている共通の形式</li>
|
||||||
<li>グループ内へ一度に複数のノードをドラッグできるようになりました。</li>
|
<li>JavaScript日付オブジェクト</li>
|
||||||
<li><code>Alt</code> を押したまま、グループ内のノードをドラッグすると、そのグループから *除く* ことができます。</li>
|
|
||||||
</ul>`,
|
</ul>`,
|
||||||
"fr": `<p>Nous avons modifié la façon dont vous interagissez avec les groupes dans l'éditeur.</p>
|
"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>
|
<ul>
|
||||||
<li>Ils ne gênent plus lorsque vous cliquez sur un noeud</li>
|
<li>Millisecondes depuis l'époque : il s'agit du comportement existant de l'option d'horodatage</li>
|
||||||
<li>Ils peuvent être réorganisés à l'aide des actions Avancer et Reculer</li>
|
<li>ISO 8601 : un format commun utilisé par de nombreux systèmes</li>
|
||||||
<li>Plusieurs noeuds peuvent être glissés dans un groupe en une seule fois</li>
|
<li>Objet Date JavaScript</li>
|
||||||
<li>Maintenir <code>Alt</code> lors du déplacement d'un noeud le *supprimera* de son groupe</li>
|
|
||||||
</ul>`
|
</ul>`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: {
|
title: {
|
||||||
"en-US": "Change notification on tabs",
|
"en-US": "Auto-complete of flow/global and env types",
|
||||||
"ja": "タブ上の変更通知",
|
"ja": "フロー/グローバル、環境変数の型の自動補完",
|
||||||
"fr": "Notification de changement sur les onglets"
|
"fr": "Saisie automatique des types de flux/global et env"
|
||||||
},
|
},
|
||||||
image: 'images/tab-changes.png',
|
image: 'images/nr4-auto-complete.png',
|
||||||
description: {
|
description: {
|
||||||
"en-US": `<p>When a tab contains undeployed changes it now shows the
|
"en-US": `<p>The <code>flow</code>/<code>global</code> context inputs and the <code>env</code> input
|
||||||
same style of change icon used by nodes.</p>
|
now all include auto-complete suggestions based on the live state of your flows.</p>
|
||||||
<p>This will make it much easier to track down changes when you're
|
`,
|
||||||
working across multiple flows.</p>`,
|
"ja": `<p><code>flow</code>/<code>global</code>コンテキストや<code>env</code>の入力を、現在のフローの状態をもとに自動補完で提案するようになりました。</p>
|
||||||
"ja": `<p>タブ内にデプロイされていない変更が存在する時は、ノードと同じスタイルで変更の印が表示されるようになりました。</p>
|
`,
|
||||||
<p>これによって複数のフローを編集している時に、変更を見つけるのが簡単になりました。</p>`,
|
"fr": `<p>Les entrées contextuelles <code>flow</code>/<code>global</code> et l'entrée <code>env</code>
|
||||||
"fr": `<p>Lorsqu'un onglet contient des modifications non déployées, il affiche désormais le
|
incluent désormais des suggestions de saisie semi-automatique basées sur l'état actuel de vos flux.</p>
|
||||||
même style d'icône de changement utilisé par les noeuds.</p>
|
`,
|
||||||
<p>Cela facilitera grandement le suivi des modifications lorsque vous
|
|
||||||
travaillez sur plusieurs flux.</p>`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: {
|
title: {
|
||||||
"en-US": "A bigger canvas to work with",
|
"en-US": "Config node customisation in Subflows",
|
||||||
"ja": "より広くなった作業キャンバス",
|
"ja": "サブフローでの設定ノードのカスタマイズ",
|
||||||
"fr": "Un canevas plus grand pour travailler"
|
"fr": "Personnalisation du noeud de configuration dans les sous-flux"
|
||||||
},
|
},
|
||||||
|
image: 'images/nr4-sf-config.png',
|
||||||
description: {
|
description: {
|
||||||
"en-US": `<p>The default canvas size has been increased so you can fit more
|
"en-US": `<p>Subflows can now be customised to allow each instance to use a different
|
||||||
into one flow.</p>
|
config node of a selected type.</p>
|
||||||
<p>We still recommend using tools such as subflows and Link Nodes to help
|
<p>For example, each instance of a subflow that connects to an MQTT Broker and does some post-processing
|
||||||
keep things organised, but now you have more room to work in.</p>`,
|
of the messages received can be pointed at a different broker.</p>
|
||||||
"ja": `<p>標準のキャンバスが広くなったため、1つのフローに沢山のものを含めることができるようになりました。</p>
|
`,
|
||||||
<p>引き続き、サブフローやリンクノードなどの方法を用いて整理することをお勧めしますが、作業できる場所が増えました。</p>`,
|
"ja": `<p>サブフローをカスタマイズして、選択した型の異なる設定ノードを各インスタンスが使用できるようになりました。</p>
|
||||||
"fr": `<p>La taille par défaut du canevas a été augmentée pour que vous puissiez en mettre plus
|
<p>例えば、MQTTブローカへ接続し、メッセージ受信と後処理を行うサブフローの各インスタンスに異なるブローカを指定することも可能です。</p>
|
||||||
sur un seul flux.</p>
|
`,
|
||||||
<p>Nous recommandons toujours d'utiliser des outils tels que les sous-flux et les noeuds de lien pour vous aider
|
"fr": `<p>Les sous-flux peuvent désormais être personnalisés pour permettre à chaque instance d'utiliser un
|
||||||
à garder les choses organisées, mais vous avez maintenant plus d'espace pour travailler.</p>`
|
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>
|
||||||
|
`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Finding help",
|
|
||||||
"ja": "ヘルプを見つける",
|
|
||||||
"fr": "Trouver de l'aide"
|
|
||||||
},
|
|
||||||
image: '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>
|
|
||||||
<p>Clicking it will open up the Help sidebar showing the help for that node.</p>`,
|
|
||||||
"ja": `<p>全てのノードの編集ダイアログの下に、ノードのヘルプへのリンクが追加されました。</p>
|
|
||||||
<p>これをクリックすると、ノードのヘルプサイドバーが表示されます。</p>`,
|
|
||||||
"fr": `<p>Toutes les boîtes de dialogue d'édition de noeud incluent désormais un lien vers l'aide de ce noeud
|
|
||||||
dans le pied de page.</p>
|
|
||||||
<p>Cliquer dessus ouvrira la barre latérale d'aide affichant l'aide pour ce noeud.</p>`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Improved Context Menu",
|
|
||||||
"ja": "コンテキストメニューの改善",
|
|
||||||
"fr": "Menu contextuel amélioré"
|
|
||||||
},
|
|
||||||
image: '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>
|
|
||||||
<p>Adding nodes, working with groups and plenty
|
|
||||||
of other useful tools are now just a click away.</p>
|
|
||||||
<p>The flow tab bar also has its own context menu to make working
|
|
||||||
with your flows much easier.</p>`,
|
|
||||||
"ja": `<p>より多くの組み込み動作を利用できるように、エディタのコンテキストメニューが拡張されました。</p>
|
|
||||||
<p>ノードの追加、グループの操作、その他の便利なツールをクリックするだけで実行できるようになりました。</p>
|
|
||||||
<p>フローのタブバーには、フローの操作をより簡単にする独自のコンテキストメニューもあります。</p>`,
|
|
||||||
"fr": `<p>Le menu contextuel de l'éditeur a été étendu pour faire beaucoup plus d'actions intégrées disponibles.</p>
|
|
||||||
<p>Ajouter des noeuds, travailler avec des groupes et beaucoup d'autres outils utiles sont désormais à portée de clic.</p>
|
|
||||||
<p>La barre d'onglets de flux possède également son propre menu contextuel pour faciliter l'utilisation de vos flux.</p>`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Hiding Flows",
|
|
||||||
"ja": "フローを非表示",
|
|
||||||
"fr": "Masquage de flux"
|
|
||||||
},
|
|
||||||
image: '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
|
|
||||||
as they were being clicked accidentally too often.</p>`,
|
|
||||||
"ja": `<p>フローを非表示にする機能は、フローのコンテキストメニューから実行するようになりました。</p>
|
|
||||||
<p>これまでのリリースでタブに存在していた「非表示」ボタンは、よく誤ってクリックされていたため、削除されました。</p>`,
|
|
||||||
"fr": `<p>Le masquage des flux s'effectue désormais via le menu contextuel du flux.</p>
|
|
||||||
<p>Le bouton "Masquer" des versions précédentes a été supprimé des onglets
|
|
||||||
car il était cliqué accidentellement trop souvent.</p>`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Locking Flows",
|
|
||||||
"ja": "フローを固定",
|
|
||||||
"fr": "Verrouillage de flux"
|
|
||||||
},
|
|
||||||
image: '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>
|
|
||||||
<p>The flow context menu provides the options to lock and unlock flows,
|
|
||||||
as well as in the Info sidebar explorer.</p>`,
|
|
||||||
"ja": `<p>誤ってフローに変更が加えられてしまうのを防ぐために、フローを固定できるようになりました。</p>
|
|
||||||
<p>固定されている時は、ノードを修正することはできません。</p>
|
|
||||||
<p>フローのコンテキストメニューと、情報サイドバーのエクスプローラには、フローの固定や解除をするためのオプションが用意されています。</p>`,
|
|
||||||
"fr": `<p>Les flux peuvent désormais être verrouillés pour éviter toute modification accidentelle.</p>
|
|
||||||
<p>Lorsqu'il est verrouillé, vous ne pouvez en aucun cas modifier les noeuds.</p>
|
|
||||||
<p>Le menu contextuel du flux fournit les options pour verrouiller et déverrouiller les flux,
|
|
||||||
ainsi que dans l'explorateur de la barre latérale d'informations.</p>`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Adding Images to node/flow descriptions",
|
|
||||||
"ja": "ノードやフローの説明へ画像を追加",
|
|
||||||
"fr": "Ajout d'images aux descriptions de noeud/flux"
|
|
||||||
},
|
|
||||||
// image: 'images/debug-path-tooltip.png',
|
|
||||||
description: {
|
|
||||||
"en-US": `<p>You can now add images to a node's or flows's description.</p>
|
|
||||||
<p>Simply drag the image into the text editor and it will get added inline.</p>
|
|
||||||
<p>When the description is shown in the Info sidebar, the image will be displayed.</p>`,
|
|
||||||
"ja": `<p>ノードまたはフローの説明に、画像を追加できるようになりました。</p>
|
|
||||||
<p>画像をテキストエディタにドラッグするだけで、行内に埋め込まれます。</p>
|
|
||||||
<p>情報サイドバーの説明を開くと、その画像が表示されます。</p>`,
|
|
||||||
"fr": `<p>Vous pouvez désormais ajouter des images à la description d'un noeud ou d'un flux.</p>
|
|
||||||
<p>Faites simplement glisser l'image dans l'éditeur de texte et elle sera ajoutée en ligne.</p>
|
|
||||||
<p>Lorsque la description s'affiche dans la barre latérale d'informations, l'image s'affiche.</p>`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Adding Mermaid Diagrams",
|
|
||||||
"ja": "Mermaid図を追加",
|
|
||||||
"fr": "Ajout de diagrammes Mermaid"
|
|
||||||
},
|
|
||||||
image: '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>`,
|
|
||||||
"ja": `<p>ノードやフローの説明に、<a href="https://github.com/mermaid-js/mermaid">Mermaid</a>図を直接追加することもできます。</p>
|
|
||||||
<p>これによって、フローを説明する文書作成の選択肢がより多くなります。</p>`,
|
|
||||||
"fr": `<p>Vous pouvez également ajouter des diagrammes <a href="https://github.com/mermaid-js/mermaid">Mermaid</a> directement dans vos descriptions de noeud ou de flux.</p>
|
|
||||||
<p>Cela vous offre des options beaucoup plus riches pour documenter vos flux.</p>`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
"en-US": "Managing Global Environment Variables",
|
|
||||||
"ja": "グローバル環境変数の管理",
|
|
||||||
"fr": "Gestion des variables d'environnement globales"
|
|
||||||
},
|
|
||||||
image: '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>`,
|
|
||||||
"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>`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: {
|
title: {
|
||||||
"en-US": "Node Updates",
|
"en-US": "Node Updates",
|
||||||
@ -221,10 +95,28 @@ export default {
|
|||||||
// image: "images/",
|
// image: "images/",
|
||||||
description: {
|
description: {
|
||||||
"en-US": `<p>The core nodes have received lots of minor fixes, documentation updates and
|
"en-US": `<p>The core nodes have received lots of minor fixes, documentation updates and
|
||||||
small enhancements. Check the full changelog in the Help sidebar for a full list.</p>`,
|
small enhancements. Check the full changelog in the Help sidebar for a full list.</p>
|
||||||
"ja": `<p>コアノードにマイナーな修正、ドキュメント更新、小規模な拡張が数多く追加されています。全ての一覧は、ヘルプサイドバーの全ての更新履歴を確認してください。</p>`,
|
<ul>
|
||||||
"fr": `<p>Les noeuds principaux ont reçu de nombreux correctifs mineurs, mises à jour de la documentation et
|
<li>A fully RFC4180 compliant CSV mode</li>
|
||||||
petites améliorations. Consulter le journal des modifications complet dans la barre latérale d'aide.</p>`
|
<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 {
|
interface NodeMessage {
|
||||||
topic?: string;
|
topic?: string;
|
||||||
payload?: any;
|
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
|
[other: string]: any; //permit other properties
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,15 +19,15 @@ declare const promisify:typeof import('util').promisify
|
|||||||
/**
|
/**
|
||||||
* @typedef NodeStatus
|
* @typedef NodeStatus
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {string} [fill] The fill property can be: red, green, yellow, blue or grey.
|
* @property {'red'|'green'|'yellow'|'blue'|'grey'|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 {'ring'|'dot'|string} [shape] The shape property can be: ring or dot.
|
||||||
* @property {string} [text] The text to display
|
* @property {string|boolean|number} [text] The text to display
|
||||||
*/
|
*/
|
||||||
interface NodeStatus {
|
interface NodeStatus {
|
||||||
/** The fill property can be: red, green, yellow, blue or grey */
|
/** 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 */
|
/** The shape property can be: ring or dot */
|
||||||
shape?: string,
|
shape?: 'ring'|'dot'|string,
|
||||||
/** The text to display */
|
/** The text to display */
|
||||||
text?: string|boolean|number
|
text?: string|boolean|number
|
||||||
}
|
}
|
||||||
@ -37,25 +37,24 @@ declare class node {
|
|||||||
* Send 1 or more messages asynchronously
|
* Send 1 or more messages asynchronously
|
||||||
* @param {object | object[]} msg The msg object
|
* @param {object | object[]} msg The msg object
|
||||||
* @param {Boolean} [clone=true] Flag to indicate the `msg` should be cloned. Default = `true`
|
* @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 */
|
/** Inform runtime this instance has completed its operation */
|
||||||
static done();
|
static done();
|
||||||
/** Send an error to the console and debug side bar. Include `msg` in the 2nd parameter to trigger the catch node. */
|
/** 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 */
|
/** Log a warn message to the console and debug sidebar */
|
||||||
static warn(warning:string|object);
|
static warn(warning:string|object);
|
||||||
/** Log an info message to the console (not sent to sidebar)' */
|
/** Log an info message to the console (not sent to sidebar)' */
|
||||||
static log(info:string|object);
|
static log(info:string|object);
|
||||||
/** Sets the status icon and text underneath the node.
|
/** Sets the status icon and text underneath the node.
|
||||||
* @param {NodeStatus} status - The status object `{fill, shape, text}`
|
* @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);
|
static status(status:NodeStatus);
|
||||||
/** Sets the status text underneath the node.
|
/** 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);
|
static status(status:string|boolean|number);
|
||||||
/** the id of this node */
|
/** the id of this node */
|
||||||
@ -264,9 +263,12 @@ declare class global {
|
|||||||
/** Get an array of the keys in the context store */
|
/** Get an array of the keys in the context store */
|
||||||
static keys(store: string, callback: Function);
|
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 {
|
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...
|
* Predefined node-red variables...
|
||||||
* * `NR_NODE_ID` - the ID of the node
|
* * `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_GROUP_NAME` - the Name of the containing group
|
||||||
* * `NR_FLOW_ID` - the ID of the flow the node is on
|
* * `NR_FLOW_ID` - the ID of the flow the node is on
|
||||||
* * `NR_FLOW_NAME` - the Name 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
|
* @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
|
* The `assert` module provides a set of assertion functions for verifying
|
||||||
* invariants.
|
* 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' {
|
declare module 'assert' {
|
||||||
/**
|
/**
|
||||||
@ -290,8 +290,8 @@ declare module 'assert' {
|
|||||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||||
*
|
*
|
||||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
* 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
|
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
||||||
* and treated as being identical in case both sides are `NaN`.
|
* and treated as being identical if both sides are `NaN`.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* import assert from 'assert';
|
* import assert from 'assert';
|
||||||
@ -323,9 +323,8 @@ declare module 'assert' {
|
|||||||
*
|
*
|
||||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
* > 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
|
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
||||||
* being identical in case both
|
* specially handled and treated as being identical if both sides are `NaN`.
|
||||||
* sides are `NaN`.
|
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* import assert from 'assert';
|
* import assert from 'assert';
|
||||||
@ -415,7 +414,7 @@ declare module 'assert' {
|
|||||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||||
/**
|
/**
|
||||||
* Tests strict equality between the `actual` and `expected` parameters as
|
* 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
|
* ```js
|
||||||
* import assert from 'assert/strict';
|
* 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;
|
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||||
/**
|
/**
|
||||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
* 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
|
* ```js
|
||||||
* import assert from 'assert/strict';
|
* 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' {
|
declare module 'assert/strict' {
|
||||||
import { strict } from 'node:assert';
|
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
|
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||||
@ -9,7 +9,7 @@
|
|||||||
* import async_hooks from 'async_hooks';
|
* import async_hooks from 'async_hooks';
|
||||||
* ```
|
* ```
|
||||||
* @experimental
|
* @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' {
|
declare module 'async_hooks' {
|
||||||
/**
|
/**
|
||||||
@ -367,7 +367,7 @@ declare module 'async_hooks' {
|
|||||||
*
|
*
|
||||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
* 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
|
* @since v13.10.0, v12.17.0
|
||||||
*/
|
*/
|
||||||
class AsyncLocalStorage<T> {
|
class AsyncLocalStorage<T> {
|
||||||
@ -398,8 +398,9 @@ declare module 'async_hooks' {
|
|||||||
getStore(): T | undefined;
|
getStore(): T | undefined;
|
||||||
/**
|
/**
|
||||||
* Runs a function synchronously within a context and returns its
|
* Runs a function synchronously within a context and returns its
|
||||||
* return value. The store is not accessible outside of the callback function or
|
* return value. The store is not accessible outside of the callback function.
|
||||||
* the asynchronous operations created within the callback.
|
* The store is accessible to any asynchronous operations created within the
|
||||||
|
* callback.
|
||||||
*
|
*
|
||||||
* The optional `args` are passed to the callback function.
|
* The optional `args` are passed to the callback function.
|
||||||
*
|
*
|
||||||
@ -413,6 +414,9 @@ declare module 'async_hooks' {
|
|||||||
* try {
|
* try {
|
||||||
* asyncLocalStorage.run(store, () => {
|
* asyncLocalStorage.run(store, () => {
|
||||||
* asyncLocalStorage.getStore(); // Returns the store object
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* setTimeout(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* }, 200);
|
||||||
* throw new Error();
|
* throw new Error();
|
||||||
* });
|
* });
|
||||||
* } catch (e) {
|
* } 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
|
* `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].
|
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
||||||
* const buf7 = Buffer.from('tést', 'latin1');
|
* 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' {
|
declare module 'buffer' {
|
||||||
import { BinaryLike } from 'node:crypto';
|
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
|
* 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.
|
* multiple worker threads.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
export class Blob {
|
export class Blob {
|
||||||
/**
|
/**
|
||||||
* The total size of the `Blob` in bytes.
|
* The total size of the `Blob` in bytes.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly size: number;
|
readonly size: number;
|
||||||
/**
|
/**
|
||||||
* The content-type of the `Blob`.
|
* The content-type of the `Blob`.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly type: string;
|
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
|
* 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.
|
* the `Blob` data.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
arrayBuffer(): Promise<ArrayBuffer>;
|
arrayBuffer(): Promise<ArrayBuffer>;
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
||||||
* data. The original `Blob` is not altered.
|
* data. The original `Blob` is not altered.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
* @param start The starting index.
|
* @param start The starting index.
|
||||||
* @param end The ending index.
|
* @param end The ending index.
|
||||||
* @param type The content-type for the new `Blob`
|
* @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
|
* Returns a promise that fulfills with the contents of the `Blob` decoded as a
|
||||||
* UTF-8 string.
|
* UTF-8 string.
|
||||||
* @since v15.7.0
|
* @since v15.7.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
text(): Promise<string>;
|
text(): Promise<string>;
|
||||||
/**
|
/**
|
||||||
@ -169,6 +168,12 @@ declare module 'buffer' {
|
|||||||
}
|
}
|
||||||
export import atob = globalThis.atob;
|
export import atob = globalThis.atob;
|
||||||
export import btoa = globalThis.btoa;
|
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 {
|
global {
|
||||||
// Buffer class
|
// Buffer class
|
||||||
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
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
|
* @since v0.11.13
|
||||||
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
* @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.
|
* 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.
|
* 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_
|
* 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
|
* ```js
|
||||||
* import { Buffer } from 'buffer';
|
* import { Buffer } from 'buffer';
|
||||||
@ -485,7 +490,7 @@ declare module 'buffer' {
|
|||||||
* if `size` is 0.
|
* if `size` is 0.
|
||||||
*
|
*
|
||||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
* 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.
|
* such `Buffer` instances with zeroes.
|
||||||
*
|
*
|
||||||
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
* 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 [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).
|
* @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`.
|
* 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
|
* Returns a new `Buffer` that references the same memory as the original, but
|
||||||
* offset and cropped by the `start` and `end` indices.
|
* 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()`,
|
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||||
* which is a superclass of `Buffer`. To copy the slice, use`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());
|
* console.log(buf.toString());
|
||||||
* // Prints: buffer
|
* // 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
|
* @since v0.3.0
|
||||||
|
* @deprecated Use `subarray` instead.
|
||||||
* @param [start=0] Where the new `Buffer` will start.
|
* @param [start=0] Where the new `Buffer` will start.
|
||||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
* @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 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.
|
* * 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
|
* * a number, `value` will be interpreted as an unsigned 8-bit integer
|
||||||
* value between `0` and `255`.
|
* value between `0` and `255`.
|
||||||
*
|
*
|
||||||
@ -2208,7 +2220,7 @@ declare module 'buffer' {
|
|||||||
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
* **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')`.**
|
* **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.
|
* @deprecated Use `Buffer.from(data, 'base64')` instead.
|
||||||
* @param data The Base64-encoded input string.
|
* @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.**
|
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
* **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')`.**
|
* **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.
|
* @deprecated Use `buf.toString('base64')` instead.
|
||||||
* @param data An ASCII (Latin1) string.
|
* @param data An ASCII (Latin1) string.
|
||||||
*/
|
*/
|
||||||
function btoa(data: string): 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' {
|
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
|
* 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.
|
* 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
|
* The command lookup is performed using the `options.env.PATH` environment
|
||||||
* variable if it is in the `options` object. Otherwise, `process.env.PATH` is
|
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
||||||
* used.
|
* 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
|
* On Windows, environment variables are case-insensitive. Node.js
|
||||||
* lexicographically sorts the `env` keys and uses the first one that
|
* 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,
|
* 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
|
* the synchronous methods can have significant impact on performance due to
|
||||||
* stalling the event loop while spawned processes complete.
|
* 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' {
|
declare module 'child_process' {
|
||||||
import { ObjectEncodingOptions } from 'node:fs';
|
import { ObjectEncodingOptions } from 'node:fs';
|
||||||
@ -624,7 +627,7 @@ declare module 'child_process' {
|
|||||||
}
|
}
|
||||||
interface CommonOptions extends ProcessEnvOptions {
|
interface CommonOptions extends ProcessEnvOptions {
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default true
|
||||||
*/
|
*/
|
||||||
windowsHide?: boolean | undefined;
|
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
|
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
||||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
* that can distribute workloads among their application threads. When process
|
||||||
* processes to handle the load.
|
* 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
|
* The cluster module allows easy creation of child processes that all share
|
||||||
* server ports.
|
* server ports.
|
||||||
@ -52,7 +53,7 @@
|
|||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
* 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' {
|
declare module 'cluster' {
|
||||||
import * as child from 'node:child_process';
|
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.
|
* 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:
|
* 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, callback?: (error: Error | null) => void): boolean;
|
||||||
send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, 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
|
* This function will kill the worker. In the primary worker, it does this by
|
||||||
* by disconnecting the `worker.process`, and once disconnected, killing
|
* disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
|
||||||
* with `signal`. In the worker, it does it by disconnecting the channel,
|
|
||||||
* and then exiting with code `0`.
|
|
||||||
*
|
*
|
||||||
* Because `kill()` attempts to gracefully disconnect the worker process, it is
|
* The `kill()` function kills the worker process without waiting for a graceful
|
||||||
* susceptible to waiting indefinitely for the disconnect to complete. For example,
|
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||||
* 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()`.
|
|
||||||
*
|
*
|
||||||
* Causes `.exitedAfterDisconnect` to be set.
|
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
||||||
*
|
|
||||||
* This method is aliased as `worker.destroy()` for backward compatibility.
|
|
||||||
*
|
*
|
||||||
* In a worker, `process.kill()` exists, but it is not this function;
|
* In a worker, `process.kill()` exists, but it is not this function;
|
||||||
* it is `kill()`.
|
* it is `kill()`.
|
||||||
@ -256,7 +251,8 @@ declare module 'cluster' {
|
|||||||
*/
|
*/
|
||||||
isDead(): boolean;
|
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`.
|
* worker has not exited, it is `undefined`.
|
||||||
*
|
*
|
||||||
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
* 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
|
* The `console` module provides a simple debugging console that is similar to the
|
||||||
@ -56,7 +56,7 @@
|
|||||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||||
* // Prints: Danger Will Robinson! Danger!, to err
|
* // 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' {
|
declare module 'console' {
|
||||||
import console = require('node: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
|
* The `crypto` module provides cryptographic functionality that includes a set of
|
||||||
@ -16,12 +16,64 @@
|
|||||||
* // Prints:
|
* // Prints:
|
||||||
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
* // 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' {
|
declare module 'crypto' {
|
||||||
import * as stream from 'node:stream';
|
import * as stream from 'node:stream';
|
||||||
import { PeerCertificate } from 'node:tls';
|
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
|
* @deprecated
|
||||||
* @param spkac
|
* @param spkac
|
||||||
@ -45,31 +97,6 @@ declare module 'crypto' {
|
|||||||
*/
|
*/
|
||||||
verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
|
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 {
|
namespace constants {
|
||||||
// https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
|
// https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
|
||||||
const OPENSSL_VERSION_NUMBER: number;
|
const OPENSSL_VERSION_NUMBER: number;
|
||||||
@ -175,7 +202,7 @@ declare module 'crypto' {
|
|||||||
*
|
*
|
||||||
* The `algorithm` is dependent on the available algorithms supported by the
|
* The `algorithm` is dependent on the available algorithms supported by the
|
||||||
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
* 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.
|
* display the available digest algorithms.
|
||||||
*
|
*
|
||||||
* Example: generating the sha256 sum of a file
|
* 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
|
* The `algorithm` is dependent on the available algorithms supported by the
|
||||||
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
* 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.
|
* display the available digest algorithms.
|
||||||
*
|
*
|
||||||
* The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
|
* 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;
|
function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
|
||||||
// https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
|
// 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 CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
|
||||||
type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
|
type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
|
||||||
type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
|
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`.
|
* 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
|
* 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
|
* 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.
|
* 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
|
* 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.
|
* display the available cipher algorithms.
|
||||||
*
|
*
|
||||||
* The `password` is used to derive the cipher key and initialization vector (IV).
|
* The `password` is used to derive the cipher key and initialization vector (IV).
|
||||||
@ -700,12 +728,13 @@ declare module 'crypto' {
|
|||||||
* initialization vector (`iv`).
|
* initialization vector (`iv`).
|
||||||
*
|
*
|
||||||
* The `options` argument controls stream behavior and is optional except when a
|
* 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
|
* 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.
|
* 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
|
* 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.
|
* 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
|
* 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).
|
* 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
|
* 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`.
|
* 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
|
* 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
|
* 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`).
|
* 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
|
* 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
|
* 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.
|
* 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
|
* 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.
|
* 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
|
* 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;
|
format?: KeyFormat | undefined;
|
||||||
type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
|
type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
|
||||||
passphrase?: string | Buffer | undefined;
|
passphrase?: string | Buffer | undefined;
|
||||||
encoding?: string | undefined;
|
|
||||||
}
|
}
|
||||||
interface PublicKeyInput {
|
interface PublicKeyInput {
|
||||||
key: string | Buffer;
|
key: string | Buffer;
|
||||||
format?: KeyFormat | undefined;
|
format?: KeyFormat | undefined;
|
||||||
type?: 'pkcs1' | 'spki' | 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`.
|
* 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 {
|
interface VerifyKeyObjectInput extends SigningOptions {
|
||||||
key: KeyObject;
|
key: KeyObject;
|
||||||
}
|
}
|
||||||
interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
|
||||||
type KeyLike = string | Buffer | KeyObject;
|
type KeyLike = string | Buffer | KeyObject;
|
||||||
/**
|
/**
|
||||||
* The `Sign` class is a utility for generating signatures. It can be used in one
|
* 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.
|
* be passed instead of a public key.
|
||||||
* @since v0.1.92
|
* @since v0.1.92
|
||||||
*/
|
*/
|
||||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
||||||
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
|
verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
|
* Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
|
||||||
@ -1453,10 +1481,10 @@ declare module 'crypto' {
|
|||||||
* @param [generator=2]
|
* @param [generator=2]
|
||||||
* @param generatorEncoding The `encoding` of the `generator` string.
|
* @param generatorEncoding The `encoding` of the `generator` string.
|
||||||
*/
|
*/
|
||||||
function createDiffieHellman(primeLength: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
|
function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
|
||||||
function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
|
function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
|
||||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding): DiffieHellman;
|
function createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
|
||||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
|
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView): DiffieHellman;
|
||||||
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
|
function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
|
||||||
/**
|
/**
|
||||||
* The `DiffieHellman` class is a utility for creating Diffie-Hellman key
|
* 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
|
* 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).
|
* 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).
|
* 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
|
* 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
|
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
|
||||||
* returned.
|
* returned.
|
||||||
* @since v0.11.14
|
* @since v0.11.14
|
||||||
* @param encoding The `encoding` of the return value.
|
* @param [encoding] The `encoding` of the return value.
|
||||||
* @param [format='uncompressed']
|
* @param [format='uncompressed']
|
||||||
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
* @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;
|
getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
|
||||||
/**
|
/**
|
||||||
* Sets the EC Diffie-Hellman private key.
|
* 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/).
|
* 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
|
* `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
|
* 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
|
* entry, such as `Uint16Array`, the result will be computed using the platform
|
||||||
@ -2331,7 +2360,7 @@ declare module 'crypto' {
|
|||||||
/** @deprecated since v10.0.0 */
|
/** @deprecated since v10.0.0 */
|
||||||
const DEFAULT_ENCODING: BufferEncoding;
|
const DEFAULT_ENCODING: BufferEncoding;
|
||||||
type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
|
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> {
|
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
||||||
format: T;
|
format: T;
|
||||||
cipher?: string | undefined;
|
cipher?: string | undefined;
|
||||||
@ -2942,16 +2971,11 @@ declare module 'crypto' {
|
|||||||
* If the `callback` function is provided this function uses libuv's threadpool.
|
* If the `callback` function is provided this function uses libuv's threadpool.
|
||||||
* @since v12.0.0
|
* @since v12.0.0
|
||||||
*/
|
*/
|
||||||
|
function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
|
||||||
function verify(
|
function verify(
|
||||||
algorithm: string | null | undefined,
|
algorithm: string | null | undefined,
|
||||||
data: NodeJS.ArrayBufferView,
|
data: NodeJS.ArrayBufferView,
|
||||||
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
|
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,
|
signature: NodeJS.ArrayBufferView,
|
||||||
callback: (error: Error | null, result: boolean) => void
|
callback: (error: Error | null, result: boolean) => void
|
||||||
): void;
|
): void;
|
||||||
@ -3100,34 +3124,33 @@ declare module 'crypto' {
|
|||||||
*/
|
*/
|
||||||
disableEntropyCache?: boolean | undefined;
|
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
|
* 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.
|
* 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 {
|
interface X509CheckOptions {
|
||||||
/**
|
/**
|
||||||
* @default 'always'
|
* @default 'always'
|
||||||
*/
|
*/
|
||||||
subject?: 'always' | 'default' | 'never';
|
subject: 'always' | 'never';
|
||||||
/**
|
/**
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
wildcards?: boolean;
|
wildcards: boolean;
|
||||||
/**
|
/**
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
partialWildcards?: boolean;
|
partialWildcards: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
multiLabelWildcards?: boolean;
|
multiLabelWildcards: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
singleLabelSubdomains?: boolean;
|
singleLabelSubdomains: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Encapsulates an X509 certificate and provides read-only access to
|
* Encapsulates an X509 certificate and provides read-only access to
|
||||||
@ -3144,12 +3167,16 @@ declare module 'crypto' {
|
|||||||
*/
|
*/
|
||||||
class X509Certificate {
|
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
|
* @since v15.6.0
|
||||||
*/
|
*/
|
||||||
readonly ca: boolean;
|
readonly ca: boolean;
|
||||||
/**
|
/**
|
||||||
* The SHA-1 fingerprint of this certificate.
|
* 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
|
* @since v15.6.0
|
||||||
*/
|
*/
|
||||||
readonly fingerprint: string;
|
readonly fingerprint: string;
|
||||||
@ -3208,6 +3235,10 @@ declare module 'crypto' {
|
|||||||
readonly raw: Buffer;
|
readonly raw: Buffer;
|
||||||
/**
|
/**
|
||||||
* The serial number of this certificate.
|
* 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
|
* @since v15.6.0
|
||||||
*/
|
*/
|
||||||
readonly serialNumber: string;
|
readonly serialNumber: string;
|
||||||
@ -3224,18 +3255,50 @@ declare module 'crypto' {
|
|||||||
constructor(buffer: BinaryLike);
|
constructor(buffer: BinaryLike);
|
||||||
/**
|
/**
|
||||||
* Checks whether the certificate matches the given email address.
|
* 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
|
* @since v15.6.0
|
||||||
* @return Returns `email` if the certificate matches, `undefined` if it does not.
|
* @return Returns `email` if the certificate matches, `undefined` if it does not.
|
||||||
*/
|
*/
|
||||||
checkEmail(email: string, options?: Pick<X509CheckOptions, 'subject'>): string | undefined;
|
checkEmail(email: string, options?: Pick<X509CheckOptions, 'subject'>): string | undefined;
|
||||||
/**
|
/**
|
||||||
* Checks whether the certificate matches the given host name.
|
* 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
|
* @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;
|
checkHost(name: string, options?: X509CheckOptions): string | undefined;
|
||||||
/**
|
/**
|
||||||
* Checks whether the certificate matches the given IP address (IPv4 or IPv6).
|
* 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
|
* @since v15.6.0
|
||||||
* @return Returns `ip` if the certificate matches, `undefined` if it does not.
|
* @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]
|
* @param [flags=crypto.constants.ENGINE_METHOD_ALL]
|
||||||
*/
|
*/
|
||||||
function setEngine(engine: string, flags?: number): void;
|
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.
|
* 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.
|
* The UUID is generated using a cryptographic pseudorandom number generator.
|
||||||
* @since v16.7.0
|
* @since v16.7.0
|
||||||
*/
|
*/
|
||||||
randomUUID(): UUID;
|
randomUUID(): string;
|
||||||
CryptoKey: CryptoKeyConstructor;
|
CryptoKey: CryptoKeyConstructor;
|
||||||
}
|
}
|
||||||
// This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
|
// 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`,
|
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
||||||
* `subtle.deriveBits()` attempts to generate `length` bits.
|
* `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.
|
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
||||||
*
|
*
|
||||||
* The algorithms currently supported include:
|
* The algorithms currently supported include:
|
||||||
*
|
*
|
||||||
* - `'ECDH'`
|
* - `'ECDH'`
|
||||||
|
* - `'X25519'`
|
||||||
|
* - `'X448'`
|
||||||
* - `'HKDF'`
|
* - `'HKDF'`
|
||||||
* - `'PBKDF2'`
|
* - `'PBKDF2'`
|
||||||
* @since v15.0.0
|
* @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`,
|
* 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`.
|
* `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:
|
* The algorithms currently supported include:
|
||||||
*
|
*
|
||||||
* - `'ECDH'`
|
* - `'ECDH'`
|
||||||
|
* - `'X25519'`
|
||||||
|
* - `'X448'`
|
||||||
* - `'HKDF'`
|
* - `'HKDF'`
|
||||||
* - `'PBKDF2'`
|
* - `'PBKDF2'`
|
||||||
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
* @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-PSS'`
|
||||||
* - `'RSA-OAEP'`
|
* - `'RSA-OAEP'`
|
||||||
* - `'ECDSA'`
|
* - `'ECDSA'`
|
||||||
|
* - `'Ed25519'`
|
||||||
|
* - `'Ed448'`
|
||||||
* - `'ECDH'`
|
* - `'ECDH'`
|
||||||
|
* - `'X25519'`
|
||||||
|
* - `'X448'`
|
||||||
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
||||||
*
|
*
|
||||||
* - `'HMAC'`
|
* - `'HMAC'`
|
||||||
@ -3787,6 +3874,8 @@ declare module 'crypto' {
|
|||||||
* - `'RSASSA-PKCS1-v1_5'`
|
* - `'RSASSA-PKCS1-v1_5'`
|
||||||
* - `'RSA-PSS'`
|
* - `'RSA-PSS'`
|
||||||
* - `'ECDSA'`
|
* - `'ECDSA'`
|
||||||
|
* - `'Ed25519'`
|
||||||
|
* - `'Ed448'`
|
||||||
* - `'HMAC'`
|
* - `'HMAC'`
|
||||||
* @since v15.0.0
|
* @since v15.0.0
|
||||||
*/
|
*/
|
||||||
@ -3812,7 +3901,11 @@ declare module 'crypto' {
|
|||||||
* - `'RSA-PSS'`
|
* - `'RSA-PSS'`
|
||||||
* - `'RSA-OAEP'`
|
* - `'RSA-OAEP'`
|
||||||
* - `'ECDSA'`
|
* - `'ECDSA'`
|
||||||
|
* - `'Ed25519'`
|
||||||
|
* - `'Ed448'`
|
||||||
* - `'ECDH'`
|
* - `'ECDH'`
|
||||||
|
* - `'X25519'`
|
||||||
|
* - `'X448'`
|
||||||
* - `'HMAC'`
|
* - `'HMAC'`
|
||||||
* - `'AES-CTR'`
|
* - `'AES-CTR'`
|
||||||
* - `'AES-CBC'`
|
* - `'AES-CBC'`
|
||||||
@ -3841,6 +3934,8 @@ declare module 'crypto' {
|
|||||||
* - `'RSASSA-PKCS1-v1_5'`
|
* - `'RSASSA-PKCS1-v1_5'`
|
||||||
* - `'RSA-PSS'`
|
* - `'RSA-PSS'`
|
||||||
* - `'ECDSA'`
|
* - `'ECDSA'`
|
||||||
|
* - `'Ed25519'`
|
||||||
|
* - `'Ed448'`
|
||||||
* - `'HMAC'`
|
* - `'HMAC'`
|
||||||
* @since v15.0.0
|
* @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.
|
* The `dgram` module provides an implementation of UDP datagram sockets.
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* server.bind(41234);
|
* server.bind(41234);
|
||||||
* // Prints: server listening 0.0.0.0: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' {
|
declare module 'dgram' {
|
||||||
import { AddressInfo } from 'node:net';
|
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,
|
* 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
|
* 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
|
* 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
|
* 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.
|
* 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.
|
* 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.
|
* is 64.
|
||||||
*
|
*
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
* 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
|
* 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
|
* should generally include the module name to avoid collisions with data from
|
||||||
* other modules.
|
* other modules.
|
||||||
* @experimental
|
* @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' {
|
declare module 'diagnostics_channel' {
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ declare module 'diagnostics_channel' {
|
|||||||
* @param name The channel name
|
* @param name The channel name
|
||||||
* @return If there are active subscribers
|
* @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
|
* 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
|
* 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
|
* @param name The channel name
|
||||||
* @return The named channel object
|
* @return The named channel object
|
||||||
*/
|
*/
|
||||||
function channel(name: string | symbol): Channel;
|
function channel(name: string): Channel;
|
||||||
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
type ChannelListener = (message: unknown, name: string) => void;
|
||||||
/**
|
/**
|
||||||
* The class `Channel` represents an individual named channel within the data
|
* The class `Channel` represents an individual named channel within the data
|
||||||
* pipeline. It is use to track subscribers and to publish messages when there
|
* 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
|
* @since v15.1.0, v14.17.0
|
||||||
*/
|
*/
|
||||||
class Channel {
|
class Channel {
|
||||||
readonly name: string | symbol;
|
readonly name: string;
|
||||||
/**
|
/**
|
||||||
* Check if there are active subscribers to this channel. This is helpful if
|
* Check if there are active subscribers to this channel. This is helpful if
|
||||||
* the message you want to send might be expensive to prepare.
|
* 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
|
* @since v15.1.0, v14.17.0
|
||||||
*/
|
*/
|
||||||
readonly hasSubscribers: boolean;
|
readonly hasSubscribers: boolean;
|
||||||
private constructor(name: string | symbol);
|
private constructor(name: string);
|
||||||
/**
|
/**
|
||||||
* Publish a message to any subscribers to the channel. This will
|
* Publish a message to any subscribers to the channel. This will
|
||||||
* trigger message handlers synchronously so they will execute within
|
* trigger message handlers synchronously so they will execute within
|
||||||
@ -146,6 +146,7 @@ declare module 'diagnostics_channel' {
|
|||||||
* ```
|
* ```
|
||||||
* @since v15.1.0, v14.17.0
|
* @since v15.1.0, v14.17.0
|
||||||
* @param onMessage The previous subscribed handler to remove
|
* @param onMessage The previous subscribed handler to remove
|
||||||
|
* @return `true` if the handler was found, `false` otherwise.
|
||||||
*/
|
*/
|
||||||
unsubscribe(onMessage: ChannelListener): void;
|
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
|
* 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 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' {
|
declare module 'dns' {
|
||||||
import * as dnsPromises from 'node:dns/promises';
|
import * as dnsPromises from 'node:dns/promises';
|
||||||
@ -61,6 +61,9 @@ declare module 'dns' {
|
|||||||
family?: number | undefined;
|
family?: number | undefined;
|
||||||
hints?: number | undefined;
|
hints?: number | undefined;
|
||||||
all?: boolean | undefined;
|
all?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
verbatim?: boolean | undefined;
|
verbatim?: boolean | undefined;
|
||||||
}
|
}
|
||||||
export interface LookupOneOptions extends LookupOptions {
|
export interface LookupOneOptions extends LookupOptions {
|
||||||
@ -174,7 +177,7 @@ declare module 'dns' {
|
|||||||
type: 'AAAA';
|
type: 'AAAA';
|
||||||
}
|
}
|
||||||
export interface CaaRecord {
|
export interface CaaRecord {
|
||||||
critical: number;
|
critial: number;
|
||||||
issue?: string | undefined;
|
issue?: string | undefined;
|
||||||
issuewild?: string | undefined;
|
issuewild?: string | undefined;
|
||||||
iodef?: 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
|
* 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
|
* 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'}]`).
|
* 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 function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
|
||||||
export namespace resolveCaa {
|
export namespace resolveCaa {
|
||||||
@ -530,14 +533,16 @@ declare module 'dns' {
|
|||||||
*/
|
*/
|
||||||
export function getServers(): string[];
|
export function getServers(): string[];
|
||||||
/**
|
/**
|
||||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
* 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`.
|
* * `ipv4first`: sets default `verbatim` `false`.
|
||||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
* * `verbatim`: sets default `verbatim` `true`.
|
||||||
* @since v14.18.0
|
*
|
||||||
* @param order must be 'ipv4first' or 'verbatim'.
|
* 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;
|
export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||||
// Error codes
|
// Error codes
|
||||||
@ -643,7 +648,7 @@ declare module 'dns' {
|
|||||||
* The resolver will use the v4 local address when making requests to IPv4 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.
|
* 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.
|
* 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 [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
||||||
* @param [ipv6='::0'] A string representation of an IPv6 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
|
* 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,
|
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
||||||
* the `Promise` is resolved with an array of objects containing available
|
* 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'}]`).
|
* 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[]>;
|
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||||
/**
|
/**
|
||||||
@ -335,14 +335,16 @@ declare module 'dns/promises' {
|
|||||||
*/
|
*/
|
||||||
function setServers(servers: ReadonlyArray<string>): void;
|
function setServers(servers: ReadonlyArray<string>): void;
|
||||||
/**
|
/**
|
||||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
* 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 {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
|
* * `ipv4first`: sets default `verbatim` `false`.
|
||||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
* * `verbatim`: sets default `verbatim` `true`.
|
||||||
* @since v14.18.0
|
*
|
||||||
* @param order must be 'ipv4first' or 'verbatim'.
|
* 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;
|
function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
||||||
class Resolver {
|
class Resolver {
|
||||||
|
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
|
* **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
|
* 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.
|
* exit immediately with an error code.
|
||||||
* @deprecated Since v1.4.2 - Deprecated
|
* @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' {
|
declare module 'domain' {
|
||||||
import EventEmitter = require('node:events');
|
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
|
* Much of the Node.js core API is built around an idiomatic asynchronous
|
||||||
@ -35,19 +35,56 @@
|
|||||||
* });
|
* });
|
||||||
* myEmitter.emit('event');
|
* 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' {
|
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 {
|
interface EventEmitterOptions {
|
||||||
/**
|
/**
|
||||||
* Enables automatic capturing of promise rejection.
|
* Enables automatic capturing of promise rejection.
|
||||||
*/
|
*/
|
||||||
captureRejections?: boolean | undefined;
|
captureRejections?: boolean | undefined;
|
||||||
}
|
}
|
||||||
interface NodeEventTarget {
|
// Any EventTarget with a Node-style `once` function
|
||||||
|
interface _NodeEventTarget {
|
||||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
}
|
}
|
||||||
interface DOMEventTarget {
|
// Any EventTarget with a DOM-style `addEventListener`
|
||||||
|
interface _DOMEventTarget {
|
||||||
addEventListener(
|
addEventListener(
|
||||||
eventName: string,
|
eventName: string,
|
||||||
listener: (...args: any[]) => void,
|
listener: (...args: any[]) => void,
|
||||||
@ -157,8 +194,8 @@ declare module 'events' {
|
|||||||
* ```
|
* ```
|
||||||
* @since v11.13.0, v10.16.0
|
* @since v11.13.0, v10.16.0
|
||||||
*/
|
*/
|
||||||
static once(emitter: NodeEventTarget, eventName: string | symbol, 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[]>;
|
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||||
/**
|
/**
|
||||||
* ```js
|
* ```js
|
||||||
* const { on, EventEmitter } = require('events');
|
* const { on, EventEmitter } = require('events');
|
||||||
@ -260,9 +297,9 @@ declare module 'events' {
|
|||||||
* getEventListeners(et, 'foo'); // [listener]
|
* 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
|
* ```js
|
||||||
* const {
|
* 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}
|
* @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.
|
* 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'`
|
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||||
* events. Listeners installed using this symbol are called before the regular
|
* 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.
|
* called multiple times to remove each instance.
|
||||||
*
|
*
|
||||||
* Once an event is emitted, all listeners attached to it at the
|
* 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
|
* time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
|
||||||
* not remove them from`emit()` in progress. Subsequent events behave as expected.
|
* will not remove them from`emit()` in progress. Subsequent events behave as expected.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* const myEmitter = new MyEmitter();
|
* const myEmitter = new MyEmitter();
|
||||||
@ -599,7 +636,7 @@ declare module 'events' {
|
|||||||
*/
|
*/
|
||||||
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
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.
|
* listener is removed, and then invoked.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```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
|
* 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
|
* All file system operations have synchronous, callback, and promise-based
|
||||||
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
* 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' {
|
declare module 'fs' {
|
||||||
import * as stream from 'node:stream';
|
import * as stream from 'node:stream';
|
||||||
@ -271,18 +271,22 @@ declare module 'fs' {
|
|||||||
*/
|
*/
|
||||||
export interface StatWatcher extends EventEmitter {
|
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
|
* @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;
|
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
|
* @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;
|
unref(): this;
|
||||||
}
|
}
|
||||||
@ -1017,8 +1021,10 @@ declare module 'fs' {
|
|||||||
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
|
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Synchronous fstat(2) - Get file status.
|
* Retrieves the `fs.Stats` for the file descriptor.
|
||||||
* @param fd A 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(
|
export function fstatSync(
|
||||||
fd: number,
|
fd: number,
|
||||||
@ -1033,7 +1039,6 @@ declare module 'fs' {
|
|||||||
}
|
}
|
||||||
): BigIntStats;
|
): BigIntStats;
|
||||||
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
|
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the `fs.Stats` for the symbolic link referred to by the path.
|
* 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
|
* 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
|
* ```js
|
||||||
* import { symlink } from 'fs';
|
* 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
|
* The above example creates a symbolic link `mewtwo` which points to `mew` in the
|
||||||
* to `mew` in the same directory:
|
* same directory:
|
||||||
*
|
*
|
||||||
* ```bash
|
* ```bash
|
||||||
* $ tree example/
|
* $ tree .
|
||||||
* example/
|
* .
|
||||||
* ├── mew
|
* ├── mew
|
||||||
* └── mewtwo -> ./mew
|
* └── mewtwo -> ./mew
|
||||||
* ```
|
* ```
|
||||||
@ -1393,7 +1398,7 @@ declare module 'fs' {
|
|||||||
* Use `fs.rm(path, { recursive: true, force: true })` instead.
|
* Use `fs.rm(path, { recursive: true, force: true })` instead.
|
||||||
*
|
*
|
||||||
* If `true`, perform a recursive directory removal. In
|
* If `true`, perform a recursive directory removal. In
|
||||||
* recursive mode soperations are retried on failure.
|
* recursive mode, operations are retried on failure.
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
recursive?: boolean | undefined;
|
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;
|
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`.
|
* 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 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;
|
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.
|
* @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 function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
||||||
|
|
||||||
export namespace open {
|
export namespace open {
|
||||||
/**
|
/**
|
||||||
* Asynchronous open(2) - open and possibly create a file.
|
* Asynchronous open(2) - open and possibly create a file.
|
||||||
@ -2096,8 +2102,7 @@ declare module 'fs' {
|
|||||||
*/
|
*/
|
||||||
export function fsyncSync(fd: number): void;
|
export function fsyncSync(fd: number): void;
|
||||||
/**
|
/**
|
||||||
* Write `buffer` to the file specified by `fd`. If `buffer` is a normal object, it
|
* Write `buffer` to the file specified by `fd`.
|
||||||
* must have an own `toString` function property.
|
|
||||||
*
|
*
|
||||||
* `offset` determines the part of the buffer to be written, and `length` is
|
* `offset` determines the part of the buffer to be written, and `length` is
|
||||||
* an integer specifying the number of bytes to write.
|
* 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
|
* For detailed information, see the documentation of the asynchronous version of
|
||||||
* this API: {@link write}.
|
* this API: {@link write}.
|
||||||
* @since v0.1.21
|
* @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 function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
|
||||||
export type ReadPosition = number | bigint;
|
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`.
|
* Read data from the file specified by `fd`.
|
||||||
*
|
*
|
||||||
@ -2262,6 +2282,21 @@ declare module 'fs' {
|
|||||||
position: ReadPosition | null,
|
position: ReadPosition | null,
|
||||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
||||||
): 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 {
|
export namespace read {
|
||||||
/**
|
/**
|
||||||
* @param fd A file descriptor.
|
* @param fd A file descriptor.
|
||||||
@ -2280,20 +2315,17 @@ declare module 'fs' {
|
|||||||
bytesRead: number;
|
bytesRead: number;
|
||||||
buffer: TBuffer;
|
buffer: TBuffer;
|
||||||
}>;
|
}>;
|
||||||
}
|
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
|
||||||
export interface ReadSyncOptions {
|
fd: number,
|
||||||
/**
|
options: ReadAsyncOptions<TBuffer>
|
||||||
* @default 0
|
): Promise<{
|
||||||
*/
|
bytesRead: number;
|
||||||
offset?: number | undefined;
|
buffer: TBuffer;
|
||||||
/**
|
}>;
|
||||||
* @default `length of buffer`
|
function __promisify__(fd: number): Promise<{
|
||||||
*/
|
bytesRead: number;
|
||||||
length?: number | undefined;
|
buffer: NodeJS.ArrayBufferView;
|
||||||
/**
|
}>;
|
||||||
* @default null
|
|
||||||
*/
|
|
||||||
position?: ReadPosition | null | undefined;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the number of `bytesRead`.
|
* 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.
|
* 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
|
* ```js
|
||||||
* import { writeFile } from 'fs';
|
* import { writeFile } from 'fs';
|
||||||
* import { Buffer } from 'buffer';
|
* import { Buffer } from 'buffer';
|
||||||
@ -2636,8 +2666,6 @@ declare module 'fs' {
|
|||||||
/**
|
/**
|
||||||
* Returns `undefined`.
|
* 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.
|
* 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
|
* For detailed information, see the documentation of the asynchronous version of
|
||||||
@ -2821,6 +2849,52 @@ declare module 'fs' {
|
|||||||
persistent?: boolean | undefined;
|
persistent?: boolean | undefined;
|
||||||
interval?: number | 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(
|
export function watchFile(
|
||||||
filename: PathLike,
|
filename: PathLike,
|
||||||
options:
|
options:
|
||||||
@ -3189,9 +3263,9 @@ declare module 'fs' {
|
|||||||
/**
|
/**
|
||||||
* Tests a user's permissions for the file or directory specified by `path`.
|
* Tests a user's permissions for the file or directory specified by `path`.
|
||||||
* The `mode` argument is an optional integer that specifies the accessibility
|
* The `mode` argument is an optional integer that specifies the accessibility
|
||||||
* checks to be performed. Check `File access constants` for possible values
|
* 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`
|
||||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
* possible values of `mode`.
|
||||||
*
|
*
|
||||||
* The final argument, `callback`, is a callback function that is invoked with
|
* 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
|
* 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'}`);
|
* console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* // Check if the file exists in the current directory, and if it is writable.
|
* // Check if the file is readable and writable.
|
||||||
* access(file, constants.F_OK | constants.W_OK, (err) => {
|
* access(file, constants.R_OK | constants.W_OK, (err) => {
|
||||||
* if (err) {
|
* console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
|
||||||
* console.error(
|
|
||||||
* `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
|
|
||||||
* } else {
|
|
||||||
* console.log(`${file} exists, and it is writable`);
|
|
||||||
* }
|
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -3368,10 +3437,9 @@ declare module 'fs' {
|
|||||||
/**
|
/**
|
||||||
* Synchronously tests a user's permissions for the file or directory specified
|
* Synchronously tests a user's permissions for the file or directory specified
|
||||||
* by `path`. The `mode` argument is an optional integer that specifies the
|
* by `path`. The `mode` argument is an optional integer that specifies the
|
||||||
* accessibility checks to be performed. Check `File access constants` for
|
* 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
|
||||||
* possible values of `mode`. It is possible to create a mask consisting of
|
* `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||||
* the bitwise OR of two or more values
|
* possible values of `mode`.
|
||||||
* (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
|
||||||
*
|
*
|
||||||
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
||||||
* the method will return `undefined`.
|
* 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
|
* `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
|
* 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
|
* \[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
|
||||||
* it may require the `flags` option to be set to `r+` rather than the default `w`.
|
* replacing it may require the `flags` option to be set to `r+` rather than the
|
||||||
* The `encoding` can be any one of those accepted by `Buffer`.
|
* 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,
|
* 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.
|
* then the file descriptor won't be closed, even if there's an error.
|
||||||
@ -3756,6 +3824,11 @@ declare module 'fs' {
|
|||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
recursive?: boolean;
|
recursive?: boolean;
|
||||||
|
/**
|
||||||
|
* When true, path resolution for symlinks will be skipped
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
verbatimSymlinks?: boolean;
|
||||||
}
|
}
|
||||||
export interface CopyOptions extends CopyOptionsBase {
|
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
|
* The `fs/promises` API provides asynchronous file system methods that return
|
||||||
@ -14,6 +14,7 @@
|
|||||||
declare module 'fs/promises' {
|
declare module 'fs/promises' {
|
||||||
import { Abortable } from 'node:events';
|
import { Abortable } from 'node:events';
|
||||||
import { Stream } from 'node:stream';
|
import { Stream } from 'node:stream';
|
||||||
|
import { ReadableStream } from 'node:stream/web';
|
||||||
import {
|
import {
|
||||||
BigIntStats,
|
BigIntStats,
|
||||||
BufferEncodingOption,
|
BufferEncodingOption,
|
||||||
@ -33,11 +34,14 @@ declare module 'fs/promises' {
|
|||||||
RmOptions,
|
RmOptions,
|
||||||
StatOptions,
|
StatOptions,
|
||||||
Stats,
|
Stats,
|
||||||
|
TimeLike,
|
||||||
WatchEventType,
|
WatchEventType,
|
||||||
WatchOptions,
|
WatchOptions,
|
||||||
WriteStream,
|
WriteStream,
|
||||||
WriteVResult,
|
WriteVResult,
|
||||||
} from 'node:fs';
|
} from 'node:fs';
|
||||||
|
import { Interface as ReadlineInterface } from 'node:readline';
|
||||||
|
|
||||||
interface FileChangeInfo<T extends string | Buffer> {
|
interface FileChangeInfo<T extends string | Buffer> {
|
||||||
eventType: WatchEventType;
|
eventType: WatchEventType;
|
||||||
filename: T;
|
filename: T;
|
||||||
@ -46,11 +50,11 @@ declare module 'fs/promises' {
|
|||||||
mode?: Mode | undefined;
|
mode?: Mode | undefined;
|
||||||
flag?: OpenMode | undefined;
|
flag?: OpenMode | undefined;
|
||||||
}
|
}
|
||||||
interface FileReadResult<T extends ArrayBufferView> {
|
interface FileReadResult<T extends NodeJS.ArrayBufferView> {
|
||||||
bytesRead: number;
|
bytesRead: number;
|
||||||
buffer: T;
|
buffer: T;
|
||||||
}
|
}
|
||||||
interface FileReadOptions<T extends ArrayBufferView = Buffer> {
|
interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
|
||||||
/**
|
/**
|
||||||
* @default `Buffer.alloc(0xffff)`
|
* @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
|
* `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
|
* 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
|
* \[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
|
||||||
* it may require the `flags` `open` option to be set to `r+` rather than the
|
* replacing it may require the `flags` `open` option to be set to `r+` rather than
|
||||||
* default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
* 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,
|
* 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.
|
* 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.
|
* integer, the current file position will remain unchanged.
|
||||||
* @return Fulfills upon success with an object with two properties:
|
* @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 NodeJS.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>(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.
|
* Asynchronously reads the entire contents of a file.
|
||||||
*
|
*
|
||||||
@ -261,6 +288,23 @@ declare module 'fs/promises' {
|
|||||||
| BufferEncoding
|
| BufferEncoding
|
||||||
| null
|
| null
|
||||||
): Promise<string | Buffer>;
|
): 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
|
* @since v10.0.0
|
||||||
* @return Fulfills with an {fs.Stats} for the file.
|
* @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.
|
* 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
|
* @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
|
* 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
|
* [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
|
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
||||||
* object with an own `toString` function
|
* The promise is resolved with no arguments upon success.
|
||||||
* property. The promise is resolved with no arguments upon success.
|
|
||||||
*
|
*
|
||||||
* If `options` is a string, then it specifies the `encoding`.
|
* If `options` is a string, then it specifies the `encoding`.
|
||||||
*
|
*
|
||||||
@ -333,20 +376,18 @@ declare module 'fs/promises' {
|
|||||||
/**
|
/**
|
||||||
* Write `buffer` to the file.
|
* 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:
|
* The promise is resolved with an object containing two properties:
|
||||||
*
|
*
|
||||||
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
* 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
|
* 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.
|
* 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 kernel ignores the position argument and always appends the data to
|
||||||
* the end of the file.
|
* the end of the file.
|
||||||
* @since v10.0.0
|
* @since v10.0.0
|
||||||
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
* @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.
|
* @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.
|
* See the POSIX pwrite(2) documentation for more detail.
|
||||||
*/
|
*/
|
||||||
@ -411,12 +452,13 @@ declare module 'fs/promises' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const constants: typeof fsConstants;
|
const constants: typeof fsConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests a user's permissions for the file or directory specified by `path`.
|
* Tests a user's permissions for the file or directory specified by `path`.
|
||||||
* The `mode` argument is an optional integer that specifies the accessibility
|
* The `mode` argument is an optional integer that specifies the accessibility
|
||||||
* checks to be performed. Check `File access constants` for possible values
|
* 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`
|
||||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
* possible values of `mode`.
|
||||||
*
|
*
|
||||||
* If the accessibility check is successful, the promise is resolved with no
|
* If the accessibility check is successful, the promise is resolved with no
|
||||||
* value. If any of the accessibility checks fail, the promise is rejected
|
* 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
|
* @since v14.5.0, v12.19.0
|
||||||
* @return Fulfills with `undefined` upon success.
|
* @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.
|
* Changes the ownership of a file.
|
||||||
* @since v10.0.0
|
* @since v10.0.0
|
||||||
@ -765,7 +807,7 @@ declare module 'fs/promises' {
|
|||||||
* @since v10.0.0
|
* @since v10.0.0
|
||||||
* @return Fulfills with `undefined` upon success.
|
* @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.
|
* 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>;
|
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.
|
* 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
|
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
||||||
* method that performs multiple `write` calls internally to write the buffer
|
* 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()`.
|
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
||||||
* Cancelation is "best effort", and some amount of data is likely still
|
* Cancelation is "best effort", and some amount of data is likely still
|
||||||
@ -1049,7 +1093,7 @@ declare module 'fs/promises' {
|
|||||||
* disappears in the directory.
|
* disappears in the directory.
|
||||||
*
|
*
|
||||||
* All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
|
* 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:
|
* @return of objects with the properties:
|
||||||
*/
|
*/
|
||||||
function watch(
|
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
|
// Declare "static" methods in Error
|
||||||
interface ErrorConstructor {
|
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.
|
* 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. */
|
/** 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.
|
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
||||||
*/
|
*/
|
||||||
readonly aborted: boolean;
|
readonly aborted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var AbortController: {
|
declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T}
|
||||||
prototype: AbortController;
|
? T
|
||||||
new(): AbortController;
|
: {
|
||||||
};
|
prototype: AbortController;
|
||||||
|
new(): AbortController;
|
||||||
|
};
|
||||||
|
|
||||||
declare var AbortSignal: {
|
declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal: infer T}
|
||||||
prototype: AbortSignal;
|
? T
|
||||||
new(): AbortSignal;
|
: {
|
||||||
abort(reason?: any): AbortSignal;
|
prototype: AbortSignal;
|
||||||
timeout(milliseconds: number): AbortSignal;
|
new(): AbortSignal;
|
||||||
};
|
abort(reason?: any): AbortSignal;
|
||||||
|
timeout(milliseconds: number): AbortSignal;
|
||||||
|
};
|
||||||
//#endregion borrowed
|
//#endregion borrowed
|
||||||
|
|
||||||
//#region ArrayLike.at()
|
//#region ArrayLike.at()
|
||||||
@ -105,6 +109,16 @@ interface BigInt64Array extends RelativeIndexable<bigint> {}
|
|||||||
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
||||||
//#endregion ArrayLike.at() end
|
//#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 *
|
* GLOBAL INTERFACES *
|
||||||
@ -210,9 +224,9 @@ declare namespace NodeJS {
|
|||||||
writable: boolean;
|
writable: boolean;
|
||||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||||
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||||
end(cb?: () => void): void;
|
end(cb?: () => void): this;
|
||||||
end(data: string | Uint8Array, cb?: () => void): void;
|
end(data: string | Uint8Array, cb?: () => void): this;
|
||||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
|
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadWriteStream extends ReadableStream, WritableStream { }
|
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')`.
|
* To use the HTTP server and client one must `require('http')`.
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* { 'content-length': '123',
|
* { 'content-length': '123',
|
||||||
* 'content-type': 'text/plain',
|
* 'content-type': 'text/plain',
|
||||||
* 'connection': 'keep-alive',
|
* 'connection': 'keep-alive',
|
||||||
* 'host': 'mysite.com',
|
* 'host': 'example.com',
|
||||||
* 'accept': '*' }
|
* 'accept': '*' }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -37,10 +37,10 @@
|
|||||||
* 'content-LENGTH', '123',
|
* 'content-LENGTH', '123',
|
||||||
* 'content-type', 'text/plain',
|
* 'content-type', 'text/plain',
|
||||||
* 'CONNECTION', 'keep-alive',
|
* 'CONNECTION', 'keep-alive',
|
||||||
* 'Host', 'mysite.com',
|
* 'Host', 'example.com',
|
||||||
* 'accepT', '*' ]
|
* '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' {
|
declare module 'http' {
|
||||||
import * as stream from 'node:stream';
|
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
|
* Limit the amount of time the parser will wait to receive the complete HTTP
|
||||||
* headers.
|
* headers.
|
||||||
*
|
*
|
||||||
* In case of inactivity, the rules defined in `server.timeout` apply. However,
|
* If the timeout expires, the server responds with status 408 without
|
||||||
* that inactivity based timeout would still allow the connection to be kept open
|
* forwarding the request to the request listener and then closes the connection.
|
||||||
* 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
|
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
||||||
* check is made that more than `server.headersTimeout` milliseconds has not
|
* potential Denial-of-Service attacks in case the server is deployed without a
|
||||||
* 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.
|
* reverse proxy in front.
|
||||||
* See `server.timeout` for more information on how timeout behavior can be
|
|
||||||
* customized.
|
|
||||||
* @since v11.3.0, v10.14.0
|
* @since v11.3.0, v10.14.0
|
||||||
*/
|
*/
|
||||||
headersTimeout: number;
|
headersTimeout: number;
|
||||||
@ -284,6 +282,16 @@ declare module 'http' {
|
|||||||
* @since v14.11.0
|
* @since v14.11.0
|
||||||
*/
|
*/
|
||||||
requestTimeout: number;
|
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: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: 'close', listener: () => void): this;
|
||||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
@ -410,7 +418,7 @@ declare module 'http' {
|
|||||||
/**
|
/**
|
||||||
* Aliases of `outgoingMessage.socket`
|
* Aliases of `outgoingMessage.socket`
|
||||||
* @since v0.3.0
|
* @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;
|
readonly connection: Socket | null;
|
||||||
/**
|
/**
|
||||||
@ -461,13 +469,13 @@ declare module 'http' {
|
|||||||
* const headers = outgoingMessage.getHeaders();
|
* const headers = outgoingMessage.getHeaders();
|
||||||
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
||||||
* ```
|
* ```
|
||||||
* @since v8.0.0
|
* @since v7.7.0
|
||||||
*/
|
*/
|
||||||
getHeaders(): OutgoingHttpHeaders;
|
getHeaders(): OutgoingHttpHeaders;
|
||||||
/**
|
/**
|
||||||
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
||||||
* names are lowercase.
|
* names are lowercase.
|
||||||
* @since v8.0.0
|
* @since v7.7.0
|
||||||
*/
|
*/
|
||||||
getHeaderNames(): string[];
|
getHeaderNames(): string[];
|
||||||
/**
|
/**
|
||||||
@ -477,7 +485,7 @@ declare module 'http' {
|
|||||||
* ```js
|
* ```js
|
||||||
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
||||||
* ```
|
* ```
|
||||||
* @since v8.0.0
|
* @since v7.7.0
|
||||||
*/
|
*/
|
||||||
hasHeader(name: string): boolean;
|
hasHeader(name: string): boolean;
|
||||||
/**
|
/**
|
||||||
@ -487,6 +495,7 @@ declare module 'http' {
|
|||||||
* outgoingMessage.removeHeader('Content-Encoding');
|
* outgoingMessage.removeHeader('Content-Encoding');
|
||||||
* ```
|
* ```
|
||||||
* @since v0.4.0
|
* @since v0.4.0
|
||||||
|
* @param name Header name
|
||||||
*/
|
*/
|
||||||
removeHeader(name: string): void;
|
removeHeader(name: string): void;
|
||||||
/**
|
/**
|
||||||
@ -564,11 +573,46 @@ declare module 'http' {
|
|||||||
assignSocket(socket: Socket): void;
|
assignSocket(socket: Socket): void;
|
||||||
detachSocket(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`.
|
* the request body should be sent. See the `'checkContinue'` event on`Server`.
|
||||||
* @since v0.3.0
|
* @since v0.3.0
|
||||||
*/
|
*/
|
||||||
writeContinue(callback?: () => void): void;
|
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
|
* 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.
|
* status code, like `404`. The last argument, `headers`, are the response headers.
|
||||||
@ -633,7 +677,7 @@ declare module 'http' {
|
|||||||
): this;
|
): this;
|
||||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): 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.
|
* the request body should be sent.
|
||||||
* @since v10.0.0
|
* @since v10.0.0
|
||||||
*/
|
*/
|
||||||
@ -681,6 +725,7 @@ declare module 'http' {
|
|||||||
* The `request.aborted` property will be `true` if the request has
|
* The `request.aborted` property will be `true` if the request has
|
||||||
* been aborted.
|
* been aborted.
|
||||||
* @since v0.11.14
|
* @since v0.11.14
|
||||||
|
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
||||||
*/
|
*/
|
||||||
aborted: boolean;
|
aborted: boolean;
|
||||||
/**
|
/**
|
||||||
@ -694,13 +739,58 @@ declare module 'http' {
|
|||||||
*/
|
*/
|
||||||
protocol: string;
|
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
|
* @since v13.0.0, v12.16.0
|
||||||
*/
|
*/
|
||||||
reusedSocket: boolean;
|
reusedSocket: boolean;
|
||||||
/**
|
/**
|
||||||
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
||||||
* @default 2000
|
|
||||||
*/
|
*/
|
||||||
maxHeadersCount: number;
|
maxHeadersCount: number;
|
||||||
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
||||||
@ -750,9 +840,12 @@ declare module 'http' {
|
|||||||
* const headerNames = request.getRawHeaderNames();
|
* const headerNames = request.getRawHeaderNames();
|
||||||
* // headerNames === ['Foo', 'Set-Cookie']
|
* // headerNames === ['Foo', 'Set-Cookie']
|
||||||
* ```
|
* ```
|
||||||
* @since v15.13.0
|
* @since v15.13.0, v14.17.0
|
||||||
*/
|
*/
|
||||||
getRawHeaderNames(): string[];
|
getRawHeaderNames(): string[];
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
addListener(event: 'abort', listener: () => void): this;
|
addListener(event: 'abort', listener: () => void): this;
|
||||||
addListener(
|
addListener(
|
||||||
event: 'connect',
|
event: 'connect',
|
||||||
@ -774,6 +867,9 @@ declare module 'http' {
|
|||||||
addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||||
addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
on(event: 'abort', listener: () => void): this;
|
on(event: 'abort', listener: () => void): this;
|
||||||
on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
||||||
on(event: 'continue', listener: () => 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: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||||
on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
once(event: 'abort', listener: () => void): this;
|
once(event: 'abort', listener: () => void): this;
|
||||||
once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
||||||
once(event: 'continue', listener: () => 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: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||||
once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
prependListener(event: 'abort', listener: () => void): this;
|
prependListener(event: 'abort', listener: () => void): this;
|
||||||
prependListener(
|
prependListener(
|
||||||
event: 'connect',
|
event: 'connect',
|
||||||
@ -825,6 +927,9 @@ declare module 'http' {
|
|||||||
prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
||||||
prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
||||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
prependOnceListener(event: 'abort', listener: () => void): this;
|
prependOnceListener(event: 'abort', listener: () => void): this;
|
||||||
prependOnceListener(
|
prependOnceListener(
|
||||||
event: 'connect',
|
event: 'connect',
|
||||||
@ -863,6 +968,7 @@ declare module 'http' {
|
|||||||
* The `message.aborted` property will be `true` if the request has
|
* The `message.aborted` property will be `true` if the request has
|
||||||
* been aborted.
|
* been aborted.
|
||||||
* @since v10.1.0
|
* @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;
|
aborted: boolean;
|
||||||
/**
|
/**
|
||||||
@ -914,7 +1020,7 @@ declare module 'http' {
|
|||||||
*
|
*
|
||||||
* This property is guaranteed to be an instance of the `net.Socket` class,
|
* This property is guaranteed to be an instance of the `net.Socket` class,
|
||||||
* a subclass of `stream.Duplex`, unless the user specified a socket
|
* 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
|
* @since v0.3.0
|
||||||
*/
|
*/
|
||||||
socket: Socket;
|
socket: Socket;
|
||||||
@ -929,7 +1035,7 @@ declare module 'http' {
|
|||||||
* // { 'user-agent': 'curl/7.22.0',
|
* // { 'user-agent': 'curl/7.22.0',
|
||||||
* // host: '127.0.0.1:8000',
|
* // host: '127.0.0.1:8000',
|
||||||
* // accept: '*' }
|
* // accept: '*' }
|
||||||
* console.log(request.headers);
|
* console.log(request.getHeaders());
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Duplicates in raw headers are handled in the following ways, depending on the
|
* 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:
|
* To parse the URL into its parts:
|
||||||
*
|
*
|
||||||
* ```js
|
* ```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
|
* ```console
|
||||||
* $ node
|
* $ node
|
||||||
* > new URL(request.url, `http://${request.headers.host}`)
|
* > new URL(request.url, `http://${request.getHeaders().host}`)
|
||||||
* URL {
|
* URL {
|
||||||
* href: 'http://localhost:3000/status?name=ryan',
|
* href: 'http://localhost:3000/status?name=ryan',
|
||||||
* origin: 'http://localhost:3000',
|
* origin: 'http://localhost:3000',
|
||||||
@ -1212,11 +1318,16 @@ declare module 'http' {
|
|||||||
function createServer<
|
function createServer<
|
||||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
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,
|
// although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
|
||||||
// create interface RequestOptions would make the naming more clear to developers
|
// create interface RequestOptions would make the naming more clear to developers
|
||||||
interface RequestOptions extends ClientRequestArgs {}
|
interface RequestOptions extends ClientRequestArgs {}
|
||||||
/**
|
/**
|
||||||
|
* `options` in `socket.connect()` are also supported.
|
||||||
|
*
|
||||||
* Node.js maintains several connections per server to make HTTP requests.
|
* Node.js maintains several connections per server to make HTTP requests.
|
||||||
* This function allows one to transparently issue 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
|
* 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');
|
* const http2 = require('http2');
|
||||||
* ```
|
* ```
|
||||||
* @since v8.4.0
|
* @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' {
|
declare module 'http2' {
|
||||||
import EventEmitter = require('node:events');
|
import EventEmitter = require('node:events');
|
||||||
@ -86,7 +86,7 @@ declare module 'http2' {
|
|||||||
*/
|
*/
|
||||||
readonly destroyed: boolean;
|
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
|
* HEADERS frame received, indicating that no additional data should be received
|
||||||
* and the readable side of the `Http2Stream` will be closed.
|
* and the readable side of the `Http2Stream` will be closed.
|
||||||
* @since v10.11.0
|
* @since v10.11.0
|
||||||
@ -761,7 +761,7 @@ declare module 'http2' {
|
|||||||
* session.setLocalWindowSize(expectedWindowSize);
|
* session.setLocalWindowSize(expectedWindowSize);
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
* @since v15.3.0
|
* @since v15.3.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
setLocalWindowSize(windowSize: number): void;
|
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
|
* 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.
|
* 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`.
|
* This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
@ -1640,7 +1645,7 @@ declare module 'http2' {
|
|||||||
* be called multiple times to provide successive parts of the body.
|
* be called multiple times to provide successive parts of the body.
|
||||||
*
|
*
|
||||||
* In the `http` module, the response body is omitted when the
|
* 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,
|
* `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.
|
* the second parameter specifies how to encode it into a byte stream.
|
||||||
@ -1668,6 +1673,34 @@ declare module 'http2' {
|
|||||||
* @since v8.4.0
|
* @since v8.4.0
|
||||||
*/
|
*/
|
||||||
writeContinue(): void;
|
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
|
* 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.
|
* 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
|
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
||||||
* separate module.
|
* 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' {
|
declare module 'https' {
|
||||||
import { Duplex } from 'node:stream';
|
import { Duplex } from 'node:stream';
|
||||||
@ -17,7 +17,6 @@ declare module 'https' {
|
|||||||
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||||
type RequestOptions = http.RequestOptions &
|
type RequestOptions = http.RequestOptions &
|
||||||
tls.SecureContextOptions & {
|
tls.SecureContextOptions & {
|
||||||
checkServerIdentity?: typeof tls.checkServerIdentity | undefined;
|
|
||||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
||||||
servername?: string | undefined; // SNI TLS Extension
|
servername?: string | undefined; // SNI TLS Extension
|
||||||
};
|
};
|
||||||
@ -50,6 +49,16 @@ declare module 'https' {
|
|||||||
options: ServerOptions<Request, Response>,
|
options: ServerOptions<Request, Response>,
|
||||||
requestListener?: http.RequestListener<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: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||||
addListener(
|
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
|
* @since v0.3.7
|
||||||
@ -88,7 +88,6 @@ declare module 'module' {
|
|||||||
static wrap(code: string): string;
|
static wrap(code: string): string;
|
||||||
static createRequire(path: string | URL): NodeRequire;
|
static createRequire(path: string | URL): NodeRequire;
|
||||||
static builtinModules: string[];
|
static builtinModules: string[];
|
||||||
static isBuiltin(moduleName: string): boolean;
|
|
||||||
static Module: typeof Module;
|
static Module: typeof Module;
|
||||||
constructor(id: string, parent?: 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
|
* > Stability: 2 - Stable
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* ```js
|
* ```js
|
||||||
* const net = require('net');
|
* 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' {
|
declare module 'net' {
|
||||||
import * as stream from 'node:stream';
|
import * as stream from 'node:stream';
|
||||||
@ -134,6 +134,17 @@ declare module 'net' {
|
|||||||
* @return The socket itself.
|
* @return The socket itself.
|
||||||
*/
|
*/
|
||||||
pause(): this;
|
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()`.
|
* Resumes reading after a call to `socket.pause()`.
|
||||||
* @return The socket itself.
|
* @return The socket itself.
|
||||||
@ -211,7 +222,7 @@ declare module 'net' {
|
|||||||
*/
|
*/
|
||||||
unref(): this;
|
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.
|
* If the socket is `ref`ed calling `ref` again will have no effect.
|
||||||
* @since v0.9.1
|
* @since v0.9.1
|
||||||
* @return The socket itself.
|
* @return The socket itself.
|
||||||
@ -271,15 +282,9 @@ declare module 'net' {
|
|||||||
readonly localPort?: number;
|
readonly localPort?: number;
|
||||||
/**
|
/**
|
||||||
* The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
|
* 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;
|
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.
|
* This property represents the state of the connection as a string.
|
||||||
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
||||||
@ -329,7 +334,8 @@ declare module 'net' {
|
|||||||
* 5. end
|
* 5. end
|
||||||
* 6. error
|
* 6. error
|
||||||
* 7. lookup
|
* 7. lookup
|
||||||
* 8. timeout
|
* 8. ready
|
||||||
|
* 9. timeout
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||||
@ -436,6 +442,14 @@ declare module 'net' {
|
|||||||
*/
|
*/
|
||||||
keepAliveInitialDelay?: number | undefined;
|
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.
|
* This class is used to create a TCP or `IPC` server.
|
||||||
* @since v0.1.90
|
* @since v0.1.90
|
||||||
@ -540,7 +554,7 @@ declare module 'net' {
|
|||||||
*/
|
*/
|
||||||
getConnections(cb: (error: Error | null, count: number) => void): void;
|
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.
|
* If the server is `ref`ed calling `ref()` again will have no effect.
|
||||||
* @since v0.9.1
|
* @since v0.9.1
|
||||||
*/
|
*/
|
||||||
@ -572,49 +586,56 @@ declare module 'net' {
|
|||||||
* 2. connection
|
* 2. connection
|
||||||
* 3. error
|
* 3. error
|
||||||
* 4. listening
|
* 4. listening
|
||||||
|
* 5. drop
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: 'close', listener: () => void): this;
|
||||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||||
addListener(event: 'listening', listener: () => 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: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: 'close'): boolean;
|
||||||
emit(event: 'connection', socket: Socket): boolean;
|
emit(event: 'connection', socket: Socket): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: 'error', err: Error): boolean;
|
||||||
emit(event: 'listening'): boolean;
|
emit(event: 'listening'): boolean;
|
||||||
|
emit(event: 'drop', data?: DropArgument): boolean;
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: 'close', listener: () => void): this;
|
||||||
on(event: 'connection', listener: (socket: Socket) => void): this;
|
on(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: 'error', listener: (err: Error) => void): this;
|
||||||
on(event: 'listening', listener: () => 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: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: 'close', listener: () => void): this;
|
||||||
once(event: 'connection', listener: (socket: Socket) => void): this;
|
once(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: 'error', listener: (err: Error) => void): this;
|
||||||
once(event: 'listening', listener: () => 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: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: 'close', listener: () => void): this;
|
||||||
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'listening', listener: () => 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: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: 'close', listener: () => void): this;
|
||||||
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||||
|
prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
||||||
}
|
}
|
||||||
type IPVersion = 'ipv4' | 'ipv6';
|
type IPVersion = 'ipv4' | 'ipv6';
|
||||||
/**
|
/**
|
||||||
* The `BlockList` object can be used with some network APIs to specify rules for
|
* 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
|
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
||||||
* IP subnets.
|
* IP subnets.
|
||||||
* @since v15.0.0
|
* @since v15.0.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
class BlockList {
|
class BlockList {
|
||||||
/**
|
/**
|
||||||
* Adds a rule to block the given IP address.
|
* 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 address An IPv4 or IPv6 address.
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||||
*/
|
*/
|
||||||
@ -622,7 +643,7 @@ declare module 'net' {
|
|||||||
addAddress(address: SocketAddress): void;
|
addAddress(address: SocketAddress): void;
|
||||||
/**
|
/**
|
||||||
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
* 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 start The starting IPv4 or IPv6 address in the range.
|
||||||
* @param end The ending 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'`.
|
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||||
@ -631,7 +652,7 @@ declare module 'net' {
|
|||||||
addRange(start: SocketAddress, end: SocketAddress): void;
|
addRange(start: SocketAddress, end: SocketAddress): void;
|
||||||
/**
|
/**
|
||||||
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
* 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 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 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'`.
|
* @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:7b7b:7b7b', 'ipv6')); // Prints: true
|
||||||
* console.log(blockList.check('::ffff:123.123.123.123', '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 address The IP address to check
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
* @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.
|
* 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:
|
* on port 8124:
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
@ -765,19 +786,39 @@ declare module 'net' {
|
|||||||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||||
/**
|
/**
|
||||||
* Tests if input is an IP address. Returns `0` for invalid strings,
|
* Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
|
||||||
* returns `4` for IP version 4 addresses, and returns `6` for IP version 6
|
* address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
|
||||||
* addresses.
|
*
|
||||||
|
* ```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
|
* @since v0.3.0
|
||||||
*/
|
*/
|
||||||
function isIP(input: string): number;
|
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
|
* @since v0.3.0
|
||||||
*/
|
*/
|
||||||
function isIPv4(input: string): boolean;
|
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
|
* @since v0.3.0
|
||||||
*/
|
*/
|
||||||
function isIPv6(input: string): boolean;
|
function isIPv6(input: string): boolean;
|
||||||
@ -803,25 +844,25 @@ declare module 'net' {
|
|||||||
port?: number | undefined;
|
port?: number | undefined;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @since v15.14.0
|
* @since v15.14.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
class SocketAddress {
|
class SocketAddress {
|
||||||
constructor(options: SocketAddressInitOptions);
|
constructor(options: SocketAddressInitOptions);
|
||||||
/**
|
/**
|
||||||
* @since v15.14.0
|
* @since v15.14.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly address: string;
|
readonly address: string;
|
||||||
/**
|
/**
|
||||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
* Either \`'ipv4'\` or \`'ipv6'\`.
|
||||||
* @since v15.14.0
|
* @since v15.14.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly family: IPVersion;
|
readonly family: IPVersion;
|
||||||
/**
|
/**
|
||||||
* @since v15.14.0
|
* @since v15.14.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly port: number;
|
readonly port: number;
|
||||||
/**
|
/**
|
||||||
* @since v15.14.0
|
* @since v15.14.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
readonly flowlabel: number;
|
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
|
* The `os` module provides operating system-related utility methods and
|
||||||
@ -8,7 +8,7 @@
|
|||||||
* ```js
|
* ```js
|
||||||
* const os = require('os');
|
* 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' {
|
declare module 'os' {
|
||||||
interface CpuInfo {
|
interface CpuInfo {
|
||||||
@ -31,6 +31,7 @@ declare module 'os' {
|
|||||||
}
|
}
|
||||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||||
family: 'IPv4';
|
family: 'IPv4';
|
||||||
|
scopeid?: undefined;
|
||||||
}
|
}
|
||||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||||
family: 'IPv6';
|
family: 'IPv6';
|
||||||
@ -390,7 +391,7 @@ declare module 'os' {
|
|||||||
const EOL: string;
|
const EOL: string;
|
||||||
/**
|
/**
|
||||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
* 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`.
|
* The return value is equivalent to `process.arch`.
|
||||||
* @since v0.5.0
|
* @since v0.5.0
|
||||||
@ -405,8 +406,9 @@ declare module 'os' {
|
|||||||
*/
|
*/
|
||||||
function version(): string;
|
function version(): string;
|
||||||
/**
|
/**
|
||||||
* Returns a string identifying the operating system platform. The value is set
|
* Returns a string identifying the operating system platform for which
|
||||||
* at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
* 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 return value is equivalent to `process.platform`.
|
||||||
*
|
*
|
||||||
@ -415,6 +417,15 @@ declare module 'os' {
|
|||||||
* @since v0.5.0
|
* @since v0.5.0
|
||||||
*/
|
*/
|
||||||
function platform(): NodeJS.Platform;
|
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
|
* Returns the operating system's default directory for temporary files as a
|
||||||
* string.
|
* 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' {
|
declare module 'path/posix' {
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
@ -16,7 +16,7 @@ declare module 'path/win32' {
|
|||||||
* ```js
|
* ```js
|
||||||
* const path = require('path');
|
* 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' {
|
declare module 'path' {
|
||||||
namespace path {
|
namespace path {
|
||||||
@ -93,7 +93,7 @@ declare module 'path' {
|
|||||||
* the current working directory is used as well. The resulting path is normalized,
|
* 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.
|
* 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.
|
* @throws {TypeError} if any of the arguments is not a string.
|
||||||
*/
|
*/
|
||||||
resolve(...paths: string[]): string;
|
resolve(...paths: string[]): string;
|
||||||
@ -125,10 +125,10 @@ declare module 'path' {
|
|||||||
* Often used to extract the file name from a fully qualified path.
|
* Often used to extract the file name from a fully qualified path.
|
||||||
*
|
*
|
||||||
* @param path the path to evaluate.
|
* @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.
|
* @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.
|
* 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.
|
* 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
|
* 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');
|
* 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' {
|
declare module 'perf_hooks' {
|
||||||
import { AsyncResource } from 'node:async_hooks';
|
import { AsyncResource } from 'node:async_hooks';
|
||||||
@ -88,6 +88,14 @@ declare module 'perf_hooks' {
|
|||||||
* @since v16.0.0
|
* @since v16.0.0
|
||||||
*/
|
*/
|
||||||
readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
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._
|
* _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.
|
* and whose performanceEntry.duration is always 0.
|
||||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||||
* @param name
|
* @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.
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||||
@ -245,9 +254,10 @@ declare module 'perf_hooks' {
|
|||||||
* @param name
|
* @param name
|
||||||
* @param startMark
|
* @param startMark
|
||||||
* @param endMark
|
* @param endMark
|
||||||
|
* @return The PerformanceMeasure entry that was created
|
||||||
*/
|
*/
|
||||||
measure(name: string, startMark?: string, endMark?: string): void;
|
measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure;
|
||||||
measure(name: string, options: MeasureOptions): void;
|
measure(name: string, options: MeasureOptions): PerformanceMeasure;
|
||||||
/**
|
/**
|
||||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
* 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();
|
* observer.disconnect();
|
||||||
* });
|
* });
|
||||||
* obs.observe({ type: 'mark' });
|
* obs.observe({ type: 'mark' });
|
||||||
@ -349,6 +362,9 @@ declare module 'perf_hooks' {
|
|||||||
* * ]
|
* * ]
|
||||||
*
|
*
|
||||||
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
||||||
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
* observer.disconnect();
|
* observer.disconnect();
|
||||||
* });
|
* });
|
||||||
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
||||||
@ -387,6 +403,8 @@ declare module 'perf_hooks' {
|
|||||||
* * }
|
* * }
|
||||||
* * ]
|
* * ]
|
||||||
*
|
*
|
||||||
|
* performance.clearMarks();
|
||||||
|
* performance.clearMeasures();
|
||||||
* observer.disconnect();
|
* observer.disconnect();
|
||||||
* });
|
* });
|
||||||
* obs.observe({ type: 'mark' });
|
* obs.observe({ type: 'mark' });
|
||||||
@ -416,7 +434,7 @@ declare module 'perf_hooks' {
|
|||||||
* } = require('perf_hooks');
|
* } = require('perf_hooks');
|
||||||
*
|
*
|
||||||
* const obs = new PerformanceObserver((list, observer) => {
|
* 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' });
|
* obs.observe({ type: 'mark' });
|
||||||
*
|
*
|
||||||
@ -519,7 +537,7 @@ declare module 'perf_hooks' {
|
|||||||
}
|
}
|
||||||
interface RecordableHistogram extends Histogram {
|
interface RecordableHistogram extends Histogram {
|
||||||
/**
|
/**
|
||||||
* @since v15.9.0
|
* @since v15.9.0, v14.18.0
|
||||||
* @param val The amount to record in the histogram.
|
* @param val The amount to record in the histogram.
|
||||||
*/
|
*/
|
||||||
record(val: number | bigint): void;
|
record(val: number | bigint): void;
|
||||||
@ -528,9 +546,15 @@ declare module 'perf_hooks' {
|
|||||||
* previous call to `recordDelta()` and records that amount in the histogram.
|
* previous call to `recordDelta()` and records that amount in the histogram.
|
||||||
*
|
*
|
||||||
* ## Examples
|
* ## Examples
|
||||||
* @since v15.9.0
|
* @since v15.9.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
recordDelta(): void;
|
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._
|
* _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`.
|
* Returns a `RecordableHistogram`.
|
||||||
* @since v15.9.0
|
* @since v15.9.0, v14.18.0
|
||||||
*/
|
*/
|
||||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
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' {
|
declare module 'node:perf_hooks' {
|
||||||
export * from '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' {
|
declare module 'process' {
|
||||||
import * as tty from 'node:tty';
|
import * as tty from 'node:tty';
|
||||||
@ -52,6 +52,7 @@ declare module 'process' {
|
|||||||
openssl: string;
|
openssl: string;
|
||||||
}
|
}
|
||||||
type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
|
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 =
|
type Signals =
|
||||||
| 'SIGABRT'
|
| 'SIGABRT'
|
||||||
| 'SIGALRM'
|
| 'SIGALRM'
|
||||||
@ -99,7 +100,7 @@ declare module 'process' {
|
|||||||
type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
|
type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
|
||||||
/**
|
/**
|
||||||
* Most of the time the unhandledRejection will be an Error, but this should not be relied upon
|
* 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 UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
|
||||||
type WarningListener = (warning: Error) => 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
|
* 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
|
* 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
|
* 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:
|
* scheduling any additional work for the event loop:
|
||||||
@ -644,7 +645,7 @@ declare module 'process' {
|
|||||||
* Android).
|
* Android).
|
||||||
* @since v0.1.31
|
* @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
|
* 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
|
* numeric ID or a group name
|
||||||
@ -671,7 +672,7 @@ declare module 'process' {
|
|||||||
* @since v0.1.31
|
* @since v0.1.31
|
||||||
* @param id The group name or ID
|
* @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.
|
* 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).)
|
* (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
|
||||||
@ -688,7 +689,7 @@ declare module 'process' {
|
|||||||
* Android).
|
* Android).
|
||||||
* @since v0.1.28
|
* @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
|
* 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.
|
* numeric ID or a username string.
|
||||||
@ -714,7 +715,7 @@ declare module 'process' {
|
|||||||
* This feature is not available in `Worker` threads.
|
* This feature is not available in `Worker` threads.
|
||||||
* @since v0.1.28
|
* @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.geteuid()` method returns the numerical effective user identity of
|
||||||
* the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
|
* the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
|
||||||
@ -731,7 +732,7 @@ declare module 'process' {
|
|||||||
* Android).
|
* Android).
|
||||||
* @since v2.0.0
|
* @since v2.0.0
|
||||||
*/
|
*/
|
||||||
geteuid(): number;
|
geteuid?: () => number;
|
||||||
/**
|
/**
|
||||||
* The `process.seteuid()` method sets the effective user identity of the process.
|
* 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
|
* (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
|
* @since v2.0.0
|
||||||
* @param id A user name or ID
|
* @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
|
* 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).)
|
* 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).
|
* Android).
|
||||||
* @since v2.0.0
|
* @since v2.0.0
|
||||||
*/
|
*/
|
||||||
getegid(): number;
|
getegid?: () => number;
|
||||||
/**
|
/**
|
||||||
* The `process.setegid()` method sets the effective group identity of the process.
|
* 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
|
* (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
|
* @since v2.0.0
|
||||||
* @param id A group name or ID
|
* @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
|
* The `process.getgroups()` method returns an array with the supplementary group
|
||||||
* IDs. POSIX leaves it unspecified if the effective group ID is included but
|
* IDs. POSIX leaves it unspecified if the effective group ID is included but
|
||||||
@ -820,7 +821,7 @@ declare module 'process' {
|
|||||||
* Android).
|
* Android).
|
||||||
* @since v0.9.4
|
* @since v0.9.4
|
||||||
*/
|
*/
|
||||||
getgroups(): number[];
|
getgroups?: () => number[];
|
||||||
/**
|
/**
|
||||||
* The `process.setgroups()` method sets the supplementary group IDs for the
|
* The `process.setgroups()` method sets the supplementary group IDs for the
|
||||||
* Node.js process. This is a privileged operation that requires the Node.js
|
* 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.
|
* This feature is not available in `Worker` threads.
|
||||||
* @since v0.9.4
|
* @since v0.9.4
|
||||||
*/
|
*/
|
||||||
setgroups(groups: ReadonlyArray<string | number>): void;
|
setgroups?: (groups: ReadonlyArray<string | number>) => void;
|
||||||
/**
|
/**
|
||||||
* The `process.setUncaughtExceptionCaptureCallback()` function sets a function
|
* The `process.setUncaughtExceptionCaptureCallback()` function sets a function
|
||||||
* that will be invoked when an uncaught exception occurs, which will receive the
|
* that will be invoked when an uncaught exception occurs, which will receive the
|
||||||
@ -1043,7 +1044,7 @@ declare module 'process' {
|
|||||||
title: string;
|
title: string;
|
||||||
/**
|
/**
|
||||||
* The operating system CPU architecture for which the Node.js binary was compiled.
|
* 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
|
* ```js
|
||||||
* import { arch } from 'process';
|
* import { arch } from 'process';
|
||||||
@ -1052,10 +1053,10 @@ declare module 'process' {
|
|||||||
* ```
|
* ```
|
||||||
* @since v0.5.0
|
* @since v0.5.0
|
||||||
*/
|
*/
|
||||||
readonly arch: string;
|
readonly arch: Architecture;
|
||||||
/**
|
/**
|
||||||
* The `process.platform` property returns a string identifying the operating
|
* 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:
|
* Currently possible values are:
|
||||||
*
|
*
|
||||||
@ -1408,7 +1409,7 @@ declare module 'process' {
|
|||||||
emit(event: 'unhandledRejection', reason: unknown, promise: Promise<unknown>): boolean;
|
emit(event: 'unhandledRejection', reason: unknown, promise: Promise<unknown>): boolean;
|
||||||
emit(event: 'warning', warning: Error): boolean;
|
emit(event: 'warning', warning: Error): boolean;
|
||||||
emit(event: 'message', message: unknown, sendHandle: unknown): this;
|
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: 'multipleResolves', type: MultipleResolveType, promise: Promise<unknown>, value: unknown): this;
|
||||||
emit(event: 'worker', listener: WorkerListener): this;
|
emit(event: 'worker', listener: WorkerListener): this;
|
||||||
on(event: 'beforeExit', listener: BeforeExitListener): 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
|
* The `querystring` module provides utilities for parsing and formatting URL
|
||||||
@ -12,7 +12,7 @@
|
|||||||
* `querystring` is more performant than `URLSearchParams` but is not a
|
* `querystring` is more performant than `URLSearchParams` but is not a
|
||||||
* standardized API. Use `URLSearchParams` when performance is not critical
|
* standardized API. Use `URLSearchParams` when performance is not critical
|
||||||
* or when compatibility with browser code is desirable.
|
* 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' {
|
declare module 'querystring' {
|
||||||
interface StringifyOptions {
|
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
|
* The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time.
|
||||||
* using:
|
*
|
||||||
|
* To use the promise-based APIs:
|
||||||
*
|
*
|
||||||
* ```js
|
* ```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.
|
* The following simple example illustrates the basic use of the `readline` module.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```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({
|
* const rl = readline.createInterface({ input, output });
|
||||||
* input: process.stdin,
|
|
||||||
* output: process.stdout
|
|
||||||
* });
|
|
||||||
*
|
*
|
||||||
* rl.question('What do you think of Node.js? ', (answer) => {
|
* const answer = await rl.question('What do you think of Node.js? ');
|
||||||
* // TODO: Log the answer in a database
|
|
||||||
* console.log(`Thank you for your valuable feedback: ${answer}`);
|
|
||||||
*
|
*
|
||||||
* 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
|
* 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.
|
* 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' {
|
declare module 'readline' {
|
||||||
import { Abortable, EventEmitter } from 'node:events';
|
import { Abortable, EventEmitter } from 'node:events';
|
||||||
interface Key {
|
import * as promises from 'node:readline/promises';
|
||||||
|
|
||||||
|
export { promises };
|
||||||
|
export interface Key {
|
||||||
sequence?: string | undefined;
|
sequence?: string | undefined;
|
||||||
name?: string | undefined;
|
name?: string | undefined;
|
||||||
ctrl?: boolean | undefined;
|
ctrl?: boolean | undefined;
|
||||||
@ -47,7 +54,7 @@ declare module 'readline' {
|
|||||||
* and is read from, the `input` stream.
|
* and is read from, the `input` stream.
|
||||||
* @since v0.1.104
|
* @since v0.1.104
|
||||||
*/
|
*/
|
||||||
class Interface extends EventEmitter {
|
export class Interface extends EventEmitter {
|
||||||
readonly terminal: boolean;
|
readonly terminal: boolean;
|
||||||
/**
|
/**
|
||||||
* The current input data being processed by node.
|
* The current input data being processed by node.
|
||||||
@ -314,11 +321,11 @@ declare module 'readline' {
|
|||||||
prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
|
prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
|
||||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||||
}
|
}
|
||||||
type ReadLine = Interface; // type forwarded for backwards compatibility
|
export type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||||
type Completer = (line: string) => CompleterResult;
|
export type Completer = (line: string) => CompleterResult;
|
||||||
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
export type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
||||||
type CompleterResult = [string[], string];
|
export type CompleterResult = [string[], string];
|
||||||
interface ReadLineOptions {
|
export interface ReadLineOptions {
|
||||||
input: NodeJS.ReadableStream;
|
input: NodeJS.ReadableStream;
|
||||||
output?: NodeJS.WritableStream | undefined;
|
output?: NodeJS.WritableStream | undefined;
|
||||||
completer?: Completer | AsyncCompleter | undefined;
|
completer?: Completer | AsyncCompleter | undefined;
|
||||||
@ -379,8 +386,8 @@ declare module 'readline' {
|
|||||||
* ```
|
* ```
|
||||||
* @since v0.1.98
|
* @since v0.1.98
|
||||||
*/
|
*/
|
||||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||||
function createInterface(options: ReadLineOptions): 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.
|
* 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)
|
* if (process.stdin.isTTY)
|
||||||
* process.stdin.setRawMode(true);
|
* 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
|
* @since v0.7.7
|
||||||
*/
|
*/
|
||||||
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||||
type Direction = -1 | 0 | 1;
|
export type Direction = -1 | 0 | 1;
|
||||||
interface CursorPos {
|
export interface CursorPos {
|
||||||
rows: number;
|
rows: number;
|
||||||
cols: number;
|
cols: number;
|
||||||
}
|
}
|
||||||
@ -412,7 +522,7 @@ declare module 'readline' {
|
|||||||
* @param callback Invoked once the operation completes.
|
* @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`.
|
* @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 `readline.clearScreenDown()` method clears the given `TTY` stream from
|
||||||
* the current position of the cursor down.
|
* the current position of the cursor down.
|
||||||
@ -420,7 +530,7 @@ declare module 'readline' {
|
|||||||
* @param callback Invoked once the operation completes.
|
* @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`.
|
* @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
|
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
||||||
* given `TTY` `stream`.
|
* given `TTY` `stream`.
|
||||||
@ -428,7 +538,7 @@ declare module 'readline' {
|
|||||||
* @param callback Invoked once the operation completes.
|
* @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`.
|
* @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
|
* The `readline.moveCursor()` method moves the cursor _relative_ to its current
|
||||||
* position in a given `TTY` `stream`.
|
* position in a given `TTY` `stream`.
|
||||||
@ -539,7 +649,7 @@ declare module 'readline' {
|
|||||||
* @param callback Invoked once the operation completes.
|
* @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`.
|
* @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' {
|
declare module 'node:readline' {
|
||||||
export * from 'readline';
|
export * from 'readline';
|
||||||
|
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.
|
* 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
|
* 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.
|
* 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' {
|
declare module 'stream' {
|
||||||
import { EventEmitter, Abortable } from 'node:events';
|
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 streamPromises from 'node:stream/promises';
|
||||||
import * as streamConsumers from 'node:stream/consumers';
|
import * as streamConsumers from 'node:stream/consumers';
|
||||||
|
import * as streamWeb from 'node:stream/web';
|
||||||
class internal extends EventEmitter {
|
class internal extends EventEmitter {
|
||||||
pipe<T extends NodeJS.WritableStream>(
|
pipe<T extends NodeJS.WritableStream>(
|
||||||
destination: T,
|
destination: T,
|
||||||
@ -56,11 +57,23 @@ declare module 'stream' {
|
|||||||
* A utility method for creating Readable Streams out of iterators.
|
* A utility method for creating Readable Streams out of iterators.
|
||||||
*/
|
*/
|
||||||
static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
|
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.
|
* Returns whether the stream has been read from or cancelled.
|
||||||
* @since v16.8.0
|
* @since v16.8.0
|
||||||
*/
|
*/
|
||||||
static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean;
|
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'`.
|
* Returns whether the stream was destroyed or errored before emitting `'end'`.
|
||||||
* @since v16.8.0
|
* @since v16.8.0
|
||||||
@ -75,7 +88,7 @@ declare module 'stream' {
|
|||||||
readable: boolean;
|
readable: boolean;
|
||||||
/**
|
/**
|
||||||
* Returns whether `'data'` has been emitted.
|
* Returns whether `'data'` has been emitted.
|
||||||
* @since v16.7.0
|
* @since v16.7.0, v14.18.0
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
readonly readableDidRead: boolean;
|
readonly readableDidRead: boolean;
|
||||||
@ -117,13 +130,23 @@ declare module 'stream' {
|
|||||||
* @since v8.0.0
|
* @since v8.0.0
|
||||||
*/
|
*/
|
||||||
destroyed: boolean;
|
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);
|
constructor(opts?: ReadableOptions);
|
||||||
_construct?(callback: (error?: Error | null) => void): void;
|
_construct?(callback: (error?: Error | null) => void): void;
|
||||||
_read(size: number): void;
|
_read(size: number): void;
|
||||||
/**
|
/**
|
||||||
* The `readable.read()` method pulls some data out of the internal buffer and
|
* The `readable.read()` method reads data out of the internal buffer and
|
||||||
* returns it. If no data available to be read, `null` is returned. By default,
|
* returns it. If no data is available to be read, `null` is returned. By default,
|
||||||
* the data will be returned as a `Buffer` object unless an encoding has been
|
* the data is returned as a `Buffer` object unless an encoding has been
|
||||||
* specified using the `readable.setEncoding()` method or the stream is operating
|
* specified using the `readable.setEncoding()` method or the stream is operating
|
||||||
* in object mode.
|
* in object mode.
|
||||||
*
|
*
|
||||||
@ -338,7 +361,7 @@ declare module 'stream' {
|
|||||||
* let chunk;
|
* let chunk;
|
||||||
* while (null !== (chunk = stream.read())) {
|
* while (null !== (chunk = stream.read())) {
|
||||||
* const str = decoder.write(chunk);
|
* const str = decoder.write(chunk);
|
||||||
* if (str.match(/\n\n/)) {
|
* if (str.includes('\n\n')) {
|
||||||
* // Found the header boundary.
|
* // Found the header boundary.
|
||||||
* const split = str.split(/\n\n/);
|
* const split = str.split(/\n\n/);
|
||||||
* header += split.shift();
|
* header += split.shift();
|
||||||
@ -351,10 +374,10 @@ declare module 'stream' {
|
|||||||
* stream.unshift(buf);
|
* stream.unshift(buf);
|
||||||
* // Now the body of the message can be read from the stream.
|
* // Now the body of the message can be read from the stream.
|
||||||
* callback(null, header, stream);
|
* callback(null, header, stream);
|
||||||
* } else {
|
* return;
|
||||||
* // Still reading the header.
|
|
||||||
* header += str;
|
|
||||||
* }
|
* }
|
||||||
|
* // Still reading the header.
|
||||||
|
* header += str;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@ -500,6 +523,18 @@ declare module 'stream' {
|
|||||||
* @since v0.9.4
|
* @since v0.9.4
|
||||||
*/
|
*/
|
||||||
class Writable extends Stream implements NodeJS.WritableStream {
|
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
|
* Is `true` if it is safe to call `writable.write()`, which means
|
||||||
* the stream has not been destroyed, errored or ended.
|
* the stream has not been destroyed, errored or ended.
|
||||||
@ -545,6 +580,21 @@ declare module 'stream' {
|
|||||||
* @since v8.0.0
|
* @since v8.0.0
|
||||||
*/
|
*/
|
||||||
destroyed: boolean;
|
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);
|
constructor(opts?: WritableOptions);
|
||||||
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
||||||
_writev?(
|
_writev?(
|
||||||
@ -571,7 +621,7 @@ declare module 'stream' {
|
|||||||
* While a stream is not draining, calls to `write()` will buffer `chunk`, and
|
* While a stream is not draining, calls to `write()` will buffer `chunk`, and
|
||||||
* return false. Once all currently buffered chunks are drained (accepted for
|
* return false. Once all currently buffered chunks are drained (accepted for
|
||||||
* delivery by the operating system), the `'drain'` event will be emitted.
|
* 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
|
* 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
|
* is not draining is allowed, Node.js will buffer all written chunks until
|
||||||
* maximum memory usage occurs, at which point it will abort unconditionally.
|
* 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.
|
* The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
|
||||||
*
|
*
|
||||||
* When using `writable.cork()` and `writable.uncork()` to manage the buffering
|
* 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
|
* 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
|
||||||
* deferred using `process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event loop phase.
|
* loop phase.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* stream.cork();
|
* stream.cork();
|
||||||
@ -811,6 +861,9 @@ declare module 'stream' {
|
|||||||
readonly writableLength: number;
|
readonly writableLength: number;
|
||||||
readonly writableObjectMode: boolean;
|
readonly writableObjectMode: boolean;
|
||||||
readonly writableCorked: number;
|
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
|
* If `false` then the stream will automatically end the writable side when the
|
||||||
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
* 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;
|
end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this;
|
||||||
cork(): void;
|
cork(): void;
|
||||||
uncork(): 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;
|
type TransformCallback = (error?: Error | null, data?: any) => void;
|
||||||
interface TransformOptions extends DuplexOptions {
|
interface TransformOptions extends DuplexOptions {
|
||||||
@ -1209,7 +1163,7 @@ declare module 'stream' {
|
|||||||
* async function run() {
|
* async function run() {
|
||||||
* await pipeline(
|
* await pipeline(
|
||||||
* fs.createReadStream('lowercase.txt'),
|
* fs.createReadStream('lowercase.txt'),
|
||||||
* async function* (source, signal) {
|
* async function* (source, { signal }) {
|
||||||
* source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
|
* source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
|
||||||
* for await (const chunk of source) {
|
* for await (const chunk of source) {
|
||||||
* yield await processChunk(chunk, { signal });
|
* yield await processChunk(chunk, { signal });
|
||||||
@ -1233,7 +1187,7 @@ declare module 'stream' {
|
|||||||
*
|
*
|
||||||
* async function run() {
|
* async function run() {
|
||||||
* await pipeline(
|
* await pipeline(
|
||||||
* async function * (signal) {
|
* async function* ({ signal }) {
|
||||||
* await someLongRunningfn({ signal });
|
* await someLongRunningfn({ signal });
|
||||||
* yield 'asd';
|
* yield 'asd';
|
||||||
* },
|
* },
|
||||||
@ -1252,7 +1206,31 @@ declare module 'stream' {
|
|||||||
*
|
*
|
||||||
* `stream.pipeline()` leaves dangling event listeners on the streams
|
* `stream.pipeline()` leaves dangling event listeners on the streams
|
||||||
* after the `callback` has been invoked. In the case of reuse of streams after
|
* 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
|
* @since v10.0.0
|
||||||
* @param callback Called when the pipeline is fully done.
|
* @param callback Called when the pipeline is fully done.
|
||||||
*/
|
*/
|
||||||
@ -1344,13 +1322,13 @@ declare module 'stream' {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the stream has encountered an error.
|
* 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;
|
function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the stream is readable.
|
* Returns whether the stream is readable.
|
||||||
* @since v16.14.0
|
* @since v17.4.0
|
||||||
*/
|
*/
|
||||||
function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
|
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' {
|
declare module 'stream/consumers' {
|
||||||
import { Readable } from 'node:stream';
|
|
||||||
import { Blob as NodeBlob } from "node:buffer";
|
import { Blob as NodeBlob } from "node:buffer";
|
||||||
|
import { Readable } from 'node:stream';
|
||||||
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
||||||
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
||||||
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<ArrayBuffer>;
|
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' {
|
declare module 'stream/promises' {
|
||||||
import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream';
|
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' {
|
declare module 'stream/web' {
|
||||||
// stub module, pending copy&paste from .d.ts or manual impl
|
// stub module, pending copy&paste from .d.ts or manual impl
|
||||||
// copy from lib.dom.d.ts
|
// copy from lib.dom.d.ts
|
||||||
|
|
||||||
interface ReadableWritablePair<R = any, W = any> {
|
interface ReadableWritablePair<R = any, W = any> {
|
||||||
readable: ReadableStream<R>;
|
readable: ReadableStream<R>;
|
||||||
/**
|
/**
|
||||||
@ -18,7 +17,6 @@ declare module 'stream/web' {
|
|||||||
*/
|
*/
|
||||||
writable: WritableStream<W>;
|
writable: WritableStream<W>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StreamPipeOptions {
|
interface StreamPipeOptions {
|
||||||
preventAbort?: boolean;
|
preventAbort?: boolean;
|
||||||
preventCancel?: boolean;
|
preventCancel?: boolean;
|
||||||
@ -66,70 +64,53 @@ declare module 'stream/web' {
|
|||||||
preventClose?: boolean;
|
preventClose?: boolean;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadableStreamGenericReader {
|
interface ReadableStreamGenericReader {
|
||||||
readonly closed: Promise<undefined>;
|
readonly closed: Promise<undefined>;
|
||||||
cancel(reason?: any): Promise<void>;
|
cancel(reason?: any): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadableStreamDefaultReadValueResult<T> {
|
interface ReadableStreamDefaultReadValueResult<T> {
|
||||||
done: false;
|
done: false;
|
||||||
value: T;
|
value: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadableStreamDefaultReadDoneResult {
|
interface ReadableStreamDefaultReadDoneResult {
|
||||||
done: true;
|
done: true;
|
||||||
value?: undefined;
|
value?: undefined;
|
||||||
}
|
}
|
||||||
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||||
type ReadableStreamDefaultReadResult<T> =
|
type ReadableStreamDefaultReadResult<T> = ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult;
|
||||||
| ReadableStreamDefaultReadValueResult<T>
|
|
||||||
| ReadableStreamDefaultReadDoneResult;
|
|
||||||
|
|
||||||
interface ReadableByteStreamControllerCallback {
|
interface ReadableByteStreamControllerCallback {
|
||||||
(controller: ReadableByteStreamController): void | PromiseLike<void>;
|
(controller: ReadableByteStreamController): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSinkAbortCallback {
|
interface UnderlyingSinkAbortCallback {
|
||||||
(reason?: any): void | PromiseLike<void>;
|
(reason?: any): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSinkCloseCallback {
|
interface UnderlyingSinkCloseCallback {
|
||||||
(): void | PromiseLike<void>;
|
(): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSinkStartCallback {
|
interface UnderlyingSinkStartCallback {
|
||||||
(controller: WritableStreamDefaultController): any;
|
(controller: WritableStreamDefaultController): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSinkWriteCallback<W> {
|
interface UnderlyingSinkWriteCallback<W> {
|
||||||
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
|
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSourceCancelCallback {
|
interface UnderlyingSourceCancelCallback {
|
||||||
(reason?: any): void | PromiseLike<void>;
|
(reason?: any): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSourcePullCallback<R> {
|
interface UnderlyingSourcePullCallback<R> {
|
||||||
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
|
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSourceStartCallback<R> {
|
interface UnderlyingSourceStartCallback<R> {
|
||||||
(controller: ReadableStreamController<R>): any;
|
(controller: ReadableStreamController<R>): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TransformerFlushCallback<O> {
|
interface TransformerFlushCallback<O> {
|
||||||
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TransformerStartCallback<O> {
|
interface TransformerStartCallback<O> {
|
||||||
(controller: TransformStreamDefaultController<O>): any;
|
(controller: TransformStreamDefaultController<O>): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TransformerTransformCallback<I, O> {
|
interface TransformerTransformCallback<I, O> {
|
||||||
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingByteSource {
|
interface UnderlyingByteSource {
|
||||||
autoAllocateChunkSize?: number;
|
autoAllocateChunkSize?: number;
|
||||||
cancel?: ReadableStreamErrorCallback;
|
cancel?: ReadableStreamErrorCallback;
|
||||||
@ -137,14 +118,12 @@ declare module 'stream/web' {
|
|||||||
start?: ReadableByteStreamControllerCallback;
|
start?: ReadableByteStreamControllerCallback;
|
||||||
type: 'bytes';
|
type: 'bytes';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSource<R = any> {
|
interface UnderlyingSource<R = any> {
|
||||||
cancel?: UnderlyingSourceCancelCallback;
|
cancel?: UnderlyingSourceCancelCallback;
|
||||||
pull?: UnderlyingSourcePullCallback<R>;
|
pull?: UnderlyingSourcePullCallback<R>;
|
||||||
start?: UnderlyingSourceStartCallback<R>;
|
start?: UnderlyingSourceStartCallback<R>;
|
||||||
type?: undefined;
|
type?: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnderlyingSink<W = any> {
|
interface UnderlyingSink<W = any> {
|
||||||
abort?: UnderlyingSinkAbortCallback;
|
abort?: UnderlyingSinkAbortCallback;
|
||||||
close?: UnderlyingSinkCloseCallback;
|
close?: UnderlyingSinkCloseCallback;
|
||||||
@ -152,11 +131,9 @@ declare module 'stream/web' {
|
|||||||
type?: undefined;
|
type?: undefined;
|
||||||
write?: UnderlyingSinkWriteCallback<W>;
|
write?: UnderlyingSinkWriteCallback<W>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadableStreamErrorCallback {
|
interface ReadableStreamErrorCallback {
|
||||||
(reason: any): void | PromiseLike<void>;
|
(reason: any): void | PromiseLike<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This Streams API interface represents a readable stream of byte data. */
|
/** This Streams API interface represents a readable stream of byte data. */
|
||||||
interface ReadableStream<R = any> {
|
interface ReadableStream<R = any> {
|
||||||
readonly locked: boolean;
|
readonly locked: boolean;
|
||||||
@ -168,29 +145,21 @@ declare module 'stream/web' {
|
|||||||
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
||||||
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReadableStream: {
|
const ReadableStream: {
|
||||||
prototype: ReadableStream;
|
prototype: ReadableStream;
|
||||||
new (
|
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
||||||
underlyingSource: UnderlyingByteSource,
|
|
||||||
strategy?: QueuingStrategy<Uint8Array>,
|
|
||||||
): ReadableStream<Uint8Array>;
|
|
||||||
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
||||||
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
||||||
releaseLock(): void;
|
releaseLock(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReadableStreamDefaultReader: {
|
const ReadableStreamDefaultReader: {
|
||||||
prototype: ReadableStreamDefaultReader;
|
prototype: ReadableStreamDefaultReader;
|
||||||
new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ReadableStreamBYOBReader: any;
|
const ReadableStreamBYOBReader: any;
|
||||||
const ReadableStreamBYOBRequest: any;
|
const ReadableStreamBYOBRequest: any;
|
||||||
|
|
||||||
interface ReadableByteStreamController {
|
interface ReadableByteStreamController {
|
||||||
readonly byobRequest: undefined;
|
readonly byobRequest: undefined;
|
||||||
readonly desiredSize: number | null;
|
readonly desiredSize: number | null;
|
||||||
@ -198,24 +167,20 @@ declare module 'stream/web' {
|
|||||||
enqueue(chunk: ArrayBufferView): void;
|
enqueue(chunk: ArrayBufferView): void;
|
||||||
error(error?: any): void;
|
error(error?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReadableByteStreamController: {
|
const ReadableByteStreamController: {
|
||||||
prototype: ReadableByteStreamController;
|
prototype: ReadableByteStreamController;
|
||||||
new (): ReadableByteStreamController;
|
new (): ReadableByteStreamController;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ReadableStreamDefaultController<R = any> {
|
interface ReadableStreamDefaultController<R = any> {
|
||||||
readonly desiredSize: number | null;
|
readonly desiredSize: number | null;
|
||||||
close(): void;
|
close(): void;
|
||||||
enqueue(chunk?: R): void;
|
enqueue(chunk?: R): void;
|
||||||
error(e?: any): void;
|
error(e?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReadableStreamDefaultController: {
|
const ReadableStreamDefaultController: {
|
||||||
prototype: ReadableStreamDefaultController;
|
prototype: ReadableStreamDefaultController;
|
||||||
new (): ReadableStreamDefaultController;
|
new (): ReadableStreamDefaultController;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Transformer<I = any, O = any> {
|
interface Transformer<I = any, O = any> {
|
||||||
flush?: TransformerFlushCallback<O>;
|
flush?: TransformerFlushCallback<O>;
|
||||||
readableType?: undefined;
|
readableType?: undefined;
|
||||||
@ -223,33 +188,24 @@ declare module 'stream/web' {
|
|||||||
transform?: TransformerTransformCallback<I, O>;
|
transform?: TransformerTransformCallback<I, O>;
|
||||||
writableType?: undefined;
|
writableType?: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TransformStream<I = any, O = any> {
|
interface TransformStream<I = any, O = any> {
|
||||||
readonly readable: ReadableStream<O>;
|
readonly readable: ReadableStream<O>;
|
||||||
readonly writable: WritableStream<I>;
|
readonly writable: WritableStream<I>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TransformStream: {
|
const TransformStream: {
|
||||||
prototype: TransformStream;
|
prototype: TransformStream;
|
||||||
new <I = any, O = any>(
|
new <I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
|
||||||
transformer?: Transformer<I, O>,
|
|
||||||
writableStrategy?: QueuingStrategy<I>,
|
|
||||||
readableStrategy?: QueuingStrategy<O>,
|
|
||||||
): TransformStream<I, O>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TransformStreamDefaultController<O = any> {
|
interface TransformStreamDefaultController<O = any> {
|
||||||
readonly desiredSize: number | null;
|
readonly desiredSize: number | null;
|
||||||
enqueue(chunk?: O): void;
|
enqueue(chunk?: O): void;
|
||||||
error(reason?: any): void;
|
error(reason?: any): void;
|
||||||
terminate(): void;
|
terminate(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TransformStreamDefaultController: {
|
const TransformStreamDefaultController: {
|
||||||
prototype: TransformStreamDefaultController;
|
prototype: TransformStreamDefaultController;
|
||||||
new (): TransformStreamDefaultController;
|
new (): TransformStreamDefaultController;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Streams API interface provides a standard abstraction for writing
|
* This Streams API interface provides a standard abstraction for writing
|
||||||
* streaming data to a destination, known as a sink. This object comes with
|
* streaming data to a destination, known as a sink. This object comes with
|
||||||
@ -261,12 +217,10 @@ declare module 'stream/web' {
|
|||||||
close(): Promise<void>;
|
close(): Promise<void>;
|
||||||
getWriter(): WritableStreamDefaultWriter<W>;
|
getWriter(): WritableStreamDefaultWriter<W>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WritableStream: {
|
const WritableStream: {
|
||||||
prototype: WritableStream;
|
prototype: WritableStream;
|
||||||
new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Streams API interface is the object returned by
|
* This Streams API interface is the object returned by
|
||||||
* WritableStream.getWriter() and once created locks the < writer to the
|
* WritableStream.getWriter() and once created locks the < writer to the
|
||||||
@ -282,12 +236,10 @@ declare module 'stream/web' {
|
|||||||
releaseLock(): void;
|
releaseLock(): void;
|
||||||
write(chunk?: W): Promise<void>;
|
write(chunk?: W): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WritableStreamDefaultWriter: {
|
const WritableStreamDefaultWriter: {
|
||||||
prototype: WritableStreamDefaultWriter;
|
prototype: WritableStreamDefaultWriter;
|
||||||
new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
|
new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Streams API interface represents a controller allowing control of a
|
* This Streams API interface represents a controller allowing control of a
|
||||||
* WritableStream's state. When constructing a WritableStream, the
|
* WritableStream's state. When constructing a WritableStream, the
|
||||||
@ -297,21 +249,17 @@ declare module 'stream/web' {
|
|||||||
interface WritableStreamDefaultController {
|
interface WritableStreamDefaultController {
|
||||||
error(e?: any): void;
|
error(e?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WritableStreamDefaultController: {
|
const WritableStreamDefaultController: {
|
||||||
prototype: WritableStreamDefaultController;
|
prototype: WritableStreamDefaultController;
|
||||||
new (): WritableStreamDefaultController;
|
new (): WritableStreamDefaultController;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface QueuingStrategy<T = any> {
|
interface QueuingStrategy<T = any> {
|
||||||
highWaterMark?: number;
|
highWaterMark?: number;
|
||||||
size?: QueuingStrategySize<T>;
|
size?: QueuingStrategySize<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QueuingStrategySize<T = any> {
|
interface QueuingStrategySize<T = any> {
|
||||||
(chunk?: T): number;
|
(chunk?: T): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QueuingStrategyInit {
|
interface QueuingStrategyInit {
|
||||||
/**
|
/**
|
||||||
* Creates a new ByteLengthQueuingStrategy with the provided high water
|
* Creates a new ByteLengthQueuingStrategy with the provided high water
|
||||||
@ -324,7 +272,6 @@ declare module 'stream/web' {
|
|||||||
*/
|
*/
|
||||||
highWaterMark: number;
|
highWaterMark: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Streams API interface provides a built-in byte length queuing
|
* This Streams API interface provides a built-in byte length queuing
|
||||||
* strategy that can be used when constructing streams.
|
* strategy that can be used when constructing streams.
|
||||||
@ -333,12 +280,10 @@ declare module 'stream/web' {
|
|||||||
readonly highWaterMark: number;
|
readonly highWaterMark: number;
|
||||||
readonly size: QueuingStrategySize<ArrayBufferView>;
|
readonly size: QueuingStrategySize<ArrayBufferView>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ByteLengthQueuingStrategy: {
|
const ByteLengthQueuingStrategy: {
|
||||||
prototype: ByteLengthQueuingStrategy;
|
prototype: ByteLengthQueuingStrategy;
|
||||||
new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
|
new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Streams API interface provides a built-in byte length queuing
|
* This Streams API interface provides a built-in byte length queuing
|
||||||
* strategy that can be used when constructing streams.
|
* strategy that can be used when constructing streams.
|
||||||
@ -347,12 +292,10 @@ declare module 'stream/web' {
|
|||||||
readonly highWaterMark: number;
|
readonly highWaterMark: number;
|
||||||
readonly size: QueuingStrategySize;
|
readonly size: QueuingStrategySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CountQueuingStrategy: {
|
const CountQueuingStrategy: {
|
||||||
prototype: CountQueuingStrategy;
|
prototype: CountQueuingStrategy;
|
||||||
new (init: QueuingStrategyInit): CountQueuingStrategy;
|
new (init: QueuingStrategyInit): CountQueuingStrategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TextEncoderStream {
|
interface TextEncoderStream {
|
||||||
/** Returns "utf-8". */
|
/** Returns "utf-8". */
|
||||||
readonly encoding: 'utf-8';
|
readonly encoding: 'utf-8';
|
||||||
@ -360,19 +303,15 @@ declare module 'stream/web' {
|
|||||||
readonly writable: WritableStream<string>;
|
readonly writable: WritableStream<string>;
|
||||||
readonly [Symbol.toStringTag]: string;
|
readonly [Symbol.toStringTag]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextEncoderStream: {
|
const TextEncoderStream: {
|
||||||
prototype: TextEncoderStream;
|
prototype: TextEncoderStream;
|
||||||
new (): TextEncoderStream;
|
new (): TextEncoderStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TextDecoderOptions {
|
interface TextDecoderOptions {
|
||||||
fatal?: boolean;
|
fatal?: boolean;
|
||||||
ignoreBOM?: boolean;
|
ignoreBOM?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type BufferSource = ArrayBufferView | ArrayBuffer;
|
type BufferSource = ArrayBufferView | ArrayBuffer;
|
||||||
|
|
||||||
interface TextDecoderStream {
|
interface TextDecoderStream {
|
||||||
/** Returns encoding's name, lower cased. */
|
/** Returns encoding's name, lower cased. */
|
||||||
readonly encoding: string;
|
readonly encoding: string;
|
||||||
@ -384,7 +323,6 @@ declare module 'stream/web' {
|
|||||||
readonly writable: WritableStream<BufferSource>;
|
readonly writable: WritableStream<BufferSource>;
|
||||||
readonly [Symbol.toStringTag]: string;
|
readonly [Symbol.toStringTag]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextDecoderStream: {
|
const TextDecoderStream: {
|
||||||
prototype: TextDecoderStream;
|
prototype: TextDecoderStream;
|
||||||
new (label?: string, options?: TextDecoderOptions): 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
|
* The `string_decoder` module provides an API for decoding `Buffer` objects into
|
||||||
@ -39,7 +39,7 @@
|
|||||||
* decoder.write(Buffer.from([0x82]));
|
* decoder.write(Buffer.from([0x82]));
|
||||||
* console.log(decoder.end(Buffer.from([0xAC])));
|
* 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' {
|
declare module 'string_decoder' {
|
||||||
class StringDecoder {
|
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.
|
* 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' {
|
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
|
* 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.
|
* 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.
|
* @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.
|
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||||
* @param options Configuration options for the test
|
* @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(options?: TestOptions, fn?: TestFn): Promise<void>;
|
||||||
function test(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.
|
* @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.
|
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||||
* @param options Configuration options for the suite
|
* @param options Configuration options for the suite
|
||||||
@ -57,8 +65,8 @@ declare module 'node:test' {
|
|||||||
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
||||||
function describe(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.
|
* @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.
|
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||||
* @param options Configuration options for the test
|
* @param options Configuration options for the test
|
||||||
@ -89,17 +97,133 @@ declare module 'node:test' {
|
|||||||
*/
|
*/
|
||||||
type ItFn = (done: (result?: any) => void) => any;
|
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
|
* 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.
|
* test runner. However, the `TestContext` constructor is not exposed as part of the API.
|
||||||
* @since v16.17.0
|
* @since v18.0.0
|
||||||
*/
|
*/
|
||||||
interface TestContext {
|
interface TestContext {
|
||||||
/**
|
/**
|
||||||
* This function is used to write TAP diagnostics to the output. Any diagnostic information is
|
* 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.
|
* 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.
|
* @param message Message to be displayed as a TAP diagnostic.
|
||||||
* @since v16.17.0
|
* @since v18.0.0
|
||||||
*/
|
*/
|
||||||
diagnostic(message: string): void;
|
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`
|
* 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.
|
* command-line option, this function is a no-op.
|
||||||
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
||||||
* @since v16.17.0
|
* @since v18.0.0
|
||||||
*/
|
*/
|
||||||
runOnly(shouldRunOnlyTests: boolean): void;
|
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
|
* 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.
|
* the test function. This function does not return a value.
|
||||||
* @param message Optional skip message to be displayed in TAP output.
|
* @param message Optional skip message to be displayed in TAP output.
|
||||||
* @since v16.17.0
|
* @since v18.0.0
|
||||||
*/
|
*/
|
||||||
skip(message?: string): void;
|
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
|
* included in the TAP output. Calling `todo()` does not terminate execution of the test
|
||||||
* function. This function does not return a value.
|
* function. This function does not return a value.
|
||||||
* @param message Optional `TODO` message to be displayed in TAP output.
|
* @param message Optional `TODO` message to be displayed in TAP output.
|
||||||
* @since v16.17.0
|
* @since v18.0.0
|
||||||
*/
|
*/
|
||||||
todo(message?: string): void;
|
todo(message?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to create subtests under the current test. This function behaves in
|
* 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.
|
* 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.
|
* @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.
|
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
||||||
* @param options Configuration options for the test
|
* @param options Configuration options for the test
|
||||||
@ -162,7 +286,7 @@ declare module 'node:test' {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows aborting an in-progress test.
|
* Allows aborting an in-progress test.
|
||||||
* @since v16.17.0
|
* @since v18.8.0
|
||||||
*/
|
*/
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
|
|
||||||
@ -177,7 +301,7 @@ declare module 'node:test' {
|
|||||||
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
||||||
* value from their parent.
|
* value from their parent.
|
||||||
* @default Infinity
|
* @default Infinity
|
||||||
* @since v16.17.0
|
* @since v18.7.0
|
||||||
*/
|
*/
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
|
||||||
@ -189,5 +313,65 @@ declare module 'node:test' {
|
|||||||
todo?: boolean | string;
|
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
|
* 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
|
* 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
|
* 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).
|
* 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' {
|
declare module 'timers' {
|
||||||
import { Abortable } from 'node:events';
|
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
|
* The `timers/promises` API provides an alternative set of timer functions
|
||||||
@ -65,31 +65,6 @@ declare module 'timers/promises' {
|
|||||||
* @since v15.9.0
|
* @since v15.9.0
|
||||||
*/
|
*/
|
||||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
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' {
|
declare module 'node:timers/promises' {
|
||||||
export * from '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
|
* The `tls` module provides an implementation of the Transport Layer Security
|
||||||
@ -9,11 +9,12 @@
|
|||||||
* ```js
|
* ```js
|
||||||
* const tls = require('tls');
|
* 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' {
|
declare module 'tls' {
|
||||||
import { X509Certificate } from 'node:crypto';
|
import { X509Certificate } from 'node:crypto';
|
||||||
import * as net from 'node:net';
|
import * as net from 'node:net';
|
||||||
|
import * as stream from 'stream';
|
||||||
const CLIENT_RENEG_LIMIT: number;
|
const CLIENT_RENEG_LIMIT: number;
|
||||||
const CLIENT_RENEG_WINDOW: number;
|
const CLIENT_RENEG_WINDOW: number;
|
||||||
interface Certificate {
|
interface Certificate {
|
||||||
@ -145,8 +146,8 @@ declare module 'tls' {
|
|||||||
*/
|
*/
|
||||||
constructor(socket: net.Socket, options?: TLSSocketOptions);
|
constructor(socket: net.Socket, options?: TLSSocketOptions);
|
||||||
/**
|
/**
|
||||||
* Returns `true` if the peer certificate was signed by one of the CAs specified
|
* This property is `true` if the peer certificate was signed by one of the CAs
|
||||||
* when creating the `tls.TLSSocket` instance, otherwise `false`.
|
* specified when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||||
* @since v0.11.4
|
* @since v0.11.4
|
||||||
*/
|
*/
|
||||||
authorized: boolean;
|
authorized: boolean;
|
||||||
@ -345,9 +346,9 @@ declare module 'tls' {
|
|||||||
* When enabled, TLS packet trace information is written to `stderr`. This can be
|
* When enabled, TLS packet trace information is written to `stderr`. This can be
|
||||||
* used to debug TLS connection problems.
|
* 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
|
* 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
|
||||||
* undocumented, can change without notice,
|
* OpenSSL's `SSL_trace()` function, the format is undocumented, can change
|
||||||
* and should not be relied on.
|
* without notice, and should not be relied on.
|
||||||
* @since v12.2.0
|
* @since v12.2.0
|
||||||
*/
|
*/
|
||||||
enableTrace(): void;
|
enableTrace(): void;
|
||||||
@ -376,7 +377,7 @@ declare module 'tls' {
|
|||||||
* 128,
|
* 128,
|
||||||
* 'client finished');
|
* 'client finished');
|
||||||
*
|
*
|
||||||
*
|
* /*
|
||||||
* Example return value of keyingMaterial:
|
* 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
|
* <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
|
* 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;
|
host?: string | undefined;
|
||||||
port?: number | undefined;
|
port?: number | undefined;
|
||||||
path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
|
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;
|
checkServerIdentity?: typeof checkServerIdentity | undefined;
|
||||||
servername?: string | undefined; // SNI TLS Extension
|
servername?: string | undefined; // SNI TLS Extension
|
||||||
session?: Buffer | undefined;
|
session?: Buffer | undefined;
|
||||||
@ -725,7 +726,7 @@ declare module 'tls' {
|
|||||||
* object.passphrase is optional. Encrypted keys will be decrypted with
|
* object.passphrase is optional. Encrypted keys will be decrypted with
|
||||||
* object.passphrase if provided, or options.passphrase if it is not.
|
* 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
|
* Name of an OpenSSL engine to get private key from. Should be used
|
||||||
* together with privateKeyIdentifier.
|
* 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
|
* 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).
|
* 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
|
* This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as
|
||||||
* the `options.checkServerIdentity` option passed to `tls.connect()`. The
|
* 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
|
* overwriting function can call `tls.checkServerIdentity()` of course, to augment
|
||||||
* the checks done with additional verification.
|
* the checks done with additional verification.
|
||||||
*
|
*
|
||||||
* This function is only called if the certificate passed all other checks, such as
|
* This function is only called if the certificate passed all other checks, such as
|
||||||
* being issued by trusted CA (`options.ca`).
|
* 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
|
* @since v0.8.4
|
||||||
* @param hostname The host name or IP address to verify the certificate against.
|
* @param hostname The host name or IP address to verify the certificate against.
|
||||||
* @param cert A `certificate object` representing the peer's certificate.
|
* @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
|
* lower-case for historical reasons, but must be uppercased to be used in
|
||||||
* the `ciphers` option of {@link createSecureContext}.
|
* 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
|
* Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
|
||||||
* TLSv1.2 and below.
|
* 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
|
* 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
|
* 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
|
* The tracing system uses the same time source
|
||||||
* as the one used by `process.hrtime()`.
|
* as the one used by `process.hrtime()`.
|
||||||
* However the trace-event timestamps are expressed in microseconds,
|
* However the trace-event timestamps are expressed in microseconds,
|
||||||
@ -76,7 +86,7 @@
|
|||||||
*
|
*
|
||||||
* The features from this module are not available in `Worker` threads.
|
* The features from this module are not available in `Worker` threads.
|
||||||
* @experimental
|
* @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' {
|
declare module 'trace_events' {
|
||||||
/**
|
/**
|
||||||
|
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
@ -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
@ -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
1372
packages/node_modules/@node-red/editor-client/src/types/node/ts4.8/child_process.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
@ -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
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
@ -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';
|
||||||
|
}
|