Files
opencli/src/browser/index.ts
T
jackwener 01b8b6b5bf refactor: fix 14 issues from deep code review
P0 Critical:
- #1 Fix double IIFE wrapping: unified wrapForEval() replaces
  normalizeEvaluateSource + ad-hoc wrap in page.evaluate()
- #2 Fix navigate race: check tab.status before addListener,
  reduced timeout 30s→15s

P1 Should Fix:
- #8 Remove unused permissions (scripting, host_permissions, content_scripts)
- #10 Add retry (3x, 500ms) + timeout (30s) to sendCommand()

P2 Cleanup:
- #3 Extract isWebUrl() to safely handle undefined tab.url
- #4 Sanitize maxDepth with Math.max/min bounds
- #6 Delete empty src/daemon/ directory
- #7 Remove dead createJsonRpcRequest + its test
- #9 Remove stale IIFE-mode comment
- #11 Validate body.id in daemon request handler
- #12 Guard ensureAttached: detach+re-attach on 'already attached'
- #14 Extract _tabOpt() helper (removes 13x spread duplication)
- #15 Add verbose warning for unsupported consoleMessages()

All 35 unit tests pass.
2026-03-19 16:21:17 +08:00

26 lines
763 B
TypeScript

/**
* Browser module — public API re-exports.
*
* This barrel replaces the former monolithic browser.ts.
* External code should import from './browser/index.js' (or './browser.js' via Node resolution).
*/
export { Page } from './page.js';
export { PlaywrightMCP } from './mcp.js';
export { isDaemonRunning } from './daemon-client.js';
// Backward compatibility: getTokenFingerprint is no longer needed but kept as no-op export
export function getTokenFingerprint(_token: string | undefined): string | null {
return null;
}
import { extractTabEntries, diffTabIndexes, appendLimited } from './tabs.js';
import { withTimeoutMs } from '../runtime.js';
export const __test__ = {
extractTabEntries,
diffTabIndexes,
appendLimited,
withTimeoutMs,
};