- Consolidated duplicate UndoManagers to single instance - Fixed connection promise to only resolve on 'connected' status - Fixed WebSocketProvider import (WebsocketProvider) - Added proper doc.destroy() cleanup - Renamed isPresenceInitialized property to avoid conflict Co-Authored-By: Paperclip <noreply@paperclip.ing>
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @noformat
|
|
* @oncall react_native
|
|
* @generated SignedSource<<0b066ed2be97f8d1db5abb8f1a933cb0>>
|
|
*
|
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
* Original file: packages/metro-core/src/Terminal.js
|
|
* To regenerate, run:
|
|
* js1 build metro-ts-defs (internal) OR
|
|
* yarn run build-ts-defs (OSS)
|
|
*/
|
|
|
|
import type {Socket} from 'net';
|
|
import type {Writable} from 'stream';
|
|
|
|
type UnderlyingStream = Socket | Writable;
|
|
/**
|
|
* We don't just print things to the console, sometimes we also want to show
|
|
* and update progress. This utility just ensures the output stays neat: no
|
|
* missing newlines, no mangled log lines.
|
|
*
|
|
* const terminal = Terminal.default;
|
|
* terminal.status('Updating... 38%');
|
|
* terminal.log('warning: Something happened.');
|
|
* terminal.status('Updating, done.');
|
|
* terminal.persistStatus();
|
|
*
|
|
* The final output:
|
|
*
|
|
* warning: Something happened.
|
|
* Updating, done.
|
|
*
|
|
* Without the status feature, we may get a mangled output:
|
|
*
|
|
* Updating... 38%warning: Something happened.
|
|
* Updating, done.
|
|
*
|
|
* This is meant to be user-readable and TTY-oriented. We use stdout by default
|
|
* because it's more about status information than diagnostics/errors (stderr).
|
|
*
|
|
* Do not add any higher-level functionality in this class such as "warning" and
|
|
* "error" printers, as it is not meant for formatting/reporting. It has the
|
|
* single responsibility of handling status messages.
|
|
*/
|
|
declare class Terminal {
|
|
constructor(stream: UnderlyingStream, opts?: {ttyPrint?: boolean});
|
|
waitForUpdates(): Promise<void>;
|
|
/**
|
|
* Useful for calling console/stdout directly after terminal logs
|
|
* Otherwise, you could end up with mangled output when the queued
|
|
* update starts writing to stream after a delay.
|
|
*/
|
|
flush(): Promise<void>;
|
|
/**
|
|
* Shows some text that is meant to be overriden later. Return the previous
|
|
* status that was shown and is no more. Calling `status()` with no argument
|
|
* removes the status altogether. The status is never shown in a
|
|
* non-interactive terminal: for example, if the output is redirected to a
|
|
* file, then we don't care too much about having a progress bar.
|
|
*/
|
|
status(format: string, ...args: Array<unknown>): string;
|
|
/**
|
|
* Similar to `console.log`, except it moves the status/progress text out of
|
|
* the way correctly. In non-interactive terminals this is the same as
|
|
* `console.log`.
|
|
*/
|
|
log(format: string, ...args: Array<unknown>): void;
|
|
/**
|
|
* Log the current status and start from scratch. This is useful if the last
|
|
* status was the last one of a series of updates.
|
|
*/
|
|
persistStatus(): void;
|
|
}
|
|
export default Terminal;
|