import { buildTscLabelData, buildTscTestPrintData } from '../protocols/tscProtocol' import type { PrinterCandidate, PrinterDriver } from '../types/printer' const KEYWORDS = [ 'd320fx', 'gp-d320fx', ] function score (device: PrinterCandidate): number { const text = `${device.name || ''} ${device.deviceId || ''}`.toLowerCase() let total = 0 KEYWORDS.forEach((keyword) => { if (text.includes(keyword)) total += 80 }) if (text.includes('gprinter')) total += 10 return total } export const gpD320fxDriver: PrinterDriver = { key: 'gp-d320fx', brand: 'Gprinter', model: 'GP-D320FX', displayName: 'Gprinter GP-D320FX', protocol: 'tsc', preferredConnection: 'ble', preferredBleMtu: 512, imageMaxWidthDots: 800, imageDpi: 203, keywords: KEYWORDS, matches (device) { return score(device) }, resolveConnectionType (device) { return device.type === 'classic' ? 'classic' : 'ble' }, buildTestPrintData () { return buildTscTestPrintData() }, buildLabelData (payload) { return buildTscLabelData(payload) }, }