@bonsae/nrg-runtime 0.38.0 → 0.38.1
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/index.cjs +22 -4
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -793,13 +793,14 @@ var import_node_async_hooks = require("node:async_hooks");
|
|
|
793
793
|
var RETURN_PROPERTY_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
794
794
|
var INPUT_KEY = "input";
|
|
795
795
|
var SOURCE_KEY = "source";
|
|
796
|
+
var MSGID_KEY = "_msgid";
|
|
796
797
|
var RESERVED_RETURN_PROPERTIES = /* @__PURE__ */ new Set([
|
|
797
798
|
SOURCE_KEY,
|
|
798
799
|
INPUT_KEY,
|
|
799
800
|
"error",
|
|
800
801
|
"complete",
|
|
801
802
|
"status",
|
|
802
|
-
|
|
803
|
+
MSGID_KEY
|
|
803
804
|
]);
|
|
804
805
|
var IONode = class _IONode extends Node {
|
|
805
806
|
static align;
|
|
@@ -1058,13 +1059,30 @@ var IONode = class _IONode extends Node {
|
|
|
1058
1059
|
const key = this.#returnPropertyKey(port);
|
|
1059
1060
|
const input = _IONode.#invocation.getStore()?.inputMsg ?? {};
|
|
1060
1061
|
const source = this.#outputSource(port);
|
|
1061
|
-
const frame = (msg) =>
|
|
1062
|
-
|
|
1062
|
+
const frame = (msg) => this.#withMsgid(
|
|
1063
|
+
Object.keys(msg).length ? { [key]: value, [SOURCE_KEY]: source, [INPUT_KEY]: msg } : { [key]: value, [SOURCE_KEY]: source }
|
|
1064
|
+
);
|
|
1065
|
+
if (mode === "reset")
|
|
1066
|
+
return this.#withMsgid({ [key]: value, [SOURCE_KEY]: source });
|
|
1063
1067
|
if (mode === "trace") return frame(input);
|
|
1064
1068
|
const lastOnly = { ...input };
|
|
1065
1069
|
delete lastOnly[INPUT_KEY];
|
|
1066
1070
|
return frame(lastOnly);
|
|
1067
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Preserve Node-RED's message-lineage id: a node's output inherits the
|
|
1074
|
+
* `_msgid` of the message it is processing (Node-RED assigns a fresh one only
|
|
1075
|
+
* when absent — see `Node.prototype.send`). Copying it onto every outgoing
|
|
1076
|
+
* message — in every context mode and on every port — stops the id forking at
|
|
1077
|
+
* each hop, which would otherwise break the message-flow debugger, Catch/
|
|
1078
|
+
* Complete grouping, and any `_msgid`-based correlation. Reads the current
|
|
1079
|
+
* invocation's input; a send outside any input() call (e.g. a source node)
|
|
1080
|
+
* has none, so nothing is stamped and Node-RED assigns one as usual.
|
|
1081
|
+
*/
|
|
1082
|
+
#withMsgid(frame) {
|
|
1083
|
+
const msgid = _IONode.#invocation.getStore()?.inputMsg?.[MSGID_KEY];
|
|
1084
|
+
return msgid !== void 0 ? { ...frame, [MSGID_KEY]: msgid } : frame;
|
|
1085
|
+
}
|
|
1068
1086
|
/**
|
|
1069
1087
|
* Provenance stamped on every data-port output under `msg.source`: the
|
|
1070
1088
|
* producing node plus the port the message was sent on (with the named-port
|
|
@@ -1147,7 +1165,7 @@ var IONode = class _IONode extends Node {
|
|
|
1147
1165
|
}
|
|
1148
1166
|
}
|
|
1149
1167
|
const out = new Array(this.#totalOutputs);
|
|
1150
|
-
out[portIndex] = msg;
|
|
1168
|
+
out[portIndex] = msg !== null && typeof msg === "object" ? this.#withMsgid(msg) : msg;
|
|
1151
1169
|
this.node.send(out);
|
|
1152
1170
|
}
|
|
1153
1171
|
/** The declared named output ports (from the injected `Output`-generic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonsae/nrg-runtime",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "The runtime for Node-RED nodes built with @bonsae/nrg — node base classes, schemas, AJV validator, and the editor client. Carries no build tooling.",
|
|
5
5
|
"author": "Allan Oricil <allanoricil@duck.com>",
|
|
6
6
|
"license": "MIT",
|