@joplo-app/server 0.2.10 → 0.2.13
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/dist/build.d.ts +3 -2
- package/dist/build.js +19 -7
- package/dist/cloud.d.ts +85 -0
- package/dist/cloud.js +110 -0
- package/dist/contract.d.ts +17 -2
- package/dist/dev.d.ts +5 -1
- package/dist/dev.js +57 -5
- package/dist/feature-diff-locales.json +882 -0
- package/dist/feature-diff-runtime.js +427 -0
- package/dist/feature-diff-viewer.d.ts +3 -0
- package/dist/feature-diff-viewer.js +130 -0
- package/dist/feature-diff.d.ts +14 -0
- package/dist/feature-diff.js +56 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/local-review.d.ts +18 -0
- package/dist/local-review.js +133 -0
- package/dist/render.js +6 -3
- package/dist/voice-http.d.ts +10 -1
- package/dist/voice-http.js +25 -10
- package/dist/voice.d.ts +16 -6
- package/dist/voice.js +21 -1
- package/package.json +5 -4
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/** Public diff shell. Keep this standalone: embedded verbatim, never executed by the publisher. */
|
|
2
|
+
"use strict";
|
|
3
|
+
// Self-contained so the same function works from source and packed server builds.
|
|
4
|
+
function viewer() {
|
|
5
|
+
const m = JSON.parse(document.getElementById('joplo-feature-diff').textContent);
|
|
6
|
+
const locales = JSON.parse(document.getElementById('joplo-diff-locales').textContent);
|
|
7
|
+
const requested = new URLSearchParams(location.search).get('locale');
|
|
8
|
+
const tag = (requested || navigator.language || 'en').toLowerCase();
|
|
9
|
+
const locale = Object.keys(locales).find(l => l.toLowerCase() === tag) || (tag.startsWith('zh') ? (/hant|tw|hk|mo/.test(tag) ? 'zh-TW' : 'zh-CN') : tag.startsWith('pt') ? 'pt-BR' : tag.split('-')[0]);
|
|
10
|
+
const words = locales[locale] || locales.en;
|
|
11
|
+
const plural = (n, one, many) => t(n === 1 ? one : many, { n });
|
|
12
|
+
const t = (en, vars) => { let s = words[en] || en; for (const k in vars || {}) s = s.split(`{${k}}`).join(String(vars[k])); return s; };
|
|
13
|
+
document.documentElement.lang = locales[locale] ? locale : 'en';
|
|
14
|
+
const $ = (id) => document.getElementById(id);
|
|
15
|
+
const button = (id) => $(id);
|
|
16
|
+
const check = (id) => $(id);
|
|
17
|
+
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text !== undefined) e.textContent = text; return e; };
|
|
18
|
+
const labels = { added: t("Added"), modified: t("Modified"), removed: t("Removed"), unchanged: t("Unchanged"), uncertain: t("Uncertain match") };
|
|
19
|
+
const reasons = { 'initial-state': t("Initial state"), scenes: t("Screens"), theme: t("Theme"), 'layers-roles': t("Layers / roles"), description: t("Description"), 'project-presentation': t("Project presentation") };
|
|
20
|
+
const stepReasons = { action: t("Action"), effects: t("Result"), caption: t("Caption"), explain: t("Explanation"), camera: t("Camera"), annotations: t("Annotations"), voice: t("Voice"), timing: t("Timing"), trace: t("Call trace"), forks: t("Branches"), kind: t("Step type"), order: t("Order"), presentation: t("Presentation"), 'ambiguous-match': t("Uncertain match") };
|
|
21
|
+
for (const [id, en] of [['prev', 'Previous'], ['next', 'Next'], ['align', 'Realign'], ['reload', 'Reload players'], ['only-changes', 'Changes only'], ['view-single', 'Single view'], ['view-split', 'Side by side']])
|
|
22
|
+
$(id).textContent = t(en);
|
|
23
|
+
document.querySelector('[data-label="unchanged"]').textContent = t("Show unchanged scenarios");
|
|
24
|
+
$('page-title').textContent = t('Feature diff');
|
|
25
|
+
document.title = 'Joplo · ' + t('Feature diff');
|
|
26
|
+
$('counter-label').textContent = t('Change');
|
|
27
|
+
$('scenarios').setAttribute('aria-label', t('Scenarios'));
|
|
28
|
+
$('sides').setAttribute('aria-label', t('Versions'));
|
|
29
|
+
$('view').setAttribute('aria-label', t('Layout'));
|
|
30
|
+
$('disclaimer').textContent = t("Changes to a concept demo, not verification of the real product. Synchronized playback is muted.");
|
|
31
|
+
$('base').textContent = m.base.sha?.slice(0, 8) ?? t("Local baseline");
|
|
32
|
+
$('head').textContent = m.head.sha?.slice(0, 8) ?? t("Local current");
|
|
33
|
+
const shas = { before: $('base').textContent, after: $('head').textContent };
|
|
34
|
+
const count = (status) => m.scenarios.filter(s => status.includes(s.status)).length;
|
|
35
|
+
$('totals').replaceChildren(...[['added', ['added']], ['modified', ['modified', 'uncertain']], ['removed', ['removed']]].filter(([, s]) => count(s)).map(([k, s]) => {
|
|
36
|
+
const pill = el('span', `pill ${k}`);
|
|
37
|
+
pill.append(el('b', '', String(count(s))), el('span', '', labels[k]));
|
|
38
|
+
return pill;
|
|
39
|
+
}));
|
|
40
|
+
const unchangedCount = count(['unchanged']);
|
|
41
|
+
$('unchanged-count').textContent = unchangedCount ? String(unchangedCount) : '';
|
|
42
|
+
let selected = -1, rows = [], index = 0, panes = [], playing = false, waiting = false, misaligned = false, fullContext = false, rowButtons = [];
|
|
43
|
+
let timeout, advance;
|
|
44
|
+
// One large stage by default: both players stay loaded and stacked, so flipping keeps size and position.
|
|
45
|
+
let layout = 'single', focus = 'after';
|
|
46
|
+
try { if (localStorage.getItem('joplo-diff-layout') === 'split') layout = 'split'; } catch { /* storage unavailable */ }
|
|
47
|
+
const position = (r) => r ? r.position : null;
|
|
48
|
+
const where = (step) => [step.before && `${t('Old')} ${step.before.position}`, step.after && `${t('New')} ${step.after.position}`].filter(Boolean).join(' → ');
|
|
49
|
+
const caption = (step) => step.after?.caption ?? step.before?.caption ?? t('Step {n}', { n: position(step.after) ?? position(step.before) });
|
|
50
|
+
function stop() { playing = false; clearTimeout(advance); button('play').textContent = t("Play changes"); button('play').className = 'primary play'; }
|
|
51
|
+
function state(kind) { $('dot').className = `dot ${kind}`; $('align').hidden = kind !== 'warn'; }
|
|
52
|
+
function paneStep(p) {
|
|
53
|
+
const total = p.scenarios.get(p.scenario);
|
|
54
|
+
// After drift, show where the player actually is so the realign prompt is credible.
|
|
55
|
+
const step = misaligned && p.actual?.scenario === p.scenario ? p.actual.step : p.target;
|
|
56
|
+
const text = step === 0 ? t("Initial state") : total === undefined ? t('Step {n}', { n: step }) : t('Step {n} / {total}', { n: step, total });
|
|
57
|
+
for (const e of p.stepEls) e.textContent = text;
|
|
58
|
+
}
|
|
59
|
+
function controls() {
|
|
60
|
+
button('prev').disabled = waiting || index <= 0;
|
|
61
|
+
button('next').disabled = waiting || index >= rows.length - 1;
|
|
62
|
+
button('play').disabled = misaligned || (waiting && !playing) || !rows.length;
|
|
63
|
+
$('counter').textContent = rows.length ? `${index + 1} / ${rows.length}` : '';
|
|
64
|
+
rowButtons.forEach((b, i) => b.setAttribute('aria-current', String(i === index)));
|
|
65
|
+
for (const p of panes) paneStep(p);
|
|
66
|
+
renderChange();
|
|
67
|
+
}
|
|
68
|
+
function invalidate() {
|
|
69
|
+
stop();
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
waiting = false;
|
|
72
|
+
misaligned = true;
|
|
73
|
+
for (const p of panes) p.confirmed = false;
|
|
74
|
+
state('warn');
|
|
75
|
+
controls();
|
|
76
|
+
}
|
|
77
|
+
function independentMove() {
|
|
78
|
+
invalidate();
|
|
79
|
+
$('status').textContent = t("Player moved independently. Realign to continue comparing.");
|
|
80
|
+
}
|
|
81
|
+
function positioned() {
|
|
82
|
+
if (!waiting || misaligned || !panes.every(p => p.ready && p.confirmed && p.actual?.scenario === p.scenario && p.actual.step === p.target))
|
|
83
|
+
return;
|
|
84
|
+
waiting = false;
|
|
85
|
+
clearTimeout(timeout);
|
|
86
|
+
$('status').textContent = t("Aligned · full preceding state restored");
|
|
87
|
+
state('ok');
|
|
88
|
+
controls();
|
|
89
|
+
if (playing) {
|
|
90
|
+
clearTimeout(advance);
|
|
91
|
+
advance = setTimeout(() => { if (index + 1 < rows.length)
|
|
92
|
+
go(index + 1);
|
|
93
|
+
else
|
|
94
|
+
stop(); }, 1800);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function send(p) { if (p.ready)
|
|
98
|
+
p.iframe.contentWindow?.postMessage({ type: 'joplo:goto', protocol: 1, scenario: p.scenario, step: p.target }, '*'); }
|
|
99
|
+
function go(i) {
|
|
100
|
+
if (!rows[i])
|
|
101
|
+
return;
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
clearTimeout(advance);
|
|
104
|
+
index = i;
|
|
105
|
+
// Added steps exist only in the new version, removed ones only in the old: show that side.
|
|
106
|
+
const only = rows[i].step?.status === 'added' ? 'after' : rows[i].step?.status === 'removed' ? 'before' : null;
|
|
107
|
+
if (only && panes.some(p => p.side === only)) focus = only;
|
|
108
|
+
waiting = true;
|
|
109
|
+
misaligned = false;
|
|
110
|
+
$('status').textContent = t("Restoring both versions…");
|
|
111
|
+
state('busy');
|
|
112
|
+
for (const p of panes) {
|
|
113
|
+
p.target = rows[i][p.side];
|
|
114
|
+
p.confirmed = false;
|
|
115
|
+
}
|
|
116
|
+
// Even a pane that stays on the same step must confirm this goto again.
|
|
117
|
+
for (const p of panes) send(p);
|
|
118
|
+
controls();
|
|
119
|
+
positioned();
|
|
120
|
+
if (waiting)
|
|
121
|
+
timeout = setTimeout(() => { invalidate(); $('status').textContent = t("Player did not confirm its position. Reload players or realign to retry."); }, 12000);
|
|
122
|
+
}
|
|
123
|
+
function forcedContext(s) { return s.status === 'unchanged' || s.reasons.length > 0; }
|
|
124
|
+
function makeRows() {
|
|
125
|
+
const s = m.scenarios[selected];
|
|
126
|
+
let b = 0, a = 0;
|
|
127
|
+
const all = [{ before: 0, after: 0, step: null, changed: s.reasons.length > 0 || s.steps.length === 0 }];
|
|
128
|
+
for (const r of s.steps) {
|
|
129
|
+
b = r.before?.position ?? b;
|
|
130
|
+
a = r.after?.position ?? a;
|
|
131
|
+
all.push({ before: b, after: a, step: r, changed: r.status !== 'unchanged' });
|
|
132
|
+
}
|
|
133
|
+
// Shared screen / theme changes affect the entire scenario, including otherwise identical steps.
|
|
134
|
+
rows = fullContext || forcedContext(s) ? all : all.filter(r => r.changed);
|
|
135
|
+
// The toggle only matters when it would hide something.
|
|
136
|
+
$('scope').hidden = forcedContext(s) || all.slice(1).every(r => r.changed);
|
|
137
|
+
$('full-context').textContent = `${t('Full flow')} · ${plural(all.length - 1, '{n} step', '{n} steps')}`;
|
|
138
|
+
button('only-changes').setAttribute('aria-pressed', String(!fullContext));
|
|
139
|
+
button('full-context').setAttribute('aria-pressed', String(fullContext));
|
|
140
|
+
}
|
|
141
|
+
function renderChange() { renderCard(); renderPanes(); }
|
|
142
|
+
/** Visible result values that changed (state, toast, outcome): at most three rows, the rest counted. */
|
|
143
|
+
function resultsEl(results) {
|
|
144
|
+
const box = el('div', 'results');
|
|
145
|
+
const value = (v, cls) => v === null ? Object.assign(el('span', 'val none', '—'), { title: t("Not produced by this step") }) : el('span', `val ${cls}`, v);
|
|
146
|
+
for (const r of results.slice(0, 3)) {
|
|
147
|
+
const line = el('div', 'result');
|
|
148
|
+
line.append(r.kind === 'state' ? el('code', 'key', r.label) : el('span', 'key', r.kind === 'message' ? t("Message") : t("Outcome")), value(r.before, 'old'), el('span', 'to', '→'), value(r.after, 'new'));
|
|
149
|
+
box.append(line);
|
|
150
|
+
}
|
|
151
|
+
if (results.length > 3) box.append(el('p', 'note', t('+{n} more', { n: results.length - 3 })));
|
|
152
|
+
return box;
|
|
153
|
+
}
|
|
154
|
+
function renderCard() {
|
|
155
|
+
const s = m.scenarios[selected], r = rows[index];
|
|
156
|
+
const detail = $('detail');
|
|
157
|
+
detail.replaceChildren();
|
|
158
|
+
if (!s || !r) { $('change').hidden = true; return; }
|
|
159
|
+
$('change').hidden = false;
|
|
160
|
+
const step = r.step, status = step ? step.status : r.changed ? 'modified' : 'unchanged';
|
|
161
|
+
$('change').className = `change ${status}`;
|
|
162
|
+
const quote = (text, cls = '') => el('p', `quote ${cls}`, `“${text}”`);
|
|
163
|
+
const note = (text) => el('p', 'note', text);
|
|
164
|
+
if (!step) {
|
|
165
|
+
$('kind').textContent = t("Initial state");
|
|
166
|
+
detail.append(s.reasons.length ? el('p', 'quote plain', s.reasons.map(x => reasons[x] ?? x).join(' · ')) : note(t("Starting point before the first step.")));
|
|
167
|
+
if (s.reasons.length) detail.append(note(t("These changes apply to the whole scenario, so every step is shown.")));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (status === 'added') {
|
|
171
|
+
$('kind').textContent = s.before ? t("New step inserted") : t("New scenario");
|
|
172
|
+
detail.append(quote(caption(step)));
|
|
173
|
+
if (s.before) detail.append(note(t("The old version has no such step; it pauses just before it.")));
|
|
174
|
+
}
|
|
175
|
+
else if (status === 'removed') {
|
|
176
|
+
$('kind').textContent = s.after ? t("Step removed in the new version") : t("Removed scenario");
|
|
177
|
+
detail.append(quote(caption(step), 'gone'));
|
|
178
|
+
if (s.after) detail.append(note(t("The new version no longer has this step; it pauses just before it.")));
|
|
179
|
+
}
|
|
180
|
+
else if (status === 'modified' && step.before?.caption && step.after?.caption && step.before.caption !== step.after.caption) {
|
|
181
|
+
$('kind').textContent = `${t("This step changed:")} ${step.reasons.map(x => stepReasons[x] ?? x).join(' · ')}`;
|
|
182
|
+
for (const [side, cls] of [['before', 'old'], ['after', 'new']]) {
|
|
183
|
+
const line = el('div', `line ${cls}`);
|
|
184
|
+
line.append(el('span', 'tag', `${side === 'before' ? t('Old') : t('New')} ${step[side].position}`), el('span', 'text', step[side].caption));
|
|
185
|
+
detail.append(line);
|
|
186
|
+
}
|
|
187
|
+
if (step.results?.length) detail.append(resultsEl(step.results));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
$('kind').textContent = status === 'modified' ? `${t("This step changed:")} ${step.reasons.map(x => stepReasons[x] ?? x).join(' · ')}` : labels[status];
|
|
191
|
+
detail.append(quote(caption(step)));
|
|
192
|
+
if (step.results?.length) detail.append(resultsEl(step.results));
|
|
193
|
+
detail.append(note(where(step)));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function select(i) {
|
|
197
|
+
stop();
|
|
198
|
+
clearTimeout(timeout);
|
|
199
|
+
selected = i;
|
|
200
|
+
// Each scenario starts on the new version; added/removed steps then pick the side that has them.
|
|
201
|
+
focus = 'after';
|
|
202
|
+
panes = [];
|
|
203
|
+
$('players').replaceChildren();
|
|
204
|
+
$('sides').replaceChildren();
|
|
205
|
+
const s = m.scenarios[i];
|
|
206
|
+
$('feature').textContent = s.featureName;
|
|
207
|
+
$('title').textContent = s.name;
|
|
208
|
+
$('badge').textContent = labels[s.status];
|
|
209
|
+
$('badge').className = `badge ${s.status}`;
|
|
210
|
+
$('badge').hidden = false;
|
|
211
|
+
const n = (st) => s.steps.filter(x => x.status === st).length;
|
|
212
|
+
const parts = !s.before || !s.after ? [plural(s.steps.length, '{n} step', '{n} steps')] : [
|
|
213
|
+
n('added') && t('{n} added', { n: n('added') }), n('modified') && t('{n} modified', { n: n('modified') }),
|
|
214
|
+
n('removed') && t('{n} removed', { n: n('removed') }), n('uncertain') && t('{n} uncertain', { n: n('uncertain') }),
|
|
215
|
+
...s.reasons.map(r => reasons[r] ?? r),
|
|
216
|
+
].filter(Boolean);
|
|
217
|
+
$('summary').textContent = parts.join(' · ');
|
|
218
|
+
$('notice').textContent = s.status === 'uncertain' ? t("Repeated actions cannot be aligned reliably. Unmatched steps are shown separately; add stable keys to resolve.") : '';
|
|
219
|
+
$('notice').hidden = s.status !== 'uncertain';
|
|
220
|
+
for (const side of ['before', 'after']) {
|
|
221
|
+
const scenario = s[side];
|
|
222
|
+
if (!scenario)
|
|
223
|
+
continue;
|
|
224
|
+
const wrap = el('div', 'pane');
|
|
225
|
+
const head = el('div', 'pane-head');
|
|
226
|
+
const name = el('span', 'pane-name', side === 'before' ? t("Before") : t("After"));
|
|
227
|
+
const chip = el('span', 'chip', t("No counterpart · paused before"));
|
|
228
|
+
const stepEl = el('span', 'pane-step');
|
|
229
|
+
const zoom = el('button', 'zoom', t("Show only this version"));
|
|
230
|
+
head.append(el('span', 'dot'), name, el('code', '', shas[side]), el('span', 'grow'), chip, stepEl, zoom);
|
|
231
|
+
// Like a multi-stream view: clicking a pane's bar enlarges just that version.
|
|
232
|
+
head.onclick = () => show(side, 'single');
|
|
233
|
+
head.title = t("Show only this version");
|
|
234
|
+
zoom.onclick = (e) => { e?.stopPropagation?.(); show(side, 'single'); };
|
|
235
|
+
const tab = el('button', 'tab');
|
|
236
|
+
const tabChip = el('span', 'chip', chip.textContent), tabStep = el('span', 'pane-step');
|
|
237
|
+
tab.append(el('span', 'dot'), el('span', 'pane-name', name.textContent), el('code', '', shas[side]), tabStep, tabChip);
|
|
238
|
+
tab.onclick = () => show(side);
|
|
239
|
+
tab.onmousedown = keepFocus;
|
|
240
|
+
head.onmousedown = keepFocus;
|
|
241
|
+
$('sides').append(tab);
|
|
242
|
+
const iframe = document.createElement('iframe');
|
|
243
|
+
iframe.title = name.textContent;
|
|
244
|
+
// Opaque sandbox keeps untrusted scripts in either build away from the viewer and its sibling.
|
|
245
|
+
iframe.setAttribute('sandbox', 'allow-scripts');
|
|
246
|
+
iframe.setAttribute('allow', "autoplay 'none'");
|
|
247
|
+
const pane = { iframe, side, scenario, ready: false, scenarios: new Map(), actual: null, confirmed: false, target: 0, wrap, tab, chips: [chip, tabChip], stepEls: [stepEl, tabStep] };
|
|
248
|
+
panes.push(pane);
|
|
249
|
+
iframe.src = `${side}/index.html?embed=1&review=1&diff=1&locale=${encodeURIComponent(locale)}&scenario=${encodeURIComponent(scenario)}`;
|
|
250
|
+
wrap.append(head, iframe);
|
|
251
|
+
$('players').append(wrap);
|
|
252
|
+
}
|
|
253
|
+
makeRows();
|
|
254
|
+
navigation();
|
|
255
|
+
go(0);
|
|
256
|
+
}
|
|
257
|
+
function renderPanes() {
|
|
258
|
+
const r = rows[index], step = r?.step, two = panes.length > 1;
|
|
259
|
+
if (!panes.some(p => p.side === focus) && panes.length) focus = panes[panes.length - 1].side;
|
|
260
|
+
const single = !two || layout === 'single';
|
|
261
|
+
$('players').className = `players ${single ? 'single' : 'split'}`;
|
|
262
|
+
$('sides').hidden = !single;
|
|
263
|
+
$('view').hidden = !two;
|
|
264
|
+
$('flip-hint').hidden = !two;
|
|
265
|
+
$('flip-hint').textContent = single ? t("Space flips between versions") : t("Click a version's bar to enlarge it");
|
|
266
|
+
button('view-single').setAttribute('aria-pressed', String(single));
|
|
267
|
+
button('view-split').setAttribute('aria-pressed', String(!single));
|
|
268
|
+
for (const p of panes) {
|
|
269
|
+
const missing = !!step && !step[p.side];
|
|
270
|
+
for (const c of p.chips) c.hidden = !missing || !two;
|
|
271
|
+
const hl = !step ? (r?.changed ? 'modified' : '') : step.status === 'added' ? (p.side === 'after' ? 'added' : '') : step.status === 'removed' ? (p.side === 'before' ? 'removed' : '') : step.status === 'unchanged' ? '' : step.status;
|
|
272
|
+
const front = p.side === focus;
|
|
273
|
+
p.wrap.className = `pane${hl ? ' hl-' + hl : ''}${missing ? ' paused' : ''}${front ? ' front' : ''}`;
|
|
274
|
+
p.tab.className = `tab${hl ? ' hl-' + hl : ''}`;
|
|
275
|
+
p.tab.setAttribute('aria-pressed', String(front));
|
|
276
|
+
// The stacked player behind is only hidden visually; keep it out of the accessibility tree and tab order.
|
|
277
|
+
p.wrap.setAttribute('aria-hidden', String(single && !front));
|
|
278
|
+
p.iframe.setAttribute('tabindex', single && !front ? '-1' : '0');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Mouse clicks on stage controls must not keep focus there, or the next Space re-clicks the control
|
|
282
|
+
// instead of flipping. Keyboard focus (Tab) still works and keeps native Space/Enter activation.
|
|
283
|
+
function keepFocus(e) { e?.preventDefault?.(); }
|
|
284
|
+
/** Bring one version to the front; optionally switch layout (side-by-side → enlarge one). */
|
|
285
|
+
function show(side, nextLayout) {
|
|
286
|
+
if (!panes.some(p => p.side === side)) return;
|
|
287
|
+
focus = side;
|
|
288
|
+
if (nextLayout) setLayout(nextLayout);
|
|
289
|
+
else renderPanes();
|
|
290
|
+
}
|
|
291
|
+
function setLayout(next) {
|
|
292
|
+
layout = next;
|
|
293
|
+
try { localStorage.setItem('joplo-diff-layout', next); } catch { /* storage unavailable */ }
|
|
294
|
+
renderPanes();
|
|
295
|
+
}
|
|
296
|
+
function flip() {
|
|
297
|
+
if (panes.length < 2) return;
|
|
298
|
+
show(focus === 'after' ? 'before' : 'after', 'single');
|
|
299
|
+
}
|
|
300
|
+
function navigation() {
|
|
301
|
+
const nav = $('scenarios');
|
|
302
|
+
nav.replaceChildren();
|
|
303
|
+
rowButtons = [];
|
|
304
|
+
let group = null, hidden = 0;
|
|
305
|
+
m.scenarios.forEach((s, i) => {
|
|
306
|
+
if (s.status === 'unchanged' && !check('unchanged').checked) {
|
|
307
|
+
hidden++;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (!group || group.id !== s.featureId) {
|
|
311
|
+
group = { id: s.featureId };
|
|
312
|
+
nav.append(el('p', 'group', s.featureName));
|
|
313
|
+
}
|
|
314
|
+
const b = el('button', 'scenario');
|
|
315
|
+
const changes = s.steps.filter(x => x.status !== 'unchanged').length;
|
|
316
|
+
const meta = !s.before || !s.after ? plural(s.steps.length, '{n} step', '{n} steps') : s.status === 'unchanged' ? '' : plural(changes + (s.reasons.length ? 1 : 0), '{n} change', '{n} changes');
|
|
317
|
+
b.append(el('span', `badge ${s.status}`, labels[s.status]), el('span', 'name', s.name), el('span', 'meta', meta));
|
|
318
|
+
b.setAttribute('aria-current', String(selected === i));
|
|
319
|
+
b.onclick = () => select(i);
|
|
320
|
+
nav.append(b);
|
|
321
|
+
if (selected !== i)
|
|
322
|
+
return;
|
|
323
|
+
const list = el('div', 'changes');
|
|
324
|
+
rows.forEach((r, j) => {
|
|
325
|
+
const c = el('button', `row ${r.step ? r.step.status : r.changed ? 'modified' : 'unchanged'}`);
|
|
326
|
+
const text = el('span', 'row-text');
|
|
327
|
+
text.append(el('span', 'row-caption', r.step ? caption(r.step) : t("Initial state")));
|
|
328
|
+
const sub = el('span', 'row-meta');
|
|
329
|
+
sub.append(el('b', '', r.step ? labels[r.step.status] : r.changed ? labels.modified : labels.unchanged));
|
|
330
|
+
if (r.step) sub.append(el('code', '', where(r.step)));
|
|
331
|
+
text.append(sub);
|
|
332
|
+
c.append(el('span', 'num', String(j + 1)), text);
|
|
333
|
+
c.setAttribute('aria-current', String(j === index));
|
|
334
|
+
c.onclick = () => { stop(); go(j); };
|
|
335
|
+
rowButtons.push(c);
|
|
336
|
+
list.append(c);
|
|
337
|
+
});
|
|
338
|
+
nav.append(list);
|
|
339
|
+
});
|
|
340
|
+
$('hidden-note').textContent = hidden ? t('{n} unchanged scenarios hidden', { n: hidden }) : '';
|
|
341
|
+
$('hidden-note').hidden = !hidden;
|
|
342
|
+
}
|
|
343
|
+
window.addEventListener('message', e => {
|
|
344
|
+
const p = panes.find(p => p.iframe.contentWindow === e.source);
|
|
345
|
+
if (!p || !e.data || e.data.protocol !== 1)
|
|
346
|
+
return;
|
|
347
|
+
if (e.data.type === 'joplo:ready' && Array.isArray(e.data.scenarios) && e.data.scenarios.every(s => s && typeof s.id === 'string' && s.id && Number.isSafeInteger(s.steps) && s.steps >= 0)) {
|
|
348
|
+
if (p.ready && !waiting) independentMove();
|
|
349
|
+
p.scenarios = new Map(e.data.scenarios.map(s => [s.id, s.steps]));
|
|
350
|
+
p.ready = p.scenarios.has(p.scenario) && p.scenarios.get(p.scenario) >= p.target;
|
|
351
|
+
p.actual = null;
|
|
352
|
+
p.confirmed = false;
|
|
353
|
+
paneStep(p);
|
|
354
|
+
send(p);
|
|
355
|
+
}
|
|
356
|
+
if (e.data.type === 'joplo:position' && p.ready && typeof e.data.scenario === 'string' && p.scenarios.has(e.data.scenario) && Number.isSafeInteger(e.data.step) && e.data.step >= 0 && e.data.step <= p.scenarios.get(e.data.scenario)) {
|
|
357
|
+
const previous = p.actual;
|
|
358
|
+
p.actual = { scenario: e.data.scenario, step: e.data.step };
|
|
359
|
+
const matches = p.actual.scenario === p.scenario && p.actual.step === p.target;
|
|
360
|
+
if (!matches) {
|
|
361
|
+
// An initial/previous step can arrive while goto is pending. A different
|
|
362
|
+
// scenario or a newly observed independent step must stop synchronization.
|
|
363
|
+
if (p.actual.scenario !== p.scenario || !waiting || p.confirmed || (previous && (previous.scenario !== p.actual.scenario || previous.step !== p.actual.step))) independentMove();
|
|
364
|
+
p.confirmed = false;
|
|
365
|
+
}
|
|
366
|
+
else if (waiting && !misaligned) {
|
|
367
|
+
p.confirmed = true;
|
|
368
|
+
positioned();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
button('prev').onclick = () => { stop(); go(index - 1); };
|
|
373
|
+
button('next').onclick = () => { stop(); go(index + 1); };
|
|
374
|
+
button('play').onclick = () => { if (playing)
|
|
375
|
+
stop();
|
|
376
|
+
else {
|
|
377
|
+
playing = true;
|
|
378
|
+
button('play').textContent = t("Pause");
|
|
379
|
+
button('play').className = 'primary pause';
|
|
380
|
+
go(index === rows.length - 1 ? 0 : index);
|
|
381
|
+
} };
|
|
382
|
+
button('align').onclick = () => { stop(); go(index); };
|
|
383
|
+
button('reload').onclick = () => { if (selected >= 0)
|
|
384
|
+
select(selected); };
|
|
385
|
+
const scope = (full) => { if (fullContext === full) return; stop(); fullContext = full; if (selected >= 0) {
|
|
386
|
+
makeRows();
|
|
387
|
+
navigation();
|
|
388
|
+
go(0);
|
|
389
|
+
} };
|
|
390
|
+
button('only-changes').onclick = () => scope(false);
|
|
391
|
+
button('view-single').onmousedown = keepFocus;
|
|
392
|
+
button('view-split').onmousedown = keepFocus;
|
|
393
|
+
button('view-single').onclick = () => setLayout('single');
|
|
394
|
+
button('view-split').onclick = () => setLayout('split');
|
|
395
|
+
// Space flips versions while the page (not a control or a player) has focus; players handle their own keys.
|
|
396
|
+
document.onkeydown = (e) => {
|
|
397
|
+
if (e.key !== ' ' || e.metaKey || e.ctrlKey || e.altKey || e.target?.closest?.('button,input,select,textarea,a,iframe,[contenteditable]')) return;
|
|
398
|
+
if (panes.length < 2) return;
|
|
399
|
+
e.preventDefault();
|
|
400
|
+
flip();
|
|
401
|
+
};
|
|
402
|
+
button('full-context').onclick = () => scope(true);
|
|
403
|
+
check('unchanged').onchange = navigation;
|
|
404
|
+
stop();
|
|
405
|
+
state('idle');
|
|
406
|
+
$('change').hidden = true;
|
|
407
|
+
$('notice').hidden = true;
|
|
408
|
+
$('badge').hidden = true;
|
|
409
|
+
$('scope').hidden = true;
|
|
410
|
+
navigation();
|
|
411
|
+
const first = m.scenarios.findIndex(s => s.status !== 'unchanged');
|
|
412
|
+
if (m.status === 'incompatible') {
|
|
413
|
+
$('title').textContent = t("Incompatible builds");
|
|
414
|
+
$('notice').textContent = t("Rebuild both versions with compatible Joplo versions. Missing baselines are never treated as new features.");
|
|
415
|
+
$('notice').hidden = false;
|
|
416
|
+
}
|
|
417
|
+
else if (first >= 0)
|
|
418
|
+
select(first);
|
|
419
|
+
else {
|
|
420
|
+
$('title').textContent = m.status === 'unchanged' ? t("No feature changes") : t("Project presentation changed");
|
|
421
|
+
$('notice').textContent = t("No changed scenario to play. Show unchanged scenarios for context.");
|
|
422
|
+
$('notice').hidden = false;
|
|
423
|
+
}
|
|
424
|
+
controls();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
viewer();
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { jsonForHtml } from "./build.js";
|
|
3
|
+
/** Icons are CSS masks so the runtime can keep replacing button text without touching markup. */
|
|
4
|
+
const icon = (paths) => `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${paths}</svg>`)}")`;
|
|
5
|
+
const ICONS = {
|
|
6
|
+
prev: icon('<path d="m15 18-6-6 6-6"/>'),
|
|
7
|
+
next: icon('<path d="m9 18 6-6-6-6"/>'),
|
|
8
|
+
play: icon('<path d="M6 4v16l14-8z"/>'),
|
|
9
|
+
pause: icon('<path d="M8 5v14M16 5v14"/>'),
|
|
10
|
+
reload: icon('<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>'),
|
|
11
|
+
align: icon('<path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 3v5h-5M3 21v-5h5"/>'),
|
|
12
|
+
arrow: icon('<path d="M5 12h14m-6-6 6 6-6 6"/>'),
|
|
13
|
+
expand: icon('<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>'),
|
|
14
|
+
single: icon('<rect x="3" y="4" width="18" height="16" rx="2"/>'),
|
|
15
|
+
split: icon('<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M12 4v16"/>'),
|
|
16
|
+
hidden: icon('<path d="M10.7 5.1A10 10 0 0 1 22 12a13 13 0 0 1-1.7 2.7M6.6 6.6A13.5 13.5 0 0 0 2 12s3 7 10 7a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/>'),
|
|
17
|
+
};
|
|
18
|
+
const MARK = '<svg width="24" height="24" viewBox="0 0 128 128" aria-hidden="true"><rect x="4" y="4" width="120" height="120" rx="30" fill="#FFD23F"/><circle cx="40" cy="40" r="9" fill="#1E1E1E"/><circle cx="43" cy="36" r="3" fill="#fff"/><circle cx="87" cy="40" r="9" fill="#1E1E1E"/><circle cx="90" cy="36" r="3" fill="#fff"/><path d="M93 60V72Q93 100 63 100Q41 100 31 82" fill="none" stroke="#1E1E1E" stroke-width="11" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
19
|
+
/** Tab icon: the same mark, standalone SVG so the viewer needs no extra file. */
|
|
20
|
+
const FAVICON = 'data:image/svg+xml,' + encodeURIComponent(MARK.replace('<svg width="24" height="24"', '<svg xmlns="http://www.w3.org/2000/svg"').replace(' aria-hidden="true"', ''));
|
|
21
|
+
// Tokens mirror design/joplo-board.pen「设计 Token v1」; layout follows「功能差异 · 单画面(默认)」.
|
|
22
|
+
const CSS = `
|
|
23
|
+
:root{--app:#f4f1ea;--surface:#fff;--sunken:#ece8de;--selected:#fff2bf;--fg:#1e1e1e;--muted:#6e6a60;--faint:#9c978b;--line:#ddd8cc;--accent:#ffd23f;--accent-press:#e0ae00;
|
|
24
|
+
--ok:#2f7a47;--ok-bg:#e5f2e8;--mod:#6b5000;--mod-bg:#fff2bf;--bad:#c8402f;--bad-bg:#fbe7e3;--mono:ui-monospace,"JetBrains Mono",SFMono-Regular,Menlo,monospace}
|
|
25
|
+
*{box-sizing:border-box}[hidden]{display:none!important}
|
|
26
|
+
html,body{height:100%}body{margin:0;background:var(--app);color:var(--fg);font:14px/1.5 "Noto Sans SC",system-ui,-apple-system,"PingFang SC","Segoe UI",sans-serif;display:flex;flex-direction:column}
|
|
27
|
+
button{font:inherit;color:inherit;background:var(--surface);border:1px solid var(--line);border-radius:8px;cursor:pointer}
|
|
28
|
+
button:disabled{opacity:.4;cursor:default}button:focus-visible,input:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
|
|
29
|
+
code{font-family:var(--mono);font-size:12px}
|
|
30
|
+
.i::before,.zoom::before,#view button::before,#prev::before,#next::after,#play::before,#reload::before,#align::before{content:"";width:16px;height:16px;flex:none;background:currentColor;-webkit-mask:var(--i) center/contain no-repeat;mask:var(--i) center/contain no-repeat}
|
|
31
|
+
.top{height:52px;flex:none;display:flex;align-items:center;gap:12px;padding:0 16px;background:var(--surface);border-bottom:1px solid var(--line);min-width:0}
|
|
32
|
+
.brand{display:flex;align-items:center;gap:7px;font-weight:800;font-size:17px;letter-spacing:-.3px}.sep{width:1px;height:20px;background:var(--line)}
|
|
33
|
+
h1{font-size:14px;font-weight:600;margin:0;white-space:nowrap}
|
|
34
|
+
.range{display:flex;align-items:center;gap:6px;padding:3px 8px;border-radius:6px;background:var(--sunken);color:var(--muted);white-space:nowrap}.range #head{color:var(--fg)}
|
|
35
|
+
.range .i{--i:${ICONS.arrow};display:flex;color:var(--faint)}.range .i::before{width:12px;height:12px}
|
|
36
|
+
.totals{display:flex;gap:6px}.pill{display:flex;gap:4px;padding:2px 8px;border-radius:999px;font-size:12px;white-space:nowrap}.pill b{font-weight:700}
|
|
37
|
+
.added{--c:var(--ok);--bg:var(--ok-bg)}.modified,.uncertain{--c:var(--mod);--bg:var(--mod-bg)}.removed{--c:var(--bad);--bg:var(--bad-bg)}.unchanged{--c:var(--muted);--bg:var(--sunken)}
|
|
38
|
+
.pill,.badge{color:var(--c);background:var(--bg)}
|
|
39
|
+
.grow{flex:1;min-width:0}
|
|
40
|
+
.switch{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;cursor:pointer;white-space:nowrap}
|
|
41
|
+
.switch input{appearance:none;-webkit-appearance:none;margin:0;width:28px;height:16px;border-radius:999px;background:#ddd8cc;position:relative;cursor:pointer;transition:background .15s}
|
|
42
|
+
.switch input::after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .15s}
|
|
43
|
+
.switch input:checked{background:var(--fg)}.switch input:checked::after{transform:translateX(12px)}#unchanged-count{color:var(--faint);font-size:12px}
|
|
44
|
+
.layout{flex:1;min-height:0;display:grid;grid-template-columns:296px minmax(0,1fr)}
|
|
45
|
+
aside{background:var(--surface);border-right:1px solid var(--line);display:flex;flex-direction:column;padding:16px 12px;min-height:0;overflow:auto}
|
|
46
|
+
nav{display:flex;flex-direction:column;gap:2px}
|
|
47
|
+
.group{margin:0;padding:12px 8px 6px;font-size:12px;font-weight:600;color:var(--muted);overflow-wrap:anywhere}.group:first-child{padding-top:0}
|
|
48
|
+
.badge{flex:none;display:inline-block;padding:1px 6px;border-radius:4px;font-size:11px;font-weight:600;line-height:18px;white-space:nowrap}
|
|
49
|
+
.scenario{display:flex;align-items:center;gap:8px;width:100%;padding:9px 10px;border:0;border-radius:8px;background:none;text-align:left}
|
|
50
|
+
.scenario:hover{background:var(--app)}.scenario[aria-current=true]{background:var(--selected)}.scenario[aria-current=true] .name{font-weight:600}
|
|
51
|
+
.scenario .name{flex:1;min-width:0;font-size:13.5px;line-height:1.4;overflow-wrap:anywhere}.meta{flex:none;font-size:11px;color:var(--faint)}
|
|
52
|
+
.changes{display:flex;flex-direction:column;gap:2px;padding:4px 0 8px 22px}
|
|
53
|
+
.row{display:flex;gap:10px;align-items:flex-start;width:100%;padding:7px 10px;border:1px solid transparent;border-radius:6px;background:none;text-align:left}
|
|
54
|
+
.row:hover{background:var(--app)}.row[aria-current=true]{background:var(--surface);border-color:var(--fg)}
|
|
55
|
+
.num{flex:none;width:18px;height:18px;margin-top:1px;border-radius:50%;background:var(--sunken);color:var(--muted);font-size:11px;font-weight:600;display:grid;place-items:center}
|
|
56
|
+
.row[aria-current=true] .num{background:var(--fg);color:#fff}
|
|
57
|
+
.row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
58
|
+
.row-caption{font-size:13px;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}.row[aria-current=true] .row-caption{font-weight:600}
|
|
59
|
+
.row.unchanged .row-caption{color:var(--muted)}
|
|
60
|
+
.row-meta{display:flex;gap:6px;align-items:baseline;font-size:11px;color:var(--faint)}.row-meta b{color:var(--c);font-weight:600}.row-meta code{font-size:11px}
|
|
61
|
+
#hidden-note{margin:auto 0 0;padding:16px 10px 8px;display:flex;gap:8px;align-items:center;font-size:12px;color:var(--faint)}
|
|
62
|
+
#hidden-note::before{content:"";width:14px;height:14px;flex:none;background:currentColor;-webkit-mask:${ICONS.hidden} center/contain no-repeat;mask:${ICONS.hidden} center/contain no-repeat}
|
|
63
|
+
#disclaimer{margin:0;padding:0 10px;font-size:11px;line-height:1.5;color:var(--faint)}#hidden-note[hidden]+#disclaimer{margin-top:auto;padding-top:16px}
|
|
64
|
+
main{display:flex;flex-direction:column;gap:12px;padding:16px 24px 14px;min-width:0;min-height:0;overflow:auto}
|
|
65
|
+
#feature{margin:0 0 6px;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
|
|
66
|
+
.title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}h2{margin:0;font-size:22px;line-height:1.3;overflow-wrap:anywhere}
|
|
67
|
+
.title-row .badge{font-size:12px;padding:2px 8px}#summary{font-size:13px;color:var(--muted)}
|
|
68
|
+
.notice{margin:10px 0 0;padding:10px 14px;border-radius:8px;background:var(--mod-bg);color:var(--mod);font-size:13px;overflow-wrap:anywhere}
|
|
69
|
+
.change{display:flex;align-items:center;gap:16px;padding:14px 16px;background:var(--surface);border:1px solid var(--line);border-radius:10px}
|
|
70
|
+
.change::before{content:"";align-self:stretch;width:4px;border-radius:2px;background:var(--c);flex:none}.change.modified::before{background:var(--accent-press)}
|
|
71
|
+
.change-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}
|
|
72
|
+
.change-meta{display:flex;gap:8px;align-items:baseline;font-size:12px;color:var(--faint);flex-wrap:wrap}#counter{font-variant-numeric:tabular-nums}#kind{font-weight:600;color:var(--c)}
|
|
73
|
+
.quote{margin:0;font-size:16px;font-weight:600;overflow-wrap:anywhere}.quote.gone{text-decoration:line-through;color:var(--bad)}.quote.plain{font-size:15px}
|
|
74
|
+
.note{margin:0;font-size:12px;color:var(--muted)}
|
|
75
|
+
.line{display:flex;gap:10px;align-items:baseline}.line .tag{flex:none;font-size:12px;color:var(--faint);min-width:36px}
|
|
76
|
+
.line .text{padding:1px 6px;border-radius:4px;font-size:15px;font-weight:600;overflow-wrap:anywhere}.line.old .text{background:var(--bad-bg);color:var(--bad);text-decoration:line-through}.line.new .text{background:var(--ok-bg);color:var(--ok)}
|
|
77
|
+
.results{display:flex;flex-direction:column;gap:3px;margin:2px 0}
|
|
78
|
+
.result{display:flex;align-items:baseline;gap:8px;min-width:0;font-size:13px}.result .key{flex:none;color:var(--muted);font-size:12px}.result .to{flex:none;color:var(--faint)}
|
|
79
|
+
.val{padding:0 6px;border-radius:4px;font-weight:600;overflow-wrap:anywhere;min-width:0}.val.old{background:var(--bad-bg);color:var(--bad);text-decoration:line-through}.val.new{background:var(--ok-bg);color:var(--ok)}.val.none{color:var(--faint);font-weight:400}
|
|
80
|
+
.transport{display:flex;gap:8px;flex:none}.transport button{height:36px;display:flex;align-items:center;gap:6px;padding:0 12px;font-weight:600}
|
|
81
|
+
#prev{--i:${ICONS.prev};font-size:0;gap:0;padding:0 9px}#next{--i:${ICONS.next}}#play{--i:${ICONS.play}}#play.pause{--i:${ICONS.pause}}
|
|
82
|
+
.primary{background:var(--accent);border-color:var(--fg)}.primary:not(:disabled):hover{background:var(--accent-press)}
|
|
83
|
+
.stage{flex:1;min-height:440px;display:flex;flex-direction:column;gap:8px}
|
|
84
|
+
.stage-bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:36px}
|
|
85
|
+
.sides{display:flex;gap:2px;padding:3px;border-radius:9px;background:var(--sunken);min-width:0;flex-wrap:wrap}
|
|
86
|
+
.tab{display:flex;align-items:center;gap:7px;padding:5px 12px;border:1px solid transparent;border-radius:7px;background:none;color:var(--muted);white-space:nowrap;min-width:0}
|
|
87
|
+
.tab:hover{color:var(--fg)}.tab[aria-pressed=true]{background:var(--surface);border-color:var(--fg);color:var(--fg)}
|
|
88
|
+
.tab .pane-name{font-weight:600}.tab code{color:var(--faint)}.tab .dot{background:#bdb7a9}
|
|
89
|
+
.hl-added{--c:var(--ok)}.hl-removed{--c:var(--bad)}.hl-modified,.hl-uncertain{--c:var(--accent-press)}.tab[class*=hl-] .dot{background:var(--c)}
|
|
90
|
+
.hint{font-size:12px;color:var(--faint)}
|
|
91
|
+
#view button{display:flex;align-items:center;gap:6px}#view-single{--i:${ICONS.single}}#view-split{--i:${ICONS.split}}#view button::before{width:14px;height:14px}
|
|
92
|
+
.players{flex:1;min-height:0;display:grid;gap:12px;grid-template-columns:repeat(2,minmax(0,1fr))}
|
|
93
|
+
/* Single view stacks both players in one cell; the back one stays loaded so flipping keeps size and position. */
|
|
94
|
+
.players.single{grid-template-columns:minmax(0,1fr)}.players.single .pane{grid-area:1/1}.players.single .pane:not(.front){visibility:hidden}.players.single .pane-head{display:none}
|
|
95
|
+
.players.split .pane-head{cursor:zoom-in}.players.split .pane-head:hover .zoom{color:var(--fg)}
|
|
96
|
+
.zoom{--i:${ICONS.expand};display:flex;align-items:center;gap:5px;padding:3px 8px;border:0;background:none;color:var(--muted);font-size:12px}.zoom::before{width:13px;height:13px}
|
|
97
|
+
.pane{min-width:0;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);border-radius:10px;overflow:hidden}
|
|
98
|
+
.pane-head{height:40px;flex:none;display:flex;align-items:center;gap:8px;padding:0 14px;border-bottom:1px solid var(--line);white-space:nowrap;min-width:0}
|
|
99
|
+
.pane-head .dot{background:#bdb7a9}.pane-name{font-weight:600}.pane-head code{color:var(--faint)}.pane-step{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
|
|
100
|
+
.chip{padding:1px 8px;border-radius:999px;background:var(--sunken);color:var(--muted);font-size:11px;overflow:hidden;text-overflow:ellipsis}
|
|
101
|
+
.pane.hl-added,.pane.hl-removed,.pane.hl-modified,.pane.hl-uncertain{border-color:var(--c);box-shadow:0 0 0 .5px var(--c)}
|
|
102
|
+
.pane.hl-uncertain{border-style:dashed}
|
|
103
|
+
.pane.hl-added .pane-head{background:var(--ok-bg)}.pane.hl-removed .pane-head{background:var(--bad-bg)}.pane.hl-modified .pane-head,.pane.hl-uncertain .pane-head{background:#fffbea}
|
|
104
|
+
.pane[class*=hl-] .pane-head .dot{background:var(--c)}
|
|
105
|
+
iframe{flex:1;width:100%;min-height:360px;border:0;display:block;background:#fff}.pane.paused iframe{opacity:.9}
|
|
106
|
+
.statusbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px}
|
|
107
|
+
.dot{width:8px;height:8px;border-radius:50%;flex:none;background:var(--faint)}.dot.ok{background:var(--ok)}.dot.warn{background:var(--accent-press)}.dot.busy{background:var(--faint);animation:pulse 1s ease-in-out infinite}
|
|
108
|
+
@keyframes pulse{50%{opacity:.3}}@media (prefers-reduced-motion:reduce){.dot.busy{animation:none}}
|
|
109
|
+
#status{margin:0;color:var(--muted)}.statusbar:has(.dot.warn) #status{color:var(--mod)}
|
|
110
|
+
#align{--i:${ICONS.align};height:28px;display:flex;align-items:center;gap:6px;padding:0 10px;font-weight:600;border-color:var(--fg)}#align::before{width:13px;height:13px}
|
|
111
|
+
.seg{display:flex;gap:2px;padding:2px;border-radius:8px;background:var(--sunken)}.seg button{border:1px solid transparent;background:none;padding:4px 10px;border-radius:6px;color:var(--muted);font-size:12px}
|
|
112
|
+
.seg button[aria-pressed=true]{background:var(--surface);border-color:var(--line);color:var(--fg);font-weight:600}
|
|
113
|
+
#reload{--i:${ICONS.reload};border:0;background:none;display:flex;align-items:center;gap:6px;padding:4px 8px;color:var(--muted);font-size:12px}#reload::before{width:14px;height:14px}#reload:hover{color:var(--fg)}
|
|
114
|
+
@media(max-width:1100px){.totals,#unchanged-count{display:none}.layout{grid-template-columns:248px minmax(0,1fr)}}
|
|
115
|
+
@media(max-width:900px){body{display:block;height:auto}.top{flex-wrap:wrap;height:auto;padding:10px 14px}.layout{display:block}
|
|
116
|
+
aside{border-right:0;border-bottom:1px solid var(--line);max-height:none}main{padding:14px;overflow:visible}
|
|
117
|
+
.change{flex-wrap:wrap}.transport{width:100%}.transport #play{flex:1;justify-content:center}.players.split{grid-template-columns:minmax(0,1fr)}iframe{min-height:56vh}}
|
|
118
|
+
`;
|
|
119
|
+
/** A small public shell around the existing shipped players; no authoring runtime is loaded. */
|
|
120
|
+
export function diffViewerHtml(manifest) {
|
|
121
|
+
return `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/svg+xml" href="${FAVICON}"><title>Joplo · Feature diff</title>
|
|
122
|
+
<style>${CSS}</style>
|
|
123
|
+
<header class="top"><span class="brand">${MARK}Joplo</span><span class="sep"></span><h1 id="page-title">Feature diff</h1><span class="range"><code id="base"></code><span class="i"></span><code id="head"></code></span><span id="totals" class="totals"></span><span class="grow"></span><label class="switch"><input id="unchanged" type="checkbox"><span data-label="unchanged">Show unchanged scenarios</span><span id="unchanged-count"></span></label></header>
|
|
124
|
+
<div class="layout"><aside><nav aria-label="Scenarios" id="scenarios"></nav><p id="hidden-note"></p><p id="disclaimer">Changes to a concept demo, not verification of the real product. Synchronized playback is muted.</p></aside>
|
|
125
|
+
<main><div><p id="feature"></p><div class="title-row"><h2 id="title"></h2><span id="badge" class="badge"></span><span id="summary"></span></div><div id="notice" class="notice"></div></div>
|
|
126
|
+
<section id="change" class="change" aria-live="polite"><div class="change-text"><div class="change-meta"><span><span id="counter-label">Change</span> <span id="counter"></span></span><span id="kind"></span></div><div id="detail"></div></div><div class="transport"><button id="prev">Previous</button><button id="play" class="primary play">Play changes</button><button id="next">Next</button></div></section>
|
|
127
|
+
<section class="stage"><div id="stage-bar" class="stage-bar"><div id="sides" class="sides" role="group"></div><span id="flip-hint" class="hint">Space flips between versions</span><span class="grow"></span><div id="view" class="seg" role="group"><button id="view-single" aria-pressed="true">Single view</button><button id="view-split" aria-pressed="false">Side by side</button></div></div><div id="players" class="players single"></div></section>
|
|
128
|
+
<div class="statusbar"><span id="dot" class="dot"></span><p id="status" role="status"></p><button id="align">Realign</button><span class="grow"></span><div id="scope" class="seg" role="group"><button id="only-changes" aria-pressed="true">Changes only</button><button id="full-context" aria-pressed="false">Full flow</button></div><button id="reload">Reload players</button></div></main></div>
|
|
129
|
+
<script type="application/json" id="joplo-diff-locales">${jsonForHtml(JSON.parse(readFileSync(new URL('./feature-diff-locales.json', import.meta.url), 'utf8')))}</script><script type="application/json" id="joplo-feature-diff">${jsonForHtml(manifest)}</script><script>${readFileSync(new URL('./feature-diff-runtime.js', import.meta.url), 'utf8')}</script></html>`;
|
|
130
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFeatureDiffBuild, type FeatureDiffManifest } from '@joplo-app/core';
|
|
2
|
+
export type DiffBuildOptions = {
|
|
3
|
+
beforeDir: string;
|
|
4
|
+
afterDir: string;
|
|
5
|
+
outDir: string;
|
|
6
|
+
baseSha?: string;
|
|
7
|
+
headSha?: string;
|
|
8
|
+
};
|
|
9
|
+
export type DiffBuildResult = {
|
|
10
|
+
outDir: string;
|
|
11
|
+
manifest: FeatureDiffManifest;
|
|
12
|
+
};
|
|
13
|
+
export declare const publicIRFromHtml: typeof readFeatureDiffBuild;
|
|
14
|
+
export declare function buildFeatureDiff(opts: DiffBuildOptions): Promise<DiffBuildResult>;
|