@daisy/ace-axe-runner-electron 1.2.5 → 1.2.6-alpha.5

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/lib/init.js CHANGED
@@ -1,8 +1,31 @@
1
1
  'use strict';
2
2
 
3
+ // TOO LATE FOR JEST RUNNER DUE TO AFTER ELECTRON APP.READY!
4
+ // (see package.json patcher script "patchElectronJestRunner3")
5
+ // // NO_HTTP_ADD
6
+ // const electron = require('electron');
7
+ // const protocol = electron.protocol;
8
+ // const ACE_ELECTRON_HTTP_PROTOCOL = "acehttps";
9
+ // // app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
10
+ // protocol.registerSchemesAsPrivileged([{
11
+ // privileges: {
12
+ // allowServiceWorkers: false,
13
+ // bypassCSP: false,
14
+ // corsEnabled: true,
15
+ // secure: true,
16
+ // standard: true,
17
+ // stream: true,
18
+ // supportFetchAPI: true,
19
+ // },
20
+ // scheme: ACE_ELECTRON_HTTP_PROTOCOL,
21
+ // }]);
22
+
23
+ const mime = require('mime-types');
24
+
25
+ const nodeStream = require('stream');
26
+
3
27
  const path = require('path');
4
28
  const fs = require('fs');
5
- const url = require('url');
6
29
 
7
30
  const electron = require('electron');
8
31
  const app = electron.app;
@@ -13,13 +36,6 @@ const BrowserWindow = electron.BrowserWindow;
13
36
 
14
37
  const fsOriginal = require('original-fs');
15
38
 
16
- const express = require('express');
17
- const portfinder = require('portfinder');
18
- // const http = require('http');
19
- const https = require('https');
20
-
21
- const generateSelfSignedData = require('./selfsigned').generateSelfSignedData;
22
-
23
39
  const isDev = process && process.env && (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true');
24
40
  const showWindow = false;
25
41
 
@@ -32,16 +48,28 @@ const SESSION_PARTITION = "persist:axe";
32
48
 
33
49
  const HTTP_QUERY_PARAM = "AXE_RUNNER";
34
50
 
35
- let expressApp;
36
- let httpServer;
37
- let port;
38
- let ip;
39
- let proto;
40
- let rootUrl;
41
-
51
+ const ACE_ELECTRON_HTTP_PROTOCOL = "acehttps";
52
+
53
+ // NO_HTTP_REMOVE
54
+ // const express = require('express');
55
+ // const portfinder = require('portfinder');
56
+ // // const http = require('http');
57
+ // const https = require('https');
58
+ // const generateSelfSignedData = require('./selfsigned').generateSelfSignedData;
59
+ // let expressApp;
60
+ // let httpServer;
61
+ // let port;
62
+ // let ip;
63
+ // let proto;
64
+ // let rootUrl;
42
65
  let httpServerStartWasRequested = false;
43
66
  let httpServerStarted = false;
44
67
 
68
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner ELECTRON MODULE INSTANCE`);
69
+
70
+ // NO_HTTP_ADD
71
+ const rootUrl = `${ACE_ELECTRON_HTTP_PROTOCOL}://0.0.0.0`;
72
+
45
73
  let browserWindows = undefined;
46
74
 
47
75
  const jsCache = {};
@@ -50,6 +78,120 @@ let _firstTimeInit = true;
50
78
 
51
79
  let iHttpReq = 0;
52
80
 
81
+ // NO_HTTP_ADD
82
+ class BufferReadableStream extends nodeStream.Readable {
83
+ constructor(buffer) {
84
+ super();
85
+ this.buffer = buffer;
86
+ this.alreadyRead = 0;
87
+ }
88
+ _read(size) {
89
+ if (this.alreadyRead >= this.buffer.length) {
90
+ this.push(null);
91
+ return;
92
+ }
93
+
94
+ let chunk = this.alreadyRead ? this.buffer.slice(this.alreadyRead) : this.buffer;
95
+
96
+ if (size) {
97
+ let l = size;
98
+ if (size > chunk.length) {
99
+ l = chunk.length;
100
+ }
101
+
102
+ chunk = chunk.slice(0, l);
103
+ }
104
+
105
+ this.alreadyRead += chunk.length;
106
+ this.push(chunk);
107
+ }
108
+ }
109
+ function bufferToStream(buffer) {
110
+ return new BufferReadableStream(buffer);
111
+ }
112
+
113
+ let _streamProtocolHandler = undefined;
114
+ const streamProtocolHandler = async (req, callback) => {
115
+
116
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} streamProtocolHandler req.url: ${req.url}`);
117
+ const u = new URL(req.url);
118
+
119
+ if (LOG_DEBUG) {
120
+ Object.keys(req.headers).forEach(header => {
121
+ const val = req.headers[header];
122
+
123
+ console.log(`${ACE_LOG_PREFIX} streamProtocolHandler req.header: ${header} => ${val}`);
124
+
125
+ // if (val) {
126
+ // headers[header] = val;
127
+ // }
128
+ });
129
+ }
130
+
131
+ let ref = u.origin;
132
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} streamProtocolHandler u.origin: ${ref}`);
133
+ if (req.referrer && req.referrer.trim()) {
134
+ ref = req.referrer;
135
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} streamProtocolHandler req.referrer: ${ref}`);
136
+ }
137
+
138
+ const headers = {};
139
+
140
+ if (ref && ref !== "null" && !/^https?:\/\/localhost.+/.test(ref) && !/^https?:\/\/127\.0\.0\.1.+/.test(ref)) {
141
+ headers.referer = ref;
142
+ } else {
143
+ headers.referer = `${ACE_ELECTRON_HTTP_PROTOCOL}://0.0.0.0/`;
144
+ }
145
+
146
+ // CORS everything!
147
+ headers["Access-Control-Allow-Origin"] = "*";
148
+ headers["Access-Control-Allow-Methods"] = "GET, HEAD, OPTIONS"; // POST, DELETE, PUT, PATCH
149
+ // tslint:disable-next-line:max-line-length
150
+ headers["Access-Control-Allow-Headers"] = "Content-Type, Content-Length, Accept-Ranges, Content-Range, Range, Link, Transfer-Encoding, X-Requested-With, Authorization, Accept, Origin, User-Agent, DNT, Cache-Control, Keep-Alive, If-Modified-Since";
151
+ // tslint:disable-next-line:max-line-length
152
+ headers["Access-Control-Expose-Headers"] = "Content-Type, Content-Length, Accept-Ranges, Content-Range, Range, Link, Transfer-Encoding, X-Requested-With, Authorization, Accept, Origin, User-Agent, DNT, Cache-Control, Keep-Alive, If-Modified-Since";
153
+
154
+ if (!_streamProtocolHandler) {
155
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} !? _streamProtocolHandler`);
156
+
157
+ const buff = Buffer.from("<html><body><p>Internal Server Error</p><p>!_streamProtocolHandler</p></body></html>");
158
+ headers["Content-Length"] = buff.length.toString();
159
+ callback({
160
+ data: bufferToStream(buff),
161
+ headers,
162
+ statusCode: 500
163
+ });
164
+ return;
165
+ }
166
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} BEFORE _streamProtocolHandler ${req.url}`);
167
+ await _streamProtocolHandler(req, callback, headers);
168
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} AFTER _streamProtocolHandler ${req.url}`);
169
+ };
170
+ app.whenReady().then(async () => {
171
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} Electron app ready`);
172
+
173
+ // try {
174
+ // await clearSessions();
175
+ // } catch (err) {
176
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} clearSessions fail?`);
177
+ // }
178
+
179
+ // if (session.defaultSession) {
180
+ // session.defaultSession.protocol.registerStreamProtocol(
181
+ // ACE_ELECTRON_HTTP_PROTOCOL,
182
+ // streamProtocolHandler);
183
+ // }
184
+ const sess = session.fromPartition(SESSION_PARTITION, { cache: true });
185
+ if (sess) {
186
+ sess.protocol.registerStreamProtocol(ACE_ELECTRON_HTTP_PROTOCOL, streamProtocolHandler);
187
+
188
+ sess.setPermissionRequestHandler((wc, permission, callback) => {
189
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} setPermissionRequestHandler ${wc.getURL()} => ${permission}`);
190
+ callback(true);
191
+ });
192
+ }
193
+ });
194
+
53
195
  function loadUrl(browserWindow) {
54
196
  browserWindow.ace__loadUrlPending = undefined;
55
197
 
@@ -151,6 +293,8 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
151
293
  }
152
294
  axeRunnerInit.todo = false;
153
295
 
296
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunnerInit TODO ...`);
297
+
154
298
  const firstTimeInit = _firstTimeInit;
155
299
  _firstTimeInit = false;
156
300
 
@@ -171,8 +315,9 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
171
315
  webSecurity: true,
172
316
  webviewTag: false,
173
317
  enableRemoteModule: false,
174
- partition: SESSION_PARTITION,
175
- nativeWindowOpen: false // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
318
+ partition: SESSION_PARTITION
319
+ // (electron) Deprecation Warning: Disabling nativeWindowOpen is deprecated. The nativeWindowOpen option will be removed in Electron 18.
320
+ // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
176
321
  }
177
322
  });
178
323
 
@@ -182,7 +327,13 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
182
327
  browserWindow.webContents.session.webRequest.onBeforeRequest({
183
328
  urls: []
184
329
  }, (details, callback) => {
185
- if (details.url && /^https?:\/\//.test(details.url) && (rootUrl && !details.url.startsWith(rootUrl) || !rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))) {
330
+ if (details.url && (/^file:\/\//.test(details.url) || /^https?:\/\//.test(details.url)
331
+ // && (
332
+ // (rootUrl && !details.url.startsWith(rootUrl))
333
+ // ||
334
+ // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
335
+ // )
336
+ )) {
186
337
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} onBeforeRequest BLOCK: ${details.url} (${rootUrl})`);
187
338
 
188
339
  // causes ERR_BLOCKED_BY_CLIENT -20 did-fail-load
@@ -224,15 +375,18 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
224
375
  return;
225
376
  }
226
377
 
227
- app.on("certificate-error", (event, webContents, u, error, certificate, callback) => {
228
- if (u.indexOf(`${rootUrl}/`) === 0) {
229
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert error OKAY ${u}`);
230
- callback(true);
231
- return;
232
- }
233
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert error FAIL ${u}`);
234
- callback(false);
235
- });
378
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunnerInit firstTimeInit ...`);
379
+
380
+ // NO_HTTP_REMOVE
381
+ // app.on("certificate-error", (event, webContents, u, error, certificate, callback) => {
382
+ // if (u.indexOf(`${rootUrl}/`) === 0) {
383
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert error OKAY ${u}`);
384
+ // callback(true);
385
+ // return;
386
+ // }
387
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert error FAIL ${u}`);
388
+ // callback(false);
389
+ // });
236
390
 
237
391
  // const filter = { urls: ["*", "*://*/*"] };
238
392
 
@@ -257,25 +411,23 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
257
411
  // }
258
412
  // };
259
413
 
260
- const setCertificateVerifyProcCB = (request, callback) => {
261
-
262
- if (request.hostname === ip) {
263
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert verify OKAY ${request.hostname}`);
264
- callback(0); // OK
265
- return;
266
- }
267
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert verify FALLBACK ${request.hostname}`);
268
- callback(-3); // Chromium
269
- // callback(-2); // Fail
270
- };
271
-
272
- const sess = session.fromPartition(SESSION_PARTITION, { cache: true }); // || session.defaultSession;
273
-
274
- if (sess) {
275
- // sess.webRequest.onHeadersReceived(filter, onHeadersReceivedCB);
276
- // sess.webRequest.onBeforeSendHeaders(filter, onBeforeSendHeadersCB);
277
- sess.setCertificateVerifyProc(setCertificateVerifyProcCB);
278
- }
414
+ // NO_HTTP_REMOVE
415
+ // const setCertificateVerifyProcCB = (request, callback) => {
416
+ // if (request.hostname === ip) {
417
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert verify OKAY ${request.hostname}`);
418
+ // callback(0); // OK
419
+ // return;
420
+ // }
421
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTPS cert verify FALLBACK ${request.hostname}`);
422
+ // callback(-3); // Chromium
423
+ // // callback(-2); // Fail
424
+ // };
425
+ // const sess = session.fromPartition(SESSION_PARTITION, { cache: true }); // || session.defaultSession;
426
+ // if (sess) {
427
+ // // sess.webRequest.onHeadersReceived(filter, onHeadersReceivedCB);
428
+ // // sess.webRequest.onBeforeSendHeaders(filter, onBeforeSendHeadersCB);
429
+ // sess.setCertificateVerifyProc(setCertificateVerifyProcCB);
430
+ // }
279
431
 
280
432
  // ipcMain
281
433
  eventEmmitter.on('AXE_RUNNER_CLOSE', (event, arg) => {
@@ -300,13 +452,17 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
300
452
  }
301
453
  browserWindows = undefined;
302
454
 
455
+ // NO_HTTP_ADD
456
+ _streamProtocolHandler = undefined;
457
+
303
458
  httpServerStarted = false;
304
459
  httpServerStartWasRequested = false;
305
460
 
306
- if (httpServer) {
307
- httpServer.close();
308
- httpServer = undefined;
309
- }
461
+ // NO_HTTP_REMOVE
462
+ // if (httpServer) {
463
+ // httpServer.close();
464
+ // httpServer = undefined;
465
+ // }
310
466
 
311
467
  let _timeOutID = setTimeout(() => {
312
468
  _timeOutID = undefined;
@@ -338,6 +494,7 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
338
494
  }
339
495
  }
340
496
 
497
+ // clearSessions()
341
498
  const sess = session.fromPartition(SESSION_PARTITION, { cache: true }); // || session.defaultSession;
342
499
  if (sess) {
343
500
  setTimeout(async () => {
@@ -382,7 +539,8 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
382
539
  console.log(uarel);
383
540
  }
384
541
  // windows! file://C:\aa\bb\chapter.xhtml
385
- const uarelObj = url.parse(uarel.replace(/\\/g, "/"));
542
+
543
+ const uarelObj = new URL(uarel.replace(/\\/g, "/"));
386
544
  const windowsDrive = uarelObj.hostname ? `${uarelObj.hostname.toUpperCase()}:` : "";
387
545
  if (LOG_DEBUG_URLS) {
388
546
  console.log("######## URL 2");
@@ -429,8 +587,6 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
429
587
  return;
430
588
  }
431
589
 
432
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner free browser window in pool: ${browserWindow.ace__poolIndex}`);
433
-
434
590
  browserWindow.ace__eventEmmitterSender = sender;
435
591
  browserWindow.ace__replySent = false;
436
592
  browserWindow.ace__timeout = undefined;
@@ -438,13 +594,15 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
438
594
  browserWindow.ace__currentUrlOriginal = uarel;
439
595
  browserWindow.ace__currentUrl = httpUrl;
440
596
 
597
+ if (LOG_DEBUG) console.log(`\n\n${ACE_LOG_PREFIX} axeRunner free browser window in pool: ${browserWindow.ace__poolIndex} ${browserWindow.ace__previousUrl} ${browserWindow.ace__currentUrlOriginal} ${browserWindow.ace__currentUrl}\n\n`);
598
+
441
599
  browserWindow.webContents.once("did-start-loading", () => {
442
600
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner did-start-loading ${browserWindow.ace__poolIndex} ${browserWindow.ace__currentUrlOriginal} --- ${browserWindow.ace__currentUrl}`);
443
601
  });
444
602
  // browserWindow.webContents.once("did-stop-loading", () => {
445
603
  // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner did-stop-loading ${browserWindow.ace__poolIndex} ${browserWindow.ace__currentUrlOriginal} --- ${browserWindow.ace__currentUrl}`);
446
604
  // });
447
- browserWindow.webContents.once("did-fail-load", (event, errorCode, errorDescription, validatedURL, isMainFrame, frameProcessId, frameRoutingId) => {
605
+ const didFailLoadHandler = (event, errorCode, errorDescription, validatedURL, isMainFrame, frameProcessId, frameRoutingId) => {
448
606
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner did-fail-load ${browserWindow.ace__poolIndex} ${browserWindow.ace__currentUrlOriginal} --- ${browserWindow.ace__currentUrl}`, "\n", `${errorCode} - ${errorDescription} - ${validatedURL} - ${isMainFrame} - ${frameProcessId} - ${frameRoutingId}`);
449
607
 
450
608
  // https://cs.chromium.org/chromium/src/net/base/net_error_list.h
@@ -469,11 +627,16 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
469
627
  err: `did-fail-load: ${errorCode} - ${errorDescription} - ${validatedURL} - ${isMainFrame} - ${frameProcessId} - ${frameRoutingId}`,
470
628
  url: browserWindow.ace__currentUrlOriginal
471
629
  });
472
- });
630
+ };
631
+ browserWindow.webContents.once("did-fail-load", didFailLoadHandler);
473
632
  // browserWindow.webContents.once("dom-ready", () => { // occurs early
474
633
  // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner dom-ready ${browserWindow.ace__poolIndex} ${browserWindow.ace__currentUrlOriginal} --- ${browserWindow.ace__currentUrl}`);
475
634
  // });
476
635
  browserWindow.webContents.once("did-finish-load", () => {
636
+ // browserWindow.webContents.setMaxListeners(11+) ?
637
+ // (node:5505) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 did-fail-load listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
638
+ browserWindow.webContents.removeListener("did-fail-load", didFailLoadHandler);
639
+
477
640
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner did-finish-load ${browserWindow.ace__poolIndex} ${browserWindow.ace__currentUrlOriginal} --- ${browserWindow.ace__currentUrl}`);
478
641
 
479
642
  browserWindow.ace__TIME_executeJavaScript = process.hrtime();
@@ -562,7 +725,7 @@ new Promise((resolve, reject) => {
562
725
  } else {
563
726
  browserWindow.ace__loadUrlPending = httpUrl;
564
727
  }
565
- }
728
+ } // poolPush()
566
729
 
567
730
  if (!httpServerStartWasRequested) {
568
731
  // lazy init
@@ -572,19 +735,30 @@ new Promise((resolve, reject) => {
572
735
 
573
736
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner starting server ...`);
574
737
 
575
- startAxeServer(basedir, scripts, scriptContents).then(() => {
576
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner server started`);
577
- httpServerStarted = true;
578
-
579
- poolCheck();
580
- }).catch(err => {
738
+ // NO_HTTP_ADD
739
+ try {
740
+ startAxeServer(basedir, scripts, scriptContents);
741
+ } catch (err) {
581
742
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner server error`);
582
743
  console.log(err);
583
744
  browserWindow.ace__eventEmmitterSender.send("AXE_RUNNER_RUN_", {
584
745
  err,
585
746
  url: browserWindow.ace__currentUrlOriginal
586
747
  });
587
- });
748
+ return;
749
+ }
750
+
751
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner server started`);
752
+ httpServerStarted = true;
753
+ poolCheck();
754
+
755
+ // NO_HTTP_REMOVE
756
+ // startAxeServer(basedir, scripts, scriptContents).then(() => {
757
+ // // ...
758
+ // httpServerStarted = true;
759
+ // }).catch((err) => {
760
+ // // ...
761
+ // });
588
762
  } else {
589
763
  poolPush();
590
764
  }
@@ -592,232 +766,362 @@ new Promise((resolve, reject) => {
592
766
  }
593
767
  axeRunnerInit.todo = true;
594
768
 
595
- const filePathsExpressStaticNotExist = {};
769
+ // const filePathsExpressStaticNotExist = {};
596
770
  function startAxeServer(basedir, scripts, scriptContents) {
597
771
 
598
- return new Promise((resolve, reject) => {
772
+ // NO_HTTP_REMOVE
773
+ // return new Promise((resolve, reject) => {
599
774
 
600
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner startAxeServer...`);
775
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner startAxeServer...`);
601
776
 
602
- let scriptsMarkup = "";
603
- scriptContents.forEach(scriptCode => {
604
- scriptsMarkup += `<script data-ace="" type="text/javascript">
777
+ let scriptsMarkup = "";
778
+ scriptContents.forEach(scriptCode => {
779
+ scriptsMarkup += `<script data-ace="" type="text/javascript">
605
780
  // <![CDATA[
606
781
  ${scriptCode}
607
782
  // ]]>
608
783
  </script>`;
609
- });
610
- scripts.forEach(scriptPath => {
611
- const filename = path.basename(scriptPath);
612
- scriptsMarkup += `<script data-ace="" src="/${HTTP_QUERY_PARAM}/${filename}"> </script>`;
613
- });
784
+ });
785
+ scripts.forEach(scriptPath => {
786
+ const filename = path.basename(scriptPath);
787
+ scriptsMarkup += `<script data-ace="" src="/${HTTP_QUERY_PARAM}/${filename}"> </script>`;
788
+ });
614
789
 
615
- expressApp = express();
616
- // expressApp.enable('strict routing');
617
-
618
- // expressApp.use("/", (req, res, next) => {
619
- // if (LOG_DEBUG) console.log("HTTP: " + req.url);
620
- // next();
621
- // });
622
-
623
- expressApp.basedir = basedir;
624
- expressApp.use("/", (req, res, next) => {
625
-
626
- for (const scriptPath of scripts) {
627
- const filename = path.basename(scriptPath);
628
- if (req.url.endsWith(`${HTTP_QUERY_PARAM}/${filename}`)) {
629
- let js = jsCache[scriptPath];
630
- if (!js) {
631
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP loading ${scriptPath}`);
632
- js = fs.readFileSync(scriptPath, { encoding: "utf8" });
633
- // if (LOG_DEBUG) console.log(js);
634
- jsCache[scriptPath] = js;
635
- } else {
636
- // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP already loaded ${scriptPath}`);
637
- }
638
- res.setHeader("Content-Type", "text/javascript");
639
- res.send(js);
640
- return;
790
+ // NO_HTTP_ADD
791
+ _streamProtocolHandler = async (req, callback, headers) => {
792
+ const u = new URL(req.url);
793
+
794
+ for (const scriptPath of scripts) {
795
+ const filename = path.basename(scriptPath);
796
+ if (req.url.endsWith(`${HTTP_QUERY_PARAM}/${filename}`)) {
797
+ let js = jsCache[scriptPath];
798
+ if (!js) {
799
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP loading ${scriptPath}`);
800
+ js = fs.readFileSync(scriptPath, { encoding: "utf8" });
801
+ // if (LOG_DEBUG) console.log(js);
802
+ jsCache[scriptPath] = js;
803
+ } else {
804
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP already loaded ${scriptPath}`);
641
805
  }
806
+ const buff = Buffer.from(js);
807
+ headers["Content-Length"] = buff.length.toString();
808
+ headers["Content-Type"] = "text/javascript";
809
+ callback({
810
+ data: bufferToStream(buff),
811
+ headers,
812
+ statusCode: 200
813
+ });
814
+ return;
642
815
  }
816
+ }
643
817
 
644
- if (req.query[HTTP_QUERY_PARAM]) {
645
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP intercept ${req.url}`);
818
+ const queryParam = u.searchParams.get(HTTP_QUERY_PARAM) || undefined;
819
+ if (queryParam) {
820
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP intercept ${req.url}`);
646
821
 
647
- if (LOG_DEBUG_URLS) {
648
- console.log(">>>>>>>>>> URL 1");
649
- console.log(req.url);
650
- }
651
- const ptn = url.parse(req.url).pathname;
652
- if (LOG_DEBUG_URLS) {
653
- console.log(">>>>>>>>>> URL 2");
654
- console.log(ptn);
655
- }
656
- const pn = decodeURI(ptn);
657
- if (LOG_DEBUG_URLS) {
658
- console.log(">>>>>>>>>> URL 3");
659
- console.log(pn);
660
- }
661
- let fileSystemPath = path.join(expressApp.basedir, pn);
662
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
822
+ if (LOG_DEBUG_URLS) {
823
+ console.log(">>>>>>>>>> URL 1");
824
+ console.log(req.url);
825
+ }
826
+ const ptn = u.pathname;
827
+ if (LOG_DEBUG_URLS) {
828
+ console.log(">>>>>>>>>> URL 2");
829
+ console.log(ptn);
830
+ }
831
+ const pn = decodeURI(ptn);
832
+ if (LOG_DEBUG_URLS) {
833
+ console.log(">>>>>>>>>> URL 3");
834
+ console.log(pn);
835
+ }
836
+
837
+ let fileSystemPath = path.join(basedir, pn);
838
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
839
+ if (!fs.existsSync(fileSystemPath)) {
840
+ fileSystemPath = pn;
841
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
663
842
  if (!fs.existsSync(fileSystemPath)) {
664
- fileSystemPath = pn;
665
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
843
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} FILE DOES NOT EXIST!! ${fileSystemPath}`);
844
+
845
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
846
+ headers["Content-Length"] = buff.length.toString();
847
+ callback({
848
+ data: bufferToStream(buff),
849
+ headers,
850
+ statusCode: 404
851
+ });
852
+ return;
666
853
  }
854
+ }
667
855
 
668
- // let html = fs.readFileSync(fileSystemPath, { encoding: "utf8" });
669
- fs.readFile(fileSystemPath, { encoding: "utf8" }, (err, html) => {
670
- if (err) {
671
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML file load??! ${req.url}`);
672
- res.status(404).end();
673
- return;
674
- }
856
+ // let html = fs.readFileSync(fileSystemPath, { encoding: "utf8" });
857
+ fs.readFile(fileSystemPath, { encoding: "utf8" }, (err, html) => {
858
+ if (err) {
859
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML file load??! ${req.url}`);
860
+ callback({
861
+ data: null,
862
+ headers,
863
+ statusCode: 404
864
+ });
865
+ return;
866
+ }
675
867
 
676
- // if (LOG_DEBUG) console.log(html);
868
+ // if (LOG_DEBUG) console.log(html);
677
869
 
678
- if (html.match(/<\/head>/)) {
679
- html = html.replace(/<\/head>/, `${scriptsMarkup}</head>`);
680
- } else if (html.match(/<\/body>/)) {
681
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML no </head>? (using </body>) ${req.url}`);
682
- html = html.replace(/<\/body>/, `${scriptsMarkup}</body>`);
683
- } else {
684
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML neither </head> nor </body>?! ${req.url}`);
685
- }
870
+ if (html.match(/<\/head>/)) {
871
+ html = html.replace(/<\/head>/, `${scriptsMarkup}</head>`);
872
+ } else if (html.match(/<\/body>/)) {
873
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML no </head>? (using </body>) ${req.url}`);
874
+ html = html.replace(/<\/body>/, `${scriptsMarkup}</body>`);
875
+ } else {
876
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTML neither </head> nor </body>?! ${req.url}`);
877
+ }
686
878
 
687
- res.setHeader("Content-Type", "application/xhtml+xml");
688
- res.send(html);
879
+ const buff = Buffer.from(html);
880
+ headers["Content-Length"] = buff.length.toString();
881
+ headers["Content-Type"] = "application/xhtml+xml";
882
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} CALLBACK HEADERS ${req.url} ${JSON.stringify(headers)}`);
883
+ callback({
884
+ data: bufferToStream(buff),
885
+ headers,
886
+ statusCode: 200
689
887
  });
690
- return;
691
- }
888
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} POST-CALLBACK ${req.url}`);
889
+ });
890
+ return;
891
+ }
692
892
 
693
- next();
694
- });
893
+ // equivalent to Express static:
695
894
 
696
- if (isDev) {
697
- // handle WebInspector JS maps etc.
698
- expressApp.use("/", (req, res, next) => {
699
- // const url = new URL(`https://fake.org${req.url}`);
700
- // const pathname = url.pathname;
701
- const pathname = decodeURI(url.parse(req.url).pathname);
895
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} Express static emulate: ${req.url}`);
702
896
 
703
- const filePath = path.join(basedir, pathname);
704
- if (filePathsExpressStaticNotExist[filePath]) {
705
- res.status(404).send(filePathsExpressStaticNotExist[filePath]);
706
- return;
707
- }
708
- fsOriginal.exists(filePath, exists => {
709
- if (exists) {
710
- fsOriginal.readFile(filePath, undefined, (err, data) => {
711
- if (err) {
712
- if (LOG_DEBUG) {
713
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
714
- }
715
- filePathsExpressStaticNotExist[filePath] = err.toString();
716
- res.status(404).send(filePathsExpressStaticNotExist[filePath]);
717
- } else {
718
- // if (LOG_DEBUG) {
719
- // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
720
- // }
721
- next();
722
- // res.send(data);
723
- }
724
- });
725
- } else {
726
- fs.exists(filePath, exists => {
727
- if (exists) {
728
- fs.readFile(filePath, undefined, (err, data) => {
729
- if (err) {
730
- if (LOG_DEBUG) {
731
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
732
- }
733
- filePathsExpressStaticNotExist[filePath] = err.toString();
734
- res.status(404).send(filePathsExpressStaticNotExist[filePath]);
735
- } else {
736
- if (LOG_DEBUG) {
737
- console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
738
- }
739
- next();
740
- // res.send(data);
741
- }
742
- });
743
- } else {
744
- if (LOG_DEBUG) {
745
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
746
- }
747
- res.status(404).end();
748
- }
749
- });
750
- }
897
+ if (LOG_DEBUG_URLS) {
898
+ console.log(">>>>>>>>>>- URL 1");
899
+ console.log(req.url);
900
+ }
901
+ const ptn = u.pathname;
902
+ if (LOG_DEBUG_URLS) {
903
+ console.log(">>>>>>>>>>- URL 2");
904
+ console.log(ptn);
905
+ }
906
+ const pn = decodeURI(ptn);
907
+ if (LOG_DEBUG_URLS) {
908
+ console.log(">>>>>>>>>>- URL 3");
909
+ console.log(pn);
910
+ }
911
+ let fileSystemPath = path.join(basedir, pn);
912
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read: ${fileSystemPath}`);
913
+ if (!fs.existsSync(fileSystemPath)) {
914
+ fileSystemPath = pn;
915
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read (corrected): ${fileSystemPath}`);
916
+ if (!fs.existsSync(fileSystemPath)) {
917
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --FILE DOES NOT EXIST!! ${fileSystemPath}`);
918
+
919
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
920
+ headers["Content-Length"] = buff.length.toString();
921
+ callback({
922
+ data: bufferToStream(buff),
923
+ headers,
924
+ statusCode: 404
751
925
  });
926
+ return;
927
+ }
928
+ }
929
+ try {
930
+ let mediaType = mime.lookup(fileSystemPath) || "stream/octet";
931
+ const stats = fs.statSync(fileSystemPath);
932
+ headers["Content-Length"] = stats.size;
933
+ headers["Content-Type"] = mediaType;
934
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --CALLBACK HEADERS ${req.url} ${JSON.stringify(headers)}`);
935
+ const steam = fs.createReadStream(fileSystemPath);
936
+ callback({
937
+ data: steam,
938
+ headers,
939
+ statusCode: 200
940
+ });
941
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --POST-CALLBACK ${req.url}`);
942
+ } catch (fsErr) {
943
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --fsErr ${fsErr}`);
944
+
945
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>fsErr: ${fsErr}</p></body></html>`);
946
+ headers["Content-Length"] = buff.length.toString();
947
+ callback({
948
+ data: bufferToStream(buff),
949
+ headers,
950
+ statusCode: 500
752
951
  });
753
952
  }
754
953
 
755
- // https://expressjs.com/en/4x/api.html#express.static
756
- const staticOptions = {
757
- dotfiles: "ignore",
758
- etag: true,
759
- // fallthrough: false,
760
- immutable: true,
761
- // index: "index.html",
762
- maxAge: "1d",
763
- redirect: false
764
- // extensions: ["css", "otf"],
765
- // setHeaders: (res, _path, _stat) => {
766
- // // res.set('x-timestamp', Date.now())
767
- // setResponseCORS(res);
768
- // },
769
- };
770
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP static path ${basedir}`);
771
- expressApp.use("/", express.static(basedir, staticOptions));
954
+ // if (isDev) { // handle WebInspector JS maps etc.
955
+
956
+ // // const url = new URL(`https://fake.org${req.url}`);
957
+ // // const pathname = url.pathname;
958
+ // const pathname = decodeURI(u.pathname);
959
+
960
+ // const filePath = path.join(basedir, pathname);
961
+ // if (filePathsExpressStaticNotExist[filePath]) {
962
+
963
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
964
+ // headers["Content-Length"] = buff.length.toString();
965
+ // headers["Content-Type"] = "plain/text";
966
+ // callback({
967
+ // data: bufferToStream(buff),
968
+ // headers,
969
+ // statusCode: 404,
970
+ // });
971
+ // return;
972
+ // }
973
+ // fsOriginal.exists(filePath, (exists) => {
974
+ // if (exists) {
975
+ // fsOriginal.readFile(filePath, undefined, (err, data) => {
976
+ // if (err) {
977
+ // if (LOG_DEBUG) {
978
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
979
+ // }
980
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
981
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
982
+ // headers["Content-Length"] = buff.length.toString();
983
+ // headers["Content-Type"] = "plain/text";
984
+ // callback({
985
+ // data: bufferToStream(buff),
986
+ // headers,
987
+ // statusCode: 404,
988
+ // });
989
+ // } else {
990
+ // // if (LOG_DEBUG) {
991
+ // // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
992
+ // // }
993
+ // callback({
994
+ // data: null,
995
+ // headers,
996
+ // statusCode: 500,
997
+ // });
998
+ // }
999
+ // });
1000
+ // } else {
1001
+ // fs.exists(filePath, (exists) => {
1002
+ // if (exists) {
1003
+ // fs.readFile(filePath, undefined, (err, data) => {
1004
+ // if (err) {
1005
+ // if (LOG_DEBUG) {
1006
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
1007
+ // }
1008
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
1009
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
1010
+ // headers["Content-Length"] = buff.length.toString();
1011
+ // headers["Content-Type"] = "plain/text";
1012
+ // callback({
1013
+ // data: bufferToStream(buff),
1014
+ // headers,
1015
+ // statusCode: 404,
1016
+ // });
1017
+ // } else {
1018
+ // if (LOG_DEBUG) {
1019
+ // console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
1020
+ // }
1021
+ // callback({
1022
+ // data: null,
1023
+ // headers,
1024
+ // statusCode: 500,
1025
+ // });
1026
+ // }
1027
+ // });
1028
+ // } else {
1029
+ // if (LOG_DEBUG) {
1030
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
1031
+ // }
1032
+ // callback({
1033
+ // data: null,
1034
+ // headers,
1035
+ // statusCode: 404,
1036
+ // });
1037
+ // }
1038
+ // });
1039
+ // }
1040
+ // });
1041
+ // }
1042
+ };
772
1043
 
773
- const startHttp = function () {
774
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner generateSelfSignedData...`);
775
- generateSelfSignedData().then(certData => {
776
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner generateSelfSignedData OK.`);
1044
+ // NO_HTTP_REMOVE
1045
+ // expressApp = express();
1046
+ // // expressApp.enable('strict routing');
1047
+ // // expressApp.use("/", (req, res, next) => {
1048
+ // // if (LOG_DEBUG) console.log("HTTP: " + req.url);
1049
+ // // next();
1050
+ // // });
1051
+ // expressApp.basedir = basedir;
1052
+ // expressApp.use("/", (req, res, next) => {
1053
+ // next();
1054
+ // });
1055
+ // if (isDev) { // handle WebInspector JS maps etc.
1056
+ // expressApp.use("/", (req, res, next) => {
1057
+ // });
1058
+ // }
1059
+
1060
+ // // https://expressjs.com/en/4x/api.html#express.static
1061
+ // const staticOptions = {
1062
+ // dotfiles: "ignore",
1063
+ // etag: true,
1064
+ // // fallthrough: false,
1065
+ // immutable: true,
1066
+ // // index: "index.html",
1067
+ // maxAge: "1d",
1068
+ // redirect: false,
1069
+ // // extensions: ["css", "otf"],
1070
+ // // setHeaders: (res, _path, _stat) => {
1071
+ // // // res.set('x-timestamp', Date.now())
1072
+ // // setResponseCORS(res);
1073
+ // // },
1074
+ // };
1075
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} HTTP static path ${basedir}`);
1076
+ // expressApp.use("/", express.static(basedir, staticOptions));
777
1077
 
778
- httpServer = https.createServer({ key: certData.private, cert: certData.cert }, expressApp).listen(port, () => {
779
- const p = httpServer.address().port;
1078
+ // const startHttp = function () {
1079
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner generateSelfSignedData...`);
1080
+ // generateSelfSignedData().then((certData) => {
1081
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner generateSelfSignedData OK.`);
780
1082
 
781
- port = p;
782
- ip = "127.0.0.1";
783
- proto = "https";
784
- rootUrl = `${proto}://${ip}:${port}`;
785
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} server URL ${rootUrl}`);
1083
+ // httpServer = https.createServer({ key: certData.private, cert: certData.cert }, expressApp).listen(port, () => {
1084
+ // const p = httpServer.address().port;
786
1085
 
787
- resolve();
788
- });
789
- }).catch(err => {
790
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} generateSelfSignedData error!`);
791
- if (LOG_DEBUG) console.log(err);
792
- httpServer = expressApp.listen(port, () => {
793
- const p = httpServer.address().port;
794
-
795
- port = p;
796
- ip = "127.0.0.1";
797
- proto = "http";
798
- rootUrl = `${proto}://${ip}:${port}`;
799
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} server URL ${rootUrl}`);
800
-
801
- resolve();
802
- });
803
- });
804
- };
1086
+ // port = p;
1087
+ // ip = "127.0.0.1";
1088
+ // proto = "https";
1089
+ // rootUrl = `${proto}://${ip}:${port}`;
1090
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} server URL ${rootUrl}`);
805
1091
 
806
- portfinder.getPortPromise().then(p => {
807
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner HTTP port ${p}`);
808
- port = p;
809
- startHttp();
810
- }).catch(err => {
811
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner HTTP port error!`);
812
- console.log(err);
813
- port = 3000;
814
- startHttp();
815
- });
816
- });
1092
+ // resolve();
1093
+ // });
1094
+ // }).catch((err) => {
1095
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} generateSelfSignedData error!`);
1096
+ // if (LOG_DEBUG) console.log(err);
1097
+ // httpServer = expressApp.listen(port, () => {
1098
+ // const p = httpServer.address().port;
1099
+
1100
+ // port = p;
1101
+ // ip = "127.0.0.1";
1102
+ // proto = "http";
1103
+ // rootUrl = `${proto}://${ip}:${port}`;
1104
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} server URL ${rootUrl}`);
1105
+
1106
+ // resolve();
1107
+ // });
1108
+ // });
1109
+ // }
1110
+
1111
+ // portfinder.getPortPromise().then((p) => {
1112
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner HTTP port ${p}`);
1113
+ // port = p;
1114
+ // startHttp();
1115
+ // }).catch((err) => {
1116
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} axeRunner HTTP port error!`);
1117
+ // console.log(err);
1118
+ // port = 3000;
1119
+ // startHttp();
1120
+ // });
1121
+ // });
817
1122
  }
818
1123
 
819
1124
  function prepareLaunch(eventEmmitter, CONCURRENT_INSTANCES) {
820
-
821
1125
  eventEmmitter.on('AXE_RUNNER_LAUNCH', (event, arg) => {
822
1126
  // const payload = eventEmmitter.ace_notElectronIpcMainRenderer ? event : arg;
823
1127
  const sender = eventEmmitter.ace_notElectronIpcMainRenderer ? eventEmmitter : event.sender;