feat: confirm no hyperscript def limit + update documentation
MAJOR FINDING: Latest hyperscript version has NO 3 def statement limit! Test Results (tests/mjs/9-hyperscript-def-limit.test.mjs): ✅ 1 def statement - PASS ✅ 2 def statements - PASS ✅ 3 def statements - PASS ✅ 4 def statements - PASS (beyond historical limit) ✅ 5 def statements - PASS (well beyond limit) Changes: 1. Created comprehensive def limit test - tests/mjs/9-hyperscript-def-limit.test.mjs - Tests 1, 2, 3, 4, 5 def statements - Verifies both parsing and function execution - Provides detailed analysis and recommendations 2. Updated PROJECT-MEMORY.md - Section 2: Changed from "NEEDS RETESTING" to "REMOVED IN LATEST VERSION" - Documented test findings and historical context - Added migration plan for hyperscript file organization - Updated test count to 10 systematic tests 3. Updated doc/HYPERSCRIPT-RULES.md - Rule 2: Removed 3 def limit warning - Documented historical context (Hyperscript 0.9.12 had limit) - New best practice: Organize by category in separate files - Added recommended file structure Impact: - Can now use unlimited def statements in hyperscript - Enables cleaner architecture with category-based organization - Allows migration from cv-functions.js back to hyperscript - Better alignment with hypermedia/server-driven pattern Next Steps: - Create organized hyperscript file structure - Migrate toggle functions from JavaScript to hyperscript - Migrate hover sync functions to hyperscript - Test each migration thoroughly
This commit is contained in:
+19
-17
@@ -9,27 +9,29 @@
|
||||
- Longer logic MUST be extracted to named functions in .\_hs files
|
||||
- HTML templates should be clean and readable
|
||||
|
||||
### Rule 2: File Structure - Hyperscript 0.9.12 Limitation
|
||||
**Maximum 3 `def` statements TOTAL across ALL files**
|
||||
### Rule 2: File Structure - Organized by Category
|
||||
**✅ NO def statement limit with latest hyperscript!**
|
||||
|
||||
**HISTORICAL NOTE** (2025-11-17): Hyperscript 0.9.12 had a 3 def limit. Latest version REMOVED this limitation.
|
||||
- Test verification: `tests/mjs/9-hyperscript-def-limit.test.mjs` (all 5 def statements passed)
|
||||
- Migration in progress: Moving functions from JavaScript back to hyperscript
|
||||
|
||||
**Current Best Practice**: Organize hyperscript functions by category in separate files
|
||||
|
||||
⚠️ **CRITICAL**: Hyperscript 0.9.12 has a parser limitation - more than 3 `def` statements **across ALL loaded .\_hs files** causes:
|
||||
```
|
||||
Error: Expected 'end' but found 'def'
|
||||
static/hyperscript/
|
||||
├── toggles._hs # Toggle functions (CV length, icons, theme)
|
||||
├── hover-sync._hs # Hover synchronization functions
|
||||
├── utils._hs # Utility functions (print, scroll, etc.)
|
||||
└── keyboard._hs # Keyboard shortcut handlers
|
||||
```
|
||||
|
||||
**Solution for Global Reusable Functions**: Use regular JavaScript instead
|
||||
- `static/js/cv-functions.js` - Global toggle and utility functions
|
||||
- toggleCVLength(), toggleIcons(), toggleTheme()
|
||||
- syncPdfHover(), syncPrintHover(), highlightZoomControl()
|
||||
|
||||
**Solution for Hyperscript-Specific Logic**: Keep max 3 defs
|
||||
- `static/hyperscript/functions._hs` - ONLY hyperscript-specific utilities (printFriendly, initScrollBehavior, handleScroll)
|
||||
|
||||
**Why JavaScript for Global Functions:**
|
||||
- ✅ No artificial limits
|
||||
- ✅ Better performance (native JS)
|
||||
- ✅ Better debugging
|
||||
- ✅ Can still be called from hyperscript using `call toggleIcons(my.checked)`
|
||||
**Benefits of Hyperscript Organization:**
|
||||
- ✅ Clean separation of concerns
|
||||
- ✅ Easy to locate and maintain functions
|
||||
- ✅ No artificial limitations
|
||||
- ✅ Server-side hypermedia pattern (functions loaded with HTML)
|
||||
- ✅ Still callable from anywhere using `call functionName(args)`
|
||||
|
||||
### Rule 3: HTML Structure Cleanliness
|
||||
**HTML must be as clean as possible regarding hyperscript**
|
||||
|
||||
Reference in New Issue
Block a user