create-pmos 0.272.0 → 0.273.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-calendar-3-test.js +3 -1
- package/workspace/briefing-premium-insights-test.js +3 -2
- package/workspace/guide/briefing-premium.md +3 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +206 -0
- package/workspace/public/pm/premium-insights.js +6 -3
- package/workspace/public/pm/premium-report-print.css +9 -0
- package/workspace/public/pm/premium-report-read.js +358 -0
- package/workspace/public/pm/premium.css +60 -0
- package/workspace/public/premium-insights.html +1 -1
- package/workspace/test-lists/premium-report-read.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.273.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -208,7 +208,9 @@ const RECORDER = () => {
|
|
|
208
208
|
await Lv.page.goto(BASE + '/premium-work.html').catch(() => {});
|
|
209
209
|
ok('R4 leaving the Briefing while it records makes the browser ask first, and staying pauses nothing', Lv.dialogs.includes('beforeunload') && Lv.pausePosts.length === 0 && /premium\.html/.test(Lv.page.url()), Lv.dialogs.join() + ' ' + Lv.page.url());
|
|
210
210
|
Lv.leave = true;
|
|
211
|
-
|
|
211
|
+
// After the stay above, Chromium on CI reports the next navigation as ERR_ABORTED while it still leaves the page: wait for the page itself.
|
|
212
|
+
await Lv.page.goto(BASE + '/premium-work.html').catch(() => {});
|
|
213
|
+
await Lv.page.waitForURL(/premium-work\.html/, { timeout: 10000 }).catch(() => {});
|
|
212
214
|
ok('R4 leaving anyway sends the pause for that note (a request that leaves with the page)', await until(() => Lv.pauseSeen.length >= 1) && Lv.pauseSeen[0].id === 'n1', JSON.stringify(Lv.pauseSeen));
|
|
213
215
|
if (!Lv.pausePosts.length) { const n = Lv.notes.find((x) => x.id === 'n1'); n.state = 'paused'; n.resume_until = new Date(Date.now() + 3600000).toISOString(); } // the stand-in could not answer a request sent as the page left
|
|
214
216
|
await Lv.page.reload();
|
|
@@ -125,9 +125,10 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
125
125
|
/* I8 reports */
|
|
126
126
|
const rp = await p.evaluate(() => ({ rows: [...document.querySelectorAll('#repDocs .dmr')].map((r) => r.querySelector('.dmn b').textContent + ' / ' + r.querySelector('.s').textContent), note: document.querySelector('#repBody .mhint').textContent, cap: document.querySelector('#repCap').textContent }));
|
|
127
127
|
ok('I8 the Reports card lists the report files: cadence, slot, draft or issued', rp.rows.join() === 'biweekly · 14 Oct / Draft,monthly · 30 Sep / Issued 1 Oct' && /Nothing is sent from here/.test(rp.note) && rp.cap === '2', JSON.stringify(rp));
|
|
128
|
-
{ const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens the
|
|
128
|
+
{ const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens in the page\'s reader, not the console (premium-report-read R1)', await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('rdrd') && document.querySelector('#dlg').classList.contains('on')), 5000) && /premium-insights\.html/.test(R.page.url()), R.page.url());
|
|
129
|
+
await R.page.click('#dClose'); await R.page.click('#repOpen'); ok('I8 the Reports tab link still opens the console to edit or issue', await until(() => /\/c3\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
|
|
129
130
|
/* I9 labels */
|
|
130
|
-
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out:
|
|
131
|
+
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out: run-based charts/.test(await txt('#foot')) && /Real data/.test(await txt('#snap')));
|
|
131
132
|
ok('I9 the page makes no write request on its own', A.posts.length === 0, A.posts.join());
|
|
132
133
|
/* I10 empty */
|
|
133
134
|
{
|
|
@@ -211,6 +211,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
211
211
|
- **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
|
|
212
212
|
- **Found in your work.** Up to three reports PMOS found in your calendar, mail or documents, each with why and what it saw. **Set it up** records the report and drafts its first cycle as a file. **Not a report** hides it and records it after 5 seconds, unless you press **Undo**.
|
|
213
213
|
- **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
|
|
214
|
-
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the
|
|
214
|
+
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens it on the page as a **Deck**: a title slide, then one slide for each section, with the arrow keys and a strip of slides. **Document** shows it as a page. **Present** shows the slide on the whole screen; the arrow keys move and Escape stops. **Download** gives PowerPoint, Word, Excel, CSV or the Markdown file; the files carry the words, not the look. **Print or save as PDF** prints one slide to a page. **Open in the console** is where a document is edited or issued. Nothing is sent from this page.
|
|
215
|
+
- **Shape a report's look.** On a draft, **Add a sample** takes a PDF, PowerPoint, Word, PNG or JPG file to follow. Say how it should look in the conversation; PMOS draws the next design version (D1, D2, …) and says what it changed. Press a version to go back to it. **This is it** saves the version shown as the report's design, and PMOS draws the cycle to match. An issued cycle is frozen with its look.
|
|
215
216
|
|
|
216
|
-
Not built:
|
|
217
|
+
Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.273.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.273.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-report-read-test.js — a report document read on the premium Insights page (initiative premium-report-read;
|
|
4
|
+
* planning/prd/premium-report-read-prd.md R1 to R11). A real server on a scratch git repository with two cycles of one report (one issued), and a
|
|
5
|
+
* stub `claude` on the PATH that plays the report-design job (as c3-report-design-real-test.js does). The real page presses the real routes:
|
|
6
|
+
* O opening · D the deck · G the page · N Present · W download · X print · L the look · I issued · P the POST allow-list · F floors
|
|
7
|
+
* Set READ_SHOTS=<dir> to save screenshots at 1280 and 390 wide. */
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { spawn, execFileSync } = require('child_process');
|
|
12
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
13
|
+
const T = require('./test-run').configure({ name: 'premium-report-read' });
|
|
14
|
+
const issues = require('./lib/issues.js');
|
|
15
|
+
const RDraft = require('./lib/report-draft.js');
|
|
16
|
+
|
|
17
|
+
const BASE = T.BASE;
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
20
|
+
const results = [];
|
|
21
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
|
|
22
|
+
let srv = null, browser = null;
|
|
23
|
+
const base = fs.mkdtempSync(path.join(os.tmpdir(), 'report-read-'));
|
|
24
|
+
const finish = async (code) => {
|
|
25
|
+
if (browser) await browser.close().catch(() => {});
|
|
26
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
27
|
+
T.killTmux();
|
|
28
|
+
try { fs.rmSync(base, { recursive: true, force: true }); } catch { /* left for the OS */ }
|
|
29
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
30
|
+
console.log(`\n${results.length - bad}/${results.length} premium-report-read assertions passed`);
|
|
31
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
32
|
+
};
|
|
33
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
34
|
+
|
|
35
|
+
/* the scratch repository: one measure, so the page draws; two cycles of the partner-review report, the older one issued */
|
|
36
|
+
const dir = path.join(base, 'repo'), stateDir = path.join(base, 'state'), fakeBin = path.join(base, 'bin'), fakeHome = path.join(base, 'home');
|
|
37
|
+
for (const d of [path.join(dir, 'planning', 'records'), stateDir, fakeBin, path.join(fakeHome, '.claude')]) fs.mkdirSync(d, { recursive: true });
|
|
38
|
+
const rd = (id, rid, at, value) => ({ id, kind: 'reading', rid, fields: { at, value } });
|
|
39
|
+
fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), [
|
|
40
|
+
{ id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
|
|
41
|
+
rd('2', 'krm-a', '2026-08-01', 24), rd('3', 'krm-a', '2026-09-01', 30), rd('4', 'krm-a', '2026-10-01', 33),
|
|
42
|
+
].map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
43
|
+
const CAD = 'partner-review';
|
|
44
|
+
const DOC = '---\ntype: Report\ntitle: "Partner review, 12 Oct"\n---\n\n# Partner review, 12 Oct\n\n## Headline\nPartner activation is **33%**, short of its line.\n\n## Initiatives\n- Partner activation: in build\n- Onboarding emails: shipped\n\n## Needs your call\n- Extend the pilot to two more partners?\n\n## Sources\n- KR metric record krm-a\n';
|
|
45
|
+
const OLD = '---\ntype: Report\ntitle: "Partner review, 5 Oct"\n---\n\n# Partner review, 5 Oct\n\n## Headline\nPartner activation is 30%.\n\n## Sources\n- KR metric record krm-a\n';
|
|
46
|
+
const pNew = RDraft.draftPath(dir, CAD, '2026-10-12'), pOld = RDraft.draftPath(dir, CAD, '2026-10-05');
|
|
47
|
+
fs.mkdirSync(path.join(dir, path.dirname(pNew)), { recursive: true });
|
|
48
|
+
fs.writeFileSync(path.join(dir, pNew), DOC); fs.writeFileSync(path.join(dir, pOld), OLD);
|
|
49
|
+
const git = (...a) => execFileSync('git', a, { cwd: dir, stdio: 'ignore' });
|
|
50
|
+
git('init', '-q'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'add', '-A'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '-m', 'records');
|
|
51
|
+
const iss = issues.appendFromCli(dir, [{ ev: 'issued', cadence: CAD, slot: '2026-10-05', path: pOld, sha: issues.blobSha(fs.readFileSync(path.join(dir, pOld))) }], { actor: { by: 'pm:wawan', via: 'cli' } });
|
|
52
|
+
/* The stub plays the report-design run: a turn writes a two-slide deck (a third slide on a later turn); a cycle render copies the reference. */
|
|
53
|
+
fs.writeFileSync(path.join(fakeBin, 'claude'), `#!/usr/bin/env node
|
|
54
|
+
const fs = require('fs');
|
|
55
|
+
let input = ''; process.stdin.on('data', (d) => { input += d; }); process.stdin.on('end', () => {
|
|
56
|
+
const line = (k) => { const m = new RegExp('^- ' + k + ': (.*)$', 'm').exec(input); return m ? m[1].trim() : null; };
|
|
57
|
+
const mode = line('Mode'); const out = line('Output path');
|
|
58
|
+
const done = (o) => { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: typeof o === 'string' ? o : JSON.stringify(o), num_turns: 2, duration_ms: 500, permission_denials: [] })); process.exit(0); };
|
|
59
|
+
if (!mode || !out) return done('Done.');
|
|
60
|
+
const sec = (id, title, body) => '<section class="pmos-slide" data-slide-id="' + id + '" data-kind="text" data-title="' + title + '">' + body + '</section>';
|
|
61
|
+
if (mode === 'turn') {
|
|
62
|
+
const prev = line('Previous version');
|
|
63
|
+
const more = prev && prev.startsWith('/');
|
|
64
|
+
const html = '<style>.pmos-slide{width:1280px;height:720px}.pmos-slide h1{font-size:64px;margin:80px}</style><script>window.parent.hacked = 1</script>'
|
|
65
|
+
+ sec('title', 'Partner review', '<h1 onclick="steal()">Partner review</h1>') + sec('headline', 'Headline', '<h2>Partner activation is 33%</h2>') + (more ? sec('needs', 'Needs your call', '<h2>Extend the pilot?</h2>') : '');
|
|
66
|
+
const took = [...input.matchAll(/^ {2}- (s-[0-9a-f]{8}) \\(NEW\\) "([^"]*)"/gm)].map((m) => ({ id: m[1], took: 'The dark title band from ' + m[2], readable: true }));
|
|
67
|
+
fs.writeFileSync(out, html);
|
|
68
|
+
setTimeout(() => done({ answer: more ? 'Added a slide for what needs your call.' : 'Made a dark title band.', took, rules: { same: ['The slide order'], changes: ['The numbers'], learned: [] } }), 400);
|
|
69
|
+
} else {
|
|
70
|
+
fs.writeFileSync(out, fs.readFileSync(line('Reference version'), 'utf8'));
|
|
71
|
+
done({ answer: 'Rendered the cycle.' });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
`, { mode: 0o755 });
|
|
75
|
+
const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', 'base64');
|
|
76
|
+
fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
|
|
77
|
+
|
|
78
|
+
(async () => {
|
|
79
|
+
ok('setup: the older cycle is issued', iss && iss.ok === true, JSON.stringify(iss));
|
|
80
|
+
const exe = findBrowser();
|
|
81
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
82
|
+
let chromium;
|
|
83
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
84
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
|
|
85
|
+
env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir, PMOS_NO_OPEN: '1', PMOS_REPORT_FIND: 'off', PMOS_CORE_DOCS: 'off', HOME: fakeHome, PATH: fakeBin + path.delimiter + process.env.PATH }) });
|
|
86
|
+
await T.waitForServer(BASE);
|
|
87
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
88
|
+
|
|
89
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true }), p = await ctx.newPage(), errs = [], posts = [];
|
|
90
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
91
|
+
p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
|
|
92
|
+
const shot = async (n) => { if (process.env.READ_SHOTS) await p.screenshot({ path: path.join(process.env.READ_SHOTS, n + '.png') }); };
|
|
93
|
+
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
94
|
+
const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
|
|
95
|
+
const counter = () => p.evaluate(() => (document.querySelector('#rdN') || {}).textContent || '');
|
|
96
|
+
const bigTitle = () => p.evaluate(() => { const h = document.querySelector('#rdSlide h3'); return h ? h.textContent : (document.querySelector('#rdSlide iframe') ? 'frame' : ''); });
|
|
97
|
+
const say = async (t) => { await p.fill('#rdIn', t); await p.press('#rdIn', 'Enter'); };
|
|
98
|
+
await p.goto(BASE + '/premium-insights.html');
|
|
99
|
+
await until(() => p.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
|
|
100
|
+
const rowSel = (slot) => `#repDocs [data-rep="rep:${CAD}:${slot}"]`;
|
|
101
|
+
|
|
102
|
+
/* O: a document row opens the reader on the page */
|
|
103
|
+
await tap(rowSel('2026-10-12'));
|
|
104
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
|
|
105
|
+
ok('O1 a document row opens the reader on the page, not the console', p.url().includes('/premium-insights.html') && await p.evaluate(() => document.querySelector('#dlg').classList.contains('rdrd')), p.url());
|
|
106
|
+
ok('O2 the dialog names the report, its date and its state', await p.textContent('#dTitle') === CAD && /2026-10-12|12 Oct/.test(await p.textContent('#dSub')) && /draft/.test(await p.textContent('#dEye')), await p.textContent('#dEye'));
|
|
107
|
+
ok('O3 the reader says it reads the words, as written', /The words of the document, as written/.test(await p.textContent('#rdSrc')), await p.textContent('#rdSrc'));
|
|
108
|
+
|
|
109
|
+
/* D: the deck */
|
|
110
|
+
ok('D1 the deck has a title slide and one slide per section', await counter() === '1 / 5' && await bigTitle() === 'Partner review, 12 Oct', await counter());
|
|
111
|
+
const strip = await p.evaluate(() => [...document.querySelectorAll('.rdt button span')].map((s) => s.textContent));
|
|
112
|
+
ok('D2 the strip lists the slides in the document\'s order', strip.join() === 'Partner review, 12 Oct,Headline,Initiatives,Needs your call,Sources', strip.join());
|
|
113
|
+
await tap('#oMain [data-rr="next"]');
|
|
114
|
+
ok('D3 Next moves to the headline, with its words as written', await counter() === '2 / 5' && await p.evaluate(() => document.querySelector('#rdSlide').textContent.includes('Partner activation is 33%, short of its line.') && document.querySelector('#rdSlide b').textContent === '33%'));
|
|
115
|
+
await p.focus('#rdSlide'); await p.keyboard.press('ArrowRight');
|
|
116
|
+
ok('D4 the arrow keys move, and a list stays a list', await counter() === '3 / 5' && await p.evaluate(() => document.querySelectorAll('#rdSlide li').length === 2));
|
|
117
|
+
await tap('#oMain [data-rr="go|4"]');
|
|
118
|
+
ok('D5 the strip goes to a slide', await counter() === '5 / 5' && await bigTitle() === 'Sources' && await p.evaluate(() => document.querySelector('[data-rr="next"]').disabled));
|
|
119
|
+
await shot('reader-deck-1280');
|
|
120
|
+
|
|
121
|
+
/* G: the page */
|
|
122
|
+
await tap('#oMain [data-rr="view|doc"]');
|
|
123
|
+
const heads = await p.evaluate(() => [...document.querySelectorAll('.rdpg h3')].map((h) => h.textContent));
|
|
124
|
+
ok('G1 Document shows the headings as written', heads.join() === 'Headline,Initiatives,Needs your call,Sources' && await p.evaluate(() => document.querySelector('.rdpg h2').textContent) === 'Partner review, 12 Oct', heads.join());
|
|
125
|
+
await tap('#oMain [data-rr="view|deck"]');
|
|
126
|
+
|
|
127
|
+
/* N: Present */
|
|
128
|
+
await tap('#oMain [data-rr="go|0"]');
|
|
129
|
+
await tap('#oMain [data-rr="present"]');
|
|
130
|
+
await until(() => p.$('#rdPres'));
|
|
131
|
+
ok('N1 Present shows the current slide over the whole page', await p.evaluate(() => { const r = document.querySelector('#rdPres').getBoundingClientRect(); return r.width >= innerWidth - 1 && r.height >= innerHeight - 1 && !!document.querySelector('#rdPres .rds.title'); }));
|
|
132
|
+
await p.keyboard.press('ArrowRight');
|
|
133
|
+
ok('N2 the arrow keys move while presenting', await p.evaluate(() => document.querySelector('#rdPres .rdpn span').textContent) === '2 / 5');
|
|
134
|
+
await p.keyboard.press('Escape'); await sleep(200);
|
|
135
|
+
ok('N3 Escape stops presenting and the reader stays open on that slide', !await p.$('#rdPres') && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')) && await counter() === '2 / 5');
|
|
136
|
+
|
|
137
|
+
/* W: download */
|
|
138
|
+
await tap('#oMain [data-rr="dm"]');
|
|
139
|
+
const items = await p.evaluate(() => [...document.querySelectorAll('.rpm [role="menuitem"]')].map((a) => a.textContent.split('(')[0].trim() + '|' + (a.getAttribute('href') || '')));
|
|
140
|
+
ok('W1 Download offers PowerPoint, Word, Excel, CSV and Markdown, through report-export', items.length === 5 && items.slice(0, 4).every((x, i) => x.includes('/api/report-export?') && x.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i]) && x.includes('path=' + encodeURIComponent(pNew))), items.join(' / '));
|
|
141
|
+
const [dl] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="dl|pptx"]')]);
|
|
142
|
+
const pptx = fs.readFileSync(await dl.path());
|
|
143
|
+
ok('W2 PowerPoint downloads a .pptx of the document', /\.pptx$/.test(dl.suggestedFilename()) && pptx.slice(0, 2).toString() === 'PK', dl.suggestedFilename());
|
|
144
|
+
await tap('#oMain [data-rr="dm"]');
|
|
145
|
+
const [md] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="md"]')]);
|
|
146
|
+
ok('W3 Markdown downloads the file as written', fs.readFileSync(await md.path(), 'utf8') === DOC && /\.md$/.test(md.suggestedFilename()), md.suggestedFilename());
|
|
147
|
+
|
|
148
|
+
/* X: print */
|
|
149
|
+
await p.evaluate(() => { window.__pr = null; window.open = () => ({ document: { open() {}, write(h) { window.__pr = h; }, close() {} }, focus() {}, print() { window.__printed = true; } }); });
|
|
150
|
+
await tap('#oMain [data-rr="print"]'); await sleep(450);
|
|
151
|
+
const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
|
|
152
|
+
ok('X1 Print opens the print page with one slide to a page', pr.printed && /pmos-print-deck/.test(pr.h) && (pr.h.match(/class="pmos-slide"/g) || []).length === 5 && pr.h.includes('premium-report-print.css'), pr.h.slice(0, 300));
|
|
153
|
+
|
|
154
|
+
/* L: the look */
|
|
155
|
+
ok('L1 with no design yet, the design row shows This cycle and no version', await p.evaluate(() => [...document.querySelectorAll('.rdv button')].map((b) => b.textContent).join()) === 'This cycle' && /No sample yet/.test(await p.textContent('.rdz')));
|
|
156
|
+
await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
|
|
157
|
+
await until(() => p.evaluate(() => /Follows q3-deck\.png/.test(document.querySelector('.rdz').textContent)));
|
|
158
|
+
ok('L2 Add a sample adds the file, and the row says the design follows it', /Follows q3-deck\.png/.test(await p.textContent('.rdz')) && /Added "q3-deck.png"/.test(await lastA()), await lastA());
|
|
159
|
+
await say('A dark title band, like the sample');
|
|
160
|
+
ok('L3 a turn says PMOS is working', /PMOS is working on it/.test(await lastA()));
|
|
161
|
+
await until(() => p.evaluate(() => /This is D1/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
|
|
162
|
+
ok('L4 the job\'s answer shows, and D1 is shown', /Made a dark title band\. This is D1/.test(await lastA()) && await p.evaluate(() => document.querySelector('.rdv [aria-pressed="true"]').textContent) === 'D1' && /Design version D1, not saved/.test(await p.textContent('#rdSrc')), await lastA());
|
|
163
|
+
const fr = await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].map((f) => ({ sb: f.getAttribute('sandbox'), doc: f.getAttribute('srcdoc') || '' })));
|
|
164
|
+
ok('L5 the version shows in frames with an empty sandbox, and its script and handlers were dropped', fr.length >= 1 && fr.every((f) => f.sb === '' && !/<script|onclick|steal/.test(f.doc)) && await p.evaluate(() => !window.hacked), JSON.stringify(fr.map((f) => f.sb)));
|
|
165
|
+
ok('L6 the deck of D1 has its two slides', await counter() === '1 / 2');
|
|
166
|
+
await say('Add a slide for what needs your call');
|
|
167
|
+
await until(() => p.evaluate(() => /This is D2/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
|
|
168
|
+
ok('L7 a second turn builds D2 on D1', await counter() === '1 / 3' && await p.evaluate(() => [...document.querySelectorAll('.rdv button')].map((b) => b.textContent).join()) === 'This cycle,D1,D2', await lastA());
|
|
169
|
+
await tap('#oMain [data-rr="ver|1"]');
|
|
170
|
+
await until(() => p.evaluate(() => document.querySelector('.rdv [aria-pressed="true"]').textContent === 'D1'));
|
|
171
|
+
ok('L8 picking D1 goes back to it, and says the next change builds on it', /Back to D1/.test(await lastA()) && posts.filter((x) => x === '/api/report-design/revert').length === 1, await lastA());
|
|
172
|
+
await tap('#oMain [data-rr="keep"]');
|
|
173
|
+
await until(() => p.evaluate(() => /Saved as the design/.test(document.querySelector('.rdz').textContent)));
|
|
174
|
+
ok('L9 This is it saves D1 as the design and says the cycle is drawn to match', /Saved D1 as the design of this report/.test(await lastA()) && !await p.$('#oMain [data-rr="keep"]'), await lastA());
|
|
175
|
+
await until(() => p.evaluate(() => !/PMOS is working/.test(document.querySelector('.rdz').textContent)), 30000);
|
|
176
|
+
await tap('#oMain [data-rr="ver|cycle"]');
|
|
177
|
+
await until(() => p.evaluate(() => /drawn to the saved design/.test(document.querySelector('#rdSrc').textContent)), 10000);
|
|
178
|
+
ok('L10 this cycle, redrawn, shows in the saved design in sandboxed frames', /This cycle, drawn to the saved design D1/.test(await p.textContent('#rdSrc')) && await bigTitle() === 'frame' && await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].every((f) => f.getAttribute('sandbox') === '')), await p.textContent('#rdSrc'));
|
|
179
|
+
await shot('reader-look-1280');
|
|
180
|
+
await p.click('#dClose'); await sleep(200);
|
|
181
|
+
|
|
182
|
+
/* I: an issued cycle is frozen */
|
|
183
|
+
await tap(rowSel('2026-10-05'));
|
|
184
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
|
|
185
|
+
ok('I1 an issued cycle has no design versions and no turn, and says it is frozen', !await p.$('#rdF') && !await p.$('.rdv') && /issued, so it is frozen/.test(await p.textContent('.rdz')) && /issued/.test(await p.textContent('#dEye')));
|
|
186
|
+
ok('I2 an issued cycle still reads as a deck', await counter() === '1 / 3');
|
|
187
|
+
await p.click('#dClose'); await sleep(200);
|
|
188
|
+
|
|
189
|
+
/* P: the writes */
|
|
190
|
+
const allowed = new Set(['/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert']);
|
|
191
|
+
ok('P1 the only POSTs are the report-design describe, sample, turn, accept and revert routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
|
|
192
|
+
ok('P2 the first turn described the look first, and each later press posted once', posts.join() === ['sample', 'describe', 'turn', 'turn', 'revert', 'accept'].map((x) => '/api/report-design/' + x).join(), posts.join());
|
|
193
|
+
ok('P3 the document file is unchanged', fs.readFileSync(path.join(dir, pNew), 'utf8') === DOC);
|
|
194
|
+
|
|
195
|
+
/* F: floors */
|
|
196
|
+
await tap(rowSel('2026-10-12'));
|
|
197
|
+
await until(() => p.evaluate(() => !!document.querySelector('#rdSlide')));
|
|
198
|
+
const small = await p.evaluate(() => [...document.querySelectorAll('#oMain button, #oMain a')].filter((b) => b.offsetParent && !b.closest('.rdt')).map((b) => { return { t: (b.textContent || b.getAttribute('aria-label') || '').trim().slice(0, 30), h: b.offsetHeight }; }).filter((x) => x.h < 44 && x.t !== 'Open in the console'));
|
|
199
|
+
ok('F1 every control of the reader is at least 44 px tall', small.length === 0, JSON.stringify(small));
|
|
200
|
+
await p.setViewportSize({ width: 390, height: 844 }); await sleep(400);
|
|
201
|
+
ok('F2 no sideways scroll at 390 px', await p.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1 && document.querySelector('#oMain').scrollWidth <= document.querySelector('#oMain').clientWidth + 1));
|
|
202
|
+
await shot('reader-deck-390');
|
|
203
|
+
ok('F4 the read-only ask of the dialog is hidden; the reader\'s own form is the one it has', await p.evaluate(() => getComputedStyle(document.querySelector('#askF')).display === 'none' && getComputedStyle(document.querySelector('#rdF')).display !== 'none'));
|
|
204
|
+
ok('F3 no page error', errs.length === 0, errs.join(' | '));
|
|
205
|
+
return finish();
|
|
206
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv } from './premium-shell.js';
|
|
10
10
|
import { pmPost, pmGet } from './http.js';
|
|
11
11
|
import { openStudio } from './premium-studio.js';
|
|
12
|
+
import { openReport } from './premium-report-read.js';
|
|
12
13
|
|
|
13
14
|
let M = null; // the model
|
|
14
15
|
let dash = 'all'; // the dashboard on screen
|
|
@@ -194,7 +195,7 @@ let askTimer = 0;
|
|
|
194
195
|
const dismissing = new Map(); // finding id → timer: "Not a report" waits 5 s for an Undo before it is sent
|
|
195
196
|
const ASKST = { running: ['Working', 'draft'], ready: ['Ready to review', 'issued'], failed: ['Failed', 'none'] };
|
|
196
197
|
function repRow(r) {
|
|
197
|
-
return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="
|
|
198
|
+
return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="${esc(r.key)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Deck, present, download, print</span></span></span></button></div>`;
|
|
198
199
|
}
|
|
199
200
|
const foundRow = (f) => `<div class="dmr" role="listitem"><button class="dmo" data-found="${esc(f.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(f.name)}</b><small>${esc(f.why)}</small><span class="dmm">${f.confidence ? `<span>${esc(f.confidence)}</span>` : ''}<span>${f.evidence.length} ${f.evidence.length === 1 ? 'sign' : 'signs'} in your work</span></span></span></button></div>`;
|
|
200
201
|
const askRow = (a) => `<div class="dmr" role="listitem"><button class="dmo" data-ask="${esc(a.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(a.proposal && a.proposal.name ? a.proposal.name : a.text)}</b><small>You asked: ${esc(a.text)}</small><span class="dmm"><span class="s ${ASKST[a.state][1]}">${ASKST[a.state][0]}</span>${a.changed ? '<span>Changed once</span>' : ''}</span></span></button></div>`;
|
|
@@ -212,12 +213,14 @@ function drawReps() {
|
|
|
212
213
|
+ (R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
|
|
213
214
|
: R.rows.length ? `<div class="dmg ngrp" id="repDocs" role="list"><p class="label">Documents · <b>${R.counts.draft}</b> ${R.counts.draft === 1 ? 'draft' : 'drafts'} · <b>${R.counts.issued}</b> issued</p>${R.rows.map(repRow).join('')}</div>`
|
|
214
215
|
: '<div class="nempty"><p><b>No report file is on record.</b> Set one up above, or ask PMOS for one.</p></div>')
|
|
215
|
-
+ `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to
|
|
216
|
+
+ `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to edit or issue a document.</p>`;
|
|
216
217
|
clearTimeout(askTimer);
|
|
217
218
|
if (asks.some((a) => a.state === 'running')) askTimer = setTimeout(load, 5000);
|
|
218
219
|
}
|
|
219
220
|
$('#repBody').addEventListener('click', (e) => {
|
|
220
|
-
|
|
221
|
+
const rp = e.target.closest('[data-rep]');
|
|
222
|
+
if (rp) { const row = M.reports.rows.find((x) => x.key === rp.dataset.rep), su = row && (M.reports.setups || []).find((x) => x.id === row.cadence); openReport(row, { ws: M.board.ws, name: su ? su.name : null }); return; }
|
|
223
|
+
if (e.target.closest('#repOpen')) { location.assign('/c3.html?tab=rep'); return; }
|
|
221
224
|
if (e.target.closest('#repNew')) { openReportEdit(null); return; }
|
|
222
225
|
const f = e.target.closest('[data-found]'), a = e.target.closest('[data-ask]'), s = e.target.closest('[data-setup]');
|
|
223
226
|
if (f) openFound((M.reports.found || []).find((x) => x.id === f.dataset.found));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* pm/premium-report-print.css — the print page of a report's words (initiative premium-report-read; premium-report-read.js printHtml).
|
|
2
|
+
One slide to a 1280 x 720 page in Deck view (c3-report-frame.css sets the page), the page as written in Document view. Colours are the slide tokens. */
|
|
3
|
+
body.pmos-print { margin: 0; font-family: var(--sans); color: var(--slide-fg); background: var(--slide-bg); }
|
|
4
|
+
body.pmos-print-deck > .pmos-slide { padding: 72px 96px; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
|
|
5
|
+
.rp-slide__h { margin: 0; font-size: 24px; font-weight: 700; }
|
|
6
|
+
.rp-slide__t p, .rp-slide__t li { margin: 0; font-size: 16px; line-height: 1.45; }
|
|
7
|
+
.rp-slide__t ul { margin: 0; display: grid; gap: 12px; }
|
|
8
|
+
body.pmos-print-doc { padding: 48px; }
|
|
9
|
+
body.pmos-print-doc h2 { margin: 24px 0 8px; font-size: 20px; }
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/* pm/premium-report-read.js — a report document read on the premium Insights page (initiative premium-report-read; planning/prd/premium-report-read-prd.md).
|
|
2
|
+
* The mockup's report sheet (prototype/premium-ux-concept/build-src/rep.js.txt): the deck or the page, Present, Download, Print, and the design row
|
|
3
|
+
* (versions, samples, This is it). It opens in the page's dialog; the conversation on the left shapes the look.
|
|
4
|
+
*
|
|
5
|
+
* openReport(row, hand) row = a Reports card document { cadence, slot, date, path, state }; hand = { ws, name (the set-up report's name, or null) }
|
|
6
|
+
* wordsOf(md, fallback) the document as { title, sections: [{ h, lines }] } (pure)
|
|
7
|
+
* slideHtml(lines) a section's lines as html: paragraphs and lists, as written (pure)
|
|
8
|
+
*
|
|
9
|
+
* READS: GET /api/doc (the words), GET /api/report-design/cycle and cycle-html (a cycle drawn to the saved design), GET /api/report-design and
|
|
10
|
+
* version (the design and its versions), GET /api/report-export (the files). PDF is the browser's print. Every render is HTML the server sanitized,
|
|
11
|
+
* shown in a frame with an empty sandbox: nothing in it runs.
|
|
12
|
+
* WRITES: only the report-design describe, sample, turn, accept and revert routes, each a press on the page (pmPost, behind the launch nonce). An
|
|
13
|
+
* issued cycle is frozen: no design row and no turn. Editing, issuing and the copies in other tools stay in the console. */
|
|
14
|
+
import { $, esc, openDlg, toast, turnA, turnU, ptx, setFull } from './premium-shell.js';
|
|
15
|
+
import { pmGet, pmPost } from './http.js';
|
|
16
|
+
|
|
17
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
18
|
+
const PREV = ICO('<path d="m15 6-6 6 6 6"/>'), NEXT = ICO('<path d="m9 6 6 6-6 6"/>'), CHV = ICO('<path d="M6 9l6 6 6-6"/>'), XI = ICO('<path d="M6 6l12 12M18 6 6 18"/>');
|
|
19
|
+
const DLI = ICO('<path d="M12 4v11M7 10l5 5 5-5M5 20h14"/>'), PRI = ICO('<path d="M7 9V4h10v5M7 17H5v-6h14v6h-2M8 14h8v6H8z"/>'), PLAY = ICO('<path d="M8 5v14l11-7z"/>');
|
|
20
|
+
const CHK = ICO('<path d="M5 12.5l4.5 4.5L19 7.5"/>'), PLUS = ICO('<path d="M12 5v14M5 12h14"/>'), SEND = ICO('<path d="M5 12h14M13 6l6 6-6 6"/>');
|
|
21
|
+
const W = 1280;
|
|
22
|
+
const POLL_MS = 800, POLL_MAX = 240000;
|
|
23
|
+
const DL = [['pptx', 'PowerPoint (.pptx)', 'A title slide, then one slide for each section.'], ['docx', 'Word (.docx)', 'Headings, paragraphs and lists.'],
|
|
24
|
+
['xlsx', 'Excel (.xlsx)', 'The tables and lists of the document, one sheet each.'], ['csv', 'CSV (.csv)', 'The rows of the document as plain text.']];
|
|
25
|
+
const KINDS = { pdf: 'pdf', pptx: 'pptx', docx: 'docx', png: 'image', jpg: 'image', jpeg: 'image' };
|
|
26
|
+
|
|
27
|
+
let R = null; // the open reader
|
|
28
|
+
|
|
29
|
+
const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
30
|
+
const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
31
|
+
|
|
32
|
+
/** The document as a title and its sections, as written. A `## ` heading starts a section; the text before the first one is the lead. */
|
|
33
|
+
export function wordsOf(md, fallback) {
|
|
34
|
+
const lines = String(md || '').replace(/\r/g, '').split('\n');
|
|
35
|
+
let i = 0, title = '';
|
|
36
|
+
if (lines[0] === '---') { const e = lines.indexOf('---', 1); if (e > 0) { for (const l of lines.slice(1, e)) { const m = /^title:\s*(.*)$/.exec(l); if (m) title = m[1].replace(/^["'](.*)["']$/, '$1').trim(); } i = e + 1; } }
|
|
37
|
+
const sections = [], lead = [];
|
|
38
|
+
let cur = null;
|
|
39
|
+
for (; i < lines.length; i++) {
|
|
40
|
+
const l = lines[i];
|
|
41
|
+
const h1 = /^#\s+(.*)$/.exec(l), h2 = /^##\s+(.*)$/.exec(l);
|
|
42
|
+
if (h1) { if (!title) title = h1[1].trim(); continue; }
|
|
43
|
+
if (h2) { cur = { h: h2[1].trim(), lines: [] }; sections.push(cur); continue; }
|
|
44
|
+
(cur ? cur.lines : lead).push(l);
|
|
45
|
+
}
|
|
46
|
+
if (lead.some((l) => l.trim())) sections.unshift({ h: 'Summary', lines: lead });
|
|
47
|
+
return { title: title || fallback || 'Report', sections };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A section's lines as html: a list for each run of bullets, a sub-heading in bold, every other line a paragraph. */
|
|
51
|
+
export function slideHtml(lines) {
|
|
52
|
+
const out = [];
|
|
53
|
+
let list = [];
|
|
54
|
+
const flush = () => { if (list.length) { out.push('<ul>' + list.map((x) => '<li>' + inline(x) + '</li>').join('') + '</ul>'); list = []; } };
|
|
55
|
+
for (const l of lines || []) {
|
|
56
|
+
const b = /^\s*[-*]\s+(.*)$/.exec(l), h = /^#{3,6}\s+(.*)$/.exec(l);
|
|
57
|
+
if (b) { list.push(b[1]); continue; }
|
|
58
|
+
flush();
|
|
59
|
+
if (h) out.push('<p><b>' + inline(h[1]) + '</b></p>');
|
|
60
|
+
else if (l.trim()) out.push('<p>' + inline(l.trim()) + '</p>');
|
|
61
|
+
}
|
|
62
|
+
flush();
|
|
63
|
+
return out.join('') || '<p>This section is empty.</p>';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ── a sanitized render: its style, its slides and its body (DOMParser; nothing of it runs) ── */
|
|
67
|
+
function splitRender(html) {
|
|
68
|
+
const d = new DOMParser().parseFromString(String(html || ''), 'text/html');
|
|
69
|
+
d.querySelectorAll('script,iframe,object,embed,link,meta,base').forEach((n) => n.remove());
|
|
70
|
+
d.querySelectorAll('*').forEach((n) => { for (const a of [...n.attributes]) if (/^on/i.test(a.name) || /^\s*javascript:/i.test(a.value)) n.removeAttribute(a.name); });
|
|
71
|
+
const style = [...d.querySelectorAll('style')].map((s) => s.textContent).join('\n');
|
|
72
|
+
d.querySelectorAll('style').forEach((s) => s.remove());
|
|
73
|
+
const slides = [...d.querySelectorAll('section.pmos-slide')].map((s, i) => ({ h: s.getAttribute('data-title') || 'Slide ' + (i + 1), html: s.outerHTML }));
|
|
74
|
+
return { style, slides, body: d.body.innerHTML };
|
|
75
|
+
}
|
|
76
|
+
const href = (f) => new URL('./' + f, import.meta.url).href;
|
|
77
|
+
function frameDoc(style, inner, cls) {
|
|
78
|
+
return '<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="stylesheet" href="' + esc(href('tokens.css')) + '"><link rel="stylesheet" href="' + esc(href('c3-report-frame.css')) + '">'
|
|
79
|
+
+ '<style>' + String(style || '').replace(/<\/style/gi, '<\\/style') + '</style></head><body class="pmos-frame ' + cls + '">' + String(inner || '') + '</body></html>';
|
|
80
|
+
}
|
|
81
|
+
const frame = (style, inner, cls, title) => `<iframe class="rdif" sandbox="" tabindex="-1" title="${esc(title)}" srcdoc="${esc(frameDoc(style, inner, cls))}"></iframe>`;
|
|
82
|
+
|
|
83
|
+
/* ── what is shown: the cycle (its words, or its designed render) or a design version ── */
|
|
84
|
+
function source() {
|
|
85
|
+
if (R.show !== 'cycle') return { kind: 'ver', n: R.show, X: R.ver.get(R.show) || null };
|
|
86
|
+
return R.cyc ? { kind: 'cycle', X: R.cyc } : { kind: 'words' };
|
|
87
|
+
}
|
|
88
|
+
function slides() {
|
|
89
|
+
const s = source();
|
|
90
|
+
if (s.kind === 'words') {
|
|
91
|
+
const w = R.W || { title: R.name, sections: [] };
|
|
92
|
+
return [{ k: 'title', h: w.title, t: [R.name, R.row.date || R.row.slot, R.issued ? 'Issued' : 'Draft'].filter(Boolean).join(' · ') }].concat(w.sections.map((x) => ({ k: 'text', h: x.h, html: slideHtml(x.lines) })));
|
|
93
|
+
}
|
|
94
|
+
return s.X ? s.X.slides.map((x) => ({ k: 'frame', h: x.h, html: x.html, css: s.X.style })) : [];
|
|
95
|
+
}
|
|
96
|
+
function sourceLine() {
|
|
97
|
+
const s = source(), d = R.design;
|
|
98
|
+
if (s.kind === 'words') return R.err ? 'The document could not be read: ' + R.err : 'The words of the document, as written. ' + (d && d.saved ? 'This cycle is not drawn to the design yet.' : 'No design is saved for this report yet.');
|
|
99
|
+
if (s.kind === 'cycle') return 'This cycle, drawn to the saved design' + (R.cycle && R.cycle.design_version ? ' D' + R.cycle.design_version : '') + '.';
|
|
100
|
+
if (!s.X) return 'Reading D' + s.n + '.';
|
|
101
|
+
return 'Design version D' + s.n + (d && d.saved && d.saved.version === s.n ? ', the saved design.' : ', not saved. Press This is it to keep it.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* ── drawing ── */
|
|
105
|
+
function slideCard(s, mini) {
|
|
106
|
+
if (s.k === 'frame') return `<div class="rdfc${mini ? ' mini' : ''}">${frame(s.css, s.html, 'pmos-one', s.h)}</div>`;
|
|
107
|
+
if (s.k === 'title') return `<div class="rds title${mini ? ' mini' : ''}"><h3>${esc(s.h)}</h3>${mini ? '' : `<p>${esc(s.t)}</p>`}</div>`;
|
|
108
|
+
return `<div class="rds${mini ? ' mini' : ''}"><h3>${esc(s.h)}</h3>${mini ? '' : s.html}</div>`;
|
|
109
|
+
}
|
|
110
|
+
function deckHtml() {
|
|
111
|
+
const L = slides();
|
|
112
|
+
if (!L.length) return '<p class="note">This version has no slides. Read it as a page.</p>';
|
|
113
|
+
const i = R.i = Math.max(0, Math.min(R.i, L.length - 1));
|
|
114
|
+
return `<div class="rdk"><div class="rdbig" id="rdSlide" tabindex="0" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(L[i].h)}. Use the arrow keys to change slide.">${slideCard(L[i])}</div>`
|
|
115
|
+
+ `<div class="rdnv"><button data-rr="prev" aria-label="Previous slide"${i === 0 ? ' disabled' : ''}>${PREV}</button><span id="rdN">${i + 1} / ${L.length}</span><button data-rr="next" aria-label="Next slide"${i === L.length - 1 ? ' disabled' : ''}>${NEXT}</button></div>`
|
|
116
|
+
+ `<div class="rdt" role="group" aria-label="Slides">${L.map((x, j) => `<button data-rr="go|${j}"${j === i ? ' aria-current="true"' : ''} aria-label="Slide ${j + 1}: ${esc(x.h)}"><span>${esc(x.h)}</span><i>${j + 1}</i></button>`).join('')}</div></div>`;
|
|
117
|
+
}
|
|
118
|
+
function pageHtml() {
|
|
119
|
+
const s = source();
|
|
120
|
+
if (s.kind === 'words') {
|
|
121
|
+
const w = R.W || { title: R.name, sections: [] };
|
|
122
|
+
return `<article class="paper doc rdpg"><h2>${esc(w.title)}</h2>${w.sections.map((x) => `<h3 class="d2">${esc(x.h)}</h3>${slideHtml(x.lines)}`).join('')}</article>`;
|
|
123
|
+
}
|
|
124
|
+
if (!s.X) return '<p class="note">Reading the render.</p>';
|
|
125
|
+
return `<div class="rdpf">${frame(s.X.style, s.X.body, '', 'The report as a page')}</div>`;
|
|
126
|
+
}
|
|
127
|
+
function designHtml() {
|
|
128
|
+
if (R.issued) return '<div class="rdz"><span class="label">Design</span><span class="rds2">This cycle is issued, so it is frozen with the look it was issued with.</span></div>';
|
|
129
|
+
const d = R.design;
|
|
130
|
+
if (!d) return `<div class="rdz"><span class="label">Design</span><span class="rds2">${R.dErr ? esc(R.dErr) : 'Reading the design.'}</span></div>`;
|
|
131
|
+
const vs = d.versions || [], shown = R.show, saved = d.saved ? d.saved.version : null;
|
|
132
|
+
const smp = (d.samples || []).length ? 'Follows ' + d.samples.map((x) => `<em>${esc(x.name)}</em>`).join(', ') : 'No sample yet.';
|
|
133
|
+
const keep = shown === 'cycle' ? '' : saved === shown ? `<span class="s issued">${CHK}Saved as the design</span>` : `<button class="dmcta alt" data-rr="keep"${R.busy ? ' disabled' : ''}>This is it</button>`;
|
|
134
|
+
return `<div class="rdz"><span class="label">Design</span><span class="rdv" role="group" aria-label="Design versions"><button data-rr="ver|cycle" aria-pressed="${shown === 'cycle'}">This cycle</button>${vs.map((v) => `<button data-rr="ver|${v.n}" aria-pressed="${shown === v.n}"${R.busy ? ' disabled' : ''} title="${esc(v.turn || '')}">D${v.n}</button>`).join('')}</span>`
|
|
135
|
+
+ `<span class="rds2">${smp}${d.running || R.busy ? ' <b>PMOS is working on it.</b>' : ''}</span><button class="dlink" data-rr="pick">${PLUS}Add a sample</button><input type="file" id="rdFile" hidden accept=".pdf,.pptx,.docx,.png,.jpg,.jpeg">${keep}</div>`;
|
|
136
|
+
}
|
|
137
|
+
function barHtml() {
|
|
138
|
+
const dm = R.dm ? `<div class="dsmn rpm" role="menu" aria-label="Download"><p class="label">Download a file</p>${DL.map(([k, l, s]) => `<a role="menuitem" data-rr="dl|${k}" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: k }))}" download>${DLI}<span>${esc(l)}<small>${esc(s)}</small></span></a>`).join('')}<button role="menuitem" data-rr="md">${DLI}<span>Markdown (.md)<small>The file, as written.</small></span></button><p class="note rpmn">The files carry the words, not the look. Print or save as PDF keeps the look.</p></div>` : '';
|
|
139
|
+
return `<div class="rdbar"><div class="seg rdvw" role="group" aria-label="View"><button data-rr="view|deck" aria-pressed="${R.view === 'deck'}">Deck</button><button data-rr="view|doc" aria-pressed="${R.view === 'doc'}">Document</button></div>`
|
|
140
|
+
+ `<button class="dsvb" data-rr="present">${PLAY}Present</button><span class="dsvw"><button class="dsvb" data-rr="dm" aria-haspopup="menu" aria-expanded="${!!R.dm}">${DLI}Download${CHV}</button>${dm}</span><button class="dsvb" data-rr="print">${PRI}Print or save as PDF</button></div>`;
|
|
141
|
+
}
|
|
142
|
+
function draw() {
|
|
143
|
+
if (!R) return;
|
|
144
|
+
const m = $('#oMain');
|
|
145
|
+
const keep = document.activeElement && document.activeElement.closest && document.activeElement.closest('#oMain') ? document.activeElement.getAttribute('data-rr') : null;
|
|
146
|
+
m.innerHTML = `<div class="rdr" id="rdR">${barHtml()}<p class="note rdsrc" id="rdSrc">${esc(sourceLine())}</p>${designHtml()}${R.view === 'deck' ? deckHtml() : pageHtml()}<p class="note rdcon"><a class="lk" href="/c3.html?tab=rep">Open in the console</a> to edit or issue this document.</p></div>`;
|
|
147
|
+
fit(m);
|
|
148
|
+
if (keep) { const b = m.querySelector(`[data-rr="${keep}"]`); if (b) b.focus(); }
|
|
149
|
+
}
|
|
150
|
+
/* a 1280 x 720 frame scales to its card's width */
|
|
151
|
+
const RO = typeof ResizeObserver === 'function' ? new ResizeObserver((es) => { for (const e of es) scaleOf(e.target, e.contentRect.width); }) : null;
|
|
152
|
+
function scaleOf(card, w) { if (w) card.style.setProperty('--rp-scale', String(Math.round((w / W) * 10000) / 10000)); }
|
|
153
|
+
function fit(root) { root.querySelectorAll('.rdfc').forEach((c) => { if (RO) RO.observe(c); scaleOf(c, c.getBoundingClientRect().width); }); }
|
|
154
|
+
|
|
155
|
+
/* ── the conversation ── */
|
|
156
|
+
const stream = () => $('#dBody .stream');
|
|
157
|
+
function sayA(t) { const s = stream(); if (!s) return null; s.insertAdjacentHTML('beforeend', turnA(ptx(t))); s.scrollTop = s.scrollHeight; const a = s.querySelectorAll('.turn.a .tt'); return a[a.length - 1]; }
|
|
158
|
+
function sayU(t) { const s = stream(); if (s) s.insertAdjacentHTML('beforeend', turnU(t)); }
|
|
159
|
+
async function onSay(e) {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
const inp = $('#rdIn'), t = inp.value.trim();
|
|
162
|
+
if (!t || !R) return;
|
|
163
|
+
inp.value = ''; sayU(t);
|
|
164
|
+
if (R.issued) { sayA('This cycle is issued, so its look is frozen. Nothing changed.'); return; }
|
|
165
|
+
if (R.busy || (R.design && R.design.running)) { sayA('PMOS is still working on the last change. Wait for its answer, then try again.'); return; }
|
|
166
|
+
const line = sayA('PMOS is working on it.');
|
|
167
|
+
R.busy = true; draw();
|
|
168
|
+
if (R.design && !R.design.description) { const d = await pmPost('/api/report-design/describe', { ws: R.ws, id: R.id, text: t }).catch((x) => ({ ok: false, error: String(x && x.message || x) })); if (!d || d.ok !== true) return answer(line, (d && d.error) || 'The description could not be saved.'); }
|
|
169
|
+
const r = await pmPost('/api/report-design/turn', { ws: R.ws, id: R.id, text: t }).catch((x) => ({ ok: false, error: String(x && x.message || x) }));
|
|
170
|
+
if (!r || r.ok !== true) return answer(line, 'Nothing changed: ' + ((r && r.error) || 'the change could not start.'));
|
|
171
|
+
const before = (R.design && R.design.log || []).length;
|
|
172
|
+
const d = await settle();
|
|
173
|
+
if (!d) return answer(line, 'PMOS did not answer in time. The design is read again when you open the report.');
|
|
174
|
+
const L = (d.log || []).slice(before).filter((x) => x.kind === 'version' || x.kind === 'error');
|
|
175
|
+
const last = L[L.length - 1];
|
|
176
|
+
if (last && last.kind === 'version' && last.version) { await showVersion(last.version); return answer(line, last.text + ' This is D' + last.version + '. Press This is it to keep it as the design.'); }
|
|
177
|
+
return answer(line, last ? 'The change did not work: ' + last.text : 'PMOS ended without a new version.');
|
|
178
|
+
}
|
|
179
|
+
function answer(line, t) { R.busy = false; if (line) line.textContent = t; else sayA(t); draw(); }
|
|
180
|
+
/* read the design again until no job runs */
|
|
181
|
+
async function settle() {
|
|
182
|
+
const t0 = Date.now();
|
|
183
|
+
for (;;) {
|
|
184
|
+
const d = await readDesign();
|
|
185
|
+
if (!R) return null;
|
|
186
|
+
if (d && !d.running) return d;
|
|
187
|
+
if (Date.now() - t0 > POLL_MAX) return null;
|
|
188
|
+
await new Promise((ok) => setTimeout(ok, POLL_MS));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async function readDesign() {
|
|
192
|
+
const j = await Promise.resolve(pmGet('/api/report-design?' + q({ ws: R.ws, id: R.id }))).catch(() => null);
|
|
193
|
+
if (!R) return null;
|
|
194
|
+
if (j && j.ok) { R.design = j.design; R.dErr = ''; } else { R.design = null; R.dErr = (j && j.error) || 'The design of this report could not be read.'; }
|
|
195
|
+
return R.design;
|
|
196
|
+
}
|
|
197
|
+
async function textOf(url) {
|
|
198
|
+
const r = await fetch(url, { credentials: 'same-origin' });
|
|
199
|
+
if (!r.ok) throw new Error((await r.text().catch(() => '')) || 'the workspace did not answer');
|
|
200
|
+
return r.text();
|
|
201
|
+
}
|
|
202
|
+
async function showVersion(n) {
|
|
203
|
+
R.show = n;
|
|
204
|
+
if (!R.ver.has(n)) { try { R.ver.set(n, splitRender(await textOf('/api/report-design/version?' + q({ ws: R.ws, id: R.id, n })))); } catch (x) { toast('D' + n + ' could not be read.'); R.show = 'cycle'; } }
|
|
205
|
+
if (R.view === 'deck' && !slides().length) R.view = 'doc';
|
|
206
|
+
R.i = 0; draw();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* ── the presses ── */
|
|
210
|
+
async function act(a) {
|
|
211
|
+
const [k, v] = a;
|
|
212
|
+
if (k === 'view') { R.view = v; draw(); return; }
|
|
213
|
+
if (k === 'prev' || k === 'next') { R.i += k === 'next' ? 1 : -1; draw(); return; }
|
|
214
|
+
if (k === 'go') { R.i = +v; draw(); return; }
|
|
215
|
+
if (k === 'dm') { R.dm = !R.dm; draw(); return; }
|
|
216
|
+
if (k === 'dl') { R.dm = false; setTimeout(draw, 0); return; }
|
|
217
|
+
if (k === 'md') { R.dm = false; saveMd(); draw(); return; }
|
|
218
|
+
if (k === 'print') { printIt(); return; }
|
|
219
|
+
if (k === 'present') { present(true); return; }
|
|
220
|
+
if (k === 'pick') { const f = $('#rdFile'); if (f) f.click(); return; }
|
|
221
|
+
if (k === 'ver') {
|
|
222
|
+
if (v === 'cycle') { R.show = 'cycle'; R.i = 0; draw(); return; }
|
|
223
|
+
const n = +v;
|
|
224
|
+
if (R.design && R.design.current !== n) {
|
|
225
|
+
const r = await pmPost('/api/report-design/revert', { ws: R.ws, id: R.id, n }).catch(() => null);
|
|
226
|
+
if (!r || r.ok !== true) { toast((r && r.error) || 'D' + n + ' could not be picked.'); return; }
|
|
227
|
+
R.design = r.design;
|
|
228
|
+
sayA('Back to D' + n + '. The next change builds on it.');
|
|
229
|
+
}
|
|
230
|
+
await showVersion(n);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (k === 'keep') {
|
|
234
|
+
const n = R.show;
|
|
235
|
+
R.busy = true; draw();
|
|
236
|
+
const r = await pmPost('/api/report-design/accept', { ws: R.ws, id: R.id, n }).catch(() => null);
|
|
237
|
+
R.busy = false;
|
|
238
|
+
if (!r || r.ok !== true) { draw(); toast((r && r.error) || 'The design could not be saved.'); return; }
|
|
239
|
+
R.design = r.design;
|
|
240
|
+
sayA('Saved D' + n + ' as the design of this report. ' + (r.redraw && r.redraw.started ? 'PMOS is drawing this cycle to match it.' : 'Each new cycle is drawn to match it.') + ' Nothing is sent.');
|
|
241
|
+
draw();
|
|
242
|
+
if (r.redraw && r.redraw.started) { await settle(); await readCycle(); draw(); }
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function saveMd() {
|
|
246
|
+
const name = (R.row.path.split('/').slice(-2).join('-') || 'report.md');
|
|
247
|
+
const u = URL.createObjectURL(new Blob([R.text || ''], { type: 'text/markdown' })), a = document.createElement('a');
|
|
248
|
+
a.href = u; a.download = name; a.setAttribute('data-rr-md', name); document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(u), 3000);
|
|
249
|
+
toast('Saved ' + name + '.');
|
|
250
|
+
}
|
|
251
|
+
async function addSample(file) {
|
|
252
|
+
const ext = (/\.([a-z0-9]+)$/i.exec(file.name) || [])[1], kind = KINDS[String(ext || '').toLowerCase()];
|
|
253
|
+
if (!kind) { toast('A sample is a PDF, PowerPoint, Word, PNG or JPG file.'); return; }
|
|
254
|
+
const data = await new Promise((ok) => { const r = new FileReader(); r.onload = () => ok(String(r.result || '')); r.onerror = () => ok(''); r.readAsDataURL(file); });
|
|
255
|
+
if (!data) { toast('The file could not be read.'); return; }
|
|
256
|
+
const r = await pmPost('/api/report-design/sample', { ws: R.ws, id: R.id, name: file.name, kind, data }).catch((x) => ({ ok: false, error: String(x && x.message || x) }));
|
|
257
|
+
if (!r || r.ok !== true) { sayA('The sample was not added: ' + ((r && r.error) || 'the press did not go through.')); return; }
|
|
258
|
+
await readDesign(); draw();
|
|
259
|
+
sayA('Added "' + file.name + '". Tell me what to take from it, and I make the next version follow it.');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* ── Present: the current slide on the whole screen ── */
|
|
263
|
+
function presHtml() {
|
|
264
|
+
const L = slides(), i = R.i;
|
|
265
|
+
return `<div class="rdpbox">${L.length ? slideCard(L[i]) : ''}</div><div class="rdpn"><button data-rp="prev" aria-label="Previous slide"${i === 0 ? ' disabled' : ''}>${PREV}</button><span>${i + 1} / ${L.length}</span><button data-rp="next" aria-label="Next slide"${i >= L.length - 1 ? ' disabled' : ''}>${NEXT}</button><button data-rp="end" aria-label="Stop presenting">${XI}</button></div>`;
|
|
266
|
+
}
|
|
267
|
+
function present(on) {
|
|
268
|
+
let p = $('#rdPres');
|
|
269
|
+
if (!on) { if (p) p.remove(); if (document.fullscreenElement) document.exitFullscreen().catch(() => {}); setFull(!R.unfull); R.unfull = false; draw(); const b = $('#oMain [data-rr="present"]'); if (b) b.focus(); return; }
|
|
270
|
+
if (R.view !== 'deck' || !slides().length) { R.view = 'deck'; if (!slides().length) { toast('This version has no slides to present.'); return; } }
|
|
271
|
+
if (!$('#dlg').classList.contains('full')) { R.unfull = true; setFull(true); }
|
|
272
|
+
if (!p) { p = document.createElement('div'); p.id = 'rdPres'; p.className = 'rdpres'; p.setAttribute('role', 'dialog'); p.setAttribute('aria-modal', 'true'); p.setAttribute('aria-label', 'Presenting ' + R.name); p.tabIndex = -1; document.body.appendChild(p); }
|
|
273
|
+
p.innerHTML = presHtml(); fit(p);
|
|
274
|
+
if (p.requestFullscreen && !document.fullscreenElement) p.requestFullscreen().catch(() => {});
|
|
275
|
+
p.focus();
|
|
276
|
+
}
|
|
277
|
+
document.addEventListener('click', (e) => {
|
|
278
|
+
const b = e.target.closest && e.target.closest('#rdPres [data-rp]');
|
|
279
|
+
if (!b || b.disabled || !R) return;
|
|
280
|
+
const k = b.dataset.rp;
|
|
281
|
+
if (k === 'end') { present(false); return; }
|
|
282
|
+
R.i += k === 'next' ? 1 : -1; present(true);
|
|
283
|
+
});
|
|
284
|
+
document.addEventListener('fullscreenchange', () => { if (!document.fullscreenElement && $('#rdPres')) present(false); });
|
|
285
|
+
|
|
286
|
+
/* ── Print: one slide to a page, or the page ── */
|
|
287
|
+
function printHtml() {
|
|
288
|
+
const s = source(), t = esc(R.name + ' ' + (R.row.slot || ''));
|
|
289
|
+
if (s.kind !== 'words' && s.X) return frameDoc(s.X.style, R.view === 'deck' && s.X.slides.length ? s.X.slides.map((x) => x.html).join('') : s.X.body, R.view === 'deck' && s.X.slides.length ? 'pmos-print pmos-print-deck' : 'pmos-print pmos-print-doc').replace('<head>', '<head><title>' + t + '</title>');
|
|
290
|
+
const css = '<link rel="stylesheet" href="' + esc(href('premium-report-print.css')) + '">';
|
|
291
|
+
const w = R.W || { title: R.name, sections: [] };
|
|
292
|
+
const inner = R.view === 'deck'
|
|
293
|
+
? slides().map((x) => `<section class="pmos-slide"><h2 class="rp-slide__h">${esc(x.h)}</h2><div class="rp-slide__t">${x.k === 'title' ? `<p>${esc(x.t)}</p>` : x.html}</div></section>`).join('')
|
|
294
|
+
: `<h1>${esc(w.title)}</h1>` + w.sections.map((x) => `<h2>${esc(x.h)}</h2>${slideHtml(x.lines)}`).join('');
|
|
295
|
+
return frameDoc('', inner, R.view === 'deck' ? 'pmos-print pmos-print-deck' : 'pmos-print pmos-print-doc').replace('<head>', '<head><title>' + t + '</title>').replace('</head>', css + '</head>');
|
|
296
|
+
}
|
|
297
|
+
function printIt() {
|
|
298
|
+
const w = window.open('', '_blank');
|
|
299
|
+
if (!w) { toast('The browser blocked the print window. Allow pop-ups for this page, then press Print again.'); return; }
|
|
300
|
+
w.document.open(); w.document.write(printHtml()); w.document.close();
|
|
301
|
+
w.focus(); setTimeout(() => { try { w.print(); } catch { /* the PM prints from the window */ } }, 300);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* ── reading the cycle ── */
|
|
305
|
+
async function readCycle() {
|
|
306
|
+
const c = await Promise.resolve(pmGet('/api/report-design/cycle?' + q({ ws: R.ws, path: R.row.path }))).catch(() => null);
|
|
307
|
+
if (!R) return;
|
|
308
|
+
R.cycle = c && c.ok ? c : null;
|
|
309
|
+
R.cyc = null;
|
|
310
|
+
if (R.cycle && R.cycle.designed) { try { R.cyc = splitRender(await textOf('/api/report-design/cycle-html?' + q({ ws: R.ws, path: R.row.path }))); } catch { R.cyc = null; } }
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export async function openReport(row, hand) {
|
|
314
|
+
if (!row || !row.path) return;
|
|
315
|
+
R = { row, ws: hand.ws, id: row.cadence, name: hand.name || row.cadence, issued: row.state === 'issued', text: '', err: '', W: null, view: 'deck', i: 0, cycle: null, cyc: null, show: 'cycle', ver: new Map(), design: null, dErr: '', dm: false, busy: false };
|
|
316
|
+
const when = row.date || row.slot;
|
|
317
|
+
const say = R.issued
|
|
318
|
+
? 'This is the ' + when + ' cycle of "' + R.name + '". It is issued, so it is frozen. Read it as a deck or a page, present it, download it or print it. Nothing is sent from here.'
|
|
319
|
+
: 'This is the ' + when + ' cycle of "' + R.name + '". Read it as a deck or a page, present it, download it or print it. To change how it looks, add a sample or tell me what to change, then press This is it on the version you want. Nothing is sent from here.';
|
|
320
|
+
openDlg({ eye: 'Report · ' + (R.issued ? 'issued' : 'draft'), title: R.name, sub: when + ' · ' + row.path, stream: turnA(ptx(say)), noteKey: null, pane: '<p class="note">Reading the document.</p>', label: 'Report' });
|
|
321
|
+
$('#dlg').classList.add('rdrd');
|
|
322
|
+
$('#askF').hidden = true; const an = $('#askNote'); if (an) an.hidden = true;
|
|
323
|
+
if (!R.issued) $('#dBody').insertAdjacentHTML('beforeend', `<form class="askbar" id="rdF"><input id="rdIn" placeholder="Say how it should look" maxlength="4000" autocomplete="off" aria-label="Say how the report should look"><button type="submit" aria-label="Send" title="Send">${SEND}</button></form><p class="fine2">A change starts a design run that writes only a new version of the look. The document's words do not change.</p>`);
|
|
324
|
+
const f = $('#rdF'); if (f) f.onsubmit = onSay;
|
|
325
|
+
if (innerWidth >= 1000) setFull(true);
|
|
326
|
+
const me = R;
|
|
327
|
+
try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: row.path })); R.W = wordsOf(R.text, R.name); } catch (x) { R.err = String((x && x.message) || x); }
|
|
328
|
+
if (R !== me) return;
|
|
329
|
+
await Promise.all([readCycle(), R.issued ? null : readDesign()]);
|
|
330
|
+
if (R !== me) return;
|
|
331
|
+
draw();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* The reader's presses. The dialog is shared, so each listener first asks whether the reader is what it holds. */
|
|
335
|
+
const inReader = (e) => R && $('#dlg').classList.contains('rdrd') && $('#dlg').classList.contains('on') && e.target.closest && e.target.closest('#oMain');
|
|
336
|
+
document.addEventListener('click', (e) => {
|
|
337
|
+
if (!inReader(e)) return;
|
|
338
|
+
const t = e.target.closest('[data-rr]');
|
|
339
|
+
if (t && !t.disabled) { act(t.dataset.rr.split('|')); return; }
|
|
340
|
+
if (R.dm && !e.target.closest('.dsvw')) { R.dm = false; draw(); }
|
|
341
|
+
});
|
|
342
|
+
document.addEventListener('change', (e) => { if (inReader(e) && e.target.id === 'rdFile' && e.target.files && e.target.files[0]) addSample(e.target.files[0]); });
|
|
343
|
+
document.addEventListener('keydown', (e) => {
|
|
344
|
+
if (!R) return;
|
|
345
|
+
if ($('#rdPres')) {
|
|
346
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopImmediatePropagation(); present(false); return; }
|
|
347
|
+
if (/^Arrow(Left|Right)$/.test(e.key)) { e.preventDefault(); const L = slides().length; const j = R.i + (e.key === 'ArrowRight' ? 1 : -1); if (j >= 0 && j < L) { R.i = j; present(true); } }
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (!inReader(e) || !/^Arrow(Left|Right)$/.test(e.key) || !e.target.closest('.rdk')) return;
|
|
351
|
+
const L = slides().length, j = R.i + (e.key === 'ArrowRight' ? 1 : -1);
|
|
352
|
+
if (j < 0 || j >= L) return;
|
|
353
|
+
e.preventDefault(); R.i = j; draw(); const s = $('#rdSlide'); if (s) s.focus();
|
|
354
|
+
}, true);
|
|
355
|
+
/* Another dialog of the page opens without the reader's class; closing the dialog closes the reader. */
|
|
356
|
+
/* While presenting, the page's Escape takes the dialog out of full screen first (premium-shell.js): that is the reader's sign to stop presenting. */
|
|
357
|
+
new MutationObserver(() => { const d = $('#dlg'); if (R && $('#rdPres') && d.classList.contains('on') && !d.classList.contains('full')) present(false); }).observe($('#dlg'), { attributes: true, attributeFilter: ['class'] });
|
|
358
|
+
new MutationObserver(() => { const d = $('#dlg'); if (d && !d.classList.contains('on') && d.classList.contains('rdrd')) { d.classList.remove('rdrd'); const p = $('#rdPres'); if (p) p.remove(); R = null; } }).observe($('#dlg'), { attributes: true, attributeFilter: ['class'] });
|
|
@@ -935,6 +935,66 @@ a.round{color:inherit;text-decoration:none}
|
|
|
935
935
|
.stsec .mut{margin:3px 0 0;font-size:13px;line-height:1.4}
|
|
936
936
|
.stlc small{font-size:12px;color:var(--ink-3);white-space:nowrap;align-self:center}
|
|
937
937
|
.stlc button{font-size:13px;font-weight:600}
|
|
938
|
+
/* ── a report read on the page (initiative premium-report-read): the deck, the page, the menus, the design row and Present. From the mockup's report sheet ── */
|
|
939
|
+
#dlg.rdrd #askF,#dlg.rdrd #askNote{display:none}
|
|
940
|
+
.rdr{display:grid;gap:12px;min-width:0}
|
|
941
|
+
.rdbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
942
|
+
.rdvw button{min-height:44px}
|
|
943
|
+
.rdvw button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
944
|
+
.dsvw{position:relative;z-index:40}
|
|
945
|
+
.dsvb{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 12px 0 14px;border-radius:10px;background:var(--well);font:600 12.5px var(--mono);color:var(--ink)}
|
|
946
|
+
.dsvb svg{width:15px;height:15px}
|
|
947
|
+
.dsvb:hover{background:color-mix(in oklab,var(--ink) 9%,transparent)}
|
|
948
|
+
.dsmn{position:absolute;z-index:30;left:0;top:48px;min-width:min(290px,80vw);padding:6px;border-radius:14px;background:var(--card-solid);box-shadow:0 18px 44px -12px rgba(20,22,31,.35),0 0 0 1px var(--hair);display:grid;gap:2px}
|
|
949
|
+
.dsmn a,.dsmn button{display:flex;align-items:flex-start;gap:10px;min-height:44px;padding:9px 12px;border-radius:9px;font:600 13px var(--mono);color:var(--ink-2);text-align:left;text-decoration:none}
|
|
950
|
+
.dsmn a:hover,.dsmn button:hover{background:var(--well);color:var(--ink)}
|
|
951
|
+
.dsmn svg{width:15px;height:15px;flex:none;margin-top:2px}
|
|
952
|
+
.rpm .label{margin:8px 12px 2px}
|
|
953
|
+
.rpm small{display:block;font:400 12px/1.35 var(--sans);color:var(--ink-3);margin-top:2px}
|
|
954
|
+
.rpmn{margin:6px 12px 8px!important;font-size:12px}
|
|
955
|
+
.rdsrc{margin:0}
|
|
956
|
+
.rdz{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 14px;border-radius:14px;background:var(--well)}
|
|
957
|
+
.rdz .label{margin:0}
|
|
958
|
+
.rdz .dmcta{min-height:44px;padding:0 14px;font-size:12.5px}
|
|
959
|
+
.rdz .s{display:inline-flex;align-items:center;gap:5px}
|
|
960
|
+
.rdz .s svg{width:14px;height:14px}
|
|
961
|
+
.rdz .dlink{min-height:44px}
|
|
962
|
+
.rdv{display:inline-flex;gap:4px;flex-wrap:wrap}
|
|
963
|
+
.rdv button{min-width:44px;min-height:44px;padding:0 12px;border-radius:999px;font:650 12px var(--mono);background:var(--card-solid);color:var(--ink-2);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
964
|
+
.rdv button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
965
|
+
.rdv button:disabled{opacity:.5}
|
|
966
|
+
.rds2{font-size:12.5px;color:var(--ink-2);flex:1 1 160px}
|
|
967
|
+
.rds2 em{font-style:normal;font-weight:650;color:var(--ink)}
|
|
968
|
+
.rdk{--acc:var(--ember);display:grid;gap:4px;min-width:0}
|
|
969
|
+
.rds{container-type:inline-size;aspect-ratio:16/9;background:var(--card-solid);border-radius:18px;box-shadow:inset 0 0 0 1px var(--hair);border-top:6px solid var(--acc);padding:5cqw 6cqw;display:grid;align-content:center;gap:2.2cqw;overflow:hidden;box-sizing:border-box}
|
|
970
|
+
.rds h3{margin:0;font-size:4.4cqw;line-height:1.15;letter-spacing:-.015em}
|
|
971
|
+
.rds p{margin:0;font-size:2.6cqw;line-height:1.45;color:var(--ink-2)}
|
|
972
|
+
.rds ul{margin:0;padding-left:3.2cqw;display:grid;gap:1.4cqw;font-size:2.7cqw;line-height:1.4}
|
|
973
|
+
.rds li::marker{color:var(--acc)}
|
|
974
|
+
.rds.title{background:var(--solid);color:var(--on-solid);border-top-color:var(--acc)}
|
|
975
|
+
.rds.title h3{font-size:6.4cqw}
|
|
976
|
+
.rds.title p{color:color-mix(in oklab,var(--on-solid) 78%,transparent);font-size:3cqw}
|
|
977
|
+
.rdbig:focus-visible{outline:2px solid var(--ink);outline-offset:3px;border-radius:18px}
|
|
978
|
+
.rdfc{position:relative;width:100%;aspect-ratio:16/9;overflow:hidden;border-radius:18px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
979
|
+
.rdfc>.rdif{position:absolute;top:0;left:0;width:1280px;height:720px;border:0;transform:scale(var(--rp-scale,.5));transform-origin:top left;pointer-events:none}
|
|
980
|
+
.rdpf>.rdif{display:block;width:100%;height:70vh;border:0;border-radius:14px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
981
|
+
.rdnv{display:flex;align-items:center;justify-content:center;gap:14px;margin:10px 0 6px;font:600 12.5px var(--mono);color:var(--ink-2)}
|
|
982
|
+
.rdnv button,.rdpn button{width:44px;height:44px;border-radius:50%;background:var(--well);display:grid;place-items:center;color:var(--ink)}
|
|
983
|
+
.rdnv button:disabled,.rdpn button:disabled{opacity:.35}
|
|
984
|
+
.rdnv svg,.rdpn svg{width:18px;height:18px}
|
|
985
|
+
.rdt{display:flex;gap:8px;overflow-x:auto;padding:4px 2px 8px;scrollbar-width:thin}
|
|
986
|
+
.rdt button{flex:0 0 118px;display:grid;gap:4px;text-align:left;padding:8px 10px;border-radius:12px;background:var(--well);box-shadow:inset 0 0 0 1px var(--hair);min-height:56px}
|
|
987
|
+
.rdt button[aria-current="true"]{box-shadow:inset 0 0 0 2px var(--ember);background:var(--card-solid)}
|
|
988
|
+
.rdt span{font-size:12px;font-weight:600;line-height:1.25;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
|
989
|
+
.rdt i{font:650 10.5px var(--mono);font-style:normal;color:var(--ink-3)}
|
|
990
|
+
.rdpg h2{margin:0 0 8px;font-size:22px;letter-spacing:-.02em}
|
|
991
|
+
.rdpg ul{padding-left:20px}
|
|
992
|
+
.rdcon{margin:0}
|
|
993
|
+
.rdpres{position:fixed;inset:0;z-index:1000;background:var(--solid);display:grid;grid-template-rows:minmax(0,1fr) auto;gap:12px;padding:24px;box-sizing:border-box}
|
|
994
|
+
.rdpres:focus{outline:none}
|
|
995
|
+
.rdpbox{display:grid;place-items:center;min-height:0}
|
|
996
|
+
.rdpbox>.rds,.rdpbox>.rdfc{width:min(100%,calc((100vh - 120px) * 16 / 9))}
|
|
997
|
+
.rdpn{display:flex;align-items:center;justify-content:center;gap:14px;font:600 12.5px var(--mono);color:var(--on-solid)}
|
|
938
998
|
/* ── initiative page (initiative briefing-premium-initiative) ── */
|
|
939
999
|
.ckr.current i{background:var(--ember)}
|
|
940
1000
|
.ckr.done i{background:var(--ok)}
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
</section>
|
|
58
58
|
</aside>
|
|
59
59
|
</div>
|
|
60
|
-
<p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. A press here records only what it says: a dashboard in the workspace's state folder, a report setup, request or dismissal in the report ledger
|
|
60
|
+
<p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. A press here records only what it says: a dashboard or a chart in the workspace's state folder, a report setup, request or dismissal in the report ledger, or a report's look in its design folder. Left out: run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. Nothing is sent from this page.</p>
|
|
61
61
|
</main>
|
|
62
62
|
<noscript>This page needs JavaScript.</noscript>
|
|
63
63
|
<script type="module" src="/pm/premium-insights.js"></script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-report-read: a report document read on the premium Insights page (deck, page, Present, download, print) and its look (samples, design versions, This is it), against the real server on a scratch repository with a stub claude for the report-design job.",
|
|
3
|
+
"seconds": {
|
|
4
|
+
"premium-report-read-test.js": 60
|
|
5
|
+
},
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-report-read-test.js"
|
|
8
|
+
]
|
|
9
|
+
}
|