@sdxc/ui 2026.11.10 → 2026.11.14

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.
Files changed (196) hide show
  1. package/README.md +92 -45
  2. package/dist/app/app-shell-toggle.d.ts +2 -0
  3. package/dist/app/app-shell-toggle.js +5 -2
  4. package/dist/app/app-shell.d.ts +25 -1
  5. package/dist/app/app-shell.js +73 -38
  6. package/dist/app/auto-refresh.d.ts +2 -0
  7. package/dist/app/auto-refresh.js +3 -3
  8. package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
  9. package/dist/app/behaviors/refresh-schedule.js +4 -3
  10. package/dist/app/board.d.ts +123 -0
  11. package/dist/app/board.js +224 -0
  12. package/dist/app/chart.d.ts +2 -2
  13. package/dist/app/chart.js +7 -3
  14. package/dist/app/check-runs.d.ts +116 -0
  15. package/dist/app/check-runs.js +201 -0
  16. package/dist/app/code-view.d.ts +172 -0
  17. package/dist/app/code-view.js +414 -0
  18. package/dist/app/command-palette.d.ts +38 -3
  19. package/dist/app/command-palette.js +53 -5
  20. package/dist/app/contribution-graph.d.ts +106 -0
  21. package/dist/app/contribution-graph.js +289 -0
  22. package/dist/app/detail-sheet.d.ts +7 -0
  23. package/dist/app/detail-sheet.js +7 -7
  24. package/dist/app/diff.d.ts +200 -0
  25. package/dist/app/diff.js +702 -0
  26. package/dist/app/filter-bar.d.ts +20 -0
  27. package/dist/app/filter-bar.js +35 -15
  28. package/dist/app/filter-menu.d.ts +144 -0
  29. package/dist/app/filter-menu.js +480 -0
  30. package/dist/app/gantt.d.ts +108 -0
  31. package/dist/app/gantt.js +420 -0
  32. package/dist/app/index.d.ts +19 -0
  33. package/dist/app/index.js +19 -0
  34. package/dist/app/log-viewer.d.ts +120 -0
  35. package/dist/app/log-viewer.js +384 -0
  36. package/dist/app/merge-box.d.ts +97 -0
  37. package/dist/app/merge-box.js +227 -0
  38. package/dist/app/mixins/app-shell-controls.d.ts +4 -1
  39. package/dist/app/mixins/app-shell-controls.js +64 -4
  40. package/dist/app/mixins/auto-refresh.d.ts +5 -2
  41. package/dist/app/mixins/auto-refresh.js +9 -3
  42. package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
  43. package/dist/app/mixins/close-popover-on-submit.js +32 -0
  44. package/dist/app/mixins/code-view-selection.d.ts +60 -0
  45. package/dist/app/mixins/code-view-selection.js +276 -0
  46. package/dist/app/mixins/command-palette.d.ts +15 -4
  47. package/dist/app/mixins/command-palette.js +94 -6
  48. package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
  49. package/dist/app/mixins/contribution-graph-keys.js +155 -0
  50. package/dist/app/mixins/diff-interactions.d.ts +72 -0
  51. package/dist/app/mixins/diff-interactions.js +269 -0
  52. package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
  53. package/dist/app/mixins/filter-menu-keys.js +91 -0
  54. package/dist/app/mixins/gantt-today.d.ts +17 -0
  55. package/dist/app/mixins/gantt-today.js +50 -0
  56. package/dist/app/mixins/log-viewer.d.ts +29 -0
  57. package/dist/app/mixins/log-viewer.js +333 -0
  58. package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
  59. package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
  60. package/dist/app/mixins/save-bar-sync.d.ts +7 -1
  61. package/dist/app/mixins/save-bar-sync.js +23 -4
  62. package/dist/app/mixins/save-status-sync.js +23 -1
  63. package/dist/app/mixins/split-view.js +1 -1
  64. package/dist/app/mixins/submit-on-close.d.ts +17 -0
  65. package/dist/app/mixins/submit-on-close.js +52 -0
  66. package/dist/app/mixins/tree-filter.d.ts +44 -0
  67. package/dist/app/mixins/tree-filter.js +111 -0
  68. package/dist/app/mixins/tree-navigation.d.ts +50 -0
  69. package/dist/app/mixins/tree-navigation.js +216 -0
  70. package/dist/app/optimistic-toggle.d.ts +8 -0
  71. package/dist/app/optimistic-toggle.js +3 -2
  72. package/dist/app/page-header.d.ts +18 -3
  73. package/dist/app/page-header.js +105 -50
  74. package/dist/app/review-thread.d.ts +115 -0
  75. package/dist/app/review-thread.js +116 -0
  76. package/dist/app/save-bar.d.ts +5 -0
  77. package/dist/app/save-bar.js +1 -1
  78. package/dist/app/settings-layout.d.ts +5 -0
  79. package/dist/app/settings-layout.js +5 -5
  80. package/dist/app/skeleton.d.ts +9 -0
  81. package/dist/app/skeleton.js +28 -0
  82. package/dist/app/split-view.d.ts +4 -0
  83. package/dist/app/split-view.js +3 -3
  84. package/dist/app/styles/code-tokens.d.ts +24 -0
  85. package/dist/app/styles/code-tokens.js +47 -0
  86. package/dist/app/tab-bar.d.ts +59 -0
  87. package/dist/app/tab-bar.js +111 -0
  88. package/dist/app/tree.d.ts +111 -14
  89. package/dist/app/tree.js +202 -15
  90. package/dist/app/utils/ansi.d.ts +55 -0
  91. package/dist/app/utils/ansi.js +157 -0
  92. package/dist/app/utils/diff-rows.d.ts +82 -0
  93. package/dist/app/utils/diff-rows.js +209 -0
  94. package/dist/app/utils/fuzzy-path.d.ts +58 -0
  95. package/dist/app/utils/fuzzy-path.js +202 -0
  96. package/dist/app/utils/line-range.d.ts +48 -0
  97. package/dist/app/utils/line-range.js +61 -0
  98. package/dist/app/utils/log-lines.d.ts +107 -0
  99. package/dist/app/utils/log-lines.js +170 -0
  100. package/dist/app/utils/tree-filter.d.ts +19 -0
  101. package/dist/app/utils/tree-filter.js +26 -0
  102. package/dist/app/view-options.d.ts +2 -0
  103. package/dist/app/view-options.js +2 -2
  104. package/dist/chat/activity.d.ts +72 -0
  105. package/dist/chat/activity.js +184 -0
  106. package/dist/chat/composer-submit.d.ts +38 -0
  107. package/dist/chat/composer-submit.js +44 -0
  108. package/dist/chat/composer.d.ts +47 -0
  109. package/dist/chat/composer.js +100 -0
  110. package/dist/chat/index.d.ts +6 -0
  111. package/dist/chat/index.js +6 -0
  112. package/dist/chat/mixins/composer-send.d.ts +32 -0
  113. package/dist/chat/mixins/composer-send.js +121 -0
  114. package/dist/chat/mixins/reveal-stream.d.ts +68 -0
  115. package/dist/chat/mixins/reveal-stream.js +184 -0
  116. package/dist/chat/mixins/stream-target.d.ts +18 -0
  117. package/dist/chat/mixins/stream-target.js +38 -0
  118. package/dist/components/button.js +7 -1
  119. package/dist/components/character-count.d.ts +44 -0
  120. package/dist/components/character-count.js +68 -0
  121. package/dist/components/index.d.ts +2 -0
  122. package/dist/components/index.js +2 -0
  123. package/dist/components/label-chip.d.ts +42 -0
  124. package/dist/components/label-chip.js +86 -0
  125. package/dist/components/property-list.d.ts +9 -2
  126. package/dist/components/property-list.js +11 -6
  127. package/dist/components/textarea.js +6 -1
  128. package/dist/components/timeline.d.ts +62 -5
  129. package/dist/components/timeline.js +124 -5
  130. package/dist/docs/code-block.js +8 -31
  131. package/dist/docs/file-tree.js +3 -48
  132. package/dist/landing/case-study.d.ts +79 -0
  133. package/dist/landing/case-study.js +162 -0
  134. package/dist/landing/contributor-wall.d.ts +72 -0
  135. package/dist/landing/contributor-wall.js +129 -0
  136. package/dist/landing/countdown.d.ts +88 -0
  137. package/dist/landing/countdown.js +91 -0
  138. package/dist/landing/episode-player.d.ts +87 -0
  139. package/dist/landing/episode-player.js +113 -0
  140. package/dist/landing/faq-band.d.ts +3 -2
  141. package/dist/landing/faq-band.js +4 -3
  142. package/dist/landing/feature-band.d.ts +8 -0
  143. package/dist/landing/feature-band.js +9 -3
  144. package/dist/landing/index.d.ts +9 -0
  145. package/dist/landing/index.js +9 -0
  146. package/dist/landing/landing-header.js +15 -4
  147. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  148. package/dist/landing/mixins/countdown-tick.js +65 -0
  149. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  150. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  151. package/dist/landing/phone-fan.d.ts +38 -0
  152. package/dist/landing/phone-fan.js +89 -0
  153. package/dist/landing/phone-frame.d.ts +48 -0
  154. package/dist/landing/phone-frame.js +41 -0
  155. package/dist/landing/price-list.d.ts +68 -0
  156. package/dist/landing/price-list.js +125 -0
  157. package/dist/landing/scroll-scene.d.ts +59 -0
  158. package/dist/landing/scroll-scene.js +70 -0
  159. package/dist/landing/sponsor-wall.d.ts +30 -6
  160. package/dist/landing/sponsor-wall.js +70 -14
  161. package/dist/landing/typed-terminal.d.ts +24 -6
  162. package/dist/landing/typed-terminal.js +22 -14
  163. package/dist/landing/usage-estimate.d.ts +127 -0
  164. package/dist/landing/usage-estimate.js +164 -0
  165. package/dist/landing/utils/countdown.d.ts +33 -0
  166. package/dist/landing/utils/countdown.js +42 -0
  167. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  168. package/dist/mixins/character-count.d.ts +62 -0
  169. package/dist/mixins/character-count.js +139 -0
  170. package/dist/mixins/index.d.ts +6 -2
  171. package/dist/mixins/index.js +6 -2
  172. package/dist/mixins/invoker-fields.d.ts +18 -0
  173. package/dist/mixins/invoker-fields.js +60 -0
  174. package/dist/mixins/media-sync.d.ts +58 -0
  175. package/dist/mixins/media-sync.js +102 -0
  176. package/dist/mixins/menu-keys.d.ts +11 -0
  177. package/dist/mixins/menu-keys.js +79 -70
  178. package/dist/mixins/sortable.d.ts +96 -0
  179. package/dist/mixins/sortable.js +433 -0
  180. package/dist/utils/code-lines.d.ts +26 -0
  181. package/dist/utils/code-lines.js +29 -0
  182. package/dist/utils/file-icon.d.ts +31 -0
  183. package/dist/utils/file-icon.js +60 -0
  184. package/dist/utils/index.d.ts +2 -0
  185. package/dist/utils/index.js +2 -0
  186. package/dist/utils/write-cookie.d.ts +15 -15
  187. package/dist/utils/write-cookie.js +10 -16
  188. package/dist/video/index.d.ts +11 -0
  189. package/dist/video/index.js +11 -0
  190. package/dist/video/mixins/video-player-sync.d.ts +27 -0
  191. package/dist/video/mixins/video-player-sync.js +413 -0
  192. package/dist/video/utils/timeline.d.ts +55 -0
  193. package/dist/video/utils/timeline.js +90 -0
  194. package/dist/video/video-player.d.ts +261 -0
  195. package/dist/video/video-player.js +927 -0
  196. package/package.json +6 -3
@@ -0,0 +1,333 @@
1
+ /**
2
+ * The browser half of the log viewer: opens a failed job on its first error, searches every
3
+ * line (painting matches through the CSS Custom Highlight API, stepping with Enter and ⇧Enter),
4
+ * and streams a live step's lines in while the log follows its tail.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ import { parseAnsiLine } from "../utils/ansi.js";
11
+ import { LOG_LINE_PLACEHOLDER, ansiAttributes, formatLogTime, readMarker, splitTimestamp, } from "../utils/log-lines.js";
12
+ /** Matches painted at once; a query matching more still counts and steps through all of them. */
13
+ const HIGHLIGHT_LIMIT = 2_000;
14
+ /** How close to the bottom, in pixels, the log still counts as following its tail. */
15
+ const FOLLOW_SLACK = 24;
16
+ /** Milliseconds the search waits after the last keystroke, so a fast typist scans once. */
17
+ const SEARCH_DELAY = 60;
18
+ /** The highlight every match is painted with, which the viewer's stylesheet tints. */
19
+ const MATCH_HIGHLIGHT = "ui-log-match";
20
+ /** The highlight the match the search is on is painted with, drawn solid. */
21
+ const CURRENT_HIGHLIGHT = "ui-log-current";
22
+ /** Marks the line the search is on. */
23
+ const CURRENT_ATTRIBUTE = "data-log-current";
24
+ /** A Range over `[start, end)` of the row's text, walking its text nodes. */
25
+ function rangeIn(row, start, end) {
26
+ let walker = row.ownerDocument.createTreeWalker(row, NodeFilter.SHOW_TEXT);
27
+ let range = row.ownerDocument.createRange();
28
+ let offset = 0;
29
+ let started = false;
30
+ for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
31
+ let length = node.textContent?.length ?? 0;
32
+ if (!started && start < offset + length) {
33
+ range.setStart(node, start - offset);
34
+ started = true;
35
+ }
36
+ if (started && end <= offset + length) {
37
+ range.setEnd(node, end - offset);
38
+ return range;
39
+ }
40
+ offset += length;
41
+ }
42
+ return null;
43
+ }
44
+ /** Opens every closed `<details>` between the row and the viewer, so the row can be seen. */
45
+ function reveal(row, root) {
46
+ for (let details = row.closest("details"); details !== null && root.contains(details);) {
47
+ if (row !== details.querySelector(":scope > summary"))
48
+ details.open = true;
49
+ details = details.parentElement?.closest("details") ?? null;
50
+ }
51
+ }
52
+ /** The counter's text: empty with no query, the no-match copy, or "{index} of {count}". */
53
+ function counterText(options, query, current, total) {
54
+ if (query === "")
55
+ return "";
56
+ if (total === 0)
57
+ return options.noMatches;
58
+ return options.matches.replace("{index}", String(current + 1)).replace("{count}", String(total));
59
+ }
60
+ /** Wires the search box: scanning, counting, painting and stepping through matches. */
61
+ function attachSearch(root, options, signal) {
62
+ let box = root.querySelector("[data-log-search]");
63
+ let input = root.querySelector("[data-log-search-input]");
64
+ let count = root.querySelector("[data-log-search-count]");
65
+ if (box === null || input === null)
66
+ return;
67
+ box.hidden = false;
68
+ let matches = [];
69
+ let current = -1;
70
+ let timer;
71
+ let highlights = typeof CSS !== "undefined" && "highlights" in CSS ? CSS.highlights : undefined;
72
+ let show = (index) => {
73
+ root.querySelector(`[${CURRENT_ATTRIBUTE}]`)?.removeAttribute(CURRENT_ATTRIBUTE);
74
+ current = matches.length === 0 ? -1 : (index + matches.length) % matches.length;
75
+ let match = matches[current];
76
+ if (count !== null)
77
+ count.textContent = counterText(options, input.value, current, matches.length);
78
+ highlights?.delete(CURRENT_HIGHLIGHT);
79
+ if (match === undefined)
80
+ return;
81
+ reveal(match.row, root);
82
+ match.row.setAttribute(CURRENT_ATTRIBUTE, "");
83
+ let range = rangeIn(match.row, match.start, match.end);
84
+ if (range !== null)
85
+ highlights?.set(CURRENT_HIGHLIGHT, new Highlight(range));
86
+ match.row.scrollIntoView({ block: "center" });
87
+ };
88
+ let scan = () => {
89
+ let query = input.value.toLowerCase();
90
+ matches = [];
91
+ if (query !== "") {
92
+ for (let row of root.querySelectorAll("[data-log-line]")) {
93
+ let text = (row.textContent ?? "").toLowerCase();
94
+ for (let at = text.indexOf(query); at !== -1; at = text.indexOf(query, at + query.length)) {
95
+ matches.push({ row, start: at, end: at + query.length });
96
+ }
97
+ }
98
+ }
99
+ if (highlights !== undefined) {
100
+ let ranges = matches
101
+ .slice(0, HIGHLIGHT_LIMIT)
102
+ .map((match) => rangeIn(match.row, match.start, match.end))
103
+ .filter((range) => range !== null);
104
+ highlights.set(MATCH_HIGHLIGHT, new Highlight(...ranges));
105
+ }
106
+ show(0);
107
+ };
108
+ input.addEventListener("input", () => {
109
+ clearTimeout(timer);
110
+ timer = setTimeout(scan, SEARCH_DELAY);
111
+ }, { signal });
112
+ input.addEventListener("keydown", (event) => {
113
+ if (event.key === "Enter") {
114
+ event.preventDefault();
115
+ clearTimeout(timer);
116
+ if (timer !== undefined) {
117
+ timer = undefined;
118
+ scan();
119
+ }
120
+ show(current + (event.shiftKey ? -1 : 1));
121
+ }
122
+ else if (event.key === "Escape" && input.value !== "") {
123
+ event.preventDefault();
124
+ input.value = "";
125
+ scan();
126
+ }
127
+ }, { signal });
128
+ root
129
+ .querySelector("[data-log-search-previous]")
130
+ ?.addEventListener("click", () => show(current - 1), { signal });
131
+ root
132
+ .querySelector("[data-log-search-next]")
133
+ ?.addEventListener("click", () => show(current + 1), { signal });
134
+ signal.addEventListener("abort", () => {
135
+ clearTimeout(timer);
136
+ highlights?.delete(MATCH_HIGHLIGHT);
137
+ highlights?.delete(CURRENT_HIGHLIGHT);
138
+ });
139
+ }
140
+ /**
141
+ * Builds one streamed line in the markup the server draws: a row holding its number link and
142
+ * its spans, or a fold whose summary is the row. An `##[endgroup]` closes the innermost fold.
143
+ */
144
+ function appendLine(live, raw) {
145
+ let document = live.step.ownerDocument;
146
+ let { ts, text: rest } = splitTimestamp(raw);
147
+ let { marker, text } = readMarker(rest);
148
+ let parsed = parseAnsiLine(text, live.style);
149
+ live.style = parsed.state;
150
+ if (marker === "endgroup") {
151
+ if (live.containers.length > 1)
152
+ live.containers.shift();
153
+ return;
154
+ }
155
+ let n = live.next++;
156
+ let href = live.href.replace("{n}", String(n));
157
+ let hash = href.indexOf("#");
158
+ let isGroup = marker === "group";
159
+ let row = document.createElement(isGroup ? "summary" : "div");
160
+ row.setAttribute("data-log-line", "");
161
+ if (hash !== -1)
162
+ row.id = decodeURIComponent(href.slice(hash + 1));
163
+ if (marker !== undefined && !isGroup)
164
+ row.setAttribute("data-tone", marker);
165
+ let link = document.createElement("a");
166
+ link.href = href;
167
+ link.dataset["n"] = String(n);
168
+ if (ts !== undefined)
169
+ link.dataset["ts"] = formatLogTime(ts);
170
+ link.tabIndex = -1;
171
+ link.setAttribute("aria-hidden", "true");
172
+ let title = isGroup ? document.createElement("span") : row;
173
+ if (isGroup)
174
+ title.setAttribute("data-log-group-title", "");
175
+ for (let span of parsed.spans) {
176
+ let attributes = Object.entries(ansiAttributes(span));
177
+ if (attributes.length === 0) {
178
+ title.appendChild(document.createTextNode(span.text));
179
+ continue;
180
+ }
181
+ let element = document.createElement("span");
182
+ for (let [name, value] of attributes)
183
+ element.setAttribute(name, value);
184
+ element.textContent = span.text;
185
+ title.appendChild(element);
186
+ }
187
+ row.insertBefore(link, row.firstChild);
188
+ if (isGroup)
189
+ row.appendChild(title);
190
+ let parent = live.containers[0];
191
+ if (!isGroup) {
192
+ parent.appendChild(row);
193
+ return;
194
+ }
195
+ let details = document.createElement("details");
196
+ details.setAttribute("data-log-group", "");
197
+ let body = document.createElement("div");
198
+ body.setAttribute("data-log-group-body", "");
199
+ details.appendChild(row);
200
+ details.appendChild(body);
201
+ parent.appendChild(details);
202
+ live.containers.unshift(body);
203
+ }
204
+ /**
205
+ * Keeps the log on its newest line while the reader is there, and once they scroll up, shows
206
+ * the "Jump to latest" pill instead of pulling them down.
207
+ */
208
+ function followTail(root, signal) {
209
+ let body = root.querySelector('[data-slot="log-viewer-body"]');
210
+ let pill = root.querySelector("[data-log-jump]");
211
+ if (body === null)
212
+ return () => { };
213
+ let following = true;
214
+ let toBottom = () => {
215
+ body.scrollTop = body.scrollHeight;
216
+ };
217
+ body.addEventListener("scroll", () => {
218
+ following = body.scrollHeight - body.scrollTop - body.clientHeight <= FOLLOW_SLACK;
219
+ if (following && pill !== null)
220
+ pill.hidden = true;
221
+ }, { signal });
222
+ pill?.addEventListener("click", () => {
223
+ following = true;
224
+ pill.hidden = true;
225
+ toBottom();
226
+ }, { signal });
227
+ if (root.ownerDocument.location.hash === "")
228
+ toBottom();
229
+ return () => {
230
+ if (following)
231
+ toBottom();
232
+ else if (pill !== null)
233
+ pill.hidden = false;
234
+ };
235
+ }
236
+ /**
237
+ * Reads a live step's stream, appending each complete line as it arrives and the last partial
238
+ * one at the end. The step's `data-stream-end` becomes `done` or `failed`, and its Refresh link
239
+ * shows again, since the page now holds a newer state than the log.
240
+ */
241
+ async function stream(step, appended, signal) {
242
+ let src = step.getAttribute("data-log-stream") ?? "";
243
+ let live = {
244
+ step,
245
+ containers: [step.querySelector("[data-log-live]") ?? step],
246
+ next: Number(step.getAttribute("data-log-next") ?? "1"),
247
+ href: (step.getAttribute("data-log-href") ?? "").replace(String(LOG_LINE_PLACEHOLDER), "{n}"),
248
+ style: {},
249
+ };
250
+ let refresh = step.querySelector("[data-log-refresh]");
251
+ let end = (state) => {
252
+ step.removeAttribute("data-stream-pending");
253
+ step.setAttribute("data-stream-end", state);
254
+ if (refresh !== null)
255
+ refresh.hidden = false;
256
+ step.dispatchEvent(new CustomEvent("log-stream-end", { bubbles: true, detail: { state } }));
257
+ };
258
+ try {
259
+ let response = await fetch(src, { signal, headers: { accept: "text/plain" } });
260
+ if (!response.ok || response.body === null)
261
+ return end("failed");
262
+ if (refresh !== null)
263
+ refresh.hidden = true;
264
+ let reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
265
+ let buffer = "";
266
+ for (let read = await reader.read(); !read.done; read = await reader.read()) {
267
+ buffer += read.value;
268
+ let lines = buffer.split("\n");
269
+ buffer = lines.pop() ?? "";
270
+ for (let line of lines)
271
+ appendLine(live, line.replace(/\r$/, ""));
272
+ step.setAttribute("data-log-next", String(live.next));
273
+ if (lines.length > 0)
274
+ appended();
275
+ }
276
+ if (buffer !== "") {
277
+ appendLine(live, buffer);
278
+ appended();
279
+ }
280
+ end("done");
281
+ }
282
+ catch {
283
+ if (!signal.aborted)
284
+ end("failed");
285
+ }
286
+ }
287
+ /**
288
+ * Brings a finished job's first error line into view, centred in the log and on the page, so
289
+ * a failed job opens on why it failed. An address naming a line keeps that line instead.
290
+ */
291
+ function showFirstError(root) {
292
+ if (root.ownerDocument.location.hash !== "")
293
+ return;
294
+ let body = root.querySelector('[data-slot="log-viewer-body"]');
295
+ let line = root.querySelector('details[data-state="failure"][open] [data-log-line][data-tone="danger"]');
296
+ if (body === null || line === null)
297
+ return;
298
+ let offset = line.getBoundingClientRect().top - body.getBoundingClientRect().top;
299
+ body.scrollTop += offset - (body.clientHeight - line.offsetHeight) / 2;
300
+ let box = line.getBoundingClientRect();
301
+ let view = root.ownerDocument.defaultView;
302
+ if (view !== null && (box.top < 0 || box.bottom > view.innerHeight)) {
303
+ line.scrollIntoView({ block: "center" });
304
+ }
305
+ }
306
+ /** Wires one viewer: search, the first error, the tail it follows, and every live step's stream. */
307
+ function attach(root, options, signal) {
308
+ attachSearch(root, options, signal);
309
+ let steps = [...root.querySelectorAll("[data-log-stream][data-stream-pending]")];
310
+ if (steps.length === 0)
311
+ return showFirstError(root);
312
+ let appended = followTail(root, signal);
313
+ for (let step of steps)
314
+ void stream(step, appended, signal);
315
+ }
316
+ /**
317
+ * Wires the `LogViewer` the host sits in: search over every line, each live step's stream, and
318
+ * following the tail; it all detaches when the host unmounts.
319
+ *
320
+ * @param options The counter's copy.
321
+ * @example <div hidden mix={[logViewerController({ matches: "{index} of {count}", noMatches: "No results" })]} />
322
+ */
323
+ export const logViewerController = createMixin((handle) => {
324
+ let options;
325
+ handle.addEventListener("insert", (event) => {
326
+ let root = event.node.closest('[data-slot="log-viewer"]');
327
+ if (root !== null && options !== undefined)
328
+ attach(root, options, handle.signal);
329
+ });
330
+ return (next) => {
331
+ options = next;
332
+ };
333
+ });
@@ -28,6 +28,11 @@ export declare namespace OptimisticToggleSync {
28
28
  label?: string;
29
29
  /** The button's title and `aria-label` while on; `label` when omitted. */
30
30
  pressedLabel?: string;
31
+ /**
32
+ * Whether the server says the toggle is on. Each render puts the toggle back to it while
33
+ * no press is waiting, so a toggle reused for another record never keeps the last press.
34
+ */
35
+ pressed?: boolean;
31
36
  }
32
37
  /** Where a press stands, as {@link OptimisticToggleEvent} reports it. */
33
38
  interface Outcome {
@@ -47,17 +47,22 @@ export class OptimisticToggleEvent extends Event {
47
47
  export const optimisticToggleSync = createMixin((handle) => {
48
48
  let options;
49
49
  let controller;
50
+ let sync;
50
51
  handle.addEventListener("insert", (event) => {
51
52
  controller?.abort();
52
53
  controller = new AbortController();
53
- connect(event.node, () => options, controller.signal);
54
+ sync = connect(event.node, () => options, controller.signal);
54
55
  });
55
56
  handle.addEventListener("remove", () => {
56
57
  controller?.abort();
57
58
  controller = undefined;
59
+ sync = undefined;
58
60
  });
59
61
  return (next) => {
60
62
  options = next;
63
+ let pressed = next.pressed;
64
+ if (pressed !== undefined)
65
+ handle.queueTask(() => sync?.(pressed));
61
66
  };
62
67
  });
63
68
  /**
@@ -66,12 +71,14 @@ export const optimisticToggleSync = createMixin((handle) => {
66
71
  * @param form The toggle's form.
67
72
  * @param read Reads the latest options.
68
73
  * @param signal Ends the listener once the form leaves the document.
74
+ * @returns Puts the form back to a state the server rendered, unless a press is waiting.
69
75
  */
70
76
  function connect(form, read, signal) {
71
77
  let button = form.querySelector('button[type="submit"]');
72
78
  let next = form.querySelector("input[data-toggle-next]");
73
79
  let status = form.querySelector('[role="status"]');
74
80
  let latest = 0;
81
+ let pending = false;
75
82
  /** Draws `pressed` and the outcome onto the form and tells the page. */
76
83
  let show = (pressed, outcome) => {
77
84
  let failed = outcome.failed ?? false;
@@ -93,6 +100,7 @@ function connect(form, read, signal) {
93
100
  let body = new FormData(form);
94
101
  let previous = form.hasAttribute("data-pressed");
95
102
  let token = ++latest;
103
+ pending = true;
96
104
  show(!previous, {});
97
105
  let answer = await fetch(form.action, {
98
106
  method: "POST",
@@ -102,11 +110,27 @@ function connect(form, read, signal) {
102
110
  }).then((response) => ({ ok: response.ok, status: response.status }), () => ({ ok: false, status: null }));
103
111
  if (token !== latest || signal.aborted)
104
112
  return;
113
+ pending = false;
105
114
  if (answer.ok)
106
115
  show(!previous, { settled: true, status: answer.status });
107
116
  else
108
117
  show(previous, { failed: true, settled: true, status: answer.status });
109
118
  }, { signal });
119
+ return (pressed) => {
120
+ if (pending)
121
+ return;
122
+ form.toggleAttribute("data-pressed", pressed);
123
+ form.removeAttribute("data-failed");
124
+ if (next)
125
+ next.value = pressed ? "false" : "true";
126
+ if (button) {
127
+ button.setAttribute("aria-pressed", pressed ? "true" : "false");
128
+ button.dataset.color = toneOf(pressed, false);
129
+ name(button, pressed, read());
130
+ }
131
+ if (status)
132
+ status.textContent = "";
133
+ };
110
134
  }
111
135
  /**
112
136
  * Renames `button` for its state, so its title and accessible name follow a flip; a button
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Why JS: a form cannot tell when its values differ from how it loaded, so script shows
3
- * the save bar while it does, binds ⌘S/Ctrl+S to submitting it, and guards leaving the page.
3
+ * the save bar while it does, binds ⌘S/Ctrl+S to submitting it, and guards leaving the page,
4
+ * including a navigation the page answers in place.
4
5
  * No-JS baseline: the bar stays hidden and the form submits through its own Save button.
5
6
  *
6
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
@@ -15,6 +16,11 @@ export declare namespace SaveBarSync {
15
16
  form?: string;
16
17
  /** What the bar's live region announces once the form changes, such as "Unsaved changes". */
17
18
  message: string;
19
+ /**
20
+ * The question asked before an in-page navigation leaves unsaved changes, such as
21
+ * "Leave without saving your changes?". @default message
22
+ */
23
+ leave?: string;
18
24
  }
19
25
  }
20
26
  /**
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Why JS: a form cannot tell when its values differ from how it loaded, so script shows
3
- * the save bar while it does, binds ⌘S/Ctrl+S to submitting it, and guards leaving the page.
3
+ * the save bar while it does, binds ⌘S/Ctrl+S to submitting it, and guards leaving the page,
4
+ * including a navigation the page answers in place.
4
5
  * No-JS baseline: the bar stays hidden and the form submits through its own Save button.
5
6
  *
6
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
@@ -80,10 +81,25 @@ function connect(bar, options, signal) {
80
81
  bar.hidden = !next;
81
82
  if (status)
82
83
  status.textContent = next ? options.message : "";
83
- if (next)
84
+ if (next) {
84
85
  view?.addEventListener("beforeunload", guard);
85
- else
86
+ view?.navigation?.addEventListener("navigate", ask);
87
+ }
88
+ else {
86
89
  view?.removeEventListener("beforeunload", guard);
90
+ view?.navigation?.removeEventListener("navigate", ask);
91
+ }
92
+ };
93
+ /**
94
+ * Asks before a navigation the page handles itself (a frame swap, which fires no
95
+ * `beforeunload`) leaves unsaved changes, and cancels it when the visitor stays; a jump
96
+ * to an anchor on the same page goes ahead.
97
+ */
98
+ let ask = (event) => {
99
+ if (event.hashChange || !event.cancelable || event.downloadRequest !== null)
100
+ return;
101
+ if (!view?.confirm(options.leave ?? options.message))
102
+ event.preventDefault();
87
103
  };
88
104
  /** Compares the form with its baseline. */
89
105
  let compare = () => show(snapshot(form) !== baseline);
@@ -102,5 +118,8 @@ function connect(bar, options, signal) {
102
118
  form.requestSubmit();
103
119
  },
104
120
  }, signal);
105
- signal.addEventListener("abort", () => view?.removeEventListener("beforeunload", guard));
121
+ signal.addEventListener("abort", () => {
122
+ view?.removeEventListener("beforeunload", guard);
123
+ view?.navigation?.removeEventListener("navigate", ask);
124
+ });
106
125
  }
@@ -60,18 +60,27 @@ export function setSaveStatus(target, state, at) {
60
60
  export const saveStatusSync = createMixin((handle) => {
61
61
  let options;
62
62
  let controller;
63
+ let follow;
63
64
  handle.addEventListener("insert", (event) => {
64
65
  controller?.abort();
65
66
  controller = new AbortController();
66
67
  if (options)
67
- connect(event.node, () => options, controller.signal);
68
+ follow = connect(event.node, () => options, controller.signal);
68
69
  });
69
70
  handle.addEventListener("remove", () => {
70
71
  controller?.abort();
71
72
  controller = undefined;
73
+ follow = undefined;
72
74
  });
73
75
  return (next) => {
76
+ let previous = options;
74
77
  options = next;
78
+ if (follow === undefined || previous === undefined)
79
+ return;
80
+ if (previous.state === next.state && previous.editedAt === next.editedAt)
81
+ return;
82
+ let apply = follow;
83
+ queueMicrotask(() => apply(next.state, next.editedAt));
75
84
  };
76
85
  });
77
86
  /**
@@ -80,6 +89,8 @@ export const saveStatusSync = createMixin((handle) => {
80
89
  * @param root The status element.
81
90
  * @param read Reads the latest options.
82
91
  * @param signal Ends every timer and listener once the status leaves the document.
92
+ * @returns Shows a state the page redrew the status with, such as "Saved" after a save
93
+ * answered in place, decaying it as a server-rendered state does.
83
94
  */
84
95
  function connect(root, read, signal) {
85
96
  let text = root.querySelector('[data-slot="save-status-text"]');
@@ -156,4 +167,15 @@ function connect(root, read, signal) {
156
167
  clearTimeout(pending);
157
168
  });
158
169
  draw();
170
+ return (state, at) => {
171
+ if (signal.aborted)
172
+ return;
173
+ clearTimeout(pending);
174
+ let next = at ? new Date(at) : null;
175
+ if (state === "saved")
176
+ return settleSaved(next ?? new Date());
177
+ if (next)
178
+ editedAt = next;
179
+ show(state);
180
+ };
159
181
  }
@@ -51,7 +51,7 @@ function persist(root) {
51
51
  list: storedSize(root, "list"),
52
52
  collapsed: collapsedPanes(root),
53
53
  });
54
- writeCookie(cookie, encodeURIComponent(value));
54
+ writeCookie(cookie, encodeURIComponent(value), { path: root.dataset.cookiePath });
55
55
  }
56
56
  /**
57
57
  * Collapses or restores `pane` and remembers it. The list and the detail never both
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Why JS: a picker in a popover saves as a model, once, when the reader is done with it, and
3
+ * only script hears the popover close. This submits the form when its popover closes changed.
4
+ * No-JS baseline: the form keeps a Save button for the browser to submit it with.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { MixinFactory } from "remix/component";
10
+ /**
11
+ * Applied to an element inside a form inside a popover: records the form's values each time
12
+ * the popover opens and, when it closes holding different values, submits the form through
13
+ * `requestSubmit`, so the app's own submit handling (a frame, a fetch) takes the request.
14
+ *
15
+ * @example <div mix={[submitOnClose()]}>{checkboxes}</div>
16
+ */
17
+ export declare const submitOnClose: MixinFactory<HTMLElement>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Why JS: a picker in a popover saves as a model, once, when the reader is done with it, and
3
+ * only script hears the popover close. This submits the form when its popover closes changed.
4
+ * No-JS baseline: the form keeps a Save button for the browser to submit it with.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ /**
11
+ * What a form would send right now, as one comparable string in sorted order, so an untouched
12
+ * form, one changed back to its starting values, and one whose fields moved all compare equal.
13
+ */
14
+ function snapshot(form) {
15
+ return [...new FormData(form)]
16
+ .map(([name, value]) => `${name}=${typeof value === "string" ? value : value.name}`)
17
+ .sort()
18
+ .join("&");
19
+ }
20
+ /**
21
+ * Applied to an element inside a form inside a popover: records the form's values each time
22
+ * the popover opens and, when it closes holding different values, submits the form through
23
+ * `requestSubmit`, so the app's own submit handling (a frame, a fetch) takes the request.
24
+ *
25
+ * @example <div mix={[submitOnClose()]}>{checkboxes}</div>
26
+ */
27
+ export const submitOnClose = createMixin((handle) => {
28
+ let controller;
29
+ handle.addEventListener("insert", (event) => {
30
+ controller?.abort();
31
+ controller = new AbortController();
32
+ let form = event.node.closest("form");
33
+ let popover = event.node.closest("[popover]");
34
+ if (!form || !popover)
35
+ return;
36
+ let opened = snapshot(form);
37
+ popover.addEventListener("toggle", (toggle) => {
38
+ if (toggle.newState === "open") {
39
+ opened = snapshot(form);
40
+ return;
41
+ }
42
+ if (snapshot(form) === opened)
43
+ return;
44
+ opened = snapshot(form);
45
+ form.requestSubmit();
46
+ }, { signal: controller.signal });
47
+ });
48
+ handle.addEventListener("remove", () => {
49
+ controller?.abort();
50
+ controller = undefined;
51
+ });
52
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Narrows a file tree as the reader types into its filter field: leaves that miss the query
3
+ * hide, every folder holding a match opens, folders with none hide, and a query matching no
4
+ * file shows the tree's no-matches line.
5
+ * Why JS: HTML has no live filtering of other elements. No-JS baseline: the field submits its
6
+ * GET form (`?filter=`) and the server renders the narrowed tree.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import type { ElementProps, MixinFactory } from "remix/component";
12
+ /** Attribute every file row carries, holding the path the filter matches. */
13
+ export declare const TREE_FILTER_TEXT_ATTRIBUTE = "data-filter-text";
14
+ /**
15
+ * Types for {@link treeFilter}.
16
+ */
17
+ export declare namespace TreeFilter {
18
+ /** Options for {@link treeFilter}. */
19
+ interface Options {
20
+ /** The `id` of the tree the field narrows. */
21
+ tree: string;
22
+ }
23
+ }
24
+ /**
25
+ * Applies `query` to every row in `tree`. Folders are visited deepest first, so a folder
26
+ * reads its subfolders' final state when it decides whether it still holds a match; the
27
+ * tree's no-matches line shows only while a query leaves no file.
28
+ *
29
+ * @param tree The tree's root element.
30
+ * @param query What the reader typed; blank restores the whole tree.
31
+ * @returns How many files match.
32
+ */
33
+ export declare function applyTreeFilter(tree: HTMLElement, query: string): number;
34
+ /**
35
+ * Filters the tree named by `options.tree` on every keystroke in the field it is applied to,
36
+ * and moves focus from the field into the first visible row on ArrowDown, so a reader types,
37
+ * then walks the results.
38
+ *
39
+ * @param options The tree to narrow.
40
+ * @example <input type="search" name="filter" mix={[treeFilter({ tree: "files" })]} />
41
+ */
42
+ export declare const treeFilter: MixinFactory<HTMLInputElement, [
43
+ options: TreeFilter.Options
44
+ ], ElementProps>;