@bonsae/nrg 0.5.3 → 0.5.4
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/build/server/resources/nrg-client.js +344 -344
- package/build/vite/index.js +3 -1
- package/package.json +7 -1
- package/src/core/client/app.vue +1 -1
- package/src/core/client/components/node-red-json-schema-form.vue +2 -1
- package/src/core/client/components/node-red-typed-input.vue +6 -0
- package/src/core/client/index.ts +17 -25
- package/src/vite/client/build.ts +3 -1
package/build/vite/index.js
CHANGED
|
@@ -1594,7 +1594,9 @@ async function build2(clientBuildOptions, buildContext) {
|
|
|
1594
1594
|
throw new BuildError("client", error);
|
|
1595
1595
|
} finally {
|
|
1596
1596
|
if (generatedEntry) {
|
|
1597
|
-
fs10.
|
|
1597
|
+
if (fs10.existsSync(entryPath)) {
|
|
1598
|
+
fs10.unlinkSync(entryPath);
|
|
1599
|
+
}
|
|
1598
1600
|
}
|
|
1599
1601
|
}
|
|
1600
1602
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonsae/nrg",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "NRG framework — build Node-RED nodes with Vue 3, TypeScript, and JSON Schema",
|
|
5
5
|
"author": "Allan Oricil <allanoricil@duck.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"pnpm": ">=10.11.0"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
+
"test": "vitest run && vitest run --config vitest.e2e.config.ts",
|
|
21
|
+
"test:unit": "vitest run",
|
|
22
|
+
"test:unit:watch": "vitest",
|
|
23
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
20
24
|
"build": "node build.mjs",
|
|
21
25
|
"typecheck": "tsc -p src/core/server/tsconfig.json --noEmit && tsc -p src/core/client/tsconfig.json --noEmit",
|
|
22
26
|
"lint": "eslint src/",
|
|
@@ -103,6 +107,7 @@
|
|
|
103
107
|
"@types/node": "^22.15.18",
|
|
104
108
|
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
105
109
|
"@typescript-eslint/parser": "^8.32.1",
|
|
110
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
106
111
|
"eslint": "^9.27.0",
|
|
107
112
|
"eslint-config-prettier": "^10.1.8",
|
|
108
113
|
"eslint-plugin-vue": "^10.1.0",
|
|
@@ -113,6 +118,7 @@
|
|
|
113
118
|
"semantic-release": "^24.2.4",
|
|
114
119
|
"typescript-eslint": "^8.32.1",
|
|
115
120
|
"vite": "^6.3.4",
|
|
121
|
+
"vitest": "^4.1.5",
|
|
116
122
|
"vue": "^3.5.14"
|
|
117
123
|
}
|
|
118
124
|
}
|
package/src/core/client/app.vue
CHANGED
|
@@ -136,6 +136,12 @@ export default defineComponent({
|
|
|
136
136
|
this.onChange();
|
|
137
137
|
});
|
|
138
138
|
},
|
|
139
|
+
beforeUnmount() {
|
|
140
|
+
if (this._observer) {
|
|
141
|
+
this._observer.disconnect();
|
|
142
|
+
this._observer = null;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
139
145
|
methods: {
|
|
140
146
|
onChange() {
|
|
141
147
|
const newValue = this.$input.typedInput("value");
|
package/src/core/client/index.ts
CHANGED
|
@@ -203,7 +203,7 @@ function getNodeState(node: Node): NodeState {
|
|
|
203
203
|
const state: NodeState = {
|
|
204
204
|
credentials: {},
|
|
205
205
|
};
|
|
206
|
-
Object.keys(node._def.defaults).forEach((prop) => {
|
|
206
|
+
Object.keys(node._def.defaults ?? {}).forEach((prop) => {
|
|
207
207
|
state[prop] = node[prop];
|
|
208
208
|
});
|
|
209
209
|
if (node._def.credentials) {
|
|
@@ -300,8 +300,6 @@ function defineNode<T extends NodeDefinition>(options: T): T {
|
|
|
300
300
|
async function registerType(definition: NodeDefinition): Promise<void> {
|
|
301
301
|
const { type } = definition;
|
|
302
302
|
try {
|
|
303
|
-
console.log(`Registering node type: ${type}`);
|
|
304
|
-
|
|
305
303
|
const nodeDefinition = {
|
|
306
304
|
...(_schemas[type] ?? {}),
|
|
307
305
|
...definition,
|
|
@@ -311,9 +309,6 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
311
309
|
const defaults = nodeDefinition.defaults ?? undefined;
|
|
312
310
|
const credentials = nodeDefinition.credentials ?? undefined;
|
|
313
311
|
|
|
314
|
-
console.log("defaults", defaults);
|
|
315
|
-
console.log("credentials", credentials);
|
|
316
|
-
|
|
317
312
|
const appContainerId = `nrg-app-${type}`;
|
|
318
313
|
|
|
319
314
|
$("<script>", {
|
|
@@ -323,21 +318,20 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
323
318
|
}).appendTo("body");
|
|
324
319
|
|
|
325
320
|
function oneditprepare(this: Node) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
321
|
+
const validationSchema =
|
|
322
|
+
nodeDefinition.configSchema &&
|
|
323
|
+
nodeDefinition.credentialsSchema?.properties
|
|
324
|
+
? {
|
|
325
|
+
...nodeDefinition.configSchema,
|
|
326
|
+
properties: {
|
|
327
|
+
...nodeDefinition.configSchema.properties,
|
|
328
|
+
credentials: {
|
|
329
|
+
type: "object",
|
|
330
|
+
properties: nodeDefinition.credentialsSchema.properties,
|
|
331
|
+
},
|
|
337
332
|
},
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
: nodeDefinition.configSchema;
|
|
333
|
+
}
|
|
334
|
+
: nodeDefinition.configSchema;
|
|
341
335
|
|
|
342
336
|
const form =
|
|
343
337
|
definition.form ??
|
|
@@ -360,7 +354,7 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
360
354
|
const changed = !!Object.keys(changes)?.length;
|
|
361
355
|
if (!changed) return false;
|
|
362
356
|
|
|
363
|
-
Object.keys(node._def.defaults).forEach((prop) => {
|
|
357
|
+
Object.keys(node._def.defaults ?? {}).forEach((prop) => {
|
|
364
358
|
if (!node._def.defaults?.[prop]?.type) return;
|
|
365
359
|
const oldConfigNodeId: string = node[prop] as string;
|
|
366
360
|
const newConfigNodeId: string = node._newState![prop] as string;
|
|
@@ -376,7 +370,7 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
376
370
|
}
|
|
377
371
|
});
|
|
378
372
|
|
|
379
|
-
Object.keys(node._def.defaults).forEach((prop) => {
|
|
373
|
+
Object.keys(node._def.defaults ?? {}).forEach((prop) => {
|
|
380
374
|
if (!node._def.defaults?.[prop]?.type) return;
|
|
381
375
|
const newConfigNodeId: string = node._newState![prop] as string;
|
|
382
376
|
if (!newConfigNodeId) return;
|
|
@@ -400,7 +394,7 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
400
394
|
// overwriting the correctly-typed values already set by merge() above.
|
|
401
395
|
const isConfigNode = definition.category === "config";
|
|
402
396
|
if (isConfigNode) {
|
|
403
|
-
Object.keys(node._def.defaults).forEach((prop) => {
|
|
397
|
+
Object.keys(node._def.defaults ?? {}).forEach((prop) => {
|
|
404
398
|
if (node._def.defaults[prop].type) return; // config-node refs handled separately
|
|
405
399
|
const inputId = `node-config-input-${prop}`;
|
|
406
400
|
let input = $(`#${inputId}`);
|
|
@@ -484,9 +478,7 @@ async function registerType(definition: NodeDefinition): Promise<void> {
|
|
|
484
478
|
*/
|
|
485
479
|
async function registerTypes(nodes: NodeDefinition[]): Promise<void> {
|
|
486
480
|
try {
|
|
487
|
-
console.log("Registering node types in parallel");
|
|
488
481
|
await Promise.all(nodes.map((definition) => registerType(definition)));
|
|
489
|
-
console.log("All node types registered in parallel");
|
|
490
482
|
} catch (error) {
|
|
491
483
|
console.error("Error registering node types:", error);
|
|
492
484
|
throw error;
|
package/src/vite/client/build.ts
CHANGED