chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -21,9 +21,7 @@ const parseFacing = (value: string): CameraFacing => {
|
||||
};
|
||||
|
||||
export function registerNodesCameraCommands(nodes: Command) {
|
||||
const camera = nodes
|
||||
.command("camera")
|
||||
.description("Capture camera media from a paired node");
|
||||
const camera = nodes.command("camera").description("Capture camera media from a paired node");
|
||||
|
||||
nodesCallOpts(
|
||||
camera
|
||||
@@ -40,10 +38,7 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
idempotencyKey: randomIdempotencyKey(),
|
||||
})) as unknown;
|
||||
|
||||
const res =
|
||||
typeof raw === "object" && raw !== null
|
||||
? (raw as { payload?: unknown })
|
||||
: {};
|
||||
const res = typeof raw === "object" && raw !== null ? (raw as { payload?: unknown }) : {};
|
||||
const payload =
|
||||
typeof res.payload === "object" && res.payload !== null
|
||||
? (res.payload as { devices?: unknown })
|
||||
@@ -62,12 +57,8 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
|
||||
for (const device of devices) {
|
||||
const id = typeof device.id === "string" ? device.id : "";
|
||||
const name =
|
||||
typeof device.name === "string" ? device.name : "Unknown Camera";
|
||||
const position =
|
||||
typeof device.position === "string"
|
||||
? device.position
|
||||
: "unspecified";
|
||||
const name = typeof device.name === "string" ? device.name : "Unknown Camera";
|
||||
const position = typeof device.position === "string" ? device.position : "unspecified";
|
||||
defaultRuntime.log(`${name} (${position})${id ? ` — ${id}` : ""}`);
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -87,15 +78,8 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
.option("--device-id <id>", "Camera device id (from nodes camera list)")
|
||||
.option("--max-width <px>", "Max width in px (optional)")
|
||||
.option("--quality <0-1>", "JPEG quality (default 0.9)")
|
||||
.option(
|
||||
"--delay-ms <ms>",
|
||||
"Delay before capture in ms (macOS default 2000)",
|
||||
)
|
||||
.option(
|
||||
"--invoke-timeout <ms>",
|
||||
"Node invoke timeout in ms (default 20000)",
|
||||
"20000",
|
||||
)
|
||||
.option("--delay-ms <ms>", "Delay before capture in ms (macOS default 2000)")
|
||||
.option("--invoke-timeout <ms>", "Node invoke timeout in ms (default 20000)", "20000")
|
||||
.action(async (opts: NodesRpcOpts) => {
|
||||
try {
|
||||
const nodeId = await resolveNodeId(opts, String(opts.node ?? ""));
|
||||
@@ -113,18 +97,10 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
);
|
||||
})();
|
||||
|
||||
const maxWidth = opts.maxWidth
|
||||
? Number.parseInt(String(opts.maxWidth), 10)
|
||||
: undefined;
|
||||
const quality = opts.quality
|
||||
? Number.parseFloat(String(opts.quality))
|
||||
: undefined;
|
||||
const delayMs = opts.delayMs
|
||||
? Number.parseInt(String(opts.delayMs), 10)
|
||||
: undefined;
|
||||
const deviceId = opts.deviceId
|
||||
? String(opts.deviceId).trim()
|
||||
: undefined;
|
||||
const maxWidth = opts.maxWidth ? Number.parseInt(String(opts.maxWidth), 10) : undefined;
|
||||
const quality = opts.quality ? Number.parseFloat(String(opts.quality)) : undefined;
|
||||
const delayMs = opts.delayMs ? Number.parseInt(String(opts.delayMs), 10) : undefined;
|
||||
const deviceId = opts.deviceId ? String(opts.deviceId).trim() : undefined;
|
||||
const timeoutMs = opts.invokeTimeout
|
||||
? Number.parseInt(String(opts.invokeTimeout), 10)
|
||||
: undefined;
|
||||
@@ -154,15 +130,9 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
invokeParams.timeoutMs = timeoutMs;
|
||||
}
|
||||
|
||||
const raw = (await callGatewayCli(
|
||||
"node.invoke",
|
||||
opts,
|
||||
invokeParams,
|
||||
)) as unknown;
|
||||
const raw = (await callGatewayCli("node.invoke", opts, invokeParams)) as unknown;
|
||||
const res =
|
||||
typeof raw === "object" && raw !== null
|
||||
? (raw as { payload?: unknown })
|
||||
: {};
|
||||
typeof raw === "object" && raw !== null ? (raw as { payload?: unknown }) : {};
|
||||
const payload = parseCameraSnapPayload(res.payload);
|
||||
const filePath = cameraTempPath({
|
||||
kind: "snap",
|
||||
@@ -194,9 +164,7 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
nodesCallOpts(
|
||||
camera
|
||||
.command("clip")
|
||||
.description(
|
||||
"Capture a short video clip from a node camera (prints MEDIA:<path>)",
|
||||
)
|
||||
.description("Capture a short video clip from a node camera (prints MEDIA:<path>)")
|
||||
.requiredOption("--node <idOrNameOrIp>", "Node id, name, or IP")
|
||||
.option("--facing <front|back>", "Camera facing", "front")
|
||||
.option("--device-id <id>", "Camera device id (from nodes camera list)")
|
||||
@@ -206,11 +174,7 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
"3000",
|
||||
)
|
||||
.option("--no-audio", "Disable audio capture")
|
||||
.option(
|
||||
"--invoke-timeout <ms>",
|
||||
"Node invoke timeout in ms (default 90000)",
|
||||
"90000",
|
||||
)
|
||||
.option("--invoke-timeout <ms>", "Node invoke timeout in ms (default 90000)", "90000")
|
||||
.action(async (opts: NodesRpcOpts & { audio?: boolean }) => {
|
||||
try {
|
||||
const nodeId = await resolveNodeId(opts, String(opts.node ?? ""));
|
||||
@@ -220,9 +184,7 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
const timeoutMs = opts.invokeTimeout
|
||||
? Number.parseInt(String(opts.invokeTimeout), 10)
|
||||
: undefined;
|
||||
const deviceId = opts.deviceId
|
||||
? String(opts.deviceId).trim()
|
||||
: undefined;
|
||||
const deviceId = opts.deviceId ? String(opts.deviceId).trim() : undefined;
|
||||
|
||||
const invokeParams: Record<string, unknown> = {
|
||||
nodeId,
|
||||
@@ -240,15 +202,8 @@ export function registerNodesCameraCommands(nodes: Command) {
|
||||
invokeParams.timeoutMs = timeoutMs;
|
||||
}
|
||||
|
||||
const raw = (await callGatewayCli(
|
||||
"node.invoke",
|
||||
opts,
|
||||
invokeParams,
|
||||
)) as unknown;
|
||||
const res =
|
||||
typeof raw === "object" && raw !== null
|
||||
? (raw as { payload?: unknown })
|
||||
: {};
|
||||
const raw = (await callGatewayCli("node.invoke", opts, invokeParams)) as unknown;
|
||||
const res = typeof raw === "object" && raw !== null ? (raw as { payload?: unknown }) : {};
|
||||
const payload = parseCameraClipPayload(res.payload);
|
||||
const filePath = cameraTempPath({
|
||||
kind: "clip",
|
||||
|
||||
Reference in New Issue
Block a user