juxscript 1.1.121 → 1.1.122
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/dom-structure-map.json +1 -1
- package/machinery/compiler3.js +19 -2
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/compiler3.js
CHANGED
|
@@ -232,8 +232,10 @@ export class JuxCompiler {
|
|
|
232
232
|
entry += `\n// --- VIEW FUNCTIONS ---\n`;
|
|
233
233
|
|
|
234
234
|
views.forEach(v => {
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
// ✅ Sanitize the name for use in function names
|
|
236
|
+
// Replace slashes, dots, and other invalid characters with underscores
|
|
237
|
+
const sanitizedName = v.name.replace(/[\/\\.\\-\s]/g, '_');
|
|
238
|
+
const capitalized = sanitizedName.charAt(0).toUpperCase() + sanitizedName.slice(1);
|
|
237
239
|
|
|
238
240
|
sourceSnapshot[v.file] = {
|
|
239
241
|
name: v.name,
|
|
@@ -245,6 +247,7 @@ export class JuxCompiler {
|
|
|
245
247
|
let viewCode = this.removeImports(v.content).replace(/^\s*export\s+default\s+.*$/gm, '');
|
|
246
248
|
const asyncPrefix = viewCode.includes('await ') ? 'async ' : '';
|
|
247
249
|
|
|
250
|
+
// ✅ Use sanitized name in function declaration
|
|
248
251
|
entry += `\n${asyncPrefix}function render${capitalized}() {\n${viewCode}\n}\n`;
|
|
249
252
|
});
|
|
250
253
|
|
|
@@ -603,4 +606,18 @@ navigate(location.pathname);
|
|
|
603
606
|
};
|
|
604
607
|
return icons[ext.toLowerCase()] || '📦';
|
|
605
608
|
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* ✅ Generate name from folder structure
|
|
612
|
+
* Example: abc/aaa.jux -> abc_aaa
|
|
613
|
+
* Example: components/header.jux -> components_header
|
|
614
|
+
*/
|
|
615
|
+
_generateNameFromPath(filepath) {
|
|
616
|
+
return filepath
|
|
617
|
+
.replace(/\.jux$/, '') // Remove .jux extension
|
|
618
|
+
.replace(/[\/\\]/g, '_') // Replace slashes with underscores
|
|
619
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Replace any other invalid chars
|
|
620
|
+
.replace(/_+/g, '_') // Collapse multiple underscores
|
|
621
|
+
.replace(/^_|_$/g, ''); // Remove leading/trailing underscores
|
|
622
|
+
}
|
|
606
623
|
}
|