create-pmos 0.320.0 → 0.321.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/guide/briefing-premium.md +9 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +16 -1
- package/workspace/premium-vw-doc-test.js +218 -0
- package/workspace/public/pm/premium-doc-sheet.js +9 -2
- package/workspace/public/pm/premium-report-read.js +20 -2
- package/workspace/public/pm/premium-vw-doc-model.js +184 -0
- package/workspace/public/pm/premium-vw-doc.css +171 -0
- package/workspace/public/pm/premium-vw-doc.js +477 -0
- package/workspace/test-lists/premium-viewer-doc.json +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.321.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-19T15:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
|
|
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-19T15:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
|
|
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-19T15:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T15:25:02Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -168,6 +168,15 @@ A row or a Today item opens a dialog with the same parts every time. At the top
|
|
|
168
168
|
|
|
169
169
|
The right side can hold more than one item. When the dialog opens a related item there, such as a document, a meeting or a ticket, the item opens as a tab beside the dialog's own detail. The first tab is always the dialog's own detail. You can have up to four more tabs; a fifth closes the oldest. Click a tab or use the arrow keys to move between them. Use the **×** on a tab, or press Delete, to close it. The tabs close when the dialog closes. With no extra item, there are no tabs.
|
|
170
170
|
|
|
171
|
+
### The document page
|
|
172
|
+
|
|
173
|
+
Every markdown document opens as one page in a tab: a report, a PRD, a new document or any other `.md` file. On a document sheet, click **Open as a page**. On a report, click **Edit**.
|
|
174
|
+
|
|
175
|
+
- **Page** shows the document as it reads. **Edit** lets you type on the page itself, with a toolbar, a **/** menu for blocks, and Ctrl+S to save. **Markdown** shows the source text. Only the sections you changed are written; the other sections and the front matter keep their exact text.
|
|
176
|
+
- When the agent proposes an edit, the page shows it applied and highlighted. Click a highlight to see the old text, and click **Put it back** to restore it. The bar above the page has **Keep as vN**, which keeps the changes that remain, and **Undo all**, which asks first and then rejects the whole edit.
|
|
177
|
+
- **Health**, **Links** and **Copies** under the toolbar show the document's checks, the documents it links to, and its linked copies. The checks only read the file.
|
|
178
|
+
- A report also shows **Present**, **Print** and **Download** on the same toolbar.
|
|
179
|
+
|
|
171
180
|
A decision opens with no option chosen, because no recommendation is on record. Choose one and the draft entry on the right changes. Nothing is written. The main button, "Not yet" and "Return this run to the agent" are off in this version, and each says why.
|
|
172
181
|
|
|
173
182
|
## The conversation
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.321.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.321.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -88,7 +88,7 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
|
|
|
88
88
|
|
|
89
89
|
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true }), p = await ctx.newPage(), errs = [], posts = [];
|
|
90
90
|
p.on('pageerror', (e) => errs.push(String(e)));
|
|
91
|
-
p.on('request', (r) => { if (r.method() === 'POST') posts.push(
|
|
91
|
+
p.on('request', (r) => { const u = new URL(r.url()).pathname; if (r.method() === 'POST' && u !== '/api/doc-health/check') posts.push(u); }); // the document page's health check is a read sent as a POST; it writes nothing
|
|
92
92
|
const shot = async (n) => { if (process.env.READ_SHOTS) await p.screenshot({ path: path.join(process.env.READ_SHOTS, n + '.png') }); };
|
|
93
93
|
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
94
94
|
const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
|
|
@@ -151,6 +151,21 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
|
|
|
151
151
|
const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
|
|
152
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
153
|
|
|
154
|
+
/* E: Edit opens the report's file as the one document page (premium-viewer S2), with this report's Present, Print and Download on its bar */
|
|
155
|
+
await tap('#oMain [data-rr="page"]');
|
|
156
|
+
const VP = '.obody.vw:not([hidden]) .vwdoc';
|
|
157
|
+
await until(() => p.evaluate((v) => !!document.querySelector(v + ' .cf'), VP));
|
|
158
|
+
ok('E1 Edit opens the report as a page in a viewer tab, with Page, Edit and Markdown', await p.evaluate((v) => { const st = window.__premiumViewer.vwState(); return st.on.startsWith('doc:') && document.querySelectorAll(v + ' .vwseg').length === 3 && /Partner review, 12 Oct/.test(document.querySelector(v + ' .cft').textContent); }, VP));
|
|
159
|
+
ok('E2 the page bar carries Present, Print and Download', await p.evaluate((v) => ['Present', 'Print', 'Download'].every((t) => [...document.querySelectorAll(v + ' .vwdt .vwbtn')].some((b) => b.textContent.trim() === t)), VP));
|
|
160
|
+
await p.click(VP + ' [data-vd="xm:dl"]');
|
|
161
|
+
const pitems = await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwxmn [role="menuitem"]')].map((a) => a.getAttribute('href') || a.dataset.vwx), VP);
|
|
162
|
+
ok('E3 its Download lists the same four files through report-export, and the Markdown file', pitems.length === 5 && pitems.slice(0, 4).every((h, i) => h.includes('/api/report-export?') && h.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i])) && pitems[4] === 'md', JSON.stringify(pitems));
|
|
163
|
+
await p.click(VP + ' [data-vd="xm:dl"]');
|
|
164
|
+
await p.click(VP + ' [data-vwx="present"]');
|
|
165
|
+
await until(() => p.$('#rdPres'));
|
|
166
|
+
ok('E4 Present from the page presents the deck over the whole page', !!(await p.$('#rdPres')) && await p.evaluate(() => window.__premiumViewer.vwState().on === 'main'));
|
|
167
|
+
await p.keyboard.press('Escape'); await sleep(200);
|
|
168
|
+
|
|
154
169
|
/* L: the look */
|
|
155
170
|
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
171
|
await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-doc-test.js — a markdown document as a page in the premium viewer (initiative premium-viewer S2; planning/prd/premium-viewer-prd.md R2, R6, R7).
|
|
4
|
+
* Serves the real initiative page from the real server and opens its PRD sheet, then the page in the viewer. The /api/doc-sheet routes are answered by a
|
|
5
|
+
* small stateful stand-in, so each press can be read off the request the page sent. The routes' own behaviour is in briefing-premium-doc-edit.test.js.
|
|
6
|
+
* D1 the page · D2 edit in place · D3 Markdown · D4 an agent's edit · D5 Undo all · D6 ask · D7 the sheet reads again · D8 floors */
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
10
|
+
const T = require('./test-run').configure({ name: 'premium-vw-doc' });
|
|
11
|
+
const IP = require('./lib/initiative-premium.js');
|
|
12
|
+
const F = require('./fixtures/initiative-premium-facts.js');
|
|
13
|
+
|
|
14
|
+
const BASE = T.BASE;
|
|
15
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
17
|
+
const results = [];
|
|
18
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
19
|
+
let srv = null; let browser = null;
|
|
20
|
+
const finish = async (code) => {
|
|
21
|
+
if (browser) await browser.close().catch(() => {});
|
|
22
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
23
|
+
T.killTmux();
|
|
24
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
25
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-doc assertions passed`);
|
|
26
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
27
|
+
};
|
|
28
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
29
|
+
|
|
30
|
+
const PATH = 'planning/prd/self-serve-v2-prd.md';
|
|
31
|
+
const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\nstatus: Draft\ntimestamp: 2026-10-16\ntags: [onboarding, q4]\n---\n\n# PRD: Self-serve onboarding v2\n\n'
|
|
32
|
+
+ '> [!NOTE]\n> Owned by the onboarding squad.\n\n## Problem\n\nA partner waits for a person.\nIt takes two days.\n\n## Goal\n\n- a first call without help\n\n'
|
|
33
|
+
+ '## Requirements\n\n| Id | What | State |\n|---|---|---|\n| R1 | a first call | :status[In progress] |\n\n- [x] draft the flow\n- [ ] test it\n';
|
|
34
|
+
const AFTER = TEXT.replace('## Goal', '## Summary\n\nPartners reach a first call without help.\n\n## Goal').replace('- a first call without help', '- a first call in under ten minutes');
|
|
35
|
+
const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a summary and tighten the goal', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, after: AFTER, sections: [
|
|
36
|
+
{ name: 'Summary', kind: 'added', before: '', after: 'Partners reach a first call without help.', current: null, stale: false },
|
|
37
|
+
{ name: 'Goal', kind: 'changed', before: '- a first call without help', after: '- a first call in under ten minutes', current: '- a first call without help', stale: false },
|
|
38
|
+
{ name: 'Requirements', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }, o || {});
|
|
39
|
+
|
|
40
|
+
(async () => {
|
|
41
|
+
const exe = findBrowser();
|
|
42
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
43
|
+
let chromium;
|
|
44
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
45
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
|
|
46
|
+
await T.waitForServer(BASE);
|
|
47
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
48
|
+
|
|
49
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', props = [], post = null } = {}) => {
|
|
50
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
51
|
+
const page = await ctx.newPage();
|
|
52
|
+
const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }], props, ask: null, errors: [], posts: [], gets: [], links: [] };
|
|
53
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
54
|
+
await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(F.facts()), as_of: F.NOW }) }));
|
|
55
|
+
await page.route('**/api/doc-health/check', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, health: { passed: 1, total: 1, checks: [{ id: 'fresh', pass: true, reason: 'ok' }] } }) }));
|
|
56
|
+
await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
|
|
57
|
+
await page.route('**/api/docs/library*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, kinds: ['cites'], files: [{ path: PATH, title: 'Self-serve PRD' }, { path: 'planning/research/interviews.md', title: 'Onboarding interviews' }, { path: 'planning/evals/self-serve-v2-rubric.md', title: 'Self-serve rubric' }], edges: [[1, 0, 0], [0, 2, 0]] }) }));
|
|
58
|
+
await page.route('**/api/docs?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, docs: [{ path: PATH, links: S.links }] }) }));
|
|
59
|
+
await page.route('**/api/docs/link', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.posts.push({ route: 'docs/link', body: b }); S.links.push({ kind: b.kind, target: b.target, signal: 'unchecked', title: 'Onboarding PRD' }); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
|
|
60
|
+
await page.route('**/api/doc-sheet/**', (r) => {
|
|
61
|
+
const rq = r.request(), u = new URL(rq.url()), route = u.pathname.replace('/api/doc-sheet/', ''), send = (b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
62
|
+
if (rq.method() === 'GET') {
|
|
63
|
+
S.gets.push({ route, query: u.search });
|
|
64
|
+
if (route === 'log') return send({ ok: true, path: PATH, revisions: S.revs, events: [] });
|
|
65
|
+
if (route === 'at') return send({ ok: true, path: PATH, rev: S.revs.length, text: S.text });
|
|
66
|
+
if (route === 'proposals') return send({ ok: true, path: PATH, proposals: S.props });
|
|
67
|
+
if (route === 'ask') return send(S.ask || { ok: true, id: 'ask-1', state: 'working' });
|
|
68
|
+
return send({ ok: false, error: 'not in this test' }, 404);
|
|
69
|
+
}
|
|
70
|
+
const body = JSON.parse(rq.postData() || '{}'); S.posts.push({ route, query: u.search, body });
|
|
71
|
+
if (post) { const a = post(route, body, S); if (a) return send(a.body, a.status || 200); }
|
|
72
|
+
if (route === 'edit') { S.text = body.text; S.revs.push({ rev: S.revs.length + 1, why: body.why, by: 'pm', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
|
|
73
|
+
if (route === 'accept') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'accepted' }) : p)); S.text = AFTER.replace('- a first call in under ten minutes', '- a first call without help'); S.revs.push({ rev: S.revs.length + 1, why: 'add a summary', by: 'pm', text_by: 'agent', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
|
|
74
|
+
if (route === 'reject') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'rejected', why: body.why }) : p)); return send({ ok: true }); }
|
|
75
|
+
if (route === 'ask') { S.ask = { ok: true, id: 'ask-1', state: 'working' }; return send({ ok: true, id: 'ask-1', state: 'working' }); }
|
|
76
|
+
return send({ ok: false, error: 'not in this test' }, 404);
|
|
77
|
+
});
|
|
78
|
+
await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
|
|
79
|
+
await until(() => page.evaluate(() => document.querySelector('#cIniDoc')));
|
|
80
|
+
await page.locator('#dmList .dmo[data-doc="prd"]').click();
|
|
81
|
+
await until(() => page.evaluate(() => document.querySelector('#oMain [data-ds="page"]')));
|
|
82
|
+
await page.click('#oMain [data-ds="page"]');
|
|
83
|
+
await until(() => page.evaluate(() => document.querySelector('.vwdoc .cf, .vwdoc .vwempty:not(:empty)') && !/Reading the file/.test(document.querySelector('.vwdoc').textContent)));
|
|
84
|
+
return { ctx, page, S };
|
|
85
|
+
};
|
|
86
|
+
const V = '.obody.vw:not([hidden]) .vwdoc';
|
|
87
|
+
const txt = (p, q) => p.evaluate((s) => ((document.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' '), q);
|
|
88
|
+
|
|
89
|
+
/* D1 the page */
|
|
90
|
+
const A = await open(); const p = A.page;
|
|
91
|
+
ok('D1 Open as a page opens the document in a viewer tab, beside the sheet', await p.evaluate(() => { const st = window.__premiumViewer && window.__premiumViewer.vwState(); return !!st && st.ids.includes('doc:planning/prd/self-serve-v2-prd.md') && st.on === 'doc:planning/prd/self-serve-v2-prd.md'; }));
|
|
92
|
+
const head = await p.evaluate((v) => { const r = document.querySelector(v); return { t: r.querySelector('.cft').textContent, by: r.querySelector('.cfby').textContent, props: [...r.querySelectorAll('.cfpr tr')].map((x) => [...x.children].map((c) => c.textContent.trim()).join(' ')), labels: [...r.querySelectorAll('.cflb span')].map((x) => x.textContent), h1: r.querySelectorAll('.cfb h1, .cfb h2').length && r.querySelector('.cfb').textContent.includes('PRD: Self-serve'), foot: r.querySelector('.cff').textContent }; }, V);
|
|
93
|
+
ok('D1 the title comes from the front matter and the first heading is not drawn twice', head.t === 'Self-serve onboarding v2' && !head.h1, JSON.stringify(head));
|
|
94
|
+
ok('D1 the byline says who changed it last, the version and the read time, from the log', /Last change by Before the sheet · 16 Oct 2026 · v1 · 1 min read/.test(head.by), head.by);
|
|
95
|
+
ok('D1 the properties table and labels come from the front matter', head.props.join('|') === 'type PRD|status Draft|timestamp 16 Oct 2026' && head.labels.join() === 'onboarding,q4', JSON.stringify(head));
|
|
96
|
+
ok('D1 the body has the panel, the table with its status label, and the task list', await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'); return !!b.querySelector('.pnl.note') && !!b.querySelector('.tw table .lz.b') && b.querySelectorAll('.tasks li').length === 2 && b.querySelector('.tasks li[data-done="true"]') !== null; }, V));
|
|
97
|
+
ok('D1 the footer names the file', /planning\/prd\/self-serve-v2-prd\.md/.test(head.foot));
|
|
98
|
+
ok('D1 Page, Edit and Markdown are one control, with Page on', await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwseg')].map((b) => b.textContent.trim() + ':' + b.getAttribute('aria-pressed')).join() === 'Page:true,Edit:false,Markdown:false', V));
|
|
99
|
+
|
|
100
|
+
/* D9 Health, Links and Copies */
|
|
101
|
+
ok('D9 the page shows Health with the checks that passed, Links and Copies', await until(() => p.evaluate((v) => [...document.querySelectorAll(v + ' .vwchip')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Health 1 of 1|Links|Copies 0', V)), await txt(p, V + ' .vwmore'));
|
|
102
|
+
await p.click(V + ' [data-vd="more:health"]');
|
|
103
|
+
ok('D9 Health lists each check from the health route', /fresh\s*Passed/.test(await txt(p, V + ' .vwmp')) && /1 of 1 checks/.test(await txt(p, V + ' .vwmp')));
|
|
104
|
+
await p.click(V + ' [data-vd="more:links"]');
|
|
105
|
+
await until(() => p.evaluate((v) => /Built from/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
|
|
106
|
+
ok('D9 Links show what it is built from and what uses it, from the document library', /Built from · 1.*Onboarding interviews/.test(await txt(p, V + ' .vwmp')) && /Used by · 1.*Self-serve rubric/.test(await txt(p, V + ' .vwmp')) && /Links 2/.test(await txt(p, V + ' .vwmore')));
|
|
107
|
+
await p.click(V + ' [data-vd="open:planning/evals/self-serve-v2-rubric.md"]');
|
|
108
|
+
ok('D9 a linked document opens as a page in its own tab', await until(() => p.evaluate(() => window.__premiumViewer.vwState().on === 'doc:planning/evals/self-serve-v2-rubric.md')));
|
|
109
|
+
await p.evaluate(() => window.__premiumViewer.vwShow('doc:planning/prd/self-serve-v2-prd.md'));
|
|
110
|
+
await p.click(V + ' [data-vd="more:copies"]');
|
|
111
|
+
ok('D9 Copies says there is none yet and offers to link one', /no copy in Confluence or Google Docs yet/.test(await txt(p, V + ' .vwmp')));
|
|
112
|
+
await p.fill(V + ' #vwCpUrl', 'https://acme.atlassian.net/wiki/spaces/PM/pages/1'); await p.click(V + ' [data-vd="cplink"]');
|
|
113
|
+
await until(() => p.evaluate((v) => /Onboarding PRD/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
|
|
114
|
+
ok('D9 Link posts the copy to /api/docs/link and the copy is listed as not checked', A.S.posts.some((x) => x.route === 'docs/link' && x.body.kind === 'confluence' && x.body.path === PATH) && /Confluence.*Not checked/.test(await txt(p, V + ' .vwmp')));
|
|
115
|
+
await p.click(V + ' [data-vd="more:copies"]');
|
|
116
|
+
const nPosts = A.S.posts.length; A.S.posts.length = 0;
|
|
117
|
+
ok('D9 (setup) the copy link was the only post so far', nPosts === 1);
|
|
118
|
+
|
|
119
|
+
/* D3 Markdown */
|
|
120
|
+
await p.click(V + ' [data-vd="mode:md"]');
|
|
121
|
+
ok('D3 Markdown shows the file exactly as it is on disk', (await p.inputValue(V + ' #vwMd')) === TEXT);
|
|
122
|
+
await p.click(V + ' [data-vd="mode:read"]');
|
|
123
|
+
|
|
124
|
+
/* D2 edit in place */
|
|
125
|
+
await p.click(V + ' [data-vd="mode:edit"]');
|
|
126
|
+
ok('D2 Edit makes the page itself editable and shows the toolbar and a save row', await p.evaluate((v) => document.querySelector(v + ' .cfb').isContentEditable && !!document.querySelector(v + ' .vwetb') && /Save as v2/.test(document.querySelector(v + ' .vwsave').textContent), V));
|
|
127
|
+
await p.evaluate((v) => { const para = [...document.querySelectorAll(v + ' .cfb p')].find((x) => /A partner waits/.test(x.textContent)); const r = document.createRange(); r.setStart(para.firstChild, 'A partner'.length); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); para.focus(); }, V);
|
|
128
|
+
await p.keyboard.type(' still');
|
|
129
|
+
await p.click(V + ' [data-vd="save"]');
|
|
130
|
+
ok('D2 Save with no reason posts nothing and says why', /Say why the document changes/.test(await txt(p, V + ' #vwErr')) && A.S.posts.length === 0);
|
|
131
|
+
ok('D2 the typing is still there after the refusal', /A partner still waits/.test(await txt(p, V + ' .cfb')));
|
|
132
|
+
await p.fill(V + ' #vwWhy', 'say the partner still waits'); await p.click(V + ' [data-vd="save"]');
|
|
133
|
+
await until(() => A.S.posts.length);
|
|
134
|
+
const e1 = A.S.posts[0];
|
|
135
|
+
const want = TEXT.replace('A partner waits for a person.\nIt takes two days.', 'A partner still waits for a person. It takes two days.');
|
|
136
|
+
ok('D2 Save posts path, text and why to /api/doc-sheet/edit for the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'say the partner still waits' && /ws=w1/.test(e1.query), JSON.stringify(e1));
|
|
137
|
+
ok('D2 only the section that was typed in changes; the front matter, the panel, the table and the tasks keep their exact text', e1 && e1.body.text === want, JSON.stringify(e1 && e1.body.text));
|
|
138
|
+
await until(() => p.evaluate((v) => document.querySelector(v + ' .vwseg[aria-pressed="true"]') && /Page/.test(document.querySelector(v + ' .vwseg[aria-pressed="true"]').textContent) && /v2/.test(document.querySelector(v + ' .cfby').textContent), V));
|
|
139
|
+
ok('D2 after Save the page reads the file again and says v2', /Last change by You · 18 Oct 2026 · v2/.test(await txt(p, V + ' .cfby')));
|
|
140
|
+
ok('D7 a write in the page reads the sheet beside it again', A.S.gets.filter((g) => g.route === 'log').length >= 3);
|
|
141
|
+
|
|
142
|
+
/* D2 the editor's blocks: a / menu and a markdown shortcut */
|
|
143
|
+
await p.click(V + ' [data-vd="mode:edit"]');
|
|
144
|
+
await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'), last = b.lastElementChild; const pp = document.createElement('p'); pp.innerHTML = '<br>'; last.after(pp); const r = document.createRange(); r.setStart(pp, 0); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); b.focus(); }, V);
|
|
145
|
+
await p.keyboard.type('/'); await sleep(100);
|
|
146
|
+
ok('D2 / opens the block menu with headings, lists, panels, a table and more', await p.evaluate((v) => { const m = document.querySelector(v.replace(' .vwdoc', '') + ' .vwpop'); return !!m && /Heading 1/.test(m.textContent) && /Info panel/.test(m.textContent) && /Table/.test(m.textContent); }, V));
|
|
147
|
+
await p.keyboard.type('info'); await p.keyboard.press('Enter'); await sleep(100);
|
|
148
|
+
await p.keyboard.type('Ship to new workspaces first.');
|
|
149
|
+
ok('D2 picking Info panel puts a panel in the page where the caret was', await p.evaluate((v) => [...document.querySelectorAll(v + ' .cfb .pnl.info')].some((x) => /Ship to new workspaces first/.test(x.textContent)), V));
|
|
150
|
+
await p.fill(V + ' #vwWhy', 'add a note'); await p.click(V + ' [data-vd="save"]');
|
|
151
|
+
await until(() => A.S.posts.length > 1);
|
|
152
|
+
ok('D2 the panel is saved as a GitHub note block in plain markdown', /> \[!INFO\]\n> Ship to new workspaces first\./.test(A.S.posts[1].body.text) && A.S.posts[1].body.text.startsWith(want.split('## Requirements')[0]), JSON.stringify(A.S.posts[1].body.text));
|
|
153
|
+
ok('0 no page error', A.S.errors.length === 0, A.S.errors.join(' | '));
|
|
154
|
+
await A.ctx.close();
|
|
155
|
+
|
|
156
|
+
/* D4 an agent's edit, applied and highlighted, with one Keep */
|
|
157
|
+
{
|
|
158
|
+
const B = await open({ props: [prop()] }); const q = B.page;
|
|
159
|
+
await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
|
|
160
|
+
ok('D4 the bar says what was asked and how many places changed, with Undo all and Keep as v2', /Asked: add a summary and tighten the goal/.test(await txt(q, V + ' .vwag')) && /The agent changed 2 places/.test(await txt(q, V + ' .vwag')) && /Keep as v2/.test(await txt(q, V + ' [data-vd="keep"]')) && !!(await q.$(V + ' [data-vd="undoall"]')));
|
|
161
|
+
ok('D4 a stale section is not applied, and the bar says so', /1 more change does not apply/.test(await txt(q, V + ' .vwag')) && !(await q.$(V + ' .vwchg[data-sec="Requirements"]')));
|
|
162
|
+
ok('D4 the changes are in the page, highlighted: the new Summary and the new Goal text', await q.evaluate((v) => { const s = document.querySelector(v + ' .vwchg.added[data-sec="Summary"]'), g = document.querySelector(v + ' .vwchg.changed[data-sec="Goal"]'); return !!s && /Partners reach a first call without help/.test(s.textContent) && !!g && /under ten minutes/.test(g.textContent); }, V));
|
|
163
|
+
ok('D4 Edit and Markdown wait until the edit is kept or undone', await q.evaluate((v) => document.querySelector(v + ' [data-vd="mode:edit"]').disabled && document.querySelector(v + ' [data-vd="mode:md"]').disabled, V));
|
|
164
|
+
await q.click(V + ' .vwchg[data-sec="Goal"] .vwcl');
|
|
165
|
+
ok('D4 clicking a highlight shows what it said before', /What it said before.*a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwbefore')));
|
|
166
|
+
await q.click(V + ' .vwchg[data-sec="Goal"] [data-vd="back:Goal"]');
|
|
167
|
+
ok('D4 Put it back shows the old text and the bar counts one place', /a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwcb')) && /The agent changed 1 place\./.test(await txt(q, V + ' .vwag')) && await q.evaluate((v) => document.querySelector(v + ' .vwchg[data-sec="Goal"]').classList.contains('off'), V));
|
|
168
|
+
await q.click(V + ' [data-vd="keep"]');
|
|
169
|
+
await until(() => B.S.posts.length);
|
|
170
|
+
const ac = B.S.posts[0];
|
|
171
|
+
ok('D4 Keep accepts only the sections still applied, with the proposal id and hash', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.sections.join() === 'Summary' && ac.body.hash === 'ha' && /ws=w1/.test(ac.query), JSON.stringify(ac));
|
|
172
|
+
await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag') && /v2/.test((document.querySelector(v + ' .cfby') || {}).textContent || ''), V));
|
|
173
|
+
ok('D4 after Keep the page is the file as v2, with no highlight left', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /Partners reach a first call/.test(document.querySelector(v + ' .cfb').textContent), V));
|
|
174
|
+
ok('0 no page error', B.S.errors.length === 0, B.S.errors.join(' | '));
|
|
175
|
+
await B.ctx.close();
|
|
176
|
+
}
|
|
177
|
+
/* D5 Undo all, D6 ask */
|
|
178
|
+
{
|
|
179
|
+
const C = await open({ props: [prop()] }); const q = C.page;
|
|
180
|
+
await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
|
|
181
|
+
await q.click(V + ' [data-vd="undoall"]');
|
|
182
|
+
await sleep(150);
|
|
183
|
+
const cf = await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); return !!b; });
|
|
184
|
+
ok('D5 Undo all asks first, and nothing is posted yet', cf && C.S.posts.length === 0);
|
|
185
|
+
await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); b.click(); });
|
|
186
|
+
await until(() => C.S.posts.length);
|
|
187
|
+
ok('D5 Undo all rejects the proposal with a reason for the Edit log, and the file is left as it is', C.S.posts[0].route === 'reject' && C.S.posts[0].body.id === 'prop-a' && /Undo all/.test(C.S.posts[0].body.why) && !C.S.posts.some((x) => x.route === 'edit' || x.route === 'accept'));
|
|
188
|
+
await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag'), V));
|
|
189
|
+
ok('D5 after Undo all the page shows the file with no highlight', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /a first call without help/.test(document.querySelector(v + ' .cfb').textContent), V));
|
|
190
|
+
await q.click(V + ' [data-vd="askt"]');
|
|
191
|
+
await q.fill(V + ' #vwAsk', 'tighten the goal'); await q.click(V + ' [data-vd="ask"]');
|
|
192
|
+
await until(() => C.S.posts.length > 1);
|
|
193
|
+
ok('D6 Ask posts path and prompt to /api/doc-sheet/ask', C.S.posts[1].route === 'ask' && C.S.posts[1].body.prompt === 'tighten the goal' && C.S.posts[1].body.path === PATH);
|
|
194
|
+
ok('D6 while the agent works the page says so', await until(() => q.evaluate((v) => /The agent is reading the document/.test(document.querySelector(v).textContent), V)));
|
|
195
|
+
C.S.props = [prop({ id: 'prop-c', hash: 'hc', prompt: 'tighten the goal', sections: [prop().sections[1]], after: TEXT.replace('- a first call without help', '- a first call in under ten minutes') })];
|
|
196
|
+
C.S.ask = { ok: true, id: 'ask-1', state: 'proposed' };
|
|
197
|
+
ok('D6 when the agent answers, its edit shows applied and highlighted', await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwchg[data-sec="Goal"]') && /The agent changed 1 place/.test(document.querySelector(v + ' .vwag').textContent), V), 9000));
|
|
198
|
+
ok('0 no page error', C.S.errors.length === 0, C.S.errors.join(' | '));
|
|
199
|
+
await C.ctx.close();
|
|
200
|
+
}
|
|
201
|
+
/* D8 floors */
|
|
202
|
+
for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
|
|
203
|
+
const R = await open({ w, h, theme, props: [prop()] });
|
|
204
|
+
await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
|
|
205
|
+
const f = await R.page.evaluate(([v, small]) => {
|
|
206
|
+
const bad = [], root = document.querySelector(v);
|
|
207
|
+
for (const e of root.querySelectorAll('button,input,textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < (small ? 44 : 30)) bad.push(e.textContent.trim().slice(0, 20) + ':' + Math.round(r.height)); }
|
|
208
|
+
const out = [...root.querySelectorAll('*')].filter((e) => { const r = e.getBoundingClientRect(); return r.width && r.right > innerWidth + 1 && !e.closest('.tw,.vwetb,pre'); }).length;
|
|
209
|
+
const fs = [...root.querySelectorAll('*')].map((e) => getComputedStyle(e).fontSize).filter((x, i, a) => a.indexOf(x) === i);
|
|
210
|
+
return { sx: document.documentElement.scrollWidth - innerWidth, bad, out, fs };
|
|
211
|
+
}, [V, w < 600]);
|
|
212
|
+
ok(`D8 at ${w} px ${theme}: no sideways scroll, no small target, nothing past the edge, console sizes only`, f.sx <= 0 && f.bad.length === 0 && f.out === 0 && f.fs.every((x) => ['11px', '12px', '14px', '16px', '20px', '28px'].includes(x)), JSON.stringify(f));
|
|
213
|
+
const c = await R.page.evaluate((v) => { const e = document.querySelector(v + ' .cf'); return [getComputedStyle(e).backgroundColor, getComputedStyle(e).color]; }, V);
|
|
214
|
+
ok(`D8 at ${w} px ${theme}: the page follows the theme`, theme === 'dark' ? c[0] === 'rgb(23, 26, 35)' : c[0] === 'rgb(253, 253, 252)', JSON.stringify(c));
|
|
215
|
+
await R.ctx.close();
|
|
216
|
+
}
|
|
217
|
+
finish();
|
|
218
|
+
})();
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { pmPost } from './http.js';
|
|
6
6
|
import { proposalsModel, relationsOf, copyKindOf, copyView, editBody, acceptBody, rejectBody, askBody, askLine, issueBody, mdHtml, sectionAttribution, revDiffHtml } from './premium-doc-edit.js';
|
|
7
7
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, logHtml, turnA, ptx, kv, CHECK, CHEV, AI } from './premium-shell.js';
|
|
8
|
+
import { openDocPage } from './premium-vw-doc.js';
|
|
8
9
|
|
|
9
10
|
const when = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return ''; return +m[3] + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+m[2] - 1]; };
|
|
10
11
|
|
|
@@ -52,7 +53,7 @@ export function mountDocSheet(ctx) {
|
|
|
52
53
|
const cps = (s.copies || []).map(copyView);
|
|
53
54
|
const cpc = s.copies == null ? '' : cps.length ? cps.map((c) => `<button type="button" class="chp lk ${c.tone}" data-ds="cp" aria-expanded="${!!s.cp}" title="${esc(c.words)}"><i></i>${esc(c.tool)}: ${esc(c.state.toLowerCase())}</button>`).join('') : `<button type="button" class="chp lk" data-ds="cp" aria-expanded="${!!s.cp}"><i></i>Link a copy</button>`;
|
|
54
55
|
const file = String(d.path).split('/').pop();
|
|
55
|
-
const head = `<div class="dsm2"><span class="chp ${d.st === 'ok' ? 'ok' : d.st === 'draft' ? 'warn' : ''}"><i></i>${esc(d.state)}</span>${revs.length ? `<span class="chp mono">v${revs.length}</span>` : ''}${chk}${cpc}<button type="button" class="chp lk" data-ds="meta" aria-expanded="${!!s.meta}" title="${esc(d.path)}">${esc(file)}</button>${last ? `<span class="chp"><span>Last change: <b>${esc(whoOf(last))}</b>${last.at ? ', ' + esc(when(last.at)) : ''}</span></span>` : ''}${d.when && !last ? `<span class="chp">updated ${esc(d.when)}</span>` : ''}</div>${s.cp ? copiesHtml(s, cps) : ''}${s.meta ? `<div class="dsmeta"><p class="dpath">${esc(d.path)}</p>${m0 && m0.fm.length ? kv(m0.fm) : '<p class="note">The file has no front matter.</p>'}</div>` : ''}`;
|
|
56
|
+
const head = `<div class="dsm2"><span class="chp ${d.st === 'ok' ? 'ok' : d.st === 'draft' ? 'warn' : ''}"><i></i>${esc(d.state)}</span>${revs.length ? `<span class="chp mono">v${revs.length}</span>` : ''}${chk}${cpc}<button type="button" class="chp lk" data-ds="meta" aria-expanded="${!!s.meta}" title="${esc(d.path)}">${esc(file)}</button><button type="button" class="chp lk" data-ds="page" title="Read and edit it as a page in the viewer">Open as a page</button>${last ? `<span class="chp"><span>Last change: <b>${esc(whoOf(last))}</b>${last.at ? ', ' + esc(when(last.at)) : ''}</span></span>` : ''}${d.when && !last ? `<span class="chp">updated ${esc(d.when)}</span>` : ''}</div>${s.cp ? copiesHtml(s, cps) : ''}${s.meta ? `<div class="dsmeta"><p class="dpath">${esc(d.path)}</p>${m0 && m0.fm.length ? kv(m0.fm) : '<p class="note">The file has no front matter.</p>'}</div>` : ''}`;
|
|
56
57
|
let body = '';
|
|
57
58
|
if (s.err) body = `<p class="empty3 plain">${esc(s.err)}</p>`;
|
|
58
59
|
else if (s.tab === 'read') {
|
|
@@ -193,7 +194,7 @@ export function mountDocSheet(ctx) {
|
|
|
193
194
|
const lg = e.target.closest('[data-lgd]');
|
|
194
195
|
if (lg && sheet) { toggleCmp(lg.dataset.lgd); return; }
|
|
195
196
|
const rl = e.target.closest('[data-rel]');
|
|
196
|
-
if (rl && sheet) {
|
|
197
|
+
if (rl && sheet) { openPage({ path: rl.dataset.rel, title: rl.dataset.rt }); return; } // a related file opens as a page beside this one (premium-viewer R1, R2)
|
|
197
198
|
const t = e.target.closest('[data-sh]');
|
|
198
199
|
if (t && sheet) { keepDraft(); sheet.vm = false; sheet.tab = t.dataset.sh; sheet.err = null; sheet.msg = ''; drawSheet(); loadTab(sheet.tab); return; }
|
|
199
200
|
const b = e.target.closest('[data-ds]'); if (b && sheet) { sheetPress(b.dataset.ds); return; }
|
|
@@ -221,6 +222,7 @@ export function mountDocSheet(ctx) {
|
|
|
221
222
|
const s = sheet; keepDraft();
|
|
222
223
|
const fail = (m) => { s.busy = false; s.msg = m; drawSheet(); };
|
|
223
224
|
if (act === 'meta') { s.meta = !s.meta; drawSheet(); return; }
|
|
225
|
+
if (act === 'page') { openPage({ path: s.d.path, title: s.d.title, iniName: s.d.iniName }); return; }
|
|
224
226
|
if (act === 'cp') { s.cp = !s.cp; s.cpMsg = ''; drawSheet(); return; }
|
|
225
227
|
if (act === 'cplink') {
|
|
226
228
|
const t = String(s.cpUrl || '').trim(), kind = copyKindOf(t);
|
|
@@ -289,6 +291,11 @@ export function mountDocSheet(ctx) {
|
|
|
289
291
|
toast('Rejected. The file is as it was.'); return reloadSheet(s);
|
|
290
292
|
}
|
|
291
293
|
}
|
|
294
|
+
/** The document as a page in the viewer (premium-vw-doc.js). A write there reads this sheet again, so its views stay in step. */
|
|
295
|
+
function openPage(doc) {
|
|
296
|
+
const s = sheet;
|
|
297
|
+
openDocPage(doc, { ws: ctx.ws, onWrite: () => { if (sheet === s && s) reloadSheet(s); } });
|
|
298
|
+
}
|
|
292
299
|
async function pollAsk(s, id) {
|
|
293
300
|
for (let i = 0; i < 400 && sheet === s; i++) {
|
|
294
301
|
await new Promise((r) => setTimeout(r, 2000));
|
|
@@ -10,14 +10,19 @@
|
|
|
10
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
11
|
* shown in a frame with an empty sandbox: nothing in it runs.
|
|
12
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.
|
|
13
|
+
* issued cycle is frozen: no design row and no turn. Issuing and the copies in other tools stay in the console.
|
|
14
|
+
* Edit opens the report's file as a page in the viewer (premium-vw-doc.js, initiative premium-viewer S2): the one document page every markdown file uses,
|
|
15
|
+
* with Present, Print and Download on its bar. Its words are saved there through the /api/doc-sheet routes. */
|
|
14
16
|
import { $, esc, openDlg, toast, turnA, turnU, ptx, setFull } from './premium-shell.js';
|
|
15
17
|
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
import { vwShow } from './premium-viewer.js';
|
|
19
|
+
import { openDocPage } from './premium-vw-doc.js';
|
|
16
20
|
|
|
17
21
|
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
18
22
|
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
23
|
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
24
|
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"/>');
|
|
25
|
+
const PEN = ICO('<path d="M4 20h4L19 9l-4-4L4 16z"/>');
|
|
21
26
|
const EYE = ICO('<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>');
|
|
22
27
|
const W = 1280;
|
|
23
28
|
const POLL_MS = 800, POLL_MAX = 240000;
|
|
@@ -147,7 +152,8 @@ function barHtml() {
|
|
|
147
152
|
const item = (k, l, ico, on) => `<button type="button" role="menuitem" data-rr="${k}"${on === undefined ? '' : ` aria-current="${on}"`}>${ico}${l}${on ? CHK : ''}</button>`;
|
|
148
153
|
return `<div class="dsvr rdbar">${mnuHtml('rm', 'Read', EYE, item('present', 'Present', PLAY) + item('print', 'Print or save as PDF', PRI))}`
|
|
149
154
|
+ `<span class="rdsp">${mnuHtml('fm', R.view === 'deck' ? 'Slide deck' : 'Document', ICO('<path d="M12 3 3 8l9 5 9-5-9-5zM3 13l9 5 9-5"/>'), item('view|deck', 'Slide deck', '', R.view === 'deck') + item('view|doc', 'Document', '', R.view === 'doc'))}`
|
|
150
|
-
+ `<span class="dsvw"><button type="button" class="dsvb" data-rr="dm" aria-haspopup="menu" aria-expanded="${!!R.dm}">${DLI}Download${CHV}</button>${dm}</span
|
|
155
|
+
+ `<span class="dsvw"><button type="button" class="dsvb" data-rr="dm" aria-haspopup="menu" aria-expanded="${!!R.dm}">${DLI}Download${CHV}</button>${dm}</span>`
|
|
156
|
+
+ (R.issued ? '' : `<button type="button" class="dsvb" data-rr="page" title="Read and edit the words as a page">${PEN}Edit</button>`) + '</span></div>';
|
|
151
157
|
}
|
|
152
158
|
function draw() {
|
|
153
159
|
if (!R) return;
|
|
@@ -228,6 +234,7 @@ async function act(a) {
|
|
|
228
234
|
if (k === 'md') { R.dm = false; saveMd(); draw(); return; }
|
|
229
235
|
if (k === 'print') { R.mn = ''; draw(); printIt(); return; }
|
|
230
236
|
if (k === 'present') { R.mn = ''; draw(); present(true); return; }
|
|
237
|
+
if (k === 'page') { openPage(); return; }
|
|
231
238
|
if (k === 'pick') { const f = $('#rdFile'); if (f) f.click(); return; }
|
|
232
239
|
if (k === 'ver') {
|
|
233
240
|
if (v === 'cycle') { R.show = 'cycle'; R.i = 0; draw(); return; }
|
|
@@ -253,6 +260,17 @@ async function act(a) {
|
|
|
253
260
|
if (r.redraw && r.redraw.started) { await settle(); await readCycle(); draw(); }
|
|
254
261
|
}
|
|
255
262
|
}
|
|
263
|
+
/** The report's file as the document page, with this report's Present, Print and Download on its bar. A save there reads the words again here. */
|
|
264
|
+
function openPage() {
|
|
265
|
+
const me = R;
|
|
266
|
+
openDocPage({ path: R.row.path, title: R.name + (R.row.slot ? ' · ' + R.row.slot : '') }, {
|
|
267
|
+
ws: () => me.ws,
|
|
268
|
+
extras: () => [{ k: 'present', label: 'Present', icon: PLAY }, { k: 'print', label: 'Print', icon: PRI },
|
|
269
|
+
{ k: 'dl', label: 'Download', icon: DLI, note: 'The files carry the words, not the look. Print or save as PDF keeps the look.', menu: DL.map(([f, l, sub]) => ({ label: l, sub, icon: DLI, download: true, href: '/api/report-export?' + q({ ws: me.ws, path: me.row.path, fmt: f }) })).concat([{ k: 'md', label: 'Markdown (.md)', sub: 'The file, as written.', icon: DLI }]) }],
|
|
270
|
+
onExtra: (k) => { if (R !== me) return; if (k === 'present') { vwShow('main'); act(['present']); } else if (k === 'print') printIt(); else if (k === 'md') saveMd(); },
|
|
271
|
+
onWrite: async () => { if (R !== me) return; try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: R.row.path })); R.W = wordsOf(R.text, R.name); } catch { /* the reader keeps what it had */ } if (R === me) draw(); },
|
|
272
|
+
});
|
|
273
|
+
}
|
|
256
274
|
function saveMd() {
|
|
257
275
|
const name = (R.row.path.split('/').slice(-2).join('-') || 'report.md');
|
|
258
276
|
const u = URL.createObjectURL(new Blob([R.text || ''], { type: 'text/markdown' })), a = document.createElement('a');
|