@esslassi/electron-printer 0.0.7 โ†’ 0.0.8

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
@@ -1,319 +1,319 @@
1
- # ๐Ÿ“ฆ @esslassi/electron-printer
2
-
3
- Cross-platform native printer driver for **Windows, macOS, and Linux**, built with Node-API (N-API).
4
- Works in **Node.js** and **Electron**.
5
-
6
- Supports:
7
-
8
- * ๐Ÿ–จ List printers
9
- * ๐Ÿ“„ Print raw/text/command data
10
- * ๐Ÿ“ Print files
11
- * ๐Ÿ“‹ Get printer driver options
12
- * ๐Ÿ“‘ Get selected paper size
13
- * ๐Ÿ“ฆ Get job status
14
- * โ›” Cancel / pause / resume jobs
15
- * ๐Ÿ”„ Promise (async/await) wrappers included
16
-
17
- ---
18
-
19
- ## ๐Ÿš€ Installation
20
-
21
- ```bash
22
- npm install @esslassi/electron-printer
23
- ```
24
-
25
- If using Electron:
26
-
27
- ```bash
28
- npx electron-rebuild
29
- ```
30
-
31
- ---
32
-
33
- ## ๐Ÿงฉ Supported Platforms
34
-
35
- | OS | Backend |
36
- | ------- | ------------ |
37
- | Windows | WinSpool API |
38
- | macOS | CUPS |
39
- | Linux | CUPS |
40
-
41
- ---
42
-
43
- # ๐Ÿ“– Usage
44
-
45
- ```ts
46
- import * as printer from '@esslassi/electron-printer'
47
- ```
48
-
49
- ---
50
-
51
- # ๐Ÿ–จ Printer Management
52
-
53
- ### Get all printers
54
-
55
- ```ts
56
- const printers = printer.getPrinters()
57
- ```
58
-
59
- ### Async version
60
-
61
- ```ts
62
- const printers = await printer.getPrintersAsync()
63
- ```
64
-
65
- ---
66
-
67
- ### Get single printer
68
-
69
- ```ts
70
- const details = printer.getPrinter("My Printer")
71
- ```
72
-
73
- ---
74
-
75
- ### Get default printer
76
-
77
- ```ts
78
- const defaultPrinter = printer.getDefaultPrinterName()
79
- ```
80
-
81
- ---
82
-
83
- ### Get printer driver options
84
-
85
- ```ts
86
- const options = printer.getPrinterDriverOptions("My Printer")
87
- ```
88
-
89
- ---
90
-
91
- ### Get selected paper size
92
-
93
- ```ts
94
- const paper = printer.getSelectedPaperSize("My Printer")
95
- ```
96
-
97
- ---
98
-
99
- # ๐Ÿ–จ Printing
100
-
101
- ---
102
-
103
- ## ๐ŸŸข Print Raw/Text Data (Callback)
104
-
105
- ```ts
106
- printer.printDirect({
107
- data: "Hello Printer\n\n",
108
- printer: "My Printer",
109
- type: "RAW",
110
- success: (jobId) => {
111
- console.log("Printed. Job ID:", jobId)
112
- },
113
- error: (err) => {
114
- console.error("Print error:", err)
115
- }
116
- })
117
- ```
118
-
119
- ---
120
-
121
- ## ๐ŸŸข Print Raw/Text Data (Async/Await)
122
-
123
- ```ts
124
- const jobId = await printer.printDirectAsync({
125
- data: Buffer.from("Hello Printer\n\n"),
126
- printer: "My Printer",
127
- type: "RAW"
128
- })
129
-
130
- console.log("Printed. Job ID:", jobId)
131
- ```
132
-
133
- ---
134
-
135
- ## ๐ŸŸข Print File (Callback)
136
-
137
- ```ts
138
- printer.printFile({
139
- filename: "./file.txt",
140
- printer: "My Printer",
141
- success: (jobId) => console.log(jobId),
142
- error: (err) => console.error(err)
143
- })
144
- ```
145
-
146
- ---
147
-
148
- ## ๐ŸŸข Print File (Async)
149
-
150
- ```ts
151
- const jobId = await printer.printFileAsync({
152
- filename: "./file.txt",
153
- printer: "My Printer"
154
- })
155
- ```
156
-
157
- ---
158
-
159
- # ๐Ÿ“ฆ Job Management
160
-
161
- ---
162
-
163
- ## Get Job Details
164
-
165
- ```ts
166
- const job = printer.getJob("My Printer", 42)
167
- ```
168
-
169
- ### Async
170
-
171
- ```ts
172
- const job = await printer.getJobAsync("My Printer", 42)
173
- ```
174
-
175
- ---
176
-
177
- ## Cancel / Pause / Resume Job
178
-
179
- ```ts
180
- printer.setJob("My Printer", 42, "CANCEL")
181
- printer.setJob("My Printer", 42, "PAUSE")
182
- printer.setJob("My Printer", 42, "RESUME")
183
- ```
184
-
185
- ---
186
-
187
- ## Get Supported Job Commands
188
-
189
- ```ts
190
- const commands = printer.getSupportedJobCommands()
191
- ```
192
-
193
- ---
194
-
195
- # ๐Ÿ“„ Supported Print Formats
196
-
197
- ```ts
198
- const formats = printer.getSupportedPrintFormats()
199
- ```
200
-
201
- Typical values:
202
-
203
- * `RAW`
204
- * `TEXT`
205
- * `COMMAND`
206
- * `AUTO`
207
-
208
- > Windows supports RAW/TEXT/COMMAND directly.
209
- > macOS/Linux support additional formats via CUPS.
210
-
211
- ---
212
-
213
- # ๐Ÿง  TypeScript Types
214
-
215
- Fully typed. Example:
216
-
217
- ```ts
218
- export interface PrintDirectOptions {
219
- data: string | Buffer
220
- printer?: string
221
- type?: 'RAW' | 'TEXT' | 'COMMAND' | 'AUTO'
222
- options?: { [key: string]: string }
223
- }
224
- ```
225
-
226
- ---
227
-
228
- # โšก Promise Wrappers Included
229
-
230
- Built-in async wrappers:
231
-
232
- * `printDirectAsync`
233
- * `printFileAsync`
234
- * `getPrintersAsync`
235
- * `getPrinterAsync`
236
- * `getJobAsync`
237
-
238
- No extra wrapper needed.
239
-
240
- ---
241
-
242
- # ๐Ÿงช Example Full Test
243
-
244
- ```ts
245
- import * as printer from '@esslassi/electron-printer'
246
-
247
- async function test() {
248
- const printers = await printer.getPrintersAsync()
249
- const defaultPrinter = printer.getDefaultPrinterName()
250
-
251
- const jobId = await printer.printDirectAsync({
252
- data: "Test print\n\n",
253
- printer: defaultPrinter,
254
- type: "RAW"
255
- })
256
-
257
- const job = await printer.getJobAsync(defaultPrinter!, Number(jobId))
258
-
259
- console.log(job)
260
- }
261
-
262
- test()
263
- ```
264
-
265
- ---
266
-
267
- # ๐Ÿ— Architecture
268
-
269
- ```
270
- Node.js / Electron
271
- โ†“
272
- N-API
273
- โ†“
274
- PrinterFactory
275
- โ†“
276
- Windows | macOS | Linux drivers
277
- ```
278
-
279
- Native C++ backend with platform-specific implementations.
280
-
281
- ---
282
-
283
- # ๐Ÿ”ง Development
284
-
285
- Build from source:
286
-
287
- ```bash
288
- npx node-gyp rebuild
289
- ```
290
-
291
- Electron:
292
-
293
- ```bash
294
- npx electron-rebuild
295
- ```
296
-
297
- ---
298
-
299
- # ๐Ÿ“œ License
300
-
301
- MIT
302
-
303
- ---
304
-
305
- # ๐Ÿ‘จโ€๐Ÿ’ป Author
306
-
307
- Esslassi
308
-
309
- ---
310
-
311
- If you want, I can also generate:
312
-
313
- * ๐Ÿ”ฅ NPM package.json template
314
- * ๐Ÿงฑ binding.gyp optimized version
315
- * โšก Prebuild support (no node-gyp required for users)
316
- * ๐Ÿงช Jest test suite
317
- * ๐Ÿ“ฆ CLI tool version
318
-
1
+ # ๐Ÿ“ฆ @esslassi/electron-printer
2
+
3
+ Cross-platform native printer driver for **Windows, macOS, and Linux**, built with Node-API (N-API).
4
+ Works in **Node.js** and **Electron**.
5
+
6
+ Supports:
7
+
8
+ * ๐Ÿ–จ List printers
9
+ * ๐Ÿ“„ Print raw/text/command data
10
+ * ๐Ÿ“ Print files
11
+ * ๐Ÿ“‹ Get printer driver options
12
+ * ๐Ÿ“‘ Get selected paper size
13
+ * ๐Ÿ“ฆ Get job status
14
+ * โ›” Cancel / pause / resume jobs
15
+ * ๐Ÿ”„ Promise (async/await) wrappers included
16
+
17
+ ---
18
+
19
+ ## ๐Ÿš€ Installation
20
+
21
+ ```bash
22
+ npm install @esslassi/electron-printer
23
+ ```
24
+
25
+ If using Electron:
26
+
27
+ ```bash
28
+ npx electron-rebuild
29
+ ```
30
+
31
+ ---
32
+
33
+ ## ๐Ÿงฉ Supported Platforms
34
+
35
+ | OS | Backend |
36
+ | ------- | ------------ |
37
+ | Windows | WinSpool API |
38
+ | macOS | CUPS |
39
+ | Linux | CUPS |
40
+
41
+ ---
42
+
43
+ # ๐Ÿ“– Usage
44
+
45
+ ```ts
46
+ import * as printer from '@esslassi/electron-printer'
47
+ ```
48
+
49
+ ---
50
+
51
+ # ๐Ÿ–จ Printer Management
52
+
53
+ ### Get all printers
54
+
55
+ ```ts
56
+ const printers = printer.getPrinters()
57
+ ```
58
+
59
+ ### Async version
60
+
61
+ ```ts
62
+ const printers = await printer.getPrintersAsync()
63
+ ```
64
+
65
+ ---
66
+
67
+ ### Get single printer
68
+
69
+ ```ts
70
+ const details = printer.getPrinter("My Printer")
71
+ ```
72
+
73
+ ---
74
+
75
+ ### Get default printer
76
+
77
+ ```ts
78
+ const defaultPrinter = printer.getDefaultPrinterName()
79
+ ```
80
+
81
+ ---
82
+
83
+ ### Get printer driver options
84
+
85
+ ```ts
86
+ const options = printer.getPrinterDriverOptions("My Printer")
87
+ ```
88
+
89
+ ---
90
+
91
+ ### Get selected paper size
92
+
93
+ ```ts
94
+ const paper = printer.getSelectedPaperSize("My Printer")
95
+ ```
96
+
97
+ ---
98
+
99
+ # ๐Ÿ–จ Printing
100
+
101
+ ---
102
+
103
+ ## ๐ŸŸข Print Raw/Text Data (Callback)
104
+
105
+ ```ts
106
+ printer.printDirect({
107
+ data: "Hello Printer\n\n",
108
+ printer: "My Printer",
109
+ type: "RAW",
110
+ success: (jobId) => {
111
+ console.log("Printed. Job ID:", jobId)
112
+ },
113
+ error: (err) => {
114
+ console.error("Print error:", err)
115
+ }
116
+ })
117
+ ```
118
+
119
+ ---
120
+
121
+ ## ๐ŸŸข Print Raw/Text Data (Async/Await)
122
+
123
+ ```ts
124
+ const jobId = await printer.printDirectAsync({
125
+ data: Buffer.from("Hello Printer\n\n"),
126
+ printer: "My Printer",
127
+ type: "RAW"
128
+ })
129
+
130
+ console.log("Printed. Job ID:", jobId)
131
+ ```
132
+
133
+ ---
134
+
135
+ ## ๐ŸŸข Print File (Callback)
136
+
137
+ ```ts
138
+ printer.printFile({
139
+ filename: "./file.txt",
140
+ printer: "My Printer",
141
+ success: (jobId) => console.log(jobId),
142
+ error: (err) => console.error(err)
143
+ })
144
+ ```
145
+
146
+ ---
147
+
148
+ ## ๐ŸŸข Print File (Async)
149
+
150
+ ```ts
151
+ const jobId = await printer.printFileAsync({
152
+ filename: "./file.txt",
153
+ printer: "My Printer"
154
+ })
155
+ ```
156
+
157
+ ---
158
+
159
+ # ๐Ÿ“ฆ Job Management
160
+
161
+ ---
162
+
163
+ ## Get Job Details
164
+
165
+ ```ts
166
+ const job = printer.getJob("My Printer", 42)
167
+ ```
168
+
169
+ ### Async
170
+
171
+ ```ts
172
+ const job = await printer.getJobAsync("My Printer", 42)
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Cancel / Pause / Resume Job
178
+
179
+ ```ts
180
+ printer.setJob("My Printer", 42, "CANCEL")
181
+ printer.setJob("My Printer", 42, "PAUSE")
182
+ printer.setJob("My Printer", 42, "RESUME")
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Get Supported Job Commands
188
+
189
+ ```ts
190
+ const commands = printer.getSupportedJobCommands()
191
+ ```
192
+
193
+ ---
194
+
195
+ # ๐Ÿ“„ Supported Print Formats
196
+
197
+ ```ts
198
+ const formats = printer.getSupportedPrintFormats()
199
+ ```
200
+
201
+ Typical values:
202
+
203
+ * `RAW`
204
+ * `TEXT`
205
+ * `COMMAND`
206
+ * `AUTO`
207
+
208
+ > Windows supports RAW/TEXT/COMMAND directly.
209
+ > macOS/Linux support additional formats via CUPS.
210
+
211
+ ---
212
+
213
+ # ๐Ÿง  TypeScript Types
214
+
215
+ Fully typed. Example:
216
+
217
+ ```ts
218
+ export interface PrintDirectOptions {
219
+ data: string | Buffer
220
+ printer?: string
221
+ type?: 'RAW' | 'TEXT' | 'COMMAND' | 'AUTO'
222
+ options?: { [key: string]: string }
223
+ }
224
+ ```
225
+
226
+ ---
227
+
228
+ # โšก Promise Wrappers Included
229
+
230
+ Built-in async wrappers:
231
+
232
+ * `printDirectAsync`
233
+ * `printFileAsync`
234
+ * `getPrintersAsync`
235
+ * `getPrinterAsync`
236
+ * `getJobAsync`
237
+
238
+ No extra wrapper needed.
239
+
240
+ ---
241
+
242
+ # ๐Ÿงช Example Full Test
243
+
244
+ ```ts
245
+ import * as printer from '@esslassi/electron-printer'
246
+
247
+ async function test() {
248
+ const printers = await printer.getPrintersAsync()
249
+ const defaultPrinter = printer.getDefaultPrinterName()
250
+
251
+ const jobId = await printer.printDirectAsync({
252
+ data: "Test print\n\n",
253
+ printer: defaultPrinter,
254
+ type: "RAW"
255
+ })
256
+
257
+ const job = await printer.getJobAsync(defaultPrinter!, Number(jobId))
258
+
259
+ console.log(job)
260
+ }
261
+
262
+ test()
263
+ ```
264
+
265
+ ---
266
+
267
+ # ๐Ÿ— Architecture
268
+
269
+ ```
270
+ Node.js / Electron
271
+ โ†“
272
+ N-API
273
+ โ†“
274
+ PrinterFactory
275
+ โ†“
276
+ Windows | macOS | Linux drivers
277
+ ```
278
+
279
+ Native C++ backend with platform-specific implementations.
280
+
281
+ ---
282
+
283
+ # ๐Ÿ”ง Development
284
+
285
+ Build from source:
286
+
287
+ ```bash
288
+ npx node-gyp rebuild
289
+ ```
290
+
291
+ Electron:
292
+
293
+ ```bash
294
+ npx electron-rebuild
295
+ ```
296
+
297
+ ---
298
+
299
+ # ๐Ÿ“œ License
300
+
301
+ MIT
302
+
303
+ ---
304
+
305
+ # ๐Ÿ‘จโ€๐Ÿ’ป Author
306
+
307
+ Esslassi
308
+
309
+ ---
310
+
311
+ If you want, I can also generate:
312
+
313
+ * ๐Ÿ”ฅ NPM package.json template
314
+ * ๐Ÿงฑ binding.gyp optimized version
315
+ * โšก Prebuild support (no node-gyp required for users)
316
+ * ๐Ÿงช Jest test suite
317
+ * ๐Ÿ“ฆ CLI tool version
318
+
319
319
  Tell me the next step ๐Ÿš€