@bonsae/nrg 0.21.0 → 0.21.2
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 +39 -19
- package/server/resources/nrg-client.js +2361 -2332
- package/test/client/component/setup.js +1 -1
- package/test/client/e2e/index.js +3 -11
- package/types/client.d.ts +13 -5
- package/types/server.d.ts +30 -21
- package/types/shims/client/types.d.ts +13 -5
- package/types/test-client-component.d.ts +6 -5
- package/types/test-client-unit.d.ts +6 -5
- package/vite/index.js +3 -11
package/package.json
CHANGED
package/server/index.cjs
CHANGED
|
@@ -471,6 +471,18 @@ var IONode = class extends Node {
|
|
|
471
471
|
}
|
|
472
472
|
return keys.length;
|
|
473
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* The names of the base output ports when `outputsSchema` is a record of
|
|
476
|
+
* named ports (`{ success, failure }`), in declaration order — otherwise
|
|
477
|
+
* `undefined` (a single schema or a positional array). Resolved here, where
|
|
478
|
+
* TypeBox's `Kind` symbol is intact, so the editor reads the names directly
|
|
479
|
+
* instead of guessing them from a serialized (symbol-stripped) schema.
|
|
480
|
+
*/
|
|
481
|
+
static get outputPortNames() {
|
|
482
|
+
const s = this.outputsSchema;
|
|
483
|
+
if (!s || Array.isArray(s) || isSchemaLike(s)) return void 0;
|
|
484
|
+
return Object.keys(s);
|
|
485
|
+
}
|
|
474
486
|
#send;
|
|
475
487
|
/**
|
|
476
488
|
* Most recent input message — the spread base for output wrapping. Not
|
|
@@ -573,19 +585,14 @@ var IONode = class extends Node {
|
|
|
573
585
|
this.#send = void 0;
|
|
574
586
|
}
|
|
575
587
|
}
|
|
576
|
-
send(msg
|
|
588
|
+
send(msg) {
|
|
577
589
|
const sendsValue = this.baseOutputs <= 1;
|
|
578
|
-
const defaultMode = options?.defaultMode;
|
|
579
590
|
if (Array.isArray(msg) && !sendsValue) {
|
|
580
591
|
const slots = msg.slice(0, this.baseOutputs);
|
|
581
592
|
const out = slots.map((m, port) => {
|
|
582
593
|
if (m == null) return m;
|
|
583
594
|
this.#validatePort(m, port);
|
|
584
|
-
return this.#wrapOutgoing(
|
|
585
|
-
m,
|
|
586
|
-
this.#resolveContextMode(port, defaultMode),
|
|
587
|
-
port
|
|
588
|
-
);
|
|
595
|
+
return this.#wrapOutgoing(m, this.#resolveContextMode(port), port);
|
|
589
596
|
});
|
|
590
597
|
this.#deliver(out);
|
|
591
598
|
return;
|
|
@@ -595,9 +602,7 @@ var IONode = class extends Node {
|
|
|
595
602
|
return;
|
|
596
603
|
}
|
|
597
604
|
this.#validatePort(msg, 0);
|
|
598
|
-
this.#deliver(
|
|
599
|
-
this.#wrapOutgoing(msg, this.#resolveContextMode(0, defaultMode), 0)
|
|
600
|
-
);
|
|
605
|
+
this.#deliver(this.#wrapOutgoing(msg, this.#resolveContextMode(0), 0));
|
|
601
606
|
}
|
|
602
607
|
#deliver(out) {
|
|
603
608
|
if (this.#send) {
|
|
@@ -648,13 +653,12 @@ var IONode = class extends Node {
|
|
|
648
653
|
return "output";
|
|
649
654
|
}
|
|
650
655
|
/**
|
|
651
|
-
* Resolves the context mode for a base-output port
|
|
652
|
-
*
|
|
653
|
-
* `
|
|
656
|
+
* Resolves the context mode for a base-output port from the flow author's
|
|
657
|
+
* per-port config (`config.outputContextModes[port]`, written by the editor
|
|
658
|
+
* when the node declares `outputContextModes`), falling back to `"carry"`.
|
|
654
659
|
*/
|
|
655
|
-
#resolveContextMode(port
|
|
656
|
-
|
|
657
|
-
return configured ?? defaultMode ?? "carry";
|
|
660
|
+
#resolveContextMode(port) {
|
|
661
|
+
return this.config.outputContextModes?.[port] ?? "carry";
|
|
658
662
|
}
|
|
659
663
|
/**
|
|
660
664
|
* Merges a sent value into the incoming message at the returnProperty key so
|
|
@@ -694,14 +698,14 @@ var IONode = class extends Node {
|
|
|
694
698
|
* throw an error or call `this.error()` for the error port, and the complete
|
|
695
699
|
* port is sent automatically on successful input processing.
|
|
696
700
|
*/
|
|
697
|
-
sendToPort(port, msg
|
|
701
|
+
sendToPort(port, msg) {
|
|
698
702
|
if (port === "error" || port === "complete" || port === "status") {
|
|
699
703
|
throw new NrgError(
|
|
700
704
|
`sendToPort("${port}") is not allowed. Built-in ports are managed by the framework.`
|
|
701
705
|
);
|
|
702
706
|
}
|
|
703
707
|
const portIndex = typeof port === "number" ? port : this.#getNamedPortIndex(port);
|
|
704
|
-
const mode = this.#resolveContextMode(portIndex ?? 0
|
|
708
|
+
const mode = this.#resolveContextMode(portIndex ?? 0);
|
|
705
709
|
this.#sendToPort(
|
|
706
710
|
port,
|
|
707
711
|
msg == null ? msg : this.#wrapOutgoing(msg, mode, portIndex ?? 0)
|
|
@@ -1183,10 +1187,26 @@ function OutputReturnProperties(options) {
|
|
|
1183
1187
|
}
|
|
1184
1188
|
);
|
|
1185
1189
|
}
|
|
1190
|
+
function OutputContextModes(options) {
|
|
1191
|
+
return import_typebox2.Type.Record(
|
|
1192
|
+
import_typebox2.Type.Number(),
|
|
1193
|
+
import_typebox2.Type.Union([
|
|
1194
|
+
import_typebox2.Type.Literal("carry"),
|
|
1195
|
+
import_typebox2.Type.Literal("trace"),
|
|
1196
|
+
import_typebox2.Type.Literal("reset")
|
|
1197
|
+
]),
|
|
1198
|
+
{
|
|
1199
|
+
description: "Per-port context mode, keyed by output port index. A missing entry falls back to `carry`.",
|
|
1200
|
+
default: {},
|
|
1201
|
+
...options
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1186
1205
|
var SchemaType = Object.assign({}, import_typebox2.Type, {
|
|
1187
1206
|
NodeRef,
|
|
1188
1207
|
TypedInput: TypedInput2,
|
|
1189
|
-
OutputReturnProperties
|
|
1208
|
+
OutputReturnProperties,
|
|
1209
|
+
OutputContextModes
|
|
1190
1210
|
});
|
|
1191
1211
|
function markNonValidatable(schema) {
|
|
1192
1212
|
const type = schema.type;
|