seven365-zyprinter 0.4.0 → 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.
package/README.md CHANGED
@@ -9,6 +9,17 @@ npm install seven365-zyprinter
9
9
  npx cap sync
10
10
  ```
11
11
 
12
+ ## Features
13
+
14
+ - ✅ **Bluetooth Printer Discovery & Connection**
15
+ - ✅ **WiFi Network Printer Discovery & Connection**
16
+ - ✅ **USB Printer Support** (iOS: requires MFi-certified accessories)
17
+ - ✅ **Text & Receipt Printing** with formatting options
18
+ - ✅ **Printer Status Monitoring**
19
+ - ✅ **ESC/POS Command Support**
20
+
21
+ > **Note:** iOS USB printer support requires MFi-certified (Made for iPhone/iPad) accessories and proper Info.plist configuration. See [USAGE.md](./USAGE.md#usb-printer-discovery) for details.
22
+
12
23
  ## API
13
24
 
14
25
  <docgen-index>
@@ -17,6 +28,7 @@ npx cap sync
17
28
  * [`discoverPrinters()`](#discoverprinters)
18
29
  * [`discoverBluetoothPrinters()`](#discoverbluetoothprinters)
19
30
  * [`discoverWiFiPrinters(...)`](#discoverwifiprinters)
31
+ * [`discoverUSBPrinters()`](#discoverusbprinters)
20
32
  * [`connectToPrinter(...)`](#connecttoprinter)
21
33
  * [`disconnectFromPrinter(...)`](#disconnectfromprinter)
22
34
  * [`printText(...)`](#printtext)
@@ -81,6 +93,17 @@ discoverWiFiPrinters(options?: { networkRange?: string | undefined; } | undefine
81
93
  --------------------
82
94
 
83
95
 
96
+ ### discoverUSBPrinters()
97
+
98
+ ```typescript
99
+ discoverUSBPrinters() => Promise<{ printers: ZyPrinter[]; }>
100
+ ```
101
+
102
+ **Returns:** <code>Promise&lt;{ printers: ZyPrinter[]; }&gt;</code>
103
+
104
+ --------------------
105
+
106
+
84
107
  ### connectToPrinter(...)
85
108
 
86
109
  ```typescript
package/dist/docs.json CHANGED
@@ -63,6 +63,18 @@
63
63
  ],
64
64
  "slug": "discoverwifiprinters"
65
65
  },
66
+ {
67
+ "name": "discoverUSBPrinters",
68
+ "signature": "() => Promise<{ printers: ZyPrinter[]; }>",
69
+ "parameters": [],
70
+ "returns": "Promise<{ printers: ZyPrinter[]; }>",
71
+ "tags": [],
72
+ "docs": "",
73
+ "complexTypes": [
74
+ "ZyPrinter"
75
+ ],
76
+ "slug": "discoverusbprinters"
77
+ },
66
78
  {
67
79
  "name": "connectToPrinter",
68
80
  "signature": "(options: { identifier: string; }) => Promise<{ connected: boolean; }>",
@@ -43,6 +43,9 @@ export interface ZyprintPlugin {
43
43
  }): Promise<{
44
44
  printers: ZyPrinter[];
45
45
  }>;
46
+ discoverUSBPrinters(): Promise<{
47
+ printers: ZyPrinter[];
48
+ }>;
46
49
  connectToPrinter(options: {
47
50
  identifier: string;
48
51
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["// Enhanced printer interface with connection type details\nexport interface ZyPrinter {\n identifier: string;\n model: string;\n status: string;\n connectionType: 'bluetooth' | 'wifi' | 'usb';\n ipAddress?: string;\n port?: number;\n rssi?: number;\n}\n\nexport interface ReceiptFormatting {\n headerSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n itemSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n itemBold?: boolean;\n totalSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n totalBold?: boolean;\n footerSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n}\n\nexport interface ReceiptTemplate {\n header?: string;\n items?: Array<{ name: string; price: string }>;\n kitchen?: Array<any>; // Support for kitchen data payload\n total?: string;\n footer?: string;\n formatting?: ReceiptFormatting;\n}\n\nexport interface ZyprintPlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n \n // Enhanced Printer Discovery Methods\n discoverPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverBluetoothPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverWiFiPrinters(options?: { networkRange?: string }): Promise<{ printers: ZyPrinter[] }>;\n \n // Connection Management\n connectToPrinter(options: { identifier: string }): Promise<{ connected: boolean }>;\n disconnectFromPrinter(options: { identifier: string }): Promise<{ disconnected: boolean }>;\n \n // Printing Methods\n printText(options: { text: string; identifier: string }): Promise<{ success: boolean }>;\n printReceipt(options: { template: ReceiptTemplate; identifier: string }): Promise<{ success: boolean }>;\n \n // Printer Status\n getPrinterStatus(options: { identifier: string }): Promise<{ status: string; paperStatus: string; connected: boolean }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["// Enhanced printer interface with connection type details\nexport interface ZyPrinter {\n identifier: string;\n model: string;\n status: string;\n connectionType: 'bluetooth' | 'wifi' | 'usb';\n ipAddress?: string;\n port?: number;\n rssi?: number;\n}\n\nexport interface ReceiptFormatting {\n headerSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n itemSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n itemBold?: boolean;\n totalSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n totalBold?: boolean;\n footerSize?: 'normal' | 'large' | 'xlarge' | 1 | 2 | 3 | 4;\n}\n\nexport interface ReceiptTemplate {\n header?: string;\n items?: Array<{ name: string; price: string }>;\n kitchen?: Array<any>; // Support for kitchen data payload\n total?: string;\n footer?: string;\n formatting?: ReceiptFormatting;\n}\n\nexport interface ZyprintPlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n \n // Enhanced Printer Discovery Methods\n discoverPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverBluetoothPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverWiFiPrinters(options?: { networkRange?: string }): Promise<{ printers: ZyPrinter[] }>;\n discoverUSBPrinters(): Promise<{ printers: ZyPrinter[] }>;\n \n // Connection Management\n connectToPrinter(options: { identifier: string }): Promise<{ connected: boolean }>;\n disconnectFromPrinter(options: { identifier: string }): Promise<{ disconnected: boolean }>;\n \n // Printing Methods\n printText(options: { text: string; identifier: string }): Promise<{ success: boolean }>;\n printReceipt(options: { template: ReceiptTemplate; identifier: string }): Promise<{ success: boolean }>;\n \n // Printer Status\n getPrinterStatus(options: { identifier: string }): Promise<{ status: string; paperStatus: string; connected: boolean }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -17,6 +17,9 @@ export declare class ZyprintWeb extends WebPlugin implements ZyprintPlugin {
17
17
  }): Promise<{
18
18
  printers: ZyPrinter[];
19
19
  }>;
20
+ discoverUSBPrinters(): Promise<{
21
+ printers: ZyPrinter[];
22
+ }>;
20
23
  connectToPrinter(_options: {
21
24
  identifier: string;
22
25
  }): Promise<{
package/dist/esm/web.js CHANGED
@@ -16,6 +16,10 @@ export class ZyprintWeb extends WebPlugin {
16
16
  console.warn('Zyprint WiFi discovery is not available on web platform');
17
17
  return { printers: [] };
18
18
  }
19
+ async discoverUSBPrinters() {
20
+ console.warn('Zyprint USB discovery is not available on web platform');
21
+ return { printers: [] };
22
+ }
19
23
  async connectToPrinter(_options) {
20
24
  console.warn('Zyprint connection is not available on web platform');
21
25
  return { connected: false };
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvC,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QACnE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAC7E,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAAoC;QAC7D,OAAO,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;QACxE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgC;QACrD,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACpE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,QAAgC;QAC1D,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA8C;QAC5D,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;QAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAA+D;QAChF,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QAC1E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgC;QACrD,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QACtE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ZyprintPlugin, ZyPrinter } from './definitions';\n\nexport class ZyprintWeb extends WebPlugin implements ZyprintPlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async discoverPrinters(): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n\n async discoverBluetoothPrinters(): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n\n async discoverWiFiPrinters(_options?: { networkRange?: string }): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n\n async connectToPrinter(_options: { identifier: string }): Promise<{ connected: boolean }> {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n\n async disconnectFromPrinter(_options: { identifier: string }): Promise<{ disconnected: boolean }> {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n\n async printText(_options: { text: string; identifier: string }): Promise<{ success: boolean }> {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n\n async printReceipt(_options: { template: Record<string, any>; identifier: string }): Promise<{ success: boolean }> {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n\n async getPrinterStatus(_options: { identifier: string }): Promise<{ status: string; paperStatus: string; connected: boolean }> {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvC,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QACnE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;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zE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ZyprintPlugin, ZyPrinter } from './definitions';\n\nexport class ZyprintWeb extends WebPlugin implements ZyprintPlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async discoverPrinters(): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n\n async discoverBluetoothPrinters(): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n\n async discoverWiFiPrinters(_options?: { networkRange?: string }): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n\n async discoverUSBPrinters(): Promise<{ printers: ZyPrinter[] }> {\n console.warn('Zyprint USB discovery is not available on web platform');\n return { printers: [] };\n }\n\n async connectToPrinter(_options: { identifier: string }): Promise<{ connected: boolean }> {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n\n async disconnectFromPrinter(_options: { identifier: string }): Promise<{ disconnected: boolean }> {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n\n async printText(_options: { text: string; identifier: string }): Promise<{ success: boolean }> {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n\n async printReceipt(_options: { template: Record<string, any>; identifier: string }): Promise<{ success: boolean }> {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n\n async getPrinterStatus(_options: { identifier: string }): Promise<{ status: string; paperStatus: string; connected: boolean }> {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n"]}
@@ -23,6 +23,10 @@ class ZyprintWeb extends core.WebPlugin {
23
23
  console.warn('Zyprint WiFi discovery is not available on web platform');
24
24
  return { printers: [] };
25
25
  }
26
+ async discoverUSBPrinters() {
27
+ console.warn('Zyprint USB discovery is not available on web platform');
28
+ return { printers: [] };
29
+ }
26
30
  async connectToPrinter(_options) {
27
31
  console.warn('Zyprint connection is not available on web platform');
28
32
  return { connected: false };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Zyprint = registerPlugin('Zyprint', {\n web: () => import('./web').then((m) => new m.ZyprintWeb()),\n});\nexport * from './definitions';\nexport { Zyprint };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ZyprintWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async discoverPrinters() {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverBluetoothPrinters() {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverWiFiPrinters(_options) {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n async connectToPrinter(_options) {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n async disconnectFromPrinter(_options) {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n async printText(_options) {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n async printReceipt(_options) {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n async getPrinterStatus(_options) {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;AAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9D,CAAC;;ACFM,MAAM,UAAU,SAASC,cAAS,CAAC;AAC1C,IAAI,MAAM,IAAI,CAAC,OAAO,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,QAAQ,EAAE;AACrC,QAAQ,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC;AAC7E,QAAQ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE;AAC9E,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Zyprint = registerPlugin('Zyprint', {\n web: () => import('./web').then((m) => new m.ZyprintWeb()),\n});\nexport * from './definitions';\nexport { Zyprint };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ZyprintWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async discoverPrinters() {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverBluetoothPrinters() {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverWiFiPrinters(_options) {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverUSBPrinters() {\n console.warn('Zyprint USB discovery is not available on web platform');\n return { printers: [] };\n }\n async connectToPrinter(_options) {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n async disconnectFromPrinter(_options) {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n async printText(_options) {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n async printReceipt(_options) {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n async getPrinterStatus(_options) {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;AAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,C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,QAAQ,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC;AACzE,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC;AACjF,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE;AACrC,QAAQ,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC;AAC7E,QAAQ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE;AAC9E,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -22,6 +22,10 @@ var capacitorExample = (function (exports, core) {
22
22
  console.warn('Zyprint WiFi discovery is not available on web platform');
23
23
  return { printers: [] };
24
24
  }
25
+ async discoverUSBPrinters() {
26
+ console.warn('Zyprint USB discovery is not available on web platform');
27
+ return { printers: [] };
28
+ }
25
29
  async connectToPrinter(_options) {
26
30
  console.warn('Zyprint connection is not available on web platform');
27
31
  return { connected: false };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Zyprint = registerPlugin('Zyprint', {\n web: () => import('./web').then((m) => new m.ZyprintWeb()),\n});\nexport * from './definitions';\nexport { Zyprint };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ZyprintWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async discoverPrinters() {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverBluetoothPrinters() {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverWiFiPrinters(_options) {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n async connectToPrinter(_options) {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n async disconnectFromPrinter(_options) {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n async printText(_options) {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n async printReceipt(_options) {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n async getPrinterStatus(_options) {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;IAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC9D,CAAC;;ICFM,MAAM,UAAU,SAASC,cAAS,CAAC;IAC1C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC,QAAQ,OAAO,OAAO;IACtB,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC;IAC1E,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/B,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC;IACpF,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/B,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,OAAO,CAAC,IAAI,CAAC,yDAAyD,CAAC;IAC/E,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/B,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE;IACrC,QAAQ,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;IAC3E,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,qBAAqB,CAAC,QAAQ,EAAE;IAC1C,QAAQ,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC;IAC9E,QAAQ,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE;IACtC,IAAI;IACJ,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;IAC9B,QAAQ,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC;IACzE,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC;IACjF,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE;IACrC,QAAQ,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC;IAC7E,QAAQ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE;IAC9E,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Zyprint = registerPlugin('Zyprint', {\n web: () => import('./web').then((m) => new m.ZyprintWeb()),\n});\nexport * from './definitions';\nexport { Zyprint };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ZyprintWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async discoverPrinters() {\n console.warn('Zyprint discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverBluetoothPrinters() {\n console.warn('Zyprint Bluetooth discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverWiFiPrinters(_options) {\n console.warn('Zyprint WiFi discovery is not available on web platform');\n return { printers: [] };\n }\n async discoverUSBPrinters() {\n console.warn('Zyprint USB discovery is not available on web platform');\n return { printers: [] };\n }\n async connectToPrinter(_options) {\n console.warn('Zyprint connection is not available on web platform');\n return { connected: false };\n }\n async disconnectFromPrinter(_options) {\n console.warn('Zyprint disconnection is not available on web platform');\n return { disconnected: false };\n }\n async printText(_options) {\n console.warn('Zyprint printing is not available on web platform');\n return { success: false };\n }\n async printReceipt(_options) {\n console.warn('Zyprint receipt printing is not available on web platform');\n return { success: false };\n }\n async getPrinterStatus(_options) {\n console.warn('Zyprint status check is not available on web platform');\n return { status: 'unknown', paperStatus: 'unknown', connected: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;IAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC9D,CAAC;;ICFM,MAAM,UAAU,SAASC,cAAS,CAAC;IAC1C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC,QAAQ,OAAO,OAAO;IACtB,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC;IAC1E,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/B,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC;IACpF,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/B,IAAI;IACJ,IAAI,MAAM,oBAAo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ethod(name: "discoverPrinters", returnType: CAPPluginReturnPromise),
18
18
  CAPPluginMethod(name: "discoverBluetoothPrinters", returnType: CAPPluginReturnPromise),
19
19
  CAPPluginMethod(name: "discoverWiFiPrinters", returnType: CAPPluginReturnPromise),
20
+ CAPPluginMethod(name: "discoverUSBPrinters", returnType: CAPPluginReturnPromise),
20
21
  CAPPluginMethod(name: "connectToPrinter", returnType: CAPPluginReturnPromise),
21
22
  CAPPluginMethod(name: "disconnectFromPrinter", returnType: CAPPluginReturnPromise),
22
23
  CAPPluginMethod(name: "printText", returnType: CAPPluginReturnPromise),
@@ -70,6 +71,18 @@ public class ZyprintPlugin: CAPPlugin, CAPBridgedPlugin {
70
71
  }
71
72
  }
72
73
 
74
+ @objc func discoverUSBPrinters(_ call: CAPPluginCall) {
75
+ implementation.discoverUSBPrinters { printers, error in
76
+ if let error = error {
77
+ call.reject(error)
78
+ } else {
79
+ call.resolve([
80
+ "printers": printers
81
+ ])
82
+ }
83
+ }
84
+ }
85
+
73
86
  @objc func connectToPrinter(_ call: CAPPluginCall) {
74
87
  guard let identifier = call.getString("identifier") else {
75
88
  call.reject("Missing identifier parameter")
@@ -8,6 +8,7 @@
8
8
  import Foundation
9
9
  import CoreBluetooth
10
10
  import Network
11
+ import ExternalAccessory
11
12
 
12
13
 
13
14
  @objc public class ZywellSDK: NSObject {
@@ -79,6 +80,51 @@ import Network
79
80
  scanSubnet(prefix: prefix, completion: completion)
80
81
  }
81
82
 
83
+ @objc public func discoverUSBPrinters(completion: @escaping ([[String: Any]], String?) -> Void) {
84
+ // Query External Accessory framework for connected accessories
85
+ let accessoryManager = EAAccessoryManager.shared()
86
+ let connectedAccessories = accessoryManager.connectedAccessories
87
+
88
+ var usbPrinters: [[String: Any]] = []
89
+
90
+ // Filter for printer accessories
91
+ // Note: This requires the app to declare supported accessory protocols in Info.plist
92
+ // under the key "UISupportedExternalAccessoryProtocols"
93
+ for accessory in connectedAccessories {
94
+ // Check if the accessory might be a printer
95
+ // Common printer protocol strings include manufacturer-specific identifiers
96
+ let isPotentialPrinter = accessory.protocolStrings.contains { protocol in
97
+ protocol.lowercased().contains("printer") ||
98
+ protocol.lowercased().contains("print") ||
99
+ protocol.lowercased().contains("pos")
100
+ }
101
+
102
+ if isPotentialPrinter || !accessory.protocolStrings.isEmpty {
103
+ usbPrinters.append([
104
+ "identifier": String(accessory.connectionID),
105
+ "model": "\(accessory.manufacturer) \(accessory.name)",
106
+ "status": accessory.isConnected ? "ready" : "offline",
107
+ "connectionType": "usb",
108
+ "manufacturer": accessory.manufacturer,
109
+ "modelNumber": accessory.modelNumber,
110
+ "serialNumber": accessory.serialNumber,
111
+ "firmwareRevision": accessory.firmwareRevision,
112
+ "hardwareRevision": accessory.hardwareRevision,
113
+ "protocols": accessory.protocolStrings
114
+ ])
115
+ }
116
+ }
117
+
118
+ // Log information about USB discovery
119
+ if usbPrinters.isEmpty {
120
+ print("ZywellSDK: No USB accessories found. Note: iOS requires MFi-certified accessories with declared protocol strings in Info.plist")
121
+ } else {
122
+ print("ZywellSDK: Found \(usbPrinters.count) potential USB printer(s)")
123
+ }
124
+
125
+ completion(usbPrinters, nil)
126
+ }
127
+
82
128
  private func scanSubnet(prefix: String, completion: @escaping ([[String: Any]], String?) -> Void) {
83
129
  let group = DispatchGroup()
84
130
  let queue = DispatchQueue(label: "com.seven365.printer.scan", attributes: .concurrent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seven365-zyprinter",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Capacitor plugin for Zywell/Zyprint thermal printer integration with Bluetooth and WiFi support",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",