@evgkch/reactive-dom 0.1.0 → 0.2.0
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 +71 -92
- package/dist/create-element.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/list.js +4 -4
- package/dist/log.d.ts +9 -14
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +20 -78
- package/dist/slot.js +4 -4
- package/dist/unmount.js +2 -2
- package/examples/index.html +4 -4
- package/examples/pages/console/index.css +73 -0
- package/examples/pages/console/index.html +13 -0
- package/examples/pages/console/index.ts +11 -0
- package/examples/pages/console/model/state.ts +25 -0
- package/examples/pages/console/ui/App.ts +57 -0
- package/examples/pages/console/ui/LineItem.ts +13 -0
- package/examples/pages/monitor/index.css +297 -0
- package/examples/pages/monitor/index.html +13 -0
- package/examples/pages/monitor/index.ts +24 -0
- package/examples/pages/monitor/model/state.ts +30 -0
- package/examples/pages/monitor/ui/App.ts +207 -0
- package/examples/pages/monitor/ui/TaskItem.ts +41 -0
- package/examples/{stream/styles.css → pages/stream/index.css} +1 -75
- package/examples/pages/stream/index.html +13 -0
- package/examples/pages/stream/index.ts +15 -0
- package/examples/pages/stream/model/state.ts +45 -0
- package/examples/pages/stream/ui/App.ts +70 -0
- package/examples/pages/stream/ui/LogLine.ts +27 -0
- package/examples/shared/lib/index.ts +19 -0
- package/examples/{console/styles.css → shared/styles/common.css} +5 -77
- package/examples/tsconfig.json +13 -0
- package/package.json +10 -8
- package/examples/console/app.js +0 -97
- package/examples/console/index.html +0 -23
- package/examples/monitor/app.js +0 -260
- package/examples/monitor/index.html +0 -23
- package/examples/monitor/styles.css +0 -425
- package/examples/stream/app.js +0 -136
- package/examples/stream/index.html +0 -23
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap");
|
|
2
|
-
|
|
3
|
-
*,
|
|
4
|
-
*::before,
|
|
5
|
-
*::after {
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
margin: 0;
|
|
8
|
-
padding: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
:root {
|
|
12
|
-
--bg: #080808;
|
|
13
|
-
--surface: #0f0f0f;
|
|
14
|
-
--border: #2a2a2a;
|
|
15
|
-
--ink: #d0d0d0;
|
|
16
|
-
--muted: #666;
|
|
17
|
-
--dim: #444;
|
|
18
|
-
--accent: #39ff14;
|
|
19
|
-
--red: #ff3333;
|
|
20
|
-
--yellow: #ffcc00;
|
|
21
|
-
--blue: #4488ff;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
body {
|
|
25
|
-
font-family: "JetBrains Mono", monospace;
|
|
26
|
-
background: var(--bg);
|
|
27
|
-
color: var(--ink);
|
|
28
|
-
min-height: 100vh;
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
|
-
padding: 2rem 1rem;
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
line-height: 1.5;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* ── монитор — основной контейнер ── */
|
|
38
|
-
.monitor {
|
|
39
|
-
width: 100%;
|
|
40
|
-
max-width: 480px;
|
|
41
|
-
border: 1px solid var(--border);
|
|
42
|
-
background: var(--surface);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* ── строка с рамкой ── */
|
|
46
|
-
.row {
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: stretch;
|
|
49
|
-
border-bottom: 1px solid var(--border);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.row:last-child {
|
|
53
|
-
border-bottom: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.cell {
|
|
57
|
-
padding: 0.5rem 0.75rem;
|
|
58
|
-
flex: 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.cell + .cell {
|
|
62
|
-
border-left: 1px solid var(--border);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* ── заголовок ── */
|
|
66
|
-
.titlebar {
|
|
67
|
-
display: flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
justify-content: space-between;
|
|
70
|
-
padding: 0.4rem 0.75rem;
|
|
71
|
-
border-bottom: 1px solid var(--border);
|
|
72
|
-
background: var(--bg);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.titlebar-left {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
gap: 0.5rem;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.dot {
|
|
82
|
-
width: 8px;
|
|
83
|
-
height: 8px;
|
|
84
|
-
border-radius: 50%;
|
|
85
|
-
display: inline-block;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.dot-red {
|
|
89
|
-
background: var(--red);
|
|
90
|
-
}
|
|
91
|
-
.dot-yellow {
|
|
92
|
-
background: var(--yellow);
|
|
93
|
-
}
|
|
94
|
-
.dot-green {
|
|
95
|
-
background: var(--accent);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.titlebar-title {
|
|
99
|
-
font-size: 11px;
|
|
100
|
-
font-weight: 700;
|
|
101
|
-
color: var(--ink);
|
|
102
|
-
letter-spacing: 0.1em;
|
|
103
|
-
margin-left: 0.5rem;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.titlebar-right {
|
|
107
|
-
font-size: 10px;
|
|
108
|
-
color: var(--muted);
|
|
109
|
-
letter-spacing: 0.05em;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* ── метрики ── */
|
|
113
|
-
.metrics {
|
|
114
|
-
display: grid;
|
|
115
|
-
grid-template-columns: 1fr 1fr 1fr;
|
|
116
|
-
border-bottom: 1px solid var(--border);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.metric {
|
|
120
|
-
padding: 0.5rem 0.75rem;
|
|
121
|
-
border-right: 1px solid var(--border);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.metric:last-child {
|
|
125
|
-
border-right: none;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.metric-label {
|
|
129
|
-
font-size: 10px;
|
|
130
|
-
color: var(--muted);
|
|
131
|
-
letter-spacing: 0.08em;
|
|
132
|
-
margin-bottom: 0.25rem;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.metric-bar {
|
|
136
|
-
height: 3px;
|
|
137
|
-
background: var(--border);
|
|
138
|
-
margin-bottom: 0.2rem;
|
|
139
|
-
position: relative;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.metric-fill {
|
|
143
|
-
height: 100%;
|
|
144
|
-
background: var(--accent);
|
|
145
|
-
transition: width 0.8s ease;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.metric-fill.warn {
|
|
149
|
-
background: var(--yellow);
|
|
150
|
-
}
|
|
151
|
-
.metric-fill.crit {
|
|
152
|
-
background: var(--red);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.metric-val {
|
|
156
|
-
font-size: 11px;
|
|
157
|
-
font-weight: 700;
|
|
158
|
-
color: var(--ink);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/* ── input ── */
|
|
162
|
-
.input-row {
|
|
163
|
-
display: flex;
|
|
164
|
-
align-items: center;
|
|
165
|
-
border-bottom: 1px solid var(--border);
|
|
166
|
-
padding: 0 0.75rem;
|
|
167
|
-
background: var(--bg);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.prompt {
|
|
171
|
-
color: var(--accent);
|
|
172
|
-
font-weight: 700;
|
|
173
|
-
margin-right: 0.5rem;
|
|
174
|
-
flex-shrink: 0;
|
|
175
|
-
font-size: 12px;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.new-input {
|
|
179
|
-
flex: 1;
|
|
180
|
-
font-family: "JetBrains Mono", monospace;
|
|
181
|
-
font-size: 12px;
|
|
182
|
-
background: transparent;
|
|
183
|
-
border: none;
|
|
184
|
-
padding: 0.55rem 0;
|
|
185
|
-
color: var(--ink);
|
|
186
|
-
outline: none;
|
|
187
|
-
caret-color: var(--accent);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.new-input::placeholder {
|
|
191
|
-
color: var(--dim);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.kbd-hint {
|
|
195
|
-
font-size: 10px;
|
|
196
|
-
color: var(--dim);
|
|
197
|
-
flex-shrink: 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/* ── task list ── */
|
|
201
|
-
.task-list {
|
|
202
|
-
list-style: none;
|
|
203
|
-
min-height: 2rem;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.task-list li {
|
|
207
|
-
display: grid;
|
|
208
|
-
grid-template-columns: 18px 1fr auto auto;
|
|
209
|
-
align-items: center;
|
|
210
|
-
gap: 0.6rem;
|
|
211
|
-
padding: 0.45rem 0.75rem;
|
|
212
|
-
border-bottom: 1px solid #1a1a1a;
|
|
213
|
-
transition: background 0.1s;
|
|
214
|
-
cursor: default;
|
|
215
|
-
visibility: visible;
|
|
216
|
-
opacity: 1;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.task-list li:last-child {
|
|
220
|
-
border-bottom: none;
|
|
221
|
-
}
|
|
222
|
-
.task-list li:hover {
|
|
223
|
-
background: #131313;
|
|
224
|
-
}
|
|
225
|
-
.task-list li.done {
|
|
226
|
-
opacity: 0.5;
|
|
227
|
-
}
|
|
228
|
-
.task-list li.selected {
|
|
229
|
-
background: #141a14;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/* checkbox */
|
|
233
|
-
.task-check {
|
|
234
|
-
appearance: none;
|
|
235
|
-
width: 14px;
|
|
236
|
-
height: 14px;
|
|
237
|
-
border: 1px solid var(--muted);
|
|
238
|
-
cursor: pointer;
|
|
239
|
-
position: relative;
|
|
240
|
-
flex-shrink: 0;
|
|
241
|
-
transition: border-color 0.1s;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.task-check:hover {
|
|
245
|
-
border-color: var(--accent);
|
|
246
|
-
}
|
|
247
|
-
.task-check:checked {
|
|
248
|
-
border-color: var(--accent);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.task-check:checked::after {
|
|
252
|
-
content: "✓";
|
|
253
|
-
position: absolute;
|
|
254
|
-
inset: 0;
|
|
255
|
-
display: flex;
|
|
256
|
-
align-items: center;
|
|
257
|
-
justify-content: center;
|
|
258
|
-
font-size: 10px;
|
|
259
|
-
color: var(--accent);
|
|
260
|
-
font-weight: 700;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/* text */
|
|
264
|
-
.task-text {
|
|
265
|
-
font-size: 12px;
|
|
266
|
-
word-break: break-word;
|
|
267
|
-
color: var(--ink);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.task-list li.done .task-text {
|
|
271
|
-
color: var(--muted);
|
|
272
|
-
text-decoration: line-through;
|
|
273
|
-
text-decoration-color: #444;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/* status badge */
|
|
277
|
-
.task-status {
|
|
278
|
-
font-size: 10px;
|
|
279
|
-
letter-spacing: 0.06em;
|
|
280
|
-
color: var(--muted);
|
|
281
|
-
flex-shrink: 0;
|
|
282
|
-
width: 52px;
|
|
283
|
-
text-align: right;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
.task-list li:not(.done) .task-status {
|
|
287
|
-
color: var(--blue);
|
|
288
|
-
}
|
|
289
|
-
.task-list li.done .task-status {
|
|
290
|
-
color: var(--dim);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/* remove */
|
|
294
|
-
.task-remove {
|
|
295
|
-
font-family: "JetBrains Mono", monospace;
|
|
296
|
-
font-size: 10px;
|
|
297
|
-
background: none;
|
|
298
|
-
border: none;
|
|
299
|
-
color: var(--dim);
|
|
300
|
-
cursor: pointer;
|
|
301
|
-
padding: 0.1rem 0.2rem;
|
|
302
|
-
opacity: 0;
|
|
303
|
-
transition:
|
|
304
|
-
opacity 0.1s,
|
|
305
|
-
color 0.1s;
|
|
306
|
-
flex-shrink: 0;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.task-list li:hover .task-remove {
|
|
310
|
-
opacity: 1;
|
|
311
|
-
}
|
|
312
|
-
.task-remove:hover {
|
|
313
|
-
color: var(--red);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/* ── footer ── */
|
|
317
|
-
.statusbar {
|
|
318
|
-
display: flex;
|
|
319
|
-
align-items: center;
|
|
320
|
-
justify-content: space-between;
|
|
321
|
-
padding: 0.35rem 0.75rem;
|
|
322
|
-
border-top: 1px solid var(--border);
|
|
323
|
-
background: var(--bg);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.status-left {
|
|
327
|
-
font-size: 10px;
|
|
328
|
-
color: var(--muted);
|
|
329
|
-
display: flex;
|
|
330
|
-
gap: 1rem;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.status-left span {
|
|
334
|
-
color: var(--ink);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
.filters {
|
|
338
|
-
display: flex;
|
|
339
|
-
gap: 0;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
.filters button {
|
|
343
|
-
font-family: "JetBrains Mono", monospace;
|
|
344
|
-
font-size: 10px;
|
|
345
|
-
background: none;
|
|
346
|
-
border: 1px solid transparent;
|
|
347
|
-
color: var(--muted);
|
|
348
|
-
cursor: pointer;
|
|
349
|
-
padding: 0.15rem 0.5rem;
|
|
350
|
-
letter-spacing: 0.05em;
|
|
351
|
-
transition:
|
|
352
|
-
color 0.1s,
|
|
353
|
-
border-color 0.1s;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
.filters button:hover {
|
|
357
|
-
color: var(--ink);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
.filters button.active {
|
|
361
|
-
color: var(--accent);
|
|
362
|
-
border-color: var(--border);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/* ── hotkeys panel ── */
|
|
366
|
-
.hotkeys {
|
|
367
|
-
display: flex;
|
|
368
|
-
gap: 1rem;
|
|
369
|
-
padding: 0.35rem 0.75rem;
|
|
370
|
-
border-top: 1px solid var(--border);
|
|
371
|
-
background: var(--bg);
|
|
372
|
-
flex-wrap: wrap;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.hotkey {
|
|
376
|
-
font-size: 10px;
|
|
377
|
-
color: var(--dim);
|
|
378
|
-
display: flex;
|
|
379
|
-
align-items: center;
|
|
380
|
-
gap: 0.3rem;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.hotkey kbd {
|
|
384
|
-
font-family: "JetBrains Mono", monospace;
|
|
385
|
-
font-size: 9px;
|
|
386
|
-
background: var(--border);
|
|
387
|
-
color: var(--ink);
|
|
388
|
-
padding: 0.1rem 0.3rem;
|
|
389
|
-
border-radius: 2px;
|
|
390
|
-
border-bottom: 1px solid #333;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/* ── empty ── */
|
|
394
|
-
.empty {
|
|
395
|
-
padding: 1.25rem 0.75rem;
|
|
396
|
-
font-size: 11px;
|
|
397
|
-
color: var(--dim);
|
|
398
|
-
border-bottom: 1px solid #1a1a1a;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
.empty::before {
|
|
402
|
-
content: "// ";
|
|
403
|
-
color: var(--border);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/* ── анимация курсора в title ── */
|
|
407
|
-
.cursor {
|
|
408
|
-
display: inline-block;
|
|
409
|
-
width: 7px;
|
|
410
|
-
height: 13px;
|
|
411
|
-
background: var(--accent);
|
|
412
|
-
margin-left: 3px;
|
|
413
|
-
vertical-align: middle;
|
|
414
|
-
animation: blink 1s step-end infinite;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
@keyframes blink {
|
|
418
|
-
0%,
|
|
419
|
-
100% {
|
|
420
|
-
opacity: 1;
|
|
421
|
-
}
|
|
422
|
-
50% {
|
|
423
|
-
opacity: 0;
|
|
424
|
-
}
|
|
425
|
-
}
|
package/examples/stream/app.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import * as R from "@evgkch/reactive";
|
|
2
|
-
import * as UI from "@evgkch/reactive-dom";
|
|
3
|
-
|
|
4
|
-
if (typeof document !== "undefined" && document.getElementById("app")) {
|
|
5
|
-
R.configure({ log: true });
|
|
6
|
-
UI.configure({ log: true });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const levelFilter = R.Value("all");
|
|
10
|
-
const logs = R.List([]);
|
|
11
|
-
|
|
12
|
-
const LEVELS = ["info", "warn", "err"];
|
|
13
|
-
const MESSAGES = [
|
|
14
|
-
"Connection established",
|
|
15
|
-
"Handshake complete",
|
|
16
|
-
"Buffer overflow risk",
|
|
17
|
-
"Retry attempt 3",
|
|
18
|
-
"Cache miss",
|
|
19
|
-
"Timeout after 2000ms",
|
|
20
|
-
"Invalid payload",
|
|
21
|
-
"Rate limit exceeded",
|
|
22
|
-
"Endpoint unreachable",
|
|
23
|
-
"Auth failed",
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
function fmtTime(ts) {
|
|
27
|
-
const d = new Date(ts);
|
|
28
|
-
return (
|
|
29
|
-
String(d.getHours()).padStart(2, "0") +
|
|
30
|
-
":" +
|
|
31
|
-
String(d.getMinutes()).padStart(2, "0") +
|
|
32
|
-
":" +
|
|
33
|
-
String(d.getSeconds()).padStart(2, "0") +
|
|
34
|
-
"." +
|
|
35
|
-
String(Math.floor(d.getMilliseconds() / 100)).padStart(1, "0")
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function addRandomLog() {
|
|
40
|
-
const level = LEVELS[Math.floor(Math.random() * LEVELS.length)];
|
|
41
|
-
const msg = MESSAGES[Math.floor(Math.random() * MESSAGES.length)];
|
|
42
|
-
logs.push(R.Struct({ ts: Date.now(), level, msg }));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let timer;
|
|
46
|
-
if (typeof document !== "undefined" && document.getElementById("app")) {
|
|
47
|
-
timer = setInterval(addRandomLog, 800);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const LogLine = UI.List(
|
|
51
|
-
`<li>
|
|
52
|
-
<span class="log-ts" data-ref="ts"></span>
|
|
53
|
-
<span class="log-level" data-ref="level"></span>
|
|
54
|
-
<span class="log-msg" data-ref="msg"></span>
|
|
55
|
-
</li>`,
|
|
56
|
-
(props, refs, ctx) => {
|
|
57
|
-
ctx.batch(() => {
|
|
58
|
-
const { level, msg, ts } = props.item;
|
|
59
|
-
refs.ts.textContent = fmtTime(ts);
|
|
60
|
-
refs.level.textContent = level.toUpperCase();
|
|
61
|
-
refs.level.className = "log-level " + level;
|
|
62
|
-
refs.msg.textContent = msg;
|
|
63
|
-
|
|
64
|
-
const f = levelFilter.get();
|
|
65
|
-
refs.el.style.display =
|
|
66
|
-
f === "all" ? "" : f === level ? "" : "none";
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const App = UI.Struct(
|
|
72
|
-
`<div class="panel">
|
|
73
|
-
<div class="titlebar">
|
|
74
|
-
<div class="titlebar-left">
|
|
75
|
-
<span class="dot dot-red"></span>
|
|
76
|
-
<span class="dot dot-yellow"></span>
|
|
77
|
-
<span class="dot dot-green"></span>
|
|
78
|
-
<span class="titlebar-title">SYS://STREAM</span>
|
|
79
|
-
</div>
|
|
80
|
-
<div class="titlebar-right" data-ref="count">0 events</div>
|
|
81
|
-
</div>
|
|
82
|
-
<div class="stream-toolbar">
|
|
83
|
-
<div class="stream-filters" data-ref="filters">
|
|
84
|
-
<button data-level="all">all</button>
|
|
85
|
-
<button data-level="info">info</button>
|
|
86
|
-
<button data-level="warn">warn</button>
|
|
87
|
-
<button data-level="err">err</button>
|
|
88
|
-
</div>
|
|
89
|
-
<button class="stream-clear" data-ref="clear">clear</button>
|
|
90
|
-
</div>
|
|
91
|
-
<ul class="log-list" data-ref="list"></ul>
|
|
92
|
-
<p class="empty-logs" data-ref="empty">waiting for events...</p>
|
|
93
|
-
</div>`,
|
|
94
|
-
(props, refs, ctx) => {
|
|
95
|
-
ctx.list(refs.list, logs, (item) => ({ item }), LogLine, {
|
|
96
|
-
onAdd: (el) => {
|
|
97
|
-
el.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 120 });
|
|
98
|
-
requestAnimationFrame(() => {
|
|
99
|
-
requestAnimationFrame(() => {
|
|
100
|
-
const list = refs.list;
|
|
101
|
-
list.scrollTop = list.scrollHeight;
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// React to list changes only (count, empty) — Watch fires on push/splice, no Batch on every add
|
|
108
|
-
function updateCount() {
|
|
109
|
-
refs.count.textContent = logs.length + " event" + (logs.length !== 1 ? "s" : "");
|
|
110
|
-
refs.empty.style.display = logs.length === 0 ? "block" : "none";
|
|
111
|
-
}
|
|
112
|
-
updateCount();
|
|
113
|
-
ctx.watch(logs, updateCount);
|
|
114
|
-
|
|
115
|
-
ctx.batch(() => {
|
|
116
|
-
const current = levelFilter.get();
|
|
117
|
-
for (const btn of refs.filters.querySelectorAll("[data-level]")) {
|
|
118
|
-
btn.className = current === btn.getAttribute("data-level") ? "active" : "";
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
refs.filters.addEventListener("click", (e) => {
|
|
123
|
-
const level = e.target?.getAttribute?.("data-level");
|
|
124
|
-
if (level) levelFilter.set(level);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
refs.clear.addEventListener("click", () => {
|
|
128
|
-
logs.splice(0, logs.length);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
export { App, logs, levelFilter };
|
|
134
|
-
if (typeof document !== "undefined" && document.getElementById("app")) {
|
|
135
|
-
document.getElementById("app").appendChild(App({}));
|
|
136
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<title>Stream — reactive-dom</title>
|
|
7
|
-
<script type="importmap">
|
|
8
|
-
{
|
|
9
|
-
"imports": {
|
|
10
|
-
"@evgkch/reactive": "/node_modules/@evgkch/reactive/dist/index.js",
|
|
11
|
-
"@evgkch/reactive-dom": "/dist/index.js"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
</script>
|
|
15
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
16
|
-
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
|
|
17
|
-
<link rel="stylesheet" href="./styles.css">
|
|
18
|
-
</head>
|
|
19
|
-
<body>
|
|
20
|
-
<div id="app"></div>
|
|
21
|
-
<script type="module" src="./app.js"></script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|