diff --git a/package.json b/package.json index c7fe644f7..e0904530d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "cors": "2.8.5", "cronosjs": "1.7.1", "denque": "2.1.0", - "express": "4.21.1", + "express": "4.21.2", "express-session": "1.18.1", "form-data": "4.0.0", "fs-extra": "11.2.0", diff --git a/packages/node_modules/@node-red/editor-api/package.json b/packages/node_modules/@node-red/editor-api/package.json index e58f2e9fb..7f71a5fb7 100644 --- a/packages/node_modules/@node-red/editor-api/package.json +++ b/packages/node_modules/@node-red/editor-api/package.json @@ -23,7 +23,7 @@ "clone": "2.1.2", "cors": "2.8.5", "express-session": "1.18.1", - "express": "4.21.1", + "express": "4.21.2", "memorystore": "1.6.7", "mime": "3.0.0", "multer": "1.4.5-lts.1", diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js index 4e16bd3f6..435e4a8cd 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js @@ -334,6 +334,30 @@ RED.clipboard = (function() { },100); } + /** + * Validates if the provided string looks like valid flow json + * @param {string} flowString the string to validate + * @returns If valid, returns the node array + */ + function validateFlowString(flowString) { + const res = JSON.parse(flowString) + if (!Array.isArray(res)) { + throw new Error(RED._("clipboard.import.errors.notArray")); + } + for (let i = 0; i < res.length; i++) { + if (typeof res[i] !== "object") { + throw new Error(RED._("clipboard.import.errors.itemNotObject",{index:i})); + } + if (!Object.hasOwn(res[i], 'id')) { + throw new Error(RED._("clipboard.import.errors.missingId",{index:i})); + } + if (!Object.hasOwn(res[i], 'type')) { + throw new Error(RED._("clipboard.import.errors.missingType",{index:i})); + } + } + return res + } + var validateImportTimeout; function validateImport() { if (activeTab === "red-ui-clipboard-dialog-import-tab-clipboard") { @@ -351,21 +375,7 @@ RED.clipboard = (function() { return; } try { - if (!/^\[[\s\S]*\]$/m.test(v)) { - throw new Error(RED._("clipboard.import.errors.notArray")); - } - var res = JSON.parse(v); - for (var i=0;i !e.link)); + let wiresToSplit = options.wires || (RED.view.selection().links && RED.view.selection().links.filter(e => !e.link)); if (!wiresToSplit) { return } @@ -1206,21 +1206,26 @@ RED.view.tools = (function() { if (links.length === 0) { return } - let pointCount = 0 - links.forEach(function(l) { - if (l._sliceLocation) { - junction.x += l._sliceLocation.x - junction.y += l._sliceLocation.y - delete l._sliceLocation - pointCount++ - } else { - junction.x += l.source.x + l.source.w/2 + l.target.x - l.target.w/2 - junction.y += l.source.y + l.target.y - pointCount += 2 - } - }) - junction.x = Math.round(junction.x/pointCount) - junction.y = Math.round(junction.y/pointCount) + if (addedJunctions.length === 0 && Object.hasOwn(options, 'x') && Object.hasOwn(options, 'y')) { + junction.x = options.x + junction.y = options.y + } else { + let pointCount = 0 + links.forEach(function(l) { + if (l._sliceLocation) { + junction.x += l._sliceLocation.x + junction.y += l._sliceLocation.y + delete l._sliceLocation + pointCount++ + } else { + junction.x += l.source.x + l.source.w/2 + l.target.x - l.target.w/2 + junction.y += l.source.y + l.target.y + pointCount += 2 + } + }) + junction.x = Math.round(junction.x/pointCount) + junction.y = Math.round(junction.y/pointCount) + } if (RED.view.snapGrid) { let gridSize = RED.view.gridSize() junction.x = (gridSize*Math.round(junction.x/gridSize)); @@ -1410,7 +1415,7 @@ RED.view.tools = (function() { RED.actions.add("core:wire-multiple-to-node", function() { wireMultipleToNode() }) RED.actions.add("core:split-wire-with-link-nodes", function () { splitWiresWithLinkNodes() }); - RED.actions.add("core:split-wires-with-junctions", function () { addJunctionsToWires() }); + RED.actions.add("core:split-wires-with-junctions", function (options) { addJunctionsToWires(options) }); RED.actions.add("core:generate-node-names", generateNodeNames ) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index 245b6db75..8ce6dc630 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -321,8 +321,8 @@ RED.view = (function() { evt.stopPropagation() RED.contextMenu.show({ type: 'workspace', - x:evt.clientX-5, - y:evt.clientY-5 + x: evt.clientX, + y: evt.clientY }) return false }) @@ -5174,8 +5174,8 @@ RED.view = (function() { var delta = Infinity; for (var i = 0; i < lineLength; i++) { var linePos = pathLine.getPointAtLength(i); - var posDeltaX = Math.abs(linePos.x-d3.event.offsetX) - var posDeltaY = Math.abs(linePos.y-d3.event.offsetY) + var posDeltaX = Math.abs(linePos.x-(d3.event.offsetX / scaleFactor)) + var posDeltaY = Math.abs(linePos.y-(d3.event.offsetY / scaleFactor)) var posDelta = posDeltaX*posDeltaX + posDeltaY*posDeltaY if (posDelta < delta) { pos = linePos diff --git a/packages/node_modules/@node-red/nodes/core/function/89-delay.js b/packages/node_modules/@node-red/nodes/core/function/89-delay.js index 8f9964115..17cbd2f4f 100644 --- a/packages/node_modules/@node-red/nodes/core/function/89-delay.js +++ b/packages/node_modules/@node-red/nodes/core/function/89-delay.js @@ -291,43 +291,23 @@ module.exports = function(RED) { } } else if (!msg.hasOwnProperty("reset")) { - if (maxKeptMsgsCount(node) > 0) { - if (node.intervalID === -1) { - node.send(msg); - node.intervalID = setInterval(sendMsgFromBuffer, node.rate); - } else { - if (node.allowrate && msg.hasOwnProperty("rate") && !isNaN(parseFloat(msg.rate)) && node.rate !== msg.rate) { - node.rate = msg.rate; - clearInterval(node.intervalID); - node.intervalID = setInterval(sendMsgFromBuffer, node.rate); - } - if (node.buffer.length < _maxKeptMsgsCount) { - var m = RED.util.cloneMessage(msg); - node.buffer.push({msg: m, send: send, done: done}); - } else { - node.trace("dropped due to buffer overflow. msg._msgid = " + msg._msgid); - node.droppedMsgs++; - } - } + if (node.allowrate && msg.hasOwnProperty("rate") && !isNaN(parseFloat(msg.rate))) { + node.rate = msg.rate; } - else { - if (node.allowrate && msg.hasOwnProperty("rate") && !isNaN(parseFloat(msg.rate))) { - node.rate = msg.rate; - } - var timeSinceLast; - if (node.lastSent) { - timeSinceLast = process.hrtime(node.lastSent); - } - if (!node.lastSent) { // ensuring that we always send the first message - node.lastSent = process.hrtime(); - send(msg); - } - else if ( ( (timeSinceLast[0] * SECONDS_TO_NANOS) + timeSinceLast[1] ) > (node.rate * MILLIS_TO_NANOS) ) { - node.lastSent = process.hrtime(); - send(msg); - } else if (node.outputs === 2) { - send([null,msg]) - } + var timeSinceLast; + if (node.lastSent) { + timeSinceLast = process.hrtime(node.lastSent); + } + if (!node.lastSent) { // ensuring that we always send the first message + node.lastSent = process.hrtime(); + send(msg); + } + else if ( ( (timeSinceLast[0] * SECONDS_TO_NANOS) + timeSinceLast[1] ) > (node.rate * MILLIS_TO_NANOS) ) { + node.lastSent = process.hrtime(); + send(msg); + } + else if (node.outputs === 2) { + send([null,msg]) } done(); } diff --git a/packages/node_modules/@node-red/nodes/core/storage/10-file.js b/packages/node_modules/@node-red/nodes/core/storage/10-file.js index fea8c490e..5cff2b631 100644 --- a/packages/node_modules/@node-red/nodes/core/storage/10-file.js +++ b/packages/node_modules/@node-red/nodes/core/storage/10-file.js @@ -339,7 +339,7 @@ module.exports = function(RED) { } else { msg.filename = filename; - var lines = Buffer.from([]); + const bufferArray = []; var spare = ""; var count = 0; var type = "buffer"; @@ -397,7 +397,7 @@ module.exports = function(RED) { } } else { - lines = Buffer.concat([lines,chunk]); + bufferArray.push(chunk); } } }) @@ -413,10 +413,11 @@ module.exports = function(RED) { }) .on('end', function() { if (node.chunk === false) { + const buffer = Buffer.concat(bufferArray); if (node.format === "utf8") { - msg.payload = decode(lines, node.encoding); + msg.payload = decode(buffer, node.encoding); } - else { msg.payload = lines; } + else { msg.payload = buffer; } nodeSend(msg); } else if (node.format === "lines") { diff --git a/packages/node_modules/@node-red/runtime/package.json b/packages/node_modules/@node-red/runtime/package.json index a160c402c..73e13f13f 100644 --- a/packages/node_modules/@node-red/runtime/package.json +++ b/packages/node_modules/@node-red/runtime/package.json @@ -20,7 +20,7 @@ "@node-red/util": "4.0.5", "async-mutex": "0.5.0", "clone": "2.1.2", - "express": "4.21.1", + "express": "4.21.2", "fs-extra": "11.2.0", "json-stringify-safe": "5.0.1", "rfdc": "^1.3.1" diff --git a/packages/node_modules/node-red/package.json b/packages/node_modules/node-red/package.json index 0969024ff..56711d6ff 100644 --- a/packages/node_modules/node-red/package.json +++ b/packages/node_modules/node-red/package.json @@ -38,7 +38,7 @@ "basic-auth": "2.0.1", "bcryptjs": "2.4.3", "cors": "2.8.5", - "express": "4.21.1", + "express": "4.21.2", "fs-extra": "11.2.0", "node-red-admin": "^4.0.1", "nopt": "5.0.0",