@bonsae/nrg 0.6.1 → 0.6.3
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 +5 -5
- package/package.json +13 -77
- package/{src/core/client → shims}/components.d.ts +2 -0
- package/{src/tsconfig → tsconfig}/client.json +3 -3
- package/types/client.d.ts +37 -0
- package/types/index.d.ts +211 -0
- package/types/server.d.ts +2307 -0
- package/types/vite.d.ts +12 -0
- package/build/vite/utils.js +0 -56
- package/src/core/client/app.vue +0 -185
- package/src/core/client/components/node-red-config-input.vue +0 -79
- package/src/core/client/components/node-red-editor-input.vue +0 -307
- package/src/core/client/components/node-red-input-label.vue +0 -53
- package/src/core/client/components/node-red-input.vue +0 -93
- package/src/core/client/components/node-red-json-schema-form.vue +0 -444
- package/src/core/client/components/node-red-select-input.vue +0 -108
- package/src/core/client/components/node-red-toggle.vue +0 -115
- package/src/core/client/components/node-red-typed-input.vue +0 -158
- package/src/core/client/index.ts +0 -500
- package/src/core/client/tsconfig.json +0 -18
- package/src/core/constants.ts +0 -18
- package/src/core/errors.ts +0 -9
- package/src/core/server/api/index.ts +0 -1
- package/src/core/server/api/serve-nrg-resources.ts +0 -54
- package/src/core/server/index.ts +0 -191
- package/src/core/server/nodes/config-node.ts +0 -67
- package/src/core/server/nodes/factories.ts +0 -136
- package/src/core/server/nodes/index.ts +0 -5
- package/src/core/server/nodes/io-node.ts +0 -179
- package/src/core/server/nodes/node.ts +0 -259
- package/src/core/server/nodes/types/config-node.ts +0 -28
- package/src/core/server/nodes/types/factories.ts +0 -130
- package/src/core/server/nodes/types/index.ts +0 -4
- package/src/core/server/nodes/types/io-node.ts +0 -40
- package/src/core/server/nodes/types/node.ts +0 -41
- package/src/core/server/nodes/utils.ts +0 -106
- package/src/core/server/schemas/base.ts +0 -66
- package/src/core/server/schemas/index.ts +0 -3
- package/src/core/server/schemas/type.ts +0 -95
- package/src/core/server/schemas/types/index.ts +0 -82
- package/src/core/server/tsconfig.json +0 -17
- package/src/core/server/types/index.ts +0 -220
- package/src/core/server/utils.ts +0 -56
- package/src/core/server/validator.ts +0 -36
- package/src/core/validator.ts +0 -222
- package/src/index.ts +0 -2
- package/src/types.ts +0 -189
- package/src/utils.ts +0 -20
- package/src/vite/async-utils.ts +0 -61
- package/src/vite/client/build.ts +0 -227
- package/src/vite/client/index.ts +0 -1
- package/src/vite/client/plugins/html-generator.ts +0 -75
- package/src/vite/client/plugins/index.ts +0 -5
- package/src/vite/client/plugins/locales-generator.ts +0 -126
- package/src/vite/client/plugins/minifier.ts +0 -23
- package/src/vite/client/plugins/node-definitions-inliner.ts +0 -275
- package/src/vite/client/plugins/static-copy.ts +0 -43
- package/src/vite/defaults.ts +0 -77
- package/src/vite/errors.ts +0 -37
- package/src/vite/index.ts +0 -2
- package/src/vite/logger.ts +0 -94
- package/src/vite/node-red-launcher.ts +0 -344
- package/src/vite/plugin.ts +0 -61
- package/src/vite/plugins/build.ts +0 -85
- package/src/vite/plugins/index.ts +0 -2
- package/src/vite/plugins/server.ts +0 -267
- package/src/vite/server/build.ts +0 -124
- package/src/vite/server/index.ts +0 -1
- package/src/vite/server/plugins/index.ts +0 -3
- package/src/vite/server/plugins/output-wrapper.ts +0 -109
- package/src/vite/server/plugins/package-json-generator.ts +0 -203
- package/src/vite/server/plugins/type-generator.ts +0 -442
- package/src/vite/types.ts +0 -174
- package/src/vite/utils.ts +0 -72
- /package/{build/index.js → index.js} +0 -0
- /package/{build/server → server}/index.cjs +0 -0
- /package/{build/server → server}/resources/nrg-client.js +0 -0
- /package/{build/server → server}/resources/vue.esm-browser.js +0 -0
- /package/{build/server → server}/resources/vue.esm-browser.prod.js +0 -0
- /package/{src/core/client → shims}/globals.d.ts +0 -0
- /package/{src/core/client → shims}/shims-vue.d.ts +0 -0
- /package/{src/tsconfig → tsconfig}/base.json +0 -0
- /package/{src/tsconfig → tsconfig}/server.json +0 -0
- /package/{build/vite → vite}/index.js +0 -0
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="nrg-toggle-wrapper">
|
|
3
|
-
<label class="nrg-toggle" :class="{ 'nrg-toggle--checked': modelValue }">
|
|
4
|
-
<input
|
|
5
|
-
type="checkbox"
|
|
6
|
-
:checked="modelValue"
|
|
7
|
-
class="nrg-toggle__input"
|
|
8
|
-
@change="
|
|
9
|
-
$emit(
|
|
10
|
-
'update:modelValue',
|
|
11
|
-
($event.target as HTMLInputElement).checked,
|
|
12
|
-
)
|
|
13
|
-
"
|
|
14
|
-
/>
|
|
15
|
-
<span v-if="icon || label" class="nrg-toggle__label">
|
|
16
|
-
<i v-if="icon" :class="iconClass"></i>
|
|
17
|
-
{{ label }}
|
|
18
|
-
</span>
|
|
19
|
-
<span class="nrg-toggle__slider"></span>
|
|
20
|
-
</label>
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
import { defineComponent } from "vue";
|
|
26
|
-
|
|
27
|
-
export default defineComponent({
|
|
28
|
-
name: "NodeRedToggle",
|
|
29
|
-
props: {
|
|
30
|
-
modelValue: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
default: false,
|
|
33
|
-
},
|
|
34
|
-
label: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: "",
|
|
37
|
-
},
|
|
38
|
-
icon: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: "",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
emits: ["update:modelValue"],
|
|
44
|
-
computed: {
|
|
45
|
-
iconClass(): string {
|
|
46
|
-
if (!this.icon) return "";
|
|
47
|
-
const name = this.icon.startsWith("fa-") ? this.icon : `fa-${this.icon}`;
|
|
48
|
-
return `fa ${name}`;
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<style scoped>
|
|
55
|
-
.nrg-toggle-wrapper {
|
|
56
|
-
display: inline-flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.nrg-toggle {
|
|
61
|
-
position: relative;
|
|
62
|
-
display: inline-flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
gap: 8px;
|
|
66
|
-
user-select: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.nrg-toggle__input {
|
|
70
|
-
position: absolute;
|
|
71
|
-
opacity: 0;
|
|
72
|
-
width: 0;
|
|
73
|
-
height: 0;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.nrg-toggle__slider {
|
|
77
|
-
position: relative;
|
|
78
|
-
display: inline-block;
|
|
79
|
-
width: 36px;
|
|
80
|
-
min-width: 36px;
|
|
81
|
-
height: 20px;
|
|
82
|
-
background-color: var(--red-ui-secondary-border-color, #ccc);
|
|
83
|
-
border-radius: 10px;
|
|
84
|
-
transition: background-color 0.2s ease;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.nrg-toggle__slider::after {
|
|
88
|
-
content: "";
|
|
89
|
-
position: absolute;
|
|
90
|
-
top: 2px;
|
|
91
|
-
left: 2px;
|
|
92
|
-
width: 16px;
|
|
93
|
-
height: 16px;
|
|
94
|
-
background-color: white;
|
|
95
|
-
border-radius: 50%;
|
|
96
|
-
transition: transform 0.2s ease;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.nrg-toggle--checked .nrg-toggle__slider {
|
|
100
|
-
background-color: var(--red-ui-text-color-link, #0070d2);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.nrg-toggle--checked .nrg-toggle__slider::after {
|
|
104
|
-
transform: translateX(16px);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.nrg-toggle__label {
|
|
108
|
-
cursor: default;
|
|
109
|
-
white-space: nowrap;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.nrg-toggle__label i {
|
|
113
|
-
margin-right: 2px;
|
|
114
|
-
}
|
|
115
|
-
</style>
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div style="display: flex; flex-direction: column; width: 100%">
|
|
3
|
-
<slot name="label">
|
|
4
|
-
<NodeRedInputLabel
|
|
5
|
-
v-if="label"
|
|
6
|
-
:label="label"
|
|
7
|
-
:icon="icon"
|
|
8
|
-
:required="required"
|
|
9
|
-
/>
|
|
10
|
-
</slot>
|
|
11
|
-
<input
|
|
12
|
-
ref="typedInput"
|
|
13
|
-
type="text"
|
|
14
|
-
class="node-red-typed-input"
|
|
15
|
-
style="flex: 1; width: 100%"
|
|
16
|
-
/>
|
|
17
|
-
<div v-if="error" class="node-red-vue-input-error-message">
|
|
18
|
-
{{ error }}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script lang="ts">
|
|
24
|
-
import { defineComponent } from "vue";
|
|
25
|
-
import NodeRedInputLabel from "./node-red-input-label.vue";
|
|
26
|
-
import { TYPED_INPUT_TYPES } from "../../constants";
|
|
27
|
-
|
|
28
|
-
export default defineComponent({
|
|
29
|
-
components: { NodeRedInputLabel },
|
|
30
|
-
props: {
|
|
31
|
-
value: {
|
|
32
|
-
type: Object,
|
|
33
|
-
required: true,
|
|
34
|
-
validator: function (obj) {
|
|
35
|
-
if (typeof obj !== "object" || obj === null) {
|
|
36
|
-
console.warn(
|
|
37
|
-
"[WARN] Invalid value for 'value' property. It must be an object.",
|
|
38
|
-
);
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
const isValid =
|
|
42
|
-
typeof obj?.value === "string" && typeof obj?.type === "string";
|
|
43
|
-
if (!isValid) {
|
|
44
|
-
console.warn(
|
|
45
|
-
"[WARN] Invalid value for 'value' property. It must be an object with 'value' and 'type' properties being strings.",
|
|
46
|
-
obj,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return isValid;
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
types: {
|
|
53
|
-
type: Array,
|
|
54
|
-
default: () => TYPED_INPUT_TYPES,
|
|
55
|
-
},
|
|
56
|
-
label: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: "",
|
|
59
|
-
},
|
|
60
|
-
icon: {
|
|
61
|
-
type: String,
|
|
62
|
-
default: "",
|
|
63
|
-
},
|
|
64
|
-
required: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: false,
|
|
67
|
-
},
|
|
68
|
-
error: {
|
|
69
|
-
type: String,
|
|
70
|
-
default: "",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
emits: ["update:value"],
|
|
74
|
-
computed: {
|
|
75
|
-
isProvidedValueTypeValid() {
|
|
76
|
-
const type = this.value.type;
|
|
77
|
-
const types = this.types;
|
|
78
|
-
|
|
79
|
-
return types.includes(type);
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
watch: {
|
|
83
|
-
isProvidedValueTypeValid: {
|
|
84
|
-
handler(newValue) {
|
|
85
|
-
if (!newValue) {
|
|
86
|
-
console.warn(
|
|
87
|
-
`Validation failed: this.value.type (${this.value.type}) must be one of the provided types (${this.types}).`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
immediate: true,
|
|
92
|
-
},
|
|
93
|
-
error(newVal) {
|
|
94
|
-
this.$nextTick(() => {
|
|
95
|
-
const targetDiv = this.$el.querySelector(
|
|
96
|
-
".red-ui-typedInput-container",
|
|
97
|
-
);
|
|
98
|
-
if (newVal) {
|
|
99
|
-
targetDiv.classList.add("input-error");
|
|
100
|
-
} else {
|
|
101
|
-
targetDiv.classList.remove("input-error");
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
mounted() {
|
|
107
|
-
const inputElement = this.$refs.typedInput;
|
|
108
|
-
this.$input = $(inputElement).typedInput({
|
|
109
|
-
default: this.value.type || this.types[0],
|
|
110
|
-
types: this.types,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
this.$input.typedInput("value", this.value.value || "");
|
|
114
|
-
this.$input.typedInput("type", this.value.type || this.types[0]);
|
|
115
|
-
|
|
116
|
-
// 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
|
|
117
|
-
this.$nextTick(() => {
|
|
118
|
-
const observer = new MutationObserver((mutations) => {
|
|
119
|
-
for (const mutation of mutations) {
|
|
120
|
-
if (mutation.attributeName === "value") {
|
|
121
|
-
this.onChange();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
observer.observe(inputElement, {
|
|
127
|
-
attributes: true,
|
|
128
|
-
attributeFilter: ["value"],
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
this._observer = observer;
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// NOTE: this emits changes to all types that lose focus when choosing a value, but text inputs
|
|
135
|
-
this.$input.on("change", () => {
|
|
136
|
-
this.onChange();
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
beforeUnmount() {
|
|
140
|
-
if (this._observer) {
|
|
141
|
-
this._observer.disconnect();
|
|
142
|
-
this._observer = null;
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
methods: {
|
|
146
|
-
onChange() {
|
|
147
|
-
const newValue = this.$input.typedInput("value");
|
|
148
|
-
const newType = this.$input.typedInput("type");
|
|
149
|
-
if (this.value.value !== newValue || this.value.type !== newType) {
|
|
150
|
-
this.$emit("update:value", {
|
|
151
|
-
value: newValue,
|
|
152
|
-
type: newType,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
</script>
|