MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / handleEvent

Function handleEvent

tools/test-examples/index.js:282–320  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

280 let pendingAbortText = null;
281
282 function handleEvent(obj) {
283 if (obj.event === 'stopped') {
284 if (pendingAbortText) {
285 exceptionOccurred = true;
286 finish(false, 'XS Abort detected: ' + pendingAbortText);
287 return;
288 }
289 if (obj.data && typeof obj.data.reason === 'string') {
290 const reason = obj.data.reason;
291 if (reason === '# Break: breakpoint!' || reason === '# Break: step!' || reason === '# Break: debugger!') {
292 // Resumes from deliberate programmatic breakpoints
293 child.stdin.write("c\n");
294 } else if (reason.startsWith('# Break:')) {
295 // Any other break is an unhandled exception or error (SyntaxError, TypeError, etc)
296 exceptionOccurred = true;
297 finish(false, 'Exception detected: ' + reason.replace('# Break: ', '').trim());
298 } else {
299 child.stdin.write("c\n");
300 }
301 } else {
302 child.stdin.write("c\n");
303 }
304 } else if (obj.event === 'log') {
305 if (obj.data && typeof obj.data.text === 'string' && obj.data.text.includes('XS abort')) {
306 exceptionOccurred = true;
307 finish(false, 'XS Abort detected');
308 }
309 } else if (obj.event === 'info_instruments') {
310 if (ipDetected && obj.data && typeof obj.data.historyCount === 'number') {
311 if (obj.data.historyCount > previousHistoryCount) {
312 previousHistoryCount = obj.data.historyCount;
313 instrumentationDataCount++;
314 if (instrumentationDataCount >= 3 && !exceptionOccurred) {
315 finish(true, 'Successful execution');
316 }
317 }
318 }
319 }
320 };
321
322 let runTimeout, launchTimeout;
323

Callers 1

runMainBuildFunction · 0.85

Calls 3

replaceMethod · 0.80
finishFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected