/** * 在已下载的 lynx AAR 里检索指定方法/字段签名。 * 用法: node scripts/lynx-api-grep.mjs <正则> [类名...] */ import { spawnSync } from 'node:child_process'; import fs from 'node:fs'; import path from 'node:path'; const WORK = 'C:\\Android\\probe'; const classesJar = (() => { for (const dir of fs.readdirSync(WORK)) { const p = path.join(WORK, dir, 'classes.jar'); if (fs.existsSync(p)) return p; } throw new Error('还没下载 AAR,先跑 lynx-api-probe.mjs'); })(); const pattern = new RegExp(process.argv[2] || 'init', 'i'); const classes = process.argv.slice(3).length ? process.argv.slice(3) : [ 'com.lynx.tasm.LynxEnv', 'com.lynx.tasm.LynxView', 'com.lynx.tasm.LynxViewBuilder', 'com.lynx.tasm.group.LynxBaseConfigurator', ]; for (const cls of classes) { const res = spawnSync('javap', ['-classpath', classesJar, cls], { encoding: 'utf8' }); if (res.status !== 0) { console.log(`-- ${cls}: 未找到`); continue; } const hits = res.stdout.split('\n').filter((l) => pattern.test(l)); console.log(`\n== ${cls} 匹配 /${pattern.source}/ 共 ${hits.length} 条`); console.log(hits.slice(0, 40).join('\n')); }