File
Blob: src/node/inspector/promises.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 type { |
| 8 | console as _console, |
| 9 | Network as _Network, |
| 10 | Session as _Session, |
| 11 | } from 'node:inspector/promises'; |
| 12 | import { ERR_METHOD_NOT_IMPLEMENTED } from 'node-internal:internal_errors'; |
| 13 | |
| 14 | const noop: VoidFunction = () => {}; |
| 15 | export const console: typeof _console = { |
| 16 | debug: noop, |
| 17 | error: noop, |
| 18 | info: noop, |
| 19 | log: noop, |
| 20 | warn: noop, |
| 21 | dir: noop, |
| 22 | dirxml: noop, |
| 23 | table: noop, |
| 24 | trace: noop, |
| 25 | group: noop, |
| 26 | groupCollapsed: noop, |
| 27 | groupEnd: noop, |
| 28 | clear: noop, |
| 29 | count: noop, |
| 30 | countReset: noop, |
| 31 | assert: noop, |
| 32 | profile: noop, |
| 33 | profileEnd: noop, |
| 34 | time: noop, |
| 35 | timeLog: noop, |
| 36 | timeStamp: noop, |
| 37 | }; |
| 38 | |
| 39 | export const Network: typeof _Network = { |
| 40 | requestWillBeSent(_params: _Network.RequestWillBeSentEventDataType): void { |
| 41 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.requestWillBeSent'); |
| 42 | }, |
| 43 | dataReceived(_params: _Network.DataReceivedEventDataType): void { |
| 44 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.dataReceived'); |
| 45 | }, |
| 46 | responseReceived(_params: _Network.ResponseReceivedEventDataType): void { |
| 47 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.responseReceived'); |
| 48 | }, |
| 49 | loadingFinished(_params: _Network.LoadingFinishedEventDataType): void { |
| 50 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.loadingFinished'); |
| 51 | }, |
| 52 | loadingFailed(_params: _Network.LoadingFailedEventDataType): void { |
| 53 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.loadingFailed'); |
| 54 | }, |
| 55 | webSocketHandshakeResponseReceived( |
| 56 | _params: _Network.WebSocketHandshakeResponseReceivedEventDataType |
| 57 | ): void { |
| 58 | throw new ERR_METHOD_NOT_IMPLEMENTED( |
| 59 | 'Network.webSocketHandshakeResponseReceived' |
| 60 | ); |
| 61 | }, |
| 62 | webSocketClosed(_params: _Network.WebSocketClosedEventDataType): void { |
| 63 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.webSocketClosed'); |
| 64 | }, |
| 65 | webSocketCreated(_params: _Network.WebSocketCreatedEventDataType): void { |
| 66 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.webSocketCreated'); |
| 67 | }, |
| 68 | dataSent(_params: unknown): void { |
| 69 | throw new ERR_METHOD_NOT_IMPLEMENTED('Network.dataSent'); |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | export class Session extends EventEmitter implements _Session { |
| 74 | constructor() { |
| 75 | super(); |
| 76 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session'); |
| 77 | } |
| 78 | |
| 79 | connect(): void { |
| 80 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.connect'); |
| 81 | } |
| 82 | |
| 83 | connectToMainThread(): void { |
| 84 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.connectToMainThread'); |
| 85 | } |
| 86 | |
| 87 | disconnect(): void { |
| 88 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.disconnect'); |
| 89 | } |
| 90 | |
| 91 | // @ts-expect-error TS2416 This is intentional |
| 92 | post( |
| 93 | _method: unknown, |
| 94 | _params?: unknown, |
| 95 | _callback?: unknown |
| 96 | ): Promise<unknown> { |
| 97 | throw new ERR_METHOD_NOT_IMPLEMENTED('Session.post'); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | export function url(): string | undefined { |
| 102 | throw new ERR_METHOD_NOT_IMPLEMENTED('Inspector.url'); |
| 103 | } |
| 104 | |
| 105 | export function waitForDebugger(): Promise<void> { |
| 106 | throw new ERR_METHOD_NOT_IMPLEMENTED('Inspector.waitForDebugger'); |
| 107 | } |
| 108 | |
| 109 | export function open(): Disposable { |
| 110 | throw new ERR_METHOD_NOT_IMPLEMENTED('Inspector.open'); |
| 111 | } |
| 112 | |
| 113 | export function close(): void { |
| 114 | throw new ERR_METHOD_NOT_IMPLEMENTED('Inspector.close'); |
| 115 | } |
| 116 | |
| 117 | export default { |
| 118 | close, |
| 119 | console, |
| 120 | Network, |
| 121 | open, |
| 122 | Session, |
| 123 | url, |
| 124 | waitForDebugger, |
| 125 | }; |