dssoca 0.5.0 → 0.8.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/dist/components/Accordion.svelte +281 -0
- package/dist/components/Accordion.svelte.d.ts +47 -0
- package/dist/components/Badge.svelte +115 -18
- package/dist/components/Badge.svelte.d.ts +28 -2
- package/dist/components/BottomNav.svelte +216 -0
- package/dist/components/BottomNav.svelte.d.ts +30 -0
- package/dist/components/Button.svelte +147 -10
- package/dist/components/Button.svelte.d.ts +21 -4
- package/dist/components/Card.svelte +167 -8
- package/dist/components/Card.svelte.d.ts +16 -1
- package/dist/components/EmptyState.svelte +85 -9
- package/dist/components/EmptyState.svelte.d.ts +14 -3
- package/dist/components/Icon.svelte +179 -13
- package/dist/components/Icon.svelte.d.ts +63 -2
- package/dist/components/Image.svelte +430 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +174 -39
- package/dist/components/Input.svelte.d.ts +22 -0
- package/dist/components/Link.svelte +148 -0
- package/dist/components/Link.svelte.d.ts +22 -0
- package/dist/components/LogStream.svelte +378 -37
- package/dist/components/LogStream.svelte.d.ts +35 -7
- package/dist/components/Menu.svelte +355 -0
- package/dist/components/Menu.svelte.d.ts +46 -0
- package/dist/components/MetricTile.svelte +124 -12
- package/dist/components/MetricTile.svelte.d.ts +20 -0
- package/dist/components/SegmentedControl.svelte +208 -0
- package/dist/components/SegmentedControl.svelte.d.ts +30 -0
- package/dist/components/ServiceCard.svelte +222 -26
- package/dist/components/ServiceCard.svelte.d.ts +13 -1
- package/dist/components/Sidebar.svelte +340 -29
- package/dist/components/Sidebar.svelte.d.ts +18 -7
- package/dist/components/Sparkline.svelte +196 -13
- package/dist/components/Sparkline.svelte.d.ts +20 -1
- package/dist/components/Toaster.svelte +193 -12
- package/dist/components/Toaster.svelte.d.ts +3 -0
- package/dist/components/Topbar.svelte +152 -21
- package/dist/components/Topbar.svelte.d.ts +20 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +6 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +12 -2
- package/dist/theme.css +242 -0
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/package.json +1 -1
|
@@ -1,20 +1,59 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** A single log severity level. */
|
|
3
|
+
export type LogLevel = 'info' | 'warn' | 'err' | 'ok'
|
|
4
|
+
|
|
5
|
+
/** A controlled log line. `id` is optional — when omitted the index is used as the key. */
|
|
6
|
+
export interface LogLine {
|
|
7
|
+
id?: string | number
|
|
8
|
+
/** Timestamp string (e.g. "12:00:01"); rendered verbatim. */
|
|
9
|
+
t?: string
|
|
10
|
+
lvl: LogLevel
|
|
11
|
+
/** Service / source tag (e.g. "[hub]"). */
|
|
12
|
+
svc?: string
|
|
13
|
+
msg: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const LEVELS: LogLevel[] = ['info', 'warn', 'err', 'ok']
|
|
17
|
+
</script>
|
|
18
|
+
|
|
1
19
|
<script lang="ts">
|
|
2
|
-
import { tick, untrack } from 'svelte'
|
|
20
|
+
import { tick, untrack, type Snippet } from 'svelte'
|
|
3
21
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
4
|
-
|
|
5
|
-
interface LogLine { id: number; t: string; lvl: string; svc: string; msg: string }
|
|
22
|
+
import EmptyState from './EmptyState.svelte'
|
|
6
23
|
|
|
7
24
|
interface Props {
|
|
8
|
-
|
|
25
|
+
/** Controlled lines. When provided, the component renders exactly these (capped to `maxLines`). */
|
|
26
|
+
lines?: LogLine[]
|
|
27
|
+
/** Seed lines for the built-in demo stream (only used when `lines` is undefined). */
|
|
9
28
|
initialLines?: Omit<LogLine, 'id'>[]
|
|
29
|
+
/** Generate a random demo stream. Defaults true ONLY when `lines` is not supplied. */
|
|
30
|
+
demo?: boolean
|
|
31
|
+
/** Back-compat alias for `demo` — drives the built-in ticker. */
|
|
32
|
+
live?: boolean
|
|
33
|
+
/** Max number of lines kept in the buffer (oldest dropped). */
|
|
34
|
+
maxLines?: number
|
|
35
|
+
/** Show the controls toolbar (filters, search, wrap, copy, clear). */
|
|
36
|
+
controls?: boolean
|
|
37
|
+
/** Replace the built-in toolbar entirely. */
|
|
38
|
+
toolbar?: Snippet
|
|
39
|
+
/** Wrap long messages (pre-wrap) vs. horizontal scroll (pre). */
|
|
40
|
+
wrap?: boolean
|
|
41
|
+
/** aria-live politeness for the log region. */
|
|
42
|
+
announce?: 'off' | 'polite' | 'assertive'
|
|
43
|
+
/** Accessible label for the log region. */
|
|
44
|
+
ariaLabel?: string
|
|
45
|
+
/** Show a connecting/loading indicator. */
|
|
46
|
+
loading?: boolean
|
|
47
|
+
/** Custom empty state. */
|
|
48
|
+
empty?: Snippet
|
|
10
49
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
11
50
|
size?: Size
|
|
12
51
|
}
|
|
13
52
|
|
|
14
|
-
const TEMPLATES = [
|
|
53
|
+
const TEMPLATES: Omit<LogLine, 'id'>[] = [
|
|
15
54
|
{ lvl: 'info', svc: '[movies-api]', msg: 'GET /movies?status=to_watch — 3 rows · 4ms' },
|
|
16
55
|
{ lvl: 'ok', svc: '[hub]', msg: 'GET /api/auth/session — 8ms' },
|
|
17
|
-
{ lvl: 'info', svc: '[hub]', msg: 'session refresh — user=
|
|
56
|
+
{ lvl: 'info', svc: '[hub]', msg: 'session refresh — user=admin' },
|
|
18
57
|
{ lvl: 'warn', svc: '[caddy]', msg: 'tls internal renewing hub.home' },
|
|
19
58
|
{ lvl: 'err', svc: '[tasks-api]', msg: 'EADDRINUSE :3004 — retrying in 2s' },
|
|
20
59
|
{ lvl: 'info', svc: '[notes-api]', msg: 'slow query · 182ms · SELECT * FROM notes' },
|
|
@@ -32,71 +71,373 @@
|
|
|
32
71
|
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
|
33
72
|
}
|
|
34
73
|
|
|
35
|
-
let {
|
|
74
|
+
let {
|
|
75
|
+
lines,
|
|
76
|
+
initialLines,
|
|
77
|
+
demo,
|
|
78
|
+
live,
|
|
79
|
+
maxLines = 30,
|
|
80
|
+
controls = true,
|
|
81
|
+
toolbar,
|
|
82
|
+
wrap = true,
|
|
83
|
+
announce = 'polite',
|
|
84
|
+
ariaLabel = 'Log output',
|
|
85
|
+
loading = false,
|
|
86
|
+
empty,
|
|
87
|
+
size,
|
|
88
|
+
}: Props = $props()
|
|
36
89
|
|
|
90
|
+
// Controlled mode: `lines` (or empty array) supplied → render those, demo off.
|
|
91
|
+
const controlled = $derived(lines !== undefined)
|
|
92
|
+
// Demo defaults on only when uncontrolled. `live`/`demo` either flips it.
|
|
93
|
+
const demoOn = $derived(!controlled && (demo ?? live ?? true))
|
|
94
|
+
|
|
95
|
+
// Internal demo buffer.
|
|
37
96
|
const seed = untrack(() => initialLines ?? TEMPLATES)
|
|
38
97
|
let counter = $state(seed.length)
|
|
39
|
-
let
|
|
98
|
+
let demoLines = $state<LogLine[]>(
|
|
99
|
+
seed.map((t, i) => ({ ...t, t: t.t || timeAgo(i * 4), id: i }))
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
// The source of truth, capped to maxLines.
|
|
103
|
+
const allLines = $derived(
|
|
104
|
+
(controlled ? (lines as LogLine[]) : demoLines).slice(-maxLines)
|
|
105
|
+
)
|
|
40
106
|
|
|
107
|
+
// --- toolbar state ---
|
|
108
|
+
let activeLevels = $state<Set<LogLevel>>(new Set(LEVELS))
|
|
109
|
+
let query = $state('')
|
|
110
|
+
let wrapOn = $state(untrack(() => wrap))
|
|
111
|
+
$effect(() => { wrapOn = wrap })
|
|
112
|
+
|
|
113
|
+
const visibleLines = $derived(
|
|
114
|
+
allLines.filter((l) => {
|
|
115
|
+
if (!activeLevels.has(l.lvl)) return false
|
|
116
|
+
if (query.trim()) {
|
|
117
|
+
const q = query.toLowerCase()
|
|
118
|
+
const hay = `${l.t ?? ''} ${l.lvl} ${l.svc ?? ''} ${l.msg}`.toLowerCase()
|
|
119
|
+
if (!hay.includes(q)) return false
|
|
120
|
+
}
|
|
121
|
+
return true
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
function toggleLevel(lvl: LogLevel) {
|
|
126
|
+
const next = new Set(activeLevels)
|
|
127
|
+
if (next.has(lvl)) next.delete(lvl)
|
|
128
|
+
else next.add(lvl)
|
|
129
|
+
activeLevels = next
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function copyVisible() {
|
|
133
|
+
const text = visibleLines
|
|
134
|
+
.map((l) => `${l.t ?? ''} ${l.lvl.toUpperCase()} ${l.svc ?? ''} ${l.msg}`.trim())
|
|
135
|
+
.join('\n')
|
|
136
|
+
try {
|
|
137
|
+
await navigator.clipboard?.writeText(text)
|
|
138
|
+
} catch {
|
|
139
|
+
/* clipboard unavailable (e.g. insecure context) — no-op */
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function clear() {
|
|
144
|
+
if (controlled) return
|
|
145
|
+
demoLines = []
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// --- follow-tail ---
|
|
41
149
|
let el: HTMLDivElement | undefined
|
|
150
|
+
let following = $state(true)
|
|
151
|
+
const NEAR = 24 // px from bottom considered "at bottom"
|
|
152
|
+
|
|
153
|
+
function atBottom() {
|
|
154
|
+
if (!el) return true
|
|
155
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight <= NEAR
|
|
156
|
+
}
|
|
42
157
|
|
|
158
|
+
function onScroll() {
|
|
159
|
+
following = atBottom()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function jumpToBottom() {
|
|
163
|
+
following = true
|
|
164
|
+
await tick()
|
|
165
|
+
if (el) el.scrollTop = el.scrollHeight
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Auto-scroll on new content only when following.
|
|
169
|
+
$effect(() => {
|
|
170
|
+
// re-run whenever the visible set changes
|
|
171
|
+
void visibleLines.length
|
|
172
|
+
if (!following) return
|
|
173
|
+
tick().then(() => {
|
|
174
|
+
if (el && untrack(() => following)) el.scrollTop = el.scrollHeight
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
// Demo ticker.
|
|
43
179
|
$effect(() => {
|
|
44
|
-
if (!
|
|
45
|
-
const interval = setInterval(
|
|
180
|
+
if (!demoOn) return
|
|
181
|
+
const interval = setInterval(() => {
|
|
46
182
|
const pick = TEMPLATES[Math.floor(Math.random() * TEMPLATES.length)]
|
|
47
|
-
|
|
48
|
-
await tick()
|
|
49
|
-
if (el) el.scrollTop = el.scrollHeight
|
|
183
|
+
demoLines = [...demoLines.slice(-maxLines), { ...pick, t: nowStr(), id: counter++ }]
|
|
50
184
|
}, 1800)
|
|
51
185
|
return () => clearInterval(interval)
|
|
52
186
|
})
|
|
187
|
+
|
|
188
|
+
function keyFor(line: LogLine, i: number) {
|
|
189
|
+
return line.id ?? i
|
|
190
|
+
}
|
|
53
191
|
</script>
|
|
54
192
|
|
|
55
|
-
<div class="ss-logs"
|
|
56
|
-
{#
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
193
|
+
<div class="ss-logs" data-size-variant={resolveComponentSize('LogStream', size)}>
|
|
194
|
+
{#if controls}
|
|
195
|
+
{#if toolbar}
|
|
196
|
+
<div class="bar">{@render toolbar()}</div>
|
|
197
|
+
{:else}
|
|
198
|
+
<div class="bar">
|
|
199
|
+
<div class="filters" role="group" aria-label="Filter by level">
|
|
200
|
+
{#each LEVELS as lvl (lvl)}
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
class="chip {lvl}"
|
|
204
|
+
aria-pressed={activeLevels.has(lvl)}
|
|
205
|
+
onclick={() => toggleLevel(lvl)}
|
|
206
|
+
>{lvl.toUpperCase()}</button>
|
|
207
|
+
{/each}
|
|
208
|
+
</div>
|
|
209
|
+
<input
|
|
210
|
+
class="search"
|
|
211
|
+
type="text"
|
|
212
|
+
placeholder="Filter…"
|
|
213
|
+
aria-label="Filter log text"
|
|
214
|
+
bind:value={query}
|
|
215
|
+
/>
|
|
216
|
+
<button
|
|
217
|
+
type="button"
|
|
218
|
+
class="chip"
|
|
219
|
+
aria-pressed={wrapOn}
|
|
220
|
+
onclick={() => (wrapOn = !wrapOn)}
|
|
221
|
+
>WRAP</button>
|
|
222
|
+
<button type="button" class="chip" onclick={copyVisible}>COPY</button>
|
|
223
|
+
{#if !controlled}
|
|
224
|
+
<button type="button" class="chip" onclick={clear}>CLEAR</button>
|
|
225
|
+
{/if}
|
|
226
|
+
</div>
|
|
227
|
+
{/if}
|
|
228
|
+
{/if}
|
|
229
|
+
|
|
230
|
+
<div class="viewport">
|
|
231
|
+
<div
|
|
232
|
+
class="scroll"
|
|
233
|
+
class:nowrap={!wrapOn}
|
|
234
|
+
bind:this={el}
|
|
235
|
+
onscroll={onScroll}
|
|
236
|
+
role="log"
|
|
237
|
+
aria-label={ariaLabel}
|
|
238
|
+
aria-live={announce}
|
|
239
|
+
aria-busy={loading}
|
|
240
|
+
>
|
|
241
|
+
{#if loading}
|
|
242
|
+
<div class="status" aria-hidden="true">
|
|
243
|
+
<span class="dot"></span> connecting…
|
|
244
|
+
</div>
|
|
245
|
+
{/if}
|
|
246
|
+
|
|
247
|
+
{#if visibleLines.length === 0}
|
|
248
|
+
{#if empty}
|
|
249
|
+
{@render empty()}
|
|
250
|
+
{:else}
|
|
251
|
+
<EmptyState
|
|
252
|
+
title="No log lines"
|
|
253
|
+
message={allLines.length ? 'No lines match the current filters.' : 'Waiting for output…'}
|
|
254
|
+
{size}
|
|
255
|
+
/>
|
|
256
|
+
{/if}
|
|
257
|
+
{:else}
|
|
258
|
+
{#each visibleLines as line, i (keyFor(line, i))}
|
|
259
|
+
<div class="ln">
|
|
260
|
+
{#if line.t}<span class="t">{line.t}</span>{/if}
|
|
261
|
+
<span class="lvl {line.lvl}">{line.lvl.toUpperCase()}</span>
|
|
262
|
+
{#if line.svc}<span class="svc">{line.svc}</span>{/if}
|
|
263
|
+
<span class="msg">{line.msg}</span>
|
|
264
|
+
</div>
|
|
265
|
+
{/each}
|
|
266
|
+
{/if}
|
|
62
267
|
</div>
|
|
63
|
-
|
|
268
|
+
|
|
269
|
+
{#if !following}
|
|
270
|
+
<button type="button" class="jump" onclick={jumpToBottom}>
|
|
271
|
+
Jump to bottom
|
|
272
|
+
</button>
|
|
273
|
+
{/if}
|
|
274
|
+
</div>
|
|
64
275
|
</div>
|
|
65
276
|
|
|
66
277
|
<style>.ss-logs {
|
|
67
278
|
font-family: var(--ss-font-mono);
|
|
68
|
-
|
|
69
|
-
|
|
279
|
+
background: var(--ss-code-bg);
|
|
280
|
+
color: var(--ss-code-fg);
|
|
281
|
+
border: 1px solid var(--ss-line);
|
|
282
|
+
display: flex;
|
|
283
|
+
flex-direction: column;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.bar {
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-wrap: wrap;
|
|
289
|
+
align-items: center;
|
|
290
|
+
gap: var(--ss-gap-sm);
|
|
291
|
+
padding: var(--ss-gap-sm) var(--ss-panel-body-px);
|
|
292
|
+
border-bottom: 1px solid var(--ss-line);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.filters {
|
|
296
|
+
display: flex;
|
|
297
|
+
gap: var(--ss-gap-sm);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.chip {
|
|
301
|
+
font-family: var(--ss-font-mono);
|
|
302
|
+
font-size: var(--ss-ui-sm);
|
|
303
|
+
line-height: 1;
|
|
304
|
+
padding: var(--ss-badge-py) var(--ss-badge-px);
|
|
305
|
+
border: 1px solid var(--ss-line);
|
|
306
|
+
background: transparent;
|
|
307
|
+
color: var(--ss-code-fg);
|
|
308
|
+
cursor: pointer;
|
|
309
|
+
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
310
|
+
}
|
|
311
|
+
.chip:hover {
|
|
312
|
+
border-color: var(--ss-line-strong);
|
|
313
|
+
}
|
|
314
|
+
.chip[aria-pressed=true] {
|
|
315
|
+
border-color: var(--ss-line-strong);
|
|
316
|
+
}
|
|
317
|
+
.chip[aria-pressed=false] {
|
|
318
|
+
opacity: 0.45;
|
|
319
|
+
}
|
|
320
|
+
.chip.info[aria-pressed=true] {
|
|
321
|
+
color: var(--ss-log-info);
|
|
322
|
+
}
|
|
323
|
+
.chip.warn[aria-pressed=true] {
|
|
324
|
+
color: var(--ss-log-warn);
|
|
325
|
+
}
|
|
326
|
+
.chip.err[aria-pressed=true] {
|
|
327
|
+
color: var(--ss-log-err);
|
|
328
|
+
}
|
|
329
|
+
.chip.ok[aria-pressed=true] {
|
|
330
|
+
color: var(--ss-log-ok);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.search {
|
|
334
|
+
flex: 1 1 8ch;
|
|
335
|
+
min-width: 8ch;
|
|
336
|
+
font-family: var(--ss-font-mono);
|
|
337
|
+
font-size: var(--ss-ui-sm);
|
|
338
|
+
padding: var(--ss-badge-py) var(--ss-gap-sm);
|
|
339
|
+
border: 1px solid var(--ss-line);
|
|
340
|
+
background: transparent;
|
|
70
341
|
color: var(--ss-code-fg);
|
|
342
|
+
}
|
|
343
|
+
.search:focus-visible {
|
|
344
|
+
outline: 2px solid var(--ss-primary);
|
|
345
|
+
outline-offset: 1px;
|
|
346
|
+
}
|
|
347
|
+
.search::placeholder {
|
|
348
|
+
color: var(--ss-fg-faint);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.viewport {
|
|
352
|
+
position: relative;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.scroll {
|
|
356
|
+
font-size: var(--ss-ui-md);
|
|
71
357
|
padding: var(--ss-gap) var(--ss-panel-body-px);
|
|
72
358
|
min-height: 160px;
|
|
73
359
|
max-height: 240px;
|
|
74
360
|
overflow: auto;
|
|
75
361
|
}
|
|
76
|
-
.
|
|
362
|
+
.scroll .ln {
|
|
77
363
|
display: flex;
|
|
78
|
-
gap:
|
|
364
|
+
gap: var(--ss-gap-sm);
|
|
79
365
|
line-height: 1.45;
|
|
366
|
+
white-space: pre-wrap;
|
|
367
|
+
}
|
|
368
|
+
.scroll.nowrap .ln {
|
|
369
|
+
white-space: pre;
|
|
80
370
|
}
|
|
81
|
-
.
|
|
371
|
+
.scroll .msg {
|
|
372
|
+
white-space: inherit;
|
|
373
|
+
}
|
|
374
|
+
.scroll .t {
|
|
82
375
|
color: var(--ss-fg-faint);
|
|
83
376
|
min-width: 58px;
|
|
377
|
+
flex: none;
|
|
84
378
|
}
|
|
85
|
-
.
|
|
379
|
+
.scroll .lvl {
|
|
86
380
|
min-width: 38px;
|
|
381
|
+
flex: none;
|
|
382
|
+
}
|
|
383
|
+
.scroll .lvl.info {
|
|
384
|
+
color: var(--ss-log-info);
|
|
385
|
+
}
|
|
386
|
+
.scroll .lvl.warn {
|
|
387
|
+
color: var(--ss-log-warn);
|
|
87
388
|
}
|
|
88
|
-
.
|
|
89
|
-
color: var(--ss-
|
|
389
|
+
.scroll .lvl.err {
|
|
390
|
+
color: var(--ss-log-err);
|
|
90
391
|
}
|
|
91
|
-
.
|
|
92
|
-
color: var(--ss-
|
|
392
|
+
.scroll .lvl.ok {
|
|
393
|
+
color: var(--ss-log-ok);
|
|
93
394
|
}
|
|
94
|
-
.
|
|
95
|
-
color: var(--ss-
|
|
395
|
+
.scroll .svc {
|
|
396
|
+
color: var(--ss-code-keyword);
|
|
397
|
+
flex: none;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.status {
|
|
401
|
+
display: flex;
|
|
402
|
+
align-items: center;
|
|
403
|
+
gap: var(--ss-gap-sm);
|
|
404
|
+
color: var(--ss-fg-faint);
|
|
405
|
+
font-size: var(--ss-ui-sm);
|
|
406
|
+
padding-bottom: var(--ss-gap-sm);
|
|
407
|
+
}
|
|
408
|
+
.status .dot {
|
|
409
|
+
width: var(--ss-s-2);
|
|
410
|
+
height: var(--ss-s-2);
|
|
411
|
+
background: var(--ss-primary);
|
|
412
|
+
animation: pulse var(--ss-dur-xslow) var(--ss-ease) infinite;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@keyframes pulse {
|
|
416
|
+
0%, 100% {
|
|
417
|
+
opacity: 0.3;
|
|
418
|
+
}
|
|
419
|
+
50% {
|
|
420
|
+
opacity: 1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
.jump {
|
|
424
|
+
position: absolute;
|
|
425
|
+
right: var(--ss-gap);
|
|
426
|
+
bottom: var(--ss-gap);
|
|
427
|
+
font-family: var(--ss-font-mono);
|
|
428
|
+
font-size: var(--ss-ui-sm);
|
|
429
|
+
line-height: 1;
|
|
430
|
+
padding: var(--ss-badge-py) var(--ss-badge-px);
|
|
431
|
+
border: 1px solid var(--ss-line-strong);
|
|
432
|
+
background: var(--ss-bg-elev);
|
|
433
|
+
color: var(--ss-fg);
|
|
434
|
+
cursor: pointer;
|
|
435
|
+
box-shadow: var(--ss-shadow-2);
|
|
96
436
|
}
|
|
97
|
-
.
|
|
98
|
-
color: var(--ss-primary);
|
|
437
|
+
.jump:hover {
|
|
438
|
+
border-color: var(--ss-primary);
|
|
99
439
|
}
|
|
100
|
-
.
|
|
101
|
-
|
|
440
|
+
.jump:focus-visible {
|
|
441
|
+
outline: 2px solid var(--ss-primary);
|
|
442
|
+
outline-offset: 1px;
|
|
102
443
|
}</style>
|
|
@@ -1,14 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/** A single log severity level. */
|
|
2
|
+
export type LogLevel = 'info' | 'warn' | 'err' | 'ok';
|
|
3
|
+
/** A controlled log line. `id` is optional — when omitted the index is used as the key. */
|
|
4
|
+
export interface LogLine {
|
|
5
|
+
id?: string | number;
|
|
6
|
+
/** Timestamp string (e.g. "12:00:01"); rendered verbatim. */
|
|
7
|
+
t?: string;
|
|
8
|
+
lvl: LogLevel;
|
|
9
|
+
/** Service / source tag (e.g. "[hub]"). */
|
|
10
|
+
svc?: string;
|
|
7
11
|
msg: string;
|
|
8
12
|
}
|
|
13
|
+
import { type Snippet } from 'svelte';
|
|
14
|
+
import { type Size } from '../config.js';
|
|
9
15
|
interface Props {
|
|
10
|
-
|
|
16
|
+
/** Controlled lines. When provided, the component renders exactly these (capped to `maxLines`). */
|
|
17
|
+
lines?: LogLine[];
|
|
18
|
+
/** Seed lines for the built-in demo stream (only used when `lines` is undefined). */
|
|
11
19
|
initialLines?: Omit<LogLine, 'id'>[];
|
|
20
|
+
/** Generate a random demo stream. Defaults true ONLY when `lines` is not supplied. */
|
|
21
|
+
demo?: boolean;
|
|
22
|
+
/** Back-compat alias for `demo` — drives the built-in ticker. */
|
|
23
|
+
live?: boolean;
|
|
24
|
+
/** Max number of lines kept in the buffer (oldest dropped). */
|
|
25
|
+
maxLines?: number;
|
|
26
|
+
/** Show the controls toolbar (filters, search, wrap, copy, clear). */
|
|
27
|
+
controls?: boolean;
|
|
28
|
+
/** Replace the built-in toolbar entirely. */
|
|
29
|
+
toolbar?: Snippet;
|
|
30
|
+
/** Wrap long messages (pre-wrap) vs. horizontal scroll (pre). */
|
|
31
|
+
wrap?: boolean;
|
|
32
|
+
/** aria-live politeness for the log region. */
|
|
33
|
+
announce?: 'off' | 'polite' | 'assertive';
|
|
34
|
+
/** Accessible label for the log region. */
|
|
35
|
+
ariaLabel?: string;
|
|
36
|
+
/** Show a connecting/loading indicator. */
|
|
37
|
+
loading?: boolean;
|
|
38
|
+
/** Custom empty state. */
|
|
39
|
+
empty?: Snippet;
|
|
12
40
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
13
41
|
size?: Size;
|
|
14
42
|
}
|