@bonsae/nrg-runtime 0.25.0 → 0.25.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/package.json +1 -1
- package/server/index.cjs +10 -17
package/package.json
CHANGED
package/server/index.cjs
CHANGED
|
@@ -483,6 +483,8 @@ function setupContext(context, store) {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
// src/server/nodes/io-node.ts
|
|
486
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
487
|
+
var inputInvocation = new import_node_async_hooks.AsyncLocalStorage();
|
|
486
488
|
function isSchemaLike(obj) {
|
|
487
489
|
return obj != null && typeof obj === "object" && import_typebox.Kind in obj;
|
|
488
490
|
}
|
|
@@ -532,13 +534,6 @@ var IONode = class extends Node {
|
|
|
532
534
|
if (!s || Array.isArray(s) || isSchemaLike(s)) return void 0;
|
|
533
535
|
return Object.keys(s);
|
|
534
536
|
}
|
|
535
|
-
#send;
|
|
536
|
-
/**
|
|
537
|
-
* Most recent input message — the spread base for output wrapping. Not
|
|
538
|
-
* cleared after input() so late async sends merge with the last received
|
|
539
|
-
* message.
|
|
540
|
-
*/
|
|
541
|
-
#currentInputMsg;
|
|
542
537
|
context;
|
|
543
538
|
constructor(RED, node, config, credentials) {
|
|
544
539
|
super(RED, node, config, credentials);
|
|
@@ -577,7 +572,6 @@ var IONode = class extends Node {
|
|
|
577
572
|
}
|
|
578
573
|
try {
|
|
579
574
|
nodeRedNode.log("Calling input");
|
|
580
|
-
this.#currentInputMsg = msg;
|
|
581
575
|
const result = await this.#input(msg, send);
|
|
582
576
|
this.#sendToPort("complete", {
|
|
583
577
|
...msg,
|
|
@@ -633,12 +627,10 @@ var IONode = class extends Node {
|
|
|
633
627
|
});
|
|
634
628
|
this.log("Input is valid");
|
|
635
629
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
this.#send = void 0;
|
|
641
|
-
}
|
|
630
|
+
return await inputInvocation.run(
|
|
631
|
+
{ inputMsg: msg, send },
|
|
632
|
+
() => Promise.resolve(this.input(msg))
|
|
633
|
+
);
|
|
642
634
|
}
|
|
643
635
|
send(msg) {
|
|
644
636
|
const multi = this.baseOutputs > 1 && Array.isArray(msg);
|
|
@@ -651,8 +643,9 @@ var IONode = class extends Node {
|
|
|
651
643
|
this.#deliver(out);
|
|
652
644
|
}
|
|
653
645
|
#deliver(out) {
|
|
654
|
-
|
|
655
|
-
|
|
646
|
+
const send = inputInvocation.getStore()?.send;
|
|
647
|
+
if (send) {
|
|
648
|
+
send(out);
|
|
656
649
|
} else {
|
|
657
650
|
this.node.send(out);
|
|
658
651
|
}
|
|
@@ -713,7 +706,7 @@ var IONode = class extends Node {
|
|
|
713
706
|
*/
|
|
714
707
|
#wrapOutgoing(value, mode, port) {
|
|
715
708
|
const key = this.#returnPropertyKey(port);
|
|
716
|
-
const input =
|
|
709
|
+
const input = inputInvocation.getStore()?.inputMsg ?? {};
|
|
717
710
|
if (mode === "reset") {
|
|
718
711
|
return { [key]: value };
|
|
719
712
|
}
|