@bonsae/nrg-runtime 0.22.2 → 0.24.0
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 +12 -19
- package/types/server.d.ts +4 -4
package/package.json
CHANGED
package/server/index.cjs
CHANGED
|
@@ -578,9 +578,10 @@ var IONode = class extends Node {
|
|
|
578
578
|
try {
|
|
579
579
|
nodeRedNode.log("Calling input");
|
|
580
580
|
this.#currentInputMsg = msg;
|
|
581
|
-
await
|
|
581
|
+
const result = await this.#input(msg, send);
|
|
582
582
|
this.#sendToPort("complete", {
|
|
583
583
|
...msg,
|
|
584
|
+
...result !== void 0 ? { output: result } : {},
|
|
584
585
|
complete: {
|
|
585
586
|
source: this.#nodeSource()
|
|
586
587
|
},
|
|
@@ -616,6 +617,7 @@ var IONode = class extends Node {
|
|
|
616
617
|
);
|
|
617
618
|
}
|
|
618
619
|
input(msg) {
|
|
620
|
+
return void 0;
|
|
619
621
|
}
|
|
620
622
|
async #input(msg, send) {
|
|
621
623
|
const NodeClass = this.constructor;
|
|
@@ -630,29 +632,20 @@ var IONode = class extends Node {
|
|
|
630
632
|
}
|
|
631
633
|
this.#send = send;
|
|
632
634
|
try {
|
|
633
|
-
await Promise.resolve(this.input(msg));
|
|
635
|
+
return await Promise.resolve(this.input(msg));
|
|
634
636
|
} finally {
|
|
635
637
|
this.#send = void 0;
|
|
636
638
|
}
|
|
637
639
|
}
|
|
638
640
|
send(msg) {
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
this.#deliver(out);
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
if (msg == null) {
|
|
651
|
-
this.#deliver(msg);
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
this.#validatePort(msg, 0);
|
|
655
|
-
this.#deliver(this.#wrapOutgoing(msg, this.#resolveContextMode(0), 0));
|
|
641
|
+
const multi = this.baseOutputs > 1 && Array.isArray(msg);
|
|
642
|
+
const values = multi ? msg.slice(0, this.baseOutputs) : [msg];
|
|
643
|
+
const out = values.map((m, port) => {
|
|
644
|
+
if (m == null) return m;
|
|
645
|
+
this.#validatePort(m, port);
|
|
646
|
+
return this.#wrapOutgoing(m, this.#resolveContextMode(port), port);
|
|
647
|
+
});
|
|
648
|
+
this.#deliver(out);
|
|
656
649
|
}
|
|
657
650
|
#deliver(out) {
|
|
658
651
|
if (this.#send) {
|
package/types/server.d.ts
CHANGED
|
@@ -727,7 +727,7 @@ export declare abstract class IONode<TConfig = any, TCredentials = any, TInput =
|
|
|
727
727
|
protected readonly context: IONodeContext;
|
|
728
728
|
constructor(RED: RED, node: NodeRedNode, config: IONodeConfig<TConfig>, credentials: IONodeCredentials<TCredentials>);
|
|
729
729
|
[WIRE_HANDLERS](nodeRedNode: NodeRedNode, createdPromise: Promise<void>): void;
|
|
730
|
-
input(msg: TInput):
|
|
730
|
+
input(msg: TInput): unknown;
|
|
731
731
|
send(msg: TOutput): void;
|
|
732
732
|
get baseOutputs(): number;
|
|
733
733
|
get totalOutputs(): number;
|
|
@@ -787,7 +787,7 @@ export interface IIONode<TConfig = any, TCredentials = any, TInput = any, TOutpu
|
|
|
787
787
|
readonly y: number;
|
|
788
788
|
readonly g: string | undefined;
|
|
789
789
|
readonly wires: string[][];
|
|
790
|
-
input(msg: TInput):
|
|
790
|
+
input(msg: TInput): unknown;
|
|
791
791
|
send(msg: TOutput): void;
|
|
792
792
|
status(status: IONodeStatus): void;
|
|
793
793
|
updateWires(wires: string[][]): void;
|
|
@@ -811,7 +811,7 @@ interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined
|
|
|
811
811
|
registered?(RED: RED): void | Promise<void>;
|
|
812
812
|
created?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): void | Promise<void>;
|
|
813
813
|
closed?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, removed?: boolean): void | Promise<void>;
|
|
814
|
-
input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>):
|
|
814
|
+
input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>): unknown;
|
|
815
815
|
}
|
|
816
816
|
/**
|
|
817
817
|
* Base class for configuration nodes that are shared across multiple nodes
|
|
@@ -899,7 +899,7 @@ export declare function registerTypes(nodes: NodeConstructor[]): RegistrationFun
|
|
|
899
899
|
* });
|
|
900
900
|
* ```
|
|
901
901
|
*/
|
|
902
|
-
export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | Record<string, TSchema> | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeConstructor<IIONode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
|
|
902
|
+
export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, const TOutputsSchema extends TSchema | readonly TSchema[] | Record<string, TSchema> | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeConstructor<IIONode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
|
|
903
903
|
/**
|
|
904
904
|
* Creates a config node class from a definition object.
|
|
905
905
|
*
|