create-pmos 0.601.0 → 0.602.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 +14 -14
- 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 +13 -0
- package/workspace/guide/agent-capabilities.md +7 -7
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.602.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": {
|
|
@@ -33,6 +33,19 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.602.0",
|
|
38
|
+
"at": "2026-11-18T08:21:52.461Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1344,
|
|
43
|
+
"t": "Prototype like Figma: pages, screens, layers, an inspector, and Play with the flow beside it",
|
|
44
|
+
"s": "Prototype like Figma: pages, screens, layers, an inspector, and Play with the flow beside it",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
36
49
|
{
|
|
37
50
|
"v": "0.601.0",
|
|
38
51
|
"at": "2026-11-18T07:30:23.248Z",
|
|
@@ -303,19 +316,6 @@
|
|
|
303
316
|
"k": "fix"
|
|
304
317
|
}
|
|
305
318
|
]
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
"v": "0.582.0",
|
|
309
|
-
"at": "2026-11-17T02:50:44.770Z",
|
|
310
|
-
"f": 4,
|
|
311
|
-
"prs": [
|
|
312
|
-
{
|
|
313
|
-
"n": 1313,
|
|
314
|
-
"t": "The meeting companion offers a live round (live round W2)",
|
|
315
|
-
"s": "The meeting companion offers a live round (live round W2)",
|
|
316
|
-
"k": "new"
|
|
317
|
-
}
|
|
318
|
-
]
|
|
319
319
|
}
|
|
320
320
|
]
|
|
321
321
|
}
|
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-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T08:21:48Z"}
|
|
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-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T08:21:48Z"}
|
|
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-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T08:21:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.602.0",
|
|
4
|
+
"at": "2026-11-18T08:21:52.461Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1344,
|
|
9
|
+
"t": "Prototype like Figma: pages, screens, layers, an inspector, and Play with the flow beside it",
|
|
10
|
+
"s": "Prototype like Figma: pages, screens, layers, an inspector, and Play with the flow beside it",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.601.0",
|
|
4
17
|
"at": "2026-11-18T07:30:23.248Z",
|
|
@@ -195,16 +195,16 @@ Not proven yet: the compare view's Production and Design columns stay left out u
|
|
|
195
195
|
You can ask to see an idea at any moment: alone while you work on an initiative, or with stakeholders in the room. It works like design work with Claude Code: you say what you want, PMOS makes or changes the one prototype, the Viewer shows it, and the chat says what changed.
|
|
196
196
|
|
|
197
197
|
1. **Ask in the initiative's chat.** Say, for example, "prototype this" or "mock this up". PMOS starts one prototype at once. Nothing to press. It opens in the Viewer beside the chat as soon as it opens and renders in a headless browser, in about a minute. The chat answers with a **Version 1** tag and says what was made and for whom. Tap a Version tag to show that version again.
|
|
198
|
-
2. **The Viewer is one canvas.**
|
|
199
|
-
- **
|
|
200
|
-
- **
|
|
201
|
-
- **Page copy
|
|
202
|
-
-
|
|
198
|
+
2. **The Viewer is one canvas, like a design tool.** The prototype is in the middle, at its own size. Three panels sit around it:
|
|
199
|
+
- **Pages, screens and layers** (left). A page is one format or page of the prototype, for example "One Raffles Place LED". A page has screens: its states, for example "Default" and "Sponsor sold". Layers lists the blocks of the screen shown. Tap a screen to show it, or tap a layer to select it. Press [ to hide or show this panel.
|
|
200
|
+
- **Exact values** (right): the inspector for the selected layer. Set its text, font, size, weight, line height, letter spacing, colour, fill, corner, padding and alignment. The prototype changes at once. PMOS keeps the change with the version, and the next version keeps it. The chat shows one quiet line, for example "You set Temperature to 56px · Bold. Kept as yours." The undo press in the panel clears that layer's changes. Press ] to hide or show the inspector.
|
|
201
|
+
- **Page copy, The flow and Who does what**: one press each in the toolbar, closed by default. One opens at a time, in the inspector's place. Page copy lists every word on the screen: edit a line in place. The flow shows screens as cards, decisions as diamonds and branches to the other scenarios: tap a screen to see it, or a side branch to play that scenario. Who does what is a swimlane with arrows between the steps. A press with a dot, or a panel that says **Updated**, is what the last version changed.
|
|
202
|
+
- Zoom out, zoom in and fit are in the toolbar. The design opens on the latest version: the toolbar says **Latest · version n**.
|
|
203
203
|
3. **Change it in one sentence.** For example, "make the alert orange". PMOS makes the next version of the prototype and its flow, swimlane and copy, and the chat says what changed, then "Also updated: step 3, the swimlane and the copy". ‹ › in the toolbar walks the versions. On an older version, **Back to latest** returns, and **Continue from version n** makes your next change start from that version.
|
|
204
|
-
4. **
|
|
204
|
+
4. **Select, then say.** Select (V) is on when the Viewer opens. Tap a block in the prototype, or a layer in the list. It is selected in both places, its exact values show in the inspector, and it goes into the chat box as a chip, for example "Temperature". Your next sentence changes that block. Sliders that the version offers for it (spacing, corner radius, colour) show under the prototype.
|
|
205
205
|
5. **Comment.** Press Comment (C) and tap an element. Write the comment, then send it to PMOS as the next change, or keep it for the team. A kept comment stays pinned, with **Make this change** beside it.
|
|
206
206
|
6. **Draw or attach an image.** Press Draw (D), sketch over the prototype, then attach the sketch. It goes with your next message. An image you attach does the same. PMOS builds from it (its layout, hierarchy and colours) unless your words say otherwise, for example "only the colours".
|
|
207
|
-
7. **Play.** Press Play to run the prototype
|
|
207
|
+
7. **Play.** Press Play to run the prototype through a path of the flow. It shows only the prototype, with no design notes. Pick where it plays: on a phone, on a desktop, or at its own size. The flow sits beside it: pick a path, and tap a step to go there. ← and → move a step, and so do the arrows under the prototype. On a screen with taps, tap where the user would tap; a tap that misses shows where to tap. Restart is under the prototype. Stop (Esc) goes back to the design.
|
|
208
208
|
8. **Several versions only when you ask.** Say "show me 3 ways" (or "two options"). PMOS picks that many directions and shows them in a tray. Tap one to preview it, then keep it (✓) or close the tray (✕).
|
|
209
209
|
9. **The initiative's prototype.** The newest version made from the chat is the initiative's prototype. It is the one entry under **Prototype & design** on the initiative page (above Documents), and the **Prototype** line on its Experiment card. Both open it in the Viewer. Older rounds stay in the Viewer's history, not on the page. Your edits in the Viewer are part of that version. Earlier versions stay in ‹ ›. PMOS never keeps a round by itself. A round of several ways, or one started from a terminal (a test), becomes the prototype only when you keep it with ✓ in the Viewer; the grill then runs once on it. ✕ drops a round, and you can say why.
|
|
210
210
|
10. **The chat knows the prototype.** Every message in the initiative's chat tells PMOS which version is current, where its files are, and the one command that makes the next version. So "Improve the prototype based on the PRD" or "Rebuild A from this list" makes the next version in the Viewer. When no version is current yet, the chat gets the list of recent versions with the command to continue each one (`--of <round>`), and asks you which one if it is not clear. The chat never writes a loose HTML file.
|
|
@@ -242,11 +242,12 @@ function promptOf(o) {
|
|
|
242
242
|
} else if (o.alone) L.push('', 'This is the one version the PM sees: make the plainest honest version of the idea, not a showcase.');
|
|
243
243
|
else L.push('', `Your direction, ${o.key}: ${one(o.title, 200)}. Other runs take the other directions: keep yours clearly different.`);
|
|
244
244
|
if (o.point && (o.point.el || o.point.label)) L.push('', `The PM pointed at one element: ${o.point.el ? 'data-el="' + one(o.point.el, 60) + '"' : ''}${o.point.label ? ' ("' + one(o.point.label, 80) + '")' : ''}. Their words are about that element: change it, and only what must follow from it.`);
|
|
245
|
-
const ed = o.edits || {}, ec = Object.entries(ed.copy || {}), ev = Object.entries(ed.vars || {});
|
|
246
|
-
if (ec.length || ev.length) {
|
|
245
|
+
const ed = o.edits || {}, ec = Object.entries(ed.copy || {}), ev = Object.entries(ed.vars || {}), es = Object.entries(ed.styles || {});
|
|
246
|
+
if (ec.length || ev.length || es.length) {
|
|
247
247
|
L.push('', 'The PM edited the last version in place. Keep these exactly, unless their words change them:');
|
|
248
248
|
for (const [k, v] of ec.slice(0, 40)) L.push(`- the text of data-copy="${k}": ${one(v, 200)}`);
|
|
249
249
|
for (const [k, v] of ev.slice(0, 20)) L.push(`- the CSS variable ${k}: ${one(v, 40)} (set it in :root)`);
|
|
250
|
+
for (const [k, v] of es.slice(0, 30)) L.push(`- the style of data-el="${k}": ${Object.entries(v).map(([p, x]) => STYLE_OK[p][0] + ': ' + x).join('; ')} (write it in the page's CSS for that element)`);
|
|
250
251
|
}
|
|
251
252
|
// the design sprint's good practice, silent (Wawan 2026-11-17: "the design sprint runs in silent"): a target user, one question, real
|
|
252
253
|
// content, Goldilocks fidelity. Never a step the PM has to fill in.
|
|
@@ -257,8 +258,9 @@ function promptOf(o) {
|
|
|
257
258
|
' - One self-contained HTML page: inline CSS only, no script, no network, no image files. Real draft copy, never lorem ipsum or a placeholder.',
|
|
258
259
|
` - In <head>, one line for the PM: <meta name="pmos-changed" content="…"> with ONE short sentence of what ${o.base ? 'you changed' : 'you made and for whom'}, in plain words, under 140 characters.`,
|
|
259
260
|
' - Each screen is a <section data-screen="<id>" data-label="<screen name>">; the first one is where the user starts. PMOS shows one screen at a time.',
|
|
261
|
+
' - When several screens are states of one page or format (default, sponsor sold, rain alert), give each data-page="<that page\'s name>": the PM sees them as one page with its screens.',
|
|
260
262
|
' - What the user taps to move on carries data-go="<screen id>" (a button, a row, a link with href="#<screen id>").',
|
|
261
|
-
' - Every
|
|
263
|
+
' - Every visible block the PM may select and restyle (each heading, line of text, card, list, button, image, region) carries data-el="<short-id>" and data-label="<its name in plain words>".',
|
|
262
264
|
' - Every piece of visible text the PM may edit is in an element with data-copy="<key>" (unique keys, kebab-case, the text only inside it).',
|
|
263
265
|
' - Spacing, corner radius and colour warmth read CSS custom properties set in :root (for example --gap, --radius, --accent), so a slider can change them.',
|
|
264
266
|
' - Pin it to the viewport: the main card is max-width 390px and width 100%, nothing wider than the screen, no horizontal scroll at 390px. At desk width it sits centred.',
|
|
@@ -367,15 +369,35 @@ function partsAt(abs) {
|
|
|
367
369
|
const l = lanesOf(rd('lanes.json'), { screens: out.flow ? new Set(out.flow.screens.map((x) => x.id)) : null }); if (!l.error) out.lanes = l;
|
|
368
370
|
const t = tweaksOf(rd('tweaks.json')); if (!t.error && t.tweaks.length) out.tweaks = t;
|
|
369
371
|
const c = rd('copy.json'); if (isObj(c)) out.copy = c;
|
|
370
|
-
const e = editsOf(rd('edits.json')); if (Object.keys(e.copy).length || Object.keys(e.vars).length) out.edits = e;
|
|
372
|
+
const e = editsOf(rd('edits.json')); if (Object.keys(e.copy).length || Object.keys(e.vars).length || Object.keys(e.styles).length) out.edits = e;
|
|
371
373
|
return out;
|
|
372
374
|
}
|
|
373
|
-
/**
|
|
375
|
+
/** The inspector's fields (design "Prototype like Figma", Wawan "build" 2026-11-18): the key edits.json keeps, the CSS property it sets,
|
|
376
|
+
* and what a value may look like. */
|
|
377
|
+
const STYLE_OK = {
|
|
378
|
+
family: ['font-family', /^[A-Za-z0-9 ,"'-]{1,80}$/], size: ['font-size', /^\d{1,3}(\.\d{1,2})?px$/], weight: ['font-weight', /^[1-9]00$/],
|
|
379
|
+
line: ['line-height', /^\d(\.\d{1,2})?$/], spacing: ['letter-spacing', /^-?\d{1,2}(\.\d{1,2})?px$/], color: ['color', /^#[0-9a-f]{6}$/i],
|
|
380
|
+
fill: ['background-color', /^(#[0-9a-f]{6}|transparent)$/i], corner: ['border-radius', /^\d{1,3}px$/], padding: ['padding', /^\d{1,3}px( \d{1,3}px)?$/],
|
|
381
|
+
align: ['text-align', /^(left|center|right)$/],
|
|
382
|
+
};
|
|
383
|
+
/** PURE. edits.json (the PM's in-place copy edits, tweaks and inspector styles, POST /api/lab/edit) →
|
|
384
|
+
* { copy: { key: text }, vars: { --var: value }, styles: { el: { field: value } } } (fields: STYLE_OK). A bad field or value is left out. */
|
|
374
385
|
function editsOf(j) {
|
|
375
|
-
const copy = {}, vars = {};
|
|
386
|
+
const copy = {}, vars = {}, styles = {};
|
|
376
387
|
if (isObj(j) && isObj(j.copy)) for (const [k, v] of Object.entries(j.copy).slice(0, 80)) if (/^[A-Za-z0-9][A-Za-z0-9_.-]{0,59}$/.test(k) && typeof v === 'string') copy[k] = one(v, 300);
|
|
377
388
|
if (isObj(j) && isObj(j.vars)) for (const [k, v] of Object.entries(j.vars).slice(0, 12)) if (/^--[a-z][a-z0-9-]{0,40}$/i.test(k) && /^-?\d{1,4}(\.\d{1,3})?(px|rem|em|%|deg)?$/.test(String(v))) vars[k] = String(v);
|
|
378
|
-
|
|
389
|
+
if (isObj(j) && isObj(j.styles)) for (const [el, ps] of Object.entries(j.styles).slice(0, 60)) {
|
|
390
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,59}$/.test(el) || !isObj(ps)) continue;
|
|
391
|
+
const o = {};
|
|
392
|
+
for (const [k, v] of Object.entries(ps)) if (STYLE_OK[k] && typeof v === 'string' && STYLE_OK[k][1].test(v)) o[k] = v;
|
|
393
|
+
if (Object.keys(o).length) styles[el] = o;
|
|
394
|
+
}
|
|
395
|
+
return { copy, vars, styles };
|
|
396
|
+
}
|
|
397
|
+
/** PURE. What one element's styles say, for the chat and the prompt: "56px · Bold · #FFFFFF". */
|
|
398
|
+
function styleWords(ps) {
|
|
399
|
+
const W = { 100: 'Thin', 200: 'Extra light', 300: 'Light', 400: 'Regular', 500: 'Medium', 600: 'Semibold', 700: 'Bold', 800: 'Extra bold', 900: 'Black' };
|
|
400
|
+
return Object.entries(ps || {}).map(([k, v]) => (k === 'weight' ? W[v] || v : k === 'size' || k === 'color' ? v : k + ' ' + v)).join(' · ');
|
|
379
401
|
}
|
|
380
402
|
|
|
381
403
|
/** The one sentence a version says about itself: <meta name="pmos-changed" content="…"> in its head, or ''. */
|
|
@@ -716,5 +738,5 @@ function stopRound(id) { return inst ? inst.stop(id) : { ok: false, error: NOT_R
|
|
|
716
738
|
function status() { return inst ? inst.status() : []; }
|
|
717
739
|
|
|
718
740
|
module.exports = { JOB, ORIGIN, STALL_MS, progressOf, KEYS, DEFAULT_DIRECTIONS, ONE_DIRECTION, PARTS, FROM, marksOf, intentOf, parseDirs, askOf, waiting, baseOf, currentOf: PR.currentOf, contextOf, scaffoldOf, promptOf, saidOf, roundLine,
|
|
719
|
-
flowOf, lanesOf, tweaksOf, copyOf, changesOf, partsAt, editsOf,
|
|
741
|
+
flowOf, lanesOf, tweaksOf, copyOf, changesOf, partsAt, editsOf, styleWords, STYLE_OK,
|
|
720
742
|
create, install, round, startNow, proposeNow, cancel, stopRound, dropCard, running, status };
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* data-screen one screen shows at a time; the first is the start data-go a tap moves to that screen
|
|
8
8
|
* data-el what the PM can point at, comment on or tap in Play data-label its name in plain words
|
|
9
9
|
* data-copy text the Page copy card edits in place :root vars what Tweaks change
|
|
10
|
-
* Parent → frame { pmos: 1, t }: mode (view | point | comment | play), screen, copy, copyAll, vars, hint, sel, pins.
|
|
11
|
-
* Frame → parent { pmos: 1, t }: ready (screens, els, copy), screen, point
|
|
10
|
+
* Parent → frame { pmos: 1, t }: mode (view | point | comment | play), screen, copy, copyAll, vars, styles (the inspector's, all of them), hint, sel, pins.
|
|
11
|
+
* Frame → parent { pmos: 1, t }: ready (screens with their data-page, els with their screen and copy key, copy), screen, point (with looks: the
|
|
12
|
+
* selected element's current styles), looks (after styles), pin, tap.
|
|
12
13
|
*
|
|
13
14
|
* withRuntime(html) → html with the runtime's <script> before </body> (or at the end) */
|
|
14
15
|
function runtime() {
|
|
@@ -32,7 +33,36 @@ function runtime() {
|
|
|
32
33
|
post({ t: 'screen', id: on.getAttribute('data-screen') });
|
|
33
34
|
};
|
|
34
35
|
var elOf = function (n) { return n && n.closest ? n.closest('[data-el]') : null; };
|
|
35
|
-
var info = function (e) {
|
|
36
|
+
var info = function (e) {
|
|
37
|
+
if (!e) return { el: '', label: '' };
|
|
38
|
+
var sc = e.closest('[data-screen]'), cp = e.hasAttribute('data-copy') ? e : e.querySelector('[data-copy]');
|
|
39
|
+
return { el: e.getAttribute('data-el') || '', label: e.getAttribute('data-label') || (e.textContent || '').trim().slice(0, 40), screen: sc ? sc.getAttribute('data-screen') || '' : '', copy: cp ? cp.getAttribute('data-copy') || '' : '' };
|
|
40
|
+
};
|
|
41
|
+
// the inspector (design "Prototype like Figma"): what the selected element looks like now, as the values it edits
|
|
42
|
+
var CSS = { family: 'font-family', size: 'font-size', weight: 'font-weight', line: 'line-height', spacing: 'letter-spacing', color: 'color', fill: 'background-color', corner: 'border-radius', padding: 'padding', align: 'text-align' };
|
|
43
|
+
var hex = function (c) { var m = /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/.exec(c || ''); if (!m) return c || ''; if (m[4] === '0') return 'transparent'; return '#' + [m[1], m[2], m[3]].map(function (x) { return ('0' + Number(x).toString(16)).slice(-2); }).join(''); };
|
|
44
|
+
var looks = function (e) {
|
|
45
|
+
var cs = getComputedStyle(e), o = {}, fs = parseFloat(cs.fontSize) || 16, bg = e, fill = 'transparent';
|
|
46
|
+
o.family = (cs.fontFamily || '').split(',')[0].replace(/["']/g, '').trim();
|
|
47
|
+
o.size = Math.round(fs) + 'px'; o.weight = String(Math.round((parseInt(cs.fontWeight, 10) || 400) / 100) * 100);
|
|
48
|
+
o.line = cs.lineHeight === 'normal' ? '1.2' : String(Math.round((parseFloat(cs.lineHeight) / fs) * 100) / 100);
|
|
49
|
+
o.spacing = cs.letterSpacing === 'normal' ? '0px' : Math.round(parseFloat(cs.letterSpacing) * 10) / 10 + 'px';
|
|
50
|
+
o.color = hex(cs.color); o.fill = hex(cs.backgroundColor);
|
|
51
|
+
// the colour picker needs a colour: a see-through fill shows what is behind it
|
|
52
|
+
while (bg && fill === 'transparent') { fill = hex(getComputedStyle(bg).backgroundColor); bg = bg.parentElement; }
|
|
53
|
+
o.fillPick = /^#/.test(fill) ? fill : '#ffffff';
|
|
54
|
+
o.corner = Math.round(parseFloat(cs.borderTopLeftRadius) || 0) + 'px'; o.padding = Math.round(parseFloat(cs.paddingTop) || 0) + 'px ' + Math.round(parseFloat(cs.paddingLeft) || 0) + 'px';
|
|
55
|
+
o.align = /center|right/.test(cs.textAlign) ? cs.textAlign : 'left';
|
|
56
|
+
return o;
|
|
57
|
+
};
|
|
58
|
+
var styled = [];
|
|
59
|
+
var applyStyles = function (all) {
|
|
60
|
+
styled.forEach(function (x) { x.e.style.removeProperty(x.p); }); styled = [];
|
|
61
|
+
Object.keys(all || {}).forEach(function (id) {
|
|
62
|
+
var e = document.querySelector('[data-el="' + String(id).replace(/[^A-Za-z0-9_-]/g, '') + '"]'); if (!e) return;
|
|
63
|
+
Object.keys(all[id] || {}).forEach(function (k) { var p = CSS[k]; if (!p) return; e.style.setProperty(p, String(all[id][k]), 'important'); styled.push({ e: e, p: p }); });
|
|
64
|
+
});
|
|
65
|
+
};
|
|
36
66
|
var hov = null;
|
|
37
67
|
document.addEventListener('mouseover', function (ev) {
|
|
38
68
|
if (mode !== 'point' && mode !== 'comment') return;
|
|
@@ -41,7 +71,7 @@ function runtime() {
|
|
|
41
71
|
}, true);
|
|
42
72
|
document.addEventListener('click', function (ev) {
|
|
43
73
|
var e = elOf(ev.target), go = ev.target.closest && ev.target.closest('[data-go],a[href^="#"]');
|
|
44
|
-
if (mode === 'point') { ev.preventDefault(); ev.stopPropagation(); if (!e) return; sel(e.getAttribute('data-el')); var i = info(e); i.t = 'point'; post(i); return; }
|
|
74
|
+
if (mode === 'point') { ev.preventDefault(); ev.stopPropagation(); if (!e) return; sel(e.getAttribute('data-el')); var i = info(e); i.t = 'point'; i.looks = looks(e); post(i); return; }
|
|
45
75
|
if (mode === 'comment') {
|
|
46
76
|
ev.preventDefault(); ev.stopPropagation();
|
|
47
77
|
var h = Math.max(1, document.documentElement.scrollHeight), w = Math.max(1, document.documentElement.clientWidth), c = info(e);
|
|
@@ -85,12 +115,16 @@ function runtime() {
|
|
|
85
115
|
(m.els || []).forEach(function (id) { var e = document.querySelector('[data-el="' + String(id).replace(/[^A-Za-z0-9_-]/g, '') + '"]'); if (e) e.classList.add('pmos-hint'); });
|
|
86
116
|
setTimeout(function () { Array.prototype.forEach.call(document.querySelectorAll('.pmos-hint'), function (x) { x.classList.remove('pmos-hint'); }); }, 1600);
|
|
87
117
|
} else if (m.t === 'sel') sel(m.el);
|
|
118
|
+
else if (m.t === 'styles') {
|
|
119
|
+
applyStyles(m.styles);
|
|
120
|
+
var se = document.querySelector('.pmos-sel'); if (se) post({ t: 'looks', el: se.getAttribute('data-el') || '', looks: looks(se) });
|
|
121
|
+
}
|
|
88
122
|
else if (m.t === 'pins') pins(m.pins);
|
|
89
123
|
});
|
|
90
124
|
var start = function () {
|
|
91
125
|
var all = screens(); if (all.length) all[0].classList.add('pmos-on');
|
|
92
126
|
var copy = {}; Array.prototype.forEach.call(document.querySelectorAll('[data-copy]'), function (x) { var k = x.getAttribute('data-copy'); if (!(k in copy)) copy[k] = (x.textContent || '').trim(); });
|
|
93
|
-
post({ t: 'ready', screens: all.map(function (s) { return { id: s.getAttribute('data-screen'), label: s.getAttribute('data-label') || '' }; }),
|
|
127
|
+
post({ t: 'ready', screens: all.map(function (s) { return { id: s.getAttribute('data-screen'), label: s.getAttribute('data-label') || '', page: s.getAttribute('data-page') || '' }; }),
|
|
94
128
|
els: Array.prototype.map.call(document.querySelectorAll('[data-el]'), function (e) { return info(e); }), copy: copy });
|
|
95
129
|
};
|
|
96
130
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start();
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Prototype by chatting (initiative live-round-iterative): the compare view of a live round carries its version's companions as data
|
|
19
19
|
* (data: { flow, lanes, copy, tweaks, edits }, lib/live-round.js partsAt) and the initiative's comments; GET /api/lab/specimen with rt=1
|
|
20
20
|
* adds the canvas runtime (lib/proto-runtime.js) inside the same sandbox, so the canvas can point, pin, play and edit through postMessage.
|
|
21
|
-
* POST /api/lab/edit { ws, file, copy?: { key: text }, vars?: { --var: value } } → { ok } the PM's in-place copy edits and
|
|
21
|
+
* POST /api/lab/edit { ws, file, copy?: { key: text }, vars?: { --var: value }, styles?: { el: { prop: value } | null } } → { ok } the PM's in-place copy edits, tweaks and inspector styles,
|
|
22
22
|
* kept with the version (edits.json next to it); the next version reads them
|
|
23
23
|
* POST /api/lab/comment { ws, ini, file, el?, label?, text, x?, y?, send? } → { ok, id } a comment pinned to an element (send: it was
|
|
24
24
|
* sent to PMOS as the next change; else it is kept for the team)
|
|
@@ -204,12 +204,16 @@ const WRITES = {
|
|
|
204
204
|
const abs = liveFile(ctx, body.file); if (!abs) return fail(ctx, res, 404, 'That version is not in the live round folder');
|
|
205
205
|
const LR = require('./live-round.js'), f = require('path').join(require('path').dirname(abs), 'edits.json');
|
|
206
206
|
let was = {}; try { was = JSON.parse(fs.readFileSync(f, 'utf8')); } catch { was = {}; }
|
|
207
|
-
const add = LR.editsOf({ copy: body.copy, vars: body.vars }), old = LR.editsOf(was);
|
|
208
|
-
|
|
207
|
+
const add = LR.editsOf({ copy: body.copy, vars: body.vars, styles: body.styles }), old = LR.editsOf(was);
|
|
208
|
+
// inspector styles merge per element; { el: null } (the layer's undo) drops that element's styles
|
|
209
|
+
const styles = { ...old.styles };
|
|
210
|
+
for (const [el, ps] of Object.entries(add.styles)) styles[el] = { ...(styles[el] || {}), ...ps };
|
|
211
|
+
if (body.styles && typeof body.styles === 'object') for (const [el, ps] of Object.entries(body.styles)) if (ps === null) delete styles[el];
|
|
212
|
+
const next = { copy: { ...old.copy, ...add.copy }, vars: { ...old.vars, ...add.vars }, styles };
|
|
209
213
|
try { fs.writeFileSync(f, JSON.stringify(next, null, 1)); } catch { return fail(ctx, res, 500, 'The edit was not saved'); }
|
|
210
214
|
// the edits are part of the version the initiative is at (2026-11-18: they lived only in edits.json): its kept line says so, once per
|
|
211
215
|
// new line edited (not on every key press)
|
|
212
|
-
const n0 = Object.keys(old.copy).length + Object.keys(old.vars).length, n1 = Object.keys(next.copy).length + Object.keys(next.vars).length;
|
|
216
|
+
const n0 = Object.keys(old.copy).length + Object.keys(old.vars).length + Object.keys(old.styles).length, n1 = Object.keys(next.copy).length + Object.keys(next.vars).length + Object.keys(next.styles).length;
|
|
213
217
|
if (n1 > n0) try { keptEdited(dir, String(body.file), next, g); } catch { /* edits.json holds them */ }
|
|
214
218
|
ctx.json(res, { ok: true, edits: next });
|
|
215
219
|
return true;
|
|
@@ -247,8 +251,8 @@ function keptEdited(dir, file, ed, g) {
|
|
|
247
251
|
}
|
|
248
252
|
const cur = ini ? PR.currentOf(F, ini) : null;
|
|
249
253
|
if (!cur || cur.file !== file) return;
|
|
250
|
-
const nc = Object.keys(ed.copy).length, nv = Object.keys(ed.vars).length;
|
|
251
|
-
const what = [nc ? nc + (nc === 1 ? ' line of copy' : ' lines of copy') : '', nv ? nv + (nv === 1 ? ' tweak' : ' tweaks') : ''].filter(Boolean).join(' and ');
|
|
254
|
+
const nc = Object.keys(ed.copy).length, nv = Object.keys(ed.vars).length, ns = Object.keys(ed.styles || {}).length;
|
|
255
|
+
const what = [nc ? nc + (nc === 1 ? ' line of copy' : ' lines of copy') : '', nv ? nv + (nv === 1 ? ' tweak' : ' tweaks') : '', ns ? ns + (ns === 1 ? ' restyled layer' : ' restyled layers') : ''].filter(Boolean).join(' and ');
|
|
252
256
|
const AF = require('./artefacts.js'), by = (g.actor && /^(pm|agent):/.test(String(g.actor.by || ''))) ? g.actor : { by: 'agent:live-round' };
|
|
253
257
|
AF.set(AF.file(dir), { scope: 'experiment:' + ini, artefact: 'specimens', field: 'kept', text: `Version ${cur.n}, with your edits in the Viewer (${what}): ${cur.said || cur.title || ''} (${LAB.specimenUrl(file)})`.slice(0, 600), sources: [{ label: 'live round', ref: LAB.specimenUrl(file) }] }, by);
|
|
254
258
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.602.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.602.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -34,10 +34,32 @@
|
|
|
34
34
|
|
|
35
35
|
/* the canvas */
|
|
36
36
|
.pc-vp { overflow: auto; border-radius: 16px; background-color: var(--cz-well); background-image: radial-gradient(var(--cz-hair) 1px, transparent 1px); background-size: 16px 16px; padding: 14px; min-height: 420px; }
|
|
37
|
-
.pc-
|
|
38
|
-
.pc-
|
|
39
|
-
.pc-
|
|
40
|
-
.pc-
|
|
37
|
+
.pc-dbody { display: flex; gap: 10px; align-items: stretch; min-height: 420px; }
|
|
38
|
+
.pc-dbody > .pc-vp { flex: 1; min-width: 0; }
|
|
39
|
+
.pc-leftw:empty, .pc-rightw:empty { display: none; }
|
|
40
|
+
.pc-board { display: flex; justify-content: center; align-items: flex-start; width: max-content; min-width: 100%; }
|
|
41
|
+
|
|
42
|
+
/* design mode: Pages > Screens > Layers on the left, Exact values on the right (canvas FpA); both hide */
|
|
43
|
+
.pc-left, .pc-insp, .pc-side { display: flex; flex-direction: column; gap: 2px; padding: 6px 0 10px; border: 1px solid var(--cz-hair); border-radius: 16px; background: var(--cz-card); overflow: auto; max-height: 72vh; }
|
|
44
|
+
.pc-left { width: 210px; }
|
|
45
|
+
.pc-insp { width: 270px; gap: 0; }
|
|
46
|
+
.pc-lh { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 6px 2px 14px; font-size: var(--fs-badge); font-weight: var(--fw-strong); letter-spacing: .06em; text-transform: uppercase; color: var(--cz-ink3); }
|
|
47
|
+
.pc-lh span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
48
|
+
.pc-lh .pc-ib { border-color: transparent; background: transparent; }
|
|
49
|
+
.pc-lrow { display: block; width: 100%; min-height: 32px; padding: 6px 14px; border: 0; background: transparent; text-align: left; font: inherit; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink2); cursor: pointer; }
|
|
50
|
+
.pc-lrow.in { padding-left: 26px; }
|
|
51
|
+
.pc-lrow:hover { background: var(--cz-well); }
|
|
52
|
+
.pc-lrow[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: var(--fw-strong); }
|
|
53
|
+
.pc-left .pc-hint, .pc-insp > .pc-hint { padding: 4px 14px; }
|
|
54
|
+
.pc-isec { display: flex; flex-direction: column; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--cz-hair); }
|
|
55
|
+
.pc-isec:first-of-type { border-top: 0; }
|
|
56
|
+
.pc-isec > b { font-size: var(--fs-badge); font-weight: var(--fw-strong); letter-spacing: .06em; text-transform: uppercase; color: var(--cz-ink3); }
|
|
57
|
+
.pc-ir { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--cz-ink2); }
|
|
58
|
+
.pc-ir input, .pc-ir select { min-width: 0; width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--cz-hair); border-radius: 8px; background: var(--cz-card); color: var(--cz-ink); font: inherit; font-size: var(--fs-meta); }
|
|
59
|
+
.pc-ir input[type="color"] { padding: 2px; cursor: pointer; }
|
|
60
|
+
.pc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
61
|
+
.pc-ifoot { margin: 0; display: flex; align-items: center; gap: 8px; padding: 10px 8px 0 14px; border-top: 1px solid var(--cz-hair); font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink3); }
|
|
62
|
+
.pc-ifoot .pc-ib { margin-left: auto; }
|
|
41
63
|
.pc-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--cz-hair); border-radius: 16px; background: var(--cz-card); min-width: 0; }
|
|
42
64
|
.pc-card h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
43
65
|
.pc-upd { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--cz-okbg); color: var(--cz-ok); font-size: var(--fs-badge); font-weight: var(--fw-strong); line-height: var(--lh-badge); }
|
|
@@ -60,9 +82,9 @@
|
|
|
60
82
|
.pc-dev { position: relative; }
|
|
61
83
|
.pc-dev.phone { width: 300px; padding: 10px; border-radius: 34px; background: var(--cz-ink); }
|
|
62
84
|
.pc-dev.phone .pc-frame { height: 600px; border-radius: 26px; }
|
|
63
|
-
.pc-dev.desktop { width:
|
|
85
|
+
.pc-dev.desktop { width: 900px; padding: 26px 0 0; border-radius: 12px; background: var(--cz-well2, var(--cz-well)); border: 1px solid var(--cz-hair); }
|
|
64
86
|
.pc-dev.desktop::before { content: ''; position: absolute; left: 12px; top: 10px; width: 36px; height: 8px; border-radius: 4px; background: radial-gradient(circle at 4px 4px, var(--cz-hair) 3.5px, transparent 4px) 0 0 / 14px 8px repeat-x; }
|
|
65
|
-
.pc-dev.desktop .pc-frame { height:
|
|
87
|
+
.pc-dev.desktop .pc-frame { height: 560px; border-radius: 0 0 12px 12px; }
|
|
66
88
|
.pc-frame { position: relative; overflow: hidden; background: var(--cz-c-ffffff); }
|
|
67
89
|
.pc-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--cz-c-ffffff); }
|
|
68
90
|
.pc-frame .pc-none { padding: 20px; }
|
|
@@ -119,7 +141,7 @@
|
|
|
119
141
|
.pc-chip[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); border-color: transparent; }
|
|
120
142
|
|
|
121
143
|
/* the page copy: a side panel over the canvas, behind the toolbar's Page copy press (closed by default) */
|
|
122
|
-
.pc-side {
|
|
144
|
+
.pc-side { width: min(420px, 100%); padding: 14px; gap: 8px; }
|
|
123
145
|
.pc-side h3 { display: flex; align-items: center; gap: 8px; }
|
|
124
146
|
.pc-side h3 .pc-ib { margin-left: auto; width: 28px; height: 28px; }
|
|
125
147
|
.pc .pc-ib.upd { position: relative; }
|
|
@@ -132,18 +154,45 @@
|
|
|
132
154
|
.pc-cr [contenteditable]:hover { background: var(--cz-well); }
|
|
133
155
|
.pc-cr.ch [contenteditable] { box-shadow: inset 2px 0 0 var(--cz-ok); }
|
|
134
156
|
|
|
135
|
-
/* Play */
|
|
136
|
-
.pc-play { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 10px; padding: 10px; border-radius: 16px; background: var(--cz-
|
|
137
|
-
.pc-
|
|
138
|
-
.pc-
|
|
139
|
-
.pc-
|
|
140
|
-
.pc-
|
|
141
|
-
.pc-
|
|
142
|
-
.pc-
|
|
143
|
-
.pc-
|
|
157
|
+
/* Play (canvas FpC): the prototype bare, the device switch, the flow beside it as steps */
|
|
158
|
+
.pc-play { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 10px; padding: 10px; border-radius: 16px; background: var(--cz-ink); color: var(--cz-onsolid); }
|
|
159
|
+
.pc-play .pc-ib { background: transparent; border-color: transparent; color: var(--cz-onsolid); }
|
|
160
|
+
.pc-play .pc-ib.blue { background: var(--cz-blue); color: var(--cz-ink); }
|
|
161
|
+
.pc-play .pc-grp { background: rgba(255, 255, 255, .08); }
|
|
162
|
+
.pc-play .pc-grp .pc-ib[aria-pressed="true"], .pc-play .pc-ib[aria-pressed="true"] { background: rgba(255, 255, 255, .16); color: var(--cz-onsolid); box-shadow: none; }
|
|
163
|
+
.pc-pbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
164
|
+
.pc-pbar b { font-weight: var(--fw-strong); }
|
|
165
|
+
.pc-pbar small { font-size: var(--fs-meta); opacity: .7; }
|
|
166
|
+
.pc-pmain { flex: 1; min-height: 0; display: flex; gap: 12px; }
|
|
167
|
+
.pc-pstage { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
|
|
168
|
+
.pc-pstage .pc-hint { color: var(--cz-onsolid); opacity: .6; text-align: center; }
|
|
169
|
+
.pc-pframe { flex: 1; min-height: 0; width: 100%; display: flex; justify-content: center; }
|
|
170
|
+
.pc-pframe iframe { border: 0; background: var(--cz-c-ffffff); height: 100%; min-height: 420px; }
|
|
171
|
+
.pc-pframe.phone iframe { width: 390px; border-radius: 26px; box-shadow: 0 0 0 10px var(--cz-ink2); margin: 10px; }
|
|
172
|
+
.pc-pframe.desktop iframe { width: min(1280px, 100%); border-radius: 12px; }
|
|
173
|
+
.pc-pframe.own iframe { width: 100%; border-radius: 6px; }
|
|
174
|
+
.pc-pctl { display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .08); }
|
|
175
|
+
.pc-pctl > span { min-width: 120px; text-align: center; font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
|
|
176
|
+
.pc-pflow { width: 300px; flex: none; display: flex; flex-direction: column; gap: 8px; padding: 6px 10px 10px; border-radius: 14px; background: rgba(255, 255, 255, .06); overflow: auto; }
|
|
177
|
+
.pc-pflow .pc-lh { color: var(--cz-onsolid); opacity: .7; padding-left: 4px; }
|
|
178
|
+
.pc-psel select { width: 100%; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); color: var(--cz-onsolid); font: inherit; font-size: var(--fs-meta); }
|
|
179
|
+
.pc-psel option { color: var(--cz-ink); }
|
|
180
|
+
.pc-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
|
|
181
|
+
.pc-pflow .pc-bar2 { background: rgba(255, 255, 255, .12); }
|
|
182
|
+
.pc-psteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
183
|
+
.pc-pst { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--cz-onsolid); font: inherit; font-size: var(--fs-meta); text-align: left; cursor: pointer; }
|
|
184
|
+
.pc-pst:hover { background: rgba(255, 255, 255, .06); }
|
|
185
|
+
.pc-pst.on { background: rgba(255, 255, 255, .14); }
|
|
186
|
+
.pc-pst.done { opacity: .7; }
|
|
187
|
+
.pc-pn { width: 22px; height: 22px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-badge); background: rgba(255, 255, 255, .12); }
|
|
188
|
+
.pc-pst.on .pc-pn { background: var(--cz-blue); color: var(--cz-ink); }
|
|
189
|
+
.pc-pst.done .pc-pn { background: var(--cz-okbg); color: var(--cz-ok); }
|
|
144
190
|
|
|
145
191
|
@media (max-width: 760px) {
|
|
146
|
-
.pc-
|
|
192
|
+
.pc-dbody { flex-direction: column; }
|
|
193
|
+
.pc-left, .pc-insp, .pc-side { width: 100%; max-height: none; }
|
|
194
|
+
.pc-pmain { flex-direction: column; }
|
|
195
|
+
.pc-pflow { width: 100%; }
|
|
147
196
|
.pc .pc-ib { width: 44px; height: 44px; }
|
|
148
197
|
.pc-dev.desktop { width: 100%; }
|
|
149
198
|
.pc-pframe.phone iframe { width: 100%; box-shadow: none; margin: 0; }
|
|
@@ -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;
|