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