juxscript 1.1.121 → 1.1.123
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 +25 -2
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/compiler3.js
CHANGED
|
@@ -232,8 +232,15 @@ 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
|
|
238
|
+
.replace(/[\/\\.\\-\s]/g, '_') // Replace /, \, ., -, spaces with _
|
|
239
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Replace any other invalid chars with _
|
|
240
|
+
.replace(/_+/g, '_') // Collapse multiple consecutive underscores
|
|
241
|
+
.replace(/^_|_$/g, ''); // Remove leading/trailing underscores
|
|
242
|
+
|
|
243
|
+
const capitalized = sanitizedName.charAt(0).toUpperCase() + sanitizedName.slice(1);
|
|
237
244
|
|
|
238
245
|
sourceSnapshot[v.file] = {
|
|
239
246
|
name: v.name,
|
|
@@ -245,6 +252,7 @@ export class JuxCompiler {
|
|
|
245
252
|
let viewCode = this.removeImports(v.content).replace(/^\s*export\s+default\s+.*$/gm, '');
|
|
246
253
|
const asyncPrefix = viewCode.includes('await ') ? 'async ' : '';
|
|
247
254
|
|
|
255
|
+
// ✅ Use sanitized name in function declaration
|
|
248
256
|
entry += `\n${asyncPrefix}function render${capitalized}() {\n${viewCode}\n}\n`;
|
|
249
257
|
});
|
|
250
258
|
|
|
@@ -603,4 +611,19 @@ navigate(location.pathname);
|
|
|
603
611
|
};
|
|
604
612
|
return icons[ext.toLowerCase()] || '📦';
|
|
605
613
|
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* ✅ Generate valid JavaScript identifier from file path
|
|
617
|
+
* Example: abc/aaa.jux -> abc_aaa
|
|
618
|
+
* Example: menus/main.jux -> menus_main
|
|
619
|
+
* Example: pages/blog/post.jux -> pages_blog_post
|
|
620
|
+
*/
|
|
621
|
+
_generateNameFromPath(filepath) {
|
|
622
|
+
return filepath
|
|
623
|
+
.replace(/\.jux$/, '') // Remove .jux extension
|
|
624
|
+
.replace(/[\/\\]/g, '_') // Replace / and \ with _
|
|
625
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Replace any other invalid chars with _
|
|
626
|
+
.replace(/_+/g, '_') // Collapse multiple consecutive underscores
|
|
627
|
+
.replace(/^_|_$/g, ''); // Remove leading/trailing underscores
|
|
628
|
+
}
|
|
606
629
|
}
|