@bonsae/nrg 0.21.0 → 0.21.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 +27 -19
- package/server/resources/nrg-client.js +2069 -2038
- package/test/client/component/setup.js +1 -1
- package/test/client/e2e/index.js +0 -11
- package/types/client.d.ts +6 -5
- package/types/server.d.ts +22 -21
- package/types/shims/client/types.d.ts +6 -5
- package/types/test-client-component.d.ts +6 -5
- package/types/test-client-unit.d.ts +6 -5
- package/vite/index.js +0 -11
package/package.json
CHANGED
package/server/index.cjs
CHANGED
|
@@ -573,19 +573,14 @@ var IONode = class extends Node {
|
|
|
573
573
|
this.#send = void 0;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
send(msg
|
|
576
|
+
send(msg) {
|
|
577
577
|
const sendsValue = this.baseOutputs <= 1;
|
|
578
|
-
const defaultMode = options?.defaultMode;
|
|
579
578
|
if (Array.isArray(msg) && !sendsValue) {
|
|
580
579
|
const slots = msg.slice(0, this.baseOutputs);
|
|
581
580
|
const out = slots.map((m, port) => {
|
|
582
581
|
if (m == null) return m;
|
|
583
582
|
this.#validatePort(m, port);
|
|
584
|
-
return this.#wrapOutgoing(
|
|
585
|
-
m,
|
|
586
|
-
this.#resolveContextMode(port, defaultMode),
|
|
587
|
-
port
|
|
588
|
-
);
|
|
583
|
+
return this.#wrapOutgoing(m, this.#resolveContextMode(port), port);
|
|
589
584
|
});
|
|
590
585
|
this.#deliver(out);
|
|
591
586
|
return;
|
|
@@ -595,9 +590,7 @@ var IONode = class extends Node {
|
|
|
595
590
|
return;
|
|
596
591
|
}
|
|
597
592
|
this.#validatePort(msg, 0);
|
|
598
|
-
this.#deliver(
|
|
599
|
-
this.#wrapOutgoing(msg, this.#resolveContextMode(0, defaultMode), 0)
|
|
600
|
-
);
|
|
593
|
+
this.#deliver(this.#wrapOutgoing(msg, this.#resolveContextMode(0), 0));
|
|
601
594
|
}
|
|
602
595
|
#deliver(out) {
|
|
603
596
|
if (this.#send) {
|
|
@@ -648,13 +641,12 @@ var IONode = class extends Node {
|
|
|
648
641
|
return "output";
|
|
649
642
|
}
|
|
650
643
|
/**
|
|
651
|
-
* Resolves the context mode for a base-output port
|
|
652
|
-
*
|
|
653
|
-
* `
|
|
644
|
+
* Resolves the context mode for a base-output port from the flow author's
|
|
645
|
+
* per-port config (`config.outputContextModes[port]`, written by the editor
|
|
646
|
+
* when the node declares `outputContextModes`), falling back to `"carry"`.
|
|
654
647
|
*/
|
|
655
|
-
#resolveContextMode(port
|
|
656
|
-
|
|
657
|
-
return configured ?? defaultMode ?? "carry";
|
|
648
|
+
#resolveContextMode(port) {
|
|
649
|
+
return this.config.outputContextModes?.[port] ?? "carry";
|
|
658
650
|
}
|
|
659
651
|
/**
|
|
660
652
|
* Merges a sent value into the incoming message at the returnProperty key so
|
|
@@ -694,14 +686,14 @@ var IONode = class extends Node {
|
|
|
694
686
|
* throw an error or call `this.error()` for the error port, and the complete
|
|
695
687
|
* port is sent automatically on successful input processing.
|
|
696
688
|
*/
|
|
697
|
-
sendToPort(port, msg
|
|
689
|
+
sendToPort(port, msg) {
|
|
698
690
|
if (port === "error" || port === "complete" || port === "status") {
|
|
699
691
|
throw new NrgError(
|
|
700
692
|
`sendToPort("${port}") is not allowed. Built-in ports are managed by the framework.`
|
|
701
693
|
);
|
|
702
694
|
}
|
|
703
695
|
const portIndex = typeof port === "number" ? port : this.#getNamedPortIndex(port);
|
|
704
|
-
const mode = this.#resolveContextMode(portIndex ?? 0
|
|
696
|
+
const mode = this.#resolveContextMode(portIndex ?? 0);
|
|
705
697
|
this.#sendToPort(
|
|
706
698
|
port,
|
|
707
699
|
msg == null ? msg : this.#wrapOutgoing(msg, mode, portIndex ?? 0)
|
|
@@ -1183,10 +1175,26 @@ function OutputReturnProperties(options) {
|
|
|
1183
1175
|
}
|
|
1184
1176
|
);
|
|
1185
1177
|
}
|
|
1178
|
+
function OutputContextModes(options) {
|
|
1179
|
+
return import_typebox2.Type.Record(
|
|
1180
|
+
import_typebox2.Type.Number(),
|
|
1181
|
+
import_typebox2.Type.Union([
|
|
1182
|
+
import_typebox2.Type.Literal("carry"),
|
|
1183
|
+
import_typebox2.Type.Literal("trace"),
|
|
1184
|
+
import_typebox2.Type.Literal("reset")
|
|
1185
|
+
]),
|
|
1186
|
+
{
|
|
1187
|
+
description: "Per-port context mode, keyed by output port index. A missing entry falls back to `carry`.",
|
|
1188
|
+
default: {},
|
|
1189
|
+
...options
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1186
1193
|
var SchemaType = Object.assign({}, import_typebox2.Type, {
|
|
1187
1194
|
NodeRef,
|
|
1188
1195
|
TypedInput: TypedInput2,
|
|
1189
|
-
OutputReturnProperties
|
|
1196
|
+
OutputReturnProperties,
|
|
1197
|
+
OutputContextModes
|
|
1190
1198
|
});
|
|
1191
1199
|
function markNonValidatable(schema) {
|
|
1192
1200
|
const type = schema.type;
|