@bonsae/nrg 0.6.0 → 0.6.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.
Files changed (84) hide show
  1. package/README.md +5 -5
  2. package/package.json +14 -75
  3. package/{build/server → server}/index.cjs +1 -1
  4. package/{src/core/client → shims}/components.d.ts +2 -0
  5. package/{src/tsconfig → tsconfig}/client.json +3 -3
  6. package/types/client.d.ts +37 -0
  7. package/types/index.d.ts +211 -0
  8. package/types/server.d.ts +2293 -0
  9. package/types/vite.d.ts +12 -0
  10. package/{build/vite → vite}/index.js +95 -0
  11. package/build/vite/utils.js +0 -56
  12. package/src/core/client/app.vue +0 -185
  13. package/src/core/client/components/node-red-config-input.vue +0 -79
  14. package/src/core/client/components/node-red-editor-input.vue +0 -307
  15. package/src/core/client/components/node-red-input-label.vue +0 -53
  16. package/src/core/client/components/node-red-input.vue +0 -93
  17. package/src/core/client/components/node-red-json-schema-form.vue +0 -444
  18. package/src/core/client/components/node-red-select-input.vue +0 -108
  19. package/src/core/client/components/node-red-toggle.vue +0 -115
  20. package/src/core/client/components/node-red-typed-input.vue +0 -158
  21. package/src/core/client/index.ts +0 -500
  22. package/src/core/client/tsconfig.json +0 -18
  23. package/src/core/constants.ts +0 -18
  24. package/src/core/errors.ts +0 -9
  25. package/src/core/server/api/index.ts +0 -1
  26. package/src/core/server/api/serve-nrg-resources.ts +0 -54
  27. package/src/core/server/index.ts +0 -190
  28. package/src/core/server/nodes/config-node.ts +0 -67
  29. package/src/core/server/nodes/factories.ts +0 -133
  30. package/src/core/server/nodes/index.ts +0 -5
  31. package/src/core/server/nodes/io-node.ts +0 -179
  32. package/src/core/server/nodes/node.ts +0 -259
  33. package/src/core/server/nodes/types/config-node.ts +0 -28
  34. package/src/core/server/nodes/types/factories.ts +0 -115
  35. package/src/core/server/nodes/types/index.ts +0 -4
  36. package/src/core/server/nodes/types/io-node.ts +0 -40
  37. package/src/core/server/nodes/types/node.ts +0 -41
  38. package/src/core/server/nodes/utils.ts +0 -106
  39. package/src/core/server/schemas/base.ts +0 -66
  40. package/src/core/server/schemas/index.ts +0 -3
  41. package/src/core/server/schemas/type.ts +0 -95
  42. package/src/core/server/schemas/types/index.ts +0 -82
  43. package/src/core/server/tsconfig.json +0 -17
  44. package/src/core/server/types/index.ts +0 -220
  45. package/src/core/server/utils.ts +0 -56
  46. package/src/core/server/validator.ts +0 -36
  47. package/src/core/validator.ts +0 -222
  48. package/src/index.ts +0 -2
  49. package/src/types.ts +0 -189
  50. package/src/utils.ts +0 -20
  51. package/src/vite/async-utils.ts +0 -61
  52. package/src/vite/client/build.ts +0 -227
  53. package/src/vite/client/index.ts +0 -1
  54. package/src/vite/client/plugins/html-generator.ts +0 -75
  55. package/src/vite/client/plugins/index.ts +0 -5
  56. package/src/vite/client/plugins/locales-generator.ts +0 -126
  57. package/src/vite/client/plugins/minifier.ts +0 -23
  58. package/src/vite/client/plugins/node-definitions-inliner.ts +0 -275
  59. package/src/vite/client/plugins/static-copy.ts +0 -43
  60. package/src/vite/defaults.ts +0 -77
  61. package/src/vite/errors.ts +0 -37
  62. package/src/vite/index.ts +0 -2
  63. package/src/vite/logger.ts +0 -94
  64. package/src/vite/node-red-launcher.ts +0 -344
  65. package/src/vite/plugin.ts +0 -61
  66. package/src/vite/plugins/build.ts +0 -85
  67. package/src/vite/plugins/index.ts +0 -2
  68. package/src/vite/plugins/server.ts +0 -267
  69. package/src/vite/server/build.ts +0 -124
  70. package/src/vite/server/index.ts +0 -1
  71. package/src/vite/server/plugins/index.ts +0 -3
  72. package/src/vite/server/plugins/output-wrapper.ts +0 -109
  73. package/src/vite/server/plugins/package-json-generator.ts +0 -203
  74. package/src/vite/server/plugins/type-generator.ts +0 -285
  75. package/src/vite/types.ts +0 -174
  76. package/src/vite/utils.ts +0 -72
  77. /package/{build/index.js → index.js} +0 -0
  78. /package/{build/server → server}/resources/nrg-client.js +0 -0
  79. /package/{build/server → server}/resources/vue.esm-browser.js +0 -0
  80. /package/{build/server → server}/resources/vue.esm-browser.prod.js +0 -0
  81. /package/{src/core/client → shims}/globals.d.ts +0 -0
  82. /package/{src/core/client → shims}/shims-vue.d.ts +0 -0
  83. /package/{src/tsconfig → tsconfig}/base.json +0 -0
  84. /package/{src/tsconfig → tsconfig}/server.json +0 -0
@@ -1,307 +0,0 @@
1
- <template>
2
- <div ref="container" class="container">
3
- <slot name="label">
4
- <NodeRedInputLabel
5
- v-if="label"
6
- :label="label"
7
- :icon="icon"
8
- :required="required"
9
- />
10
- </slot>
11
- <div class="editor-wrapper">
12
- <button
13
- ref="expand-button"
14
- class="red-ui-button red-ui-button-small expand-button"
15
- @click="onClickExpand"
16
- >
17
- <i class="fa fa-expand"></i>
18
- </button>
19
- <div :id="editorId" ref="editor"></div>
20
- </div>
21
- <div v-show="error" class="node-red-vue-input-error-message">
22
- {{ error }}
23
- </div>
24
- </div>
25
- </template>
26
-
27
- <script lang="ts">
28
- // TODO: expose editor apis
29
- import { defineComponent } from "vue";
30
- import NodeRedInputLabel from "./node-red-input-label.vue";
31
- export default defineComponent({
32
- components: { NodeRedInputLabel },
33
- props: {
34
- value: {
35
- type: String,
36
- default: "",
37
- },
38
- language: {
39
- type: String,
40
- default: "json",
41
- validator: function (value) {
42
- const allowedLanguages = [
43
- "abap",
44
- "apex",
45
- "azcli",
46
- "bat",
47
- "bicep",
48
- "cameligo",
49
- "clojure",
50
- "coffee",
51
- "cpp",
52
- "csharp",
53
- "csp",
54
- "css",
55
- "cypher",
56
- "dart",
57
- "dockerfile",
58
- "ecl",
59
- "elixir",
60
- "flow9",
61
- "freemarker2",
62
- "fsharp",
63
- "go",
64
- "graphql",
65
- "handlebars",
66
- "hcl",
67
- "html",
68
- "ini",
69
- "java",
70
- "javascript",
71
- "json",
72
- "julia",
73
- "kotlin",
74
- "less",
75
- "lexon",
76
- "liquid",
77
- "lua",
78
- "m3",
79
- "markdown",
80
- "mdx",
81
- "mips",
82
- "msdax",
83
- "mysql",
84
- "objective-c",
85
- "pascal",
86
- "pascaligo",
87
- "perl",
88
- "pgsql",
89
- "php",
90
- "pla",
91
- "postiats",
92
- "powerquery",
93
- "powershell",
94
- "protobuf",
95
- "pub",
96
- "python",
97
- "qsharp",
98
- "r",
99
- "razor",
100
- "redis",
101
- "redshift",
102
- "restructuredtext",
103
- "ruby",
104
- "rust",
105
- "sb",
106
- "scala",
107
- "scheme",
108
- "scss",
109
- "shell",
110
- "solidity",
111
- "sophia",
112
- "sparql",
113
- "sql",
114
- "st",
115
- "swift",
116
- "systemverilog",
117
- "tcl",
118
- "twig",
119
- "typescript",
120
- "typespec",
121
- "vb",
122
- "wgsl",
123
- "xml",
124
- "yaml",
125
- ];
126
- const isValid = allowedLanguages.includes(value);
127
- if (!isValid) {
128
- console.warn(
129
- `[WARN]: Invalid value for 'type' property: "${value}". ` +
130
- `Expected one of: ${allowedLanguages.join(", ")}`,
131
- );
132
- }
133
- return isValid;
134
- },
135
- },
136
- label: {
137
- type: String,
138
- default: "",
139
- },
140
- icon: {
141
- type: String,
142
- default: "",
143
- },
144
- required: {
145
- type: Boolean,
146
- default: false,
147
- },
148
- error: {
149
- type: String,
150
- default: "",
151
- },
152
- },
153
- emits: ["update:value"],
154
- editor: null,
155
- data() {
156
- const stateId = Math.random().toString(36).substring(2, 9);
157
- return {
158
- editorId: "node-red-editor-" + stateId,
159
- stateId,
160
- };
161
- },
162
- mounted() {
163
- // NOTE: jquery wrapper is used because RED.popover.tooltip needs it
164
- const expandButton = $(this.$refs["expand-button"]);
165
- RED.popover.tooltip(expandButton, RED._("node-red:common.label.expand"));
166
- this.mountEditor();
167
- this.createExpandeEditorTray();
168
- },
169
- beforeUnmount() {
170
- if (this.editorInstance) {
171
- try {
172
- this.editorInstance.destroy();
173
- } catch (err) {
174
- console.error(`Error destroying editor for ID ${this.editorId}:`, err);
175
- }
176
- this.editorInstance = null;
177
- }
178
- },
179
- methods: {
180
- mountEditor() {
181
- this.$nextTick(() => {
182
- const containerEl = this.$refs.container;
183
- const editorEl = this.$refs.editor;
184
-
185
- if (containerEl && editorEl) {
186
- try {
187
- const inlineHeight = containerEl.style.height;
188
- const inlineWidth = containerEl.style.width;
189
- if (inlineHeight) {
190
- editorEl.style.height = inlineHeight;
191
- } else {
192
- editorEl.style.height = "200px";
193
- }
194
-
195
- if (inlineWidth) {
196
- editorEl.style.width = inlineWidth;
197
- } else {
198
- editorEl.style.width = "100%";
199
- }
200
-
201
- this.createEditorInstance();
202
- } catch (e) {
203
- console.error(
204
- "[NodeRedEditorInput] Error setting initial editor style:",
205
- e,
206
- );
207
- this.createEditorInstance();
208
- }
209
- } else {
210
- console.error(
211
- "[NodeRedEditorInput] Container or Editor div refs not found on mount.",
212
- );
213
- }
214
- });
215
- },
216
- createEditorInstance() {
217
- this.editorInstance = RED.editor.createEditor({
218
- id: this.editorId,
219
- mode: this.language,
220
- value: this.value,
221
- });
222
- this.editorInstance.getSession().on("change", () => {
223
- const currentValue = this.editorInstance.getValue();
224
- if (currentValue !== this.value) {
225
- this.$emit("update:value", currentValue);
226
- }
227
- });
228
- },
229
- createExpandeEditorTray() {
230
- let expandedEditor;
231
-
232
- const onCancel = () => {
233
- setTimeout(() => {
234
- this.editorInstance.focus();
235
- }, 250);
236
- RED.tray.close();
237
- };
238
-
239
- const onDone = () => {
240
- expandedEditor.saveView();
241
- this.editorInstance.setValue(expandedEditor.getValue(), -1);
242
- setTimeout(() => {
243
- this.editorInstance.restoreView();
244
- this.editorInstance.focus();
245
- }, 250);
246
- RED.tray.close();
247
- };
248
-
249
- this.expandedEditorTray = {
250
- title: "Editor",
251
- focusElement: true,
252
- width: "Infinity",
253
- buttons: [
254
- {
255
- id: "node-dialog-cancel",
256
- text: RED._("common.label.cancel"),
257
- click: onCancel,
258
- },
259
- {
260
- id: "node-dialog-ok",
261
- text: RED._("common.label.done"),
262
- class: "primary",
263
- click: onDone,
264
- },
265
- ],
266
- open: (tray) => {
267
- const dialogForm = $(
268
- '<form id="dialog-form" class="form-horizontal" autocomplete="off"></form>',
269
- ).appendTo(tray.find(".red-ui-tray-body"));
270
- dialogForm.html(
271
- '<div id="expanded-editor-input" style="height: 100%"></div>',
272
- );
273
-
274
- expandedEditor = RED.editor.createEditor({
275
- id: "expanded-editor-input",
276
- stateId: this.stateId,
277
- mode: this.language,
278
- focus: true,
279
- value: this.value,
280
- });
281
- dialogForm.i18n();
282
- },
283
- close: function () {
284
- expandedEditor.destroy();
285
- },
286
- };
287
- },
288
- onClickExpand() {
289
- RED.tray.show(this.expandedEditorTray);
290
- },
291
- },
292
- });
293
- </script>
294
- <style scoped>
295
- .editor-wrapper {
296
- position: relative;
297
- }
298
-
299
- .expand-button {
300
- position: absolute;
301
- top: -23px;
302
- right: 0px;
303
- z-index: 10;
304
- transition: color 0.3s ease;
305
- cursor: pointer;
306
- }
307
- </style>
@@ -1,53 +0,0 @@
1
- <template>
2
- <span class="nrg-label">
3
- <i v-if="icon" :class="iconClass"></i>
4
- <slot>{{ label }}</slot>
5
- <span v-if="required" class="nrg-required">*</span>
6
- </span>
7
- </template>
8
-
9
- <script lang="ts">
10
- import { defineComponent } from "vue";
11
-
12
- export default defineComponent({
13
- name: "NodeRedInputLabel",
14
- props: {
15
- label: {
16
- type: String,
17
- default: "",
18
- },
19
- icon: {
20
- type: String,
21
- default: "",
22
- },
23
- required: {
24
- type: Boolean,
25
- default: false,
26
- },
27
- },
28
- computed: {
29
- iconClass(): string {
30
- if (!this.icon) return "";
31
- const name = this.icon.startsWith("fa-") ? this.icon : `fa-${this.icon}`;
32
- return `fa ${name}`;
33
- },
34
- },
35
- });
36
- </script>
37
-
38
- <style scoped>
39
- .nrg-label {
40
- display: inline-block;
41
- width: 100%;
42
- cursor: default;
43
- }
44
-
45
- .nrg-label i {
46
- margin-right: 5px;
47
- }
48
-
49
- .nrg-required {
50
- color: var(--red-ui-text-color-error);
51
- margin-left: 2px;
52
- }
53
- </style>
@@ -1,93 +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="inputField"
13
- :type="type"
14
- :value="internalValue"
15
- :placeholder="placeholder"
16
- style="width: 100%"
17
- @input="onInput"
18
- @focus="onFocus"
19
- @blur="onBlur"
20
- />
21
- <div v-if="error" class="node-red-vue-input-error-message">
22
- {{ error }}
23
- </div>
24
- </div>
25
- </template>
26
-
27
- <script lang="ts">
28
- import { defineComponent } from "vue";
29
- import NodeRedInputLabel from "./node-red-input-label.vue";
30
-
31
- const SECRET_PATTERN = "*************";
32
-
33
- export default defineComponent({
34
- components: { NodeRedInputLabel },
35
- props: {
36
- value: {
37
- type: String,
38
- default: "",
39
- },
40
- type: {
41
- type: String,
42
- default: "text",
43
- },
44
- placeholder: {
45
- type: String,
46
- default: "",
47
- },
48
- label: {
49
- type: String,
50
- default: "",
51
- },
52
- icon: {
53
- type: String,
54
- default: "",
55
- },
56
- required: {
57
- type: Boolean,
58
- default: false,
59
- },
60
- error: {
61
- type: String,
62
- default: "",
63
- },
64
- },
65
- emits: ["update:value", "input"],
66
- data() {
67
- return {
68
- internalValue: "",
69
- };
70
- },
71
- beforeMount() {
72
- this.internalValue = this.value;
73
- this.onBlur();
74
- },
75
- methods: {
76
- onInput(event) {
77
- this.internalValue = event.target.value;
78
- this.$emit("update:value", this.internalValue);
79
- this.$emit("input", this.internalValue);
80
- },
81
- onFocus() {
82
- if (this.type === "password" && this.internalValue === SECRET_PATTERN) {
83
- this.internalValue = "";
84
- }
85
- },
86
- onBlur() {
87
- if (this.type === "password" && this.value === "__PWD__") {
88
- this.internalValue = SECRET_PATTERN;
89
- }
90
- },
91
- },
92
- });
93
- </script>