create-pmos 0.601.0 → 0.603.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 +33 -27
- 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/changelog.json +32 -0
- package/workspace/guide/agent-capabilities.md +7 -7
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/statuses.md +12 -1
- package/workspace/lib/initiative-chat.js +3 -0
- package/workspace/lib/initiative-premium.js +1 -0
- package/workspace/lib/live-round.js +30 -8
- package/workspace/lib/proto-runtime.js +39 -5
- package/workspace/lib/routes-lab.js +10 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-proto.css +66 -17
- package/workspace/public/pm/cozy-proto.js +224 -56
- package/workspace/public/pm/home-chat.js +4 -0
- package/workspace/public/pm/ini-tasks.js +6 -2
- package/workspace/public/pm/ini-view-model.js +20 -4
- package/workspace/public/pm/ini-view.css +4 -0
- package/workspace/public/pm/premium-initiative-head.js +1 -1
- package/workspace/public/pm/stage-line.js +2 -2
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
* 2026-11-17). The initiative chat sits on the left; this draws the right side for a live round (lib/live-round.js), from the compare view
|
|
4
4
|
* pm/cozy-lab.js reads (GET /api/lab/compare: the version's file and its companions as data, lib/live-round.js partsAt).
|
|
5
5
|
*
|
|
6
|
-
* The toolbar:
|
|
7
|
-
*
|
|
6
|
+
* The toolbar: Select (V), Comment (C), Draw (D) · pages and layers ([), the inspector (]) · Page copy, The flow, Who does what (side
|
|
7
|
+
* panels, closed by default: Wawan 2026-11-18) · Latest · version n (‹ to earlier ones; an older one has › , Back to latest, Continue from
|
|
8
|
+
* version n) · zoom −, +, fit · Play. Icon-only presses with aria-labels.
|
|
9
|
+
* Design mode (design "Prototype like Figma", Exploring 2 page pgFp, Wawan "build" 2026-11-18): Pages > Screens > Layers on the left (a
|
|
10
|
+
* page is a data-page, its screens are its states, its layers are the data-el blocks of the screen shown); the inspector on the right
|
|
11
|
+
* (Exact values: text, font, size, weight, line height, spacing, colour, fill, corner, padding, align), saved with the version in
|
|
12
|
+
* edits.json (styles) and kept by the next version; a change says "You set … Kept as yours." once in the chat ('pmos:note').
|
|
8
13
|
* The cards, which update together: the prototype in a phone or desktop frame (Tweaks under it for the element pointed at, the comments,
|
|
9
14
|
* the ✦ test-link suggestion); the flow (screens as cards, decisions as diamonds, drawn as SVG from flow.json: a screen shows that moment
|
|
10
15
|
* on the prototype, a branch plays its scenario); the page copy, in its side panel (copy.json, edited in place: the prototype changes as the PM types and
|
|
@@ -31,7 +36,8 @@ const I = {
|
|
|
31
36
|
prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6', latest: 'M5 12h14M13 6l6 6-6 6', cont: 'M4 12a8 8 0 1 0 2.3-5.6L4 9M4 4v5h5',
|
|
32
37
|
restart: 'M4 12a8 8 0 1 0 2.3-5.6L4 9M4 4v5h5', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12l5 5 9-10', send: 'M12 19V5M6 11l6-6 6 6',
|
|
33
38
|
keep: 'M6 4h12v16l-6-4-6 4z', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
|
|
34
|
-
text: 'M4 7V5h16v2M12 5v14M9 19h6',
|
|
39
|
+
text: 'M4 7V5h16v2M12 5v14M9 19h6', flow: 'M3 4h6v5H3zM15 4h6v5h-6zM9 15h6v5H9zM9 6.5h6M18 9v3h-6v3', lanes: 'M3 6h18M3 12h18M3 18h18M6 4h4v4H6zM13 10h4v4h-4z',
|
|
40
|
+
left: 'M3 4h18v16H3zM9 4v16', right: 'M3 4h18v16H3zM15 4v16', own: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5', undo: 'M3 7v6h6M21 17a9 9 0 0 0-15-6.7L3 13', select: 'M4 3l7 18 2.5-7.5L21 11z',
|
|
35
41
|
attach: 'M20 11l-8.5 8.5a5 5 0 0 1-7-7L13 4a3.5 3.5 0 0 1 5 5l-8.5 8.5a2 2 0 0 1-3-3L14 7', star: 'M12 3l2.2 6.3H21l-5.4 4 2 6.4L12 15.8 6.4 19.7l2-6.4L3 9.3h6.8z',
|
|
36
42
|
};
|
|
37
43
|
const ib = (attr, label, icon, cls = '') => `<button type="button" class="pc-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
|
|
@@ -143,9 +149,12 @@ export function lanesLayout(lanes) {
|
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
/* ── state ── */
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
/* Design mode is the default (design "Prototype like Figma", Wawan "build" 2026-11-18): Select is on, Pages > Screens > Layers on the left,
|
|
153
|
+
* the inspector (Exact values) on the right; both hide ([ and ]). Page copy, The flow and Who does what are side panels behind toolbar
|
|
154
|
+
* presses, closed by default; one shows at a time, in the inspector's place. The device switch is only for Play. */
|
|
155
|
+
const V = { body: null, c: null, at: null, H: null, last: null, mode: 'point', pdev: store.get('pmos.pc.pdev') || 'own', zoom: Number(store.get('pmos.pc.zoom')) || 0,
|
|
156
|
+
sel: null, looks: null, screen: '', frameUrl: '', ready: null, edits: { copy: {}, vars: {}, styles: {} }, pend: null, saveT: null, draft: null, drawing: false, strokes: 0,
|
|
157
|
+
play: null, sig: '', side: null, left: store.get('pmos.pc.left') !== '0', insp: store.get('pmos.pc.insp') !== '0', noteT: null };
|
|
149
158
|
const ARROW = '<marker id="pcArr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="currentColor"/></marker>';
|
|
150
159
|
const frameUrl = (c) => (c && c.url ? c.url + '&rt=1' : '');
|
|
151
160
|
const toFrame = (m, f) => { const fr = f || (V.body && V.body.querySelector('.pc-frame iframe')); if (fr && fr.contentWindow) fr.contentWindow.postMessage({ pmos: 1, ...m }, '*'); };
|
|
@@ -162,20 +171,22 @@ function shown(c) {
|
|
|
162
171
|
|
|
163
172
|
/* ── the parts ── */
|
|
164
173
|
function barHtml(c, v) {
|
|
165
|
-
const H = (c.history || []).filter((h) => h.round)
|
|
174
|
+
const H = (c.history || []).filter((h) => h.round);
|
|
166
175
|
const at = H.findIndex((h) => h.current), newest = H[0];
|
|
167
176
|
const older = at >= 0 && at + 1 < H.length ? H[at + 1] : null, newer = at > 0 ? H[at - 1] : null;
|
|
168
177
|
const old = at > 0 && newest;
|
|
169
178
|
const tool = (m, label, icon, key) => `<button type="button" class="pc-ib" data-pc-mode="${m}" aria-pressed="${V.mode === m}" aria-label="${esc(label + ' (' + key + ')')}" title="${esc(label + ' (' + key + ')')}">${SVG(icon, 16)}</button>`;
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
: `<span class="pc-ver"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
+ `<span class="pc-grp">${
|
|
178
|
-
|
|
179
|
+
const tog = (attr, on, label, icon, extra = '') => `<button type="button" class="pc-ib${extra}" ${attr} aria-pressed="${on}" aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
|
|
180
|
+
// the design opens on the latest version (Wawan 2026-11-18: "default should show the latest version"); an older one says so, with the way back
|
|
181
|
+
const ver = !old ? `<span class="pc-ver">${older ? ib(`data-lab-round="${esc(older.id)}"`, 'Earlier version', I.prev) : ''}<b>Latest · version ${c.round || 1}</b></span>`
|
|
182
|
+
: `<span class="pc-ver">${ib(`data-lab-round="${esc(older ? older.id : '')}"${older ? '' : ' disabled'}`, 'Earlier version', I.prev)}<b>Version ${c.round}</b>${ib(`data-lab-round="${esc(newer ? newer.id : '')}"`, 'Later version', I.next)}`
|
|
183
|
+
+ ib(`data-lab-round="${esc(newest.id)}"`, 'Back to latest', I.latest) + ib(`data-pc-from="${c.round}"`, 'Continue from version ' + c.round, I.cont) + '</span>';
|
|
184
|
+
const z = Math.round((V.zoom || 1) * 100), u = c.updated || {};
|
|
185
|
+
return `<div class="pc-bar" role="toolbar" aria-label="Prototype tools"><span class="pc-grp">${tool('point', 'Select a layer', I.select, 'V')}${tool('comment', 'Comment', I.comment, 'C')}${tool('draw', 'Draw a sketch', I.draw, 'D')}</span>`
|
|
186
|
+
+ `<span class="pc-grp" aria-label="Show or hide panels">${tog('data-pc-left', V.left, (V.left ? 'Hide' : 'Show') + ' pages and layers ([)', I.left)}${tog('data-pc-insp', V.insp && !V.side, (V.insp ? 'Hide' : 'Show') + ' the inspector (])', I.right)}</span>`
|
|
187
|
+
// the page copy, the flow and who does what each sit behind one press, closed by default (Wawan 2026-11-18), like the page copy before
|
|
188
|
+
+ `<span class="pc-grp" aria-label="Side panels">${tog('data-pc-side="copy"', V.side === 'copy', 'Page copy', I.text, u.copy ? ' upd' : '')}${tog('data-pc-side="flow"', V.side === 'flow', 'The flow', I.flow, u.flow ? ' upd' : '')}${tog('data-pc-side="lanes"', V.side === 'lanes', 'Who does what', I.lanes, u.lanes ? ' upd' : '')}</span>`
|
|
189
|
+
+ `${ver}<span class="pc-sp"></span>`
|
|
179
190
|
+ `<span class="pc-grp">${ib('data-pc-zoom="-1"', 'Zoom out', I.minus)}<span class="pc-z" aria-live="polite">${z}%</span>${ib('data-pc-zoom="1"', 'Zoom in', I.plus)}${ib('data-pc-zoom="0"', 'Fit to the Viewer', I.fit)}</span>`
|
|
180
191
|
+ `${ib('data-pc-play', 'Play the prototype', I.play, 'blue')}</div>`;
|
|
181
192
|
}
|
|
@@ -201,15 +212,14 @@ if (typeof document !== 'undefined' && typeof setInterval === 'function') setInt
|
|
|
201
212
|
function protoCard(c, v, making) {
|
|
202
213
|
const data = v.data || {}, tw = ((data.tweaks && data.tweaks.tweaks) || []).filter((t) => !t.el || (V.sel && t.el === V.sel.el));
|
|
203
214
|
const tweaks = tw.length ? `<div class="pc-tw" aria-label="Tweaks">${tw.map((t) => { const val = parseFloat(V.edits.vars[t.var]) || t.value; return `<label><span>${esc(t.label)}</span><input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${val}" data-pc-var="${esc(t.var)}" data-pc-unit="${esc(t.unit)}"><em>${esc(val + t.unit)}</em></label>`; }).join('')}</div>` : '';
|
|
204
|
-
const sel = V.sel ? `<p class="pc-sel">${SVG(I.point, 14)}<b>${esc(V.sel.label || V.sel.el)}</b> is in the chat box: say the change.${ib('data-pc-unsel', 'Clear the element', I.x)}</p>` : '';
|
|
215
|
+
const sel = V.sel && !(V.insp && !V.side) ? `<p class="pc-sel">${SVG(I.point, 14)}<b>${esc(V.sel.label || V.sel.el)}</b> is in the chat box: say the change.${ib('data-pc-unsel', 'Clear the element', I.x)}</p>` : '';
|
|
205
216
|
const cm = (c.comments || []).filter((x) => !x.send);
|
|
206
217
|
const draft = V.draft ? `<div class="pc-cdraft"><label for="pcCm">Comment${V.draft.label ? ' on ' + esc(V.draft.label) : ''}</label><textarea id="pcCm" rows="2" maxlength="500" placeholder="Say what should change"></textarea><span>${ib('data-pc-cm="send"', 'Send to PMOS as the next change', I.send, 'blue')}${ib('data-pc-cm="keep"', 'Keep for the team', I.keep)}${ib('data-pc-cm="x"', 'Cancel', I.x)}</span></div>` : '';
|
|
207
218
|
const list = cm.length ? `<ol class="pc-cms">${cm.map((x, i) => `<li><span class="pc-pin">${i + 1}</span><span class="w">${x.label ? `<small>on ${esc(x.label)}</small>` : ''}${esc(x.text)}</span>${ib(`data-pc-make="${esc(x.id)}"`, 'Make this change', I.star)}</li>`).join('')}</ol>` : '';
|
|
208
219
|
const sug = suggestion(c);
|
|
209
220
|
const draw = V.mode === 'draw' ? `<canvas class="pc-ink" aria-label="Sketch over the prototype"></canvas><span class="pc-inkacts">${ib('data-pc-ink="attach"', 'Attach the sketch to your next message', I.attach, 'blue')}${ib('data-pc-ink="clear"', 'Clear the sketch', I.x)}</span>` : '';
|
|
210
221
|
const lost = c.notMade ? `<p class="pc-making pc-lost">Version ${c.round} was not made: ${esc(c.notMade)}.${c.fallbackN ? ` This is version ${c.fallbackN}.` : ''} Ask in the chat for it in smaller steps, one screen or format at a time.</p>` : '';
|
|
211
|
-
return `<
|
|
212
|
-
+ `<div class="pc-dev ${V.device}"><div class="pc-frame" data-pc-frame>${v.url ? '' : '<p class="pc-none">PMOS is making it.</p>'}</div>${draw}</div>${sel}${tweaks}${draft}${list}${sug}</section>`;
|
|
222
|
+
return { pre: lost + (making ? progressHtml(c) : ''), dev: `<div class="pc-frame" data-pc-frame>${v.url ? '' : '<p class="pc-none">PMOS is making it.</p>'}</div>${draw}`, post: sel + tweaks + draft + list + sug };
|
|
213
223
|
}
|
|
214
224
|
function suggestion(c) {
|
|
215
225
|
// the design sprint runs silently: PMOS recommends good practice as ONE ✦ (canvas PbcChat), here: test it with people once it settles
|
|
@@ -219,8 +229,10 @@ function suggestion(c) {
|
|
|
219
229
|
return `<div class="pc-sug"><span class="pc-star" aria-hidden="true">✦</span><p>Version ${c.round} answers the brief. Try it on 3 to 5 people it is for before more polish.</p>${ib(`data-pc-sug="link" data-pc-sugk="${esc(key)}"`, 'Get a test link', I.link, 'blue')}${ib(`data-pc-sug="no" data-pc-sugk="${esc(key)}"`, 'Not now', I.x)}</div>`;
|
|
220
230
|
}
|
|
221
231
|
function flowCard(c, v) {
|
|
232
|
+
if (V.side !== 'flow') return '';
|
|
233
|
+
const close = ib('data-pc-side="flow"', 'Close the flow', I.x);
|
|
222
234
|
const f = (v.data || {}).flow, st = (c.parts || {}).flow;
|
|
223
|
-
if (!f) return `<section class="pc-card pc-flowc" aria-label="The flow"><h3>The flow</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No flow for this version.')}</p></section>`;
|
|
235
|
+
if (!f) return `<section class="pc-card pc-flowc pc-side" aria-label="The flow"><h3>The flow ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No flow for this version.')}</p></section>`;
|
|
224
236
|
const L = flowLayout(f), scen = f.scenarios || [];
|
|
225
237
|
const branchOf = (to) => { for (let i = 1; i < scen.length; i += 1) if (scen[i].steps.some((s) => s.screen === to)) return scen[i].id; return ''; };
|
|
226
238
|
const nodes = L.nodes.map((n) => n.kind === 'decision'
|
|
@@ -228,12 +240,12 @@ function flowCard(c, v) {
|
|
|
228
240
|
: `<g class="pc-sn${n.main ? '' : ' br'}${V.screen === n.id ? ' on' : ''}" data-pc-screen="${esc(n.id)}" role="button" tabindex="0" aria-label="${esc('Show ' + n.title + ' on the prototype')}"><rect x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" rx="8"/><text x="${n.x + 10}" y="${n.y + 15}" class="k">SCREEN</text><text>${lines(n.title, n.x + 10, n.y + 31, 21)}</text></g>`).join('');
|
|
229
241
|
const edges = L.edges.map((e) => { const sc = e.main ? '' : branchOf(e.to); return `<g class="pc-e${e.main ? '' : ' br'}"${sc ? ` data-pc-scen="${esc(sc)}" role="button" tabindex="0" aria-label="${esc('Play ' + (scen.find((x) => x.id === sc) || {}).name)}"` : ''}><path d="${e.d}" marker-end="url(#pcArr)"/>${sc ? `<path class="hit" d="${e.d}"/>` : ''}${e.label ? `<text x="${e.lx}" y="${e.ly}" text-anchor="${e.anchor || 'middle'}">${esc(e.label)}</text>` : ''}</g>`; }).join('');
|
|
230
242
|
const chips = scen.length ? `<div class="pc-scens">${scen.map((s, i) => `<button type="button" class="pc-chip" data-pc-scen="${esc(s.id)}" title="${esc(s.description || '')}">${SVG(I.play, 12)}${esc(i === 0 ? s.name : s.name)}</button>`).join('')}</div>` : '';
|
|
231
|
-
return `<section class="pc-card pc-flowc" aria-label="The flow"><h3>The flow ${upd(c, 'flow')}</h3><div class="pc-svgw"><svg class="pc-flow" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${edges}${nodes}</svg></div>`
|
|
243
|
+
return `<section class="pc-card pc-flowc pc-side" aria-label="The flow"><h3>The flow ${upd(c, 'flow')}${close}</h3><div class="pc-svgw"><svg class="pc-flow" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${edges}${nodes}</svg></div>`
|
|
232
244
|
+ `<p class="pc-hint">Tap a screen to see it on the prototype. Tap a side branch to play that scenario.</p>${chips}</section>`;
|
|
233
245
|
}
|
|
234
246
|
function copyCard(c, v) {
|
|
235
|
-
if (
|
|
236
|
-
const close = ib('data-pc-
|
|
247
|
+
if (V.side !== 'copy') return '';
|
|
248
|
+
const close = ib('data-pc-side="copy"', 'Close the page copy', I.x);
|
|
237
249
|
const copy = (v.data || {}).copy || {}, keys = Object.keys(copy);
|
|
238
250
|
if (!keys.length) return `<section class="pc-card pc-copyc pc-side" aria-label="Page copy"><h3>Page copy ${close}</h3><p class="pc-none">${esc(v.url ? 'This version has no editable copy.' : 'PMOS is writing it.')}</p></section>`;
|
|
239
251
|
const changed = new Set((c.updated && c.updated.keys) || []);
|
|
@@ -241,15 +253,75 @@ function copyCard(c, v) {
|
|
|
241
253
|
+ '<p class="pc-hint">Edit any line: the prototype changes as you type, and the next version keeps it.</p></section>';
|
|
242
254
|
}
|
|
243
255
|
function lanesCard(c, v) {
|
|
256
|
+
if (V.side !== 'lanes') return '';
|
|
257
|
+
const close = ib('data-pc-side="lanes"', 'Close who does what', I.x);
|
|
244
258
|
const l = (v.data || {}).lanes, st = (c.parts || {}).lanes;
|
|
245
|
-
if (!l) return `<section class="pc-card pc-lanesc" aria-label="Who does what"><h3>Who does what</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No swimlane for this version.')}</p></section>`;
|
|
259
|
+
if (!l) return `<section class="pc-card pc-lanesc pc-side" aria-label="Who does what"><h3>Who does what ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No swimlane for this version.')}</p></section>`;
|
|
246
260
|
const L = lanesLayout(l), chg = new Set((c.updated && c.updated.steps) || []);
|
|
247
261
|
const lanes = L.lanes.map((x, i) => `<g class="pc-ln${i % 2 ? ' alt' : ''}"><rect x="0" y="${x.y}" width="${L.w}" height="${LH}"/><text x="12" y="${x.y + LH / 2 + 4}">${esc(x.name.slice(0, 14))}</text></g>`).join('');
|
|
248
262
|
const boxes = L.boxes.map((b) => `<g class="pc-bx${chg.has(b.n) ? ' ch' : ''}${b.screen ? '' : ' ns'}"${b.screen ? ` data-pc-screen="${esc(b.screen)}" role="button" tabindex="0" aria-label="${esc('Show step ' + b.n + ' on the prototype')}"` : ''}><rect x="${b.x}" y="${b.y}" width="${BW}" height="${BH}" rx="8"/><text text-anchor="middle">${lines(b.title, b.x + BW / 2, b.y + (b.title.length > 21 ? 17 : 24), 21, 12)}</text><circle cx="${b.x}" cy="${b.y}" r="9"/><text class="n" x="${b.x}" y="${b.y + 3.5}" text-anchor="middle">${b.n}</text></g>`).join('');
|
|
249
263
|
const arrows = L.arrows.map((a) => `<path class="pc-ar" d="${a.d}" marker-end="url(#pcArr)"/>`).join('');
|
|
250
|
-
return `<section class="pc-card pc-lanesc" aria-label="Who does what"><h3>Who does what ${upd(c, 'lanes')}</h3><div class="pc-svgw"><svg class="pc-lanes" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${lanes}${arrows}${boxes}</svg></div><p class="pc-hint">Tap a step to see it on the prototype.</p></section>`;
|
|
264
|
+
return `<section class="pc-card pc-lanesc pc-side" aria-label="Who does what"><h3>Who does what ${upd(c, 'lanes')}${close}</h3><div class="pc-svgw"><svg class="pc-lanes" width="100%" style="max-width:${L.w}px" viewBox="0 0 ${L.w} ${L.h}" preserveAspectRatio="xMinYMin meet"><defs>${ARROW}</defs>${lanes}${arrows}${boxes}</svg></div><p class="pc-hint">Tap a step to see it on the prototype.</p></section>`;
|
|
251
265
|
}
|
|
252
266
|
|
|
267
|
+
|
|
268
|
+
/* ── design mode: Pages > Screens > Layers, and the inspector ── */
|
|
269
|
+
/** PURE. The left panel's lists from the frame's ready message: pages (data-page, when the run wrote them), the screens of the page shown,
|
|
270
|
+
* and the layers (data-el) of the screen shown. */
|
|
271
|
+
export function layersOf(ready, screen) {
|
|
272
|
+
const S = (ready && ready.screens) || [], E = (ready && ready.els) || [];
|
|
273
|
+
const cur = S.find((x) => x.id === screen) || S[0] || null;
|
|
274
|
+
const pages = [...new Set(S.map((x) => x.page).filter(Boolean))];
|
|
275
|
+
const page = cur && cur.page ? cur.page : '';
|
|
276
|
+
const screens = page ? S.filter((x) => x.page === page) : S;
|
|
277
|
+
const els = E.filter((e) => e.el && (!e.screen || !cur || e.screen === cur.id));
|
|
278
|
+
return { pages, page, screens, screen: cur ? cur.id : '', screenLabel: cur ? cur.label || human(cur.id) : '', els };
|
|
279
|
+
}
|
|
280
|
+
function leftHtml() {
|
|
281
|
+
if (!V.left) return '';
|
|
282
|
+
const hide = ib('data-pc-left', 'Hide pages and layers', I.left);
|
|
283
|
+
if (!V.ready) return `<aside class="pc-left" aria-label="Pages and layers"><div class="pc-lh"><span>Layers</span>${hide}</div><p class="pc-hint">Reading the layers…</p></aside>`;
|
|
284
|
+
const L = layersOf(V.ready, V.screen), row = (attr, on, text, cls = '') => `<button type="button" class="pc-lrow${cls}" ${attr} aria-pressed="${on}">${esc(text)}</button>`;
|
|
285
|
+
const pages = L.pages.length ? `<div class="pc-lh"><span>Pages</span>${hide}</div>${L.pages.map((pg) => row(`data-pc-page="${esc(pg)}"`, pg === L.page, pg)).join('')}` : '';
|
|
286
|
+
const scr = `<div class="pc-lh"><span>Screens${L.page ? ' · ' + esc(L.page) : ''}</span>${L.pages.length ? '' : hide}</div>${L.screens.map((x) => row(`data-pc-screen="${esc(x.id)}"`, x.id === L.screen, x.label || human(x.id))).join('')}`;
|
|
287
|
+
const lay = `<div class="pc-lh"><span>Layers · ${esc(L.screenLabel)}</span></div>${L.els.length ? L.els.map((e) => row(`data-pc-layer="${esc(e.el)}"`, !!(V.sel && V.sel.el === e.el), e.label || human(e.el), ' in')).join('') : '<p class="pc-hint">This screen has no marked layers. Ask in the chat to mark them.</p>'}`;
|
|
288
|
+
return `<aside class="pc-left" aria-label="Pages and layers">${pages}${scr}${lay}</aside>`;
|
|
289
|
+
}
|
|
290
|
+
const FONTS = ['Plus Jakarta Sans', 'Inter', 'Space Grotesk', 'Space Mono', 'IBM Plex Sans', 'Georgia', 'system-ui'];
|
|
291
|
+
const WEIGHTS = [['300', 'Light'], ['400', 'Regular'], ['500', 'Medium'], ['600', 'Semibold'], ['700', 'Bold'], ['800', 'Extra bold']];
|
|
292
|
+
/** PURE. What one layer's styles say in the chat: "56px · Bold" (lib/live-round.js styleWords says the same). */
|
|
293
|
+
export function styleWords(ps) {
|
|
294
|
+
const W = Object.fromEntries(WEIGHTS);
|
|
295
|
+
return Object.entries(ps || {}).map(([k, v]) => (k === 'weight' ? W[v] || v : k === 'size' || k === 'color' ? v : k + ' ' + v)).join(' · ');
|
|
296
|
+
}
|
|
297
|
+
function inspHtml() {
|
|
298
|
+
if (V.side || !V.insp) return '';
|
|
299
|
+
const hide = ib('data-pc-insp', 'Hide the inspector', I.right);
|
|
300
|
+
if (!V.sel) return `<aside class="pc-insp" aria-label="Exact values"><div class="pc-lh"><span>Exact values</span>${hide}</div><p class="pc-hint">Select a layer on the prototype, or in Layers, to set its exact values. For anything else, say it in the chat.</p></aside>`;
|
|
301
|
+
const el = V.sel.el, mine = V.edits.styles[el] || {}, lk = V.looks || {}, val = (k, d = '') => (k in mine ? mine[k] : k in lk ? lk[k] : d);
|
|
302
|
+
const num = (v) => String(parseFloat(v) || 0), colr = (v) => (/^#[0-9a-f]{6}$/i.test(v) ? v : lk.fillPick || '');
|
|
303
|
+
const id = (k) => 'pcS-' + k;
|
|
304
|
+
const fld = (k, label, inner) => `<label class="pc-ir" for="${id(k)}"><span>${label}</span>${inner}</label>`;
|
|
305
|
+
const nIn = (k, unit, step = '1', min = '0', max = '400', part = '') => `<input type="number" id="${id(k + part)}" data-pc-style="${k}"${part ? ` data-pc-part="${part}"` : ''} data-pc-unit="${unit}" step="${step}" min="${min}" max="${max}" value="${esc(num(part ? String(val(k, '0px 0px')).split(' ')[Number(part)] : val(k)))}">`;
|
|
306
|
+
const sel = (k, opts, cur) => `<select id="${id(k)}" data-pc-style="${k}">${opts.map(([v, t]) => `<option value="${esc(v)}"${String(v) === String(cur) ? ' selected' : ''}>${esc(t)}</option>`).join('')}</select>`;
|
|
307
|
+
const fam = val('family'), fonts = FONTS.includes(fam) || !fam ? FONTS : [fam, ...FONTS];
|
|
308
|
+
const copyKey = V.sel.copy || '', copyVal = copyKey ? (copyKey in V.edits.copy ? V.edits.copy[copyKey] : ((V.ready && V.ready.copy) || {})[copyKey] || '') : '';
|
|
309
|
+
const changed = Object.keys(mine).length;
|
|
310
|
+
return `<aside class="pc-insp" aria-label="Exact values"><div class="pc-lh"><span>Exact values · ${esc(V.sel.label || el)}</span>${hide}</div>`
|
|
311
|
+
+ (copyKey ? `<div class="pc-isec">${fld('text', 'Text', `<input type="text" id="${id('text')}" data-pc-copy-in="${esc(copyKey)}" value="${esc(copyVal)}">`)}</div>` : '')
|
|
312
|
+
+ `<div class="pc-isec"><b>Type</b>${fld('family', 'Font', sel('family', fonts.map((f) => [f, f]), fam))}`
|
|
313
|
+
+ `${fld('size', 'Size', nIn('size', 'px', '1', '6', '400'))}${fld('weight', 'Weight', sel('weight', WEIGHTS, val('weight', '400')))}`
|
|
314
|
+
+ `${fld('line', 'Line height', nIn('line', '', '0.05', '0.8', '3'))}${fld('spacing', 'Spacing', nIn('spacing', 'px', '0.1', '-5', '20'))}`
|
|
315
|
+
+ `${fld('color', 'Colour', `<input type="color" id="${id('color')}" data-pc-style="color" value="${esc(colr(val('color')))}">`)}</div>`
|
|
316
|
+
+ `<div class="pc-isec"><b>Box</b>${fld('fill', 'Fill', `<input type="color" id="${id('fill')}" data-pc-style="fill" value="${esc(colr(val('fill')))}">`)}`
|
|
317
|
+
+ `${fld('corner', 'Corner', nIn('corner', 'px', '1', '0', '200'))}`
|
|
318
|
+
+ `<div class="pc-ir"><span>Padding</span><span class="pc-two">${nIn('padding', 'px', '1', '0', '200', '0')}${nIn('padding', 'px', '1', '0', '200', '1')}</span></div>`
|
|
319
|
+
+ `${fld('align', 'Align', sel('align', [['left', 'Left'], ['center', 'Centre'], ['right', 'Right']], val('align', 'left')))}</div>`
|
|
320
|
+
+ `<p class="pc-ifoot">${changed ? `Saved with version ${esc((V.v && V.v.round) || (V.c && V.c.round) || 1)}. The next version keeps it.` : 'Your changes are saved with this version.'}${changed ? ib(`data-pc-unstyle="${esc(el)}"`, 'Undo this layer\'s changes', I.undo) : ''}</p>`
|
|
321
|
+
+ '</aside>';
|
|
322
|
+
}
|
|
323
|
+
function rightHtml(c, v) { return copyCard(c, v) + flowCard(c, v) + lanesCard(c, v) + inspHtml(); }
|
|
324
|
+
|
|
253
325
|
/* ── draw ── */
|
|
254
326
|
/** Draw or update the canvas. body: the Viewer's body; c: GET /api/lab/compare's compare (live); o: { at, H } */
|
|
255
327
|
export function draw(body, c, o = {}) {
|
|
@@ -258,26 +330,35 @@ export function draw(body, c, o = {}) {
|
|
|
258
330
|
if (c.file && c.data) V.last = c;
|
|
259
331
|
const { v, making } = shown(c), prevFile = V.v && V.v.file;
|
|
260
332
|
// a new version: its own edits, nothing pointed at
|
|
261
|
-
if (prevFile !== v.file) {
|
|
333
|
+
if (prevFile !== v.file) { const e = (v.data && v.data.edits) || {}; V.edits = { copy: { ...(e.copy || {}) }, vars: { ...(e.vars || {}) }, styles: { ...(e.styles || {}) } }; V.sel = null; V.looks = null; V.ready = null; }
|
|
262
334
|
V.c = c; V.v = v;
|
|
263
335
|
let root = body.querySelector(':scope > .pc');
|
|
264
336
|
if (!root) { body.innerHTML = '<div class="pc"></div>'; root = body.querySelector('.pc'); wire(root); }
|
|
265
337
|
V.body = body;
|
|
266
338
|
// keep the frame (and what the PM typed) while the canvas reads again every 2 seconds
|
|
267
|
-
const sig = JSON.stringify([c.id, c.key, c.round, c.file, v.file, c.working, c.progress, c.notMade, c.updated, c.parts, (c.comments || []).length, V.mode, V.
|
|
268
|
-
const focus = document.activeElement && root.contains(document.activeElement) && document.activeElement.matches('[data-pc-copy],textarea,input');
|
|
339
|
+
const sig = JSON.stringify([c.id, c.key, c.round, c.file, v.file, c.working, c.progress, c.notMade, c.updated, c.parts, (c.comments || []).length, V.mode, V.sel && V.sel.el, V.looks, !!V.ready, V.screen, V.left, V.insp, V.side, !!V.draft, (c.history || []).length, c.state]);
|
|
340
|
+
const focus = document.activeElement && root.contains(document.activeElement) && document.activeElement.matches('[data-pc-copy],textarea,input,select');
|
|
269
341
|
if (sig === V.sig && root.firstChild) return;
|
|
270
342
|
if (focus && prevFile === v.file) return; // the PM is typing in this version: draw on a later read
|
|
271
343
|
V.sig = sig;
|
|
272
344
|
const frame = root.querySelector('.pc-frame iframe'), keepFrame = frame && V.frameUrl === frameUrl(v);
|
|
273
345
|
const draftText = root.querySelector('#pcCm') ? root.querySelector('#pcCm').value : '';
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
346
|
+
const P = protoCard(c, v, making);
|
|
347
|
+
if (keepFrame) {
|
|
348
|
+
// everything around the frame is drawn again; the frame stays where it is (moving an iframe reloads it)
|
|
349
|
+
const put = (sel, html) => { const n = root.querySelector(sel); if (n) n.innerHTML = html; };
|
|
350
|
+
put('.pc-barw', barHtml(c, v)); put('.pc-trayw', trayHtml(c)); put('.pc-leftw', leftHtml()); put('.pc-rightw', rightHtml(c, v));
|
|
351
|
+
put('.pc-pre', P.pre); put('.pc-post', P.post);
|
|
352
|
+
root.querySelectorAll('.pc-dev > :not(.pc-frame)').forEach((n) => n.remove());
|
|
353
|
+
const dv = root.querySelector('.pc-dev'); if (dv) dv.insertAdjacentHTML('beforeend', P.dev.slice(P.dev.indexOf('</div>') + 6));
|
|
354
|
+
} else {
|
|
355
|
+
root.innerHTML = `<div class="pc-barw">${barHtml(c, v)}</div><div class="pc-trayw">${trayHtml(c)}</div><div class="pc-dbody"><div class="pc-leftw">${leftHtml()}</div>`
|
|
356
|
+
+ `<div class="pc-vp"><div class="pc-board"><section class="pc-card pc-proto" aria-label="The prototype"><div class="pc-pre">${P.pre}</div><div class="pc-dev desktop">${P.dev}</div><div class="pc-post">${P.post}</div></section></div></div>`
|
|
357
|
+
+ `<div class="pc-rightw">${rightHtml(c, v)}</div></div>`;
|
|
358
|
+
const slot = root.querySelector('[data-pc-frame]');
|
|
359
|
+
if (slot && v.url) { V.frameUrl = frameUrl(v); V.ready = null; slot.innerHTML = `<iframe src="${esc(V.frameUrl)}" sandbox="allow-scripts" title="${esc('The prototype, version ' + (v.round || 1))}"></iframe>`; }
|
|
280
360
|
}
|
|
361
|
+
if (!V.play) { const op = root.querySelector('.pc-play'); if (op) op.remove(); }
|
|
281
362
|
if (draftText && root.querySelector('#pcCm')) root.querySelector('#pcCm').value = draftText;
|
|
282
363
|
applyZoom(root);
|
|
283
364
|
if (V.mode === 'draw') ink(root);
|
|
@@ -307,18 +388,24 @@ if (typeof window !== 'undefined') window.addEventListener('message', (e) => {
|
|
|
307
388
|
V.ready = m;
|
|
308
389
|
if (Object.keys(V.edits.copy).length) toFrame({ t: 'copyAll', copy: V.edits.copy });
|
|
309
390
|
if (Object.keys(V.edits.vars).length) toFrame({ t: 'vars', vars: V.edits.vars });
|
|
391
|
+
if (Object.keys(V.edits.styles).length) toFrame({ t: 'styles', styles: V.edits.styles });
|
|
310
392
|
toFrame({ t: 'mode', mode: V.mode === 'draw' ? 'view' : V.mode });
|
|
311
393
|
if (V.screen) toFrame({ t: 'screen', id: V.screen });
|
|
312
394
|
if (V.sel) toFrame({ t: 'sel', el: V.sel.el });
|
|
313
395
|
pins();
|
|
396
|
+
V.sig = ''; draw(V.body, V.c);
|
|
314
397
|
} else if (m.t === 'screen') {
|
|
315
398
|
V.screen = String(m.id || '');
|
|
316
|
-
V.
|
|
399
|
+
V.sig = ''; draw(V.body, V.c);
|
|
317
400
|
} else if (m.t === 'point') {
|
|
318
|
-
//
|
|
319
|
-
V.sel = { el: String(m.el || ''), label: String(m.label || '').slice(0, 80) };
|
|
320
|
-
|
|
401
|
+
// Select (canvas FpA): the layer shows in the inspector with its exact values, and goes in the chat box as the subject of the next words
|
|
402
|
+
V.sel = { el: String(m.el || ''), label: String(m.label || '').slice(0, 80), copy: String(m.copy || '') };
|
|
403
|
+
V.looks = m.looks && typeof m.looks === 'object' ? m.looks : null;
|
|
404
|
+
if (m.screen) V.screen = String(m.screen);
|
|
405
|
+
fire('pmos:point', { ini: V.c && V.c.ini, el: V.sel.el, label: V.sel.label });
|
|
321
406
|
V.sig = ''; draw(V.body, V.c);
|
|
407
|
+
} else if (m.t === 'looks') {
|
|
408
|
+
if (V.sel && m.el === V.sel.el && m.looks && typeof m.looks === 'object') { V.looks = m.looks; V.sig = ''; draw(V.body, V.c); }
|
|
322
409
|
} else if (m.t === 'pin') {
|
|
323
410
|
V.draft = { el: String(m.el || ''), label: String(m.label || '').slice(0, 80), x: m.x, y: m.y };
|
|
324
411
|
V.sig = ''; draw(V.body, V.c);
|
|
@@ -331,12 +418,20 @@ function wire(root) {
|
|
|
331
418
|
const b = e.target.closest('button, [data-pc-screen], [data-pc-scen]'); if (!b || !root.contains(b)) return;
|
|
332
419
|
const d = b.dataset;
|
|
333
420
|
if (d.pcMode) { setMode(V.mode === d.pcMode ? 'view' : d.pcMode); return; }
|
|
334
|
-
if (
|
|
335
|
-
if (d
|
|
421
|
+
if (d.pcSide) { V.side = V.side === d.pcSide ? null : d.pcSide; V.sig = ''; draw(V.body, V.c); return; }
|
|
422
|
+
if ('pcLeft' in d) { panel('left'); return; }
|
|
423
|
+
if ('pcInsp' in d) { panel('insp'); return; }
|
|
424
|
+
if (d.pcPage) { const L = layersOf(V.ready, V.screen), first = ((V.ready && V.ready.screens) || []).find((x) => x.page === d.pcPage); if (first && first.id !== L.screen) { V.screen = first.id; toFrame({ t: 'screen', id: first.id }); } return; }
|
|
425
|
+
if (d.pcLayer) { pick(d.pcLayer); return; }
|
|
426
|
+
if (d.pcUnstyle) { unstyle(d.pcUnstyle); return; }
|
|
427
|
+
if (d.pcPdev) { V.pdev = d.pcPdev; store.set('pmos.pc.pdev', V.pdev); startPlay(V.play.id, V.play.i); return; }
|
|
428
|
+
if ('pcPflow' in d) { V.play.flow = !V.play.flow; startPlay(V.play.id, V.play.i); return; }
|
|
429
|
+
if (d.pcPstep != null) { startPlay(V.play.id, Number(d.pcPstep)); return; }
|
|
430
|
+
if (d.pcPnav) { playStep(Number(d.pcPnav)); return; }
|
|
336
431
|
if (d.pcZoom != null) { const k = Number(d.pcZoom); V.zoom = k === 0 ? 0 : Math.max(0.4, Math.min(1.6, Math.round(((V.zoom || currentZoom()) + k * 0.1) * 10) / 10)); store.set('pmos.pc.zoom', V.zoom ? String(V.zoom) : null); applyZoom(root); return; }
|
|
337
432
|
if ('pcPlay' in d) { const sc = ((V.v.data || {}).flow || {}).scenarios || []; startPlay(sc.length ? sc[0].id : '', 0, true); return; }
|
|
338
433
|
if (d.pcFrom) { fire('pmos:from', { ini: V.c.ini, n: Number(d.pcFrom) }); say('The next change you send continues from version ' + d.pcFrom + '.'); return; }
|
|
339
|
-
if (d.pcScreen) { V.screen = d.pcScreen; toFrame({ t: 'screen', id: d.pcScreen }); return; }
|
|
434
|
+
if (d.pcScreen) { V.screen = d.pcScreen; toFrame({ t: 'screen', id: d.pcScreen }); V.sig = ''; draw(V.body, V.c); return; }
|
|
340
435
|
if (d.pcScen) { startPlay(d.pcScen, 0, true); return; }
|
|
341
436
|
if ('pcStop' in d) { pmPost('/api/lab/stop', { ws: (V.at || {}).ws, run: d.pcStop }).then((r) => { if (!r || !r.ok) say((r && r.error) || 'It did not stop.'); }).catch(() => say('It did not stop.')); return; }
|
|
342
437
|
if ('pcUnsel' in d) { V.sel = null; toFrame({ t: 'sel', el: '' }); fire('pmos:point', { ini: V.c.ini, el: '', label: '' }); V.sig = ''; draw(V.body, V.c); return; }
|
|
@@ -346,12 +441,15 @@ function wire(root) {
|
|
|
346
441
|
if (d.pcInk) { if (d.pcInk === 'clear') clearInk(); else attachInk(); return; }
|
|
347
442
|
if (d.pcTray) { tray(d.pcTray); return; }
|
|
348
443
|
if (d.pcPlayx) { if (d.pcPlayx === 'close') { V.play = null; const p = root.querySelector('.pc-play'); if (p) p.remove(); } else startPlay(V.play.id, 0); return; }
|
|
349
|
-
if (d.pcPlaysc) { startPlay(d.pcPlaysc, 0, true); }
|
|
350
444
|
});
|
|
445
|
+
// a number or a list takes effect when it is changed (an arrow press, Enter, leaving the field), not on every key
|
|
446
|
+
root.addEventListener('change', (e) => { const t = e.target; if (t.matches('[data-pc-style]') && (t.type === 'number' || t.tagName === 'SELECT')) style(t); else if (t.matches('[data-pc-playsel]')) startPlay(t.value, 0, false); });
|
|
351
447
|
root.addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('[data-pc-screen],[data-pc-scen]') && e.target.tagName !== 'BUTTON') { e.preventDefault(); e.target.dispatchEvent(new MouseEvent('click', { bubbles: true })); } });
|
|
352
448
|
root.addEventListener('input', (e) => {
|
|
353
449
|
const t = e.target;
|
|
354
450
|
if (t.matches('[data-pc-copy]')) { const k = t.dataset.pcCopy, text = t.textContent; V.edits.copy[k] = text; toFrame({ t: 'copy', key: k, text }); save({ copy: { [k]: text } }); }
|
|
451
|
+
else if (t.matches('[data-pc-copy-in]')) { const k = t.dataset.pcCopyIn, text = t.value; V.edits.copy[k] = text; toFrame({ t: 'copy', key: k, text }); save({ copy: { [k]: text } }); }
|
|
452
|
+
else if (t.matches('[data-pc-style]') && t.type !== 'number' && t.tagName !== 'SELECT') style(t);
|
|
355
453
|
else if (t.matches('[data-pc-var]')) { const val = t.value + (t.dataset.pcUnit || ''); V.edits.vars[t.dataset.pcVar] = val; toFrame({ t: 'vars', vars: { [t.dataset.pcVar]: val } }); const em = t.parentElement.querySelector('em'); if (em) em.textContent = val; save({ vars: { [t.dataset.pcVar]: val } }); }
|
|
356
454
|
});
|
|
357
455
|
}
|
|
@@ -361,9 +459,49 @@ function setMode(m) {
|
|
|
361
459
|
toFrame({ t: 'mode', mode: m === 'draw' ? 'view' : m });
|
|
362
460
|
V.sig = ''; draw(V.body, V.c);
|
|
363
461
|
}
|
|
364
|
-
|
|
462
|
+
function panel(k) {
|
|
463
|
+
if (k === 'insp' && V.side) { V.side = null; V.insp = true; } else V[k] = !V[k];
|
|
464
|
+
store.set(k === 'left' ? 'pmos.pc.left' : 'pmos.pc.insp', V[k] ? null : '0');
|
|
465
|
+
V.sig = ''; draw(V.body, V.c);
|
|
466
|
+
}
|
|
467
|
+
/** A layer picked in Layers: selected on the prototype, its looks read back, and in the chat box as the subject. */
|
|
468
|
+
function pick(el) {
|
|
469
|
+
const e = ((V.ready && V.ready.els) || []).find((x) => x.el === el); if (!e) return;
|
|
470
|
+
V.sel = { el, label: String(e.label || '').slice(0, 80), copy: String(e.copy || '') }; V.looks = null;
|
|
471
|
+
toFrame({ t: 'sel', el }); toFrame({ t: 'styles', styles: V.edits.styles });
|
|
472
|
+
fire('pmos:point', { ini: V.c && V.c.ini, el, label: V.sel.label });
|
|
473
|
+
V.sig = ''; draw(V.body, V.c);
|
|
474
|
+
}
|
|
475
|
+
/** One inspector field changed: the prototype changes at once, the value is kept with the version, and the chat hears it once. */
|
|
476
|
+
function style(t) {
|
|
477
|
+
if (!V.sel) return;
|
|
478
|
+
const el = V.sel.el, k = t.dataset.pcStyle, unit = t.dataset.pcUnit || '';
|
|
479
|
+
let val = t.type === 'number' ? (Number.isFinite(parseFloat(t.value)) ? String(Math.round(parseFloat(t.value) * 100) / 100) + unit : '') : t.value;
|
|
480
|
+
if (k === 'padding') {
|
|
481
|
+
const two = [...V.body.querySelectorAll('[data-pc-style="padding"]')].map((x) => Math.max(0, Math.round(parseFloat(x.value) || 0)) + 'px');
|
|
482
|
+
val = two.join(' ');
|
|
483
|
+
}
|
|
484
|
+
if (k === 'size' || k === 'corner') val = Math.max(0, Math.round(parseFloat(val) || 0)) + 'px';
|
|
485
|
+
if (!val) return;
|
|
486
|
+
V.edits.styles[el] = { ...(V.edits.styles[el] || {}), [k]: val };
|
|
487
|
+
toFrame({ t: 'styles', styles: V.edits.styles });
|
|
488
|
+
save({ styles: { [el]: { [k]: val } } });
|
|
489
|
+
clearTimeout(V.noteT);
|
|
490
|
+
const label = V.sel.label || el;
|
|
491
|
+
V.noteT = setTimeout(() => fire('pmos:note', { ini: V.c && V.c.ini, text: `You set ${label} to ${styleWords(V.edits.styles[el])}. Kept as yours.` }), 1500);
|
|
492
|
+
const f = V.body.querySelector('.pc-ifoot'); if (f && !f.querySelector('[data-pc-unstyle]')) { V.sig = ''; setTimeout(() => draw(V.body, V.c), 0); }
|
|
493
|
+
}
|
|
494
|
+
function unstyle(el) {
|
|
495
|
+
delete V.edits.styles[el];
|
|
496
|
+
toFrame({ t: 'styles', styles: V.edits.styles });
|
|
497
|
+
save({ styles: { [el]: null } });
|
|
498
|
+
V.sig = ''; draw(V.body, V.c);
|
|
499
|
+
}
|
|
500
|
+
// the PM's copy edits, tweaks and inspector styles are kept with the version (edits.json), so the next version reads them
|
|
365
501
|
function save(part) {
|
|
366
|
-
|
|
502
|
+
const st = { ...((V.pend && V.pend.styles) || {}) };
|
|
503
|
+
for (const [el, ps] of Object.entries(part.styles || {})) st[el] = ps === null ? null : { ...(st[el] || {}), ...ps };
|
|
504
|
+
V.pend = { copy: { ...((V.pend && V.pend.copy) || {}), ...(part.copy || {}) }, vars: { ...((V.pend && V.pend.vars) || {}), ...(part.vars || {}) }, styles: st };
|
|
367
505
|
clearTimeout(V.saveT);
|
|
368
506
|
const file = V.v && V.v.file;
|
|
369
507
|
V.saveT = setTimeout(async () => {
|
|
@@ -429,22 +567,49 @@ async function attachInk() {
|
|
|
429
567
|
clearInk(); setMode('view');
|
|
430
568
|
}
|
|
431
569
|
|
|
432
|
-
/* ── Play (canvas
|
|
570
|
+
/* ── Play (canvas FpC): the prototype bare, the device switch, the flow beside it as steps you can tap, ← → ── */
|
|
433
571
|
function playHtml(v) {
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
+ `<
|
|
572
|
+
const f = (v.data || {}).flow || {}, sc = f.scenarios || [], p = V.play, s = sc.find((x) => x.id === p.id) || null;
|
|
573
|
+
const n = s ? s.steps.length : 0, i = Math.min(p.i, Math.max(0, n - 1)), step = s ? s.steps[i] : null;
|
|
574
|
+
const title = (id) => { const x = (f.screens || []).find((y) => y.id === id); return x ? x.title : human(id); };
|
|
575
|
+
const dev = (d, label, icon) => `<button type="button" class="pc-ib" data-pc-pdev="${d}" aria-pressed="${V.pdev === d}" aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
|
|
576
|
+
const flow = p.flow === false ? '' : `<aside class="pc-pflow" aria-label="The flow"><div class="pc-lh"><span>The flow</span></div>`
|
|
577
|
+
+ (sc.length ? `<label class="pc-psel"><span class="pc-vh">Path</span><select data-pc-playsel aria-label="Pick a path">${sc.map((x) => `<option value="${esc(x.id)}"${x.id === p.id ? ' selected' : ''}>${esc(x.name)}</option>`).join('')}</select></label>`
|
|
578
|
+
+ `<span class="pc-bar2" aria-hidden="true"><i style="width:${n ? Math.round(((i + 1) / n) * 100) : 0}%"></i></span>`
|
|
579
|
+
+ `<ol class="pc-psteps">${(s ? s.steps : []).map((x, k) => `<li><button type="button" class="pc-pst${k < i ? ' done' : ''}${k === i ? ' on' : ''}" data-pc-pstep="${k}"${k === i ? ' aria-current="step"' : ''}><span class="pc-pn">${k < i ? SVG(I.check, 12, 3) : k + 1}</span><span>${esc(title(x.screen))}</span></button></li>`).join('')}</ol>`
|
|
580
|
+
: '<p class="pc-hint">This version has no flow yet. Ask for one in the chat.</p>') + '</aside>';
|
|
581
|
+
return `<div class="pc-play" role="dialog" aria-label="Play the prototype"><div class="pc-pbar"><b>Playing · Version ${esc(v.round || 1)}</b><small>${step ? esc(title(step.screen)) : ''}</small><span class="pc-sp"></span>`
|
|
582
|
+
+ `<span class="pc-grp" aria-label="Play on">${dev('phone', 'Play on a phone', I.phone)}${dev('desktop', 'Play on a desktop', I.desk)}${dev('own', 'Play at its own size', I.own)}</span>`
|
|
583
|
+
+ `${ib(`data-pc-pflow aria-pressed="${p.flow !== false}"`, (p.flow === false ? 'Show' : 'Hide') + ' the flow', I.right)}${ib('data-pc-playx="close"', 'Stop playing (Esc)', I.x)}</div>`
|
|
584
|
+
+ `<div class="pc-pmain"><div class="pc-pstage"><div class="pc-pframe ${V.pdev}">${v.url ? `<iframe src="${esc(frameUrl(v))}" sandbox="allow-scripts" title="Play the prototype"></iframe>` : ''}</div>`
|
|
585
|
+
+ `<div class="pc-pctl">${ib('data-pc-pnav="-1"' + (i > 0 ? '' : ' disabled'), 'Previous step (←)', I.prev)}<span>${s ? `Step ${i + 1} of ${n}` : 'No steps'}</span>${ib('data-pc-pnav="1"' + (s && i < n - 1 ? '' : ' disabled'), 'Next step (→)', I.next, 'blue')}${ib('data-pc-playx="restart"', 'Restart', I.restart)}</div>`
|
|
586
|
+
+ `<p class="pc-hint">${step && step.say ? esc(step.say) + ' ' : ''}← → to move. On a screen with taps, a tap that misses shows where to tap.</p></div>${flow}</div></div>`;
|
|
440
587
|
}
|
|
441
588
|
function startPlay(id, i = 0, fresh = false) {
|
|
442
589
|
const root = V.body && V.body.querySelector('.pc'); if (!root) return;
|
|
443
|
-
const
|
|
444
|
-
V.play = { id, i };
|
|
445
|
-
const old = root.querySelector('.pc-play');
|
|
590
|
+
const keepF = !fresh && V.play ? root.querySelector('.pc-pframe iframe') : null;
|
|
591
|
+
V.play = { id, i: Math.max(0, i), flow: V.play ? V.play.flow : true };
|
|
592
|
+
const old = root.querySelector('.pc-play');
|
|
593
|
+
if (old && keepF) {
|
|
594
|
+
// the frame stays where it is (moving an iframe reloads it): only the bar, the controls and the flow are drawn again
|
|
595
|
+
const tmp = document.createElement('div'); tmp.innerHTML = playHtml(V.v);
|
|
596
|
+
const nu = tmp.firstElementChild;
|
|
597
|
+
old.querySelector('.pc-pbar').replaceWith(nu.querySelector('.pc-pbar'));
|
|
598
|
+
old.querySelector('.pc-pctl').replaceWith(nu.querySelector('.pc-pctl'));
|
|
599
|
+
old.querySelector('.pc-pstage > .pc-hint').replaceWith(nu.querySelector('.pc-pstage > .pc-hint'));
|
|
600
|
+
const of = old.querySelector('.pc-pflow'), nf = nu.querySelector('.pc-pflow');
|
|
601
|
+
if (of && nf) of.replaceWith(nf); else if (of) of.remove(); else if (nf) old.querySelector('.pc-pmain').appendChild(nf);
|
|
602
|
+
old.querySelector('.pc-pframe').className = 'pc-pframe ' + V.pdev;
|
|
603
|
+
playGo(keepF);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (old) old.remove();
|
|
446
607
|
root.insertAdjacentHTML('beforeend', playHtml(V.v));
|
|
447
|
-
|
|
608
|
+
}
|
|
609
|
+
function playStep(d) {
|
|
610
|
+
if (!V.play) return;
|
|
611
|
+
const s = (((V.v.data || {}).flow || {}).scenarios || []).find((x) => x.id === V.play.id); if (!s) return;
|
|
612
|
+
const i = Math.max(0, Math.min(s.steps.length - 1, V.play.i + d)); if (i !== V.play.i) startPlay(V.play.id, i);
|
|
448
613
|
}
|
|
449
614
|
function playGo(fr) {
|
|
450
615
|
const sc = ((V.v.data || {}).flow || {}).scenarios || [], s = sc.find((x) => x.id === (V.play || {}).id);
|
|
@@ -480,7 +645,10 @@ if (typeof window !== 'undefined') {
|
|
|
480
645
|
if (!V.body || !V.body.isConnected || !V.body.querySelector('.pc') || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
481
646
|
const t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
|
|
482
647
|
const k = e.key.toLowerCase();
|
|
483
|
-
if (k === '
|
|
648
|
+
if (V.play && (k === 'arrowleft' || k === 'arrowright')) { e.preventDefault(); playStep(k === 'arrowright' ? 1 : -1); return; }
|
|
649
|
+
if (k === '[' && !V.play) { panel('left'); return; }
|
|
650
|
+
if (k === ']' && !V.play) { panel('insp'); return; }
|
|
651
|
+
if (k === 'v' || k === 's') setMode(V.mode === 'point' ? 'view' : 'point');
|
|
484
652
|
else if (k === 'c') setMode(V.mode === 'comment' ? 'view' : 'comment');
|
|
485
653
|
else if (k === 'd') setMode(V.mode === 'draw' ? 'view' : 'draw');
|
|
486
654
|
else if (k === 'escape' && (V.mode !== 'view' || V.play)) { if (V.play) { V.play = null; const p = V.body.querySelector('.pc-play'); if (p) p.remove(); } else setMode('view'); }
|
|
@@ -282,6 +282,7 @@ export function mountChat(el, host) {
|
|
|
282
282
|
placeDivider(parts, items, goal);
|
|
283
283
|
let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + pendHtml() + queuedHtml();
|
|
284
284
|
html += GU.choiceHtml(); // /goal while a goal works here: In a new chat, or Here instead
|
|
285
|
+
for (const n of C.notes || []) if (t.ini && n.ini === t.ini) html += `<p class="hm-note hm-you">${esc(n.text)}</p>`;
|
|
285
286
|
if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
|
|
286
287
|
if (C.conv && C.conv.state === 'ended') html += '<p class="hm-note">This session has ended. Your conversation is kept here, and your next message picks it up.</p>';
|
|
287
288
|
// an empty chat: Adler resting, because nothing runs here yet (canvas AdH1)
|
|
@@ -728,6 +729,9 @@ export function mountChat(el, host) {
|
|
|
728
729
|
window.addEventListener('pmos:point', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), point: e.detail.el || e.detail.label ? { el: e.detail.el || '', label: e.detail.label || '' } : null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta && C.mark.point) ta.focus(); });
|
|
729
730
|
window.addEventListener('pmos:from', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), from: Number(e.detail.n) || null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta) ta.focus(); });
|
|
730
731
|
window.addEventListener('pmos:say', (e) => { if (!mine(e) || !e.detail.text) return; send(String(e.detail.text)); });
|
|
732
|
+
// a hand edit in the canvas's inspector (pm/cozy-proto.js 'pmos:note'): one quiet line in the conversation, so it shows on both sides.
|
|
733
|
+
// It lives on this page only; the next version reads the edit itself from edits.json.
|
|
734
|
+
window.addEventListener('pmos:note', (e) => { if (!mine(e) || !e.detail.text) return; C.notes = [...(C.notes || []).filter((n) => n.ini === C.t.ini), { ini: C.t.ini, text: String(e.detail.text).slice(0, 200) }].slice(-4); draw(); });
|
|
731
735
|
/* An older message's Copy, Retry and Make a work-item on a phone (batch 31 item 5): press and hold the message to show them (the CSS
|
|
732
736
|
* shows them on the newest message, and on focus for a keyboard). A tap elsewhere hides them again. */
|
|
733
737
|
let holdT = null;
|
|
@@ -69,6 +69,10 @@ export const setKanbanStage = (id, key) => { if (id && key != null) STAGE.set(id
|
|
|
69
69
|
/* ── days, as whole numbers (UTC, so a summer-time night never moves a bar) ── */
|
|
70
70
|
const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
71
71
|
export const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
72
|
+
// today is the PM's own day: the view's day (the model's), else the day on this device's clock. Never a rounded UTC day: that is tomorrow
|
|
73
|
+
// after 12:00 UTC and yesterday before 08:00 in Singapore (batch 31 item 7)
|
|
74
|
+
export const localDay = (now = Date.now()) => { const d = new Date(now); return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / 864e5); };
|
|
75
|
+
export const todayOf = (v, now) => { const n = dn(v && v.today); return n != null ? n : localDay(now); };
|
|
72
76
|
export const isoN = (n) => new Date(n * 864e5).toISOString().slice(0, 10);
|
|
73
77
|
export const md = (n) => { const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
|
|
74
78
|
/** "Nov 4 → 13", "Nov 28 → Dec 3", "Nov 4": the tip while a bar drags, in the List's words. */
|
|
@@ -265,7 +269,7 @@ export function timelineCols() {
|
|
|
265
269
|
export function setTimelineCols(keys) { TC = TCOLS.map((c) => c[0]).filter((k) => keys.includes(k)); store.set('pmos.tasks.cols.timeline', JSON.stringify(TC)); }
|
|
266
270
|
export function timelineHtml(v, o, isOpen) {
|
|
267
271
|
if (zoomOf() === 'all') return allHtml(v, o, isOpen);
|
|
268
|
-
const today =
|
|
272
|
+
const today = todayOf(v), z = ZOOMS.find((x) => x[0] === zoomOf());
|
|
269
273
|
const S = v.tasks.sections;
|
|
270
274
|
// the tasks with no dates share one row at the foot, "N without dates · Set" (XvpA3bMonths), in place of a dashed press on each row
|
|
271
275
|
const undated = (x) => !x.closed && dn(x.start) == null && dn(x.end) == null;
|
|
@@ -442,7 +446,7 @@ const short = (n) => "\u2019" + String(new Date(n * 864e5).getUTCFullYear()).sli
|
|
|
442
446
|
/** "Oct 9 – Nov 27", "Dec 14 – 18", "Mar 1": a stage's days in the name column. */
|
|
443
447
|
const rng = (a, b) => { if (a === b) return md(a); const x = new Date(a * 864e5), y = new Date(b * 864e5); return md(a) + ' \u2013 ' + (x.getUTCMonth() === y.getUTCMonth() && x.getUTCFullYear() === y.getUTCFullYear() ? y.getUTCDate() : md(b)); };
|
|
444
448
|
export function allHtml(v, o, isOpen) {
|
|
445
|
-
const S = v.tasks.sections, today =
|
|
449
|
+
const S = v.tasks.sections, today = todayOf(v);
|
|
446
450
|
const rowsOf = (sec) => flat(sec).concat(flatDone(sec));
|
|
447
451
|
const spanOf = (sec) => {
|
|
448
452
|
const ds = rowsOf(sec).filter((x) => !x.wont).flatMap((x) => [dn(x.start), dn(x.end)]).concat(jiraOf(sec).flatMap((k) => [dn(k.start), dn(k.due)])).filter((n) => n != null);
|
|
@@ -182,6 +182,18 @@ export function bodyOf(rows, archived = []) {
|
|
|
182
182
|
}
|
|
183
183
|
const countOf = (open, late, done) => (late && late === open ? late + ' late' : late ? late + ' late · ' + open + ' open' : open ? open + ' open' : done ? done + ' done' : '');
|
|
184
184
|
|
|
185
|
+
/** When finished work really finished, and how late that was against its plan (batch 31, Wawan 2026-11-18: a Closed initiative read "145 days
|
|
186
|
+
* over" because the count ran to today). The finish is the latest end of its Done tasks, else the day it moved into its current (last) stage,
|
|
187
|
+
* else null. r: the row (end: the planned finish); rows: its task rows (rowOf); ran: the dates each stage ran; cur: the current stage's index.
|
|
188
|
+
* → { at: 'YYYY-MM-DD' | '', slip: whole days after the planned finish, 0 when on time or unknown }. Pure; it never reads today. */
|
|
189
|
+
export function finishOf(r, rows = [], ran = [], cur = -1) {
|
|
190
|
+
const ends = (rows || []).filter((x) => x && x.done && dayOf(x.end)).map((x) => String(x.end).slice(0, 10)).sort();
|
|
191
|
+
const moved = cur >= 0 && ran[cur] && dayOf(ran[cur].from) ? String(ran[cur].from).slice(0, 10) : '';
|
|
192
|
+
const at = ends.length ? ends[ends.length - 1] : moved;
|
|
193
|
+
const end = dayOf(r && r.end), d = dayOf(at);
|
|
194
|
+
return { at, slip: end && d && d > end ? between(end, d) : 0 };
|
|
195
|
+
}
|
|
196
|
+
|
|
185
197
|
/* ── the view ── */
|
|
186
198
|
export function iniView(r, ctx = {}) {
|
|
187
199
|
const today = todayOf(ctx), t = r.track || {}, tr = r.trail || {};
|
|
@@ -224,12 +236,16 @@ export function iniView(r, ctx = {}) {
|
|
|
224
236
|
: curRows.length ? curRows.filter((x) => x.closed).length + ' of ' + curRows.length + ' done' : '';
|
|
225
237
|
// days in the stage: the trail's (when it entered the stage) first, then the track's
|
|
226
238
|
const days = tr.days != null ? tr.days : tr.since && dayOf(tr.since) ? Math.max(0, between(dayOf(tr.since), today)) : t.days != null ? t.days : null, usual = ctx.usual && ctx.usual.days != null ? ctx.usual.days : null;
|
|
227
|
-
const end = dayOf(r.end), fc = dayOf(t.forecast), finished = r.status === 'done' || r.status === 'cancelled';
|
|
239
|
+
const end = dayOf(r.end), fc = dayOf(t.forecast), finished = r.status === 'done' || r.status === 'cancelled' || !!r.closed;
|
|
240
|
+
// batch 31: finished work is measured against when it finished, never today (finishOf): on time says nothing, late is a fixed slip
|
|
241
|
+
const fin = finished && r.status !== 'cancelled' ? finishOf(r, rows, ran, cur) : null;
|
|
228
242
|
const dates = (r.start || r.end) ? {
|
|
229
243
|
start: r.start ? dateY(r.start, today) : '',
|
|
230
244
|
end: r.end ? dateY(r.end, today) : '',
|
|
231
|
-
left: end && !finished ? (end < today ? plural(between(end, today), 'day', 'days') + ' over' : end > today ? plural(between(today, end), 'day', 'days') + ' left' : 'ends today')
|
|
232
|
-
|
|
245
|
+
left: end && !finished ? (end < today ? plural(between(end, today), 'day', 'days') + ' over' : end > today ? plural(between(today, end), 'day', 'days') + ' left' : 'ends today')
|
|
246
|
+
: fin && fin.slip > 0 ? 'Finished ' + plural(fin.slip, 'day', 'days') + ' late' : '',
|
|
247
|
+
over: !!(end && end < today && !finished) || !!(fin && fin.slip > 0),
|
|
248
|
+
...(fin && fin.at ? { doneAt: fin.at } : {}),
|
|
233
249
|
jira: fc && (!end || fc > end) && !finished ? dateY(t.forecast, today) : '',
|
|
234
250
|
// the numbers behind "N days left" (the mission's readouts): the plan's length, the days gone (negative before the start), the days left (negative once over); none once finished or with one date
|
|
235
251
|
n: r.start && end && !finished ? { total: between(dayOf(r.start), end), gone: between(dayOf(r.start), today), left: between(today, end) } : null,
|
|
@@ -238,7 +254,7 @@ export function iniView(r, ctx = {}) {
|
|
|
238
254
|
// Won't do and Archived hold their stage (D99 wfRules): no next stage to move to
|
|
239
255
|
if (cur >= 0 && !r.ended && r.status !== 'done' && r.status !== 'cancelled') { const n = list.slice(cur + 1).find((s) => s.status !== 'skip'); if (n) nx = { key: n.key, name: n.name, ms: n.ms, moves: n.ms && r.kr ? r.kr : '' }; }
|
|
240
256
|
// the stage card is one line (batch 11 item 21, agreed A): each stage on its own dates, the milestone tasks as ◇, the Board's states
|
|
241
|
-
const line = lineOf(r, { list, cur, ran, rows, today, deps: tr.deps || [] });
|
|
257
|
+
const line = lineOf(r, { list, cur, ran, rows, today, deps: tr.deps || [], doneAt: fin && fin.at ? fin.at : '' });
|
|
242
258
|
const ready = !!nx && curRows.length > 0 && curRows.every((x) => x.closed); // every task of the stage done: the → turns blue (state 1)
|
|
243
259
|
// the way to finish the stage (R5): the stage's count, and its milestone tasks, the open ones by date, the done ones counted
|
|
244
260
|
const msRows = curRows.filter((x) => x.ms && !x.wont);
|