|
| 1 | +// Copyright 2025 The Chromium Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import type * as Protocol from '../../generated/protocol.js'; |
| 6 | + |
| 7 | +import type * as StackTrace from './stack_trace.js'; |
| 8 | + |
| 9 | +/** |
| 10 | + * Intentionally very close to a {@link Protocol.Runtime.CallFrame} but with optional `scriptId`. |
| 11 | + */ |
| 12 | +export interface RawFrame { |
| 13 | + readonly scriptId?: Protocol.Runtime.ScriptId; |
| 14 | + readonly url?: string; |
| 15 | + readonly functionName?: string; |
| 16 | + readonly lineNumber: number; |
| 17 | + readonly columnNumber: number; |
| 18 | +} |
| 19 | + |
| 20 | +interface FrameNodeBase<ChildT, ParentT> { |
| 21 | + readonly parent: ParentT; |
| 22 | + readonly children: ChildT[]; |
| 23 | +} |
| 24 | + |
| 25 | +type RootFrameNode = FrameNodeBase<WeakRef<FrameNode>, null>; |
| 26 | +type AnyFrameNode = FrameNode|RootFrameNode; |
| 27 | + |
| 28 | +export interface FrameNode extends FrameNodeBase<FrameNode, AnyFrameNode> { |
| 29 | + readonly rawFrame: RawFrame; |
| 30 | + frames: StackTrace.StackTrace.Frame[]; |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * Stores stack trace fragments in a trie, but does not own them/keep them alive. |
| 35 | + */ |
| 36 | +export class Trie { |
| 37 | + // eslint-disable-next-line no-unused-private-class-members |
| 38 | + readonly #root: RootFrameNode = {parent: null, children: []}; |
| 39 | + |
| 40 | + insert(frames: RawFrame[]): FrameNode { |
| 41 | + if (frames.length === 0) { |
| 42 | + throw new Error('Trie.insert called with an empty frames array.'); |
| 43 | + } |
| 44 | + |
| 45 | + // TODO(crbug.com/433162438): Implement it. |
| 46 | + throw new Error('Not implemented'); |
| 47 | + } |
| 48 | +} |
0 commit comments