mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 21:10:25 +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:
@@ -7,6 +7,7 @@ import type { ChannelId, ChannelPairingAdapter } from "../channels/plugins/types
|
||||
import { getPairingAdapter } from "../channels/plugins/pairing.js";
|
||||
import { resolveOAuthDir, resolveStateDir } from "../config/paths.js";
|
||||
import { resolveRequiredHomeDir } from "../infra/home-dir.js";
|
||||
import { safeParseJson } from "../utils.js";
|
||||
|
||||
const PAIRING_CODE_LENGTH = 8;
|
||||
const PAIRING_CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
||||
@@ -72,14 +73,6 @@ function resolveAllowFromPath(
|
||||
return path.join(resolveCredentialsDir(env), `${safeChannelKey(channel)}-allowFrom.json`);
|
||||
}
|
||||
|
||||
function safeParseJson<T>(raw: string): T | null {
|
||||
try {
|
||||
return JSON.parse(raw) as T;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function readJsonFile<T>(
|
||||
filePath: string,
|
||||
fallback: T,
|
||||
|
||||
Reference in New Issue
Block a user