@kumologica/sdk 3.6.0-beta1 → 3.6.0-beta10
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/cli/cli.js +31 -8
- package/cli/commands/open.js +167 -72
- package/cli/commands/run.js +167 -0
- package/cli/commands/serve.js +139 -0
- package/package.json +4 -4
- package/src/app/main.js +177 -141
- package/src/app/preload.js +225 -137
- package/src/app/ui/editor-client/public/red/red.js +1960 -794
- package/src/app/ui/editor-client/public/red/red.min.js +2 -2
- package/src/app/ui/editor-client/public/red/style.min.css +1 -1
- package/src/app/ui/editor-client/src/js/red.js +183 -179
- package/src/app/ui/editor-client/src/js/ui/common/commandBox.js +107 -0
- package/src/app/ui/editor-client/src/js/ui/common/searchBox.js +91 -90
- package/src/app/ui/editor-client/src/js/ui/modules.js +164 -0
- package/src/app/ui/editor-client/src/js/ui/search.js +171 -123
- package/src/app/ui/editor-client/src/js/ui/sidebar.js +1 -1
- package/src/app/ui/editor-client/src/js/ui/ui-settings.js +441 -426
- package/src/app/ui/editor-client/src/sass/editor.scss +4 -3
- package/src/app/ui/editor-client/src/sass/forms.scss +1 -1
- package/src/app/ui/editor-client/src/sass/search.scss +16 -2
- package/src/app/ui/editor-client/src/sass/sidebar.scss +1 -1
- package/src/app/ui/editor-client/src/sass/style.scss +72 -69
- package/src/app/ui/editor-client/src/sass/ui/common/commandBox.scss +100 -0
- package/src/app/ui/editor-client/src/sass/ui/common/searchBox.scss +3 -2
- package/src/app/ui/editor-client/src/sass/ui-settings.scss +22 -17
- package/src/app/ui/editor-client/templates/index.mst +1 -1
- package/src/server/DesignerServer.js +152 -153
package/src/app/main.js
CHANGED
|
@@ -2,42 +2,43 @@
|
|
|
2
2
|
* ipcMain.on('ch', (e.msg){}) <---------------------- ipcRenderer.send('reply', msg)
|
|
3
3
|
* win.webContents.send('message', msg) -------------> ipcRenderer.on('message' (e,msg){})
|
|
4
4
|
*/
|
|
5
|
-
const electron = require(
|
|
5
|
+
const electron = require("electron");
|
|
6
6
|
// Initialize remote from the main. Refer to: https://www.npmjs.com/package/@electron/remote/v/2.0.8
|
|
7
|
-
require(
|
|
8
|
-
|
|
9
|
-
const fixPath = require(
|
|
10
|
-
const util = require(
|
|
11
|
-
const path = require(
|
|
12
|
-
const exec = util.promisify(require(
|
|
13
|
-
const
|
|
7
|
+
require("@electron/remote/main").initialize();
|
|
8
|
+
|
|
9
|
+
const fixPath = require("./lib/utils/fix-path.js");
|
|
10
|
+
const util = require("util");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const exec = util.promisify(require("child_process").exec);
|
|
13
|
+
const { spawn, execSync } = require("child_process");
|
|
14
|
+
const request = require("request");
|
|
14
15
|
const requestAsync = util.promisify(request);
|
|
15
|
-
const has = require(
|
|
16
|
+
const has = require("lodash/has");
|
|
16
17
|
|
|
17
18
|
// using electron-updater instead of builtin autoUpdater
|
|
18
19
|
// see why: https://www.electron.build/auto-update
|
|
19
20
|
//const { autoUpdater } = require('electron-updater');
|
|
20
21
|
|
|
21
|
-
const fs = require(
|
|
22
|
+
const fs = require("fs");
|
|
22
23
|
let { app, Menu, ipcMain, shell } = electron;
|
|
23
24
|
|
|
24
|
-
const { appMenu, dockMenu } = require(
|
|
25
|
-
const EditorManager = require(
|
|
26
|
-
const { codegen } = require(
|
|
25
|
+
const { appMenu, dockMenu } = require("./main-process/menu");
|
|
26
|
+
const EditorManager = require("./main-process/editor-manager");
|
|
27
|
+
const { codegen } = require("@kumologica/builder");
|
|
27
28
|
|
|
28
|
-
const MainWindow = require(
|
|
29
|
-
const ModalNewProject = require(
|
|
30
|
-
const ModalHome = require(
|
|
31
|
-
const ModalNewTab = require(
|
|
32
|
-
const ModalRenameTab = require(
|
|
33
|
-
const ModalWelcome = require(
|
|
34
|
-
const EventEmitter = require(
|
|
35
|
-
const ModalNodeLibrary = require(
|
|
29
|
+
const MainWindow = require("./main-process/main-window");
|
|
30
|
+
const ModalNewProject = require("./main-process/modal-newproject");
|
|
31
|
+
const ModalHome = require("./main-process/modal-home");
|
|
32
|
+
const ModalNewTab = require("./main-process/modal-newtab");
|
|
33
|
+
const ModalRenameTab = require("./main-process/modal-renameTab");
|
|
34
|
+
const ModalWelcome = require("./main-process/modal-welcome");
|
|
35
|
+
const EventEmitter = require("events");
|
|
36
|
+
const ModalNodeLibrary = require("./main-process/modal-nodelibrary");
|
|
36
37
|
|
|
37
38
|
const {
|
|
38
39
|
UserPreferenceStore,
|
|
39
40
|
defaultKeys,
|
|
40
|
-
} = require(
|
|
41
|
+
} = require("./lib/stores/user-preference-store");
|
|
41
42
|
|
|
42
43
|
let RUNTIME_PORT;
|
|
43
44
|
|
|
@@ -66,17 +67,17 @@ class WindowsController {
|
|
|
66
67
|
let winController = new WindowsController();
|
|
67
68
|
|
|
68
69
|
// Disable security warnings
|
|
69
|
-
process.env[
|
|
70
|
+
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
|
|
70
71
|
|
|
71
72
|
// ***** Events from 'modal-welcome *****
|
|
72
|
-
ipcMain.on(
|
|
73
|
+
ipcMain.on("modal-welcome:show-dialog-newproject", async () => {
|
|
73
74
|
winController.setKeepAppRunningIfAllWindowsClosed(true);
|
|
74
75
|
currentModalWindow.close();
|
|
75
|
-
const { version } = require(
|
|
76
|
+
const { version } = require("../../package.json");
|
|
76
77
|
|
|
77
78
|
let userDir = codegen.generateInitialCode(
|
|
78
79
|
userPrefStore.getUserDataPath(),
|
|
79
|
-
|
|
80
|
+
"__untitled__",
|
|
80
81
|
null,
|
|
81
82
|
version
|
|
82
83
|
);
|
|
@@ -87,11 +88,11 @@ ipcMain.on('modal-welcome:show-dialog-newproject', async () => {
|
|
|
87
88
|
winController.setKeepAppRunningIfAllWindowsClosed(false);
|
|
88
89
|
});
|
|
89
90
|
|
|
90
|
-
ipcMain.on(
|
|
91
|
+
ipcMain.on("modal-welcome:show-dialog-openproject", async () => {
|
|
91
92
|
let openDialog = electron.dialog;
|
|
92
93
|
let options = {
|
|
93
|
-
title:
|
|
94
|
-
properties: [
|
|
94
|
+
title: "Open project directory",
|
|
95
|
+
properties: ["openDirectory"],
|
|
95
96
|
};
|
|
96
97
|
openDialog
|
|
97
98
|
.showOpenDialog(currentModalWindow.window, options)
|
|
@@ -110,54 +111,54 @@ ipcMain.on('modal-welcome:show-dialog-openproject', async () => {
|
|
|
110
111
|
|
|
111
112
|
// **** Events from "modal-home" ****
|
|
112
113
|
|
|
113
|
-
ipcMain.on(
|
|
114
|
+
ipcMain.on("modal-home:show-dialog-newproject", () => {
|
|
114
115
|
currentModalWindow.close();
|
|
115
116
|
showNewProjectDialog(true);
|
|
116
117
|
});
|
|
117
118
|
|
|
118
|
-
ipcMain.on(
|
|
119
|
+
ipcMain.on("modal-home:show-dialog-openproject", () => {
|
|
119
120
|
currentModalWindow.close();
|
|
120
121
|
showOpenProjectDialog(mainWindow.window);
|
|
121
122
|
});
|
|
122
123
|
|
|
123
|
-
ipcMain.on(
|
|
124
|
+
ipcMain.on("modal-home:open-project-in-editor", async (event, msg) => {
|
|
124
125
|
if (currentModalWindow) currentModalWindow.close();
|
|
125
126
|
await openProjectEditor(msg.payload.projectLocation);
|
|
126
127
|
});
|
|
127
128
|
|
|
128
129
|
// menu events
|
|
129
130
|
|
|
130
|
-
ipcMain.on(
|
|
131
|
-
shell.openExternal(
|
|
131
|
+
ipcMain.on("menu-help-documentation", () => {
|
|
132
|
+
shell.openExternal("https://docs.kumologica.com/docs/guide/Intro.html");
|
|
132
133
|
});
|
|
133
134
|
|
|
134
|
-
ipcMain.on(
|
|
135
|
+
ipcMain.on("menu-help-training-videos", () => {
|
|
135
136
|
shell.openExternal(
|
|
136
|
-
|
|
137
|
+
"https://www.youtube.com/channel/UCsTDAlhijUFpsfThJu3hF9g"
|
|
137
138
|
);
|
|
138
139
|
});
|
|
139
140
|
|
|
140
|
-
ipcMain.on(
|
|
141
|
+
ipcMain.on("menu-help-release-notes", () => {
|
|
141
142
|
shell.openExternal(
|
|
142
|
-
|
|
143
|
+
"https://github.com/KumologicaHQ/kumologica-designer-releases/releases/"
|
|
143
144
|
);
|
|
144
145
|
});
|
|
145
146
|
|
|
146
|
-
ipcMain.on(
|
|
147
|
-
shell.openExternal(
|
|
147
|
+
ipcMain.on("menu-help-join-twitter", () => {
|
|
148
|
+
shell.openExternal("https://twitter.com/kumologica");
|
|
148
149
|
});
|
|
149
150
|
|
|
150
|
-
ipcMain.on(
|
|
151
|
-
shell.openExternal(
|
|
151
|
+
ipcMain.on("menu-help-join-discord", () => {
|
|
152
|
+
shell.openExternal("https://discord.com/invite/HrTCY8zXxM");
|
|
152
153
|
});
|
|
153
154
|
|
|
154
|
-
ipcMain.on(
|
|
155
|
-
shell.openExternal(
|
|
156
|
-
})
|
|
155
|
+
ipcMain.on("kumologica-contact-us", () => {
|
|
156
|
+
shell.openExternal("https://kumologica.com/contact.html");
|
|
157
|
+
});
|
|
157
158
|
|
|
158
159
|
// **** Events from 'NewProject modal' ****
|
|
159
160
|
|
|
160
|
-
ipcMain.on(
|
|
161
|
+
ipcMain.on("modal-projects:close", () => {
|
|
161
162
|
if (currentModalWindow.isCancellable()) {
|
|
162
163
|
currentModalWindow.close();
|
|
163
164
|
} else {
|
|
@@ -167,11 +168,11 @@ ipcMain.on('modal-projects:close', () => {
|
|
|
167
168
|
}
|
|
168
169
|
});
|
|
169
170
|
|
|
170
|
-
ipcMain.on(
|
|
171
|
+
ipcMain.on("modal-projects:create-project", async (event, payload) => {
|
|
171
172
|
const { projectName, projectBaseDir, flow } = payload;
|
|
172
173
|
|
|
173
174
|
app.addRecentDocument(projectBaseDir);
|
|
174
|
-
const { version } = require(
|
|
175
|
+
const { version } = require("../../package.json");
|
|
175
176
|
|
|
176
177
|
currentModalWindow.close();
|
|
177
178
|
const projectDir = codegen.generateInitialCode(
|
|
@@ -185,59 +186,62 @@ ipcMain.on('modal-projects:create-project', async (event, payload) => {
|
|
|
185
186
|
|
|
186
187
|
// Events from menu
|
|
187
188
|
|
|
188
|
-
ipcMain.on(
|
|
189
|
+
ipcMain.on("core:show-import-dialog", () => {
|
|
189
190
|
mainWindow.sendEventToRenderer("core:show-import-dialog");
|
|
190
191
|
});
|
|
191
192
|
|
|
192
|
-
ipcMain.on(
|
|
193
|
+
ipcMain.on("core:show-export-dialog", () => {
|
|
193
194
|
mainWindow.sendEventToRenderer("core:show-export-dialog");
|
|
194
195
|
});
|
|
195
196
|
|
|
196
|
-
ipcMain.on(
|
|
197
|
+
ipcMain.on("core:search", () => {
|
|
197
198
|
mainWindow.sendEventToRenderer("core:search");
|
|
198
199
|
});
|
|
199
200
|
|
|
200
|
-
ipcMain.on(
|
|
201
|
+
ipcMain.on("core:search", () => {
|
|
201
202
|
mainWindow.sendEventToRenderer("core:search");
|
|
202
203
|
});
|
|
203
204
|
|
|
204
|
-
ipcMain.on(
|
|
205
|
+
ipcMain.on("core:toggle-terminal", () => {
|
|
205
206
|
mainWindow.sendEventToRenderer("core:toggle-terminal");
|
|
206
207
|
});
|
|
207
|
-
ipcMain.on(
|
|
208
|
+
ipcMain.on("core:toggle-palette", () => {
|
|
208
209
|
mainWindow.sendEventToRenderer("core:toggle-palette");
|
|
209
210
|
});
|
|
210
|
-
ipcMain.on(
|
|
211
|
+
ipcMain.on("core:view-main-workspace", () => {
|
|
211
212
|
mainWindow.sendEventToRenderer("core:view-main-flow");
|
|
212
213
|
});
|
|
213
|
-
ipcMain.on(
|
|
214
|
+
ipcMain.on("core:view-test-workspace", () => {
|
|
214
215
|
mainWindow.sendEventToRenderer("core:view-test-flow");
|
|
215
216
|
});
|
|
216
|
-
ipcMain.on(
|
|
217
|
+
ipcMain.on("core:view-settings", () => {
|
|
217
218
|
mainWindow.sendEventToRenderer("core:toggle-settings");
|
|
218
219
|
});
|
|
219
220
|
|
|
220
|
-
ipcMain.on(
|
|
221
|
+
ipcMain.on("show-newProject-modal", () => {
|
|
221
222
|
showNewProjectDialog(true);
|
|
222
223
|
});
|
|
223
|
-
ipcMain.on(
|
|
224
|
+
ipcMain.on("show-openProject-dialog", () => {
|
|
224
225
|
showOpenProjectDialog();
|
|
225
226
|
});
|
|
226
227
|
|
|
227
|
-
ipcMain.on(
|
|
228
|
-
event.sender.send(
|
|
228
|
+
ipcMain.on("app_version", (event) => {
|
|
229
|
+
event.sender.send("app_version", { version: app.getVersion() });
|
|
229
230
|
});
|
|
230
|
-
ipcMain.on(
|
|
231
|
+
ipcMain.on("main-header:show-modal-home", () => {
|
|
231
232
|
currentModalWindow = new ModalHome(findRecentProjects());
|
|
232
233
|
currentModalWindow.load();
|
|
233
234
|
});
|
|
234
|
-
ipcMain.on(
|
|
235
|
+
ipcMain.on("navigator:open-new-tab-dialog", () => {
|
|
235
236
|
currentModalWindow = new ModalNewTab(mainWindow.window, true);
|
|
236
237
|
currentModalWindow.load();
|
|
237
238
|
});
|
|
238
|
-
ipcMain.on(
|
|
239
|
+
ipcMain.on("navigator:open-rename-tab-dialog", (event, payload) => {
|
|
239
240
|
const { tabId, oldTabName } = payload;
|
|
240
|
-
currentModalWindow = new ModalRenameTab(mainWindow.window, true, {
|
|
241
|
+
currentModalWindow = new ModalRenameTab(mainWindow.window, true, {
|
|
242
|
+
tabId,
|
|
243
|
+
oldTabName,
|
|
244
|
+
});
|
|
241
245
|
currentModalWindow.load();
|
|
242
246
|
});
|
|
243
247
|
|
|
@@ -245,22 +249,22 @@ ipcMain.on('navigator:open-rename-tab-dialog', (event, payload) => {
|
|
|
245
249
|
|
|
246
250
|
// - Modal window launch event
|
|
247
251
|
|
|
248
|
-
ipcMain.on(
|
|
252
|
+
ipcMain.on("show-node-library-modal", () => {
|
|
249
253
|
currentModalWindow = new ModalNodeLibrary();
|
|
250
254
|
currentModalWindow.load();
|
|
251
255
|
});
|
|
252
256
|
|
|
253
257
|
// Ask for the project directory
|
|
254
|
-
ipcMain.on(
|
|
258
|
+
ipcMain.on("modal-node-library:fetch-installed-nodes", (event, payload) => {
|
|
255
259
|
let results = [];
|
|
256
260
|
let projectDir = EditorManager.getCurrentUserDir();
|
|
257
261
|
try {
|
|
258
|
-
const packageJsonPath = path.join(projectDir,
|
|
259
|
-
let data = fs.readFileSync(packageJsonPath,
|
|
262
|
+
const packageJsonPath = path.join(projectDir, "package.json");
|
|
263
|
+
let data = fs.readFileSync(packageJsonPath, "utf-8");
|
|
260
264
|
const pkg = JSON.parse(data);
|
|
261
265
|
const dependencies = pkg.dependencies;
|
|
262
266
|
results = Object.keys(dependencies).filter((dep) =>
|
|
263
|
-
dep.includes(
|
|
267
|
+
dep.includes("kumologica-contrib")
|
|
264
268
|
);
|
|
265
269
|
} catch (err) {
|
|
266
270
|
console.log(err);
|
|
@@ -268,44 +272,65 @@ ipcMain.on('modal-node-library:fetch-installed-nodes', (event, payload) => {
|
|
|
268
272
|
`package.json file not found in the project directory: ${projectDir}`
|
|
269
273
|
);
|
|
270
274
|
}
|
|
271
|
-
event.sender.send(
|
|
275
|
+
event.sender.send("modal-node-library:fetch-installed-nodes-response", {
|
|
272
276
|
installedNodes: results,
|
|
273
277
|
});
|
|
274
278
|
});
|
|
275
279
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
//
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
//
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
280
|
+
ipcMain.on("modal-node-library:install-package", (event, payload) => {
|
|
281
|
+
// let { command } = payload;
|
|
282
|
+
// let newEnv = {
|
|
283
|
+
// ...process.env,
|
|
284
|
+
// PATH: includeNodePathIntoPath(),
|
|
285
|
+
// };
|
|
286
|
+
// const child = spawn("npm", ["install"], {
|
|
287
|
+
// cwd: EditorManager.getCurrentUserDir(),
|
|
288
|
+
// env: newEnv,
|
|
289
|
+
// });
|
|
290
|
+
// // Stream stdout data
|
|
291
|
+
// child.stdout.on("data", (data) => {
|
|
292
|
+
// window.__kumologica.editor.terminal.eventEmitter.emit(
|
|
293
|
+
// "terminal-output",
|
|
294
|
+
// data.toString()
|
|
295
|
+
// );
|
|
296
|
+
// // console.log(data.toString());
|
|
297
|
+
// });
|
|
298
|
+
// // Stream stderr data
|
|
299
|
+
// child.stderr.on("data", (data) => {
|
|
300
|
+
// console.log(data.toString());
|
|
301
|
+
// });
|
|
302
|
+
// // Handle process exit
|
|
303
|
+
// child.on("close", (code) => {
|
|
304
|
+
// if (code !== 0) {
|
|
305
|
+
// let message =
|
|
306
|
+
// code === 127
|
|
307
|
+
// ? `Command: 'node' could not be found. Please ensure that the NODE_PATH environment variable is correctly set and exported in your system's environment.`
|
|
308
|
+
// : `Command failed with exit code ${code}`;
|
|
309
|
+
// window.__kumologica.editor.terminal.eventEmitter.emit(
|
|
310
|
+
// "terminal-output",
|
|
311
|
+
// `Error: ${message}`
|
|
312
|
+
// );
|
|
313
|
+
// // console.log(error.message);
|
|
314
|
+
// const error = new Error(message);
|
|
315
|
+
// // reject(error);
|
|
316
|
+
// } else {
|
|
317
|
+
// // resolve();
|
|
318
|
+
// }
|
|
319
|
+
// });
|
|
320
|
+
// // Handle execution errors
|
|
321
|
+
// child.on("error", (error) => {
|
|
322
|
+
// console.log(error.message);
|
|
323
|
+
// // reject(error);
|
|
324
|
+
// });
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// Send signal to modal window that we have finished with the installation and a restart is required
|
|
328
|
+
// event.sender.send("modal-node-library:install-package-finished", {
|
|
329
|
+
// source: source,
|
|
330
|
+
// });
|
|
306
331
|
|
|
307
332
|
// - Uninstall package command event
|
|
308
|
-
ipcMain.on(
|
|
333
|
+
ipcMain.on("modal-node-library:uninstall-package", async (event, payload) => {
|
|
309
334
|
let { source } = payload;
|
|
310
335
|
|
|
311
336
|
// Execute the command: npm install <package>
|
|
@@ -314,16 +339,16 @@ ipcMain.on('modal-node-library:uninstall-package', async (event, payload) => {
|
|
|
314
339
|
await exec(npmCmd, { cwd: currentProjectDir });
|
|
315
340
|
|
|
316
341
|
// Send signal to modal window that we have finished with the installation and a restart is required
|
|
317
|
-
event.sender.send(
|
|
342
|
+
event.sender.send("modal-node-library:uninstall-package-finished", {
|
|
318
343
|
source: source,
|
|
319
344
|
});
|
|
320
345
|
});
|
|
321
|
-
ipcMain.on(
|
|
346
|
+
ipcMain.on("restart-requested", async (event, msg) => {
|
|
322
347
|
// reload the nodes available in the palette
|
|
323
348
|
try {
|
|
324
349
|
await requestAsync({
|
|
325
350
|
uri: `http://127.0.0.1:${RUNTIME_PORT}/nodes-reload`,
|
|
326
|
-
method:
|
|
351
|
+
method: "POST",
|
|
327
352
|
json: true,
|
|
328
353
|
});
|
|
329
354
|
} catch (err) {
|
|
@@ -333,13 +358,13 @@ ipcMain.on('restart-requested', async (event, msg) => {
|
|
|
333
358
|
mainWindow.reload();
|
|
334
359
|
});
|
|
335
360
|
|
|
336
|
-
ipcMain.on(
|
|
361
|
+
ipcMain.on("modal-node-library:restart-requested", async (event, msg) => {
|
|
337
362
|
currentModalWindow.close();
|
|
338
363
|
// reload the nodes available in the palette
|
|
339
364
|
try {
|
|
340
365
|
await requestAsync({
|
|
341
366
|
uri: `http://127.0.0.1:${RUNTIME_PORT}/nodes-reload`,
|
|
342
|
-
method:
|
|
367
|
+
method: "POST",
|
|
343
368
|
json: true,
|
|
344
369
|
});
|
|
345
370
|
} catch (err) {
|
|
@@ -349,7 +374,7 @@ ipcMain.on('modal-node-library:restart-requested', async (event, msg) => {
|
|
|
349
374
|
mainWindow.reload();
|
|
350
375
|
});
|
|
351
376
|
|
|
352
|
-
ipcMain.on(
|
|
377
|
+
ipcMain.on("open-new-tab-dialog:close", async (event, payload) => {
|
|
353
378
|
if (currentModalWindow.isCancellable()) {
|
|
354
379
|
currentModalWindow.close();
|
|
355
380
|
} else {
|
|
@@ -359,7 +384,7 @@ ipcMain.on('open-new-tab-dialog:close', async (event, payload) => {
|
|
|
359
384
|
}
|
|
360
385
|
});
|
|
361
386
|
|
|
362
|
-
ipcMain.on(
|
|
387
|
+
ipcMain.on("open-rename-tab-dialog:close", async (event, payload) => {
|
|
363
388
|
if (currentModalWindow.isCancellable()) {
|
|
364
389
|
currentModalWindow.close();
|
|
365
390
|
} else {
|
|
@@ -369,19 +394,18 @@ ipcMain.on('open-rename-tab-dialog:close', async (event, payload) => {
|
|
|
369
394
|
}
|
|
370
395
|
});
|
|
371
396
|
|
|
372
|
-
ipcMain.on(
|
|
397
|
+
ipcMain.on("open-new-tab-dialog:create-tab", async (event, payload) => {
|
|
373
398
|
currentModalWindow.close();
|
|
374
|
-
let tabName = payload[
|
|
375
|
-
mainWindow.sendEventToRenderer(
|
|
399
|
+
let tabName = payload["createTabName"];
|
|
400
|
+
mainWindow.sendEventToRenderer("create-new-tab", { tabName });
|
|
376
401
|
});
|
|
377
402
|
|
|
378
|
-
ipcMain.on(
|
|
403
|
+
ipcMain.on("open-rename-tab-dialog:rename-tab", async (event, payload) => {
|
|
379
404
|
currentModalWindow.close();
|
|
380
405
|
const { tabId, newTabName } = payload;
|
|
381
|
-
mainWindow.sendEventToRenderer(
|
|
406
|
+
mainWindow.sendEventToRenderer("explorer:rename-tab", { tabId, newTabName });
|
|
382
407
|
});
|
|
383
408
|
|
|
384
|
-
|
|
385
409
|
function showNewProjectDialog(cancellable) {
|
|
386
410
|
currentModalWindow = new ModalNewProject(mainWindow.window, cancellable);
|
|
387
411
|
currentModalWindow.load();
|
|
@@ -390,8 +414,8 @@ function showNewProjectDialog(cancellable) {
|
|
|
390
414
|
function showOpenProjectDialog(parent) {
|
|
391
415
|
let openDialog = electron.dialog;
|
|
392
416
|
let options = {
|
|
393
|
-
title:
|
|
394
|
-
properties: [
|
|
417
|
+
title: "Open project directory",
|
|
418
|
+
properties: ["openDirectory"],
|
|
395
419
|
};
|
|
396
420
|
|
|
397
421
|
openDialog.showOpenDialog(parent, options).then(async (result) => {
|
|
@@ -407,30 +431,42 @@ function showOpenProjectDialog(parent) {
|
|
|
407
431
|
function runtimeEventListener(event) {
|
|
408
432
|
// console.log('runtimeEventListener hit with event:', event);
|
|
409
433
|
// runtime events @Terminal
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
|
|
434
|
+
if (
|
|
435
|
+
event &&
|
|
436
|
+
event.id &&
|
|
437
|
+
event.id == "terminal-output" &&
|
|
438
|
+
mainWindow &&
|
|
439
|
+
mainWindow.window &&
|
|
440
|
+
mainWindow.window.webContents
|
|
441
|
+
) {
|
|
442
|
+
mainWindow.window.webContents.send("terminal-output", event);
|
|
413
443
|
}
|
|
414
444
|
// runtime events @tests
|
|
415
|
-
if (
|
|
416
|
-
|
|
445
|
+
if (
|
|
446
|
+
event &&
|
|
447
|
+
event.id &&
|
|
448
|
+
event.id.startsWith("test:") &&
|
|
449
|
+
mainWindow &&
|
|
450
|
+
mainWindow.window &&
|
|
451
|
+
mainWindow.window.webContents
|
|
452
|
+
) {
|
|
417
453
|
mainWindow.window.webContents.send(event.id, event);
|
|
418
454
|
}
|
|
419
455
|
|
|
420
|
-
if (has(event,
|
|
456
|
+
if (has(event, "id") && event.id.startsWith("debugger:")) {
|
|
421
457
|
mainWindow.window.webContents.send(event.id, event);
|
|
422
458
|
}
|
|
423
459
|
}
|
|
424
460
|
|
|
425
461
|
async function openProjectEditor(projectDir, onDidLoad) {
|
|
426
462
|
console.log(`> Node.js version: ${process.versions.node}`);
|
|
427
|
-
console.log(
|
|
463
|
+
console.log("> Project directory:", projectDir);
|
|
428
464
|
|
|
429
465
|
try {
|
|
430
466
|
let startupErrorEvent;
|
|
431
467
|
startupEmitter = new EventEmitter();
|
|
432
468
|
|
|
433
|
-
startupEmitter.on(
|
|
469
|
+
startupEmitter.on("runtime-startup-error", (event) => {
|
|
434
470
|
startupErrorEvent = event;
|
|
435
471
|
});
|
|
436
472
|
|
|
@@ -441,11 +477,11 @@ async function openProjectEditor(projectDir, onDidLoad) {
|
|
|
441
477
|
// otherwise, we will have duplicated listeners on runtime-events
|
|
442
478
|
// causing the events to trigger multiple times.
|
|
443
479
|
EditorManager.appServer.events.removeAllListeners(
|
|
444
|
-
|
|
480
|
+
"runtime-event",
|
|
445
481
|
runtimeEventListener
|
|
446
482
|
);
|
|
447
483
|
|
|
448
|
-
EditorManager.appServer.events.on(
|
|
484
|
+
EditorManager.appServer.events.on("runtime-event", runtimeEventListener);
|
|
449
485
|
|
|
450
486
|
if (mainWindow) {
|
|
451
487
|
// Updating the project information
|
|
@@ -464,7 +500,7 @@ async function openProjectEditor(projectDir, onDidLoad) {
|
|
|
464
500
|
app.addRecentDocument(projectDir);
|
|
465
501
|
|
|
466
502
|
if (startupErrorEvent) {
|
|
467
|
-
ipcMain.emit(
|
|
503
|
+
ipcMain.emit("runtime-startup-error", startupErrorEvent);
|
|
468
504
|
}
|
|
469
505
|
} catch (err) {
|
|
470
506
|
// throw err;
|
|
@@ -479,11 +515,11 @@ async function openProjectEditor(projectDir, onDidLoad) {
|
|
|
479
515
|
|
|
480
516
|
let openDialog = electron.dialog;
|
|
481
517
|
let options = {
|
|
482
|
-
type:
|
|
483
|
-
buttons: [
|
|
518
|
+
type: "error",
|
|
519
|
+
buttons: ["OK"],
|
|
484
520
|
message: `Kumologica Designer is unable to open project`,
|
|
485
521
|
detail: `${err}`,
|
|
486
|
-
icon: electron.nativeImage.createEmpty()
|
|
522
|
+
icon: electron.nativeImage.createEmpty(),
|
|
487
523
|
};
|
|
488
524
|
openDialog.showMessageBoxSync(parentWindow, options, async (response) => {
|
|
489
525
|
// no need to do anything, the runtime has already been recovered with a safe userDir
|
|
@@ -501,11 +537,11 @@ async function openWelcomePage() {
|
|
|
501
537
|
// There is no project recently opened - we will create one just to kick the runtime
|
|
502
538
|
// This project will be created in the dataPath of the store:
|
|
503
539
|
// ~/Library/Application Support/Kumologica
|
|
504
|
-
const { version } = require(
|
|
540
|
+
const { version } = require("../../package.json");
|
|
505
541
|
|
|
506
542
|
let userDir = codegen.generateInitialCode(
|
|
507
543
|
userPrefStore.getUserDataPath(),
|
|
508
|
-
|
|
544
|
+
"__untitled__",
|
|
509
545
|
null,
|
|
510
546
|
version
|
|
511
547
|
);
|
|
@@ -552,7 +588,7 @@ function findLatestProject() {
|
|
|
552
588
|
// This method will be called when Electron has finished
|
|
553
589
|
// initialization and is ready to create browser windows.
|
|
554
590
|
// Some APIs can only be used after this event occurs.
|
|
555
|
-
app.on(
|
|
591
|
+
app.on("ready", async () => {
|
|
556
592
|
Menu.setApplicationMenu(appMenu);
|
|
557
593
|
if (app.dock) {
|
|
558
594
|
app.dock.setMenu(dockMenu);
|
|
@@ -584,14 +620,14 @@ app.on('ready', async () => {
|
|
|
584
620
|
});
|
|
585
621
|
|
|
586
622
|
// event triggered from open recent api
|
|
587
|
-
app.on(
|
|
623
|
+
app.on("open-file", (event, path) => {
|
|
588
624
|
event.preventDefault();
|
|
589
625
|
openProjectEditor(path, true);
|
|
590
626
|
});
|
|
591
627
|
|
|
592
628
|
// Called before quitting...gives us an opportunity to shutdown the child process
|
|
593
|
-
app.on(
|
|
594
|
-
console.log(
|
|
629
|
+
app.on("before-quit", async () => {
|
|
630
|
+
console.log("> Gracefully shutting down...");
|
|
595
631
|
|
|
596
632
|
// Kill the web process
|
|
597
633
|
await EditorManager.stop();
|
|
@@ -601,7 +637,7 @@ app.on('before-quit', async () => {
|
|
|
601
637
|
});
|
|
602
638
|
|
|
603
639
|
// Quit when all windows are closed.
|
|
604
|
-
app.on(
|
|
640
|
+
app.on("window-all-closed", function () {
|
|
605
641
|
if (!winController.isKeepRunning()) {
|
|
606
642
|
//recreateWindowRequired = true;
|
|
607
643
|
// mainWindow.window.destroy();
|
|
@@ -616,7 +652,7 @@ app.on('window-all-closed', function () {
|
|
|
616
652
|
}
|
|
617
653
|
});
|
|
618
654
|
|
|
619
|
-
app.on(
|
|
655
|
+
app.on("activate", function () {
|
|
620
656
|
// On OS X it's common to re-create a window in the app when the
|
|
621
657
|
// dock icon is clicked and there are no other windows open.
|
|
622
658
|
if (mainWindow === null) {
|
|
@@ -641,8 +677,8 @@ autoUpdater.on('update-available', () => {
|
|
|
641
677
|
});
|
|
642
678
|
*/
|
|
643
679
|
|
|
644
|
-
process.on(
|
|
680
|
+
process.on("SIGINT", function () {
|
|
645
681
|
//graceful shutdown
|
|
646
|
-
console.log(
|
|
682
|
+
console.log("SIGNINT SENT");
|
|
647
683
|
process.exit();
|
|
648
684
|
});
|