juxscript 1.1.122 → 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 +14 -8
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/compiler3.js
CHANGED
|
@@ -234,7 +234,12 @@ export class JuxCompiler {
|
|
|
234
234
|
views.forEach(v => {
|
|
235
235
|
// ✅ Sanitize the name for use in function names
|
|
236
236
|
// Replace slashes, dots, and other invalid characters with underscores
|
|
237
|
-
const sanitizedName = v.name
|
|
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
|
+
|
|
238
243
|
const capitalized = sanitizedName.charAt(0).toUpperCase() + sanitizedName.slice(1);
|
|
239
244
|
|
|
240
245
|
sourceSnapshot[v.file] = {
|
|
@@ -608,16 +613,17 @@ navigate(location.pathname);
|
|
|
608
613
|
}
|
|
609
614
|
|
|
610
615
|
/**
|
|
611
|
-
* ✅ Generate
|
|
616
|
+
* ✅ Generate valid JavaScript identifier from file path
|
|
612
617
|
* Example: abc/aaa.jux -> abc_aaa
|
|
613
|
-
* Example:
|
|
618
|
+
* Example: menus/main.jux -> menus_main
|
|
619
|
+
* Example: pages/blog/post.jux -> pages_blog_post
|
|
614
620
|
*/
|
|
615
621
|
_generateNameFromPath(filepath) {
|
|
616
622
|
return filepath
|
|
617
|
-
.replace(/\.jux$/, '')
|
|
618
|
-
.replace(/[\/\\]/g, '_')
|
|
619
|
-
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
620
|
-
.replace(/_+/g, '_')
|
|
621
|
-
.replace(/^_|_$/g, '');
|
|
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
|
|
622
628
|
}
|
|
623
629
|
}
|