uwright 0.0.0-stage → 0.1.1
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/README.md +112 -2
- package/dist/browser-install.js +23 -0
- package/dist/cli-args.js +12 -0
- package/dist/cli.js +213 -0
- package/dist/diff.js +62 -0
- package/dist/driver.js +187 -0
- package/dist/e2e-lock.js +439 -0
- package/dist/e2e-preflight.js +130 -0
- package/dist/e2e-runner.js +621 -0
- package/dist/e2e-status.js +30 -0
- package/dist/lock.js +295 -0
- package/dist/mcp.js +65 -0
- package/dist/model.js +115 -0
- package/dist/navigation-action.js +43 -0
- package/dist/run-viewer.js +50 -0
- package/dist/runner.js +447 -0
- package/dist/secret-action.js +99 -0
- package/dist/tap-action.js +79 -0
- package/dist/templates/run-viewer.html +188 -0
- package/dist/templates/watch.html +538 -0
- package/dist/watch.js +412 -0
- package/dist/workspace.js +103 -0
- package/package.json +57 -4
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Uwright</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root{font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#202721;background:#f6f7f3;font-synthesis:none}
|
|
9
|
+
*{box-sizing:border-box}
|
|
10
|
+
body{margin:0}
|
|
11
|
+
button,textarea{font:inherit}
|
|
12
|
+
button{cursor:pointer}
|
|
13
|
+
button:focus-visible,a:focus-visible,textarea:focus-visible,img:focus-visible,summary:focus-visible{outline:3px solid #8bb6a3;outline-offset:2px}
|
|
14
|
+
button:disabled{cursor:not-allowed;opacity:.45}
|
|
15
|
+
.topbar{height:70px;background:#fff;border-bottom:1px solid #e6eae4;display:flex;align-items:center;padding:0 32px;gap:18px}
|
|
16
|
+
.brand{display:flex;align-items:center;gap:10px;font-weight:750;letter-spacing:-.04em;font-size:19px}
|
|
17
|
+
.mark{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:#244f3f;color:white;font-size:17px}
|
|
18
|
+
.divider{width:1px;height:24px;background:#e4e9e2}
|
|
19
|
+
.crumb{color:#7b857d;font-size:13px}
|
|
20
|
+
.topbar .spacer{flex:1}
|
|
21
|
+
.local{font-size:12px;color:#728077;display:flex;align-items:center;gap:7px}
|
|
22
|
+
.local:before{content:"";width:7px;height:7px;background:#7caa8e;border-radius:50%}
|
|
23
|
+
.shell{max-width:1600px;margin:auto;padding:36px 40px 60px}
|
|
24
|
+
.heading{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:28px}
|
|
25
|
+
.eyebrow{font-size:11px;letter-spacing:.13em;text-transform:uppercase;font-weight:750;color:#78877c;margin:0 0 9px}
|
|
26
|
+
h1{font-size:30px;letter-spacing:-.045em;line-height:1.15;margin:0;overflow-wrap:anywhere}
|
|
27
|
+
.subtitle{color:#778279;margin:8px 0 0;font-size:13px}
|
|
28
|
+
.controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
29
|
+
.btn{border:1px solid #dfe6de;background:#fff;border-radius:8px;color:#3b4b40;padding:10px 14px;font-weight:650;font-size:12px;transition:background .15s,border-color .15s}
|
|
30
|
+
.btn:hover:not(:disabled){background:#f2f6f1;border-color:#bdcfc0}
|
|
31
|
+
.btn.primary{background:#285b47;color:white;border-color:#285b47}
|
|
32
|
+
.btn.primary:hover:not(:disabled){background:#1e4938}
|
|
33
|
+
.btn[hidden]{display:none}
|
|
34
|
+
.layout{display:grid;grid-template-columns:minmax(300px,370px) minmax(0,1fr);gap:20px;align-items:start}
|
|
35
|
+
.card{background:#fff;border:1px solid #e4eae2;border-radius:13px;box-shadow:0 3px 14px #263d2810;min-width:0}
|
|
36
|
+
.plan-head{padding:22px 22px 18px;border-bottom:1px solid #edf0eb}
|
|
37
|
+
.row{display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
38
|
+
h2{font-size:15px;letter-spacing:-.02em;margin:0}
|
|
39
|
+
.muted{color:#849087;font-size:12px;line-height:1.5}
|
|
40
|
+
.plan-head .muted{margin:6px 0 0}
|
|
41
|
+
.count{font-size:11px;font-weight:700;color:#6a7b6e;background:#f2f5f0;border-radius:20px;padding:5px 9px;white-space:nowrap}
|
|
42
|
+
.progress{height:4px;border-radius:4px;background:#edf1eb;margin-top:19px;overflow:hidden}
|
|
43
|
+
.progress span{display:block;height:100%;width:0;background:#5c9a73;transition:width .3s}
|
|
44
|
+
.plan-body{padding:10px 12px 16px;max-height:calc(100vh - 290px);min-height:250px;overflow:auto}
|
|
45
|
+
ol,ul{list-style:none;margin:0;padding:0}
|
|
46
|
+
#plan ol{margin-left:20px;border-left:1px solid #e6ebe4;padding-left:10px}
|
|
47
|
+
.step{width:100%;display:flex;align-items:flex-start;gap:11px;border:0;background:transparent;border-radius:8px;text-align:left;padding:11px 10px;color:#39483d}
|
|
48
|
+
.step:hover,.step.selected{background:#f4f7f2}
|
|
49
|
+
.step.running{background:#eff5fa}
|
|
50
|
+
.step.failed{background:#fcf1ef}
|
|
51
|
+
.dot{flex:0 0 21px;width:21px;height:21px;border:1px solid #d9e2d8;border-radius:50%;display:grid;place-items:center;color:#9eaaa0;font-size:11px;font-weight:700}
|
|
52
|
+
.running .dot{background:#dceaf5;color:#315f84;border-color:#cbdfee}
|
|
53
|
+
.passed .dot{background:#dceee1;color:#397b50;border-color:#dceee1}
|
|
54
|
+
.failed .dot{background:#f9ddd9;color:#b75b4d;border-color:#f9ddd9}
|
|
55
|
+
.step-copy{min-width:0}
|
|
56
|
+
.step-label{display:block;font-size:10px;font-weight:750;letter-spacing:.08em;text-transform:uppercase;color:#9aa69c;margin:1px 0 5px}
|
|
57
|
+
.step-text{display:block;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
|
|
58
|
+
.step-detail{display:block;color:#647568;margin-top:5px;font-size:11px;line-height:1.5}
|
|
59
|
+
.passed .step-detail,.passed .step-label{color:#356d48}
|
|
60
|
+
.failed .step-detail,.failed .step-label{color:#a14337}
|
|
61
|
+
.running .step-label{color:#315f84}
|
|
62
|
+
.actions{margin:0 12px 7px 42px;color:#829085;font-size:11px;line-height:1.5}
|
|
63
|
+
.actions li{padding:3px 0}
|
|
64
|
+
.empty-plan{padding:24px 12px;color:#8b978c;font-size:12px;line-height:1.5}
|
|
65
|
+
.plan-footer{border-top:1px solid #edf0eb;padding:14px 20px}
|
|
66
|
+
.text-button{background:none;border:0;color:#47745b;font-size:12px;font-weight:700;padding:4px 0}
|
|
67
|
+
.workspace{overflow:hidden}
|
|
68
|
+
.workspace-head{padding:0 22px;display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid #edf0eb;min-height:61px}
|
|
69
|
+
.tabs{display:flex;gap:24px;align-self:stretch}
|
|
70
|
+
.tab{position:relative;border:0;background:none;color:#929d93;font-size:12px;font-weight:700;padding:0}
|
|
71
|
+
.tab.active{color:#315c43}
|
|
72
|
+
.tab.active:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background:#4e8762}
|
|
73
|
+
.badge{display:inline-flex;align-items:center;gap:7px;border-radius:20px;background:#f1f4ef;color:#758176;padding:6px 10px;font-size:11px;font-weight:700;text-transform:capitalize;white-space:nowrap}
|
|
74
|
+
.badge:before{content:"";width:7px;height:7px;background:#aeb9af;border-radius:50%}
|
|
75
|
+
.badge.running:before,.badge.starting:before{background:#6ca07b}
|
|
76
|
+
.badge.failed:before{background:#d27b6c}
|
|
77
|
+
.badge.passed:before{background:#4f986a}
|
|
78
|
+
.workspace-body{padding:22px}
|
|
79
|
+
.context{display:flex;justify-content:space-between;align-items:flex-start;gap:15px;margin-bottom:17px}
|
|
80
|
+
.context h2{font-size:14px}
|
|
81
|
+
.context p{margin:5px 0 0}
|
|
82
|
+
.screen{position:relative;background:#edf1eb;border:1px solid #e4eae2;border-radius:9px;min-height:360px;display:flex;align-items:center;justify-content:center;overflow:hidden}
|
|
83
|
+
.screen-empty{text-align:center;color:#91a094;font-size:12px;padding:30px}
|
|
84
|
+
.screen-empty strong{display:block;color:#627468;font-size:13px;margin-bottom:6px}
|
|
85
|
+
.screen img{display:none;width:100%;height:auto;outline:none}
|
|
86
|
+
.screen.has-frame img{display:block}
|
|
87
|
+
.screen.has-frame .screen-empty{display:none}
|
|
88
|
+
.screen.paused{box-shadow:0 0 0 3px #b9d8c2}
|
|
89
|
+
.editor{display:none}
|
|
90
|
+
.editor.open{display:block}
|
|
91
|
+
.editor textarea{display:block;width:100%;min-height:420px;resize:vertical;border:1px solid #e1e8df;border-radius:8px;background:#fafbf9;color:#334438;padding:16px;font:12px/1.7 ui-monospace,SFMono-Regular,monospace}
|
|
92
|
+
.editor-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px}
|
|
93
|
+
.clarification{display:none;padding:18px 22px;border-top:1px solid #edf0eb;background:#fafcf9}
|
|
94
|
+
.clarification.open{display:block}
|
|
95
|
+
.clarification p{margin:6px 0 14px}
|
|
96
|
+
.clarification label{display:block;font-size:11px;font-weight:700;color:#647568;margin:12px 0}
|
|
97
|
+
.clarification textarea{display:block;width:100%;min-height:65px;margin-top:6px;padding:9px;border:1px solid #dfe7dd;border-radius:7px;resize:vertical}
|
|
98
|
+
.clarification .btn{margin-right:6px}
|
|
99
|
+
.notice{margin:0 22px 18px;padding:11px 13px;border-radius:7px;background:#f8f5e9;color:#806c36;font-size:12px;white-space:pre-wrap}
|
|
100
|
+
.notice:empty{display:none}
|
|
101
|
+
.lower{display:flex;align-items:center;justify-content:space-between;gap:15px;padding:15px 22px;border-top:1px solid #edf0eb}
|
|
102
|
+
.lower details{flex:1;min-width:0}
|
|
103
|
+
.lower summary{cursor:pointer;color:#879489;font-size:11px;font-weight:700}
|
|
104
|
+
.lower pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:180px;overflow:auto;color:#6e7e71;font:11px/1.5 ui-monospace,monospace}
|
|
105
|
+
a{color:#47745b;font-size:12px;font-weight:700}
|
|
106
|
+
#report:empty{display:none}
|
|
107
|
+
@media(max-width:850px){.shell{padding:26px 20px 40px}
|
|
108
|
+
.layout{grid-template-columns:1fr}
|
|
109
|
+
.plan-body{max-height:400px;min-height:0}
|
|
110
|
+
.heading{align-items:flex-start;flex-direction:column}
|
|
111
|
+
.screen{min-height:240px}
|
|
112
|
+
@media(max-width:500px){.topbar{padding:0 20px}
|
|
113
|
+
.crumb,.divider,.local{display:none}
|
|
114
|
+
.shell{padding:24px 14px}
|
|
115
|
+
.workspace-body{padding:16px}
|
|
116
|
+
.workspace-head{padding:0 16px}
|
|
117
|
+
.controls{gap:6px}
|
|
118
|
+
h1{font-size:25px}
|
|
119
|
+
</style>
|
|
120
|
+
</head>
|
|
121
|
+
<body>
|
|
122
|
+
<header class="topbar">
|
|
123
|
+
<div class="brand"><span class="mark">↗</span>uwright</div>
|
|
124
|
+
<span class="divider"> </span>
|
|
125
|
+
<span class="crumb">Test workspace</span>
|
|
126
|
+
<span class="spacer"> </span>
|
|
127
|
+
<span class="local">Local session</span>
|
|
128
|
+
</header>
|
|
129
|
+
<main class="shell">
|
|
130
|
+
<div class="heading">
|
|
131
|
+
<div>
|
|
132
|
+
<p class="eyebrow">Test workspace</p>
|
|
133
|
+
<h1 id="title"></h1>
|
|
134
|
+
<p class="subtitle">Author your test, then watch it come to life.</p>
|
|
135
|
+
</div>
|
|
136
|
+
<div class="controls">
|
|
137
|
+
<button id="start" class="btn primary">▶ Start test</button>
|
|
138
|
+
<button id="pause" class="btn" hidden>Pause after step</button>
|
|
139
|
+
<button id="resume" class="btn primary" hidden>Resume</button>
|
|
140
|
+
<button id="stop" class="btn" hidden>Stop</button>
|
|
141
|
+
<button id="rerun" class="btn primary" hidden>
|
|
142
|
+
↻ Run again
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="layout">
|
|
147
|
+
<aside class="card">
|
|
148
|
+
<div class="plan-head">
|
|
149
|
+
<div class="row">
|
|
150
|
+
<h2>Test plan</h2>
|
|
151
|
+
<span id="count" class="count">0 steps</span>
|
|
152
|
+
</div>
|
|
153
|
+
<p class="muted">Your steps and checks, in order.</p>
|
|
154
|
+
<div
|
|
155
|
+
class="progress"
|
|
156
|
+
role="progressbar"
|
|
157
|
+
aria-label="Test progress"
|
|
158
|
+
aria-valuemin="0"
|
|
159
|
+
aria-valuemax="100"
|
|
160
|
+
aria-valuenow="0"
|
|
161
|
+
>
|
|
162
|
+
<span id="progress"> </span>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="plan-body">
|
|
166
|
+
<ol id="plan"></ol>
|
|
167
|
+
<p id="empty-plan" class="empty-plan">Preparing your test plan…</p>
|
|
168
|
+
</div>
|
|
169
|
+
<div class="plan-footer">
|
|
170
|
+
<button id="clarify" class="text-button">
|
|
171
|
+
✧ Clarify an assertion
|
|
172
|
+
</button>
|
|
173
|
+
</div>
|
|
174
|
+
</aside>
|
|
175
|
+
<section class="card workspace">
|
|
176
|
+
<div class="workspace-head">
|
|
177
|
+
<div class="tabs" role="tablist" aria-label="Workspace">
|
|
178
|
+
<button
|
|
179
|
+
id="live-tab"
|
|
180
|
+
class="tab active"
|
|
181
|
+
role="tab"
|
|
182
|
+
aria-selected="true"
|
|
183
|
+
>
|
|
184
|
+
Live view
|
|
185
|
+
</button>
|
|
186
|
+
<button id="edit" class="tab" role="tab" aria-selected="false">
|
|
187
|
+
Markdown
|
|
188
|
+
</button>
|
|
189
|
+
</div>
|
|
190
|
+
<span id="status" class="badge">Connecting…</span>
|
|
191
|
+
</div>
|
|
192
|
+
<div class="workspace-body">
|
|
193
|
+
<div id="live-panel">
|
|
194
|
+
<div class="context">
|
|
195
|
+
<div>
|
|
196
|
+
<h2 id="current">Waiting for browser</h2>
|
|
197
|
+
<p class="muted" id="hint">
|
|
198
|
+
Your application will appear here when it’s ready.
|
|
199
|
+
</p>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
<div class="screen" id="screen">
|
|
203
|
+
<div class="screen-empty">
|
|
204
|
+
<strong>Waiting for the application</strong>The live browser
|
|
205
|
+
will appear here.
|
|
206
|
+
</div>
|
|
207
|
+
<img
|
|
208
|
+
id="video"
|
|
209
|
+
alt="Live application under test"
|
|
210
|
+
tabindex="0"
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
<div class="editor" id="editor">
|
|
215
|
+
<div class="context">
|
|
216
|
+
<div>
|
|
217
|
+
<h2>Test Markdown</h2>
|
|
218
|
+
<p class="muted">
|
|
219
|
+
Edit the source of your test. Changes apply on the next run.
|
|
220
|
+
</p>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<textarea
|
|
224
|
+
id="source"
|
|
225
|
+
aria-label="Flow Markdown"
|
|
226
|
+
spellcheck="false"
|
|
227
|
+
></textarea>
|
|
228
|
+
<div class="editor-actions">
|
|
229
|
+
<span class="muted">Review your changes before saving.</span>
|
|
230
|
+
<button id="save" class="btn primary">Save Markdown</button>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
<div class="clarification" id="clarification">
|
|
235
|
+
<div class="row">
|
|
236
|
+
<h2>Clarify an assertion</h2>
|
|
237
|
+
<button id="close-clarify" class="text-button">Close</button>
|
|
238
|
+
</div>
|
|
239
|
+
<p class="muted">
|
|
240
|
+
Select a step or enter an assertion, then describe what you mean.
|
|
241
|
+
Your text is sent to the configured model.
|
|
242
|
+
</p>
|
|
243
|
+
<label>Existing assertion<textarea id="claim"></textarea></label>
|
|
244
|
+
<label
|
|
245
|
+
>What should it mean?<textarea id="meaning"></textarea>
|
|
246
|
+
</label>
|
|
247
|
+
<button id="suggest" class="btn">Suggest wording</button>
|
|
248
|
+
<label
|
|
249
|
+
>Suggested assertion<textarea id="proposal"></textarea>
|
|
250
|
+
</label>
|
|
251
|
+
<button id="insert" class="btn">Put suggestion in Markdown</button>
|
|
252
|
+
</div>
|
|
253
|
+
<p id="message" class="notice" role="status"></p>
|
|
254
|
+
<div class="lower">
|
|
255
|
+
<details>
|
|
256
|
+
<summary>Run logs</summary>
|
|
257
|
+
<pre id="logs" aria-label="Run logs"></pre>
|
|
258
|
+
</details>
|
|
259
|
+
<span id="report"> </span>
|
|
260
|
+
</div>
|
|
261
|
+
</section>
|
|
262
|
+
</div>
|
|
263
|
+
</main>
|
|
264
|
+
<script>
|
|
265
|
+
const title = "__TEMPLATE_VALUE__";
|
|
266
|
+
document.querySelector("#title").textContent = title;
|
|
267
|
+
const $ = (s) => document.querySelector(s);
|
|
268
|
+
let paused = false,
|
|
269
|
+
revision = "",
|
|
270
|
+
queue = Promise.resolve(),
|
|
271
|
+
lastCheck = "",
|
|
272
|
+
selectedId = "";
|
|
273
|
+
const send = (payload) => {
|
|
274
|
+
const task = queue.then(async () => {
|
|
275
|
+
try {
|
|
276
|
+
const r = await fetch("command", {
|
|
277
|
+
method: "POST",
|
|
278
|
+
headers: { "Content-Type": "application/json" },
|
|
279
|
+
body: JSON.stringify(payload),
|
|
280
|
+
});
|
|
281
|
+
if (!r.ok) {
|
|
282
|
+
$("#message").textContent = await r.text();
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return r.json();
|
|
286
|
+
} catch {
|
|
287
|
+
$("#message").textContent = "Connection lost. Please try again.";
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
queue = task.then(
|
|
292
|
+
() => {},
|
|
293
|
+
() => {},
|
|
294
|
+
);
|
|
295
|
+
return task;
|
|
296
|
+
};
|
|
297
|
+
const events = new EventSource("events");
|
|
298
|
+
events.addEventListener("frame", (e) => {
|
|
299
|
+
$("#video").src = "data:image/jpeg;base64," + e.data;
|
|
300
|
+
$("#screen").classList.add("has-frame");
|
|
301
|
+
});
|
|
302
|
+
events.onmessage = (e) => {
|
|
303
|
+
const s = JSON.parse(e.data);
|
|
304
|
+
paused = s.status === "paused";
|
|
305
|
+
const done = ["passed", "failed", "stopped"].includes(s.status);
|
|
306
|
+
$("#status").textContent =
|
|
307
|
+
s.status === "starting"
|
|
308
|
+
? s.ready
|
|
309
|
+
? "Ready"
|
|
310
|
+
: "Preparing"
|
|
311
|
+
: s.status;
|
|
312
|
+
$("#status").className = "badge " + s.status;
|
|
313
|
+
$("#current").textContent =
|
|
314
|
+
s.current ||
|
|
315
|
+
(s.status === "starting"
|
|
316
|
+
? "Ready when you are"
|
|
317
|
+
: s.status === "passed"
|
|
318
|
+
? "Test completed"
|
|
319
|
+
: s.status === "failed"
|
|
320
|
+
? "Test needs attention"
|
|
321
|
+
: s.status === "stopped"
|
|
322
|
+
? "Test stopped"
|
|
323
|
+
: "Preparing your test");
|
|
324
|
+
$("#message").textContent = s.message;
|
|
325
|
+
$("#logs").textContent = s.logs.join("\\n");
|
|
326
|
+
$("#start").hidden = s.status !== "starting" || done;
|
|
327
|
+
$("#start").disabled = !s.ready;
|
|
328
|
+
$("#resume").hidden = !paused;
|
|
329
|
+
$("#pause").hidden = paused || s.status === "starting" || done;
|
|
330
|
+
$("#pause").disabled = ["pause requested", "stopping"].includes(
|
|
331
|
+
s.status,
|
|
332
|
+
);
|
|
333
|
+
$("#stop").hidden = done;
|
|
334
|
+
$("#stop").disabled = s.status === "stopping";
|
|
335
|
+
$("#rerun").hidden = !done;
|
|
336
|
+
$("#screen").classList.toggle("paused", paused);
|
|
337
|
+
$("#hint").textContent = paused
|
|
338
|
+
? "Manual control is active. Click the page, then type or scroll."
|
|
339
|
+
: s.status === "starting"
|
|
340
|
+
? "Review the plan, then start your test."
|
|
341
|
+
: "Follow the application as your test runs.";
|
|
342
|
+
const roots = s.plan.filter((item) => !item.parentId);
|
|
343
|
+
const complete = roots.filter((item) =>
|
|
344
|
+
["passed", "failed", "skipped"].includes(item.status),
|
|
345
|
+
).length;
|
|
346
|
+
const percent = roots.length
|
|
347
|
+
? Math.round((complete / roots.length) * 100)
|
|
348
|
+
: 0;
|
|
349
|
+
$("#count").textContent = complete + " / " + roots.length + " complete";
|
|
350
|
+
$("#progress").style.width = percent + "%";
|
|
351
|
+
$(".progress").setAttribute("aria-valuenow", String(percent));
|
|
352
|
+
$("#empty-plan").hidden = roots.length > 0;
|
|
353
|
+
const renderStep = (item, index) => {
|
|
354
|
+
const li = document.createElement("li");
|
|
355
|
+
const button = document.createElement("button");
|
|
356
|
+
button.className =
|
|
357
|
+
"step " + item.status + (selectedId === item.id ? " selected" : "");
|
|
358
|
+
const dot = document.createElement("span");
|
|
359
|
+
dot.className = "dot";
|
|
360
|
+
dot.textContent =
|
|
361
|
+
item.status === "passed"
|
|
362
|
+
? "✓"
|
|
363
|
+
: item.status === "failed"
|
|
364
|
+
? "!"
|
|
365
|
+
: item.status === "running"
|
|
366
|
+
? "•"
|
|
367
|
+
: String(index + 1);
|
|
368
|
+
const copy = document.createElement("span");
|
|
369
|
+
copy.className = "step-copy";
|
|
370
|
+
const label = document.createElement("span");
|
|
371
|
+
label.className = "step-label";
|
|
372
|
+
label.textContent =
|
|
373
|
+
({ step: "Step", action: "Action", check: "Check", skill: "Skill" }[
|
|
374
|
+
item.kind
|
|
375
|
+
] || "Step") +
|
|
376
|
+
" · " +
|
|
377
|
+
item.status;
|
|
378
|
+
const text = document.createElement("span");
|
|
379
|
+
text.className = "step-text";
|
|
380
|
+
text.textContent = item.text;
|
|
381
|
+
copy.append(label, text);
|
|
382
|
+
if (item.detail) {
|
|
383
|
+
const detail = document.createElement("span");
|
|
384
|
+
detail.className = "step-detail";
|
|
385
|
+
detail.textContent = item.detail;
|
|
386
|
+
copy.append(detail);
|
|
387
|
+
}
|
|
388
|
+
button.append(dot, copy);
|
|
389
|
+
button.onclick = () => {
|
|
390
|
+
lastCheck = item.text;
|
|
391
|
+
selectedId = item.id;
|
|
392
|
+
$("#claim").value = item.text;
|
|
393
|
+
document
|
|
394
|
+
.querySelectorAll(".step.selected")
|
|
395
|
+
.forEach((el) => el.classList.remove("selected"));
|
|
396
|
+
button.classList.add("selected");
|
|
397
|
+
};
|
|
398
|
+
li.append(button);
|
|
399
|
+
if (item.actions.length) {
|
|
400
|
+
const list = document.createElement("ul");
|
|
401
|
+
list.className = "actions";
|
|
402
|
+
for (const action of item.actions) {
|
|
403
|
+
const entry = document.createElement("li");
|
|
404
|
+
entry.textContent = action;
|
|
405
|
+
list.append(entry);
|
|
406
|
+
}
|
|
407
|
+
li.append(list);
|
|
408
|
+
}
|
|
409
|
+
const children = s.plan.filter((child) => child.parentId === item.id);
|
|
410
|
+
if (children.length) {
|
|
411
|
+
const list = document.createElement("ol");
|
|
412
|
+
list.append(...children.map(renderStep));
|
|
413
|
+
li.append(list);
|
|
414
|
+
}
|
|
415
|
+
return li;
|
|
416
|
+
};
|
|
417
|
+
$("#plan").replaceChildren(...roots.map(renderStep));
|
|
418
|
+
$("#report").replaceChildren();
|
|
419
|
+
if (s.report) {
|
|
420
|
+
const a = document.createElement("a");
|
|
421
|
+
a.href = s.report;
|
|
422
|
+
a.target = "_blank";
|
|
423
|
+
a.textContent = "Open saved report ↗";
|
|
424
|
+
$("#report").append(a);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
$("#start").onclick = () => send({ type: "start" });
|
|
428
|
+
$("#pause").onclick = () => send({ type: "pause" });
|
|
429
|
+
$("#resume").onclick = () => send({ type: "resume" });
|
|
430
|
+
$("#stop").onclick = () => send({ type: "stop" });
|
|
431
|
+
$("#rerun").onclick = () => send({ type: "rerun" });
|
|
432
|
+
const video = $("#video");
|
|
433
|
+
video.onclick = (e) => {
|
|
434
|
+
if (!paused) return;
|
|
435
|
+
const r = video.getBoundingClientRect();
|
|
436
|
+
video.focus();
|
|
437
|
+
send({
|
|
438
|
+
type: "click",
|
|
439
|
+
x: (e.clientX - r.left) / r.width,
|
|
440
|
+
y: (e.clientY - r.top) / r.height,
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
video.onkeydown = (e) => {
|
|
444
|
+
if (!paused) return;
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey)
|
|
447
|
+
send({ type: "text", text: e.key });
|
|
448
|
+
else if (
|
|
449
|
+
[
|
|
450
|
+
"Enter",
|
|
451
|
+
"Backspace",
|
|
452
|
+
"Tab",
|
|
453
|
+
"Escape",
|
|
454
|
+
"ArrowUp",
|
|
455
|
+
"ArrowDown",
|
|
456
|
+
"ArrowLeft",
|
|
457
|
+
"ArrowRight",
|
|
458
|
+
"Delete",
|
|
459
|
+
].includes(e.key)
|
|
460
|
+
)
|
|
461
|
+
send({ type: "key", key: e.key });
|
|
462
|
+
};
|
|
463
|
+
video.onwheel = (e) => {
|
|
464
|
+
if (paused) {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
send({
|
|
467
|
+
type: "scroll",
|
|
468
|
+
delta: Math.max(-1200, Math.min(1200, e.deltaY)),
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
const showTab = (editing) => {
|
|
473
|
+
$("#live-panel").hidden = editing;
|
|
474
|
+
$("#editor").classList.toggle("open", editing);
|
|
475
|
+
$("#edit").classList.toggle("active", editing);
|
|
476
|
+
$("#live-tab").classList.toggle("active", !editing);
|
|
477
|
+
$("#edit").setAttribute("aria-selected", String(editing));
|
|
478
|
+
$("#live-tab").setAttribute("aria-selected", String(!editing));
|
|
479
|
+
};
|
|
480
|
+
const edit = async () => {
|
|
481
|
+
if (!revision) {
|
|
482
|
+
try {
|
|
483
|
+
const r = await fetch("source");
|
|
484
|
+
if (!r.ok) throw new Error();
|
|
485
|
+
const d = await r.json();
|
|
486
|
+
$("#source").value = d.content;
|
|
487
|
+
revision = d.revision;
|
|
488
|
+
} catch {
|
|
489
|
+
$("#message").textContent = "Could not load the Markdown source.";
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
showTab(true);
|
|
494
|
+
};
|
|
495
|
+
$("#edit").onclick = edit;
|
|
496
|
+
$("#live-tab").onclick = () => showTab(false);
|
|
497
|
+
$("#save").onclick = async () => {
|
|
498
|
+
const result = await send({
|
|
499
|
+
type: "save",
|
|
500
|
+
content: $("#source").value,
|
|
501
|
+
revision,
|
|
502
|
+
});
|
|
503
|
+
if (result) revision = result.revision;
|
|
504
|
+
};
|
|
505
|
+
$("#clarify").onclick = () => {
|
|
506
|
+
$("#claim").value = lastCheck;
|
|
507
|
+
$("#clarification").classList.add("open");
|
|
508
|
+
$("#claim").focus();
|
|
509
|
+
};
|
|
510
|
+
$("#close-clarify").onclick = () =>
|
|
511
|
+
$("#clarification").classList.remove("open");
|
|
512
|
+
$("#suggest").onclick = async () => {
|
|
513
|
+
const result = await send({
|
|
514
|
+
type: "suggest",
|
|
515
|
+
claim: $("#claim").value,
|
|
516
|
+
clarification: $("#meaning").value,
|
|
517
|
+
});
|
|
518
|
+
if (result) $("#proposal").value = result.assertion;
|
|
519
|
+
};
|
|
520
|
+
$("#insert").onclick = async () => {
|
|
521
|
+
if (!revision) await edit();
|
|
522
|
+
if (!revision) return;
|
|
523
|
+
const before = $("#claim").value,
|
|
524
|
+
after = $("#proposal").value,
|
|
525
|
+
content = $("#source").value;
|
|
526
|
+
if (!before || !after || content.split(before).length !== 2) {
|
|
527
|
+
$("#message").textContent =
|
|
528
|
+
"The original assertion must appear exactly once in the Markdown.";
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
$("#source").value = content.replace(before, after);
|
|
532
|
+
showTab(true);
|
|
533
|
+
$("#message").textContent =
|
|
534
|
+
"Suggestion inserted in editor only. Review it before saving.";
|
|
535
|
+
};
|
|
536
|
+
</script>
|
|
537
|
+
</body>
|
|
538
|
+
</html>
|