@monster-orange/den-ui 0.7.1 → 0.7.5
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 +93 -0
- package/inventory/nav-inventory.d.ts +8 -2
- package/inventory/nav-inventory.js +68 -7
- package/package.json +9 -1
- package/src/busy.d.ts +1 -0
- package/src/busy.js +23 -14
- package/src/markdown-editor.css +230 -0
- package/src/markdown-editor.d.ts +187 -0
- package/src/markdown-editor.js +1122 -0
- package/src/report.d.ts +7 -1
- package/src/report.js +32 -2
- package/src/shell-client.js +7 -0
- package/src/shell-html.d.ts +68 -3
- package/src/shell-html.js +206 -12
- package/src/shell.css +49 -3
- package/src/strings.js +99 -0
- package/src/whatsnew.js +13 -2
package/README.md
CHANGED
|
@@ -83,6 +83,36 @@ data and HTML slots; it keeps no copy of the kit's markup, CSS or code.
|
|
|
83
83
|
Also `topBarHtml`, `railHtml`, `navItemHtml`, `versionChipHtml`,
|
|
84
84
|
`reportButtonHtml`, `icon(name)` (`src/icons.js`) and `esc`.
|
|
85
85
|
|
|
86
|
+
- **Kind tags (0.7.3).** A pin or a link into another product sets
|
|
87
|
+
`kind` on its nav item: `"project"`, `"den"`, `"service"`, `"hub"`, or
|
|
88
|
+
`{ artifact: "Mock" }` (an artifact pin's own word, in the host's
|
|
89
|
+
language). The kit draws a small uppercase tag at the row's end in the
|
|
90
|
+
scope labels' look, and the tooltip and name are always the kit's:
|
|
91
|
+
"North · Project"; a label that is its kind word reads once ("Hub").
|
|
92
|
+
A badge says what it counts with `what` (`"open"`, `"waiting"`,
|
|
93
|
+
`"down"`, `"running"`) and the kit words it: "North · Den, 3 waiting".
|
|
94
|
+
Hosts pass data, never display text: a `tip`, `title` or `aria-label`
|
|
95
|
+
on an entry with a kind is not used. Any other kind is dropped: the tag
|
|
96
|
+
never names a machine. A project pin may set `icon: { initial: "North" }`
|
|
97
|
+
for its initial in a disc. A pin row gets `aria-keyshortcuts="Delete"`
|
|
98
|
+
from the kit. The nav inventory records each entry's kind and
|
|
99
|
+
`compareNav` reports a `kind` difference. Host text in any rail entry
|
|
100
|
+
(`title`, `aria-label`, `aria-labelledby` or `aria-description` in
|
|
101
|
+
`attrs`, or a badge's `label`) is stamped `data-nav-host-text`:
|
|
102
|
+
`navWarnings` lists it and `compareNav` fails on it (`hostText`).
|
|
103
|
+
`data-*` attrs stay allowed.
|
|
104
|
+
|
|
105
|
+
- **Off entries (0.7.4).** An entry that can't be opened sets `off` to
|
|
106
|
+
why, as data: `"connect"` (not connected yet), `"reconnect"` (its
|
|
107
|
+
sign-in is no longer accepted), `"forbidden"` (not allowed; an admin
|
|
108
|
+
decides), `"unreachable"` (can't be reached right now) or `"config"`
|
|
109
|
+
(its settings have a problem). The kit greys the entry (`.den-off`)
|
|
110
|
+
and words why, in en, es and ja, after the name in the tooltip and
|
|
111
|
+
the accessible name: "Acme Co · Hub, reconnect in Settings"; an entry
|
|
112
|
+
without a kind reads "Docs, can't be reached right now". Any other
|
|
113
|
+
value is dropped (not greyed, no words). The nav inventory records
|
|
114
|
+
each entry's `off` and `compareNav` reports an `off` difference.
|
|
115
|
+
|
|
86
116
|
- **Slots.** The top bar reads: ☰, the brand, `start` (a search, a scope
|
|
87
117
|
menu), then the right group: `end` (status chips), Report, `bell`, the
|
|
88
118
|
version chip, `account`. Report · bell · account keep their place
|
|
@@ -131,6 +161,13 @@ paste where the team tracks issues. A product with more (a preview, a
|
|
|
131
161
|
sign-in flow, drafts) gives `info`, `diagnostics`, `preview`, `send`,
|
|
132
162
|
`githubSend`, `githubPoll` and `saveDraft`; see the top of `report.js`.
|
|
133
163
|
|
|
164
|
+
Each of `info()`'s `repos` may say its `visibility` (`"public"`,
|
|
165
|
+
`"private"` or `"internal"`) and an `audience` (who can see it, as words).
|
|
166
|
+
A public repo, or one that doesn't say, gets the "Public repository" pill
|
|
167
|
+
and the "visible to everyone" warning above Send. A private or internal
|
|
168
|
+
one gets its own pill, the audience, and a quiet line instead of the
|
|
169
|
+
warning. Both follow the repo chosen in Review.
|
|
170
|
+
|
|
134
171
|
### Strings
|
|
135
172
|
|
|
136
173
|
`src/strings.js` (export `./strings`) exports `en`, `es` and `ja`: every
|
|
@@ -350,6 +387,60 @@ browser test, on the image (Den's real server on the demo distribution,
|
|
|
350
387
|
is `src/kit.d.ts`. A test compiles a consumer against them with
|
|
351
388
|
`--strict`.
|
|
352
389
|
|
|
390
|
+
## The Markdown editor (0.7.5)
|
|
391
|
+
|
|
392
|
+
`src/markdown-editor.js` and `src/markdown-editor.css` (exports
|
|
393
|
+
`./markdown-editor`, `./markdown-editor.css`): a Markdown field,
|
|
394
|
+
ported from an existing editor. CodeMirror 6 on the Markdown text: the
|
|
395
|
+
document is the string that is stored, character for character, and the
|
|
396
|
+
live preview is drawn in place, as decoration only (no preview pane,
|
|
397
|
+
never converted to HTML and back).
|
|
398
|
+
|
|
399
|
+
import { mountMarkdownEditor } from "@monster-orange/den-ui/markdown-editor";
|
|
400
|
+
// link markdown-editor.css after tokens.css
|
|
401
|
+
const ed = mountMarkdownEditor(el, {
|
|
402
|
+
value: "", onChange: (text) => save(text),
|
|
403
|
+
label: "Notes", // or labelledBy; describedBy for help
|
|
404
|
+
mode: "full", // "full": a toolbar, Enter is a new line,
|
|
405
|
+
// ⌘/Ctrl+Enter submits; "lite": a chat box,
|
|
406
|
+
// Enter sends, Shift+Enter is a new line
|
|
407
|
+
onSubmit, onEscape, onBlur, placeholder, maxLength, rows,
|
|
408
|
+
disabled, readOnly, required, invalid, lang, uiLang, nonce,
|
|
409
|
+
});
|
|
410
|
+
await ed.ready; // CodeMirror has taken over
|
|
411
|
+
ed.setValue(""); ed.focus(); ed.run("bold");
|
|
412
|
+
ed.insertBlock(text); ed.insertLinkTo(label, url); ed.replaceEnd(n, text);
|
|
413
|
+
ed.update({ disabled: true }); ed.destroy();
|
|
414
|
+
|
|
415
|
+
- **Lazy.** The module imports no CodeMirror. On mount it loads
|
|
416
|
+
`@codemirror/state`, `view`, `commands` and `@lezer/markdown` with
|
|
417
|
+
`import()`, so a bundler puts them in a chunk of their own, and a plain
|
|
418
|
+
textarea takes the typing until it arrives (its toolbar works too). The
|
|
419
|
+
editor then goes on from the textarea's text, focus, caret and
|
|
420
|
+
selection. `loadMarkdownEditor()` warms the chunk early. The packages
|
|
421
|
+
are the kit's `dependencies`, pinned exactly. Den's own pages don't
|
|
422
|
+
load it.
|
|
423
|
+
- **The preview.** On a line the caret is not on, the markers hide and
|
|
424
|
+
the words show formatted; `- ` becomes a bullet. On the line being
|
|
425
|
+
edited every marker stays, muted. CommonMark without setext headings,
|
|
426
|
+
indented code, HTML, entities, reference links, images and autolinks,
|
|
427
|
+
plus strikethrough; only an http(s) link is drawn as a link.
|
|
428
|
+
- **IME.** An Enter that belongs to a composition (`view.composing`,
|
|
429
|
+
`isComposing`, keyCode 229, or within 100 ms of `compositionend`, as
|
|
430
|
+
Safari sends it) never sends, submits or adds a line. The preview is
|
|
431
|
+
frozen while a composition is open, and `maxLength` never cuts one.
|
|
432
|
+
- **Shortcuts.** ⌘/Ctrl+B, I, E (code), K (link), ⇧X (strike); Enter in
|
|
433
|
+
a list or quote continues it, and on an empty item ends it.
|
|
434
|
+
- **Words.** The toolbar's are `kit.md.*` in strings.js (en, es, ja), in
|
|
435
|
+
`uiLang`, else `<html lang>`.
|
|
436
|
+
- **Touch sizes.** On `(pointer: coarse)` or below 720px the toolbar's
|
|
437
|
+
buttons are `--tap` (44×44px) and the text is 16px (no zoom on focus);
|
|
438
|
+
elsewhere 28px and 15px.
|
|
439
|
+
- **CSP.** CodeMirror writes its base styles into a `<style>`: under a
|
|
440
|
+
strict `style-src`, pass the page's `nonce`.
|
|
441
|
+
- The content element has `data-md-dirty` while it holds unsaved text
|
|
442
|
+
(for an update pill's `askFirst`).
|
|
443
|
+
|
|
353
444
|
## 0.7.1
|
|
354
445
|
|
|
355
446
|
The top bar's search sits in the same place in every product (issue 303).
|
|
@@ -481,6 +572,8 @@ button)`. A crumb left out of the list draws nothing, and no separator
|
|
|
481
572
|
on `<body>`: a heading, then the host's `items` as rows (`{ text, href?,
|
|
482
573
|
time?, read? }`) or the empty state. `bellPanelHtml(...)` takes `actions`
|
|
483
574
|
(buttons beside the heading), `lead`, `body` (the host's own rows),
|
|
575
|
+
`sections` (issue 101: `{ needs, earlier? }`, the rows of each; the kit
|
|
576
|
+
heads them "Needs you", always first, and "Earlier", in its own words),
|
|
484
577
|
`empty`, `after` and `foot`. A click on the bell toggles the panel.
|
|
485
578
|
Opening it focuses its first link or button. Esc closes it and focus goes
|
|
486
579
|
back to the bell, in Safari too (`focusBack` from `dialog.js`). A click
|
|
@@ -47,6 +47,12 @@ export interface NavElement {
|
|
|
47
47
|
labelOnly?: boolean;
|
|
48
48
|
/** The kit's stamp on what it draws (data-nav-kit). */
|
|
49
49
|
kit?: string;
|
|
50
|
+
/** 0.7.3: a rail entry's kind tag (data-nav-kind): project, den, service, hub, artifact. */
|
|
51
|
+
kind?: string;
|
|
52
|
+
/** 0.7.4: why a rail entry is off (data-nav-off): connect, reconnect, forbidden, unreachable, config. */
|
|
53
|
+
off?: string;
|
|
54
|
+
/** 0.7.3: host text in an entry of the rail (data-nav-host-text): compareNav fails on it. */
|
|
55
|
+
hostText?: string;
|
|
50
56
|
}
|
|
51
57
|
export interface NavTheme {
|
|
52
58
|
id: string;
|
|
@@ -84,7 +90,7 @@ export interface NavCompareOptions {
|
|
|
84
90
|
export interface NavDiff {
|
|
85
91
|
key: string;
|
|
86
92
|
slot: NavSlot | "";
|
|
87
|
-
/** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "box.<edge>", "style.<prop>", "version". */
|
|
93
|
+
/** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "kind", "off", "hostText", "box.<edge>", "style.<prop>", "version". */
|
|
88
94
|
property: string;
|
|
89
95
|
reference: string | number;
|
|
90
96
|
actual: string | number;
|
|
@@ -122,7 +128,7 @@ export declare function topSlotDiffs(
|
|
|
122
128
|
snap: NavSnapshot,
|
|
123
129
|
tolerance?: number,
|
|
124
130
|
): NavDiff[];
|
|
125
|
-
/** 0.7.1: host HTML in the kit's account and search slots
|
|
131
|
+
/** 0.7.1: host HTML in the kit's account and search slots; 0.7.3: host text in an entry of the rail. */
|
|
126
132
|
export declare function navWarnings(snap: NavSnapshot): string[];
|
|
127
133
|
export declare function collectNav(
|
|
128
134
|
page: NavPage,
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* entries after its spacer, .den-rail-grow: Settings, the collapse
|
|
22
22
|
* toggle). For each: its key (below), its parent's key, slot, role, tag,
|
|
23
23
|
* accessible name, classes, box { x, y, w, h } and computed styles
|
|
24
|
-
* (STYLE_PROPS).
|
|
24
|
+
* (STYLE_PROPS), and a rail entry's kind tag (0.7.3: `kind`, compared on
|
|
25
|
+
* every entry both sides draw) and why it is off (0.7.4: `off`, compared
|
|
26
|
+
* the same way).
|
|
25
27
|
*
|
|
26
28
|
* The key names an element the same way on every run: `#id` when it has
|
|
27
29
|
* an id; `[data-nav="x"]` for a rail entry; else its parent's key, " > ",
|
|
@@ -300,6 +302,20 @@ export async function collectNav(page, opts = {}) {
|
|
|
300
302
|
...(el.hasAttribute("data-nav-kit")
|
|
301
303
|
? { kit: el.getAttribute("data-nav-kit") }
|
|
302
304
|
: {}),
|
|
305
|
+
// Issue 307: a rail entry's kind tag (project, den, service,
|
|
306
|
+
// hub, artifact), compared across products.
|
|
307
|
+
...(el.hasAttribute("data-nav-kind")
|
|
308
|
+
? { kind: el.getAttribute("data-nav-kind") }
|
|
309
|
+
: {}),
|
|
310
|
+
// Issue 326: why an entry is off (greyed), compared across
|
|
311
|
+
// products.
|
|
312
|
+
...(el.hasAttribute("data-nav-off")
|
|
313
|
+
? { off: el.getAttribute("data-nav-off") }
|
|
314
|
+
: {}),
|
|
315
|
+
// 0.7.3: host text in an entry of the rail (the kit stamps it).
|
|
316
|
+
...(el.hasAttribute("data-nav-host-text")
|
|
317
|
+
? { hostText: el.getAttribute("data-nav-host-text") }
|
|
318
|
+
: {}),
|
|
303
319
|
});
|
|
304
320
|
}
|
|
305
321
|
if (el.tagName.toLowerCase() === "svg") return mySlot;
|
|
@@ -678,6 +694,10 @@ export function navWarnings(snap) {
|
|
|
678
694
|
out.push(
|
|
679
695
|
`account: ${e.key} is not the kit's (host HTML; draw it with accountHtml)`,
|
|
680
696
|
);
|
|
697
|
+
if (e.hostText)
|
|
698
|
+
out.push(
|
|
699
|
+
`rail entry: ${e.key} has the host's ${e.hostText} (pass data: the kit owns its words)`,
|
|
700
|
+
);
|
|
681
701
|
if (
|
|
682
702
|
e.slot === "top" &&
|
|
683
703
|
e.classes.includes("den-search") &&
|
|
@@ -881,9 +901,36 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
881
901
|
);
|
|
882
902
|
// Issue 303: the search's slot, from the viewport alone.
|
|
883
903
|
diffs.push(...topSlotDiffs(actual, tol));
|
|
904
|
+
// Issue 307: an entry both sides draw (host content too: its key is its
|
|
905
|
+
// data-nav id) has the same kind tag, or none on both. The tag's look is
|
|
906
|
+
// the "kind" role's, compared below with the first of each role.
|
|
907
|
+
{
|
|
908
|
+
const wantKind = new Map(allWant.map((e) => [e.key, e]));
|
|
909
|
+
for (const g of allGot) {
|
|
910
|
+
const w = wantKind.get(g.key);
|
|
911
|
+
if (w && (w.kind ?? "") !== (g.kind ?? ""))
|
|
912
|
+
add(w, "kind", w.kind ?? "(none)", g.kind ?? "(none)");
|
|
913
|
+
// Issue 326: an entry off on one side is off, for the same reason,
|
|
914
|
+
// on the other.
|
|
915
|
+
if (w && (w.off ?? "") !== (g.off ?? ""))
|
|
916
|
+
add(w, "off", w.off ?? "(none)", g.off ?? "(none)");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
884
919
|
// A crumb's value outlasts its label: one whose label shows while its
|
|
885
920
|
// value is hidden fails, whatever the reference drew (crumbs are host
|
|
886
921
|
// content, so this is checked on every element drawn).
|
|
922
|
+
// 0.7.3: hosts pass data; the kit owns a rail entry's words. Host text
|
|
923
|
+
// on an entry (a title, aria-label, aria-labelledby, aria-description,
|
|
924
|
+
// a badge's label) fails, whatever the reference drew.
|
|
925
|
+
for (const g of actual.elements)
|
|
926
|
+
if (g.hostText)
|
|
927
|
+
diffs.push({
|
|
928
|
+
key: g.key,
|
|
929
|
+
slot: g.slot,
|
|
930
|
+
property: "hostText",
|
|
931
|
+
reference: "none",
|
|
932
|
+
actual: g.hostText,
|
|
933
|
+
});
|
|
887
934
|
for (const g of actual.elements)
|
|
888
935
|
if (g.labelOnly)
|
|
889
936
|
diffs.push({
|
|
@@ -970,14 +1017,28 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
970
1017
|
// Name over @login is taller than @login alone: an entry with another
|
|
971
1018
|
// line count than the reference's (both the kit's shapes) moves nothing
|
|
972
1019
|
// else's place; its own height and what it centres are its data.
|
|
1020
|
+
const tall = /^(box\.(height|top|bottom)|style\.height)$/;
|
|
973
1021
|
const acct = actual.elements.find((e) => e.account);
|
|
974
1022
|
const acctRef = acct && reference.elements.find((e) => e.key === acct.key);
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1023
|
+
const acctOwn =
|
|
1024
|
+
acct && acctRef && (acct.lines ?? 0) !== (acctRef.lines ?? 0)
|
|
1025
|
+
? (k) => k === acct.key || k.startsWith(acct.key + " >")
|
|
1026
|
+
: () => false;
|
|
1027
|
+
// Issue 313: a container empty on one side and holding something on
|
|
1028
|
+
// the other is as tall as what it holds; its top, bottom and height are
|
|
1029
|
+
// not compared (its x and width are). Children by the recorded parent.
|
|
1030
|
+
const kids = (snap) => {
|
|
1031
|
+
const n = new Map();
|
|
1032
|
+
for (const e of snap.elements)
|
|
1033
|
+
if (e.parent) n.set(e.parent, (n.get(e.parent) || 0) + 1);
|
|
1034
|
+
return n;
|
|
1035
|
+
};
|
|
1036
|
+
const ka = kids(actual);
|
|
1037
|
+
const kr = kids(reference);
|
|
1038
|
+
const emptyOneSide = (k) => !ka.get(k) !== !kr.get(k);
|
|
1039
|
+
return diffs.filter(
|
|
1040
|
+
(d) => !(tall.test(d.property) && (acctOwn(d.key) || emptyOneSide(d.key))),
|
|
1041
|
+
);
|
|
981
1042
|
function styles(w, g, skip) {
|
|
982
1043
|
for (const p of STYLE_PROPS) {
|
|
983
1044
|
if (skip.includes(p)) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monster-orange/den-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Den's UI kit: tokens, fonts and shared components, framework-free",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"./report.css": "./src/report.css",
|
|
35
35
|
"./busy.css": "./src/busy.css",
|
|
36
36
|
"./dialog.css": "./src/dialog.css",
|
|
37
|
+
"./markdown-editor": "./src/markdown-editor.js",
|
|
38
|
+
"./markdown-editor.css": "./src/markdown-editor.css",
|
|
37
39
|
"./inventory": {
|
|
38
40
|
"types": "./inventory/nav-inventory.d.ts",
|
|
39
41
|
"default": "./inventory/nav-inventory.js"
|
|
@@ -56,5 +58,11 @@
|
|
|
56
58
|
],
|
|
57
59
|
"bin": {
|
|
58
60
|
"den-ui-parity": "bin/den-ui-parity.mjs"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@codemirror/commands": "6.11.1",
|
|
64
|
+
"@codemirror/state": "6.7.6",
|
|
65
|
+
"@codemirror/view": "6.43.13",
|
|
66
|
+
"@lezer/markdown": "1.7.2"
|
|
59
67
|
}
|
|
60
68
|
}
|
package/src/busy.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const NO_ANSWER_MS: number;
|
|
|
5
5
|
export declare const SUCCESS_CLOSE_MS: number;
|
|
6
6
|
export declare const POLL_MS: number;
|
|
7
7
|
export declare const POLL_MAX_MS: number;
|
|
8
|
+
export declare const ASK_MS: number;
|
|
8
9
|
|
|
9
10
|
export type Words = Record<string, Record<string, string>>;
|
|
10
11
|
/** Check again's answer: how a request id ended. */
|
package/src/busy.js
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* Reconnect mode: the request may get no answer (the product stopped
|
|
68
68
|
* first); that counts as going down, and the pop-up waits for it to come
|
|
69
69
|
* back. busyAction then resolves with the new answer from reconnect.url.
|
|
70
|
+
* Each ask of reconnect.url gives up after ASK_MS: an ask in flight as the
|
|
71
|
+
* product goes down (or one a proxy holds) may never be answered, and the
|
|
72
|
+
* next ask must still come.
|
|
70
73
|
*
|
|
71
74
|
* The request contract (Settled in v2): Try again sends the same id only
|
|
72
75
|
* when no answer came back; after the server answered with an error it
|
|
@@ -84,6 +87,7 @@ export const NO_ANSWER_MS = 60_000;
|
|
|
84
87
|
export const SUCCESS_CLOSE_MS = 1200;
|
|
85
88
|
export const POLL_MS = 1000;
|
|
86
89
|
export const POLL_MAX_MS = 3000;
|
|
90
|
+
export const ASK_MS = 3000;
|
|
87
91
|
|
|
88
92
|
const hook = {
|
|
89
93
|
lang: () =>
|
|
@@ -206,6 +210,20 @@ function newId() {
|
|
|
206
210
|
|
|
207
211
|
const later = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
208
212
|
|
|
213
|
+
/** One ask of the reconnect url: its JSON, or null (no answer in ASK_MS). */
|
|
214
|
+
async function askOnce(url) {
|
|
215
|
+
const stop = new AbortController();
|
|
216
|
+
const timer = setTimeout(() => stop.abort(), ASK_MS);
|
|
217
|
+
try {
|
|
218
|
+
const r = await fetch(url, { cache: "no-store", signal: stop.signal });
|
|
219
|
+
return r.ok ? await r.json() : null;
|
|
220
|
+
} catch {
|
|
221
|
+
return null;
|
|
222
|
+
} finally {
|
|
223
|
+
clearTimeout(timer);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
209
227
|
/** The first message with words: the error's own, its answer's, nothing. */
|
|
210
228
|
export function messageOf(err) {
|
|
211
229
|
const tries = [
|
|
@@ -625,13 +643,7 @@ export function busyAction(name, run, opts = {}) {
|
|
|
625
643
|
while (!settled && Date.now() - startedAt < limit) {
|
|
626
644
|
await later(gap);
|
|
627
645
|
gap = Math.min(POLL_MAX_MS, gap + 500);
|
|
628
|
-
|
|
629
|
-
try {
|
|
630
|
-
const r = await fetch(rc.url, { cache: "no-store" });
|
|
631
|
-
now = r.ok ? await r.json() : null;
|
|
632
|
-
} catch {
|
|
633
|
-
now = null;
|
|
634
|
-
}
|
|
646
|
+
const now = await askOnce(rc.url);
|
|
635
647
|
if (settled) return;
|
|
636
648
|
if (now && rc.back(now, before)) {
|
|
637
649
|
const v = rc.version?.(now) ?? "";
|
|
@@ -650,13 +662,10 @@ export function busyAction(name, run, opts = {}) {
|
|
|
650
662
|
// Reconnect mode: how the product answered before it went away.
|
|
651
663
|
let before = opts.before ?? null;
|
|
652
664
|
if (reconnect && hook.reconnect && !before)
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
before = b;
|
|
658
|
-
attempt();
|
|
659
|
-
});
|
|
665
|
+
askOnce(hook.reconnect.url).then((b) => {
|
|
666
|
+
before = b;
|
|
667
|
+
attempt();
|
|
668
|
+
});
|
|
660
669
|
else attempt();
|
|
661
670
|
return result;
|
|
662
671
|
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/* den-ui: the Markdown editor's look (markdown-editor.js). Tokens only, both
|
|
2
|
+
modes: no colour of its own. Linked, never injected. The box looks like a
|
|
3
|
+
text input (border, radius, the accent focus ring), so it sits in a form
|
|
4
|
+
unchanged. Safari: no flex gap on the editor itself, explicit
|
|
5
|
+
min-heights, -webkit-user-modify left to CodeMirror. Knobs, set on
|
|
6
|
+
.md-field: --md-min-height (full: from `rows`; lite: 48px) and
|
|
7
|
+
--md-max-height (full 360px, lite 200px). */
|
|
8
|
+
.md-field {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
background: var(--raised);
|
|
13
|
+
border: 1px solid var(--border-strong);
|
|
14
|
+
border-radius: var(--radius);
|
|
15
|
+
transition: border-color var(--dur-fast) var(--ease);
|
|
16
|
+
}
|
|
17
|
+
.md-field:hover {
|
|
18
|
+
border-color: var(--faint);
|
|
19
|
+
}
|
|
20
|
+
.md-field:focus-within {
|
|
21
|
+
border-color: var(--accent);
|
|
22
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
|
|
23
|
+
}
|
|
24
|
+
.md-field[data-invalid="true"] {
|
|
25
|
+
border-color: var(--bad);
|
|
26
|
+
}
|
|
27
|
+
.md-field[data-disabled="true"] {
|
|
28
|
+
background: var(--sunken);
|
|
29
|
+
color: var(--faint);
|
|
30
|
+
cursor: not-allowed;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.md-toolbar {
|
|
34
|
+
position: relative;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-wrap: wrap;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 2px;
|
|
39
|
+
padding: 4px 6px;
|
|
40
|
+
border-bottom: 1px solid var(--border);
|
|
41
|
+
}
|
|
42
|
+
.md-toolbar-sep {
|
|
43
|
+
width: 1px;
|
|
44
|
+
height: 18px;
|
|
45
|
+
margin: 0 4px;
|
|
46
|
+
background: var(--border);
|
|
47
|
+
}
|
|
48
|
+
.md-tool {
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
width: 28px;
|
|
53
|
+
height: 28px;
|
|
54
|
+
padding: 0;
|
|
55
|
+
border: 0;
|
|
56
|
+
border-radius: var(--radius-button);
|
|
57
|
+
background: transparent;
|
|
58
|
+
color: var(--muted);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
.md-tool:hover {
|
|
62
|
+
background: var(--sunken);
|
|
63
|
+
color: var(--text);
|
|
64
|
+
}
|
|
65
|
+
.md-tool:focus-visible {
|
|
66
|
+
outline: 2px solid var(--accent);
|
|
67
|
+
outline-offset: 1px;
|
|
68
|
+
}
|
|
69
|
+
.md-tool[disabled] {
|
|
70
|
+
opacity: 0.5;
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* The editor and its plain-textarea stand-in share one metric, so the swap does not jump. */
|
|
75
|
+
.md-editor-host,
|
|
76
|
+
.md-fallback {
|
|
77
|
+
font-family: var(--sans);
|
|
78
|
+
font-size: 15px;
|
|
79
|
+
line-height: 1.5;
|
|
80
|
+
color: var(--text);
|
|
81
|
+
}
|
|
82
|
+
.md-fallback {
|
|
83
|
+
display: block;
|
|
84
|
+
width: 100%;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
padding: 10px 12px;
|
|
87
|
+
border: 0;
|
|
88
|
+
background: transparent;
|
|
89
|
+
resize: vertical;
|
|
90
|
+
font: inherit;
|
|
91
|
+
font-size: 15px;
|
|
92
|
+
line-height: 1.5;
|
|
93
|
+
color: var(--text);
|
|
94
|
+
}
|
|
95
|
+
.md-fallback:focus {
|
|
96
|
+
outline: none;
|
|
97
|
+
}
|
|
98
|
+
.md-fallback::placeholder {
|
|
99
|
+
color: var(--faint);
|
|
100
|
+
}
|
|
101
|
+
.md-field .md-fallback,
|
|
102
|
+
.md-field .md-editor-host .cm-content {
|
|
103
|
+
min-height: var(--md-min-height, 88px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.md-editor-host .cm-editor {
|
|
107
|
+
background: transparent;
|
|
108
|
+
color: inherit;
|
|
109
|
+
}
|
|
110
|
+
.md-editor-host .cm-editor.cm-focused {
|
|
111
|
+
outline: none;
|
|
112
|
+
}
|
|
113
|
+
.md-editor-host .cm-scroller {
|
|
114
|
+
font-family: inherit;
|
|
115
|
+
line-height: inherit;
|
|
116
|
+
max-height: var(--md-max-height, 360px);
|
|
117
|
+
overflow: auto;
|
|
118
|
+
}
|
|
119
|
+
.md-editor-host .cm-content {
|
|
120
|
+
padding: 10px 12px;
|
|
121
|
+
caret-color: var(--text);
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
}
|
|
124
|
+
.md-editor-host .cm-line {
|
|
125
|
+
padding: 0;
|
|
126
|
+
}
|
|
127
|
+
/* readable: the muted text passes contrast (faint is for marks) */
|
|
128
|
+
.md-editor-host .cm-placeholder {
|
|
129
|
+
color: var(--muted);
|
|
130
|
+
}
|
|
131
|
+
.md-editor-host .cm-cursor {
|
|
132
|
+
border-left-color: var(--text);
|
|
133
|
+
}
|
|
134
|
+
.md-editor-host .cm-selectionBackground,
|
|
135
|
+
.md-editor-host .cm-focused .cm-selectionBackground {
|
|
136
|
+
background: color-mix(in srgb, var(--accent) 20%, transparent);
|
|
137
|
+
}
|
|
138
|
+
.md-editor-host .cm-content[aria-disabled="true"] {
|
|
139
|
+
color: var(--faint);
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* The live preview (livePreview in markdown-editor.js). */
|
|
144
|
+
.md-strong {
|
|
145
|
+
font-weight: 700;
|
|
146
|
+
}
|
|
147
|
+
.md-em {
|
|
148
|
+
font-style: italic;
|
|
149
|
+
}
|
|
150
|
+
.md-del {
|
|
151
|
+
text-decoration: line-through;
|
|
152
|
+
}
|
|
153
|
+
.md-code {
|
|
154
|
+
font-family: var(--mono);
|
|
155
|
+
font-size: 0.92em;
|
|
156
|
+
padding: 0 0.2em;
|
|
157
|
+
border-radius: var(--radius-button);
|
|
158
|
+
background: var(--sunken);
|
|
159
|
+
}
|
|
160
|
+
.md-link {
|
|
161
|
+
color: var(--accent-text);
|
|
162
|
+
text-decoration: underline;
|
|
163
|
+
text-underline-offset: 2px;
|
|
164
|
+
}
|
|
165
|
+
.md-marker {
|
|
166
|
+
color: var(--faint);
|
|
167
|
+
}
|
|
168
|
+
.md-listmark {
|
|
169
|
+
color: var(--muted);
|
|
170
|
+
}
|
|
171
|
+
.md-bullet {
|
|
172
|
+
display: inline-block;
|
|
173
|
+
min-width: 0.8em;
|
|
174
|
+
color: var(--muted);
|
|
175
|
+
}
|
|
176
|
+
.md-h {
|
|
177
|
+
font-weight: 700;
|
|
178
|
+
}
|
|
179
|
+
.md-h1 {
|
|
180
|
+
font-size: 1.2em;
|
|
181
|
+
}
|
|
182
|
+
.md-h2 {
|
|
183
|
+
font-size: 1.1em;
|
|
184
|
+
}
|
|
185
|
+
.md-quote {
|
|
186
|
+
border-left: 3px solid var(--border-strong);
|
|
187
|
+
padding-left: 10px !important;
|
|
188
|
+
color: var(--muted);
|
|
189
|
+
}
|
|
190
|
+
.md-fence {
|
|
191
|
+
font-family: var(--mono);
|
|
192
|
+
font-size: 0.92em;
|
|
193
|
+
background: var(--sunken);
|
|
194
|
+
}
|
|
195
|
+
.md-hr {
|
|
196
|
+
color: var(--faint);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* The chat (mode "lite"): the composer row's own box. */
|
|
200
|
+
.md-lite {
|
|
201
|
+
min-width: 0;
|
|
202
|
+
}
|
|
203
|
+
.md-lite .md-editor-host .cm-content,
|
|
204
|
+
.md-lite .md-fallback {
|
|
205
|
+
min-height: var(--md-min-height, 48px);
|
|
206
|
+
}
|
|
207
|
+
/* the stand-in is the editor's height from its first frame: one row, no resize handle, a long placeholder clipped, never wrapped taller */
|
|
208
|
+
.md-lite .md-fallback {
|
|
209
|
+
resize: none;
|
|
210
|
+
overflow: hidden;
|
|
211
|
+
}
|
|
212
|
+
.md-lite .md-editor-host .cm-scroller {
|
|
213
|
+
max-height: var(--md-max-height, 200px);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Touch sizes: on a touch screen or a narrow one (the kit's own
|
|
217
|
+
breakpoints), each toolbar button is the kit's tap (--tap, 44×44px) and
|
|
218
|
+
the text is 16px, so iOS does not zoom in on focus. Desktop keeps the
|
|
219
|
+
sizes above. */
|
|
220
|
+
@media (pointer: coarse), (max-width: 720px) {
|
|
221
|
+
.md-tool {
|
|
222
|
+
min-width: var(--tap);
|
|
223
|
+
min-height: var(--tap);
|
|
224
|
+
}
|
|
225
|
+
.md-editor-host,
|
|
226
|
+
.md-fallback,
|
|
227
|
+
.md-field .md-fallback {
|
|
228
|
+
font-size: 16px;
|
|
229
|
+
}
|
|
230
|
+
}
|