import { ChildProcess } from "child_process" ; import * as Immutable from "immutable" ; import { Observable , Subject } from "rxjs" ; import { KernelId , SessionId } from "../ids" ; import { HostRef , KernelRef } from "../refs" ; import { KernelInfo } from "./kernel-info" ; export interface KernelNotStartedProps { kernelSpecName ? : string | null ; status ? : string | null ; type : "unknown" ; cwd : "." ; channels : Subject < any > ; info ? : KernelInfo | null ; } export type KernelNotStartedRecord = Immutable . RecordOf < KernelNotStartedProps > ; export const makeKernelNotStartedRecord = Immutable . Record < KernelNotStartedProps > ( { kernelSpecName : null , status : null , type : "unknown" , cwd : "." , channels : new Subject ( ) , info : null } ) ; export enum KernelStatus { /** Kernel is currently executing code. */ Busy = "busy" , /** Kernel is currently not executing code. */ Idle = "idle" , /** Kernel process is being launched. */ Starting = "starting" , /** Kernel is being shut down. */ ShuttingDown = "shutting down" , /** Kernel is restarting. */ Restarting = "restarting" , /** Kernel's current execution process has been interrupted. */ Interrupted = "interrupted" , /** Kernel is not connected to current notebook. */ NotConnected = "not connected" , /** 0mq-based kernel is launched. */ Launched = "launched" , /** 0mq-based kernel is killed. */ Killed = "killed" , /** Kernel is in an failed or error state. */ Error = "error" } export interface LocalKernelProps { kernelSpecName ? : string | null ; info ? : KernelInfo | null ; hostRef ? : HostRef | null ; lastActivity ? : Date | null ; channels : Subject < any > ; cwd : string ; status ? : string | null ; type : "zeromq" ; spawn ? : ChildProcess | null ; connectionFile ? : string | null ; } export const makeLocalKernelRecord = Immutable . Record < LocalKernelProps > ( { type : "zeromq" , cwd : "." , info : null , kernelSpecName : null , hostRef : null , lastActivity : null , channels : new Subject ( ) , status : null , spawn : null , connectionFile : null } ) ; export type LocalKernelRecord = Immutable . RecordOf < LocalKernelProps > ; export interface RemoteKernelProps { kernelSpecName ? : string | null ; info ? : KernelInfo | null ; hostRef ? : HostRef | null ; lastActivity ? : Date | null ; channels : Subject < any > ; cwd : string ; status ? : string | null ; type : "websocket" ; sessionId ? : SessionId | null ; remoteSessionId ? : SessionId | null ; id ? : KernelId | null ; } export const makeRemoteKernelRecord = Immutable . Record < RemoteKernelProps > ( { type : "websocket" , info : null , cwd : "." , id : null , kernelSpecName : null , hostRef : null , lastActivity : null , channels : new Subject ( ) , sessionId : null , remoteSessionId : null , status : null } ) ; export type RemoteKernelRecord = Immutable . RecordOf < RemoteKernelProps > ; export type KernelRecord = KernelNotStartedRecord | LocalKernelRecord | RemoteKernelRecord ; export interface KernelsRecordProps { byRef : Immutable . Map < KernelRef , KernelRecord > ; } export const makeKernelsRecord = Immutable . Record < KernelsRecordProps > ( { byRef : Immutable . Map ( ) } ) ;