@node-red/nodes 4.1.5 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -392,12 +392,28 @@ RED.debug = (function() {
392
392
  if (o) { stack.push(o); }
393
393
  if (!busy && (stack.length > 0)) {
394
394
  busy = true;
395
- processDebugMessage(stack.shift());
396
- setTimeout(function() {
397
- busy = false;
398
- handleDebugMessage();
399
- }, 15); // every 15mS = 66 times a second
400
- if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
395
+ const message = stack.shift()
396
+ // call any preDebugLog hooks, allowing them to modify the message or block it from being displayed
397
+ RED.hooks.trigger('debugPreProcessMessage', { message }).then(result => {
398
+ if (result === false) {
399
+ return false; // A hook returned false - halt processing of this message
400
+ }
401
+ return processDebugMessage(message);
402
+ }).then(processArtifacts => {
403
+ if (processArtifacts === false) {
404
+ return false; // A hook returned false - halt processing of this message
405
+ }
406
+ const { message, element, payload } = processArtifacts || {};
407
+ return RED.hooks.trigger('debugPostProcessMessage', { message, element, payload });
408
+ }).catch(err => {
409
+ console.error("Error in debug process message hooks", err);
410
+ }).finally(() => {
411
+ setTimeout(function() {
412
+ busy = false;
413
+ handleDebugMessage();
414
+ }, 15); // every 15mS = 66 times a second
415
+ if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
416
+ })
401
417
  }
402
418
  }
403
419
 
@@ -519,10 +535,13 @@ RED.debug = (function() {
519
535
  sourceId: sourceNode && sourceNode.id,
520
536
  rootPath: path,
521
537
  nodeSelector: config.messageSourceClick,
522
- enablePinning: true
538
+ enablePinning: true,
539
+ tools: o.tools // permit preDebugLog hooks to add extra tools to the <debugMessage> element
523
540
  });
524
541
  // Do this in a separate step so the element functions aren't stripped
525
542
  debugMessage.appendTo(el);
543
+ // add the meta row tools container, even if there are no tools, so that the postProcessDebugMessage hook can add tools
544
+ const tools = $('<span class="red-ui-debug-msg-tools button-group"></span>').appendTo(metaRow)
526
545
  // NOTE: relying on function error to have a "type" that all other msgs don't
527
546
  if (o.hasOwnProperty("type") && (o.type === "function")) {
528
547
  var errorLvlType = 'error';
@@ -534,7 +553,6 @@ RED.debug = (function() {
534
553
  msg.addClass('red-ui-debug-msg-level-' + errorLvl);
535
554
  $('<span class="red-ui-debug-msg-topic">function : (' + errorLvlType + ')</span>').appendTo(metaRow);
536
555
  } else {
537
- var tools = $('<span class="red-ui-debug-msg-tools button-group"></span>').appendTo(metaRow);
538
556
  var filterMessage = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-caret-down"></i></button>').appendTo(tools);
539
557
  filterMessage.on("click", function(e) {
540
558
  e.preventDefault();
@@ -590,6 +608,14 @@ RED.debug = (function() {
590
608
  if (atBottom) {
591
609
  messageList.scrollTop(sbc.scrollHeight);
592
610
  }
611
+
612
+ // return artifacts to permit postProcessDebugMessage hooks to modify the message element, access the
613
+ // processed payload or otherwise modify the message after it has been generated.
614
+ return {
615
+ message: o, // original debug message object, useful for any hook that might have tagged additional info onto it
616
+ element: msg, // the top-level element for this debug message
617
+ payload // the reconstructed debug message
618
+ }
593
619
  }
594
620
 
595
621
  function clearMessageList(clearFilter, filteredOnly) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/nodes",
3
- "version": "4.1.5",
3
+ "version": "4.1.6",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,9 +15,9 @@
15
15
  }
16
16
  ],
17
17
  "dependencies": {
18
- "acorn": "8.15.0",
19
- "acorn-walk": "8.3.4",
20
- "ajv": "8.17.1",
18
+ "acorn": "8.16.0",
19
+ "acorn-walk": "8.3.5",
20
+ "ajv": "8.18.0",
21
21
  "body-parser": "1.20.4",
22
22
  "cheerio": "1.0.0-rc.10",
23
23
  "content-type": "1.0.5",
@@ -35,7 +35,7 @@
35
35
  "is-utf8": "0.2.1",
36
36
  "js-yaml": "4.1.1",
37
37
  "media-typer": "1.1.0",
38
- "mqtt": "5.11.0",
38
+ "mqtt": "5.15.0",
39
39
  "multer": "2.0.2",
40
40
  "mustache": "4.2.0",
41
41
  "node-watch": "0.7.4",