@bonsae/nrg 0.1.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/README.md +130 -0
- package/build/server/index.cjs +910 -0
- package/build/server/resources/nrg-client.js +6530 -0
- package/build/server/resources/vue.esm-browser.prod.js +13 -0
- package/build/vite/index.js +1893 -0
- package/build/vite/utils.js +60 -0
- package/package.json +110 -0
- package/src/core/client/api/index.ts +17 -0
- package/src/core/client/app.vue +201 -0
- package/src/core/client/components/node-red-config-input.vue +57 -0
- package/src/core/client/components/node-red-editor-input.vue +283 -0
- package/src/core/client/components/node-red-input.vue +71 -0
- package/src/core/client/components/node-red-json-schema-form.vue +369 -0
- package/src/core/client/components/node-red-select-input.vue +86 -0
- package/src/core/client/components/node-red-typed-input.vue +130 -0
- package/src/core/client/components.d.ts +18 -0
- package/src/core/client/globals.d.ts +17 -0
- package/src/core/client/index.ts +504 -0
- package/src/core/client/shims-vue.d.ts +5 -0
- package/src/core/client/tsconfig.json +18 -0
- package/src/core/client/virtual.d.ts +5 -0
- package/src/core/constants.ts +18 -0
- package/src/core/server/index.ts +209 -0
- package/src/core/server/nodes/config-node.ts +67 -0
- package/src/core/server/nodes/index.ts +4 -0
- package/src/core/server/nodes/io-node.ts +178 -0
- package/src/core/server/nodes/node.ts +255 -0
- package/src/core/server/nodes/types/config-node.ts +28 -0
- package/src/core/server/nodes/types/index.ts +3 -0
- package/src/core/server/nodes/types/io-node.ts +37 -0
- package/src/core/server/nodes/types/node.ts +41 -0
- package/src/core/server/nodes/utils.ts +83 -0
- package/src/core/server/schemas/base.ts +66 -0
- package/src/core/server/schemas/index.ts +3 -0
- package/src/core/server/schemas/type.ts +95 -0
- package/src/core/server/schemas/types/index.ts +73 -0
- package/src/core/server/tsconfig.json +17 -0
- package/src/core/server/types/index.ts +73 -0
- package/src/core/server/utils.ts +56 -0
- package/src/core/server/validator.ts +32 -0
- package/src/core/validator.ts +222 -0
- package/src/tsconfig/base.json +23 -0
- package/src/tsconfig/client.json +11 -0
- package/src/tsconfig/server.json +6 -0
- package/src/vite/async-utils.ts +61 -0
- package/src/vite/client/build.ts +223 -0
- package/src/vite/client/index.ts +1 -0
- package/src/vite/client/plugins/html-generator.ts +75 -0
- package/src/vite/client/plugins/index.ts +5 -0
- package/src/vite/client/plugins/locales-generator.ts +126 -0
- package/src/vite/client/plugins/minifier.ts +22 -0
- package/src/vite/client/plugins/node-definitions-inliner.ts +224 -0
- package/src/vite/client/plugins/static-copy.ts +43 -0
- package/src/vite/defaults.ts +77 -0
- package/src/vite/errors.ts +37 -0
- package/src/vite/index.ts +3 -0
- package/src/vite/logger.ts +94 -0
- package/src/vite/node-red-launcher.ts +344 -0
- package/src/vite/plugin.ts +61 -0
- package/src/vite/plugins/build.ts +73 -0
- package/src/vite/plugins/index.ts +2 -0
- package/src/vite/plugins/server.ts +267 -0
- package/src/vite/server/build.ts +124 -0
- package/src/vite/server/index.ts +1 -0
- package/src/vite/server/plugins/index.ts +3 -0
- package/src/vite/server/plugins/output-wrapper.ts +109 -0
- package/src/vite/server/plugins/package-json-generator.ts +203 -0
- package/src/vite/server/plugins/type-generator.ts +285 -0
- package/src/vite/types.ts +369 -0
- package/src/vite/utils.ts +103 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="display: flex; flex-direction: column; width: 100%">
|
|
3
|
+
<input
|
|
4
|
+
ref="selectInput"
|
|
5
|
+
type="text"
|
|
6
|
+
class="node-input-select"
|
|
7
|
+
style="width: 100%"
|
|
8
|
+
/>
|
|
9
|
+
<div v-if="error" class="node-red-vue-input-error-message">
|
|
10
|
+
{{ error }}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { defineComponent } from "vue";
|
|
17
|
+
export default defineComponent({
|
|
18
|
+
props: {
|
|
19
|
+
value: {
|
|
20
|
+
type: [String, Array],
|
|
21
|
+
default: () => "",
|
|
22
|
+
},
|
|
23
|
+
options: {
|
|
24
|
+
type: Array,
|
|
25
|
+
required: true,
|
|
26
|
+
validator: function (value) {
|
|
27
|
+
if (!Array.isArray(value)) {
|
|
28
|
+
console.warn(
|
|
29
|
+
"[WARN] Invalid value for 'options' property. It must be an array.",
|
|
30
|
+
);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const isValid = value.every(
|
|
34
|
+
(item) =>
|
|
35
|
+
typeof item === "object" &&
|
|
36
|
+
item !== null &&
|
|
37
|
+
typeof item.value === "string" &&
|
|
38
|
+
typeof item.label === "string" &&
|
|
39
|
+
Object.prototype.hasOwnProperty.call(item, "value") &&
|
|
40
|
+
Object.prototype.hasOwnProperty.call(item, "label"),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!isValid) {
|
|
44
|
+
console.warn(
|
|
45
|
+
"[WARN] Invalid value for 'options' property. Each item must be an object with 'value' and 'label' properties being strings.",
|
|
46
|
+
value,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return isValid;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
multiple: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
emits: ["update:value"],
|
|
62
|
+
mounted() {
|
|
63
|
+
const inputElement = this.$refs.selectInput;
|
|
64
|
+
const $selectInput = $(inputElement);
|
|
65
|
+
$selectInput.typedInput({
|
|
66
|
+
types: [
|
|
67
|
+
{
|
|
68
|
+
multiple: this.multiple,
|
|
69
|
+
options: this.options,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
$selectInput.typedInput(
|
|
75
|
+
"value",
|
|
76
|
+
Array.isArray(this.value) ? this.value.join(",") : this.value,
|
|
77
|
+
);
|
|
78
|
+
$selectInput.on("change", () => {
|
|
79
|
+
const newValue = this.multiple
|
|
80
|
+
? ($selectInput.typedInput("value")?.split(",").filter(Boolean) ?? [])
|
|
81
|
+
: $selectInput.typedInput("value");
|
|
82
|
+
this.$emit("update:value", newValue);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="display: flex; flex-direction: column; width: 100%">
|
|
3
|
+
<input
|
|
4
|
+
ref="typedInput"
|
|
5
|
+
type="text"
|
|
6
|
+
class="node-red-typed-input"
|
|
7
|
+
style="flex: 1; width: 100%"
|
|
8
|
+
/>
|
|
9
|
+
<div v-if="error" class="node-red-vue-input-error-message">
|
|
10
|
+
{{ error }}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { defineComponent } from "vue";
|
|
17
|
+
import { TYPED_INPUT_TYPES } from "../../constants";
|
|
18
|
+
|
|
19
|
+
export default defineComponent({
|
|
20
|
+
props: {
|
|
21
|
+
value: {
|
|
22
|
+
type: Object,
|
|
23
|
+
required: true,
|
|
24
|
+
validator: function (obj) {
|
|
25
|
+
if (typeof obj !== "object" || obj === null) {
|
|
26
|
+
console.warn(
|
|
27
|
+
"[WARN] Invalid value for 'value' property. It must be an object.",
|
|
28
|
+
);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const isValid =
|
|
32
|
+
typeof obj?.value === "string" && typeof obj?.type === "string";
|
|
33
|
+
if (!isValid) {
|
|
34
|
+
console.warn(
|
|
35
|
+
"[WARN] Invalid value for 'value' property. It must be an object with 'value' and 'type' properties being strings.",
|
|
36
|
+
obj,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return isValid;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
types: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => TYPED_INPUT_TYPES,
|
|
45
|
+
},
|
|
46
|
+
error: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
emits: ["update:value"],
|
|
52
|
+
computed: {
|
|
53
|
+
isProvidedValueTypeValid() {
|
|
54
|
+
const type = this.value.type;
|
|
55
|
+
const types = this.types;
|
|
56
|
+
|
|
57
|
+
return types.includes(type);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
watch: {
|
|
61
|
+
isProvidedValueTypeValid: {
|
|
62
|
+
handler(newValue) {
|
|
63
|
+
if (!newValue) {
|
|
64
|
+
console.warn(
|
|
65
|
+
`Validation failed: this.value.type (${this.value.type}) must be one of the provided types (${this.types}).`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
immediate: true,
|
|
70
|
+
},
|
|
71
|
+
error(newVal) {
|
|
72
|
+
this.$nextTick(() => {
|
|
73
|
+
const targetDiv = this.$el.querySelector(
|
|
74
|
+
".red-ui-typedInput-container",
|
|
75
|
+
);
|
|
76
|
+
if (newVal) {
|
|
77
|
+
targetDiv.classList.add("input-error");
|
|
78
|
+
} else {
|
|
79
|
+
targetDiv.classList.remove("input-error");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
mounted() {
|
|
85
|
+
const inputElement = this.$refs.typedInput;
|
|
86
|
+
this.$input = $(inputElement).typedInput({
|
|
87
|
+
default: this.value.type || this.types[0],
|
|
88
|
+
types: this.types,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.$input.typedInput("value", this.value.value || "");
|
|
92
|
+
this.$input.typedInput("type", this.value.type || this.types[0]);
|
|
93
|
+
|
|
94
|
+
// NOTE: when typed input is just a text input, it isn't emiting change while typing because it is updating the value in a hidden input
|
|
95
|
+
this.$nextTick(() => {
|
|
96
|
+
const observer = new MutationObserver((mutations) => {
|
|
97
|
+
for (const mutation of mutations) {
|
|
98
|
+
if (mutation.attributeName === "value") {
|
|
99
|
+
this.onChange();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
observer.observe(inputElement, {
|
|
105
|
+
attributes: true,
|
|
106
|
+
attributeFilter: ["value"],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
this._observer = observer;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// NOTE: this emits changes to all types that lose focus when choosing a value, but text inputs
|
|
113
|
+
this.$input.on("change", () => {
|
|
114
|
+
this.onChange();
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
onChange() {
|
|
119
|
+
const newValue = this.$input.typedInput("value");
|
|
120
|
+
const newType = this.$input.typedInput("type");
|
|
121
|
+
if (this.value.value !== newValue || this.value.type !== newType) {
|
|
122
|
+
this.$emit("update:value", {
|
|
123
|
+
value: newValue,
|
|
124
|
+
type: newType,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global component type declarations for Volar / Vue Language Server.
|
|
3
|
+
* Provides autocompletion and type-checking for NRG form components
|
|
4
|
+
* used inside Vue SFC <template> blocks.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {};
|
|
8
|
+
|
|
9
|
+
declare module "vue" {
|
|
10
|
+
export interface GlobalComponents {
|
|
11
|
+
NodeRedInput: (typeof import("./components/node-red-input.vue"))["default"];
|
|
12
|
+
NodeRedTypedInput: (typeof import("./components/node-red-typed-input.vue"))["default"];
|
|
13
|
+
NodeRedConfigInput: (typeof import("./components/node-red-config-input.vue"))["default"];
|
|
14
|
+
NodeRedSelectInput: (typeof import("./components/node-red-select-input.vue"))["default"];
|
|
15
|
+
NodeRedEditorInput: (typeof import("./components/node-red-editor-input.vue"))["default"];
|
|
16
|
+
NodeRedJsonSchemaForm: (typeof import("./components/node-red-json-schema-form.vue"))["default"];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global type declarations for the Node-RED editor environment.
|
|
3
|
+
* These are provided by Node-RED at runtime, not imported.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// jQuery — injected by Node-RED editor
|
|
7
|
+
declare const $: any;
|
|
8
|
+
|
|
9
|
+
// Node-RED editor API — injected by Node-RED editor
|
|
10
|
+
declare const RED: {
|
|
11
|
+
nodes: {
|
|
12
|
+
registerType(type: string, definition: any): void;
|
|
13
|
+
node(id: string): any;
|
|
14
|
+
dirty(): boolean;
|
|
15
|
+
};
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|