chore: initialize repository baseline
Import the existing Electron + React + TypeScript app as the version-control baseline before the scanner rework (C# input/capture sidecar, resolution-anchored layout profiles, OCR preprocessing, eval harness, rescan-merge, GOOD interop). Housekeeping in this commit: - Remove orphaned temp_inputhelper_block.ts (duplicate of the input-helper script). - Ignore .claude/scheduled_tasks.lock local session state. - Add .gitattributes to normalize line endings (LF in repo). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { useCallback, type MouseEvent } from "react";
|
||||
import type { ScanDetailsModalProps } from "../types";
|
||||
import type { ParsedArtifactCandidate } from "../../../../lib/artifactOcrParser";
|
||||
|
||||
export interface ScanDetailsModalModel {
|
||||
closeDetails: () => void;
|
||||
stopPropagation: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
parsedNotes: string[];
|
||||
showParsedNotes: boolean;
|
||||
cropRows: Array<{ id: string; dataUrl: string; label: string; x: number; y: number; width: number; height: number }>;
|
||||
ocrRows: Array<{ id: string; label: string; confidence: number; text: string }>;
|
||||
debugText: string;
|
||||
showCrops: boolean;
|
||||
showOcr: boolean;
|
||||
}
|
||||
|
||||
interface UseScanDetailsModalModelInput {
|
||||
setDetailsOpen: ScanDetailsModalProps["setDetailsOpen"];
|
||||
parsedArtifact: ScanDetailsModalProps["controller"]["parsedArtifact"];
|
||||
latestCapture: ScanDetailsModalProps["latestCapture"];
|
||||
}
|
||||
|
||||
export function useScanDetailsModalModel({
|
||||
setDetailsOpen,
|
||||
parsedArtifact,
|
||||
latestCapture,
|
||||
}: UseScanDetailsModalModelInput): ScanDetailsModalModel {
|
||||
const closeDetails = useCallback(() => setDetailsOpen(false), [setDetailsOpen]);
|
||||
const stopPropagation = useCallback((event: MouseEvent<HTMLDivElement>) => {
|
||||
event.stopPropagation();
|
||||
}, []);
|
||||
const parsedNotes = (parsedArtifact?.notes ?? []) as ParsedArtifactCandidate["notes"];
|
||||
|
||||
const crops = latestCapture?.crops ?? [];
|
||||
const ocr = latestCapture?.ocr ?? [];
|
||||
|
||||
return {
|
||||
closeDetails,
|
||||
stopPropagation,
|
||||
parsedNotes,
|
||||
showParsedNotes: parsedNotes.length > 0,
|
||||
cropRows: crops.map((crop) => ({
|
||||
id: crop.id,
|
||||
dataUrl: crop.dataUrl,
|
||||
label: crop.label,
|
||||
x: crop.rect.x,
|
||||
y: crop.rect.y,
|
||||
width: crop.rect.width,
|
||||
height: crop.rect.height,
|
||||
})),
|
||||
ocrRows: ocr.map((entry) => ({
|
||||
id: entry.id,
|
||||
label: entry.label,
|
||||
confidence: entry.confidence,
|
||||
text: entry.text || "No text detected",
|
||||
})),
|
||||
debugText: `Debug: crops ${crops.length} / ocr ${ocr.length}`,
|
||||
showCrops: crops.length > 0,
|
||||
showOcr: ocr.length > 0,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user