MCPcopy Create free account
hub / github.com/Snapchat/Valdi / NodeTarget

Class NodeTarget

valdi/vscode_debugger/src/targets/node/nodeTarget.ts:28–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28export class NodeTarget implements ITarget, IThreadDelegate {
29 private _cdp: Cdp.Api;
30 private _parent: NodeTarget | undefined;
31 private _children: NodeTarget[] = [];
32 private _targetId: string;
33 private _targetName: string;
34 private _scriptName: string;
35 private _serialize: Promise<Cdp.Api | undefined> = Promise.resolve(undefined);
36 private _attached = false;
37 private _waitingForDebugger: boolean;
38 private _onNameChangedEmitter = new EventEmitter<void>();
39 private _onDisconnectEmitter = new EventEmitter<void>();
40
41 public entryBreakpoint: IBreakpointPathAndId | undefined = undefined;
42
43 public readonly onDisconnect = this._onDisconnectEmitter.event;
44 public readonly onNameChanged = this._onNameChangedEmitter.event;
45
46 constructor(
47 private readonly pathResolver: ISourcePathResolver,
48 private readonly targetOriginValue: ITargetOrigin,
49 public readonly connection: Connection,
50 cdp: Cdp.Api,
51 targetInfo: Cdp.Target.TargetInfo,
52 public readonly logger: ILogger,
53 private readonly lifecycle: INodeTargetLifecycleHooks = {},
54 ) {
55 this.connection = connection;
56 this._cdp = cdp;
57 cdp.pause();
58 this._targetId = targetInfo.targetId;
59 this._scriptName = targetInfo.title;
60 this._waitingForDebugger = targetInfo.type === 'waitingForDebugger';
61 if (targetInfo.title)
62 this._targetName = `${basename(targetInfo.title)} [${targetInfo.targetId}]`;
63 else this._targetName = `[${targetInfo.targetId}]`;
64
65 cdp.Target.on('targetDestroyed', () => this.connection.close());
66 connection.onDisconnected(() => this._disconnected());
67 }
68
69 id(): string {
70 return this._targetId;
71 }
72
73 name(): string {
74 return this._targetName;
75 }
76
77 fileName(): string | undefined {
78 return this._scriptName;
79 }
80
81 type(): string {
82 return 'node';
83 }
84
85 targetOrigin(): ITargetOrigin {

Callers

nothing calls this directly

Calls 1

resolveMethod · 0.65

Tested by

no test coverage detected