Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/Fonts/FontManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function AddFontForm({ onDone }: AddFontFormProps) {
await loadFontFile(file, printerName);
onDone();
} catch {
// Inline hint is the only signal (non-TTF/OTF, oversized, FileReader
// failure). Codebase has no production logging path; specific causes
// are debugged with a devtools breakpoint on this catch.
setUploadFailed(true);
} finally {
setUploading(false);
Expand Down
1 change: 1 addition & 0 deletions src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const ar = {
selectImage: 'اختر صورة…',
upload: 'رفع صورة',
uploading: 'جارٍ الرفع…',
uploadError: 'تعذر تحميل الصورة',
preview: 'معاينة',
widthDots: 'العرض (نقاط)',
threshold: 'عتبة أحادية',
Expand Down
1 change: 1 addition & 0 deletions src/locales/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const bg = {
selectImage: 'Изберете изображение…',
upload: 'Качване на изображение',
uploading: 'Качване…',
uploadError: 'Изображението не може да бъде заредено',
preview: 'Преглед',
widthDots: 'Ширина (точки)',
threshold: 'Моно праг',
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const cs = {
selectImage: 'Vybrat obrázek…',
upload: 'Nahrát obrázek',
uploading: 'Nahrávání…',
uploadError: 'Obrázek nelze načíst',
preview: 'Náhled',
widthDots: 'Šířka (body)',
threshold: 'Mono práh',
Expand Down
1 change: 1 addition & 0 deletions src/locales/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const da = {
selectImage: 'Vælg billede…',
upload: 'Upload billede',
uploading: 'Uploader…',
uploadError: 'Kunne ikke indlæse billede',
preview: 'Forhåndsvisning',
widthDots: 'Bredde (punkter)',
threshold: 'Mono-tærskel',
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ const de = {
selectImage: 'Bild auswählen…',
upload: 'Bild hochladen',
uploading: 'Hochladen…',
uploadError: 'Bild konnte nicht geladen werden',
preview: 'Vorschau',
widthDots: 'Breite (Punkte)',
threshold: 'Mono-Schwellenwert',
Expand Down
1 change: 1 addition & 0 deletions src/locales/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const el = {
selectImage: 'Επιλογή εικόνας…',
upload: 'Μεταφόρτωση εικόνας',
uploading: 'Μεταφόρτωση…',
uploadError: 'Αδυναμία φόρτωσης εικόνας',
preview: 'Προεπισκόπηση',
widthDots: 'Πλάτος (κουκκίδες)',
threshold: 'Κατώφλι mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ const en = {
selectImage: 'Select image…',
upload: 'Upload image',
uploading: 'Uploading…',
uploadError: 'Could not load image',
preview: 'Preview',
widthDots: 'Width (dots)',
threshold: 'Mono threshold',
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const es = {
selectImage: 'Seleccionar imagen…',
upload: 'Subir imagen',
uploading: 'Subiendo…',
uploadError: 'No se pudo cargar la imagen',
preview: 'Vista previa',
widthDots: 'Ancho (puntos)',
threshold: 'Umbral mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const et = {
selectImage: 'Vali pilt…',
upload: 'Laadi pilt üles',
uploading: 'Üleslaadimine…',
uploadError: 'Pildi laadimine ebaõnnestus',
preview: 'Eelvaade',
widthDots: 'Laius (punktid)',
threshold: 'Mono lävi',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const fa = {
selectImage: 'انتخاب تصویر…',
upload: 'بارگذاری تصویر',
uploading: 'در حال بارگذاری…',
uploadError: 'بارگذاری تصویر ممکن نشد',
preview: 'پیش‌نمایش',
widthDots: 'عرض (نقاط)',
threshold: 'آستانه تک‌رنگ',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const fi = {
selectImage: 'Valitse kuva…',
upload: 'Lataa kuva',
uploading: 'Ladataan…',
uploadError: 'Kuvaa ei voitu ladata',
preview: 'Esikatselu',
widthDots: 'Leveys (pisteet)',
threshold: 'Mono-kynnys',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const fr = {
selectImage: 'Sélectionner une image…',
upload: 'Télécharger une image',
uploading: 'Téléchargement…',
uploadError: 'Impossible de charger l\'image',
preview: 'Aperçu',
widthDots: 'Largeur (points)',
threshold: 'Seuil mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const he = {
selectImage: 'בחר תמונה…',
upload: 'העלאת תמונה',
uploading: 'מעלה…',
uploadError: 'לא ניתן לטעון את התמונה',
preview: 'תצוגה מקדימה',
widthDots: 'רוחב (נקודות)',
threshold: 'סף מונו',
Expand Down
1 change: 1 addition & 0 deletions src/locales/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const hr = {
selectImage: 'Odaberite sliku…',
upload: 'Prenesi sliku',
uploading: 'Prenošenje…',
uploadError: 'Sliku nije moguće učitati',
preview: 'Pregled',
widthDots: 'Širina (točke)',
threshold: 'Mono prag',
Expand Down
1 change: 1 addition & 0 deletions src/locales/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const hu = {
selectImage: 'Kép kiválasztása…',
upload: 'Kép feltöltése',
uploading: 'Feltöltés…',
uploadError: 'A kép nem tölthető be',
preview: 'Előnézet',
widthDots: 'Szélesség (pont)',
threshold: 'Mono küszöb',
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const it = {
selectImage: 'Seleziona immagine…',
upload: 'Carica immagine',
uploading: 'Caricamento…',
uploadError: 'Impossibile caricare l\'immagine',
preview: 'Anteprima',
widthDots: 'Larghezza (punti)',
threshold: 'Soglia mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const ja = {
selectImage: '画像を選択…',
upload: '画像をアップロード',
uploading: 'アップロード中…',
uploadError: '画像を読み込めませんでした',
preview: 'プレビュー',
widthDots: '幅(ドット)',
threshold: 'モノクロしきい値',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const ko = {
selectImage: '이미지 선택…',
upload: '이미지 업로드',
uploading: '업로드 중…',
uploadError: '이미지를 불러올 수 없습니다',
preview: '미리보기',
widthDots: '너비 (도트)',
threshold: '모노 임계값',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const lt = {
selectImage: 'Pasirinkite vaizdą…',
upload: 'Įkelti vaizdą',
uploading: 'Įkeliama…',
uploadError: 'Nepavyko įkelti vaizdo',
preview: 'Peržiūra',
widthDots: 'Plotis (taškai)',
threshold: 'Mono slenkstis',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const lv = {
selectImage: 'Izvēlēties attēlu…',
upload: 'Augšupielādēt attēlu',
uploading: 'Augšupielāde…',
uploadError: 'Neizdevās ielādēt attēlu',
preview: 'Priekšskatījums',
widthDots: 'Platums (punkti)',
threshold: 'Mono slieksnis',
Expand Down
1 change: 1 addition & 0 deletions src/locales/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const nl = {
selectImage: 'Afbeelding selecteren…',
upload: 'Afbeelding uploaden',
uploading: 'Uploaden…',
uploadError: 'Kon afbeelding niet laden',
preview: 'Voorbeeld',
widthDots: 'Breedte (punten)',
threshold: 'Mono-drempelwaarde',
Expand Down
1 change: 1 addition & 0 deletions src/locales/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const no = {
selectImage: 'Velg bilde…',
upload: 'Last opp bilde',
uploading: 'Laster opp…',
uploadError: 'Kunne ikke laste bilde',
preview: 'Forhåndsvisning',
widthDots: 'Bredde (punkter)',
threshold: 'Mono-terskel',
Expand Down
1 change: 1 addition & 0 deletions src/locales/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const pl = {
selectImage: 'Wybierz obraz…',
upload: 'Prześlij obraz',
uploading: 'Przesyłanie…',
uploadError: 'Nie można załadować obrazu',
preview: 'Podgląd',
widthDots: 'Szerokość (punkty)',
threshold: 'Próg mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const pt = {
selectImage: 'Selecionar imagem…',
upload: 'Carregar imagem',
uploading: 'Carregando…',
uploadError: 'Não foi possível carregar a imagem',
preview: 'Pré-visualização',
widthDots: 'Largura (pontos)',
threshold: 'Limiar mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const ro = {
selectImage: 'Selectați imaginea…',
upload: 'Încărcați imaginea',
uploading: 'Se încarcă…',
uploadError: 'Imaginea nu a putut fi încărcată',
preview: 'Previzualizare',
widthDots: 'Lățime (puncte)',
threshold: 'Prag mono',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const sk = {
selectImage: 'Vybrať obrázok…',
upload: 'Nahrať obrázok',
uploading: 'Nahrávanie…',
uploadError: 'Obrázok sa nedá načítať',
preview: 'Náhľad',
widthDots: 'Šírka (body)',
threshold: 'Mono prah',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const sl = {
selectImage: 'Izberite sliko…',
upload: 'Naloži sliko',
uploading: 'Nalaganje…',
uploadError: 'Slike ni bilo mogoče naložiti',
preview: 'Predogled',
widthDots: 'Širina (pike)',
threshold: 'Mono prag',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const sr = {
selectImage: 'Изаберите слику…',
upload: 'Отпремите слику',
uploading: 'Отпремање…',
uploadError: 'Слика није могла да се учита',
preview: 'Преглед',
widthDots: 'Ширина (тачке)',
threshold: 'Моно праг',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const sv = {
selectImage: 'Välj bild…',
upload: 'Ladda upp bild',
uploading: 'Laddar upp…',
uploadError: 'Kunde inte ladda bilden',
preview: 'Förhandsvisning',
widthDots: 'Bredd (punkter)',
threshold: 'Mono-tröskel',
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const tr = {
selectImage: 'Görsel seçin…',
upload: 'Görsel yükle',
uploading: 'Yükleniyor…',
uploadError: 'Görsel yüklenemedi',
preview: 'Önizleme',
widthDots: 'Genişlik (nokta)',
threshold: 'Mono eşik',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const zhHans = {
selectImage: '选择图片…',
upload: '上传图片',
uploading: '上传中…',
uploadError: '无法加载图像',
preview: '预览',
widthDots: '宽度(点)',
threshold: '单色阈值',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const zhHant = {
selectImage: '選擇圖片…',
upload: '上傳圖片',
uploading: '上傳中…',
uploadError: '無法載入圖片',
preview: '預覽',
widthDots: '寬度(點)',
threshold: '單色閾值',
Expand Down
11 changes: 11 additions & 0 deletions src/registry/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,25 @@ export const image: ObjectTypeDefinition<ImageProps> = {
const p = obj.props;
const fileRef = useRef<HTMLInputElement>(null);
const [uploading, setUploading] = useState(false);
const [uploadFailed, setUploadFailed] = useState(false);

const cached = getImage(p.imageId);
const allImages = getAllImages();

const handleUpload = useCallback(async (file: File) => {
setUploading(true);
setUploadFailed(false);
try {
const entry = await loadImageFile(file);
// Pre-generate GFA cache
const result = await imageToGFA(entry.dataUrl, p.widthDots, p.threshold);
onChange({ imageId: entry.id, _gfaCache: result.zpl });
} catch {
// Surface the failure inline (non-image MIME, oversized file, decode
// error, GFA exception) and stop. The codebase has no production
// logging path; debugging specific causes (e.g. an obscure MIME) is
// done with a devtools breakpoint on this catch.
setUploadFailed(true);
Comment on lines +103 to +108
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment mentions that the error is already in the console, but catching it without re-throwing or logging it actually prevents it from appearing there (as it is no longer an unhandled rejection). It is best to explicitly log the error to aid in debugging issues like invalid image formats or conversion failures.

      } catch (err) {
        // loadImageFile rejects on non-image MIME, oversized files, decode
        // failures; imageToGFA can also throw. Surface a single inline hint
        // (mirrors FontManager) — we log the error to the console for debugging.
        console.error(err);
        setUploadFailed(true);
      }

} finally {
setUploading(false);
}
Expand Down Expand Up @@ -160,6 +168,9 @@ export const image: ObjectTypeDefinition<ImageProps> = {
>
{uploading ? t.registry.image.uploading : t.registry.image.upload}
</button>
{uploadFailed && (
<p className="text-[10px] font-mono text-red-400">{t.registry.image.uploadError}</p>
)}
</div>

{/* Preview thumbnail */}
Expand Down