@rosepetal/node-red-contrib-image-tools 1.1.3
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.
- package/.gitattributes +6 -0
- package/.github/workflows/build-prebuild.yml +326 -0
- package/LICENSE +13 -0
- package/README.md +161 -0
- package/artifacts/darwin-arm64/package.json +25 -0
- package/artifacts/linux-arm64/package.json +26 -0
- package/artifacts/linux-x64/package.json +26 -0
- package/artifacts/linuxmusl-x64/package.json +26 -0
- package/assets/flow_time_example.gif +0 -0
- package/assets/nodes/io/array-in-demo.gif +0 -0
- package/assets/nodes/io/array-out-demo.gif +0 -0
- package/assets/nodes/io/array-select-demo.gif +0 -0
- package/assets/nodes/io/image-in-demo.gif +0 -0
- package/assets/nodes/mix/concat-demo.gif +0 -0
- package/assets/nodes/mix/mosaic-demo.gif +0 -0
- package/assets/nodes/transform/crop-demo.gif +0 -0
- package/assets/nodes/transform/filter-demo.gif +0 -0
- package/assets/nodes/transform/padding-demo.gif +0 -0
- package/assets/nodes/transform/resize-demo.gif +0 -0
- package/assets/nodes/transform/rotate-demo.gif +0 -0
- package/docs/nodes/blend/add-mask.md +275 -0
- package/docs/nodes/blend/add-masks.md +284 -0
- package/docs/nodes/blend/blend.md +248 -0
- package/docs/nodes/io/array-in.md +119 -0
- package/docs/nodes/io/array-out.md +150 -0
- package/docs/nodes/io/array-select.md +157 -0
- package/docs/nodes/io/image-in.md +131 -0
- package/docs/nodes/io/image-out.md +179 -0
- package/docs/nodes/io/queue.md +57 -0
- package/docs/nodes/io/save-file.md +30 -0
- package/docs/nodes/mix/advanced-mosaic.md +108 -0
- package/docs/nodes/mix/concat.md +127 -0
- package/docs/nodes/mix/mosaic.md +146 -0
- package/docs/nodes/specialized/cropBB.md +271 -0
- package/docs/nodes/specialized/image-align.md +426 -0
- package/docs/nodes/transform/crop.md +132 -0
- package/docs/nodes/transform/draw.md +77 -0
- package/docs/nodes/transform/filter.md +84 -0
- package/docs/nodes/transform/padding.md +133 -0
- package/docs/nodes/transform/resize.md +158 -0
- package/docs/nodes/transform/rotate.md +121 -0
- package/docs/nodes/util/block-detect.md +46 -0
- package/install.sh +144 -0
- package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
- package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
- package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
- package/node-red-contrib-image-tools/package.json +64 -0
- package/npm/darwin-arm64/lib/.gitkeep +1 -0
- package/npm/darwin-arm64/package.json +25 -0
- package/npm/darwin-x64/lib/.gitkeep +1 -0
- package/npm/darwin-x64/package.json +25 -0
- package/npm/linux-arm64/lib/.gitkeep +1 -0
- package/npm/linux-arm64/package.json +26 -0
- package/npm/linux-x64/lib/.gitkeep +1 -0
- package/npm/linux-x64/package.json +26 -0
- package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
- package/npm/linuxmusl-x64/package.json +26 -0
- package/npm/win32-x64/lib/.gitkeep +1 -0
- package/npm/win32-x64/package.json +25 -0
- package/package.json +74 -0
- package/rosepetal-image-engine/binding.gyp +153 -0
- package/rosepetal-image-engine/package.json +19 -0
- package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
- package/rosepetal-image-engine/src/add-mask.cpp +240 -0
- package/rosepetal-image-engine/src/add-masks.cpp +638 -0
- package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
- package/rosepetal-image-engine/src/blend.cpp +200 -0
- package/rosepetal-image-engine/src/concat.cpp +329 -0
- package/rosepetal-image-engine/src/crop.cpp +139 -0
- package/rosepetal-image-engine/src/draw.cpp +414 -0
- package/rosepetal-image-engine/src/filter.cpp +230 -0
- package/rosepetal-image-engine/src/filters/kernels.h +171 -0
- package/rosepetal-image-engine/src/image-align.cpp +551 -0
- package/rosepetal-image-engine/src/main.cpp +36 -0
- package/rosepetal-image-engine/src/mosaic.cpp +373 -0
- package/rosepetal-image-engine/src/padding.cpp +124 -0
- package/rosepetal-image-engine/src/resize.cpp +210 -0
- package/rosepetal-image-engine/src/rotate.cpp +177 -0
- package/rosepetal-image-engine/src/utils.h +563 -0
- package/rosepetal-image-engine/test-formats.js +119 -0
- package/scripts/build-opencv-static.ps1 +166 -0
- package/scripts/build-opencv-static.sh +147 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function() {
|
|
3
|
+
RED.nodes.registerType('block-detect', {
|
|
4
|
+
category: 'RP Image',
|
|
5
|
+
color: '#F4C95D',
|
|
6
|
+
defaults: {
|
|
7
|
+
name: { value: "" },
|
|
8
|
+
intervalMs: { value: 1000, required: true, validate: RED.validators.number() },
|
|
9
|
+
thresholdMs: { value: 120, required: true, validate: RED.validators.number() },
|
|
10
|
+
consecutive: { value: 1, required: true, validate: RED.validators.number() },
|
|
11
|
+
cooldown: { value: 30000, required: true, validate: RED.validators.number() },
|
|
12
|
+
showStats: { value: true }
|
|
13
|
+
},
|
|
14
|
+
inputs: 0,
|
|
15
|
+
outputs: 0,
|
|
16
|
+
icon: "font-awesome/fa-shield",
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name || "block detect";
|
|
19
|
+
},
|
|
20
|
+
oneditprepare: function() {
|
|
21
|
+
$("#node-input-showStats").prop("checked", this.showStats !== false);
|
|
22
|
+
},
|
|
23
|
+
oneditsave: function() {
|
|
24
|
+
this.showStats = $("#node-input-showStats").is(":checked");
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
})();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="text/x-red" data-template-name="block-detect">
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
33
|
+
<input type="text" id="node-input-name" placeholder="Event loop watchdog">
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-input-thresholdMs"><i class="fa fa-bolt"></i> Threshold (ms)</label>
|
|
38
|
+
<input type="number" id="node-input-thresholdMs" min="1" step="10">
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="form-row">
|
|
42
|
+
<label for="node-input-intervalMs"><i class="fa fa-clock-o"></i> Sample interval (ms)</label>
|
|
43
|
+
<input type="number" id="node-input-intervalMs" min="100" step="100">
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div class="form-row">
|
|
47
|
+
<label for="node-input-consecutive"><i class="fa fa-repeat"></i> Consecutive hits</label>
|
|
48
|
+
<input type="number" id="node-input-consecutive" min="1" step="1">
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div class="form-row">
|
|
52
|
+
<label for="node-input-cooldown"><i class="fa fa-hourglass-half"></i> Cooldown (ms)</label>
|
|
53
|
+
<input type="number" id="node-input-cooldown" min="1000" step="1000">
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div class="form-row">
|
|
57
|
+
<label></label>
|
|
58
|
+
<input type="checkbox" id="node-input-showStats" checked>
|
|
59
|
+
<label for="node-input-showStats" style="width: auto;">Show live delay metrics</label>
|
|
60
|
+
</div>
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<script type="text/x-red" data-help-name="block-detect">
|
|
64
|
+
<p>Continuously monitors Node-RED's event loop for blocking work that would slow down flows.</p>
|
|
65
|
+
|
|
66
|
+
<h3>How it works</h3>
|
|
67
|
+
<p>The node samples <code>monitorEventLoopDelay</code> (or falls back to timer drift) and raises an alert when the measured delay exceeds the configured threshold for a number of consecutive samples.</p>
|
|
68
|
+
|
|
69
|
+
<h3>Properties</h3>
|
|
70
|
+
<dl class="message-properties">
|
|
71
|
+
<dt>Threshold (ms)<span class="property-type">number</span></dt>
|
|
72
|
+
<dd>Maximum allowed event loop delay before the node treats a sample as blocking.</dd>
|
|
73
|
+
<dt>Sample interval (ms)<span class="property-type">number</span></dt>
|
|
74
|
+
<dd>How often to collect a measurement. Lower values catch spikes sooner but cost a little more CPU.</dd>
|
|
75
|
+
<dt>Consecutive hits<span class="property-type">number</span></dt>
|
|
76
|
+
<dd>Number of back-to-back samples that must exceed the threshold before an alert is emitted.</dd>
|
|
77
|
+
<dt>Cooldown (ms)<span class="property-type">number</span></dt>
|
|
78
|
+
<dd>Minimum time between alerts so your logs do not flood when something stays blocked.</dd>
|
|
79
|
+
<dt>Show live delay metrics<span class="property-type">boolean</span></dt>
|
|
80
|
+
<dd>Toggle live status text that displays the current average and max delay.</dd>
|
|
81
|
+
</dl>
|
|
82
|
+
|
|
83
|
+
<h3>Usage</h3>
|
|
84
|
+
<p>Drop the node anywhere in a flow (it has no wires) to keep a lightweight background watchdog running. Use multiple instances with different thresholds if you want per-flow granularity.</p>
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Node-RED logic for the block-detect node.
|
|
3
|
+
* Monitors the Node.js event loop delay to detect blocking work.
|
|
4
|
+
*/
|
|
5
|
+
const { performance, monitorEventLoopDelay } = require('perf_hooks');
|
|
6
|
+
|
|
7
|
+
module.exports = function(RED) {
|
|
8
|
+
function BlockDetectNode(config) {
|
|
9
|
+
RED.nodes.createNode(this, config);
|
|
10
|
+
const node = this;
|
|
11
|
+
|
|
12
|
+
const intervalMs = sanitizeNumber(config.intervalMs, 1000, 100);
|
|
13
|
+
const thresholdMs = sanitizeNumber(config.thresholdMs, 120, 1);
|
|
14
|
+
const resolutionMs = 20; // Medium resolution for event-loop histogram (ms)
|
|
15
|
+
const consecutive = Math.max(1, Math.round(sanitizeNumber(config.consecutive, 1, 1)));
|
|
16
|
+
const cooldownMs = sanitizeNumber(config.cooldown, 30000, 1000);
|
|
17
|
+
const showStats = config.showStats !== false;
|
|
18
|
+
|
|
19
|
+
let overThresholdCount = 0;
|
|
20
|
+
let lastAlertAt = 0;
|
|
21
|
+
let timer = null;
|
|
22
|
+
let histogram = null;
|
|
23
|
+
let fallbackPrev = performance.now();
|
|
24
|
+
let monitorAvailable = typeof monitorEventLoopDelay === 'function';
|
|
25
|
+
|
|
26
|
+
if (monitorAvailable) {
|
|
27
|
+
histogram = monitorEventLoopDelay({ resolution: resolutionMs });
|
|
28
|
+
histogram.enable();
|
|
29
|
+
} else {
|
|
30
|
+
node.warn('monitorEventLoopDelay not available; falling back to coarse timer drift detection.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
node.status({ fill: 'grey', shape: 'ring', text: 'monitoring…' });
|
|
34
|
+
|
|
35
|
+
timer = setInterval(() => {
|
|
36
|
+
const stats = monitorAvailable
|
|
37
|
+
? readHistogramStats(histogram)
|
|
38
|
+
: readFallbackStats();
|
|
39
|
+
|
|
40
|
+
if (showStats) {
|
|
41
|
+
const color = stats.max >= thresholdMs ? (stats.alert ? 'red' : 'yellow') : 'green';
|
|
42
|
+
const shape = stats.max >= thresholdMs ? 'ring' : 'dot';
|
|
43
|
+
node.status({
|
|
44
|
+
fill: color,
|
|
45
|
+
shape,
|
|
46
|
+
text: `avg ${stats.mean.toFixed(1)}ms | max ${stats.max.toFixed(1)}ms`
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
if (stats.alert) {
|
|
50
|
+
node.status({ fill: 'red', shape: 'dot', text: 'blocking detected' });
|
|
51
|
+
} else if (stats.max >= thresholdMs) {
|
|
52
|
+
node.status({ fill: 'yellow', shape: 'ring', text: 'high loop delay' });
|
|
53
|
+
} else {
|
|
54
|
+
node.status({ fill: 'green', shape: 'dot', text: 'ok' });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (stats.max >= thresholdMs) {
|
|
59
|
+
overThresholdCount += 1;
|
|
60
|
+
} else {
|
|
61
|
+
overThresholdCount = 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (overThresholdCount >= consecutive) {
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
if (now - lastAlertAt >= cooldownMs) {
|
|
67
|
+
emitAlert(stats);
|
|
68
|
+
lastAlertAt = now;
|
|
69
|
+
}
|
|
70
|
+
overThresholdCount = 0;
|
|
71
|
+
}
|
|
72
|
+
}, intervalMs);
|
|
73
|
+
|
|
74
|
+
node.on('close', function() {
|
|
75
|
+
if (timer) {
|
|
76
|
+
clearInterval(timer);
|
|
77
|
+
}
|
|
78
|
+
if (histogram) {
|
|
79
|
+
histogram.disable();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
function emitAlert(stats) {
|
|
84
|
+
const message =
|
|
85
|
+
`Detected potential blocking: max ${stats.max.toFixed(1)} ms ` +
|
|
86
|
+
`(avg ${stats.mean.toFixed(1)} ms, min ${stats.min.toFixed(1)} ms, threshold ${thresholdMs} ms).`;
|
|
87
|
+
|
|
88
|
+
node.warn(message);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function readHistogramStats(hist) {
|
|
92
|
+
const mean = Number.isFinite(hist.mean) ? hist.mean / 1e6 : 0;
|
|
93
|
+
const max = Number.isFinite(hist.max) ? hist.max / 1e6 : 0;
|
|
94
|
+
const min = Number.isFinite(hist.min) ? hist.min / 1e6 : 0;
|
|
95
|
+
hist.reset();
|
|
96
|
+
return {
|
|
97
|
+
mean,
|
|
98
|
+
max,
|
|
99
|
+
min,
|
|
100
|
+
alert: max >= thresholdMs
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function readFallbackStats() {
|
|
105
|
+
const now = performance.now();
|
|
106
|
+
const delta = now - fallbackPrev;
|
|
107
|
+
fallbackPrev = now;
|
|
108
|
+
const delay = Math.max(0, delta - intervalMs);
|
|
109
|
+
return {
|
|
110
|
+
mean: delay,
|
|
111
|
+
max: delay,
|
|
112
|
+
min: delay,
|
|
113
|
+
alert: delay >= thresholdMs
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
RED.nodes.registerType('block-detect', BlockDetectNode, {
|
|
119
|
+
defaults: {
|
|
120
|
+
name: { value: '' },
|
|
121
|
+
intervalMs: { value: 1000 },
|
|
122
|
+
thresholdMs: { value: 120 },
|
|
123
|
+
consecutive: { value: 1 },
|
|
124
|
+
cooldown: { value: 30000 },
|
|
125
|
+
showStats: { value: true }
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
function sanitizeNumber(value, fallback, min) {
|
|
131
|
+
const num = Number(value);
|
|
132
|
+
if (Number.isFinite(num)) {
|
|
133
|
+
return Math.max(min, num);
|
|
134
|
+
}
|
|
135
|
+
return fallback;
|
|
136
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function() {
|
|
3
|
+
function toggleCompleteField($complete, type) {
|
|
4
|
+
const $textInput = $complete.typedInput('input');
|
|
5
|
+
if (type === "full") {
|
|
6
|
+
if ($textInput && $textInput.length) {
|
|
7
|
+
$textInput.prop("disabled", true).addClass("disabled");
|
|
8
|
+
}
|
|
9
|
+
$("#node-input-complete-full-label").show();
|
|
10
|
+
} else {
|
|
11
|
+
if ($textInput && $textInput.length) {
|
|
12
|
+
$textInput.prop("disabled", false).removeClass("disabled");
|
|
13
|
+
}
|
|
14
|
+
$("#node-input-complete-full-label").hide();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RED.nodes.registerType('clean-debug', {
|
|
19
|
+
category: 'common',
|
|
20
|
+
paletteLabel: 'clean debug',
|
|
21
|
+
color: '#E2D96E',
|
|
22
|
+
inputs: 1,
|
|
23
|
+
outputs: 0,
|
|
24
|
+
icon: 'font-awesome/fa-bug',
|
|
25
|
+
align: 'right',
|
|
26
|
+
defaults: {
|
|
27
|
+
name: { value: "" },
|
|
28
|
+
active: { value: true },
|
|
29
|
+
tosidebar: { value: true },
|
|
30
|
+
console: { value: false },
|
|
31
|
+
complete: { value: "payload" },
|
|
32
|
+
targetType: { value: "msg" },
|
|
33
|
+
clean: { value: true }
|
|
34
|
+
},
|
|
35
|
+
label: function() {
|
|
36
|
+
if (this.name) {
|
|
37
|
+
return this.name;
|
|
38
|
+
}
|
|
39
|
+
return this.clean === false ? "debug" : "clean debug";
|
|
40
|
+
},
|
|
41
|
+
labelStyle: function() {
|
|
42
|
+
return this.name ? "node_label_italic" : "";
|
|
43
|
+
},
|
|
44
|
+
button: {
|
|
45
|
+
toggle: "active",
|
|
46
|
+
visible: function() {
|
|
47
|
+
return true;
|
|
48
|
+
},
|
|
49
|
+
onclick: function() {
|
|
50
|
+
var node = this;
|
|
51
|
+
var desiredState = node.active;
|
|
52
|
+
|
|
53
|
+
sendCleanDebugToggle(node, desiredState, function() {
|
|
54
|
+
var historyEvent = {
|
|
55
|
+
t: 'edit',
|
|
56
|
+
node: node,
|
|
57
|
+
changes: {
|
|
58
|
+
active: !node.active
|
|
59
|
+
},
|
|
60
|
+
dirty: node.dirty,
|
|
61
|
+
changed: node.changed,
|
|
62
|
+
callback: function(ev) {
|
|
63
|
+
sendCleanDebugToggle(ev.node, ev.node.active);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
node.changed = true;
|
|
68
|
+
node.dirty = true;
|
|
69
|
+
RED.nodes.dirty(true);
|
|
70
|
+
RED.history.push(historyEvent);
|
|
71
|
+
RED.view.redraw();
|
|
72
|
+
}, function() {
|
|
73
|
+
node.active = !node.active;
|
|
74
|
+
RED.view.redraw();
|
|
75
|
+
RED.notify("Failed to update Clean Debug state", "error");
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
oneditprepare: function() {
|
|
80
|
+
const $complete = $("#node-input-complete");
|
|
81
|
+
$complete.typedInput({
|
|
82
|
+
default: 'msg',
|
|
83
|
+
types: [
|
|
84
|
+
'msg',
|
|
85
|
+
'flow',
|
|
86
|
+
'global',
|
|
87
|
+
'str',
|
|
88
|
+
'num',
|
|
89
|
+
'bool',
|
|
90
|
+
'json',
|
|
91
|
+
'bin',
|
|
92
|
+
'date',
|
|
93
|
+
'jsonata',
|
|
94
|
+
'env',
|
|
95
|
+
{
|
|
96
|
+
value: 'full',
|
|
97
|
+
label: 'complete msg object',
|
|
98
|
+
hasValue: false
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
typeField: "#node-input-targetType"
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
toggleCompleteField($complete, $complete.typedInput('type'));
|
|
105
|
+
|
|
106
|
+
$complete.on("change", function() {
|
|
107
|
+
toggleCompleteField($complete, $complete.typedInput('type'));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
$("#node-input-tosidebar").prop("checked", this.tosidebar !== false);
|
|
111
|
+
$("#node-input-console").prop("checked", this.console === true);
|
|
112
|
+
$("#node-input-clean").prop("checked", this.clean !== false);
|
|
113
|
+
},
|
|
114
|
+
oneditsave: function() {
|
|
115
|
+
this.tosidebar = $("#node-input-tosidebar").is(":checked");
|
|
116
|
+
this.console = $("#node-input-console").is(":checked");
|
|
117
|
+
this.clean = $("#node-input-clean").is(":checked");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
})();
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<script type="text/x-red" data-template-name="clean-debug">
|
|
124
|
+
<div class="form-row">
|
|
125
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
126
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="form-row">
|
|
130
|
+
<label for="node-input-complete"><i class="fa fa-dot-circle-o"></i> Output</label>
|
|
131
|
+
<input type="text" id="node-input-complete" style="width: 70%;">
|
|
132
|
+
<input type="hidden" id="node-input-targetType">
|
|
133
|
+
<span id="node-input-complete-full-label" style="display: none;">complete msg object</span>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<div class="form-row">
|
|
137
|
+
<label></label>
|
|
138
|
+
<input type="checkbox" id="node-input-tosidebar" checked>
|
|
139
|
+
<label for="node-input-tosidebar" style="width: auto;">Send to debug sidebar</label>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div class="form-row">
|
|
143
|
+
<label></label>
|
|
144
|
+
<input type="checkbox" id="node-input-console">
|
|
145
|
+
<label for="node-input-console" style="width: auto;">Also log to console</label>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div class="form-row">
|
|
149
|
+
<label></label>
|
|
150
|
+
<input type="checkbox" id="node-input-clean" checked>
|
|
151
|
+
<label for="node-input-clean" style="width: auto;">Clean heavy payloads (images/buffers)</label>
|
|
152
|
+
</div>
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<script type="text/x-red" data-help-name="clean-debug">
|
|
156
|
+
<p>An enhanced drop-in replacement for the core Debug node that filters out heavy binary/image payloads by default to keep the debug sidebar responsive.</p>
|
|
157
|
+
|
|
158
|
+
<h3>Details</h3>
|
|
159
|
+
<p>The Clean Debug node mirrors the behaviour of the standard Debug node while adding an optional cleaning step that replaces Buffers, typed arrays, data URLs and large Base64 strings with short placeholders.</p>
|
|
160
|
+
|
|
161
|
+
<h3>Properties</h3>
|
|
162
|
+
<dl class="message-properties">
|
|
163
|
+
<dt>Output<span class="property-type">typed input</span></dt>
|
|
164
|
+
<dd>Select the message property (or expression) to show in the debug sidebar. Choose <strong>complete msg object</strong> to inspect the whole message.</dd>
|
|
165
|
+
<dt>Send to debug sidebar<span class="property-type">boolean</span></dt>
|
|
166
|
+
<dd>Publish the result to the editor sidebar. Disable if you only want console/status output.</dd>
|
|
167
|
+
<dt>Also log to console<span class="property-type">boolean</span></dt>
|
|
168
|
+
<dd>Write the formatted output to the Node-RED runtime log.</dd>
|
|
169
|
+
<dt>Clean heavy payloads<span class="property-type">boolean</span></dt>
|
|
170
|
+
<dd>When enabled (default), large Buffers, Base64 strings and data URLs are replaced with concise placeholders so they do not flood the UI.</dd>
|
|
171
|
+
<dt>Enabled<span class="property-type">boolean</span></dt>
|
|
172
|
+
<dd>Temporarily disable the node without removing it from your flow.</dd>
|
|
173
|
+
</dl>
|
|
174
|
+
|
|
175
|
+
<h3>Notes</h3>
|
|
176
|
+
<ul>
|
|
177
|
+
<li>Disabling the clean option restores the exact behaviour of the built-in Debug node.</li>
|
|
178
|
+
<li>The cleaning step only affects what is displayed; the original message object is left untouched.</li>
|
|
179
|
+
</ul>
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<script type="text/javascript">
|
|
183
|
+
function sendCleanDebugToggle(node, desiredState, onSuccess, onError) {
|
|
184
|
+
$.ajax({
|
|
185
|
+
url: "clean-debug/" + node.id,
|
|
186
|
+
type: "POST",
|
|
187
|
+
data: JSON.stringify({ active: desiredState }),
|
|
188
|
+
contentType: "application/json; charset=utf-8",
|
|
189
|
+
success: function(resp) {
|
|
190
|
+
if (typeof onSuccess === "function") {
|
|
191
|
+
onSuccess(resp);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
error: function(jqXHR, textStatus, errorThrown) {
|
|
195
|
+
if (typeof onError === "function") {
|
|
196
|
+
onError(jqXHR, textStatus, errorThrown);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
</script>
|