80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import { WebPlugin } from '@capacitor/core';
|
|
import type {
|
|
PrinterPlugin,
|
|
PrinterDevice,
|
|
NetworkPrinter,
|
|
UsbConnectionResult,
|
|
BluetoothPrintOptions,
|
|
NetworkPrintOptions,
|
|
UsbPrintOptions,
|
|
PermissionResult,
|
|
PrinterStatusOptions,
|
|
PrinterStatusResult
|
|
} from './definitions';
|
|
|
|
export class PrinterWeb extends WebPlugin implements PrinterPlugin {
|
|
async scanBluetooth(): Promise<{ devices: PrinterDevice[] }> {
|
|
console.warn('Bluetooth not available on web');
|
|
return { devices: [] };
|
|
}
|
|
|
|
async scanUsb(): Promise<{ devices: PrinterDevice[] }> {
|
|
console.warn('USB not available on web');
|
|
return { devices: [] };
|
|
}
|
|
|
|
async connectUsb(): Promise<UsbConnectionResult> {
|
|
console.warn('USB connection not available on web');
|
|
|
|
return {
|
|
name: '',
|
|
address: '',
|
|
connected: false
|
|
};
|
|
}
|
|
|
|
async scanNetwork(): Promise<{ devices: NetworkPrinter[] }> {
|
|
console.warn('Network scan not available on web');
|
|
return { devices: [] };
|
|
}
|
|
|
|
async printBluetooth(_options: BluetoothPrintOptions): Promise<{ success: boolean }> {
|
|
console.warn('Bluetooth printing not available on web');
|
|
return { success: false };
|
|
}
|
|
|
|
async printNetwork(_options: NetworkPrintOptions): Promise<{ success: boolean }> {
|
|
console.warn('Network printing not available on web');
|
|
return { success: false };
|
|
}
|
|
|
|
async printUsb(_options: UsbPrintOptions): Promise<{ success: boolean }> {
|
|
console.warn('USB printing not available on web');
|
|
return { success: false };
|
|
}
|
|
|
|
async requestPermissions(): Promise<PermissionResult> {
|
|
return { bluetooth: 'granted', network: 'granted' };
|
|
}
|
|
|
|
async printIntent(_options: any): Promise<void> {
|
|
console.warn('printIntent not available on web');
|
|
}
|
|
|
|
async checkPrinterStatus(
|
|
_options: PrinterStatusOptions
|
|
): Promise<PrinterStatusResult> {
|
|
|
|
console.warn("Printer status not available on web");
|
|
|
|
return {
|
|
connected: false,
|
|
status: "offline",
|
|
type: _options.type,
|
|
address: _options.address,
|
|
message: "Not supported on web"
|
|
};
|
|
|
|
}
|
|
}
|