/// import * as net from 'net'; import type { BrightScriptDebugSession } from './debugSession/BrightScriptDebugSession'; import type { Position, Range } from 'brighterscript'; import type { AdapterOptions, DisposableLike } from './interfaces'; import type { Response } from 'request'; import type * as requestType from 'request'; import type { Logger } from '@rokucommunity/logger'; declare class Util { /** * If the path does not have a trailing slash, one is appended to it * @param dirPath */ ensureTrailingSlash(dirPath: string): string; /** * Determine if a file exists * @param filePath */ fileExists(filePath: string): Promise; /** * Determines if the given path is a file * @param filePathAbsolute */ isFile(filePathAbsolute: string): Promise; /** * Removes any leading scheme in the file path * @param filePath */ removeFileScheme(filePath: string): string; /** * Gets any leading scheme in the file path * @param filePath */ getFileScheme(filePath: string): string | null; /** * Remove a single trailing newline from a string (\n or \r\n) */ removeTrailingNewline(value: string): string; /** * Reads the the manifest file and converts to a javascript object skipping empty lines and comments * @param path location of the manifest file */ convertManifestToObject(path: string): Promise | undefined>; /** * Checks to see if the port is already in use * @param port target port to check */ isPortInUse(port: number): Promise; /** * A reference to the current debug session. Used for logging, and set in the debug session constructor */ _debugSession: BrightScriptDebugSession; /** * Write to the standard brightscript output log so users can see it. (This also writes to the debug server output channel, and the console) * @param message */ log(message: string): void; /** * The vscode hover will occasionally forget to include the closing quotemark for quoted strings, * so this attempts to auto-insert a closing quotemark if an opening one was found but is missing the closing one * @param text */ ensureClosingQuote(text: string): string; /** * Test if `position` is in `range`. If the position is at the edges, will return true. * Adapted from core vscode * @param range * @param position */ rangeContains(range: Range, position: Position): boolean; /** * Ensures that all roku-emitted beacons are entirely on their own lines */ ensureDebugPromptOnOwnLine(text: string): string; /** * Does the string end with the "Brightscript Debugger>" prompt? * @param responseText */ endsWithDebuggerPrompt(text: string): boolean; /** * Does the string end with the "thread attached......" text, ignoring trailing whitespace. * explanation: https://regex101.com/r/pN6grB/1 */ endsWithThreadAttachedText(text: string): boolean; /** * Remove those pesky "Thread attached" messages and the debugger prompt following them. * explanation: https://regex101.com/r/OwAWdw/4 */ removeThreadAttachedText(text: string): string; /** * Removes the trailing `Brightscript Debugger>` prompt if present. If not present, returns original value * @param value */ trimDebugPrompt(value: string): string; /** * Check if the parameter is an expression * The HACK portion is copied from the getVariablePath function * @param expression */ isAssignableExpression(expression: string): boolean; /** * Get the keys for a given variable expression, or undefined if the expression doesn't make sense. */ getVariablePath(expression: string): string[]; /** * Given a full URL, convert any dns name into its IP address and then return the full URL with the name replaced */ resolveUrl(url: string, skipCache?: boolean): Promise; dnsLookup(host: string, skipCache?: boolean): Promise; private dnsCache; /** * Is this expression the `print` keyword followed by a variable expression (like `a.b` or `a['b'].c`) * @param expression */ isPrintVarExpression(expression: string): boolean; sleep(milliseconds: number): Promise; fence(data: string): string; formatTime(ms: number): string; normalizeAdapterOptions(options: AdapterOptions): void; /** * Set an interval that can be cleared by calling the callback * @param intervalMs the number of milliseconds to wait for the next interval */ setInterval(callback: (cancel: () => void) => any, intervalMs: number): () => void; isNullish(item: any): boolean; /** * Do an http GET request */ httpGet(url: string, options?: requestType.CoreOptions): Promise; /** * Do an http POST request */ httpPost(url: string, options?: requestType.CoreOptions): Promise; /** * Does the supplied value have at least one defined property with a non-nullish value? */ hasNonNullishProperty(value: Record): boolean; private minPort; getPort(): Promise; isTransientVariable(variableName: string): boolean; handleLogFragments(currentFragment: string, newFragment: string): { completed: string; remaining: string; }; /** * Execute dispose for a series of disposable items, and empties the array in-place * @param disposables a list of functions or disposables */ applyDispose(disposables: DisposableLike[]): void; /** * Parse an xml file and get back a javascript object containing its results */ parseXml(text: string): Promise; /** * Register the socket events for logging * @param socket - the socket to listen to for events * @param logger - the logger to use for logging * @param socketType - the type of socket (e.g. "client", "server") */ registerSocketLogging(socket: net.Socket, logger: Logger, socketType: string): void; private getSocketAddressForLogs; truncate(value: string, maxLength: number): string; /** * Coerce any value into an Error object. If it's already an Error, return it as-is. If it's not, create a new Error with the stringified value as the message * @param error * @returns */ toError(error: any): Error; } export declare function defer(): { promise: Promise; tryResolve: (value?: PromiseLike | T) => void; resolve: (value?: PromiseLike | T) => void; tryReject: (reason?: any) => void; reject: (reason?: any) => void; isResolved: boolean; isRejected: boolean; readonly isCompleted: boolean; }; export declare const util: Util; export interface Deferred { promise: Promise; resolve(value?: T): any; reject(error?: any): any; } export {};