@bonsae/nrg-runtime 0.25.0 → 0.26.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 +3 -23
- package/server/index.cjs +52 -42
- package/server/resources/nrg-client.js +6 -6
- package/internal/README.md +0 -30
- package/internal/client/components.mjs +0 -1287
- package/internal/client/index.mjs +0 -229
- package/internal/server/index.cjs +0 -298
- package/types/client.d.ts +0 -266
- package/types/internal/client/components.d.ts +0 -9
- package/types/internal/client/index.d.ts +0 -9
- package/types/internal/server/index.d.ts +0 -422
- package/types/server.d.ts +0 -941
- package/types/shims/brands.d.ts +0 -32
- package/types/shims/client/form/components/node-red-config-input.vue.d.ts +0 -125
- package/types/shims/client/form/components/node-red-editor-input.vue.d.ts +0 -124
- package/types/shims/client/form/components/node-red-input-label.vue.d.ts +0 -34
- package/types/shims/client/form/components/node-red-input.vue.d.ts +0 -123
- package/types/shims/client/form/components/node-red-json-schema-form.vue.d.ts +0 -772
- package/types/shims/client/form/components/node-red-select-input.vue.d.ts +0 -132
- package/types/shims/client/form/components/node-red-toggle.vue.d.ts +0 -36
- package/types/shims/client/form/components/node-red-typed-input.vue.d.ts +0 -151
- package/types/shims/client/globals.d.ts +0 -320
- package/types/shims/client/types.d.ts +0 -227
- package/types/shims/components.d.ts +0 -23
- package/types/shims/constants.d.ts +0 -4
- package/types/shims/schema-options.d.ts +0 -24
- package/types/shims/shims-vue.d.ts +0 -5
- package/types/shims/typebox.d.ts +0 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonsae/nrg-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.26.0",
|
|
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",
|
|
7
7
|
"type": "commonjs",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"url": "git+https://github.com/bonsaedev/nrg.git",
|
|
14
|
-
"type": "git"
|
|
15
|
-
"directory": "packages/runtime"
|
|
14
|
+
"type": "git"
|
|
16
15
|
},
|
|
17
16
|
"publishConfig": {
|
|
18
17
|
"access": "public"
|
|
@@ -34,27 +33,8 @@
|
|
|
34
33
|
],
|
|
35
34
|
"exports": {
|
|
36
35
|
"./server": {
|
|
37
|
-
"types": "./types/server.d.ts",
|
|
38
36
|
"require": "./server/index.cjs",
|
|
39
37
|
"default": "./server/index.cjs"
|
|
40
|
-
},
|
|
41
|
-
"./client": {
|
|
42
|
-
"types": "./types/client.d.ts"
|
|
43
|
-
},
|
|
44
|
-
"./internal/server": {
|
|
45
|
-
"types": "./types/internal/server/index.d.ts",
|
|
46
|
-
"require": "./internal/server/index.cjs",
|
|
47
|
-
"default": "./internal/server/index.cjs"
|
|
48
|
-
},
|
|
49
|
-
"./internal/client": {
|
|
50
|
-
"types": "./types/internal/client/index.d.ts",
|
|
51
|
-
"import": "./internal/client/index.mjs",
|
|
52
|
-
"default": "./internal/client/index.mjs"
|
|
53
|
-
},
|
|
54
|
-
"./internal/client/components": {
|
|
55
|
-
"types": "./types/internal/client/components.d.ts",
|
|
56
|
-
"import": "./internal/client/components.mjs",
|
|
57
|
-
"default": "./internal/client/components.mjs"
|
|
58
38
|
}
|
|
59
39
|
},
|
|
60
40
|
"dependencies": {
|
package/server/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/server/index.ts
|
|
30
|
+
// src/core/server/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
CompletePortSchema: () => CompletePortSchema,
|
|
@@ -48,7 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(index_exports);
|
|
50
50
|
|
|
51
|
-
// src/errors.ts
|
|
51
|
+
// src/core/errors.ts
|
|
52
52
|
var NrgError = class _NrgError extends Error {
|
|
53
53
|
constructor(message) {
|
|
54
54
|
super(message);
|
|
@@ -57,7 +57,7 @@ var NrgError = class _NrgError extends Error {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
// src/server/typed-input.ts
|
|
60
|
+
// src/core/server/typed-input.ts
|
|
61
61
|
var TypedInput = class {
|
|
62
62
|
constructor(RED, node, input) {
|
|
63
63
|
this.RED = RED;
|
|
@@ -99,7 +99,7 @@ var TypedInput = class {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
// src/server/nodes/proxy.ts
|
|
102
|
+
// src/core/server/nodes/proxy.ts
|
|
103
103
|
function setupConfigProxy(opts) {
|
|
104
104
|
const { RED, node, config, schema } = opts;
|
|
105
105
|
const SKIP_PROPS = /* @__PURE__ */ new Set(["id", "_id", "_users"]);
|
|
@@ -156,7 +156,7 @@ function setupConfigProxy(opts) {
|
|
|
156
156
|
return createProxy(config);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
// src/server/utils.ts
|
|
159
|
+
// src/core/server/utils.ts
|
|
160
160
|
function getCredentialsFromSchema(schema) {
|
|
161
161
|
const result = {};
|
|
162
162
|
for (const [key, value] of Object.entries(schema.properties)) {
|
|
@@ -171,10 +171,10 @@ function getCredentialsFromSchema(schema) {
|
|
|
171
171
|
return result;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// src/server/nodes/symbols.ts
|
|
174
|
+
// src/core/server/nodes/symbols.ts
|
|
175
175
|
var WIRE_HANDLERS = Symbol.for("nrg.wireHandlers");
|
|
176
176
|
|
|
177
|
-
// src/server/nodes/node.ts
|
|
177
|
+
// src/core/server/nodes/node.ts
|
|
178
178
|
var cachedSettingsMap = /* @__PURE__ */ new WeakMap();
|
|
179
179
|
var Node = class _Node {
|
|
180
180
|
static type;
|
|
@@ -408,10 +408,10 @@ var Node = class _Node {
|
|
|
408
408
|
}
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
-
// src/server/nodes/io-node.ts
|
|
411
|
+
// src/core/server/nodes/io-node.ts
|
|
412
412
|
var import_typebox = require("@sinclair/typebox");
|
|
413
413
|
|
|
414
|
-
// src/server/nodes/context.ts
|
|
414
|
+
// src/core/server/nodes/context.ts
|
|
415
415
|
var updateLocks = /* @__PURE__ */ new WeakMap();
|
|
416
416
|
function setupContext(context, store) {
|
|
417
417
|
const get = (key) => new Promise(
|
|
@@ -482,13 +482,14 @@ function setupContext(context, store) {
|
|
|
482
482
|
return { get, set, keys, update, increment };
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
// src/server/nodes/io-node.ts
|
|
485
|
+
// src/core/server/nodes/io-node.ts
|
|
486
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
486
487
|
function isSchemaLike(obj) {
|
|
487
488
|
return obj != null && typeof obj === "object" && import_typebox.Kind in obj;
|
|
488
489
|
}
|
|
489
490
|
var RETURN_PROPERTY_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
490
491
|
var INPUT_KEY = "input";
|
|
491
|
-
var IONode = class extends Node {
|
|
492
|
+
var IONode = class _IONode extends Node {
|
|
492
493
|
static align;
|
|
493
494
|
static color;
|
|
494
495
|
static inputSchema;
|
|
@@ -532,13 +533,20 @@ var IONode = class extends Node {
|
|
|
532
533
|
if (!s || Array.isArray(s) || isSchemaLike(s)) return void 0;
|
|
533
534
|
return Object.keys(s);
|
|
534
535
|
}
|
|
535
|
-
#send;
|
|
536
536
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
537
|
+
* Per-`input()`-invocation context, scoped via AsyncLocalStorage. One store
|
|
538
|
+
* per class, shared by every instance: each `.run()` isolates one input()
|
|
539
|
+
* call (and everything it `await`s, including detached `.then`/timer
|
|
540
|
+
* continuations it schedules) into its own session, so concurrent inputs on a
|
|
541
|
+
* node never clobber each other's context and a deferred send keeps the
|
|
542
|
+
* context of the input that scheduled it. Real Node-RED never awaits an async
|
|
543
|
+
* input handler before delivering the next message, so two inputs can be in
|
|
544
|
+
* flight at once. `getStore()` is `undefined` only for a send made entirely
|
|
545
|
+
* outside any `input()` (e.g. a timer set up in `created()`): it carries no
|
|
546
|
+
* inherited context and delivers via `node.send`. Server-only — this is part
|
|
547
|
+
* of the node runtime and is never imported in a browser.
|
|
540
548
|
*/
|
|
541
|
-
#
|
|
549
|
+
static #invocation = new import_node_async_hooks.AsyncLocalStorage();
|
|
542
550
|
context;
|
|
543
551
|
constructor(RED, node, config, credentials) {
|
|
544
552
|
super(RED, node, config, credentials);
|
|
@@ -577,7 +585,6 @@ var IONode = class extends Node {
|
|
|
577
585
|
}
|
|
578
586
|
try {
|
|
579
587
|
nodeRedNode.log("Calling input");
|
|
580
|
-
this.#currentInputMsg = msg;
|
|
581
588
|
const result = await this.#input(msg, send);
|
|
582
589
|
this.#sendToPort("complete", {
|
|
583
590
|
...msg,
|
|
@@ -633,12 +640,10 @@ var IONode = class extends Node {
|
|
|
633
640
|
});
|
|
634
641
|
this.log("Input is valid");
|
|
635
642
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
this.#send = void 0;
|
|
641
|
-
}
|
|
643
|
+
return await _IONode.#invocation.run(
|
|
644
|
+
{ inputMsg: msg, send },
|
|
645
|
+
() => Promise.resolve(this.input(msg))
|
|
646
|
+
);
|
|
642
647
|
}
|
|
643
648
|
send(msg) {
|
|
644
649
|
const multi = this.baseOutputs > 1 && Array.isArray(msg);
|
|
@@ -651,8 +656,9 @@ var IONode = class extends Node {
|
|
|
651
656
|
this.#deliver(out);
|
|
652
657
|
}
|
|
653
658
|
#deliver(out) {
|
|
654
|
-
|
|
655
|
-
|
|
659
|
+
const send = _IONode.#invocation.getStore()?.send;
|
|
660
|
+
if (send) {
|
|
661
|
+
send(out);
|
|
656
662
|
} else {
|
|
657
663
|
this.node.send(out);
|
|
658
664
|
}
|
|
@@ -713,7 +719,7 @@ var IONode = class extends Node {
|
|
|
713
719
|
*/
|
|
714
720
|
#wrapOutgoing(value, mode, port) {
|
|
715
721
|
const key = this.#returnPropertyKey(port);
|
|
716
|
-
const input =
|
|
722
|
+
const input = _IONode.#invocation.getStore()?.inputMsg ?? {};
|
|
717
723
|
if (mode === "reset") {
|
|
718
724
|
return { [key]: value };
|
|
719
725
|
}
|
|
@@ -839,7 +845,7 @@ var IONode = class extends Node {
|
|
|
839
845
|
}
|
|
840
846
|
};
|
|
841
847
|
|
|
842
|
-
// src/server/nodes/config-node.ts
|
|
848
|
+
// src/core/server/nodes/config-node.ts
|
|
843
849
|
var ConfigNode = class extends Node {
|
|
844
850
|
static category = "config";
|
|
845
851
|
context;
|
|
@@ -871,7 +877,7 @@ var ConfigNode = class extends Node {
|
|
|
871
877
|
}
|
|
872
878
|
};
|
|
873
879
|
|
|
874
|
-
// src/server/nodes/factories.ts
|
|
880
|
+
// src/core/server/nodes/factories.ts
|
|
875
881
|
function defineIONode(def) {
|
|
876
882
|
const NodeClass = class extends IONode {
|
|
877
883
|
static type = def.type;
|
|
@@ -933,10 +939,10 @@ function defineConfigNode(def) {
|
|
|
933
939
|
return NodeClass;
|
|
934
940
|
}
|
|
935
941
|
|
|
936
|
-
// src/validator.ts
|
|
937
|
-
var import_ajv = __toESM(require("ajv"));
|
|
938
|
-
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
939
|
-
var import_ajv_errors = __toESM(require("ajv-errors"));
|
|
942
|
+
// src/core/validator.ts
|
|
943
|
+
var import_ajv = __toESM(require("ajv"), 1);
|
|
944
|
+
var import_ajv_formats = __toESM(require("ajv-formats"), 1);
|
|
945
|
+
var import_ajv_errors = __toESM(require("ajv-errors"), 1);
|
|
940
946
|
var Validator = class {
|
|
941
947
|
ajv;
|
|
942
948
|
constructor(options) {
|
|
@@ -1073,7 +1079,7 @@ var ValidationError = class _ValidationError extends Error {
|
|
|
1073
1079
|
}
|
|
1074
1080
|
};
|
|
1075
1081
|
|
|
1076
|
-
// src/server/validation.ts
|
|
1082
|
+
// src/core/server/validation.ts
|
|
1077
1083
|
function initValidator(RED) {
|
|
1078
1084
|
if (RED.validator) return;
|
|
1079
1085
|
const nrg = {
|
|
@@ -1114,9 +1120,9 @@ function initValidator(RED) {
|
|
|
1114
1120
|
});
|
|
1115
1121
|
}
|
|
1116
1122
|
|
|
1117
|
-
// src/server/api/assets.ts
|
|
1118
|
-
var import_path = __toESM(require("path"));
|
|
1119
|
-
var import_fs = __toESM(require("fs"));
|
|
1123
|
+
// src/core/server/api/assets.ts
|
|
1124
|
+
var import_path = __toESM(require("path"), 1);
|
|
1125
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
1120
1126
|
var import_module = require("module");
|
|
1121
1127
|
function serveFile(filePath) {
|
|
1122
1128
|
return (_req, res, next) => {
|
|
@@ -1138,7 +1144,7 @@ function initAssetsRoutes(router) {
|
|
|
1138
1144
|
router.get("/nrg/assets/vue.esm-browser.js", serveFile(vueFile));
|
|
1139
1145
|
}
|
|
1140
1146
|
|
|
1141
|
-
// src/server/api/routes.ts
|
|
1147
|
+
// src/core/server/api/routes.ts
|
|
1142
1148
|
var _initialized = false;
|
|
1143
1149
|
function initRoutes(RED) {
|
|
1144
1150
|
if (_initialized) return;
|
|
@@ -1146,7 +1152,7 @@ function initRoutes(RED) {
|
|
|
1146
1152
|
initAssetsRoutes(RED.httpAdmin);
|
|
1147
1153
|
}
|
|
1148
1154
|
|
|
1149
|
-
// src/server/registration.ts
|
|
1155
|
+
// src/core/server/registration.ts
|
|
1150
1156
|
async function registerType(RED, NodeClass) {
|
|
1151
1157
|
RED.log.debug(`Registering Type: ${NodeClass.type}`);
|
|
1152
1158
|
if (!(NodeClass.prototype instanceof Node)) {
|
|
@@ -1181,7 +1187,7 @@ function registerTypes(nodes) {
|
|
|
1181
1187
|
return fn;
|
|
1182
1188
|
}
|
|
1183
1189
|
|
|
1184
|
-
// src/constants.ts
|
|
1190
|
+
// src/core/constants.ts
|
|
1185
1191
|
var TYPED_INPUT_TYPES = [
|
|
1186
1192
|
"msg",
|
|
1187
1193
|
"flow",
|
|
@@ -1199,7 +1205,7 @@ var TYPED_INPUT_TYPES = [
|
|
|
1199
1205
|
"cred"
|
|
1200
1206
|
];
|
|
1201
1207
|
|
|
1202
|
-
// src/server/schemas/type.ts
|
|
1208
|
+
// src/core/server/schemas/type.ts
|
|
1203
1209
|
var import_typebox2 = require("@sinclair/typebox");
|
|
1204
1210
|
var import_rules = require("ajv/dist/compile/rules");
|
|
1205
1211
|
function NodeRef(nodeClass, options) {
|
|
@@ -1221,6 +1227,9 @@ function TypedInput2(options) {
|
|
|
1221
1227
|
[import_typebox2.Kind]: "TypedInput"
|
|
1222
1228
|
};
|
|
1223
1229
|
}
|
|
1230
|
+
function NrgString(options) {
|
|
1231
|
+
return import_typebox2.Type.String(options);
|
|
1232
|
+
}
|
|
1224
1233
|
function OutputReturnProperties(options) {
|
|
1225
1234
|
return import_typebox2.Type.Record(
|
|
1226
1235
|
import_typebox2.Type.Number(),
|
|
@@ -1248,6 +1257,7 @@ function OutputContextModes(options) {
|
|
|
1248
1257
|
);
|
|
1249
1258
|
}
|
|
1250
1259
|
var SchemaType = Object.assign({}, import_typebox2.Type, {
|
|
1260
|
+
String: NrgString,
|
|
1251
1261
|
NodeRef,
|
|
1252
1262
|
TypedInput: TypedInput2,
|
|
1253
1263
|
OutputReturnProperties,
|
|
@@ -1288,7 +1298,7 @@ function defineSchema(properties, options) {
|
|
|
1288
1298
|
return markNonValidatable(schema);
|
|
1289
1299
|
}
|
|
1290
1300
|
|
|
1291
|
-
// src/server/schemas/base.ts
|
|
1301
|
+
// src/core/server/schemas/base.ts
|
|
1292
1302
|
var NodeConfigSchema = SchemaType.Object({
|
|
1293
1303
|
id: SchemaType.String(),
|
|
1294
1304
|
type: SchemaType.String(),
|
|
@@ -1379,7 +1389,7 @@ var StatusPortSchema = SchemaType.Object({
|
|
|
1379
1389
|
source: NodeSourceSchema
|
|
1380
1390
|
});
|
|
1381
1391
|
|
|
1382
|
-
// src/server/index.ts
|
|
1392
|
+
// src/core/server/index.ts
|
|
1383
1393
|
function defineModule(definition) {
|
|
1384
1394
|
return definition;
|
|
1385
1395
|
}
|