Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/shot_stage.mjs

1.4 KiB, 1 run

created by r2519314175:195, 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// shot_stage.mjs — the stage as the author will see it: the source, its pages,
2// and the daimon, all at once.
3import { open, shot } from './harness.mjs';
4
5const MAIN = `#import "one.typ": one
6#set page(width: 120mm, height: 160mm, margin: 12mm)
7#set text(size: 10pt)
8#set par(justify: true)
9= The book
10#one
11`;
12const ONE = `#let one = [
13== Chapter one
14Alpha lorem ipsum dolor sit amet, consectetur adipiscing elit.
15
16#lorem(120)
17]
18`;
19
20const s = await open({ name: 'stageshot', connect: false });
21const p = s.page;
22await p.setViewportSize({ width: 1920, height: 1080 });
23await p.waitForTimeout(1000);
24
25const put = (path, text) => p.evaluate(async ({ path, text }) => {
26 const m = await import('/pkg/oxedyne_daimond.js');
27 await m.write_file(path, text);
28}, { path, text });
29await put('book/main.typ', MAIN);
30await put('book/one.typ', ONE);
31
32await p.evaluate(() => window.DaimondDoc.show('book/main.typ'));
33await p.waitForTimeout(1200);
34await p.click('[data-act="compile"]', { force: true });
35const st = () => p.evaluate(() => window.DaimondTypstWatch.state());
36for (let i = 0; i < 80 && !(await st()).drawn; i++) await p.waitForTimeout(500);
37await p.waitForTimeout(1500);
38await shot(s, 'stage-source-and-pages');
39console.log(JSON.stringify(await p.evaluate(() => [...document.getElementById('stage').children]
40 .filter((k) => k.getClientRects().length)
41 .map((k) => (k.dataset.panel || 'handle') + ':' + Math.round(k.getBoundingClientRect().width)))));
42await s.close();