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:
juanatsap
2025-11-17 15:02:30 +00:00
parent 19a19bdf78
commit 5d5b050029
3 changed files with 635 additions and 42 deletions
+27 -25
View File
@@ -32,36 +32,37 @@ const showLogos = ...
---
### 2. Hyperscript Parser Limit (NEEDS RETESTING)
### 2. Hyperscript Parser Limit (REMOVED IN LATEST VERSION ✅)
**⚠️ TO VERIFY: Maximum 3 `def` statements limit with latest hyperscript version**
**✅ CONFIRMED: NO 3 def statement limit with latest hyperscript version**
**Status:** We upgraded to the LATEST hyperscript version. This limit may no longer exist.
**Test Results (2025-11-17):** Test 9 (`tests/mjs/9-hyperscript-def-limit.test.mjs`) confirmed:
- ✅ 1 def statement works
- ✅ 2 def statements work
- ✅ 3 def statements work
- ✅ 4 def statements work (beyond historical limit)
- ✅ 5 def statements work (well beyond limit)
**TODO:** Test if the 3 `def` statement limit still applies with current version
**Historical Context:**
- Hyperscript 0.9.12 had a hard 3 def limit
- Latest hyperscript version removed this limitation
- Functions were moved to JavaScript as workaround
- Now migrating back to hyperscript for cleaner architecture
**Current solution (still recommended):** Move complex logic to JavaScript functions
**Current Best Practice:** Organize hyperscript functions by category in separate files
```javascript
// ✅ CORRECT - JavaScript functions
function toggleIcons(showIcons) { ... }
function toggleCVLength(isLong) { ... }
function toggleTheme(isClean) { ... }
// Call from hyperscript
_="on change call toggleIcons(my.checked)"
// ❌ WRONG - Too many def statements
_="def toggleIcons(show)
if show then add .show-icons...
end"
```
static/hyperscript/
├── toggles._hs # Toggle functions (CV length, icons, theme)
├── hover-sync._hs # Hover synchronization functions
└── utils._hs # Utility functions (keyboard shortcuts, etc.)
```
**Why:** Parser crashes/fails silently when limit exceeded.
**Migration in progress:** Moving functions from `cv-functions.js` back to hyperscript
**Test that enforces this:** `tests/mjs/3-hyperscript.test.mjs`
**Test that verifies no limit:** `tests/mjs/9-hyperscript-def-limit.test.mjs`
**Reference:** `HYPERSCRIPT-RULES.md`
**Reference:** `doc/HYPERSCRIPT-RULES.md`
---
@@ -166,12 +167,13 @@ tests/mjs/
├── 0-zoom.test.mjs # Zoom functionality
├── 1-toggles.test.mjs # ALL toggles + sync + persistence
├── 2-keyboard-shortcuts.test.mjs # L, I, V, ? keys
├── 3-hyperscript.test.mjs # Parse errors + def limit
├── 3-hyperscript.test.mjs # Parse errors + integrity
├── 4-htmx.test.mjs # HTMX integration
├── 5-language.test.mjs # EN/ES switching
├── 6-modals.test.mjs # Modal functionality
├── 7-mobile-responsive.test.mjs # Mobile viewports
── 8-hover-sync.test.mjs # PDF/Print button hover sync
── 8-hover-sync.test.mjs # PDF/Print button hover sync
└── 9-hyperscript-def-limit.test.mjs # Def statement limit verification
```
**Non-negotiable:**
@@ -512,6 +514,6 @@ document.addEventListener('keydown', (e) => {
---
**Last Updated:** 2025-11-17
**Project Status:** Production
**Test Coverage:** 9 systematic tests, 100% core features
**Project Status:** Production - Migrating to hyperscript architecture
**Test Coverage:** 10 systematic tests, 100% core features + def limit verification
**Critical Memory Files:** This file + `~/.claude/cv-icons-migration.md`