Add QR codes to cards, stop inventing call number parts
Cards now carry a QR code holding the book's own record (call number, title, authors, ISBN, year), and the scanner reads it back to find or add that book. Call number selection no longer pads catalogue numbers with generated cutters. A number is "exact" only when it comes verbatim from a record for this edition; a bare class is a hint that steers the other-edition and similar-books lookups; a record fetched by LCCN must list the book's ISBN to count as this edition. "Look up again" bypasses every cached result, and shelf order breaks ties by author then title. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cec404e21
commit
ad2956e868
56 files changed
+4020
-156
No files matched your search
+15
-4
@@ -1,5 +1,5 @@
|
||||
import { prepareZXingModule } from 'zxing-wasm/reader';
|
||||
import { acceptRead, markEmitted, newReadState } from './readstate.ts';
|
||||
import { acceptCard, acceptRead, markCardEmitted, markEmitted, newReadState } from './readstate.ts';
|
||||
import { cropRect } from './frame.ts';
|
||||
import { decodeLive, decodeThorough, newLiveState, sharpness, wantsFull } from './decode.ts';
|
||||
import type { DecodeOutcome, Pixels } from './decode.ts';
|
||||
@@ -62,6 +62,8 @@ function nextFrame(video: HTMLVideoElement, fallbackMs: number): Promise<void> {
|
||||
export interface ScannerHandlers {
|
||||
/** A valid ISBN-13 was read (at most once per 5 seconds per book). */
|
||||
onIsbn(isbn13: string): void;
|
||||
/** A Booksorter card's QR code was read (at most once per 5 seconds per card). */
|
||||
onCard(text: string): void;
|
||||
/** A barcode was read that is not a book ISBN. */
|
||||
onOther(code: string): void;
|
||||
/** The camera stopped by itself (unplugged, taken by another program). */
|
||||
@@ -148,6 +150,11 @@ export async function startScanner(
|
||||
const r = await decodeLive(grab(video, c.x, c.y, c.w, c.h), live);
|
||||
live = r.state;
|
||||
if (stopped || burst) { /* a burst took over: drop this result */ } else {
|
||||
if (r.out.card) {
|
||||
const a = acceptCard(state, r.out.card, Date.now());
|
||||
state = a.state;
|
||||
if (a.emit) handlers.onCard(a.emit);
|
||||
}
|
||||
for (const code of [r.out.isbn, r.out.other]) {
|
||||
if (!code) continue;
|
||||
const a = acceptRead(state, code, Date.now());
|
||||
@@ -180,13 +187,17 @@ export async function startScanner(
|
||||
if (!best || score > best.score) best = { full, score };
|
||||
const out = await decodeThorough(crop, full);
|
||||
other ??= out.other;
|
||||
if (out.card) {
|
||||
state = markCardEmitted(state, out.card, Date.now());
|
||||
return { isbn: null, other, card: out.card, saved: null };
|
||||
}
|
||||
if (out.isbn) {
|
||||
state = markEmitted(state, out.isbn, Date.now());
|
||||
return { isbn: out.isbn, other, saved: null };
|
||||
return { isbn: out.isbn, other, card: null, saved: null };
|
||||
}
|
||||
}
|
||||
if (other) return { isbn: null, other, saved: null };
|
||||
return { isbn: null, other: null, saved: best ? await saveFailed(best.full) : null };
|
||||
if (other) return { isbn: null, other, card: null, saved: null };
|
||||
return { isbn: null, other: null, card: null, saved: best ? await saveFailed(best.full) : null };
|
||||
} finally {
|
||||
burst = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user