@amitkhare/capacitor-cat-printer 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,243 @@
1
+ package khare.catprinter.plugin;
2
+
3
+ import java.util.UUID;
4
+
5
+ /**
6
+ * Cat Printer BLE protocol implementation.
7
+ * Handles command building, CRC8 calculation, and protocol constants.
8
+ */
9
+ public class PrinterProtocol {
10
+
11
+ // BLE Service and Characteristics
12
+ public static final UUID SERVICE_UUID = UUID.fromString("0000ae30-0000-1000-8000-00805f9b34fb");
13
+ public static final UUID TX_CHAR_UUID = UUID.fromString("0000ae01-0000-1000-8000-00805f9b34fb");
14
+ public static final UUID RX_CHAR_UUID = UUID.fromString("0000ae02-0000-1000-8000-00805f9b34fb");
15
+ public static final UUID CCCD_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
16
+
17
+ // Flow control signals from printer (received on RX characteristic)
18
+ // These are the exact bytes from the reference implementation
19
+ public static final byte[] FLOW_PAUSE = new byte[]{
20
+ 0x51, 0x78, (byte)0xae, 0x01, 0x01, 0x00, 0x10, 0x70, (byte)0xff
21
+ };
22
+ public static final byte[] FLOW_RESUME = new byte[]{
23
+ 0x51, 0x78, (byte)0xae, 0x01, 0x01, 0x00, 0x00, 0x00, (byte)0xff
24
+ };
25
+
26
+ // Alternative service UUID (some printers use this)
27
+ public static final UUID SERVICE_UUID_ALT = UUID.fromString("0000ae30-0000-1000-8000-00805f9b34fb");
28
+
29
+ // Paper width constants
30
+ public static final int WIDTH_58MM = 384;
31
+ public static final int WIDTH_80MM = 576;
32
+
33
+ // CRC8 lookup table
34
+ private static final int[] CRC8_TABLE = {
35
+ 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
36
+ 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65,
37
+ 0x48, 0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, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f,
52
+ 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b,
53
+ 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7,
54
+ 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83,
55
+ 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef,
56
+ 0xfa, 0xfd, 0xf4, 0xf3
57
+ };
58
+
59
+ /**
60
+ * Calculate CRC8 checksum for data
61
+ */
62
+ public static byte crc8(byte[] data) {
63
+ int crc = 0;
64
+ for (byte b : data) {
65
+ crc = CRC8_TABLE[(crc ^ (b & 0xff)) & 0xff];
66
+ }
67
+ return (byte) (crc & 0xff);
68
+ }
69
+
70
+ /**
71
+ * Reverse bits in a byte (required for bitmap data)
72
+ */
73
+ public static byte reverseBits(byte b) {
74
+ int i = b & 0xff;
75
+ i = ((i & 0b10101010) >> 1) | ((i & 0b01010101) << 1);
76
+ i = ((i & 0b11001100) >> 2) | ((i & 0b00110011) << 2);
77
+ return (byte) (((i & 0b11110000) >> 4) | ((i & 0b00001111) << 4));
78
+ }
79
+
80
+ /**
81
+ * Build a command packet
82
+ */
83
+ public static byte[] makeCommand(int commandBit, byte[] payload) {
84
+ int payloadSize = payload.length;
85
+ if (payloadSize > 255) {
86
+ throw new IllegalArgumentException("Payload too large: " + payloadSize);
87
+ }
88
+
89
+ byte[] cmd = new byte[8 + payloadSize];
90
+ cmd[0] = 0x51;
91
+ cmd[1] = 0x78;
92
+ cmd[2] = (byte) commandBit;
93
+ cmd[3] = 0x00;
94
+ cmd[4] = (byte) payloadSize;
95
+ cmd[5] = 0x00;
96
+ System.arraycopy(payload, 0, cmd, 6, payloadSize);
97
+ cmd[6 + payloadSize] = crc8(payload);
98
+ cmd[7 + payloadSize] = (byte) 0xff;
99
+
100
+ return cmd;
101
+ }
102
+
103
+ /**
104
+ * Convert int to little-endian bytes
105
+ */
106
+ public static byte[] intToBytes(int value, int length) {
107
+ byte[] result = new byte[length];
108
+ for (int i = 0; i < length; i++) {
109
+ result[i] = (byte) (value & 0xff);
110
+ value >>= 8;
111
+ }
112
+ return result;
113
+ }
114
+
115
+ // ==================== PRINTER COMMANDS ====================
116
+
117
+ /**
118
+ * Get device state - refreshes device state & applies config
119
+ * Command 0xa3 with payload 0x00
120
+ */
121
+ public static byte[] cmdGetDeviceState() {
122
+ return makeCommand(0xa3, new byte[]{0x00});
123
+ }
124
+
125
+ /**
126
+ * Start printing command (standard printers)
127
+ * This is a raw command without the makeCommand wrapper
128
+ */
129
+ public static byte[] cmdStartPrinting() {
130
+ return new byte[]{0x51, 0x78, (byte)0xa3, 0x00, 0x01, 0x00, 0x00, 0x00, (byte)0xff};
131
+ }
132
+
133
+ /**
134
+ * Start printing command for newer printers (GB03, etc.)
135
+ * Has 0x12 prefix
136
+ */
137
+ public static byte[] cmdStartPrintingNew() {
138
+ return new byte[]{0x12, 0x51, 0x78, (byte)0xa3, 0x00, 0x01, 0x00, 0x00, 0x00, (byte)0xff};
139
+ }
140
+
141
+ /**
142
+ * Set DPI to 200 (sends value 50)
143
+ */
144
+ public static byte[] cmdSetDpi200() {
145
+ return makeCommand(0xa4, new byte[]{50});
146
+ }
147
+
148
+ /**
149
+ * Start lattice - marks the start of printing bitmap data
150
+ */
151
+ public static byte[] cmdStartLattice() {
152
+ return makeCommand(0xa6, new byte[]{
153
+ (byte)0xaa, 0x55, 0x17, 0x38, 0x44, 0x5f, 0x5f, 0x5f, 0x44, 0x38, 0x2c
154
+ });
155
+ }
156
+
157
+ /**
158
+ * End lattice - marks the end of printing bitmap data
159
+ */
160
+ public static byte[] cmdEndLattice() {
161
+ return makeCommand(0xa6, new byte[]{
162
+ (byte)0xaa, 0x55, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Set print speed (lower = faster, but affects quality)
168
+ * Recommended range: 8-36
169
+ */
170
+ public static byte[] cmdSetSpeed(int speed) {
171
+ return makeCommand(0xbd, new byte[]{(byte) speed});
172
+ }
173
+
174
+ /**
175
+ * Set thermal energy (print darkness)
176
+ * Range: 0x0000 to 0xFFFF
177
+ * Default is around 0x3000 (about 1/5)
178
+ */
179
+ public static byte[] cmdSetEnergy(int energy) {
180
+ return makeCommand(0xaf, intToBytes(energy, 2));
181
+ }
182
+
183
+ /**
184
+ * Apply the previously set energy
185
+ */
186
+ public static byte[] cmdApplyEnergy() {
187
+ return makeCommand(0xbe, new byte[]{0x01});
188
+ }
189
+
190
+ /**
191
+ * Update device state
192
+ */
193
+ public static byte[] cmdUpdateDevice() {
194
+ return makeCommand(0xa9, new byte[]{0x00});
195
+ }
196
+
197
+ /**
198
+ * Feed paper forward by specified pixels
199
+ */
200
+ public static byte[] cmdFeedPaper(int pixels) {
201
+ return makeCommand(0xa1, intToBytes(pixels, 2));
202
+ }
203
+
204
+ /**
205
+ * Retract paper by specified pixels
206
+ */
207
+ public static byte[] cmdRetractPaper(int pixels) {
208
+ return makeCommand(0xa0, intToBytes(pixels, 2));
209
+ }
210
+
211
+ /**
212
+ * Create bitmap line command with bit reversal
213
+ */
214
+ public static byte[] cmdDrawBitmap(byte[] lineData) {
215
+ byte[] reversed = new byte[lineData.length];
216
+ for (int i = 0; i < lineData.length; i++) {
217
+ reversed[i] = reverseBits(lineData[i]);
218
+ }
219
+ return makeCommand(0xa2, reversed);
220
+ }
221
+
222
+ /**
223
+ * Check if data matches flow pause signal
224
+ */
225
+ public static boolean isFlowPause(byte[] data) {
226
+ if (data.length != FLOW_PAUSE.length) return false;
227
+ for (int i = 0; i < data.length; i++) {
228
+ if (data[i] != FLOW_PAUSE[i]) return false;
229
+ }
230
+ return true;
231
+ }
232
+
233
+ /**
234
+ * Check if data matches flow resume signal
235
+ */
236
+ public static boolean isFlowResume(byte[] data) {
237
+ if (data.length != FLOW_RESUME.length) return false;
238
+ for (int i = 0; i < data.length; i++) {
239
+ if (data[i] != FLOW_RESUME[i]) return false;
240
+ }
241
+ return true;
242
+ }
243
+ }
@@ -0,0 +1,189 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export interface CatPrinterPlugin {
3
+ /**
4
+ * Scan for nearby BLE devices
5
+ */
6
+ scan(options?: ScanOptions): Promise<ScanResult>;
7
+ /**
8
+ * Stop ongoing scan
9
+ */
10
+ stopScan(): Promise<void>;
11
+ /**
12
+ * Connect to a printer by address
13
+ */
14
+ connect(options: ConnectOptions): Promise<void>;
15
+ /**
16
+ * Disconnect from current printer
17
+ */
18
+ disconnect(): Promise<void>;
19
+ /**
20
+ * Check if connected to a printer
21
+ */
22
+ isConnected(): Promise<ConnectionStatus>;
23
+ /**
24
+ * Print an image (PNG/JPEG as base64)
25
+ */
26
+ printImage(options: PrintImageOptions): Promise<void>;
27
+ /**
28
+ * Print text as receipt
29
+ */
30
+ printText(options: PrintTextOptions): Promise<void>;
31
+ /**
32
+ * Feed paper (advance paper without printing)
33
+ */
34
+ feedPaper(options?: FeedOptions): Promise<void>;
35
+ /**
36
+ * Add listener for scan results (devices found during scan)
37
+ */
38
+ addListener(eventName: 'scanResult', listenerFunc: (device: BleDevice) => void): Promise<PluginListenerHandle>;
39
+ /**
40
+ * Add listener for connection state changes
41
+ */
42
+ addListener(eventName: 'connectionState', listenerFunc: (state: ConnectionState) => void): Promise<PluginListenerHandle>;
43
+ /**
44
+ * Add listener for print progress
45
+ */
46
+ addListener(eventName: 'printProgress', listenerFunc: (progress: PrintProgress) => void): Promise<PluginListenerHandle>;
47
+ /**
48
+ * Remove all listeners
49
+ */
50
+ removeAllListeners(): Promise<void>;
51
+ }
52
+ export interface ScanOptions {
53
+ /**
54
+ * Scan duration in milliseconds
55
+ * @default 4000
56
+ */
57
+ duration?: number;
58
+ }
59
+ export interface ScanResult {
60
+ devices: BleDevice[];
61
+ }
62
+ export interface BleDevice {
63
+ name: string;
64
+ address: string;
65
+ rssi?: number;
66
+ }
67
+ export interface ConnectOptions {
68
+ /**
69
+ * Bluetooth MAC address of the printer
70
+ */
71
+ address: string;
72
+ /**
73
+ * Paper width in pixels
74
+ * 384 = 58mm, 576 = 80mm
75
+ * @default 384
76
+ */
77
+ paperWidth?: number;
78
+ }
79
+ export interface ConnectionStatus {
80
+ connected: boolean;
81
+ address?: string;
82
+ paperWidth?: number;
83
+ }
84
+ export interface ConnectionState {
85
+ connected: boolean;
86
+ address?: string;
87
+ }
88
+ export interface PrintImageOptions {
89
+ /**
90
+ * Base64 encoded image data (PNG or JPEG)
91
+ */
92
+ imageBase64: string;
93
+ /**
94
+ * Thermal energy (print darkness)
95
+ * Range: 0.0 to 1.0
96
+ * @default 0.5
97
+ */
98
+ energy?: number;
99
+ /**
100
+ * Print quality (1-4, higher = better but slower)
101
+ * @default 3
102
+ */
103
+ quality?: number;
104
+ /**
105
+ * Paper feed after printing in pixels
106
+ * @default 100
107
+ */
108
+ feedAfter?: number;
109
+ /**
110
+ * Threshold for black/white conversion (0-255)
111
+ * @default 127
112
+ */
113
+ threshold?: number;
114
+ /**
115
+ * Use Floyd-Steinberg dithering for better image quality
116
+ * @default true
117
+ */
118
+ dither?: boolean;
119
+ }
120
+ export interface PrintTextOptions {
121
+ /**
122
+ * Text content to print
123
+ */
124
+ text: string;
125
+ /**
126
+ * Font size in pixels
127
+ * @default 24
128
+ */
129
+ fontSize?: number;
130
+ /**
131
+ * Text alignment: 'left', 'center', 'right'
132
+ * @default 'left'
133
+ */
134
+ align?: 'left' | 'center' | 'right';
135
+ /**
136
+ * Bold text
137
+ * @default false
138
+ */
139
+ bold?: boolean;
140
+ /**
141
+ * Line spacing multiplier
142
+ * @default 1.2
143
+ */
144
+ lineSpacing?: number;
145
+ /**
146
+ * Thermal energy (print darkness)
147
+ * @default 0.6
148
+ */
149
+ energy?: number;
150
+ /**
151
+ * Print quality (1-4)
152
+ * @default 3
153
+ */
154
+ quality?: number;
155
+ /**
156
+ * Paper feed after printing in pixels
157
+ * @default 100
158
+ */
159
+ feedAfter?: number;
160
+ }
161
+ export interface FeedOptions {
162
+ /**
163
+ * Number of pixels to feed
164
+ * @default 100
165
+ */
166
+ pixels?: number;
167
+ }
168
+ export interface PrintProgress {
169
+ /**
170
+ * Progress percentage (0-100)
171
+ */
172
+ percent: number;
173
+ /**
174
+ * Current status
175
+ */
176
+ status: 'processing' | 'printing' | 'feeding' | 'done' | 'error';
177
+ /**
178
+ * Optional message
179
+ */
180
+ message?: string;
181
+ }
182
+ /**
183
+ * Paper width constants
184
+ */
185
+ export declare const PaperWidth: {
186
+ readonly MM_58: 384;
187
+ readonly MM_80: 576;
188
+ };
189
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEjD;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEzC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG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,
7
+ };
8
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAoOA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { CatPrinterPlugin } from './definitions';
2
+ declare const CatPrinter: CatPrinterPlugin;
3
+ export * from './definitions';
4
+ export { CatPrinter };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,QAAA,MAAM,UAAU,kBAEd,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CatPrinter = registerPlugin('CatPrinter', {
3
+ web: () => import('./web').then(m => new m.CatPrinterWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { CatPrinter };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CatPrinterPlugin, ScanOptions, ScanResult, ConnectOptions, ConnectionStatus, PrintImageOptions, PrintTextOptions, FeedOptions } from './definitions';
3
+ export declare class CatPrinterWeb extends WebPlugin implements CatPrinterPlugin {
4
+ scan(_options?: ScanOptions): Promise<ScanResult>;
5
+ stopScan(): Promise<void>;
6
+ connect(_options: ConnectOptions): Promise<void>;
7
+ disconnect(): Promise<void>;
8
+ isConnected(): Promise<ConnectionStatus>;
9
+ printImage(_options: PrintImageOptions): Promise<void>;
10
+ printText(_options: PrintTextOptions): Promise<void>;
11
+ feedPaper(_options: FeedOptions): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB,qBAAa,aAAc,SAAQ,SAAU,YAAW,gBAAgB;IAChE,IAAI,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIxC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtD"}
@@ -0,0 +1,28 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CatPrinterWeb extends WebPlugin {
3
+ async scan(_options) {
4
+ throw this.unavailable('BLE printing is not available on web');
5
+ }
6
+ async stopScan() {
7
+ throw this.unavailable('BLE printing is not available on web');
8
+ }
9
+ async connect(_options) {
10
+ throw this.unavailable('BLE printing is not available on web');
11
+ }
12
+ async disconnect() {
13
+ throw this.unavailable('BLE printing is not available on web');
14
+ }
15
+ async isConnected() {
16
+ return { connected: false };
17
+ }
18
+ async printImage(_options) {
19
+ throw this.unavailable('BLE printing is not available on web');
20
+ }
21
+ async printText(_options) {
22
+ throw this.unavailable('BLE printing is not available on web');
23
+ }
24
+ async feedPaper(_options) {
25
+ throw this.unavailable('BLE printing is not available on web');
26
+ }
27
+ }
28
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,IAAI,CAAC,QAAsB;QAC/B,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAwB;QACpC,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA2B;QAC1C,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA0B;QACxC,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAqB;QACnC,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACjE,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /**
6
+ * Paper width constants
7
+ */
8
+ const PaperWidth = {
9
+ MM_58: 384,
10
+ MM_80: 576,
11
+ };
12
+
13
+ const CatPrinter = core.registerPlugin('CatPrinter', {
14
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CatPrinterWeb()),
15
+ });
16
+
17
+ class CatPrinterWeb extends core.WebPlugin {
18
+ async scan(_options) {
19
+ throw this.unavailable('BLE printing is not available on web');
20
+ }
21
+ async stopScan() {
22
+ throw this.unavailable('BLE printing is not available on web');
23
+ }
24
+ async connect(_options) {
25
+ throw this.unavailable('BLE printing is not available on web');
26
+ }
27
+ async disconnect() {
28
+ throw this.unavailable('BLE printing is not available on web');
29
+ }
30
+ async isConnected() {
31
+ return { connected: false };
32
+ }
33
+ async printImage(_options) {
34
+ throw this.unavailable('BLE printing is not available on web');
35
+ }
36
+ async printText(_options) {
37
+ throw this.unavailable('BLE printing is not available on web');
38
+ }
39
+ async feedPaper(_options) {
40
+ throw this.unavailable('BLE printing is not available on web');
41
+ }
42
+ }
43
+
44
+ var web = /*#__PURE__*/Object.freeze({
45
+ __proto__: null,
46
+ CatPrinterWeb: CatPrinterWeb
47
+ });
48
+
49
+ exports.CatPrinter = CatPrinter;
50
+ exports.PaperWidth = PaperWidth;
51
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Paper width constants\n */\nexport const PaperWidth = {\n MM_58: 384,\n MM_80: 576,\n};\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CatPrinter = registerPlugin('CatPrinter', {\n web: () => import('./web').then(m => new m.CatPrinterWeb()),\n});\nexport * from './definitions';\nexport { CatPrinter };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CatPrinterWeb extends WebPlugin {\n async scan(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async stopScan() {\n throw this.unavailable('BLE printing is not available on web');\n }\n async connect(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async disconnect() {\n throw this.unavailable('BLE printing is not available on web');\n }\n async isConnected() {\n return { connected: false };\n }\n async printImage(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async printText(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async feedPaper(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACY,MAAC,UAAU,GAAG;AAC1B,IAAI,KAAK,EAAE,GAAG;AACd,IAAI,KAAK,EAAE,GAAG;AACd;;ACLK,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACFM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;AACnC,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,sCAAsC,CAAC;AACtE,IAAI;AACJ;;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,54 @@
1
+ var capacitorCatPrinter = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Paper width constants
6
+ */
7
+ const PaperWidth = {
8
+ MM_58: 384,
9
+ MM_80: 576,
10
+ };
11
+
12
+ const CatPrinter = core.registerPlugin('CatPrinter', {
13
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CatPrinterWeb()),
14
+ });
15
+
16
+ class CatPrinterWeb extends core.WebPlugin {
17
+ async scan(_options) {
18
+ throw this.unavailable('BLE printing is not available on web');
19
+ }
20
+ async stopScan() {
21
+ throw this.unavailable('BLE printing is not available on web');
22
+ }
23
+ async connect(_options) {
24
+ throw this.unavailable('BLE printing is not available on web');
25
+ }
26
+ async disconnect() {
27
+ throw this.unavailable('BLE printing is not available on web');
28
+ }
29
+ async isConnected() {
30
+ return { connected: false };
31
+ }
32
+ async printImage(_options) {
33
+ throw this.unavailable('BLE printing is not available on web');
34
+ }
35
+ async printText(_options) {
36
+ throw this.unavailable('BLE printing is not available on web');
37
+ }
38
+ async feedPaper(_options) {
39
+ throw this.unavailable('BLE printing is not available on web');
40
+ }
41
+ }
42
+
43
+ var web = /*#__PURE__*/Object.freeze({
44
+ __proto__: null,
45
+ CatPrinterWeb: CatPrinterWeb
46
+ });
47
+
48
+ exports.CatPrinter = CatPrinter;
49
+ exports.PaperWidth = PaperWidth;
50
+
51
+ return exports;
52
+
53
+ })({}, capacitorExports);
54
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Paper width constants\n */\nexport const PaperWidth = {\n MM_58: 384,\n MM_80: 576,\n};\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CatPrinter = registerPlugin('CatPrinter', {\n web: () => import('./web').then(m => new m.CatPrinterWeb()),\n});\nexport * from './definitions';\nexport { CatPrinter };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CatPrinterWeb extends WebPlugin {\n async scan(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async stopScan() {\n throw this.unavailable('BLE printing is not available on web');\n }\n async connect(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async disconnect() {\n throw this.unavailable('BLE printing is not available on web');\n }\n async isConnected() {\n return { connected: false };\n }\n async printImage(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async printText(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n async feedPaper(_options) {\n throw this.unavailable('BLE printing is not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACY,UAAC,UAAU,GAAG;IAC1B,IAAI,KAAK,EAAE,GAAG;IACd,IAAI,KAAK,EAAE,GAAG;IACd;;ACLK,UAAC,UAAU,GAAGA,mBA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