Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 17x 17x 17x 17x | import { wsMessageSchema, type WSMessage, type ParserMessage, type IOPinRecord } from "@shared/schema";
export type IncomingArduinoMessage = WSMessage;
export type SerialPayload = Extract<WSMessage, { type: "serial_output" }>;
export type CompilationStatusPayload = Extract<WSMessage, { type: "compilation_status" }>;
export type CompilationErrorPayload = Extract<WSMessage, { type: "compilation_error" }>;
export type SimulationStatusPayload = Extract<WSMessage, { type: "simulation_status" }>;
export type PinStatePayload = Extract<WSMessage, { type: "pin_state" }>;
export type PinStateBatchPayload = Extract<WSMessage, { type: "pin_state_batch" }>;
export type IoRegistryPayload = Extract<WSMessage, { type: "io_registry" }>;
export type SimTelemetryPayload = Extract<WSMessage, { type: "sim_telemetry" }>;
/**
* Type-guard for incoming socket messages.
*
* Useful when parsing untyped JSON from the WebSocket.
*/
export interface CompilerError {
file: string;
line: number;
column: number;
type: "error" | "warning";
message: string;
}
export interface CompileConfig {
code: string;
headers?: Array<{ name: string; content: string }>;
fqbn?: string;
libraries?: string[];
}
export interface HexResult {
success: boolean;
raw?: string;
error?: string;
}
export interface CompileResult {
success: boolean;
output?: string;
stderr?: string;
errors?: CompilerError[] | string;
raw?: string;
parserMessages?: ParserMessage[];
ioRegistry?: IOPinRecord[];
arduinoCliStatus?: "idle" | "compiling" | "success" | "error";
cached?: boolean;
}
export function isArduinoMessage(value: unknown): value is WSMessage {
return wsMessageSchema.safeParse(value).success;
}
// Helper to check if value is an object with a success boolean property
function hasSuccessProperty(value: unknown): boolean {
return (
typeof value === "object" &&
value !== null &&
(() => {
const maybe = value as { success?: unknown };
return typeof maybe.success === "boolean";
})()
);
}
export function isHexResult(value: unknown): value is HexResult {
return hasSuccessProperty(value);
}
export function isCompileResult(value: unknown): value is CompileResult {
return hasSuccessProperty(value);
}
|