File
Blob: src/node/inspector.ts
| 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | // Copyright Joyent and Node contributors. All rights reserved. MIT license. |
| 5 | |
| 6 | import { EventEmitter } from 'node-internal:events'; |
| 7 | import { ERR_METHOD_NOT_IMPLEMENTED } from 'node-internal:internal_errors'; |
| 8 | import type { |
| 9 | InspectorConsole, |
| 10 | Session as _Session, |
| 11 | Network as _Network, |
| 12 | } from 'node:inspector'; |
| 13 | |
| 14 | export function close(): void { |
| 15 | // Acts as a no-op. |
| 16 | } |
| 17 | |
| 18 | const noop: VoidFunction = () => {}; |
| 19 | |
| 20 | export const console: InspectorConsole = { |
| 21 | debug: noop, |
| 22 | error: noop, |
| 23 | info: noop, |
| 24 | log: noop, |
| 25 | warn: noop, |
| 26 | dir: noop, |
| 27 | dirxml: noop, |
| 28 | table: noop, |
| 29 | trace: noop, |
| 30 | group: noop, |
| 31 | groupCollapsed: noop, |
| 32 | groupEnd: noop, |
| 33 | clear: noop, |
| 34 | count: noop, |
| 35 | countReset: noop, |
| 36 | assert: noop, |
| 37 | profile: noop, |
| 38 | profileEnd: noop, |
| 39 | time: noop, |
| 40 | timeLog: noop, |
| 41 | timeStamp: noop, |
| 42 | }; |
| 43 | |
| 44 | export function open( |
| 45 | _port?: number, |
| 46 | _host?: string, |
| 47 | _wait?: boolean |
| 48 | ): Disposable { |
| 49 | return { |
| 50 | [Symbol.dispose](): Promise<void> { |
| 51 | return Promise.resolve(); |
| 52 | }, |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | export function url(): string | undefined { |
| 57 | return undefined; |
| 58 | } |
| 59 | |
| 60 | export function waitForDebugger(): void { |
| 61 | // Acts as a no-op. |
| 62 | } |
| 63 | |
| 64 | export class Session extends EventEmitter implements _Session { |
| 65 | constructor() { |
| 66 | super(); |
| 67 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session'); |
| 68 | } |
| 69 | |
| 70 | connect(): void { |
| 71 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.connect'); |
| 72 | } |
| 73 | |
| 74 | connectToMainThread(): void { |
| 75 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.connectToMainThread'); |
| 76 | } |
| 77 | |
| 78 | disconnect(): void { |
| 79 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.disconnect'); |
| 80 | } |
| 81 | |
| 82 | post(_method: unknown, _params?: unknown, _callback?: unknown): void { |
| 83 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.post'); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | export const Network: typeof _Network = { |
| 88 | requestWillBeSent(_params: _Network.RequestWillBeSentEventDataType): void { |
| 89 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.requestWillBeSent'); |
| 90 | }, |
| 91 | dataReceived(_params: _Network.DataReceivedEventDataType): void { |
| 92 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.dataReceived'); |
| 93 | }, |
| 94 | dataSent(_params: unknown): void { |
| 95 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.dataSent'); |
| 96 | }, |
| 97 | responseReceived(_params: _Network.ResponseReceivedEventDataType): void { |
| 98 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.responseReceived'); |
| 99 | }, |
| 100 | loadingFinished(_params: _Network.LoadingFinishedEventDataType): void { |
| 101 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.loadingFinished'); |
| 102 | }, |
| 103 | loadingFailed(_params: _Network.LoadingFailedEventDataType): void { |
| 104 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.loadingFailed'); |
| 105 | }, |
| 106 | webSocketCreated(_params: _Network.WebSocketCreatedEventDataType): void { |
| 107 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.webSocketCreated'); |
| 108 | }, |
| 109 | webSocketHandshakeResponseReceived( |
| 110 | _params: _Network.WebSocketHandshakeResponseReceivedEventDataType |
| 111 | ): void { |
| 112 | throw new ERR_METHOD_NOT_IMPLEMENTED( |
| 113 | 'Network.webSocketHandshakeResponseReceived' |
| 114 | ); |
| 115 | }, |
| 116 | webSocketClosed(_params: _Network.WebSocketClosedEventDataType): void { |
| 117 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.webSocketClosed'); |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | export default { |
| 122 | Session, |
| 123 | close, |
| 124 | console, |
| 125 | open, |
| 126 | url, |
| 127 | waitForDebugger, |
| 128 | Network, |
| 129 | }; |