Spaces:
Sleeping
Sleeping
| // Standalone repro tool: open chart.html in puppeteer with console capture | |
| // so we can see exactly why D3 failed to produce an SVG. | |
| // Usage: PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome \ | |
| // node scripts/_debug_render.cjs <chart.html path> | |
| const puppeteer = require('puppeteer'); | |
| const path = require('path'); | |
| (async () => { | |
| const browser = await puppeteer.launch({ | |
| headless: 'new', | |
| executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || undefined, | |
| args: ['--no-sandbox', '--disable-setuid-sandbox'], | |
| }); | |
| const page = await browser.newPage(); | |
| page.on('console', msg => console.log('[console.' + msg.type() + ']', msg.text())); | |
| page.on('pageerror', err => console.log('[pageerror]', err.toString())); | |
| page.on('requestfailed', req => | |
| console.log('[reqfail]', req.url(), req.failure().errorText)); | |
| await page.setViewport({ width: 1200, height: 800 }); | |
| const target = path.resolve(process.argv[2]); | |
| await page.goto('file://' + target, { waitUntil: 'networkidle0' }); | |
| await new Promise(r => setTimeout(r, 3000)); | |
| const info = await page.evaluate(() => { | |
| const c = document.querySelector('#chart-container'); | |
| return { | |
| container_exists: !!c, | |
| container_html_length: c ? c.innerHTML.length : 0, | |
| container_children: c ? c.children.length : 0, | |
| svg_count: document.querySelectorAll('svg').length, | |
| d3_present: typeof d3 !== 'undefined', | |
| }; | |
| }); | |
| console.log('PAGE INFO:', JSON.stringify(info, null, 2)); | |
| await browser.close(); | |
| })(); | |