Files
OneOS1.2/.local/extract-annotation-source/extract.mjs
王冕 af29b26fe8 Sync OneOS workspace with new prototypes, annotations, and Gitea remote fix.
Add vehicle-h2-fee-ledger, customer-management, lease and self-operated ledgers, annotation sources, agent skills, and vite annotation runtime support. Update vehicle management, contract templates, and lease contract flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 15:27:23 +08:00

39 lines
1.0 KiB
JavaScript

import { chromium } from 'playwright';
import { writeFileSync } from 'node:fs';
const url = process.argv[2];
if (!url) {
console.error('Usage: node extract.mjs <url>');
process.exit(1);
}
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
const errors = [];
page.on('console', (m) => {
if (m.type() === 'error') errors.push(m.text());
});
await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 });
const title = await page.title();
let source = null;
try {
await page.waitForFunction(() => window.__AXHUB_ANNOTATION_SOURCE__, { timeout: 30000 });
source = await page.evaluate(() => window.__AXHUB_ANNOTATION_SOURCE__);
} catch {
// fall through
}
const out = { title, errors, source };
writeFileSync('output.json', JSON.stringify(out, null, 2));
console.log(JSON.stringify({
title,
errorCount: errors.length,
hasSource: !!source,
nodeCount: source?.nodes?.length ?? 0,
directoryNodeCount: source?.directory?.nodes?.length ?? 0,
}, null, 2));
await browser.close();