@kumologica/sdk 3.5.4 → 3.6.0-alpha7

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 (36) hide show
  1. package/cli/cli.js +31 -8
  2. package/cli/commands/open.js +88 -15
  3. package/cli/commands/run.js +167 -0
  4. package/cli/commands/serve.js +139 -0
  5. package/package.json +5 -5
  6. package/src/app/main-process/main-window.js +1 -0
  7. package/src/app/main-process/modal-home.js +1 -0
  8. package/src/app/main-process/modal-newproject.js +1 -0
  9. package/src/app/main-process/modal-newtab.js +1 -0
  10. package/src/app/main-process/modal-nodelibrary.js +1 -0
  11. package/src/app/main-process/modal-renameTab.js +1 -0
  12. package/src/app/main-process/modal-welcome.js +1 -0
  13. package/src/app/main.js +179 -141
  14. package/src/app/preload.js +225 -139
  15. package/src/app/ui/editor-client/public/red/red.js +1943 -783
  16. package/src/app/ui/editor-client/public/red/red.min.js +2 -2
  17. package/src/app/ui/editor-client/public/red/style.min.css +1 -1
  18. package/src/app/ui/editor-client/public/vendor/ace-linters/javascript-service.js +10 -2
  19. package/src/app/ui/editor-client/src/js/red.js +183 -179
  20. package/src/app/ui/editor-client/src/js/ui/common/commandBox.js +107 -0
  21. package/src/app/ui/editor-client/src/js/ui/common/searchBox.js +91 -90
  22. package/src/app/ui/editor-client/src/js/ui/modules.js +164 -0
  23. package/src/app/ui/editor-client/src/js/ui/search.js +171 -123
  24. package/src/app/ui/editor-client/src/js/ui/sidebar.js +1 -1
  25. package/src/app/ui/editor-client/src/js/ui/ui-settings.js +419 -410
  26. package/src/app/ui/editor-client/src/sass/editor.scss +745 -746
  27. package/src/app/ui/editor-client/src/sass/forms.scss +1 -1
  28. package/src/app/ui/editor-client/src/sass/search.scss +16 -2
  29. package/src/app/ui/editor-client/src/sass/sidebar.scss +1 -1
  30. package/src/app/ui/editor-client/src/sass/style.scss +72 -69
  31. package/src/app/ui/editor-client/src/sass/ui/common/commandBox.scss +100 -0
  32. package/src/app/ui/editor-client/src/sass/ui/common/searchBox.scss +3 -2
  33. package/src/app/ui/editor-client/src/sass/ui-settings.scss +14 -14
  34. package/src/app/ui/editor-client/src/vendor/ace-linters/build/javascript-service.js +10 -2
  35. package/src/app/ui/editor-client/templates/index.mst +2 -2
  36. package/src/server/DesignerServer.js +152 -153
@@ -0,0 +1,107 @@
1
+ (function ($) {
2
+ /**
3
+ * options:
4
+ * - command : the command to run
5
+ * - delay : delay, in ms, after a keystroke before firing change event
6
+ *
7
+ * methods:
8
+ * - value([val]) - gets the current value, or, if `val` is provided, sets the value
9
+ * - count - sets or clears a sub-label on the input. This can be used to provide
10
+ * a feedback on the number of matches, or number of available entries to search
11
+ * - change - trigger a change event
12
+ *
13
+ */
14
+
15
+ $.widget("kumologica.commandBox", {
16
+ _create: function () {
17
+ var that = this;
18
+
19
+ this.currentTimeout = null;
20
+ this.lastSent = "";
21
+ let command = this.options.command || "";
22
+
23
+ this.element.val(command + " ");
24
+ this.uiContainer = this.element.wrap("<div>").parent();
25
+ this.uiContainer.addClass("red-ui-commandBox-container");
26
+
27
+ $(
28
+ `<div class="red-ui-commandBox-command"><i class="fa fa-terminal"></i></div>`
29
+ ).prependTo(this.uiContainer);
30
+ this.enterButton = $(
31
+ '<span class="enter-command pointer">run</span>'
32
+ ).appendTo(this.uiContainer);
33
+
34
+ this.enterButton.on("click", function (e) {
35
+ e.preventDefault();
36
+ that.options.execute(that.element.val());
37
+ });
38
+
39
+ this.resultCount = $("<span>", {
40
+ class: "red-ui-searchBox-resultCount hide",
41
+ }).appendTo(this.uiContainer);
42
+
43
+ this.element.on("keydown", function (evt) {
44
+ if (evt.keyCode === 27) {
45
+ // Escape key
46
+ that.element.val("");
47
+ } else if (evt.keyCode === 13) {
48
+ // Enter key
49
+ evt.preventDefault();
50
+ let command = that.element.val();
51
+ that.options.execute(command);
52
+ }
53
+ });
54
+ this.element.on("keyup", function (evt) {
55
+ that._change($(this).val());
56
+ });
57
+
58
+ this.element.on("focus", function () {
59
+ $("body").one("mousedown", function () {
60
+ that.element.blur();
61
+ });
62
+ });
63
+ },
64
+ _change: function (val, instant) {
65
+ var fireEvent = false;
66
+ if (val === "") {
67
+ // this.clearButton.hide();
68
+ fireEvent = true;
69
+ } else {
70
+ // this.clearButton.show();
71
+ fireEvent = val.length >= (this.options.minimumLength || 0);
72
+ }
73
+ var current = this.element.val();
74
+ fireEvent = fireEvent && current !== this.lastSent;
75
+ if (fireEvent) {
76
+ if (!instant && this.options.delay > 0) {
77
+ clearTimeout(this.currentTimeout);
78
+ var that = this;
79
+ this.currentTimeout = setTimeout(function () {
80
+ that.lastSent = that.element.val();
81
+ that._trigger("change");
82
+ }, this.options.delay);
83
+ } else {
84
+ this._trigger("change");
85
+ }
86
+ }
87
+ },
88
+ value: function (val) {
89
+ if (val === undefined) {
90
+ return this.element.val();
91
+ } else {
92
+ this.element.val(val);
93
+ this._change(val);
94
+ }
95
+ },
96
+ count: function (val) {
97
+ if (val === undefined || val === null || val === "") {
98
+ this.resultCount.text("").hide();
99
+ } else {
100
+ this.resultCount.text(val).show();
101
+ }
102
+ },
103
+ change: function () {
104
+ this._trigger("change");
105
+ },
106
+ });
107
+ })(jQuery);
@@ -1,98 +1,99 @@
1
-
2
- (function($) {
1
+ (function ($) {
2
+ /**
3
+ * options:
4
+ * - minimumLength : the minimum length of text before firing a change event
5
+ * - delay : delay, in ms, after a keystroke before firing change event
6
+ *
7
+ * methods:
8
+ * - value([val]) - gets the current value, or, if `val` is provided, sets the value
9
+ * - count - sets or clears a sub-label on the input. This can be used to provide
10
+ * a feedback on the number of matches, or number of available entries to search
11
+ * - change - trigger a change event
12
+ *
13
+ */
3
14
 
4
- /**
5
- * options:
6
- * - minimumLength : the minimum length of text before firing a change event
7
- * - delay : delay, in ms, after a keystroke before firing change event
8
- *
9
- * methods:
10
- * - value([val]) - gets the current value, or, if `val` is provided, sets the value
11
- * - count - sets or clears a sub-label on the input. This can be used to provide
12
- * a feedback on the number of matches, or number of available entries to search
13
- * - change - trigger a change event
14
- *
15
- */
15
+ $.widget("nodered.searchBox", {
16
+ _create: function () {
17
+ var that = this;
16
18
 
17
- $.widget( "nodered.searchBox", {
18
- _create: function() {
19
- var that = this;
19
+ this.currentTimeout = null;
20
+ this.lastSent = "";
21
+ this.element.val("");
22
+ this.uiContainer = this.element.wrap("<div>").parent();
23
+ this.uiContainer.addClass("red-ui-searchBox-container");
20
24
 
21
- this.currentTimeout = null;
22
- this.lastSent = "";
23
- this.element.val("");
24
- this.uiContainer = this.element.wrap("<div>").parent();
25
- this.uiContainer.addClass("red-ui-searchBox-container");
25
+ $('<i class="fa fa-search"></i>').prependTo(this.uiContainer);
26
+ this.clearButton = $(
27
+ '<a href="#"><i class="fa fa-times"></i></a>'
28
+ ).appendTo(this.uiContainer);
29
+ this.clearButton.on("click", function (e) {
30
+ e.preventDefault();
31
+ that.element.val("");
32
+ that._change("", true);
33
+ that.element.focus();
34
+ });
26
35
 
27
- $('<i class="fa fa-search"></i>').prependTo(this.uiContainer);
28
- this.clearButton = $('<a href="#"><i class="fa fa-times"></i></a>').appendTo(this.uiContainer);
29
- this.clearButton.on("click",function(e) {
30
- e.preventDefault();
31
- that.element.val("");
32
- that._change("",true);
33
- that.element.focus();
34
- });
36
+ this.resultCount = $("<span>", {
37
+ class: "red-ui-searchBox-resultCount hide",
38
+ }).appendTo(this.uiContainer);
35
39
 
36
- this.resultCount = $('<span>',{class:"red-ui-searchBox-resultCount hide"}).appendTo(this.uiContainer);
37
-
38
- this.element.val("");
39
- this.element.on("keydown",function(evt) {
40
- if (evt.keyCode === 27) {
41
- that.element.val("");
42
- }
43
- })
44
- this.element.on("keyup",function(evt) {
45
- that._change($(this).val());
46
- });
47
-
48
- this.element.on("focus",function() {
49
- $("body").one("mousedown",function() {
50
- that.element.blur();
51
- });
52
- });
40
+ this.element.val("");
41
+ this.element.on("keydown", function (evt) {
42
+ if (evt.keyCode === 27) {
43
+ that.element.val("");
44
+ }
45
+ });
46
+ this.element.on("keyup", function (evt) {
47
+ that._change($(this).val());
48
+ });
53
49
 
54
- },
55
- _change: function(val,instant) {
56
- var fireEvent = false;
57
- if (val === "") {
58
- this.clearButton.hide();
59
- fireEvent = true;
60
- } else {
61
- this.clearButton.show();
62
- fireEvent = (val.length >= (this.options.minimumLength||0));
63
- }
64
- var current = this.element.val();
65
- fireEvent = fireEvent && current !== this.lastSent;
66
- if (fireEvent) {
67
- if (!instant && this.options.delay > 0) {
68
- clearTimeout(this.currentTimeout);
69
- var that = this;
70
- this.currentTimeout = setTimeout(function() {
71
- that.lastSent = that.element.val();
72
- that._trigger("change");
73
- },this.options.delay);
74
- } else {
75
- this._trigger("change");
76
- }
77
- }
78
- },
79
- value: function(val) {
80
- if (val === undefined) {
81
- return this.element.val();
82
- } else {
83
- this.element.val(val);
84
- this._change(val);
85
- }
86
- },
87
- count: function(val) {
88
- if (val === undefined || val === null || val === "") {
89
- this.resultCount.text("").hide();
90
- } else {
91
- this.resultCount.text(val).show();
92
- }
93
- },
94
- change: function() {
95
- this._trigger("change");
50
+ this.element.on("focus", function () {
51
+ $("body").one("mousedown", function () {
52
+ that.element.blur();
53
+ });
54
+ });
55
+ },
56
+ _change: function (val, instant) {
57
+ var fireEvent = false;
58
+ if (val === "") {
59
+ this.clearButton.hide();
60
+ fireEvent = true;
61
+ } else {
62
+ this.clearButton.show();
63
+ fireEvent = val.length >= (this.options.minimumLength || 0);
64
+ }
65
+ var current = this.element.val();
66
+ fireEvent = fireEvent && current !== this.lastSent;
67
+ if (fireEvent) {
68
+ if (!instant && this.options.delay > 0) {
69
+ clearTimeout(this.currentTimeout);
70
+ var that = this;
71
+ this.currentTimeout = setTimeout(function () {
72
+ that.lastSent = that.element.val();
73
+ that._trigger("change");
74
+ }, this.options.delay);
75
+ } else {
76
+ this._trigger("change");
96
77
  }
97
- });
78
+ }
79
+ },
80
+ value: function (val) {
81
+ if (val === undefined) {
82
+ return this.element.val();
83
+ } else {
84
+ this.element.val(val);
85
+ this._change(val);
86
+ }
87
+ },
88
+ count: function (val) {
89
+ if (val === undefined || val === null || val === "") {
90
+ this.resultCount.text("").hide();
91
+ } else {
92
+ this.resultCount.text(val).show();
93
+ }
94
+ },
95
+ change: function () {
96
+ this._trigger("change");
97
+ },
98
+ });
98
99
  })(jQuery);
@@ -0,0 +1,164 @@
1
+ RED.modules = (function () {
2
+ let dialog;
3
+ let commandInputContainer;
4
+ let visible = false;
5
+
6
+ const NPM_INSTALL_CMD = "npm install";
7
+ function createDialog() {
8
+ console.log("[RED.modules.createDialog] Invoked");
9
+
10
+ let $mainContainer = $("#main-container");
11
+
12
+ dialog = $(
13
+ `<div id="modules-dialog-container" class="red-ui-search"></div>`
14
+ ).appendTo($mainContainer);
15
+
16
+ dialog.on("click", function (e) {
17
+ e.stopPropagation();
18
+ });
19
+
20
+ console.log(
21
+ "[RED.modules.createDialog] Looking for hook for main-container",
22
+ $("#main-container")
23
+ );
24
+
25
+ commandInputContainer = $("<div>", {
26
+ class: "command-input-container",
27
+ }).appendTo(dialog);
28
+
29
+ installInput = $(
30
+ `<input type="text" placeholder="Type module to install...">`
31
+ )
32
+ .appendTo(commandInputContainer)
33
+ .commandBox({
34
+ command: NPM_INSTALL_CMD,
35
+ delay: 100,
36
+ change: function () {
37
+ evaluateCommand($(this).val());
38
+ },
39
+ execute: function (command) {
40
+ hide();
41
+ $("#workspace-terminal").show();
42
+ console.log("[modules] command received", command);
43
+ executeCommand(command);
44
+ },
45
+ });
46
+ console.log("[RED.modules.createDialog] 2");
47
+
48
+ installInput.on("keydown", function (evt) {
49
+ if (evt.key === "Enter" || evt.keyCode === 13) {
50
+ evt.preventDefault(); // Prevent default action if necessary
51
+ evaluateCommand($(this).val());
52
+ }
53
+ });
54
+
55
+ installInput.on("paste", function (evt) {
56
+ evt.preventDefault();
57
+
58
+ let clipboardData =
59
+ evt.originalEvent.clipboardData || window.clipboardData;
60
+ let pastedData = clipboardData.getData("Text");
61
+ if (pastedData.startsWith(NPM_INSTALL_CMD)) {
62
+ pastedData = pastedData.slice(NPM_INSTALL_CMD.length).trim();
63
+ }
64
+
65
+ installInput.commandBox("value", `${NPM_INSTALL_CMD} ${pastedData}`);
66
+ });
67
+ }
68
+
69
+ function init() {
70
+ RED.actions.add("npm:install", show);
71
+ RED.actions.add("npm:install:close", hide);
72
+ }
73
+
74
+ function show(v) {
75
+ if (!visible) {
76
+ RED.keyboard.add("*", "escape", function () {
77
+ hide();
78
+ });
79
+
80
+ $("#main-container").click(() => {
81
+ hide();
82
+ });
83
+
84
+ console.log("[modules.show] dialog?", dialog);
85
+ if (!dialog) {
86
+ createDialog();
87
+ }
88
+ // restore the value to the original
89
+ installInput.commandBox("value", NPM_INSTALL_CMD + " ");
90
+ visible = true;
91
+ console.log("[modules.show] dialog created");
92
+ dialog.slideDown(300);
93
+
94
+ RED.events.emit("modules:install");
95
+ window.setTimeout(() => {
96
+ installInput.focus();
97
+ }, 50);
98
+ }
99
+ }
100
+ function updateValue(value) {
101
+ installInput.commandBox("value", value);
102
+ }
103
+ function hide() {
104
+ if (visible) {
105
+ $("#main-container").off("click");
106
+ RED.keyboard.remove("escape");
107
+ visible = false;
108
+ if (dialog !== null) {
109
+ dialog.slideUp(200, function () {
110
+ installInput.commandBox("value", NPM_INSTALL_CMD);
111
+ });
112
+ }
113
+ RED.events.emit("modules:close");
114
+ }
115
+ }
116
+
117
+ function evaluateCommand(module) {
118
+ // check that module contains the prefix: NPM_INSTALL_CMD otherwise quit the app
119
+ if (!module.startsWith(NPM_INSTALL_CMD)) {
120
+ hide();
121
+ RED.actions.invoke("core:search");
122
+ } else {
123
+ const moduleName = module.slice(NPM_INSTALL_CMD.length).trim();
124
+ console.log(`npm install ${moduleName}`);
125
+ }
126
+ }
127
+
128
+ async function executeCommand(command) {
129
+ try {
130
+ await window.__kumologica.command.npmInstall(command);
131
+ RED.notifications.notify(
132
+ "<b>Task Completed Successfully</b></br>Please reload the designer to update the nodes palette.",
133
+ {
134
+ type: "success",
135
+ buttons: [
136
+ {
137
+ text: "Reload",
138
+ click: () => {
139
+ window.__kumologica.main.dispatch("restart-requested");
140
+ },
141
+ },
142
+ ],
143
+ fixed: true,
144
+ },
145
+ true,
146
+ undefined
147
+ );
148
+ } catch (err) {
149
+ RED.notifications.notify(
150
+ "<b>Error: Task Failed</b></br>The task could not be completed due to errors. Check the logs for details",
151
+ "error",
152
+ undefined,
153
+ 5000
154
+ );
155
+ }
156
+ }
157
+
158
+ return {
159
+ init,
160
+ show,
161
+ hide,
162
+ updateValue,
163
+ };
164
+ })();