Class DaemonClient

Client that can perform various tasks with the TSIMP Daemon process.

Hierarchy

Constructors

  • Parameters

    • Optional__namedParameters: SockDaemonClientOptions

    Returns DaemonClient

Accessors

  • get connected(): boolean
  • True if currently connected to the daemon service

    Returns boolean

  • get connection(): undefined | Socket
  • True if the client is currently connected

    Returns undefined | Socket

  • get execArgv(): string[]
  • The execArgv that is used when spawning the daemon script.

    Returns string[]

  • get logFile(): string
  • Path where daemon logs are written

    Returns string

  • get mtimeFile(): string
  • Path where the daemonScript mtime is written

    Returns string

  • get path(): string
  • The folder where this daemon service stores stuff

    Returns string

  • get pidFile(): string
  • File containing the daemon process ID

    Returns string

  • get requests(): ClientRequest<Request, Response>[]
  • List of current pending requests

    Returns ClientRequest<Request, Response>[]

  • get socket(): string
  • Path to the socket used by this service

    Returns string

  • get daemonScript(): string
  • Path to the script that is the daemon program for node to run on demand in the background.

    Returns string

  • get serviceName(): "tsimp"
  • Always 'tsimp'. Used by SockDaemon to know where to put stuff.

    Returns "tsimp"

Methods

  • Drop all pending requests

    Returns void

  • Compile the code contained in inputFile.

    Return the fileName that the resulting JS was written to, and a string[] of diagnostics.

    Parameters

    • inputFile: string
    • diagMode: DiagMode = ...
    • pretty: boolean = !!process.stderr.isTTY

    Returns Promise<CompileResult>

  • Immediately disconnect from the server. Pending requests will be replayed on the next connection, unless clear() is called.

    Returns void

  • Returns true if the object is a MessageBase

    Parameters

    • msg: any

    Returns msg is MessageBase

  • Kill the server, if it is running.

    Attempts to send a SIGHUP to allow for graceful shutdown, but this is not possible on Windows.

    Returns Promise<void>

  • Send a PING message to the server. This can be useful when you want to start the daemon, without making any specific request.

    Returns Promise<Omit<Ping, "PING"> & {
        pid: number;
        PING: "PONG";
    } & {
        duration: number;
    }>

  • Explicitly start up the language service, used for type checking

    This is a slow operation, but it's somewhat rare that you'd need to do this explicitly, since it's done on demand when needed. Mostly this is for testing purposes.

    Parameters

    Returns Promise<PreloadResult>

  • Send a request. The id property is made optional, because it will be overridden anyway by a generated message ID. Starts the daemon script automatically if not already running, and connects if needed.

    If an AbortSignal is provided, then the request will be dropped on an abort signal, and the promise rejected with the abort reason, if it has not already been resolved.

    Parameters

    • msg: Omit<Ping, "id">
    • Optionalsignal: AbortSignal

    Returns Promise<Omit<Ping, "PING"> & {
        pid: number;
        PING: "PONG";
    } & {
        duration: number;
    }>

  • Parameters

    Returns Promise<ServiceCompileResult | ServiceResolveResult>

  • Translate a module identifier like ./src/foo.js into file:///path/to/src/foo.ts A file that isn't .ts or isn't a file:// url is returned as-is.

    Parameters

    • url: string
    • OptionalparentURL: string

    Returns Promise<string>