|
5 | 5 | import Message from '../Message.svelte'; |
6 | 6 | import PaneWithPanel from './PaneWithPanel.svelte'; |
7 | 7 | import ReplProxy from './ReplProxy.js'; |
8 | | - import Console, { type Log } from './console/Console.svelte'; |
| 8 | + import Console from './console/Console.svelte'; |
9 | 9 | import getLocationFromStack from './get-location-from-stack'; |
10 | 10 | import srcdoc from './srcdoc/index.html?raw'; |
11 | 11 | import srcdoc_styles from './srcdoc/styles.css?raw'; |
12 | 12 | import ErrorOverlay from './ErrorOverlay.svelte'; |
13 | 13 | import type { CompileError } from 'svelte/compiler'; |
14 | 14 | import type Bundler from '../Bundler.svelte'; |
15 | 15 | import type { BundleResult } from '../public'; |
| 16 | + import { Log } from './console/Log.svelte'; |
16 | 17 |
|
17 | 18 | interface Props { |
18 | 19 | error: Error | null; |
|
48 | 49 | let context = get_repl_context(); |
49 | 50 | let bundle = $derived((bundler ?? context?.bundler)?.result); |
50 | 51 |
|
51 | | - let logs: Log[] = $state.raw([]); // we don't want to proxify the logged values |
| 52 | + let logs: Log[] = $state([]); |
52 | 53 | let log_group_stack: Log[][] = []; |
53 | 54 |
|
54 | 55 | // svelte-ignore state_referenced_locally |
|
255 | 256 | error = e; |
256 | 257 | } |
257 | 258 |
|
258 | | - function push_logs(log: Log) { |
| 259 | + function push_logs(data: any) { |
| 260 | + const log = new Log(data); |
259 | 261 | current_log_group.push((last_console_event = log)); |
260 | | - logs = [...logs, log]; |
261 | 262 | onLog?.(logs); |
262 | 263 | } |
263 | 264 |
|
264 | | - function group_logs(log: Log) { |
265 | | - log.logs = []; |
| 265 | + function group_logs(data: any) { |
| 266 | + const log = new Log(data); |
266 | 267 | current_log_group.push(log); |
267 | 268 | // TODO: Investigate |
268 | 269 | log_group_stack.push(current_log_group); |
269 | 270 | current_log_group = log.logs; |
270 | | - logs = [...logs]; |
271 | 271 | onLog?.(logs); |
272 | 272 | } |
273 | 273 |
|
|
278 | 278 | } |
279 | 279 |
|
280 | 280 | function increment_duplicate_log() { |
281 | | - const last_log = current_log_group[current_log_group.length - 1]; |
| 281 | + last_console_event.count += 1; |
282 | 282 |
|
283 | | - if (last_log) { |
284 | | - last_log.count = (last_log.count || 1) + 1; |
285 | | - logs = [...logs]; |
| 283 | + if (current_log_group.includes(last_console_event)) { |
286 | 284 | onLog?.(logs); |
287 | 285 | } else { |
288 | | - last_console_event.count = 1; |
| 286 | + // console was cleared |
289 | 287 | push_logs(last_console_event); |
290 | 288 | } |
291 | 289 | } |
|
0 commit comments