juxscript 1.0.73 → 1.0.75

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.
@@ -206,7 +206,8 @@ export async function bundleJuxFilesToRouter(projectRoot, distDir, options = {})
206
206
 
207
207
  // ✅ CHECK: Is this import pointing to a file we are bundling?
208
208
  let isBundledLocal = false;
209
- if (moduleName.startsWith('.')) {
209
+ // Support relative (./, ../) OR project-root relative (/) imports
210
+ if (moduleName.startsWith('.') || moduleName.startsWith('/')) {
210
211
  const resolved = resolveImportPath(moduleName, relativePath);
211
212
  if (bundledPaths.has(resolved)) {
212
213
  isBundledLocal = true;
@@ -338,6 +339,7 @@ function transformJuxToViewFunction(juxContent, functionName, pageName, relative
338
339
  const resolvedPath = resolveImportPath(importPath, relativePath);
339
340
 
340
341
  // ✅ Check if this import is pointing to a bundled file
342
+ // Handle BOTH relative and absolute-relative imports (starting with /)
341
343
  const isBundled = (bundledPaths && bundledPaths.has(resolvedPath)) || importPath.endsWith('.jux');
342
344
 
343
345
  if (isBundled) {
@@ -383,6 +385,10 @@ JuxError.register('${cleanName}', '${relativePath}');
383
385
  }
384
386
 
385
387
  function resolveImportPath(importPath, currentFilePath) {
388
+ // ✅ FIX: Handle root-relative imports (start with /)
389
+ if (importPath.startsWith('/')) {
390
+ return importPath.substring(1).replace(/\\/g, '/');
391
+ }
386
392
  const currentDir = path.dirname(currentFilePath);
387
393
  return path.join(currentDir, importPath).replace(/\\/g, '/');
388
394
  }
@@ -453,6 +459,41 @@ const JuxError = {
453
459
  this.sourceMap[viewName] = sourceFile;
454
460
  },
455
461
 
462
+ // Global Error Handler Setup
463
+ init() {
464
+ window.addEventListener('error', (event) => {
465
+ JuxError.displayError('Uncaught Exception', event.error);
466
+ });
467
+ window.addEventListener('unhandledrejection', (event) => {
468
+ JuxError.displayError('Unhandled Promise Rejection', event.reason);
469
+ });
470
+ },
471
+
472
+ displayError(title, error) {
473
+ console.error(\`🚨 JUX \${title}\`, error);
474
+ const app = document.getElementById('app');
475
+ if (app) {
476
+ // Prevent multiple error overlays stacking
477
+ if (document.getElementById('jux-error-overlay')) return;
478
+
479
+ app.innerHTML = \`
480
+ <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;">
481
+ <div style="display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem;">
482
+ <div style="font-size: 2rem;">🚨</div>
483
+ <div>
484
+ <h1 style="margin:0; font-size: 1.5rem; color: #ff6b6b;">JUX Runtime Error</h1>
485
+ <div style="color: #888; margin-top: 4px;">\${title}</div>
486
+ </div>
487
+ </div>
488
+
489
+ <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>
490
+
491
+ <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>
492
+ </div>
493
+ \`;
494
+ }
495
+ },
496
+
456
497
  wrap(viewName, viewFn) {
457
498
  return function() {
458
499
  const sourceFile = JuxError.sourceMap[viewName] || 'unknown';
@@ -461,39 +502,18 @@ const JuxError = {
461
502
  try {
462
503
  return viewFn.apply(this, arguments);
463
504
  } catch (error) {
464
- console.error(\`🚨 JUX RUNTIME ERROR\\nView: \${viewName}\\nSource: \${sourceFile}\`);
465
- console.error(error);
466
-
467
- const app = document.getElementById('app');
468
- if (app) {
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;
505
+ // Enhance error object with view context if possible
506
+ error.message = \`[View: \${viewName}] \${error.message}\`;
507
+ JuxError.displayError('View Rendering Error', error);
508
+ // We do NOT rethrow here to prevent console noise, as we handled it UI-wise.
509
+ // However, stopping execution flow is implicitly handled by not returning valid DOM.
493
510
  }
494
511
  };
495
512
  }
496
513
  };
514
+
515
+ // Initialize Global Handlers
516
+ JuxError.init();
497
517
  `;
498
518
 
499
519
  return `// Generated Jux Router Bundle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "lib/jux.js",