juxscript 1.0.73 → 1.0.74
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/machinery/compiler.js +43 -29
- package/package.json +1 -1
package/machinery/compiler.js
CHANGED
|
@@ -453,6 +453,41 @@ const JuxError = {
|
|
|
453
453
|
this.sourceMap[viewName] = sourceFile;
|
|
454
454
|
},
|
|
455
455
|
|
|
456
|
+
// Global Error Handler Setup
|
|
457
|
+
init() {
|
|
458
|
+
window.addEventListener('error', (event) => {
|
|
459
|
+
JuxError.displayError('Uncaught Exception', event.error);
|
|
460
|
+
});
|
|
461
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
462
|
+
JuxError.displayError('Unhandled Promise Rejection', event.reason);
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
|
|
466
|
+
displayError(title, error) {
|
|
467
|
+
console.error(\`🚨 JUX \${title}\`, error);
|
|
468
|
+
const app = document.getElementById('app');
|
|
469
|
+
if (app) {
|
|
470
|
+
// Prevent multiple error overlays stacking
|
|
471
|
+
if (document.getElementById('jux-error-overlay')) return;
|
|
472
|
+
|
|
473
|
+
app.innerHTML = \`
|
|
474
|
+
<div id="jux-error-overlay" style="font-family: monospace; background: #1e1e1e; color: #ff6b6b; min-height: 100vh; padding: 2rem; position:fixed; top:0; left:0; width:100%; z-index:99999;">
|
|
475
|
+
<div style="display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem;">
|
|
476
|
+
<div style="font-size: 2rem;">🚨</div>
|
|
477
|
+
<div>
|
|
478
|
+
<h1 style="margin:0; font-size: 1.5rem; color: #ff6b6b;">JUX Runtime Error</h1>
|
|
479
|
+
<div style="color: #888; margin-top: 4px;">\${title}</div>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
<pre style="background: #2d2d2d; padding: 20px; border-radius: 8px; overflow-x: auto; color: #e0e0e0; border-left: 4px solid #ff6b6b; font-size: 14px; line-height: 1.5;">\${error?.stack || error?.message || String(error)}</pre>
|
|
484
|
+
|
|
485
|
+
<button onclick="window.location.reload()" style="margin-top:20px; padding: 10px 20px; background: #333; color: white; border: 1px solid #555; cursor: pointer; border-radius: 4px;">Reload Application</button>
|
|
486
|
+
</div>
|
|
487
|
+
\`;
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
|
|
456
491
|
wrap(viewName, viewFn) {
|
|
457
492
|
return function() {
|
|
458
493
|
const sourceFile = JuxError.sourceMap[viewName] || 'unknown';
|
|
@@ -461,39 +496,18 @@ const JuxError = {
|
|
|
461
496
|
try {
|
|
462
497
|
return viewFn.apply(this, arguments);
|
|
463
498
|
} catch (error) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
app.innerHTML = \`
|
|
470
|
-
<div style="font-family: monospace; background: #1e1e1e; color: #ff6b6b; min-height: 100vh; padding: 2rem;">
|
|
471
|
-
<div style="display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem;">
|
|
472
|
-
<div style="font-size: 2rem;">🚨</div>
|
|
473
|
-
<div>
|
|
474
|
-
<h1 style="margin:0; font-size: 1.5rem; color: #ff6b6b;">JUX Runtime Error</h1>
|
|
475
|
-
</div>
|
|
476
|
-
</div>
|
|
477
|
-
|
|
478
|
-
<div style="margin-bottom: 1rem;">
|
|
479
|
-
<div style="color: #888; margin-bottom: 4px;">View:</div>
|
|
480
|
-
<span style="color: #fff; font-weight: bold;">\${viewName}</span>
|
|
481
|
-
</div>
|
|
482
|
-
|
|
483
|
-
<div style="margin-bottom: 2rem;">
|
|
484
|
-
<div style="color: #888; margin-bottom: 4px;">Source:</div>
|
|
485
|
-
<span style="color: #4caf50; font-family: monospace;">\${sourceFile}</span>
|
|
486
|
-
</div>
|
|
487
|
-
|
|
488
|
-
<pre style="background: #2d2d2d; padding: 20px; border-radius: 8px; overflow-x: auto; color: #e0e0e0; border-left: 4px solid #ff6b6b;">\${error.message}\\n\\n\${error.stack}</pre>
|
|
489
|
-
</div>
|
|
490
|
-
\`;
|
|
491
|
-
}
|
|
492
|
-
throw error;
|
|
499
|
+
// Enhance error object with view context if possible
|
|
500
|
+
error.message = \`[View: \${viewName}] \${error.message}\`;
|
|
501
|
+
JuxError.displayError('View Rendering Error', error);
|
|
502
|
+
// We do NOT rethrow here to prevent console noise, as we handled it UI-wise.
|
|
503
|
+
// However, stopping execution flow is implicitly handled by not returning valid DOM.
|
|
493
504
|
}
|
|
494
505
|
};
|
|
495
506
|
}
|
|
496
507
|
};
|
|
508
|
+
|
|
509
|
+
// Initialize Global Handlers
|
|
510
|
+
JuxError.init();
|
|
497
511
|
`;
|
|
498
512
|
|
|
499
513
|
return `// Generated Jux Router Bundle
|