oxedyne/daimond/dev/probe_preview.mjs
2.0 KiB, 1 run
created by r2519314175:63, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | // probe_preview.mjs — a look at the source/preview split while it is being built. |
| 2 | import { open, shot } from './harness.mjs'; |
| 3 | |
| 4 | const s = await open({ name: 'previewprobe', connect: false }); |
| 5 | const p = s.page; |
| 6 | await p.setViewportSize({ width: 2400, height: 950 }); |
| 7 | await p.waitForTimeout(1200); |
| 8 | |
| 9 | // A text file and a PDF, both real. |
| 10 | await p.evaluate(async () => { |
| 11 | const m = await import('/pkg/oxedyne_daimond.js'); |
| 12 | const app = new m.DaimondApp('http://127.0.0.1/v1/chat/completions', '', 'none', 4096, '', true); |
| 13 | await app.run_tool('file_write', JSON.stringify({ path: 'notes.md', content: '# Notes\n\nhello\n' })); |
| 14 | // A minimal but genuinely openable PDF. |
| 15 | const pdf = '%PDF-1.4\n1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj\n' |
| 16 | + '2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj\n' |
| 17 | + '3 0 obj<</Type/Page/Parent 2 0 R/MediaBox[0 0 200 200]>>endobj\n' |
| 18 | + 'trailer<</Root 1 0 R>>\n%%EOF\n'; |
| 19 | const bytes = new Uint8Array([...pdf].map((c) => c.charCodeAt(0))); |
| 20 | await app.write_bytes('paper.pdf', bytes); |
| 21 | }); |
| 22 | |
| 23 | const geom = () => p.evaluate(() => { |
| 24 | const st = document.getElementById('stage'); |
| 25 | return { |
| 26 | seats: [...st.children].filter((k) => k.getClientRects().length) |
| 27 | .map((k) => (k.dataset.panel || 'handle') + ':' + Math.round(k.getBoundingClientRect().width)), |
| 28 | docName: (document.getElementById('doc-name') || {}).textContent, |
| 29 | pvName: (document.getElementById('pv-name') || {}).textContent, |
| 30 | docBody: !!document.querySelector('#doc-view .files-view-body'), |
| 31 | pvEmbed: !!document.querySelector('#pv-view .fileview embed'), |
| 32 | lineno: (document.getElementById('doc-lineno') || {}).style.display, |
| 33 | }; |
| 34 | }); |
| 35 | |
| 36 | await p.evaluate(() => window.DaimondDoc.show('notes.md')); |
| 37 | await p.waitForTimeout(900); |
| 38 | console.log('after notes.md ', JSON.stringify(await geom())); |
| 39 | |
| 40 | await p.evaluate(() => window.DaimondDoc.show('paper.pdf')); |
| 41 | await p.waitForTimeout(1500); |
| 42 | console.log('after paper.pdf', JSON.stringify(await geom())); |
| 43 | |
| 44 | await shot(s, "probe-preview-split"); |
| 45 | console.log('errors:', s.errs.filter((e) => !/502|Bad Gateway/.test(e)).slice(0, 8)); |
| 46 | await s.close(); |