Add SPA+Route code quality rule, async eval support for rsx:debug

Tighten CLAUDE.md from 44KB to 35KB without information loss

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-09 05:32:28 +00:00
parent 2da7a6da08
commit 0df844f77f
4 changed files with 205 additions and 41 deletions

View File

@@ -50,7 +50,8 @@ function parse_args() {
console.log(' --dump-element=<sel> Extract and display HTML of specific element');
console.log(' --storage Dump localStorage and sessionStorage contents');
console.log(' --full Enable all display options for maximum info');
console.log(' --eval=<code> Execute JavaScript code in the page context');
console.log(' --eval=<code> Execute async JavaScript after page loads (supports await)');
console.log(' Example: --eval="$(\'[data-sid=btn_edit]\').click(); await new Promise(r => setTimeout(r, 2000));"');
console.log(' --timeout=<ms> Navigation timeout in milliseconds (minimum 30000ms, default 30000ms)');
console.log(' --console-debug-filter=<ch> Filter console_debug to specific channel');
console.log(' --console-debug-benchmark Include benchmark timing in console_debug');
@@ -638,52 +639,32 @@ function parse_args() {
}
// Execute eval code if --eval option is passed
// This runs AFTER page is fully loaded and ready, supports async/await
if (options.eval_code) {
try {
const evalResult = await page.evaluate((code) => {
return new Promise((resolve) => {
// Wrap the eval code in a function
const __eval_func = function() {
const evalResult = await page.evaluate(async (code) => {
try {
// Wrap code in async function to support await
const asyncFunc = new Function('return (async () => { ' + code + ' })()');
const result = await asyncFunc();
// Convert result to string representation
if (result === undefined) {
return 'undefined';
} else if (result === null) {
return 'null';
} else if (typeof result === 'object') {
try {
// Use eval directly for more complex expressions
const result = eval(code);
// Convert result to string representation
if (result === undefined) {
return 'undefined';
} else if (result === null) {
return 'null';
} else if (typeof result === 'object') {
try {
return JSON.stringify(result, null, 2);
} catch (e) {
return String(result);
}
} else {
return String(result);
}
} catch (error) {
return `Error: ${error.message}`;
return JSON.stringify(result, null, 2);
} catch (e) {
return String(result);
}
};
// Wait for RSX framework to be fully initialized
if (window.Rsx && window.Rsx.on) {
// Use Rsx._debug_ready event which fires after all initialization
window.Rsx.on('_debug_ready', function() {
resolve(__eval_func());
});
} else {
// Fallback for non-RSX pages
if (document.readyState === 'complete' || document.readyState === 'interactive') {
setTimeout(function() { resolve(__eval_func()); }, 500);
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() { resolve(__eval_func()); }, 500);
});
}
return String(result);
}
});
} catch (error) {
return `Error: ${error.message}`;
}
}, options.eval_code);
console.log('\nJavaScript Eval Result:');