mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
refactor: consolidate PNG encoder and safeParseJson utilities (#12457)
- Create shared PNG encoder module (src/media/png-encode.ts) - Refactor qr-image.ts and live-image-probe.ts to use shared encoder - Add safeParseJson to utils.ts and plugin-sdk exports - Update msteams and pairing-store to use centralized safeParseJson
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { safeParseJson } from "openclaw/plugin-sdk";
|
||||
import lockfile from "proper-lockfile";
|
||||
|
||||
const STORE_LOCK_OPTIONS = {
|
||||
@@ -14,14 +15,6 @@ const STORE_LOCK_OPTIONS = {
|
||||
stale: 30_000,
|
||||
} as const;
|
||||
|
||||
function safeParseJson<T>(raw: string): T | null {
|
||||
try {
|
||||
return JSON.parse(raw) as T;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function readJsonFile<T>(
|
||||
filePath: string,
|
||||
fallback: T,
|
||||
|
||||
Reference in New Issue
Block a user