@m430/capacitor-label-printer 0.1.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.
Files changed (150) hide show
  1. package/API.md +218 -0
  2. package/LICENSE +21 -0
  3. package/M430CapacitorLabelPrinter.podspec +21 -0
  4. package/README.md +190 -0
  5. package/android/build.gradle +46 -0
  6. package/android/libs/.gitkeep +1 -0
  7. package/android/libs/fat-generic-tspl-bluetooth-classic-0.1.16-GA.jar +0 -0
  8. package/android/src/main/AndroidManifest.xml +12 -0
  9. package/android/src/main/java/com/m430/capacitor/labelprinter/.gitkeep +1 -0
  10. package/android/src/main/java/com/m430/capacitor/labelprinter/AndroidPrinterManager.java +132 -0
  11. package/android/src/main/java/com/m430/capacitor/labelprinter/AndroidStatusMapper.java +54 -0
  12. package/android/src/main/java/com/m430/capacitor/labelprinter/LabelPrinterPlugin.java +273 -0
  13. package/android/src/main/java/com/m430/capacitor/labelprinter/VendorAndroidDeviceCatalog.java +81 -0
  14. package/android/src/main/java/com/m430/capacitor/labelprinter/VendorAndroidPrinterSession.java +189 -0
  15. package/capacitor-label-printer.podspec +21 -0
  16. package/dist/docs.json +443 -0
  17. package/dist/esm/cpcl/builder.d.ts +10 -0
  18. package/dist/esm/cpcl/builder.js +35 -0
  19. package/dist/esm/definitions.d.ts +107 -0
  20. package/dist/esm/definitions.js +1 -0
  21. package/dist/esm/errors.d.ts +1 -0
  22. package/dist/esm/errors.js +1 -0
  23. package/dist/esm/index.d.ts +9 -0
  24. package/dist/esm/index.js +11 -0
  25. package/dist/esm/tspl/builder.d.ts +13 -0
  26. package/dist/esm/tspl/builder.js +45 -0
  27. package/dist/esm/tspl/helpers.d.ts +2 -0
  28. package/dist/esm/tspl/helpers.js +6 -0
  29. package/dist/esm/types.d.ts +12 -0
  30. package/dist/esm/types.js +1 -0
  31. package/dist/esm/web.d.ts +21 -0
  32. package/dist/esm/web.js +34 -0
  33. package/dist/plugin.cjs.js +143 -0
  34. package/dist/plugin.cjs.js.map +1 -0
  35. package/dist/plugin.js +136 -0
  36. package/dist/plugin.js.map +1 -0
  37. package/ios/Plugin/.gitkeep +1 -0
  38. package/ios/Plugin/IOSPrinterManager.swift +230 -0
  39. package/ios/Plugin/IOSStatusMapper.swift +57 -0
  40. package/ios/Plugin/LabelPrinterPlugin.swift +141 -0
  41. package/ios/VendorFrameworks/.gitkeep +1 -0
  42. package/ios/VendorFrameworks/adapter.framework/Headers/BasedOtherConnectedDevice.h +17 -0
  43. package/ios/VendorFrameworks/adapter.framework/Headers/ConnectedDevice.h +213 -0
  44. package/ios/VendorFrameworks/adapter.framework/Headers/IPRTBlueToothBaseDef.h +22 -0
  45. package/ios/VendorFrameworks/adapter.framework/Headers/KeepStateConnectedDevice.h +18 -0
  46. package/ios/VendorFrameworks/adapter.framework/Headers/QueueConfig.h +18 -0
  47. package/ios/VendorFrameworks/adapter.framework/Headers/ReadOptions.h +22 -0
  48. package/ios/VendorFrameworks/adapter.framework/Headers/WroteReporter.h +23 -0
  49. package/ios/VendorFrameworks/adapter.framework/Headers/adapter.h +18 -0
  50. package/ios/VendorFrameworks/adapter.framework/Info.plist +0 -0
  51. package/ios/VendorFrameworks/adapter.framework/Modules/module.modulemap +6 -0
  52. package/ios/VendorFrameworks/adapter.framework/adapter +0 -0
  53. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/Info.plist +0 -0
  54. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/_CodeSignature/CodeResources +101 -0
  55. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/adapter +0 -0
  56. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Frameworks/adapter.framework/Info.plist +0 -0
  57. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Frameworks/adapter.framework/adapter +0 -0
  58. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Info.plist +0 -0
  59. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/_CodeSignature/CodeResources +132 -0
  60. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/ibridge +0 -0
  61. package/ios/VendorFrameworks/appleble.framework/Headers/AppleBle.h +25 -0
  62. package/ios/VendorFrameworks/appleble.framework/Info.plist +0 -0
  63. package/ios/VendorFrameworks/appleble.framework/Modules/module.modulemap +6 -0
  64. package/ios/VendorFrameworks/appleble.framework/_CodeSignature/CodeResources +252 -0
  65. package/ios/VendorFrameworks/appleble.framework/appleble +0 -0
  66. package/ios/VendorFrameworks/father.framework/Frameworks/adapter.framework/Info.plist +0 -0
  67. package/ios/VendorFrameworks/father.framework/Frameworks/adapter.framework/adapter +0 -0
  68. package/ios/VendorFrameworks/father.framework/Headers/Appendat.h +28 -0
  69. package/ios/VendorFrameworks/father.framework/Headers/Arg.h +22 -0
  70. package/ios/VendorFrameworks/father.framework/Headers/BasicBatteryVolumeArg.h +16 -0
  71. package/ios/VendorFrameworks/father.framework/Headers/BinaryCommand.h +17 -0
  72. package/ios/VendorFrameworks/father.framework/Headers/CPCLCommand.h +10 -0
  73. package/ios/VendorFrameworks/father.framework/Headers/CallbackData.h +26 -0
  74. package/ios/VendorFrameworks/father.framework/Headers/Checker.h +16 -0
  75. package/ios/VendorFrameworks/father.framework/Headers/Command.h +25 -0
  76. package/ios/VendorFrameworks/father.framework/Headers/CommandClause.h +33 -0
  77. package/ios/VendorFrameworks/father.framework/Headers/Commander.h +31 -0
  78. package/ios/VendorFrameworks/father.framework/Headers/DataWriteOperation.h +42 -0
  79. package/ios/VendorFrameworks/father.framework/Headers/DefaultCommand.h +16 -0
  80. package/ios/VendorFrameworks/father.framework/Headers/EasyArg.h +16 -0
  81. package/ios/VendorFrameworks/father.framework/Headers/FastBinary.h +20 -0
  82. package/ios/VendorFrameworks/father.framework/Headers/HexOutput.h +19 -0
  83. package/ios/VendorFrameworks/father.framework/Headers/IDataWriteCallback.h +25 -0
  84. package/ios/VendorFrameworks/father.framework/Headers/Lifecycle.h +21 -0
  85. package/ios/VendorFrameworks/father.framework/Headers/NewLineArg.h +15 -0
  86. package/ios/VendorFrameworks/father.framework/Headers/OnlyBinaryHeaderArg.h +15 -0
  87. package/ios/VendorFrameworks/father.framework/Headers/OnlyTextHeaderArg.h +16 -0
  88. package/ios/VendorFrameworks/father.framework/Headers/PImageTool.h +22 -0
  89. package/ios/VendorFrameworks/father.framework/Headers/PReplaceKit.h +16 -0
  90. package/ios/VendorFrameworks/father.framework/Headers/PSDK.h +60 -0
  91. package/ios/VendorFrameworks/father.framework/Headers/PVariableKit.h +18 -0
  92. package/ios/VendorFrameworks/father.framework/Headers/PsdkConst.h +33 -0
  93. package/ios/VendorFrameworks/father.framework/Headers/Raw.h +22 -0
  94. package/ios/VendorFrameworks/father.framework/Headers/SimpleCheck.h +16 -0
  95. package/ios/VendorFrameworks/father.framework/Headers/SingleCommand.h +32 -0
  96. package/ios/VendorFrameworks/father.framework/Headers/TSPLCommand.h +10 -0
  97. package/ios/VendorFrameworks/father.framework/Headers/WriteControl.h +12 -0
  98. package/ios/VendorFrameworks/father.framework/Headers/WriteOptions.h +28 -0
  99. package/ios/VendorFrameworks/father.framework/Headers/father.h +21 -0
  100. package/ios/VendorFrameworks/father.framework/Info.plist +0 -0
  101. package/ios/VendorFrameworks/father.framework/Modules/module.modulemap +6 -0
  102. package/ios/VendorFrameworks/father.framework/father +0 -0
  103. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Frameworks/adapter.framework/Info.plist +0 -0
  104. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Frameworks/adapter.framework/adapter +0 -0
  105. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Info.plist +0 -0
  106. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/father +0 -0
  107. package/ios/VendorFrameworks/tspl.framework/Headers/BasicTSPL.h +146 -0
  108. package/ios/VendorFrameworks/tspl.framework/Headers/BasicTSPLArg.h +17 -0
  109. package/ios/VendorFrameworks/tspl.framework/Headers/GenericTSPL.h +16 -0
  110. package/ios/VendorFrameworks/tspl.framework/Headers/TBar.h +30 -0
  111. package/ios/VendorFrameworks/tspl.framework/Headers/TBarCode.h +54 -0
  112. package/ios/VendorFrameworks/tspl.framework/Headers/TBatteryVolume.h +19 -0
  113. package/ios/VendorFrameworks/tspl.framework/Headers/TBox.h +32 -0
  114. package/ios/VendorFrameworks/tspl.framework/Headers/TCircle.h +26 -0
  115. package/ios/VendorFrameworks/tspl.framework/Headers/TCleanBmpFlash.h +20 -0
  116. package/ios/VendorFrameworks/tspl.framework/Headers/TClear.h +20 -0
  117. package/ios/VendorFrameworks/tspl.framework/Headers/TCut.h +21 -0
  118. package/ios/VendorFrameworks/tspl.framework/Headers/TDensity.h +21 -0
  119. package/ios/VendorFrameworks/tspl.framework/Headers/TDirection.h +51 -0
  120. package/ios/VendorFrameworks/tspl.framework/Headers/TDmatrix.h +29 -0
  121. package/ios/VendorFrameworks/tspl.framework/Headers/TDownloadBmpFlash.h +16 -0
  122. package/ios/VendorFrameworks/tspl.framework/Headers/TGap.h +21 -0
  123. package/ios/VendorFrameworks/tspl.framework/Headers/TImage.h +36 -0
  124. package/ios/VendorFrameworks/tspl.framework/Headers/TLine.h +34 -0
  125. package/ios/VendorFrameworks/tspl.framework/Headers/TMddle.h +16 -0
  126. package/ios/VendorFrameworks/tspl.framework/Headers/TPage.h +22 -0
  127. package/ios/VendorFrameworks/tspl.framework/Headers/TPrint.h +21 -0
  128. package/ios/VendorFrameworks/tspl.framework/Headers/TQRCode.h +35 -0
  129. package/ios/VendorFrameworks/tspl.framework/Headers/TReadState.h +16 -0
  130. package/ios/VendorFrameworks/tspl.framework/Headers/TReverse.h +27 -0
  131. package/ios/VendorFrameworks/tspl.framework/Headers/TSN.h +19 -0
  132. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLCodeType.h +53 -0
  133. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLCorrectLevel.h +21 -0
  134. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLFont.h +83 -0
  135. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLImageMode.h +30 -0
  136. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLLineMode.h +37 -0
  137. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLLineType.h +21 -0
  138. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLOutDirection.h +27 -0
  139. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLRotation.h +36 -0
  140. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLShowType.h +36 -0
  141. package/ios/VendorFrameworks/tspl.framework/Headers/TSPL_.h +18 -0
  142. package/ios/VendorFrameworks/tspl.framework/Headers/TSpeed.h +20 -0
  143. package/ios/VendorFrameworks/tspl.framework/Headers/TText.h +38 -0
  144. package/ios/VendorFrameworks/tspl.framework/Headers/TTextBox.h +44 -0
  145. package/ios/VendorFrameworks/tspl.framework/Headers/TVersion.h +19 -0
  146. package/ios/VendorFrameworks/tspl.framework/Headers/tspl.h +45 -0
  147. package/ios/VendorFrameworks/tspl.framework/Info.plist +0 -0
  148. package/ios/VendorFrameworks/tspl.framework/Modules/module.modulemap +6 -0
  149. package/ios/VendorFrameworks/tspl.framework/tspl +0 -0
  150. package/package.json +95 -0
package/dist/docs.json ADDED
@@ -0,0 +1,443 @@
1
+ {
2
+ "api": {
3
+ "name": "LabelPrinterPlugin",
4
+ "slug": "labelprinterplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "isSupported",
10
+ "signature": "() => Promise<{ supported: boolean; }>",
11
+ "parameters": [],
12
+ "returns": "Promise<{ supported: boolean; }>",
13
+ "tags": [],
14
+ "docs": "判断当前运行环境是否支持原生标签打印。",
15
+ "complexTypes": [],
16
+ "slug": "issupported"
17
+ },
18
+ {
19
+ "name": "checkPermissions",
20
+ "signature": "() => Promise<PrinterPermissionResult>",
21
+ "parameters": [],
22
+ "returns": "Promise<PrinterPermissionResult>",
23
+ "tags": [],
24
+ "docs": "查询当前蓝牙访问权限状态。",
25
+ "complexTypes": [
26
+ "PrinterPermissionResult"
27
+ ],
28
+ "slug": "checkpermissions"
29
+ },
30
+ {
31
+ "name": "ensurePermissions",
32
+ "signature": "() => Promise<PrinterPermissionResult>",
33
+ "parameters": [],
34
+ "returns": "Promise<PrinterPermissionResult>",
35
+ "tags": [],
36
+ "docs": "确保蓝牙访问权限已就绪。",
37
+ "complexTypes": [
38
+ "PrinterPermissionResult"
39
+ ],
40
+ "slug": "ensurepermissions"
41
+ },
42
+ {
43
+ "name": "discoverDevices",
44
+ "signature": "(options?: DiscoverDevicesOptions | undefined) => Promise<{ devices: PrinterDevice[]; }>",
45
+ "parameters": [
46
+ {
47
+ "name": "options",
48
+ "docs": "",
49
+ "type": "DiscoverDevicesOptions | undefined"
50
+ }
51
+ ],
52
+ "returns": "Promise<{ devices: PrinterDevice[]; }>",
53
+ "tags": [],
54
+ "docs": "发现可用于连接的打印机列表。",
55
+ "complexTypes": [
56
+ "PrinterDevice",
57
+ "DiscoverDevicesOptions"
58
+ ],
59
+ "slug": "discoverdevices"
60
+ },
61
+ {
62
+ "name": "connect",
63
+ "signature": "(options: ConnectOptions) => Promise<void>",
64
+ "parameters": [
65
+ {
66
+ "name": "options",
67
+ "docs": "",
68
+ "type": "ConnectOptions"
69
+ }
70
+ ],
71
+ "returns": "Promise<void>",
72
+ "tags": [],
73
+ "docs": "连接指定打印机。",
74
+ "complexTypes": [
75
+ "ConnectOptions"
76
+ ],
77
+ "slug": "connect"
78
+ },
79
+ {
80
+ "name": "disconnect",
81
+ "signature": "() => Promise<void>",
82
+ "parameters": [],
83
+ "returns": "Promise<void>",
84
+ "tags": [],
85
+ "docs": "断开当前打印机连接。",
86
+ "complexTypes": [],
87
+ "slug": "disconnect"
88
+ },
89
+ {
90
+ "name": "getConnectionState",
91
+ "signature": "() => Promise<{ state: PrinterConnectionState; }>",
92
+ "parameters": [],
93
+ "returns": "Promise<{ state: PrinterConnectionState; }>",
94
+ "tags": [],
95
+ "docs": "查询当前连接状态。",
96
+ "complexTypes": [
97
+ "PrinterConnectionState"
98
+ ],
99
+ "slug": "getconnectionstate"
100
+ },
101
+ {
102
+ "name": "print",
103
+ "signature": "(options: PrintOptions) => Promise<void>",
104
+ "parameters": [
105
+ {
106
+ "name": "options",
107
+ "docs": "",
108
+ "type": "PrintOptions"
109
+ }
110
+ ],
111
+ "returns": "Promise<void>",
112
+ "tags": [],
113
+ "docs": "发送原始打印负载到打印机。",
114
+ "complexTypes": [
115
+ "PrintOptions"
116
+ ],
117
+ "slug": "print"
118
+ },
119
+ {
120
+ "name": "getStatus",
121
+ "signature": "() => Promise<PrinterStatus>",
122
+ "parameters": [],
123
+ "returns": "Promise<PrinterStatus>",
124
+ "tags": [],
125
+ "docs": "查询当前打印机状态。",
126
+ "complexTypes": [
127
+ "PrinterStatus"
128
+ ],
129
+ "slug": "getstatus"
130
+ },
131
+ {
132
+ "name": "openAppSettings",
133
+ "signature": "() => Promise<void>",
134
+ "parameters": [],
135
+ "returns": "Promise<void>",
136
+ "tags": [],
137
+ "docs": "跳转到应用系统设置页。",
138
+ "complexTypes": [],
139
+ "slug": "openappsettings"
140
+ }
141
+ ],
142
+ "properties": []
143
+ },
144
+ "interfaces": [
145
+ {
146
+ "name": "PrinterPermissionResult",
147
+ "slug": "printerpermissionresult",
148
+ "docs": "插件统一输出的权限状态。",
149
+ "tags": [],
150
+ "methods": [],
151
+ "properties": [
152
+ {
153
+ "name": "granted",
154
+ "tags": [],
155
+ "docs": "",
156
+ "complexTypes": [],
157
+ "type": "boolean"
158
+ },
159
+ {
160
+ "name": "canPrompt",
161
+ "tags": [],
162
+ "docs": "",
163
+ "complexTypes": [],
164
+ "type": "boolean"
165
+ },
166
+ {
167
+ "name": "shouldOpenSettings",
168
+ "tags": [],
169
+ "docs": "",
170
+ "complexTypes": [],
171
+ "type": "boolean"
172
+ },
173
+ {
174
+ "name": "permissions",
175
+ "tags": [],
176
+ "docs": "",
177
+ "complexTypes": [
178
+ "PermissionState"
179
+ ],
180
+ "type": "{ bluetoothConnect?: PermissionState | undefined; bluetoothScan?: PermissionState | undefined; bluetooth?: PermissionState | undefined; }"
181
+ }
182
+ ]
183
+ },
184
+ {
185
+ "name": "PrinterDevice",
186
+ "slug": "printerdevice",
187
+ "docs": "扫描或枚举到的标签打印机设备。",
188
+ "tags": [],
189
+ "methods": [],
190
+ "properties": [
191
+ {
192
+ "name": "id",
193
+ "tags": [],
194
+ "docs": "",
195
+ "complexTypes": [],
196
+ "type": "string"
197
+ },
198
+ {
199
+ "name": "name",
200
+ "tags": [],
201
+ "docs": "",
202
+ "complexTypes": [],
203
+ "type": "string"
204
+ },
205
+ {
206
+ "name": "address",
207
+ "tags": [],
208
+ "docs": "",
209
+ "complexTypes": [],
210
+ "type": "string | undefined"
211
+ },
212
+ {
213
+ "name": "transport",
214
+ "tags": [],
215
+ "docs": "",
216
+ "complexTypes": [
217
+ "PrinterTransport"
218
+ ],
219
+ "type": "PrinterTransport"
220
+ },
221
+ {
222
+ "name": "bonded",
223
+ "tags": [],
224
+ "docs": "",
225
+ "complexTypes": [],
226
+ "type": "boolean | undefined"
227
+ },
228
+ {
229
+ "name": "rssi",
230
+ "tags": [],
231
+ "docs": "",
232
+ "complexTypes": [],
233
+ "type": "number | undefined"
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ "name": "DiscoverDevicesOptions",
239
+ "slug": "discoverdevicesoptions",
240
+ "docs": "发现设备时使用的过滤参数。",
241
+ "tags": [],
242
+ "methods": [],
243
+ "properties": [
244
+ {
245
+ "name": "timeout",
246
+ "tags": [],
247
+ "docs": "",
248
+ "complexTypes": [],
249
+ "type": "number | undefined"
250
+ },
251
+ {
252
+ "name": "namePrefixes",
253
+ "tags": [],
254
+ "docs": "",
255
+ "complexTypes": [],
256
+ "type": "string[] | undefined"
257
+ }
258
+ ]
259
+ },
260
+ {
261
+ "name": "ConnectOptions",
262
+ "slug": "connectoptions",
263
+ "docs": "连接指定设备时使用的参数。",
264
+ "tags": [],
265
+ "methods": [],
266
+ "properties": [
267
+ {
268
+ "name": "deviceId",
269
+ "tags": [],
270
+ "docs": "",
271
+ "complexTypes": [],
272
+ "type": "string"
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ "name": "PrintOptions",
278
+ "slug": "printoptions",
279
+ "docs": "打印任务参数。",
280
+ "tags": [],
281
+ "methods": [],
282
+ "properties": [
283
+ {
284
+ "name": "payload",
285
+ "tags": [],
286
+ "docs": "",
287
+ "complexTypes": [],
288
+ "type": "string"
289
+ },
290
+ {
291
+ "name": "language",
292
+ "tags": [],
293
+ "docs": "",
294
+ "complexTypes": [
295
+ "PrinterLanguage"
296
+ ],
297
+ "type": "PrinterLanguage"
298
+ },
299
+ {
300
+ "name": "copies",
301
+ "tags": [],
302
+ "docs": "",
303
+ "complexTypes": [],
304
+ "type": "number | undefined"
305
+ }
306
+ ]
307
+ },
308
+ {
309
+ "name": "PrinterStatus",
310
+ "slug": "printerstatus",
311
+ "docs": "插件统一输出的打印机状态。",
312
+ "tags": [],
313
+ "methods": [],
314
+ "properties": [
315
+ {
316
+ "name": "connected",
317
+ "tags": [],
318
+ "docs": "",
319
+ "complexTypes": [],
320
+ "type": "boolean"
321
+ },
322
+ {
323
+ "name": "ready",
324
+ "tags": [],
325
+ "docs": "",
326
+ "complexTypes": [],
327
+ "type": "boolean | undefined"
328
+ },
329
+ {
330
+ "name": "paperOut",
331
+ "tags": [],
332
+ "docs": "",
333
+ "complexTypes": [],
334
+ "type": "boolean | undefined"
335
+ },
336
+ {
337
+ "name": "coverOpen",
338
+ "tags": [],
339
+ "docs": "",
340
+ "complexTypes": [],
341
+ "type": "boolean | undefined"
342
+ },
343
+ {
344
+ "name": "overheating",
345
+ "tags": [],
346
+ "docs": "",
347
+ "complexTypes": [],
348
+ "type": "boolean | undefined"
349
+ },
350
+ {
351
+ "name": "message",
352
+ "tags": [],
353
+ "docs": "",
354
+ "complexTypes": [],
355
+ "type": "string | undefined"
356
+ },
357
+ {
358
+ "name": "raw",
359
+ "tags": [],
360
+ "docs": "",
361
+ "complexTypes": [],
362
+ "type": "unknown"
363
+ }
364
+ ]
365
+ }
366
+ ],
367
+ "enums": [],
368
+ "typeAliases": [
369
+ {
370
+ "name": "PermissionState",
371
+ "slug": "permissionstate",
372
+ "docs": "",
373
+ "types": [
374
+ {
375
+ "text": "\"denied\"",
376
+ "complexTypes": []
377
+ },
378
+ {
379
+ "text": "\"granted\"",
380
+ "complexTypes": []
381
+ },
382
+ {
383
+ "text": "\"prompt\"",
384
+ "complexTypes": []
385
+ }
386
+ ]
387
+ },
388
+ {
389
+ "name": "PrinterTransport",
390
+ "slug": "printertransport",
391
+ "docs": "插件内部约定的连接通道类型。",
392
+ "types": [
393
+ {
394
+ "text": "'classic'",
395
+ "complexTypes": []
396
+ },
397
+ {
398
+ "text": "'ble'",
399
+ "complexTypes": []
400
+ }
401
+ ]
402
+ },
403
+ {
404
+ "name": "PrinterConnectionState",
405
+ "slug": "printerconnectionstate",
406
+ "docs": "统一连接状态枚举。",
407
+ "types": [
408
+ {
409
+ "text": "'disconnected'",
410
+ "complexTypes": []
411
+ },
412
+ {
413
+ "text": "'connecting'",
414
+ "complexTypes": []
415
+ },
416
+ {
417
+ "text": "'connected'",
418
+ "complexTypes": []
419
+ }
420
+ ]
421
+ },
422
+ {
423
+ "name": "PrinterLanguage",
424
+ "slug": "printerlanguage",
425
+ "docs": "打印负载的协议类型。",
426
+ "types": [
427
+ {
428
+ "text": "'tspl'",
429
+ "complexTypes": []
430
+ },
431
+ {
432
+ "text": "'cpcl'",
433
+ "complexTypes": []
434
+ },
435
+ {
436
+ "text": "'raw'",
437
+ "complexTypes": []
438
+ }
439
+ ]
440
+ }
441
+ ],
442
+ "pluginConfigs": []
443
+ }
@@ -0,0 +1,10 @@
1
+ export declare class CpclBuilder {
2
+ private readonly lines;
3
+ page(height: number, copies?: number, offset?: number, horizontalDpi?: number, verticalDpi?: number): this;
4
+ pageWidth(width: number): this;
5
+ text(font: number, rotation: number, x: number, y: number, value: string): this;
6
+ barcode128(x: number, y: number, height: number, value: string, narrow?: number, wide?: number): this;
7
+ form(): this;
8
+ print(): this;
9
+ build(): string;
10
+ }
@@ -0,0 +1,35 @@
1
+ function escapeCpclText(value) {
2
+ return value.replace(/[\r\n]+/g, ' ').trim();
3
+ }
4
+ export class CpclBuilder {
5
+ constructor() {
6
+ this.lines = [];
7
+ }
8
+ page(height, copies = 1, offset = 0, horizontalDpi = 200, verticalDpi = 200) {
9
+ this.lines.push(`! ${offset} ${horizontalDpi} ${verticalDpi} ${height} ${copies}`);
10
+ return this;
11
+ }
12
+ pageWidth(width) {
13
+ this.lines.push(`PAGE-WIDTH ${width}`);
14
+ return this;
15
+ }
16
+ text(font, rotation, x, y, value) {
17
+ this.lines.push(`TEXT ${font} ${rotation} ${x} ${y} ${escapeCpclText(value)}`);
18
+ return this;
19
+ }
20
+ barcode128(x, y, height, value, narrow = 1, wide = 1) {
21
+ this.lines.push(`BARCODE 128 ${narrow} ${wide} ${height} ${x} ${y} ${escapeCpclText(value)}`);
22
+ return this;
23
+ }
24
+ form() {
25
+ this.lines.push('FORM');
26
+ return this;
27
+ }
28
+ print() {
29
+ this.lines.push('PRINT');
30
+ return this;
31
+ }
32
+ build() {
33
+ return `${this.lines.join('\n')}\n`;
34
+ }
35
+ }
@@ -0,0 +1,107 @@
1
+ import type { PermissionState } from '@capacitor/core';
2
+ import type { PrinterConnectionState, PrinterLanguage, PrinterTransport } from './types';
3
+ /**
4
+ * 扫描或枚举到的标签打印机设备。
5
+ */
6
+ export interface PrinterDevice {
7
+ id: string;
8
+ name: string;
9
+ address?: string;
10
+ transport: PrinterTransport;
11
+ bonded?: boolean;
12
+ rssi?: number;
13
+ }
14
+ /**
15
+ * 发现设备时使用的过滤参数。
16
+ */
17
+ export interface DiscoverDevicesOptions {
18
+ timeout?: number;
19
+ namePrefixes?: string[];
20
+ }
21
+ /**
22
+ * 连接指定设备时使用的参数。
23
+ */
24
+ export interface ConnectOptions {
25
+ deviceId: string;
26
+ }
27
+ /**
28
+ * 打印任务参数。
29
+ */
30
+ export interface PrintOptions {
31
+ payload: string;
32
+ language?: PrinterLanguage;
33
+ copies?: number;
34
+ }
35
+ /**
36
+ * 插件统一输出的打印机状态。
37
+ */
38
+ export interface PrinterStatus {
39
+ connected: boolean;
40
+ ready?: boolean;
41
+ paperOut?: boolean;
42
+ coverOpen?: boolean;
43
+ overheating?: boolean;
44
+ message?: string;
45
+ raw?: unknown;
46
+ }
47
+ /**
48
+ * 插件统一输出的权限状态。
49
+ */
50
+ export interface PrinterPermissionResult {
51
+ granted: boolean;
52
+ canPrompt: boolean;
53
+ shouldOpenSettings: boolean;
54
+ permissions: {
55
+ bluetoothConnect?: PermissionState;
56
+ bluetoothScan?: PermissionState;
57
+ bluetooth?: PermissionState;
58
+ };
59
+ }
60
+ export interface LabelPrinterPlugin {
61
+ /**
62
+ * 判断当前运行环境是否支持原生标签打印。
63
+ */
64
+ isSupported(): Promise<{
65
+ supported: boolean;
66
+ }>;
67
+ /**
68
+ * 查询当前蓝牙访问权限状态。
69
+ */
70
+ checkPermissions(): Promise<PrinterPermissionResult>;
71
+ /**
72
+ * 确保蓝牙访问权限已就绪。
73
+ */
74
+ ensurePermissions(): Promise<PrinterPermissionResult>;
75
+ /**
76
+ * 发现可用于连接的打印机列表。
77
+ */
78
+ discoverDevices(options?: DiscoverDevicesOptions): Promise<{
79
+ devices: PrinterDevice[];
80
+ }>;
81
+ /**
82
+ * 连接指定打印机。
83
+ */
84
+ connect(options: ConnectOptions): Promise<void>;
85
+ /**
86
+ * 断开当前打印机连接。
87
+ */
88
+ disconnect(): Promise<void>;
89
+ /**
90
+ * 查询当前连接状态。
91
+ */
92
+ getConnectionState(): Promise<{
93
+ state: PrinterConnectionState;
94
+ }>;
95
+ /**
96
+ * 发送原始打印负载到打印机。
97
+ */
98
+ print(options: PrintOptions): Promise<void>;
99
+ /**
100
+ * 查询当前打印机状态。
101
+ */
102
+ getStatus(): Promise<PrinterStatus>;
103
+ /**
104
+ * 跳转到应用系统设置页。
105
+ */
106
+ openAppSettings(): Promise<void>;
107
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const UNSUPPORTED_WEB_ERROR = "Label printing is not supported on web.";
@@ -0,0 +1 @@
1
+ export const UNSUPPORTED_WEB_ERROR = 'Label printing is not supported on web.';
@@ -0,0 +1,9 @@
1
+ import type { LabelPrinterPlugin } from './definitions';
2
+ declare const LabelPrinter: LabelPrinterPlugin;
3
+ export * from './definitions';
4
+ export * from './errors';
5
+ export * from './types';
6
+ export * from './cpcl/builder';
7
+ export * from './tspl/builder';
8
+ export * from './tspl/helpers';
9
+ export { LabelPrinter };
@@ -0,0 +1,11 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const LabelPrinter = registerPlugin('LabelPrinter', {
3
+ web: () => import('./web').then(m => new m.LabelPrinterWeb())
4
+ });
5
+ export * from './definitions';
6
+ export * from './errors';
7
+ export * from './types';
8
+ export * from './cpcl/builder';
9
+ export * from './tspl/builder';
10
+ export * from './tspl/helpers';
11
+ export { LabelPrinter };
@@ -0,0 +1,13 @@
1
+ export declare class TsplBuilder {
2
+ private readonly lines;
3
+ sizeMm(width: number, height: number): this;
4
+ gapMm(gap: number, offset: number): this;
5
+ density(level: number): this;
6
+ speed(level: number): this;
7
+ cls(): this;
8
+ text(x: number, y: number, font: string, rotation: number, xScale: number, yScale: number, value: string): this;
9
+ barcode128(x: number, y: number, height: number, value: string): this;
10
+ qrcode(x: number, y: number, cellWidth: number, value: string): this;
11
+ printCopies(copies: number): this;
12
+ build(): string;
13
+ }
@@ -0,0 +1,45 @@
1
+ import { escapeTsplText } from './helpers';
2
+ export class TsplBuilder {
3
+ constructor() {
4
+ this.lines = [];
5
+ }
6
+ sizeMm(width, height) {
7
+ this.lines.push(`SIZE ${width} mm,${height} mm`);
8
+ return this;
9
+ }
10
+ gapMm(gap, offset) {
11
+ this.lines.push(`GAP ${gap} mm,${offset} mm`);
12
+ return this;
13
+ }
14
+ density(level) {
15
+ this.lines.push(`DENSITY ${level}`);
16
+ return this;
17
+ }
18
+ speed(level) {
19
+ this.lines.push(`SPEED ${level}`);
20
+ return this;
21
+ }
22
+ cls() {
23
+ this.lines.push('CLS');
24
+ return this;
25
+ }
26
+ text(x, y, font, rotation, xScale, yScale, value) {
27
+ this.lines.push(`TEXT ${x},${y},"${font}",${rotation},${xScale},${yScale},"${escapeTsplText(value)}"`);
28
+ return this;
29
+ }
30
+ barcode128(x, y, height, value) {
31
+ this.lines.push(`BARCODE ${x},${y},"128",${height},1,0,2,2,"${escapeTsplText(value)}"`);
32
+ return this;
33
+ }
34
+ qrcode(x, y, cellWidth, value) {
35
+ this.lines.push(`QRCODE ${x},${y},L,${cellWidth},A,0,"${escapeTsplText(value)}"`);
36
+ return this;
37
+ }
38
+ printCopies(copies) {
39
+ this.lines.push(`PRINT 1,${copies}`);
40
+ return this;
41
+ }
42
+ build() {
43
+ return `${this.lines.join('\n')}\n`;
44
+ }
45
+ }
@@ -0,0 +1,2 @@
1
+ export declare function mmToDots(mm: number, dpi?: number): number;
2
+ export declare function escapeTsplText(value: string): string;
@@ -0,0 +1,6 @@
1
+ export function mmToDots(mm, dpi = 203) {
2
+ return Math.round((mm / 25.4) * dpi);
3
+ }
4
+ export function escapeTsplText(value) {
5
+ return value.replace(/"/g, '\\"');
6
+ }