Files
unkernel/js/core/index.ts

101 lines
11 KiB
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
// The universal part of the SDK, re-exported by both entries (node.ts, web.ts).
export { IRQ_SYNC, Kernel, bundledBoot, moduleIsMemory64 } from "./kernel.ts";
export type { BootStage, ExitKind, ExitResult, KernelConfig, KernelStats, MemoryStage, NetDevice } from "./kernel.ts";
export { HOLD_CLOCK_LAG_MS, SNAPSHOT_COMMIT_TIMEOUT_MS, SnapshotCommitError, decodeSnapshot, encodeSnapshot, snapshotCpuMismatch, snapshotDeviceMismatch, snapshotDiskMismatch } from "./snapshot.ts";
export type { DeviceKind, DeviceSnapshots, KernelSnapshot, SnapshotHoldDecision, SnapshotOptions } from "./snapshot.ts";
export { BaseDisk, CowDisk, F_DISCARD, F_FLUSH, F_RO, F_WRITE_ZEROES, FlushTracker, HttpBase, readDistroHeader, SparseBase, ZERO_BLOCK, ZeroBase } from "./block.ts";
export type { BlockDevice, BlockStats, CowDiskOptions, CowDiskStats, DiskBase, DiskSnapshotState, DistroHeader, HttpBaseOptions, HttpBaseStats, MaybePromise, OverlayStore, StoreIndex } from "./block.ts";
export { DiskInUseError, OPFS_EXTENT, OpfsDisk } from "./opfs-disk.ts";
export type { OpfsDiskDir, OpfsDiskOptions, OpfsDiskStats, OpfsFormat, OpfsHeader, OpfsSyncFile } from "./opfs-disk.ts";
export { KWSPARSE_MAGIC, decodeKwsparse, encodeKwsparse, gunzipIfNeeded, gzipBlob, isZeroBlock, kwsparseHeader, readKwsparse } from "./kwsparse.ts";
export type { KwsparseImage } from "./kwsparse.ts";
export { NetStack, ip4, ip4str } from "./net.ts";
export type { NetBackend, NetConnection, NetConnectionEvents, NetStackOptions, NetStats, NetTunnel, NetTunnelResolver } from "./net.ts";
export { RemoteTunnel, TUNNEL_MTU } from "./net-tunnel.ts";
export type { NetTunnelConfig, NetTunnelStats } from "./net-tunnel.ts";
// Tailscale: types only here; the client is imported on demand (its own chunk).
export { createTailscaleClient, loadTailscale } from "./tailscale-load.ts";
export type { ControlState as TailscaleControlState, TailscaleClient, TailscaleClientOptions, TailscaleEvent, TailscaleExitNodeStatus, TailscaleExitStatus, TailscalePeerStatus, TailscaleRegionStatus, TailscaleState, TailscaleStats, TailscaleStatus } from "./tailscale/client.ts";
export { wispBackend } from "./net-wisp.ts";
export type { WispBackend, WispBackendOptions } from "./net-wisp.ts";
export { fetchRoutes } from "./net-fetch.ts";
export type { FetchRoute, FetchRoutesBackend, FetchRoutesOptions } from "./net-fetch.ts";
export { ANSI, ConsoleRouter, IMPORTANT, KSTAMP } from "./console.ts";
export type { ConsoleRouterOptions, KernelLineInfo } from "./console.ts";
export { checkJspi, checkSupport } from "./support.ts";
export type { SupportReport } from "./support.ts";
export { BootError, download, loadBytes, loadKernelModule } from "./load.ts";
export type { BootFailStage, BytesSource, DownloadProgress, KernelSource, LoadOptions } from "./load.ts";
export { JitHost, jitSimd } from "./jit.ts";
export { DEFAULT_DISPLAY_SIZE, DisplayHost, FOURCC_XRGB8888, frameToPpm, xrgbToRgba } from "./display.ts";
export type { DisplayFrame, DisplayHostOptions, DisplayMode, DisplayOption, DisplaySize, DisplayStats } from "./display.ts";
export { ABS_MAX, ABS_X, ABS_Y, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, DOM_CODE_TO_LINUX, EV_ABS, EV_KEY, EV_REL, EV_SYN, INPUT_KEYBOARD, INPUT_MOUSE, INPUT_TABLET, InputHost, REL_WHEEL, REL_X, REL_Y, domButtonToLinux, domCodeToLinux } from "./input.ts";
export type { Evdev, InputHostOptions, InputState, InputStats } from "./input.ts";
export { SOUND_FORMAT_S16_LE, SOUND_FORMAT_U8, SoundHost, convertPcm, floatToPcm, pcmToFloat32, wavHeader } from "./sound.ts";
export type { SoundChunk, SoundEvent, SoundFormat, SoundHostOptions, SoundInOption, SoundInStats, SoundOption, SoundSink, SoundSource, SoundState, SoundStats } from "./sound.ts";
export { CAPTURE_MAX_S, CAPTURE_TARGET_S, SoundInQueue, SoundInRingReader, SoundInRingWriter, createSoundInRing } from "./sound-in-ring.ts";
export { SoundRingReader, SoundRingWriter, createSoundRing } from "./sound-ring.ts";
export { CAMERA_MAX_FRAME_BYTES, CameraFrameStore, CameraFramesReader, CameraFramesWriter, CameraHost, cameraInitBits, createCameraFrames, patternSource } from "./camera.ts";
export type { CameraChunkSink, CameraFormat, CameraHostOptions, CameraOption, CameraSnapshot, CameraSource, CameraStats, CameraStoreStats, CameraStoredFrame, CameraVideoFrame, PatternSourceOptions } from "./camera.ts";
export { CAMERA_CODECS, CAMERA_FOURCC_H264, CAMERA_FOURCC_I420, CAMERA_FOURCC_NV12, CAMERA_FOURCC_YUYV, blackFrame, cameraCompressed, cameraFourcc, cameraFrameBytes, cameraPixelFormat, rgbaToI420, rgbaToNv12, rgbaToYuyv, testPattern, yuv420To } from "./camera-pixels.ts";
export type { CameraCodec, CameraPixelFormat, CameraStreamFormat, PlaneLayout } from "./camera-pixels.ts";
export { CHUNK_CLOCK, CHUNK_QUEUE_BYTES, CHUNK_QUEUE_MAX, CameraChunkQueue, ChunkGate, ChunkRingReader, ChunkRingWriter, createChunkRing } from "./camera-chunks.ts";
export type { ChunkCounts, ChunkRead } from "./camera-chunks.ts";
export { H264Pattern, H264_PROFILES, avccToAnnexB, h264Codec, h264Level, nalTypes, nalUnits, parameterSets, withParameterSets } from "./camera-h264.ts";
export type { H264PatternOptions, H264Profile } from "./camera-h264.ts";
export type { SoundRingRecord } from "./sound-ring.ts";
export type { JitHostOptions, JitStats, KwemuStats } from "./jit.ts";
export { PROFILE_ANON, PROFILE_UNKNOWN, formatProfile, symbolizeProfile } from "./profile.ts";
export type { ProfileCpu, ProfileFile, ProfileFileReader, ProfileOptions, ProfilePage, ProfileProcPage, ProfileReport, ProfileRow, ProfileSite, ProfileSymbol, ProfileTier, SamplerHandle, SamplerInit } from "./profile.ts";
export { KernelInstance } from "./instance.ts";
export type { BootProgress, CreateKernelOptions, InstanceStats, KernelHandle, VsockOption, WorkerOption } from "./instance.ts";
export { VSOCK_GUEST_CID, VSOCK_HEADER_SIZE, VSOCK_HOST_CID, VsockDevice, VsockError, VsockHost, decodeVsockHeader, encodeVsockPacket } from "./vsock.ts";
export type { Vsock, VsockConnection, VsockDeviceOptions, VsockDeviceStats, VsockHeader, VsockHostOptions, VsockListener, VsockStats } from "./vsock.ts";
export { PtyError, TTY_DETACH_TIMEOUT, TTY_FEATURE_CONNECT, TTY_FEATURE_DETACH, TTY_FEATURE_PIPES, TTY_FEATURE_USER, TTY_PORT, TTY_SIGNALS, TTY_VERSION, TtyFrameParser, attachPty, connectGuest, encodeTtyAttach, encodeTtyFrame, encodeTtyOpen, encodeTtyResize, execSubprocess, spawnPty, spawnSubprocess } from "./tty.ts";
export type { AttachOptions, ConnectOptions, ExecOptions, ExecResult, GuestSocket, PipeOptions, Pty, PtyEnd, PtyErrorCode, PtyOptions, PtySize, SpawnOptions, Subprocess, TtyFrame, TtySessionSnapshot } from "./tty.ts";
export { HTTP_MAX_HEADER_BYTES, fetchOver } from "./http.ts";
export type { ByteDuplex, GuestConnect } from "./http.ts";
export { FS_DEFAULT_OWNER, FsError } from "./fs.ts";
export type { Fs, FsAttr, FsDirEntry, FsFile, FsFileType, FsOpenFlags, FsSetAttr, FsStatFs } from "./fs.ts";
export { MemoryFs } from "./memfs.ts";
export type { FsTree, FsTreeFile, MemoryFsChange } from "./memfs.ts";
export { MountError } from "./mounts.ts";
export type { FsSource, Mount, MountErrorCode, MountOptions, MountSpec, MountStats, MountsOption } from "./mounts.ts";
export { CMD_PORT, CommandError } from "./commands.ts";
export { GL_FORWARDER, GL_PORT, GlHost } from "./gl.ts";
export type { GlOption, GlOptions, GlRendererStatus, GlStats, VirglTotals } from "./gl.ts";
export { VK_PORT, VkHost } from "./vk.ts";
export type { VkExternalRef, VkGpuAdapter, VkGpuDevice, VkOption, VkOptions, VkRendererStatus, VkStats } from "./vk.ts";
export { VA_PORT, VaHost } from "./va.ts";
export type { VaContextStats, VaOption, VaOptions, VaStats, VaStatus } from "./va.ts";
export { Deframer, MUX, StreamHost, frame } from "./gl-stream.ts";
export type { StreamHostStats, VtestRenderer } from "./gl-stream.ts";
export type { CommandErrorCode, CommandsOption, HostCommand, HostCommandContext, HostCommandResult } from "./commands.ts";
export { SHM_PAGE_SIZE, ShmClient, ShmDevice, ShmError, ShmInPlace, ShmShareServer, inlineShm } from "./shm.ts";
export type { InlineShmFile, Shm, ShmBackend, ShmCall, ShmCallResult, ShmCloseReason, ShmDeviceOptions, ShmDeviceStats, ShmFile, ShmInfo, ShmLocal, ShmPlace, ShmStats } from "./shm.ts";
export { FakeSerialBackend, IRQ_SERIAL, SERIAL_MAX_PORTS, SerialDevice, SerialHost, decodeSerialConfig, encodeSerialConfig } from "./serial.ts";
export type { FakeSerialCall, FakeSerialOptions, Serial, SerialBackend, SerialBackendInfo, SerialConfig, SerialDeviceOptions, SerialDeviceStats, SerialInputSignals, SerialOption, SerialOutputSignals, SerialPhase, SerialPortState, SerialSnapshot, SerialStats } from "./serial.ts";
export { BT_RX_WINDOW, BT_TX_WINDOW, BluetoothDevice, BluetoothHost, H4Framer, H4StreamController, IRQ_BT, h4Length } from "./bluetooth.ts";
export type { Bluetooth, BluetoothBus, BluetoothController, BluetoothDeviceOptions, BluetoothDeviceStats, BluetoothOption, BluetoothSink, BluetoothSnapshot, BluetoothState, BluetoothStats, ByteStream, H4StreamControllerOptions } from "./bluetooth.ts";
export { ATT_MTU, SCAN_REPEAT_MS, VirtualLeController, advertisingData, randomControllerAddress } from "./bluetooth-le.ts";
export type { VirtualLeActivity, VirtualLeOptions, VirtualLeStats } from "./bluetooth-le.ts";
export { FAKE_LOOPBACK_CHAR, FAKE_LOOPBACK_SERVICE, FakeGattCentral, GATT_PROP_BROADCAST, GATT_PROP_EXTENDED, GATT_PROP_INDICATE, GATT_PROP_NOTIFY, GATT_PROP_READ, GATT_PROP_SIGNED_WRITE, GATT_PROP_WRITE, GATT_PROP_WRITE_NO_RESPONSE, GattError, canonicalUuid, deviceAddress, fakeDemoPeripheral, formatAddress, parseAddress, shortUuid } from "./bluetooth-gatt.ts";
export type { FakeCharacteristic, FakeDescriptor, FakeGattCall, FakePeripheral, FakeService, GattCentral, GattCharacteristicInfo, GattConnection, GattDescriptorInfo, GattDeviceInfo, GattErrorKind, GattPath, GattServiceInfo } from "./bluetooth-gatt.ts";
export { IRQ_USB, USB_DEFAULT_PORTS, USB_MAX_PORTS, USB_PROTECTED_CLASSES, UsbDevice, UsbHost, deriveSpeed, filterConfig, parseConfig } from "./usb.ts";
export type { Usb, UsbAttachOptions, UsbBackend, UsbBackendInfo, UsbConfigInfo, UsbControlSetup, UsbDeviceKey, UsbDeviceStats, UsbEndpointInfo, UsbInResult, UsbIsoInResult, UsbIsoOutResult, UsbOption, UsbOutResult, UsbPhase, UsbPortState, UsbSnapshot, UsbSpeed, UsbStats, UsbTransferStatus } from "./usb.ts";
export { FakeUsbBackend } from "./usb-fake.ts";
export type { FakeUsbCall, FakeUsbOptions } from "./usb-fake.ts";
export { WorkerKernel } from "./worker-host.ts";
export type { WorkerKernelOptions } from "./worker-host.ts";
export { sharedMemoryAvailable } from "./worker-shared.ts";
export type { KernelTransport } from "./worker-shared.ts";
export { WASI_EXEC_PORT } from "./wasi-exec.ts";
export type { WasiExecOptions, WasiExecServer, WasiExecStats } from "./wasi-exec.ts";
export { DistroDisk, probeDistro } from "./distro.ts";
export type { DistroIndex, DistroIndexEntry, DistroInfo, DistroSource } from "./distro.ts";
export { DEVICE_SPEC_VERSION, isDiskSpec, isNetSpec } from "./devices.ts";
export type { DataDiskSpec, DiskSpec, DiskState, FileDiskSpec, HttpDiskSpec, NetBackendSpec, NetSpec, SkippedDisk, TailscaleSpec } from "./devices.ts";