@osdlc/wayfinder 0.7.1 → 0.7.2
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/CHANGELOG.md +23 -0
- package/README.md +210 -182
- package/SECURITY.md +39 -1
- package/bin/way.js +14 -9
- package/dist/args.d.ts +16 -16
- package/dist/args.js +19 -19
- package/dist/cache.js +3 -4
- package/dist/clean-command.d.ts +18 -18
- package/dist/clean-command.js +35 -36
- package/dist/cli.d.ts +19 -20
- package/dist/cli.js +76 -69
- package/dist/config-command.d.ts +15 -14
- package/dist/config-command.js +63 -59
- package/dist/config.d.ts +135 -130
- package/dist/config.js +156 -149
- package/dist/devlink.d.ts +6 -2
- package/dist/devlink.js +7 -2
- package/dist/guide.js +5 -4
- package/dist/origin-owner.d.ts +7 -2
- package/dist/origin-owner.js +20 -4
- package/dist/providers-command.d.ts +1 -1
- package/dist/providers-command.js +11 -23
- package/dist/serve.d.ts +43 -42
- package/dist/serve.js +251 -258
- package/dist/terminal-text.d.ts +57 -0
- package/dist/terminal-text.js +91 -0
- package/dist/tools.d.ts +4 -4
- package/dist/tools.js +4 -4
- package/dist/trust-command.d.ts +6 -7
- package/dist/trust-command.js +48 -50
- package/dist/trust-store.d.ts +1 -1
- package/dist/tui.d.ts +65 -66
- package/dist/tui.js +124 -130
- package/dist/web/main.js +371 -386
- package/dist/web/page.html +6 -5
- package/dist/web/styles.css +258 -271
- package/package.json +7 -7
package/dist/web/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/web/state.ts
|
|
2
2
|
const SEP = " › ";
|
|
3
3
|
/**
|
|
4
|
-
* Every static element this page
|
|
5
|
-
* removed, so a lookup
|
|
6
|
-
*
|
|
4
|
+
* Every static element this page uses is declared in `page.html` and never
|
|
5
|
+
* removed, so a failed lookup is a bug in the markup, not a case to handle at
|
|
6
|
+
* runtime. The `!` states that rule rather than hiding a real null.
|
|
7
7
|
*/
|
|
8
8
|
function $(id) {
|
|
9
9
|
return document.getElementById(id);
|
|
@@ -70,27 +70,27 @@ function restoreRunnerOrder() {
|
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region ../system-model/dist/duration.js
|
|
72
72
|
/**
|
|
73
|
-
* Durations and ages
|
|
73
|
+
* Durations and ages formatted for people, not raw milliseconds.
|
|
74
74
|
*
|
|
75
|
-
* These format the two numbers `cache.ts` measures
|
|
76
|
-
* ({@link humanMs}) and how old a stored answer is ({@link humanAge})
|
|
77
|
-
*
|
|
78
|
-
*
|
|
75
|
+
* These format the two numbers `cache.ts` measures: how long a probe takes
|
|
76
|
+
* ({@link humanMs}) and how old a stored answer is ({@link humanAge}). Every
|
|
77
|
+
* caller that reports on the cache (both CLIs, the TUI, the web view) prints
|
|
78
|
+
* one or both.
|
|
79
79
|
*
|
|
80
|
-
* They are
|
|
81
|
-
* view is bundled for the browser, and `cache.ts`
|
|
82
|
-
* `node:
|
|
83
|
-
* subpath and must
|
|
80
|
+
* They are not in `cache.ts`, for the same reason `match.ts` is not. The web
|
|
81
|
+
* view is bundled for the browser, and `cache.ts` imports `node:fs`,
|
|
82
|
+
* `node:path` and `node:crypto`. This module has its own `./duration` export
|
|
83
|
+
* subpath and must not use the DOM or Node built-ins.
|
|
84
84
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
85
|
+
* Callers do not get the sentence around the number from here. The CLIs say
|
|
86
|
+
* "35s old, refresh usually about 149ms", the TUI says "~149ms", and the page
|
|
87
|
+
* says "never timed here". Each caller words it for where it is read, on
|
|
88
|
+
* purpose. Only the number's format is shared.
|
|
89
89
|
*/
|
|
90
90
|
/**
|
|
91
91
|
* A duration, at a precision that suits its size: milliseconds under a second,
|
|
92
92
|
* one decimal of a second under ten, then whole seconds and whole minutes. A
|
|
93
|
-
* probe cost is a rough
|
|
93
|
+
* probe cost is a rough estimate, and `1.4s` is easier to read than `1423ms`.
|
|
94
94
|
*/
|
|
95
95
|
function humanMs(ms) {
|
|
96
96
|
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
@@ -99,13 +99,13 @@ function humanMs(ms) {
|
|
|
99
99
|
return `${Math.round(ms / 6e4)}m`;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* How old a cached answer is. `undefined` is a miss, which has no age
|
|
103
|
-
*
|
|
102
|
+
* How old a cached answer is. `undefined` is a miss, which has no age. It
|
|
103
|
+
* returns "of unknown age" rather than "0s old", which would claim a freshness
|
|
104
104
|
* nothing measured.
|
|
105
105
|
*
|
|
106
|
-
* The
|
|
107
|
-
* moments after it was written is still
|
|
108
|
-
*
|
|
106
|
+
* The minimum of one second is deliberate. An answer read from the store
|
|
107
|
+
* moments after it was written is still a stored answer, and "0s old" would
|
|
108
|
+
* suggest it is live.
|
|
109
109
|
*/
|
|
110
110
|
function humanAge(ms) {
|
|
111
111
|
if (ms === void 0) return "of unknown age";
|
|
@@ -117,16 +117,16 @@ function humanAge(ms) {
|
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region ../system-model/dist/match.js
|
|
119
119
|
/**
|
|
120
|
-
* Ranked search over catalog entries
|
|
120
|
+
* Ranked search over catalog entries. Both views use this one matcher.
|
|
121
121
|
*
|
|
122
|
-
* Every
|
|
123
|
-
* same
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
122
|
+
* Every view of this catalog must agree on what a query means. Otherwise the
|
|
123
|
+
* same query ranks differently depending on which view you use. The terminal
|
|
124
|
+
* UI imports it directly. The web view loads it transpiled for the browser.
|
|
125
|
+
* That is why it has its own `./match` export subpath, and why it must not use
|
|
126
|
+
* the DOM or Node built-ins. Importing anything from `node:fs` here breaks the
|
|
127
|
+
* browser build.
|
|
128
128
|
*
|
|
129
|
-
* Query language
|
|
129
|
+
* Query language:
|
|
130
130
|
* - terms are whitespace-separated and ANDed; every term must match a field
|
|
131
131
|
* - a leading `'` forces that term to match as a substring, fzf-style
|
|
132
132
|
* - `mode: "exact"` forces every term to, without the prefix
|
|
@@ -220,27 +220,27 @@ function matchEntry(entry, queryTerms, mode) {
|
|
|
220
220
|
//#endregion
|
|
221
221
|
//#region ../system-model/dist/params.js
|
|
222
222
|
/**
|
|
223
|
-
* How a task's parameters are
|
|
223
|
+
* How a task's parameters are written for a reader.
|
|
224
224
|
*
|
|
225
|
-
*
|
|
226
|
-
* `duration.ts` and `match.ts
|
|
227
|
-
* and importing this from the
|
|
228
|
-
* `node:crypto` and `child_process` into that bundle. This module must
|
|
229
|
-
*
|
|
230
|
-
*
|
|
225
|
+
* This is its own module with its own `./params` export subpath, for the same
|
|
226
|
+
* reason as `duration.ts` and `match.ts`. The web view is bundled for the
|
|
227
|
+
* browser, and importing this from the detection entry would pull `node:fs`,
|
|
228
|
+
* `node:crypto` and `child_process` into that bundle. This module must not use
|
|
229
|
+
* the DOM or Node built-ins. The `Param` import below is type-only, so it is
|
|
230
|
+
* erased.
|
|
231
231
|
*
|
|
232
|
-
*
|
|
232
|
+
* Three callers share this format. just's runner builds `display` with it, the
|
|
233
233
|
* TUI prints it under a command that ran without arguments, and the web view's
|
|
234
234
|
* run bar shows it under the field.
|
|
235
235
|
*/
|
|
236
236
|
/**
|
|
237
|
-
* Parameters in just's own notation
|
|
238
|
-
* for a variadic that does
|
|
237
|
+
* Parameters in just's own notation: `<required>`, `[optional]`, and `+` or
|
|
238
|
+
* `*` for a variadic that does or does not need an argument.
|
|
239
239
|
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* string for a task
|
|
243
|
-
* length check.
|
|
240
|
+
* For display only, never for running. `<name>` is a shell redirection and
|
|
241
|
+
* `*` is a glob, which is why `argv` and `display` are separate fields.
|
|
242
|
+
* Returns an empty string for a task with no parameters, so a caller can
|
|
243
|
+
* concatenate without a length check.
|
|
244
244
|
*/
|
|
245
245
|
function paramShape(parameters) {
|
|
246
246
|
return parameters.map((p) => {
|
|
@@ -290,6 +290,39 @@ function runnerLabel(runner) {
|
|
|
290
290
|
return group.runner === runner ? group.title.toLowerCase() : runner;
|
|
291
291
|
}
|
|
292
292
|
//#endregion
|
|
293
|
+
//#region src/app.ts
|
|
294
|
+
/**
|
|
295
|
+
* The app's names. Every user-facing name that carries the product name
|
|
296
|
+
* derives from here. Browser-safe: the page imports it too.
|
|
297
|
+
*/
|
|
298
|
+
/** The product name: config directory, cache directory, trust store key, message prefix. */
|
|
299
|
+
const APP = "wayfinder";
|
|
300
|
+
/**
|
|
301
|
+
* The name before the rename to wayfinder. Its user config, project config,
|
|
302
|
+
* trust store and config variable are still read when the new ones are
|
|
303
|
+
* absent. Nothing is written under it.
|
|
304
|
+
*/
|
|
305
|
+
const LEGACY_APP = "waypost";
|
|
306
|
+
`${APP.toUpperCase()}`;
|
|
307
|
+
`${LEGACY_APP.toUpperCase()}`;
|
|
308
|
+
/** The request header that carries the web view's session token. */
|
|
309
|
+
const TOKEN_HEADER = `x-${APP}-token`;
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/terminal-text.ts
|
|
312
|
+
/** C0 (tab and newline included), DEL, C1, and bidi U+202A-202E and U+2066-2069. */
|
|
313
|
+
const CONTROL = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
|
|
314
|
+
/** The same, but tab and newline are kept. */
|
|
315
|
+
const CONTROL_KEEP_LINES = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
|
|
316
|
+
const REPLACEMENT = "�";
|
|
317
|
+
/**
|
|
318
|
+
* `text` with every C0 control character (ESC included), DEL, C1 control
|
|
319
|
+
* character and bidi control replaced by U+FFFD. With `multiline`, tab and
|
|
320
|
+
* newline are kept, for output that is already more than one line.
|
|
321
|
+
*/
|
|
322
|
+
function terminalSafe(text, opts = {}) {
|
|
323
|
+
return text.replace(opts.multiline === true ? CONTROL_KEEP_LINES : CONTROL, REPLACEMENT);
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
293
326
|
//#region src/web/view.ts
|
|
294
327
|
function escapeHtml(s) {
|
|
295
328
|
return s.replace(/[&<>"]/g, (c) => ({
|
|
@@ -304,31 +337,31 @@ function brandOf(runner) {
|
|
|
304
337
|
return (state.catalog?.reports || []).find((r) => r.runner === runner)?.brand || null;
|
|
305
338
|
}
|
|
306
339
|
/**
|
|
307
|
-
* The runner's icon,
|
|
308
|
-
* own
|
|
309
|
-
* field it renders.
|
|
310
|
-
*
|
|
340
|
+
* The runner's icon, inserted unescaped on purpose. It is inline SVG that the
|
|
341
|
+
* server's own runners declare, which this page trusts as it trusts every
|
|
342
|
+
* field it renders. Escaping it would print the markup as text instead of
|
|
343
|
+
* drawing it.
|
|
311
344
|
*/
|
|
312
345
|
function iconHtml(runner) {
|
|
313
346
|
const icon = brandOf(runner)?.icon;
|
|
314
347
|
return icon ? "<span class=\"ricon\" aria-hidden=\"true\">" + icon + "</span>" : "";
|
|
315
348
|
}
|
|
316
|
-
/** Row tint attributes. The color is data
|
|
349
|
+
/** Row tint attributes. The color is data passed to CSS, so it is escaped. */
|
|
317
350
|
function brandAttrs(runner) {
|
|
318
351
|
const color = brandOf(runner)?.color;
|
|
319
352
|
return color ? " class=\"branded\" style=\"--rb:" + escapeHtml(color) + "\"" : "";
|
|
320
353
|
}
|
|
321
354
|
/**
|
|
322
|
-
* The attributes every body row
|
|
323
|
-
* and a
|
|
355
|
+
* The attributes every body row has: the brand tint, the task's stable id,
|
|
356
|
+
* and a tabindex for roving focus.
|
|
324
357
|
*
|
|
325
|
-
* `data-id` is the task's own id, not its position
|
|
326
|
-
* keyboard and render() replaces #out
|
|
327
|
-
*
|
|
358
|
+
* `data-id` is the task's own id, not its position. The list is used by
|
|
359
|
+
* keyboard and render() replaces all of #out, so the focused row must be
|
|
360
|
+
* found again by id after a rebuild reorders or drops rows.
|
|
328
361
|
*
|
|
329
|
-
* Every row starts at -1. markEnterTarget()
|
|
330
|
-
* whole list is a single tab stop and the arrows move within it
|
|
331
|
-
* pattern rovingGroup() uses for the toolbar segments.
|
|
362
|
+
* Every row starts at -1. markEnterTarget() sets exactly one to 0, so the
|
|
363
|
+
* whole list is a single tab stop and the arrows move within it. This is the
|
|
364
|
+
* same pattern rovingGroup() uses for the toolbar segments.
|
|
332
365
|
*/
|
|
333
366
|
function rowAttrs(e) {
|
|
334
367
|
return brandAttrs(e.runner) + " data-id=\"" + escapeHtml(e.id) + "\" tabindex=\"-1\"";
|
|
@@ -401,10 +434,10 @@ function renderNode(node, prefix) {
|
|
|
401
434
|
return html;
|
|
402
435
|
}
|
|
403
436
|
/**
|
|
404
|
-
* The service icon,
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
437
|
+
* The service icon, drawn here rather than taken from a runner's brand. Brand
|
|
438
|
+
* icons identify runners, and this marks a property of the task. It has no
|
|
439
|
+
* fixed size or colour: styles.css sizes the box and `currentColor` takes the
|
|
440
|
+
* theme colour.
|
|
408
441
|
*/
|
|
409
442
|
function serviceIcon(declared) {
|
|
410
443
|
return declared ? "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><circle cx=\"8\" cy=\"8\" r=\"4.5\" fill=\"currentColor\" /></svg>" : "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><circle cx=\"8\" cy=\"8\" r=\"4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" /></svg>";
|
|
@@ -419,15 +452,15 @@ function quoteDir(dir) {
|
|
|
419
452
|
/**
|
|
420
453
|
* What Copy hands over, which is not always what the Command column shows.
|
|
421
454
|
*
|
|
422
|
-
* Most tasks are written to run from the repository root and
|
|
423
|
-
* bound to its own directory gets the `cd`
|
|
424
|
-
*
|
|
425
|
-
* anything that
|
|
455
|
+
* Most tasks are written to run from the repository root and are copied as
|
|
456
|
+
* they are. A task bound to its own directory gets the `cd` it needs, since
|
|
457
|
+
* without it the copied command would fail. `argv` is unchanged either way,
|
|
458
|
+
* because anything that spawns a task already uses the directory.
|
|
426
459
|
*/
|
|
427
460
|
function copyText(task) {
|
|
428
|
-
return task.cwd === "." ? task.display : "cd " + quoteDir(task.cwd) + " && " + task.display;
|
|
461
|
+
return terminalSafe(task.cwd === "." ? task.display : "cd " + quoteDir(task.cwd) + " && " + task.display);
|
|
429
462
|
}
|
|
430
|
-
/** What Run
|
|
463
|
+
/** What Run does, stated up front: the page ends and the task takes the terminal. */
|
|
431
464
|
function runTip(task) {
|
|
432
465
|
return "Run " + task.display + " in the terminal wayfinder is serving from. The server exits and this page is finished.";
|
|
433
466
|
}
|
|
@@ -437,9 +470,9 @@ function copyTip(task) {
|
|
|
437
470
|
}
|
|
438
471
|
/**
|
|
439
472
|
* The columns, in the order the colgroup declares them, plus the depth spacer
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
473
|
+
* between the first two below the root. Five of them, or four once Runs is
|
|
474
|
+
* dropped at a narrow width (see `showRuns`). The indicator has its own column
|
|
475
|
+
* rather than sitting before the name, because a prefix would push each marked
|
|
443
476
|
* row's chain out of line with its neighbours.
|
|
444
477
|
*/
|
|
445
478
|
function cells(e, nameHtml, depth = 0) {
|
|
@@ -454,26 +487,23 @@ function outdent(depth) {
|
|
|
454
487
|
return "margin-left:-" + px + "px;width:calc(100% + " + px + "px)";
|
|
455
488
|
}
|
|
456
489
|
/**
|
|
457
|
-
* The action
|
|
458
|
-
* `↵ copy`,
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* own 8px right padding is 105.12.
|
|
490
|
+
* The action column. Wide enough for `run` beside the enter-target row's
|
|
491
|
+
* `↵ copy`, the widest the column gets. The plain `copy` on other rows leaves
|
|
492
|
+
* 14px more. Measured in Chromium at 1700px and 1100px, which agree: `run`
|
|
493
|
+
* 35.23 + a 4px gap + `↵ copy` 57.89 + the cell's 8px right padding is 105.12.
|
|
462
494
|
*
|
|
463
|
-
* 112 rather than
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* 6.88px here is slack a re-measure can spend.
|
|
495
|
+
* 112 rather than 106, because 106 leaves only 0.88px. A fallback font or one
|
|
496
|
+
* more pixel of button padding would then clip, and silently: the row's
|
|
497
|
+
* actions would lose their right edge. The 6.88px is spare room.
|
|
467
498
|
*/
|
|
468
499
|
const ACT_W = 112;
|
|
469
500
|
/** The indicator gutter: one icon wide, with room to centre a second later. */
|
|
470
501
|
const IND_W = 30;
|
|
471
502
|
/**
|
|
472
|
-
* Below this the Runs column is dropped.
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* padding), not of the window.
|
|
503
|
+
* Below this the Runs column is dropped. Runs is cut off too much to be useful
|
|
504
|
+
* below a 1100px viewport. `main` pads 16px on each side, so that is about
|
|
505
|
+
* 1068px of table width. The number is in the same units as `availWidth()`:
|
|
506
|
+
* the width of the table area (`main` minus its padding), not of the window.
|
|
477
507
|
*/
|
|
478
508
|
const RUNS_MIN_W = 1068;
|
|
479
509
|
/** The width every table's columns are measured against. */
|
|
@@ -481,18 +511,18 @@ function availWidth() {
|
|
|
481
511
|
return Math.max(320, state.mainWidth || 1e3);
|
|
482
512
|
}
|
|
483
513
|
/**
|
|
484
|
-
* Whether the Runs column
|
|
485
|
-
* `renderColHeads` all
|
|
486
|
-
*
|
|
487
|
-
*
|
|
514
|
+
* Whether the Runs column is shown right now. `colgroup`, `cells` and
|
|
515
|
+
* `renderColHeads` all call this, because if a table's colgroup, head row and
|
|
516
|
+
* body rows disagree on the number of columns, every column after the first
|
|
517
|
+
* is misaligned.
|
|
488
518
|
*/
|
|
489
519
|
function showRuns() {
|
|
490
520
|
return availWidth() >= RUNS_MIN_W;
|
|
491
521
|
}
|
|
492
522
|
/**
|
|
493
|
-
* The columns, named once. `tip` is the hover
|
|
494
|
-
*
|
|
495
|
-
*
|
|
523
|
+
* The columns, named once. `tip` is the hover text. The help modal has the
|
|
524
|
+
* longer version of anything a tooltip cannot hold. This is the full list;
|
|
525
|
+
* `renderColHeads` drops Runs when the width does.
|
|
496
526
|
*/
|
|
497
527
|
const COLUMNS = [
|
|
498
528
|
{
|
|
@@ -517,23 +547,22 @@ const COLUMNS = [
|
|
|
517
547
|
}
|
|
518
548
|
];
|
|
519
549
|
/**
|
|
520
|
-
* Column widths, in pixels rather than percentages, because the tables
|
|
521
|
-
* different widths
|
|
522
|
-
* left edges agree,
|
|
523
|
-
*
|
|
550
|
+
* Column widths, in pixels rather than percentages, because the tables have
|
|
551
|
+
* different widths. Each is outdented by its depth (see `outdent`) so their
|
|
552
|
+
* left edges agree, so a percentage would be a different number of pixels at
|
|
553
|
+
* each level.
|
|
524
554
|
*
|
|
525
|
-
* A leading spacer column
|
|
526
|
-
* its group header
|
|
527
|
-
* command column starts at the same
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
555
|
+
* A leading spacer column as wide as the outdent puts the content back under
|
|
556
|
+
* its group header, and the name column gives up the same amount. So the
|
|
557
|
+
* command column starts at the same x at every depth, and no row text lands
|
|
558
|
+
* in the strip left of the headers. Text there would show through beside a
|
|
559
|
+
* header as rows scroll under it, because a header's background stops at its
|
|
560
|
+
* own indented box.
|
|
531
561
|
*
|
|
532
|
-
* Which columns exist
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* recompute what the others are worth.
|
|
562
|
+
* Which columns exist depends on the width: under RUNS_MIN_W the Runs column
|
|
563
|
+
* is dropped and its space goes to Task and Command. That has to happen here
|
|
564
|
+
* rather than in a media query, because the widths are computed pixels. A
|
|
565
|
+
* media query can hide cells but cannot recompute the other widths.
|
|
537
566
|
*/
|
|
538
567
|
function colgroup(depth) {
|
|
539
568
|
const indent = depth * INDENT_PER_LEVEL;
|
|
@@ -600,27 +629,26 @@ function renderSearchRow(row) {
|
|
|
600
629
|
return "<tr" + rowAttrs(e) + ">" + cells(e, out) + "</tr>";
|
|
601
630
|
}
|
|
602
631
|
/**
|
|
603
|
-
* How deep in the repository a task is
|
|
632
|
+
* How deep in the repository a task is declared: the number of directories
|
|
604
633
|
* above its source file. `justfile` and `moon.yml` at the root are 0;
|
|
605
634
|
* `apps/web/client/moon.yml` is 3.
|
|
606
635
|
*
|
|
607
|
-
* This is where a task
|
|
608
|
-
* filters on it, so "Root" is the
|
|
609
|
-
* declares
|
|
636
|
+
* This is where a task is declared, not how the tree draws it. The Depth
|
|
637
|
+
* control filters on it, so "Root" is the few commands the repository itself
|
|
638
|
+
* declares, not the ones its packages do.
|
|
610
639
|
*/
|
|
611
640
|
function sourceDepth(task) {
|
|
612
641
|
const at = task.source.lastIndexOf("/");
|
|
613
642
|
return at === -1 ? 0 : task.source.slice(0, at).split("/").length;
|
|
614
643
|
}
|
|
615
644
|
/**
|
|
616
|
-
* The one runner order,
|
|
617
|
-
*
|
|
618
|
-
* page under it.
|
|
645
|
+
* The one runner order, used by the tabs, the picker and the tree's top level.
|
|
646
|
+
* All three must agree, or the tab bar no longer matches the page below it.
|
|
619
647
|
*
|
|
620
648
|
* Grouped first (tasks, dependencies, tools, git hooks), then alphabetical
|
|
621
|
-
* within a group.
|
|
622
|
-
*
|
|
623
|
-
*
|
|
649
|
+
* within a group. An order the user dragged (on either surface) is kept in
|
|
650
|
+
* localStorage and wins within its group. A runner not in the saved order is
|
|
651
|
+
* placed alphabetically after it rather than left out.
|
|
624
652
|
*/
|
|
625
653
|
function runnerOrder() {
|
|
626
654
|
const present = (state.catalog?.reports || []).map((r) => r.runner);
|
|
@@ -645,21 +673,20 @@ function sortedRunnerOrder(key, dir) {
|
|
|
645
673
|
});
|
|
646
674
|
}
|
|
647
675
|
/**
|
|
648
|
-
* The sort the user last
|
|
649
|
-
* activeSort
|
|
650
|
-
* anything, so a drag clears the arrow. It only decides
|
|
651
|
-
*
|
|
652
|
-
* counts are
|
|
676
|
+
* The sort the user last asked for. It does not say what order is on screen.
|
|
677
|
+
* activeSort checks it against the live order before the header shows
|
|
678
|
+
* anything, so a drag clears the arrow. It only decides which column gets the
|
|
679
|
+
* arrow when an order matches two sorts, as every order does when all the
|
|
680
|
+
* counts are equal.
|
|
653
681
|
*/
|
|
654
682
|
let requestedSort = null;
|
|
655
683
|
/**
|
|
656
|
-
* Which sort the order
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
* lying about what is on screen.
|
|
684
|
+
* Which sort the current order already matches, if any, found by comparing.
|
|
685
|
+
* A stored "sorted by name" flag would stay set after a drag rearranged the
|
|
686
|
+
* list, and the header would then be wrong about what is on screen.
|
|
660
687
|
*
|
|
661
|
-
* The last requested sort is tried
|
|
662
|
-
*
|
|
688
|
+
* The last requested sort is tried first, because two sorts can match one
|
|
689
|
+
* order and only one of them is the one the user pressed.
|
|
663
690
|
*/
|
|
664
691
|
function activeSort() {
|
|
665
692
|
const now = runnerOrder().join("\0");
|
|
@@ -678,7 +705,7 @@ function activeSort() {
|
|
|
678
705
|
};
|
|
679
706
|
return null;
|
|
680
707
|
}
|
|
681
|
-
/** Sorting
|
|
708
|
+
/** Sorting reorders the one saved order, so the tab bar updates at once. */
|
|
682
709
|
function sortRunners(key, dir) {
|
|
683
710
|
requestedSort = {
|
|
684
711
|
key,
|
|
@@ -703,13 +730,13 @@ function treeStart() {
|
|
|
703
730
|
return state.runner === "all" ? 0 : 1;
|
|
704
731
|
}
|
|
705
732
|
/**
|
|
706
|
-
* Why a runner reports nothing when execution is off.
|
|
707
|
-
*
|
|
733
|
+
* Why a runner reports nothing when execution is off. Defined once because
|
|
734
|
+
* three places show it: the tab's tooltip, the picker's note and the
|
|
708
735
|
* per-runner modal.
|
|
709
736
|
*
|
|
710
|
-
* Two sentences,
|
|
711
|
-
* running it
|
|
712
|
-
*
|
|
737
|
+
* Two sentences, for two reasons. Either way, reading this runner means
|
|
738
|
+
* running it. Whether the page can fix that depends on whether trust is what
|
|
739
|
+
* is missing, which only the server knows (see `state.trustable`).
|
|
713
740
|
*/
|
|
714
741
|
const EXEC_NOTE_OFF = "This runner can only be read by running it, and execution is off for this session.";
|
|
715
742
|
const EXEC_NOTE_UNTRUSTED = "This runner can only be read by running it, and this repository is not trusted yet.";
|
|
@@ -717,19 +744,17 @@ function execNote() {
|
|
|
717
744
|
return state.trustable ? EXEC_NOTE_UNTRUSTED : EXEC_NOTE_OFF;
|
|
718
745
|
}
|
|
719
746
|
/**
|
|
720
|
-
* The grant. Offered wherever the
|
|
721
|
-
* the
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
* three-letter badge and a tooltip are not telling. Confirmed before it POSTs —
|
|
725
|
-
* see input.ts.
|
|
747
|
+
* The trust grant button. Offered wherever the withheld runners are explained:
|
|
748
|
+
* the trust bar, the per-runner modal and the picker. A badge and a tooltip
|
|
749
|
+
* alone would leave someone who opens neither menu uninformed. It asks for
|
|
750
|
+
* confirmation before it POSTs (see input.ts).
|
|
726
751
|
*/
|
|
727
752
|
const TRUST_BUTTON = "<button class=\"toolbtn\" data-trust-repo=\"1\" title=\"Record that this repository may run subprocesses to be read. Remembered per repository.\">Trust this repository</button>";
|
|
728
753
|
/**
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* (needs --exec)
|
|
754
|
+
* One chip in place of the tabs of all folded runners. It shows how many, and
|
|
755
|
+
* its title says which and why. It is not a menu of its own. The runner
|
|
756
|
+
* picker already lists each one with its count and its (failed),
|
|
757
|
+
* (needs --exec) or (not trusted) note, so this only opens the picker (see
|
|
733
758
|
* input.ts).
|
|
734
759
|
*/
|
|
735
760
|
function foldedChip(reports) {
|
|
@@ -840,11 +865,10 @@ function render() {
|
|
|
840
865
|
/**
|
|
841
866
|
* Put keyboard focus back in the rebuilt list.
|
|
842
867
|
*
|
|
843
|
-
* The focused row is found by task id. When that task is gone
|
|
844
|
-
* 15s poll or a resize dropped it
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
* search box, which is where the user can act.
|
|
868
|
+
* The focused row is found by task id. When that task is gone (a filter, the
|
|
869
|
+
* 15s poll or a resize dropped it), focus would fall to <body> and the arrows
|
|
870
|
+
* would stop working with no sign why. So the first remaining row takes
|
|
871
|
+
* focus, and with no rows left focus goes back to the search box.
|
|
848
872
|
*/
|
|
849
873
|
function restoreListFocus() {
|
|
850
874
|
const rows = listRows();
|
|
@@ -859,9 +883,9 @@ function restoreListFocus() {
|
|
|
859
883
|
/**
|
|
860
884
|
* A selector naming one picker control, stable across a rebuild.
|
|
861
885
|
*
|
|
862
|
-
* The picker's markup is regenerated
|
|
863
|
-
* afterwards. Every control in it
|
|
864
|
-
*
|
|
886
|
+
* The picker's markup is regenerated in full, so an element reference is no
|
|
887
|
+
* use afterwards. Every control in it has a runner id or a fixed attribute,
|
|
888
|
+
* which stays the same.
|
|
865
889
|
*/
|
|
866
890
|
function pickerFocusSelector(el) {
|
|
867
891
|
if (el.closest("#pickbtn")) return "#pickbtn";
|
|
@@ -876,10 +900,10 @@ function pickerFocusSelector(el) {
|
|
|
876
900
|
return null;
|
|
877
901
|
}
|
|
878
902
|
/**
|
|
879
|
-
* The longer explanation, for what a tooltip is too small to hold
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
903
|
+
* The longer explanation, for what a tooltip is too small to hold. Mainly the
|
|
904
|
+
* two points that surprise people: part of a task's chain is grouping this
|
|
905
|
+
* page adds, and a task can be declared by a runner or only implied by a
|
|
906
|
+
* convention.
|
|
883
907
|
*/
|
|
884
908
|
const HELP = [
|
|
885
909
|
"<h3>What this is</h3>",
|
|
@@ -916,28 +940,25 @@ const HELP = [
|
|
|
916
940
|
"<p>The very first paint may come from a stored listing so the page appears at once on a repository whose slowest runner takes seconds. When it does, the status bar names those runners after <code>cached:</code> and marks their tabs with <code>~</code>, and a fresh read is already running behind the page. Rows never come from a store without saying so.</p>"
|
|
917
941
|
].join("");
|
|
918
942
|
/**
|
|
919
|
-
* The header
|
|
920
|
-
*
|
|
921
|
-
*
|
|
943
|
+
* The header for the selection column: a checkbox mark, sized to match the
|
|
944
|
+
* row checkboxes below it. Visual only. The accessible name comes from the
|
|
945
|
+
* button's aria-label, so a screen reader says "Shown", not a shape.
|
|
922
946
|
*/
|
|
923
947
|
const CHECK_GLYPH = "<svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"1.5\" y=\"1.5\" width=\"13\" height=\"13\" rx=\"2.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\"/><path d=\"M4.5 8.4l2.4 2.4 4.6-5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>";
|
|
924
948
|
/**
|
|
925
|
-
* The picker's sort header: three columns that reorder the one
|
|
949
|
+
* The picker's sort header: three columns that reorder the one saved order.
|
|
926
950
|
*
|
|
927
|
-
* The columns are
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
* whatever it is nearest.
|
|
951
|
+
* The columns are in the same order as in each row: shown, name, count. A
|
|
952
|
+
* header must sit above the column it sorts, or it looks like it belongs to
|
|
953
|
+
* whatever is nearest.
|
|
931
954
|
*
|
|
932
|
-
* The row's leading drag handle is repeated here, hidden,
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* ever changes.
|
|
955
|
+
* The row's leading drag handle is repeated here, hidden, instead of a fixed
|
|
956
|
+
* width. It is the same element and character, so the columns start where the
|
|
957
|
+
* row's content starts even if the handle changes.
|
|
936
958
|
*
|
|
937
959
|
* Real buttons, so the header is reachable by Tab and by voice. The arrow
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
* follows a refresh rather than a snapshot.
|
|
960
|
+
* shows only while the current order matches that sort. After a drag, neither
|
|
961
|
+
* column shows one. Count uses the live task counts, so it follows a refresh.
|
|
941
962
|
*/
|
|
942
963
|
function renderSortHead() {
|
|
943
964
|
const active = activeSort();
|
|
@@ -952,10 +973,10 @@ function renderSortHead() {
|
|
|
952
973
|
/**
|
|
953
974
|
* The runner picker, a control in the toolbar's Scope cluster.
|
|
954
975
|
*
|
|
955
|
-
* A
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
976
|
+
* A runner turned off here is still collected and only hidden. That keeps the
|
|
977
|
+
* toggle instant, and its counts are current when you turn it back on. A
|
|
978
|
+
* runner that failed to probe is still listed with its error, so unchecking
|
|
979
|
+
* it hides a broken runner.
|
|
959
980
|
*/
|
|
960
981
|
function renderRunnerPicker(cat) {
|
|
961
982
|
const enabled = state.enabled;
|
|
@@ -976,14 +997,13 @@ function listRows() {
|
|
|
976
997
|
/**
|
|
977
998
|
* Which row Enter takes, and where the single tab stop into the list sits.
|
|
978
999
|
*
|
|
979
|
-
*
|
|
980
|
-
* mark follows it: Enter there copies
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
* lie about what the key does.
|
|
1000
|
+
* It depends on whether a row is focused. While `focusedId` names a row, the
|
|
1001
|
+
* mark follows it: Enter there copies that row. The mark goes back to the top
|
|
1002
|
+
* hit when `focusedId` is cleared, which the search box's focus handler does
|
|
1003
|
+
* (see input.ts). Moving to a toolbar button leaves the row marked, because
|
|
1004
|
+
* Enter there presses that button, not the list. The top hit is marked only
|
|
1005
|
+
* while a query is active. With no query there is no top hit, and a marked
|
|
1006
|
+
* first row would misstate what Enter does.
|
|
987
1007
|
*
|
|
988
1008
|
* A focused row whose task no longer exists (a filter dropped it) clears
|
|
989
1009
|
* `focusedId` rather than leaving the list marked with a row that is gone.
|
|
@@ -1007,8 +1027,8 @@ function markEnterTarget() {
|
|
|
1007
1027
|
/**
|
|
1008
1028
|
* Move the list's keyboard focus to `id`, or off the list entirely with null.
|
|
1009
1029
|
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1030
|
+
* Updates the mark rather than re-rendering. The rows have not changed, and a
|
|
1031
|
+
* full render() on every arrow key would rebuild the whole table to move one
|
|
1012
1032
|
* class.
|
|
1013
1033
|
*/
|
|
1014
1034
|
function setFocusedRow(id) {
|
|
@@ -1016,12 +1036,8 @@ function setFocusedRow(id) {
|
|
|
1016
1036
|
markEnterTarget();
|
|
1017
1037
|
}
|
|
1018
1038
|
/**
|
|
1019
|
-
* One runner's
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* This is what the legend's chain chips used to say, for every runner at
|
|
1023
|
-
* once. Asked for one runner at a time it fits, and it can say more than a
|
|
1024
|
-
* chip had room for.
|
|
1039
|
+
* One runner's explanation: what each position of its path selects, how it
|
|
1040
|
+
* is read, and whether reading it means running anything.
|
|
1025
1041
|
*/
|
|
1026
1042
|
function showRunnerInfo(runner) {
|
|
1027
1043
|
const report = (state.catalog?.reports || []).find((r) => r.runner === runner);
|
|
@@ -1042,23 +1058,23 @@ function showRunnerInfo(runner) {
|
|
|
1042
1058
|
$("help").showModal();
|
|
1043
1059
|
}
|
|
1044
1060
|
/**
|
|
1045
|
-
* The column
|
|
1046
|
-
* `thead` in each group's table would repeat the row down the whole page
|
|
1047
|
-
*
|
|
1048
|
-
* starts at the same x
|
|
1061
|
+
* The column headers, drawn as their own depth-0 table in the sticky header.
|
|
1062
|
+
* A `thead` in each group's table would repeat the row down the whole page.
|
|
1063
|
+
* This one stays in place and still lines up, because every table's command
|
|
1064
|
+
* column starts at the same x at every depth.
|
|
1049
1065
|
*/
|
|
1050
1066
|
function renderColHeads() {
|
|
1051
1067
|
const cells = COLUMNS.filter((c) => c.label !== "Runs" || showRuns()).map((c) => "<th title=\"" + escapeHtml(c.tip) + "\">" + (escapeHtml(c.label) || " ") + "</th>").join("");
|
|
1052
1068
|
$("colheads").innerHTML = "<table>" + colgroup(0) + "<thead><tr>" + cells + "</tr></thead></table>";
|
|
1053
1069
|
}
|
|
1054
1070
|
/**
|
|
1055
|
-
* The cache's three states, as one status span
|
|
1071
|
+
* The cache's three states, as one status span, the same three the TUI shows.
|
|
1056
1072
|
*
|
|
1057
1073
|
* Fresh returns "": there is nothing to report, and a span that is always
|
|
1058
|
-
*
|
|
1059
|
-
* stale because it is the case the cache exists for
|
|
1060
|
-
* seconds is why the page has rows instead of a spinner,
|
|
1061
|
-
*
|
|
1074
|
+
* shown is a span nobody reads. Stale and slow is kept apart from ordinary
|
|
1075
|
+
* stale because it is the case the cache exists for. A runner measured at
|
|
1076
|
+
* seconds is why the page has rows instead of a spinner, so it gets the more
|
|
1077
|
+
* prominent class. Slowness is measured, never assumed.
|
|
1062
1078
|
*/
|
|
1063
1079
|
function cacheSpan(rows) {
|
|
1064
1080
|
const stale = rows.filter((r) => r.state === "stale");
|
|
@@ -1069,27 +1085,23 @@ function cacheSpan(rows) {
|
|
|
1069
1085
|
return "<span>cached: " + escapeHtml(stale.map((r) => r.runner + " " + humanAge(r.ageMs)).join(", ")) + " - re-probing</span>";
|
|
1070
1086
|
}
|
|
1071
1087
|
/**
|
|
1072
|
-
* Runners
|
|
1073
|
-
* everything
|
|
1088
|
+
* Runners withheld because execution is off, shown in the page's own bar
|
|
1089
|
+
* above everything. It matches the CLI's "N runners not collected" line.
|
|
1074
1090
|
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
* saw a shorter catalog and no statement that anything was missing, which is
|
|
1080
|
-
* the one thing this tool must never do quietly.
|
|
1091
|
+
* Without it, the page would mention withheld runners only on the tab badge,
|
|
1092
|
+
* in its tooltip, in the per-runner modal and in the picker, all behind a
|
|
1093
|
+
* hover or a click. Someone would see a shorter catalog with nothing saying
|
|
1094
|
+
* that anything was missing, which this tool must never do quietly.
|
|
1081
1095
|
*
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
* in a row of counts reads as one more piece of chrome.
|
|
1096
|
+
* It is its own bar rather than a span in the status strip. The status strip
|
|
1097
|
+
* reports numbers about what you are looking at, and this asks for a decision
|
|
1098
|
+
* about what you are not. A button in a row of counts looks like one more
|
|
1099
|
+
* control.
|
|
1087
1100
|
*
|
|
1088
|
-
* It names the runners rather than only counting them
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
* wrong instruction.
|
|
1101
|
+
* It names the runners rather than only counting them, so the reader does not
|
|
1102
|
+
* have to ask which. The trust button is included only when trust is what is
|
|
1103
|
+
* missing. Otherwise execution is off for the session and trusting the
|
|
1104
|
+
* repository would change nothing.
|
|
1093
1105
|
*/
|
|
1094
1106
|
function withheldBar(reports) {
|
|
1095
1107
|
const held = reports.filter((s) => s.skippedForExec);
|
|
@@ -1109,24 +1121,24 @@ function renderTrustBar() {
|
|
|
1109
1121
|
host.hidden = html === "";
|
|
1110
1122
|
}
|
|
1111
1123
|
/**
|
|
1112
|
-
* Kept separate from the table so an unchanged poll can
|
|
1113
|
-
* without touching the
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1124
|
+
* Kept separate from the table so an unchanged poll can update the clock
|
|
1125
|
+
* without touching the table. Otherwise Refresh on an unchanged repo would
|
|
1126
|
+
* look like nothing happened, and the timestamp would show data as older than
|
|
1127
|
+
* it is.
|
|
1116
1128
|
*/
|
|
1117
1129
|
function renderStatus(shown, total) {
|
|
1118
1130
|
const errs = (state.catalog?.reports || []).filter((s) => s.status === "error").map((s) => s.runner);
|
|
1119
1131
|
$("status").innerHTML = "<span>" + shown + " of " + total + " " + (state.runner === "all" ? "commands, all runners" : state.runner + " commands") + "</span><span>checked " + new Date(state.checkedAt).toLocaleTimeString() + (state.loading ? " - refreshing" : "") + "</span>" + cacheSpan(state.cache) + (errs.length ? "<span class=\"err\">probe failed: " + errs.join(", ") + "</span>" : "") + "<span><kbd>/</kbd> search · <kbd>Enter</kbd> copy top hit · <kbd>↑</kbd><kbd>↓</kbd> move · <kbd>Esc</kbd> back to search, again to clear it</span>";
|
|
1120
1132
|
}
|
|
1121
1133
|
/**
|
|
1122
|
-
* The run bar:
|
|
1134
|
+
* The run bar: enter a task's arguments before handing over the terminal.
|
|
1123
1135
|
*
|
|
1124
|
-
* The command
|
|
1136
|
+
* The command prefix is static text, not part of the field. The server adds
|
|
1125
1137
|
* what this sends to the argv it looked up itself and ignores anything else,
|
|
1126
|
-
* so an editable `just`
|
|
1127
|
-
*
|
|
1138
|
+
* so an editable `just` would mislead: editing it would change nothing. Only
|
|
1139
|
+
* the trailing arguments can be typed, and the bar shows exactly that.
|
|
1128
1140
|
*
|
|
1129
|
-
* A bar rather than a modal: it
|
|
1141
|
+
* A bar rather than a modal: it needs no click to dismiss, and the row that
|
|
1130
1142
|
* opened it stays on screen behind it.
|
|
1131
1143
|
*/
|
|
1132
1144
|
function showRunBar(task) {
|
|
@@ -1142,17 +1154,17 @@ function showRunBar(task) {
|
|
|
1142
1154
|
field.focus();
|
|
1143
1155
|
return field;
|
|
1144
1156
|
}
|
|
1145
|
-
/**
|
|
1157
|
+
/** Remove the run bar. Idempotent: `esc`, a run and a re-open all call it. */
|
|
1146
1158
|
function hideRunBar() {
|
|
1147
1159
|
document.getElementById("runbar")?.remove();
|
|
1148
1160
|
}
|
|
1149
1161
|
/**
|
|
1150
|
-
* The end of the page: the task now
|
|
1162
|
+
* The end of the page: the task now has the terminal and this server is gone.
|
|
1151
1163
|
*
|
|
1152
|
-
* It replaces the view rather than sitting beside it, because
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1164
|
+
* It replaces the view rather than sitting beside it, because nothing on
|
|
1165
|
+
* screen works any more. The catalog cannot be refreshed, the buttons cannot
|
|
1166
|
+
* act, and a poll would only show a failed fetch. So the page says the tab
|
|
1167
|
+
* is finished.
|
|
1156
1168
|
*/
|
|
1157
1169
|
function showHandoff(command) {
|
|
1158
1170
|
const el = document.createElement("div");
|
|
@@ -1164,7 +1176,7 @@ function showHandoff(command) {
|
|
|
1164
1176
|
el.tabIndex = -1;
|
|
1165
1177
|
el.focus();
|
|
1166
1178
|
}
|
|
1167
|
-
/**
|
|
1179
|
+
/** Shown on the row that asked, when another run got the terminal first. */
|
|
1168
1180
|
function showRunTaken(button) {
|
|
1169
1181
|
const cell = button.closest("td.act");
|
|
1170
1182
|
if (!cell || cell.querySelector(".runerr")) return;
|
|
@@ -1176,10 +1188,10 @@ function showRunTaken(button) {
|
|
|
1176
1188
|
setTimeout(() => note.remove(), 4e3);
|
|
1177
1189
|
}
|
|
1178
1190
|
/**
|
|
1179
|
-
*
|
|
1180
|
-
* rather than hard-coded because the search row and the status line wrap at
|
|
1181
|
-
* widths
|
|
1182
|
-
*
|
|
1191
|
+
* Set the sticky header's real height as a CSS variable. It is measured
|
|
1192
|
+
* rather than hard-coded because the search row and the status line wrap at
|
|
1193
|
+
* narrow widths. A wrong number would hide the first group header behind the
|
|
1194
|
+
* sticky header or leave a gap under it.
|
|
1183
1195
|
*/
|
|
1184
1196
|
function measureChrome() {
|
|
1185
1197
|
document.documentElement.style.setProperty("--chrome-h", Math.round($("chrome").getBoundingClientRect().height) + "px");
|
|
@@ -1187,17 +1199,17 @@ function measureChrome() {
|
|
|
1187
1199
|
//#endregion
|
|
1188
1200
|
//#region src/args.ts
|
|
1189
1201
|
/**
|
|
1190
|
-
* Split
|
|
1191
|
-
*
|
|
1202
|
+
* Split typed arguments into words the way a shell does, and do nothing else
|
|
1203
|
+
* a shell does.
|
|
1192
1204
|
*
|
|
1193
1205
|
* Quotes group and a backslash escapes the next character. There is no
|
|
1194
|
-
* globbing, no variable expansion, no operators
|
|
1195
|
-
* goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
1196
|
-
* so `*.log` is passed through as the
|
|
1197
|
-
* the same rule `argv`
|
|
1206
|
+
* globbing, no variable expansion, no operators and no substitution. The
|
|
1207
|
+
* result goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
1208
|
+
* shell, so `*.log` is passed through as the five characters typed. This is
|
|
1209
|
+
* the same rule that keeps `argv` separate from `display`.
|
|
1198
1210
|
*
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1211
|
+
* This is not `.split(/\s+/)` for one reason: a quoted `"two words"` must stay
|
|
1212
|
+
* one argument.
|
|
1201
1213
|
*/
|
|
1202
1214
|
function splitArgs(input) {
|
|
1203
1215
|
const out = [];
|
|
@@ -1235,40 +1247,21 @@ function splitArgs(input) {
|
|
|
1235
1247
|
return out;
|
|
1236
1248
|
}
|
|
1237
1249
|
//#endregion
|
|
1238
|
-
//#region src/app.ts
|
|
1239
|
-
/**
|
|
1240
|
-
* The app's names. Every user-facing name that carries the product name
|
|
1241
|
-
* derives from here. Browser-safe: the page imports it too.
|
|
1242
|
-
*/
|
|
1243
|
-
/** The product name: config directory, cache directory, trust store key, message prefix. */
|
|
1244
|
-
const APP = "wayfinder";
|
|
1245
|
-
/**
|
|
1246
|
-
* The name before the rename to wayfinder. Its user config, project config,
|
|
1247
|
-
* trust store and config variable are still read when the new ones are
|
|
1248
|
-
* absent. Nothing is written under it.
|
|
1249
|
-
*/
|
|
1250
|
-
const LEGACY_APP = "waypost";
|
|
1251
|
-
`${APP.toUpperCase()}`;
|
|
1252
|
-
`${LEGACY_APP.toUpperCase()}`;
|
|
1253
|
-
/** The request header that carries the web view's session token. */
|
|
1254
|
-
const TOKEN_HEADER = `x-${APP}-token`;
|
|
1255
|
-
//#endregion
|
|
1256
1250
|
//#region src/web/api.ts
|
|
1257
1251
|
/**
|
|
1258
1252
|
* The session token the server embedded in this page, read once at import.
|
|
1259
1253
|
*
|
|
1260
|
-
*
|
|
1261
|
-
* outlive the tab or
|
|
1262
|
-
* with the page, which is the lifetime
|
|
1254
|
+
* Kept in module state only. localStorage, sessionStorage and cookies either
|
|
1255
|
+
* outlive the tab or are sent with requests the page did not make. Module
|
|
1256
|
+
* state ends with the page, which is the lifetime the token should have.
|
|
1263
1257
|
*/
|
|
1264
1258
|
const token = globalThis.__WAYFINDER_TOKEN__ ?? "";
|
|
1265
1259
|
/**
|
|
1266
|
-
* Every server call goes through here
|
|
1260
|
+
* Every server call goes through here, the one place the token is attached.
|
|
1267
1261
|
*
|
|
1268
1262
|
* The endpoints are on loopback, which any process on this machine and any
|
|
1269
|
-
* page the user
|
|
1270
|
-
*
|
|
1271
|
-
* which is the point.
|
|
1263
|
+
* page the user visits can reach, so reads and writes both carry the token.
|
|
1264
|
+
* Send new endpoints through here. A request without the token gets a 401.
|
|
1272
1265
|
*/
|
|
1273
1266
|
function authFetch(path, init = {}) {
|
|
1274
1267
|
const headers = new Headers(init.headers);
|
|
@@ -1292,12 +1285,12 @@ async function getConfig() {
|
|
|
1292
1285
|
/**
|
|
1293
1286
|
* Write staged settings to the project file, and read back what that produced.
|
|
1294
1287
|
*
|
|
1295
|
-
* A
|
|
1288
|
+
* A patch of dotted keys, named as `way config set` names them. The server
|
|
1296
1289
|
* applies it to the file's raw contents, so a key this version does not know
|
|
1297
|
-
* survives the save
|
|
1290
|
+
* survives the save (see `writeProjectConfig` in serve.ts).
|
|
1298
1291
|
*
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1292
|
+
* On success it returns the config as it now is in the file, so the screen
|
|
1293
|
+
* re-renders from the file in one round trip.
|
|
1301
1294
|
*/
|
|
1302
1295
|
async function saveConfig(set) {
|
|
1303
1296
|
try {
|
|
@@ -1349,11 +1342,10 @@ async function trustRepo() {
|
|
|
1349
1342
|
/**
|
|
1350
1343
|
* Revoke this repository's trust.
|
|
1351
1344
|
*
|
|
1352
|
-
* The store
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
* rather than implying a revoke the process did not perform.
|
|
1345
|
+
* The store then says not trusted. The running session keeps the execution
|
|
1346
|
+
* setting it decided at start. See the DELETE branch in serve.ts for why the
|
|
1347
|
+
* server does not guess whether that came from the store or from `--exec`.
|
|
1348
|
+
* The caller says so, rather than implying a revoke that did not happen.
|
|
1357
1349
|
*/
|
|
1358
1350
|
async function untrustRepo() {
|
|
1359
1351
|
try {
|
|
@@ -1378,12 +1370,11 @@ async function untrustRepo() {
|
|
|
1378
1370
|
/**
|
|
1379
1371
|
* Ask the server to hand its terminal to a task.
|
|
1380
1372
|
*
|
|
1381
|
-
* The id selects the command
|
|
1382
|
-
* (`staging` for `just deploy <env>`). The server looks the
|
|
1383
|
-
* catalog it built
|
|
1384
|
-
* arguments and the cwd never come from
|
|
1385
|
-
*
|
|
1386
|
-
* the port.
|
|
1373
|
+
* The id selects the command. `args` are the trailing arguments a recipe with
|
|
1374
|
+
* parameters needs (`staging` for `just deploy <env>`). The server looks the
|
|
1375
|
+
* task up in the catalog it built and adds these. The binary, the leading
|
|
1376
|
+
* arguments and the cwd never come from the page, because anything that can
|
|
1377
|
+
* reach the port could send a command.
|
|
1387
1378
|
*/
|
|
1388
1379
|
async function requestRun(id, args = []) {
|
|
1389
1380
|
try {
|
|
@@ -1420,13 +1411,13 @@ async function requestRun(id, args = []) {
|
|
|
1420
1411
|
/**
|
|
1421
1412
|
* Pull the catalog.
|
|
1422
1413
|
*
|
|
1423
|
-
* `force` is the Refresh button, and it
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1414
|
+
* `force` is the Refresh button, and it always runs a real probe of every
|
|
1415
|
+
* runner, since a refresh answered from a store is not a refresh. An unforced
|
|
1416
|
+
* call (first view, focus, the poll) takes the newest answer the server has.
|
|
1417
|
+
* On the first request that is the stored answer, with a probe already
|
|
1418
|
+
* running in the background. `state.cache` says which rows those were.
|
|
1428
1419
|
*
|
|
1429
|
-
* The fingerprint check
|
|
1420
|
+
* The fingerprint check stops an unchanged poll from resetting the scroll
|
|
1430
1421
|
* position and open groups.
|
|
1431
1422
|
*/
|
|
1432
1423
|
async function load(force) {
|
|
@@ -1462,29 +1453,28 @@ async function load(force) {
|
|
|
1462
1453
|
//#endregion
|
|
1463
1454
|
//#region src/web/settings.ts
|
|
1464
1455
|
/**
|
|
1465
|
-
* The settings screen
|
|
1456
|
+
* The settings screen: this project's configuration, and edits to it.
|
|
1466
1457
|
*
|
|
1467
|
-
* Edits
|
|
1468
|
-
* committed file, so a click must not
|
|
1458
|
+
* Edits are staged. Nothing is written until Save. The project config is a
|
|
1459
|
+
* committed file, so a click must not silently change someone's working tree.
|
|
1469
1460
|
*
|
|
1470
|
-
* It is
|
|
1471
|
-
*
|
|
1461
|
+
* It is not the runner picker. The picker in the header filters this session
|
|
1462
|
+
* and is then forgotten. This screen sets which runners the project uses.
|
|
1472
1463
|
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1475
|
-
* describes.
|
|
1464
|
+
* Sections follow the config schema's key order (runners, execution,
|
|
1465
|
+
* discovery, excluded paths), so the screen reads like the file it describes.
|
|
1476
1466
|
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1467
|
+
* Its state lives here, not in `state.ts`. The staged edits belong to the
|
|
1468
|
+
* dialog and mean nothing once it closes. In the page-wide `AppState`, every
|
|
1469
|
+
* user of that state would carry a field about a screen it never opens.
|
|
1480
1470
|
*/
|
|
1481
1471
|
/** What the server last told us the configuration is. */
|
|
1482
1472
|
let loaded = null;
|
|
1483
|
-
/** Runner ids the catalog reported
|
|
1473
|
+
/** Runner ids the catalog reported. The config alone cannot supply them. */
|
|
1484
1474
|
let knownRunners = [];
|
|
1485
1475
|
/**
|
|
1486
|
-
* Edits not yet written, by dotted key. Empty means
|
|
1487
|
-
*
|
|
1476
|
+
* Edits not yet written, by dotted key. Empty means nothing is unsaved. This
|
|
1477
|
+
* is the only unsaved-changes test, since a separate boolean could disagree.
|
|
1488
1478
|
*/
|
|
1489
1479
|
let staged = {};
|
|
1490
1480
|
/** A message from the last Save, shown until the next render clears it. */
|
|
@@ -1592,8 +1582,8 @@ function openSettings(config, known) {
|
|
|
1592
1582
|
return screen();
|
|
1593
1583
|
}
|
|
1594
1584
|
/**
|
|
1595
|
-
* Handle a click inside the settings dialog. Returns true when
|
|
1596
|
-
* the page's
|
|
1585
|
+
* Handle a click inside the settings dialog. Returns true when this function
|
|
1586
|
+
* handled it, so the page's shared click listener can stop.
|
|
1597
1587
|
*/
|
|
1598
1588
|
function handleSettingsClick(target) {
|
|
1599
1589
|
const runner = target.closest("[data-set-runner]");
|
|
@@ -1692,13 +1682,12 @@ async function commit() {
|
|
|
1692
1682
|
//#endregion
|
|
1693
1683
|
//#region src/web/input.ts
|
|
1694
1684
|
/**
|
|
1695
|
-
* Ask for the terminal and
|
|
1685
|
+
* Ask for the terminal and handle every outcome.
|
|
1696
1686
|
*
|
|
1697
1687
|
* Shared by the row button and the run bar so the four outcomes are handled
|
|
1698
|
-
*
|
|
1699
|
-
* would
|
|
1700
|
-
* "another run took the terminal"
|
|
1701
|
-
* yourself.
|
|
1688
|
+
* in one place. `button`, when given, is disabled for the round trip.
|
|
1689
|
+
* Otherwise a double click would send a second POST that gets a 409, and the
|
|
1690
|
+
* user would be told "another run took the terminal" about their own click.
|
|
1702
1691
|
*/
|
|
1703
1692
|
async function handOff(id, args, button) {
|
|
1704
1693
|
if (button) button.disabled = true;
|
|
@@ -1720,9 +1709,9 @@ async function handOff(id, args, button) {
|
|
|
1720
1709
|
/**
|
|
1721
1710
|
* Keys for the run bar's field: Enter runs what is typed, Escape goes back.
|
|
1722
1711
|
*
|
|
1723
|
-
* Bound to the field
|
|
1724
|
-
*
|
|
1725
|
-
*
|
|
1712
|
+
* Bound to the field rather than the document, so it goes away with the bar.
|
|
1713
|
+
* A leftover document listener could send a run for a task the user had
|
|
1714
|
+
* already dismissed.
|
|
1726
1715
|
*/
|
|
1727
1716
|
function armRunBar(id, field) {
|
|
1728
1717
|
field.addEventListener("keydown", (ev) => {
|
|
@@ -1741,8 +1730,8 @@ function armRunBar(id, field) {
|
|
|
1741
1730
|
/**
|
|
1742
1731
|
* The refresh loop, and the flag that ends it.
|
|
1743
1732
|
*
|
|
1744
|
-
* The flag is
|
|
1745
|
-
*
|
|
1733
|
+
* The flag is needed as well as clearing the interval, because the focus
|
|
1734
|
+
* listener also loads. One flag turns both off in one place.
|
|
1746
1735
|
*/
|
|
1747
1736
|
let pollTimer;
|
|
1748
1737
|
let polling = true;
|
|
@@ -1855,29 +1844,28 @@ function wireInput() {
|
|
|
1855
1844
|
if (menu && !target.closest(".picker")) menu.hidden = true;
|
|
1856
1845
|
});
|
|
1857
1846
|
/**
|
|
1858
|
-
* Drag
|
|
1859
|
-
*
|
|
1860
|
-
* surfaces.
|
|
1847
|
+
* Drag to reorder, shared by the tab bar and the picker. Both mark their
|
|
1848
|
+
* draggable elements with a runner id, so one set of handlers serves both.
|
|
1861
1849
|
*
|
|
1862
|
-
* The drag
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* will produce
|
|
1850
|
+
* The drag shows a preview. A solid clone follows the pointer instead of the
|
|
1851
|
+
* browser's faint default drag image, and the real elements move as the
|
|
1852
|
+
* pointer passes their midpoints. The dragged element moves with them,
|
|
1853
|
+
* faded, to mark where it would land. So the list shows the order the drop
|
|
1854
|
+
* will produce before the drop.
|
|
1867
1855
|
*
|
|
1868
|
-
* The DOM is only the preview. State
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
1856
|
+
* The DOM is only the preview. State is the source of truth: the drop saves
|
|
1857
|
+
* through saveRunnerOrder, and a drag cancelled without a drop re-renders
|
|
1858
|
+
* from the saved order, which puts everything back.
|
|
1871
1859
|
*/
|
|
1872
1860
|
let dragging = null;
|
|
1873
1861
|
let dragEl = null;
|
|
1874
1862
|
let ghost = null;
|
|
1875
1863
|
/**
|
|
1876
|
-
* The
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
*
|
|
1864
|
+
* The order the user has actually seen, updated once per animation frame.
|
|
1865
|
+
* Chromium sends a last `dragover` in the same task as the `drop`, so the
|
|
1866
|
+
* move that dragover makes is never painted. Saving the live DOM order would
|
|
1867
|
+
* then be one position off from what was on screen. Saving this snapshot
|
|
1868
|
+
* saves what was last shown.
|
|
1881
1869
|
*/
|
|
1882
1870
|
let painted = [];
|
|
1883
1871
|
let paintQueued = false;
|
|
@@ -1893,15 +1881,15 @@ function wireInput() {
|
|
|
1893
1881
|
});
|
|
1894
1882
|
}
|
|
1895
1883
|
/**
|
|
1896
|
-
* Put the page back
|
|
1897
|
-
*
|
|
1898
|
-
* tab strip and the picker, which
|
|
1899
|
-
* fires no `dragend` for a source
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1884
|
+
* Put the page back as it was before the drag. Idempotent, and called from
|
|
1885
|
+
* both `drop` and `dragend`. `drop` runs it before saving, because saving
|
|
1886
|
+
* re-renders the tab strip and the picker, which removes the drag source, and
|
|
1887
|
+
* Chromium fires no `dragend` for a source no longer in the document. If
|
|
1888
|
+
* only `dragend` cleaned up, every saved drag would leave its drag image and
|
|
1889
|
+
* drag state behind.
|
|
1902
1890
|
*
|
|
1903
|
-
* Returns whether there was a drag to end, which
|
|
1904
|
-
* is the cancel path
|
|
1891
|
+
* Returns whether there was a drag to end, which tells `dragend` whether it
|
|
1892
|
+
* is the cancel path or the end of a saved drag.
|
|
1905
1893
|
*/
|
|
1906
1894
|
function endDrag() {
|
|
1907
1895
|
if (!dragEl) return false;
|
|
@@ -2012,9 +2000,9 @@ function wireInput() {
|
|
|
2012
2000
|
node.querySelector(".twisty").textContent = state.collapsed.has(key) ? "▸" : "▾";
|
|
2013
2001
|
});
|
|
2014
2002
|
/**
|
|
2015
|
-
*
|
|
2016
|
-
* table per tree group, so "next row" is the next row in
|
|
2017
|
-
* across all of #out
|
|
2003
|
+
* Keyboard handling for the whole results list. Rows are <tr> elements in
|
|
2004
|
+
* one table per tree group, so "next row" is the next row in document order
|
|
2005
|
+
* across all of #out, not within one table.
|
|
2018
2006
|
*/
|
|
2019
2007
|
$("out").addEventListener("keydown", (e) => {
|
|
2020
2008
|
const ev = e;
|
|
@@ -2081,9 +2069,9 @@ function wireInput() {
|
|
|
2081
2069
|
/**
|
|
2082
2070
|
* Put a row's command on the clipboard and say what happened.
|
|
2083
2071
|
*
|
|
2084
|
-
* The button is the
|
|
2085
|
-
* a
|
|
2086
|
-
*
|
|
2072
|
+
* The button is the only sign that the clipboard changed, so a refused write
|
|
2073
|
+
* (a permissions policy, or a page that is not the active document) must not
|
|
2074
|
+
* be reported as a copy. Returns whether the write succeeded.
|
|
2087
2075
|
*/
|
|
2088
2076
|
async function copyCommand(copy) {
|
|
2089
2077
|
let ok = true;
|
|
@@ -2103,10 +2091,10 @@ async function copyCommand(copy) {
|
|
|
2103
2091
|
/**
|
|
2104
2092
|
* Copy a row's command and say so on the row.
|
|
2105
2093
|
*
|
|
2106
|
-
* The confirmation
|
|
2107
|
-
*
|
|
2108
|
-
*
|
|
2109
|
-
*
|
|
2094
|
+
* The confirmation shows on the row, not just the button, because neither
|
|
2095
|
+
* caller is looking at the button. From the search box the button is far to
|
|
2096
|
+
* the right, and from a focused row the keypress was on the row. One helper,
|
|
2097
|
+
* so both callers behave the same.
|
|
2110
2098
|
*/
|
|
2111
2099
|
function copyRow(row) {
|
|
2112
2100
|
const button = row.querySelector(".copy");
|
|
@@ -2133,10 +2121,10 @@ function runnerOf(el) {
|
|
|
2133
2121
|
/**
|
|
2134
2122
|
* The drag image: a solid, elevated copy of what is being dragged.
|
|
2135
2123
|
*
|
|
2136
|
-
* setDragImage only takes
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
*
|
|
2124
|
+
* setDragImage only takes a rendered element, so the clone is added to the
|
|
2125
|
+
* document and placed off-screen by its class. It is removed at the end of
|
|
2126
|
+
* the drag, not on the next tick, because the browser may not have taken its
|
|
2127
|
+
* snapshot yet.
|
|
2140
2128
|
*/
|
|
2141
2129
|
function makeDragGhost(el, e, dt) {
|
|
2142
2130
|
const box = el.getBoundingClientRect();
|
|
@@ -2162,11 +2150,10 @@ function makeDragGhost(el, e, dt) {
|
|
|
2162
2150
|
/**
|
|
2163
2151
|
* Move `moving` before `before` and let the displaced siblings slide there.
|
|
2164
2152
|
*
|
|
2165
|
-
* insertBefore is instant, so the
|
|
2166
|
-
*
|
|
2167
|
-
*
|
|
2168
|
-
*
|
|
2169
|
-
* asking for exactly that.
|
|
2153
|
+
* insertBefore is instant, so without this the siblings would jump. Each
|
|
2154
|
+
* sibling's old position is measured, it is offset back there, and then the
|
|
2155
|
+
* offset is released (the FLIP technique: first, last, invert, play). With
|
|
2156
|
+
* reduced motion set, the siblings jump, which is what that setting asks for.
|
|
2170
2157
|
*/
|
|
2171
2158
|
function slideInto(parent, moving, before) {
|
|
2172
2159
|
if (moving.nextSibling === before && before !== null) return;
|
|
@@ -2191,14 +2178,14 @@ function slideInto(parent, moving, before) {
|
|
|
2191
2178
|
/**
|
|
2192
2179
|
* Commit a previewed arrangement to the persisted order.
|
|
2193
2180
|
*
|
|
2194
|
-
* The surface
|
|
2195
|
-
*
|
|
2196
|
-
*
|
|
2197
|
-
*
|
|
2198
|
-
*
|
|
2199
|
-
* visible predecessor when it was dropped last
|
|
2200
|
-
* "before the first
|
|
2201
|
-
* would
|
|
2181
|
+
* The dragged surface shows only some of the runners (the tab bar folds the
|
|
2182
|
+
* empty ones and hides the disabled ones), so the preview cannot become the
|
|
2183
|
+
* order as it is. A drag only decides where the moved runner sits among the
|
|
2184
|
+
* runners on screen, and the hidden runners must keep their neighbours. So
|
|
2185
|
+
* the moved runner is placed before its new visible successor, or after its
|
|
2186
|
+
* visible predecessor when it was dropped last. A drop at the start means
|
|
2187
|
+
* "before the first visible runner", not "at the front of the full list",
|
|
2188
|
+
* which would move it past folded and disabled runners the user never saw.
|
|
2202
2189
|
*/
|
|
2203
2190
|
function commitDragOrder(shown, moved) {
|
|
2204
2191
|
const order = runnerOrder().filter((r) => r !== moved);
|
|
@@ -2211,13 +2198,13 @@ function commitDragOrder(shown, moved) {
|
|
|
2211
2198
|
saveRunnerOrder(order);
|
|
2212
2199
|
}
|
|
2213
2200
|
/**
|
|
2214
|
-
* Make a group of buttons
|
|
2201
|
+
* Make a group of buttons one tab stop, with arrow keys moving inside it.
|
|
2215
2202
|
*
|
|
2216
|
-
* Without this, two segmented controls and eight runner tabs
|
|
2217
|
-
* stops between the search box and anything else
|
|
2218
|
-
*
|
|
2219
|
-
*
|
|
2220
|
-
*
|
|
2203
|
+
* Without this, two segmented controls and eight runner tabs add a dozen Tab
|
|
2204
|
+
* stops between the search box and anything else. Tab would move to the next
|
|
2205
|
+
* button instead of the next control, which is not what a keyboard user
|
|
2206
|
+
* expects. Only the active button is reachable by Tab. The rest are reached
|
|
2207
|
+
* with the arrows, as in a radio group or tab list.
|
|
2221
2208
|
*/
|
|
2222
2209
|
function rovingGroup(container, selector = "button") {
|
|
2223
2210
|
if (!container) return;
|
|
@@ -2254,7 +2241,7 @@ const THEME_CYCLE = {
|
|
|
2254
2241
|
light: "dark",
|
|
2255
2242
|
dark: "system"
|
|
2256
2243
|
};
|
|
2257
|
-
/** How each scheme
|
|
2244
|
+
/** How the button shows each scheme when it is the one in use. */
|
|
2258
2245
|
const THEME_FACE = {
|
|
2259
2246
|
system: {
|
|
2260
2247
|
glyph: "◐",
|
|
@@ -2273,14 +2260,13 @@ const THEME_FACE = {
|
|
|
2273
2260
|
}
|
|
2274
2261
|
};
|
|
2275
2262
|
/**
|
|
2276
|
-
*
|
|
2263
|
+
* Update the theme button for the choice now in use.
|
|
2277
2264
|
*
|
|
2278
|
-
* The button shows the
|
|
2279
|
-
* name
|
|
2280
|
-
*
|
|
2281
|
-
*
|
|
2282
|
-
*
|
|
2283
|
-
* agree from the first frame.
|
|
2265
|
+
* The button shows the current scheme, so both the title and the accessible
|
|
2266
|
+
* name must say two things: what is on, and what a click does next. A single
|
|
2267
|
+
* cycling button has nowhere else to say the second, and a screen-reader user
|
|
2268
|
+
* would otherwise not know what the press does. Startup calls this too, so
|
|
2269
|
+
* the button matches the restored preference from the first frame.
|
|
2284
2270
|
*/
|
|
2285
2271
|
function setThemeButton(choice) {
|
|
2286
2272
|
const btn = $("theme");
|
|
@@ -2294,10 +2280,9 @@ function setThemeButton(choice) {
|
|
|
2294
2280
|
//#endregion
|
|
2295
2281
|
//#region src/web/main.ts
|
|
2296
2282
|
/**
|
|
2297
|
-
*
|
|
2298
|
-
* frame.
|
|
2299
|
-
*
|
|
2300
|
-
* their startup in the order the page depends on.
|
|
2283
|
+
* Startup only: restore saved preferences, attach every listener, draw the
|
|
2284
|
+
* first frame. Rendering, data loading and event handling live in `view.ts`,
|
|
2285
|
+
* `api.ts` and `input.ts`. This module starts them in the order the page needs.
|
|
2301
2286
|
*/
|
|
2302
2287
|
if (new URL(location.href).searchParams.has("boot")) {
|
|
2303
2288
|
const clean = new URL(location.href);
|